[Qual] Uniformize code

This commit is contained in:
philippe grand 2015-12-12 10:59:02 +01:00
parent 4b9e87367f
commit de0a13ae8f
16 changed files with 69 additions and 66 deletions

View File

@ -73,7 +73,7 @@ if ($action == 'remises')
{
if (dolibarr_set_const($db, 'MARGIN_METHODE_FOR_DISCOUNT', $_POST['MARGIN_METHODE_FOR_DISCOUNT'], 'chaine', 0, '', $conf->entity) > 0)
{
setEventMessage($langs->trans("RecordModifiedSuccessfully"));
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
}
else
{
@ -85,7 +85,7 @@ if ($action == 'typemarges')
{
if (dolibarr_set_const($db, 'MARGIN_TYPE', $_POST['MARGIN_TYPE'], 'chaine', 0, '', $conf->entity) > 0)
{
setEventMessage($langs->trans("RecordModifiedSuccessfully"));
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
}
else
{
@ -97,7 +97,7 @@ if ($action == 'contact')
{
if (dolibarr_set_const($db, 'AGENT_CONTACT_TYPE', $_POST['AGENT_CONTACT_TYPE'], 'chaine', 0, '', $conf->entity) > 0)
{
setEventMessage($langs->trans("RecordModifiedSuccessfully"));
setEventMessages($langs->trans("RecordModifiedSuccessfully"), null, 'mesgs');
}
else
{

View File

@ -99,7 +99,7 @@ if ($action == 'update')
$res=$object->update($user);
if ($res < 0)
{
setEventMessage($object->error,'errors');
setEventMessages($object->error, $object->errors, 'errors');
$action='edit';
}
}
@ -131,7 +131,7 @@ if (GETPOST('ajoutcomment'))
if (! $resql)
{
setEventMessage($langs->trans('ErrorInsertingComment'), 'errors');
setEventMessages($langs->trans('ErrorInsertingComment'), null, 'errors');
}
}
}

View File

@ -91,7 +91,7 @@ if (GETPOST("boutonp") || GETPOST("boutonp.x") || GETPOST("boutonp_x")) // bout
$num_rows = $db->num_rows($resql);
if ($num_rows > 0)
{
setEventMessage($langs->trans("VoteNameAlreadyExists"),'errors');
setEventMessages($langs->trans("VoteNameAlreadyExists"), null, 'errors');
$error++;
}
else
@ -1024,11 +1024,11 @@ if (isset($_POST["boutonp"]) && $_POST["nom"] == "") {
}
if (isset($erreur_prenom) && $erreur_prenom) {
setEventMessage($langs->trans('VoteNameAlreadyExists'), 'errors');
setEventMessages($langs->trans('VoteNameAlreadyExists'), null, 'errors');
}
if (isset($erreur_ajout_date) && $erreur_ajout_date) {
setEventMessage($langs->trans("ErrorWrongDate"), 'errors');
setEventMessages($langs->trans("ErrorWrongDate"), null, 'errors');
}
//fin du tableau

View File

@ -84,7 +84,7 @@ if (isset($_POST["confirmecreation"]))
//message d'erreur si aucun champ renseigné
if ($testremplissage != "ok" || (!$toutchoix)) {
setEventMessage($langs->trans("ErrorOpenSurveyOneChoice"), 'errors');
setEventMessages($langs->trans("ErrorOpenSurveyOneChoice"), null, 'errors');
} else {
//format du sondage AUTRE

View File

@ -156,13 +156,13 @@ if (GETPOST('confirmation'))
}
if (isset($errheure)) {
setEventMessage($langs->trans("ErrorBadFormat"), 'errors');
setEventMessages($langs->trans("ErrorBadFormat"), null, 'errors');
}
}
//If just one day and no other time options, error message
if (count($_SESSION["totalchoixjour"])=="1" && $_POST["horaires0"][0]=="" && $_POST["horaires0"][1]=="" && $_POST["horaires0"][2]=="" && $_POST["horaires0"][3]=="" && $_POST["horaires0"][4]=="") {
setEventMessage($langs->trans("MoreChoices"), 'errors');
setEventMessages($langs->trans("MoreChoices"), null, 'errors');
$erreur=true;
}

View File

@ -94,12 +94,12 @@ if (GETPOST("creation_sondage_date") || GETPOST("creation_sondage_autre"))
$_SESSION['champdatefin'] = dol_print_date($champdatefin,'dayrfc');
//$testdate = false;
//$_SESSION['champdatefin'] = dol_print_date($champdatefin,'dayrfc');
setEventMessage('ExpireDate','warnings');
setEventMessages('ExpireDate', null, 'warnings');
}
}
if (! $testdate) {
setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("ExpireDate")), 'errors');
setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("ExpireDate")), null, 'errors');
}
if ($titre && $testdate)

View File

@ -67,7 +67,7 @@ if ($action == 'setvalue' && $user->admin)
if (! $error)
{
$db->commit();
setEventMessage($langs->trans("SetupSaved"));
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{

View File

@ -75,7 +75,7 @@ if ($action == 'setvalue' && $user->admin)
if (! $error)
{
$db->commit();
setEventMessage($langs->trans("SetupSaved"));
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
@ -113,7 +113,7 @@ print $langs->trans("PaypalDesc")."<br>\n";
if (! function_exists('curl_version'))
{
$langs->load("errors");
setEventMessage($langs->trans("ErrorPhpCurlNotInstalled"), 'errors');
setEventMessages($langs->trans("ErrorPhpCurlNotInstalled"), null, 'errors');
}

View File

@ -43,14 +43,14 @@ $price_globals = new PriceGlobalVariable($db);
if ($action == 'edit_variable') {
$res = $price_globals->fetch($selection);
if ($res < 1) {
setEventMessage($price_globals->error, 'errors');
setEventMessages($price_globals->error, $price_globals->errors, 'errors');
}
}
$price_updaters = new PriceGlobalVariableUpdater($db);
if ($action == 'edit_updater') {
$res = $price_updaters->fetch($selection);
if ($res < 1) {
setEventMessage($price_updaters->error, 'errors');
setEventMessages($price_updaters->error, $price_updaters->errors, 'errors');
}
}
@ -67,7 +67,7 @@ if (!empty($action) && empty($cancel)) {
if (!empty($save)) {
foreach ($price_globals->listGlobalVariables() as $entry) {
if ($price_globals->id != $entry->id && dol_strtolower($price_globals->code) == dol_strtolower($entry->code)) {
setEventMessage($langs->trans("ErrorRecordAlreadyExists"), 'errors');
setEventMessages($langs->trans("ErrorRecordAlreadyExists"), null, 'errors');
$save = null;
}
}
@ -78,21 +78,21 @@ if (!empty($action) && empty($cancel)) {
if ($res > 0) {
$action = '';
} else {
setEventMessage($price_globals->error, 'errors');
setEventMessages($price_globals->error, $price_globals->errors, 'errors');
}
} elseif ($action == 'edit_variable' && !empty($save)) {
$res = $price_globals->update($user);
if ($res > 0) {
$action = '';
} else {
setEventMessage($price_globals->error, 'errors');
setEventMessages($price_globals->error, $price_globals->errors, 'errors');
}
} elseif ($action == 'delete_variable') {
$res = $price_globals->delete($selection, $user);
if ($res > 0) {
$action = '';
} else {
setEventMessage($price_globals->error, 'errors');
setEventMessages($price_globals->error, $price_globals->errors, 'errors');
}
}
@ -113,7 +113,7 @@ if (!empty($action) && empty($cancel)) {
if ($res > 0) {
$action = '';
} else {
setEventMessage($price_updaters->error, 'errors');
setEventMessages($price_updaters->error, $price_updaters->errors, 'errors');
}
} elseif ($action == 'edit_updater' && !empty($save)) {
//Verify if process() works
@ -124,14 +124,14 @@ if (!empty($action) && empty($cancel)) {
if ($res > 0) {
$action = '';
} else {
setEventMessage($price_updaters->error, 'errors');
setEventMessages($price_updaters->error, $price_updaters->errors, 'errors');
}
} elseif ($action == 'delete_updater') {
$res = $price_updaters->delete($selection, $user);
if ($res > 0) {
$action = '';
} else {
setEventMessage($price_updaters->error, 'errors');
setEventMessages($price_updaters->error, $price_updaters->errors, 'errors');
}
}
} elseif (!empty($cancel)) {

View File

@ -89,13 +89,13 @@ if ($_POST) {
SET fk_level = ".$db->escape($i_fk_level).", var_percent = ".$i_var_percent.", var_min_percent = ".$i_var_min_percent." WHERE level = ".$i;
if (!$db->query($sql)) {
setEventMessage($langs->trans('ErrorSavingChanges'), 'errors');
setEventMessages($langs->trans('ErrorSavingChanges'), null, 'errors');
}
}
}
setEventMessage($langs->trans("RecordSaved"));
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
}
/*

View File

@ -98,12 +98,12 @@ if ($action == 'setModuleOptions')
if (! $error)
{
$db->commit();
setEventMessage($langs->trans("SetupSaved"));
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
$db->rollback();
setEventMessage($langs->trans("Error"), 'errors');
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
@ -196,11 +196,11 @@ if ($action)
if (! $error)
{
setEventMessage($langs->trans("SetupSaved"));
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessage($langs->trans("Error"), 'errors');
setEventMessages($langs->trans("Error"), null, 'errors');
}
}

View File

@ -57,7 +57,7 @@ if ($action == 'convert')
if ($oldvatrate == $newvatrate)
{
$langs->load("errors");
setEventMessage($langs->trans("ErrorNewValueCantMatchOldValue"),'errors');
setEventMessages($langs->trans("ErrorNewValueCantMatchOldValue"), null, 'errors');
$error++;
}
@ -225,12 +225,12 @@ if ($action == 'convert')
// Output result
if (! $error)
{
if ($nbrecordsmodified > 0) setEventMessage($langs->trans("RecordsModified",$nbrecordsmodified));
else setEventMessage($langs->trans("NoRecordFound"),'warnings');
if ($nbrecordsmodified > 0) setEventMessages($langs->trans("RecordsModified",$nbrecordsmodified), null, 'mesgs');
else setEventMessages($langs->trans("NoRecordFound"), null, 'warnings');
}
else
{
setEventMessage($langs->trans("Error"),'errors');
setEventMessages($langs->trans("Error"), null, 'errors');
}
}

View File

@ -85,9 +85,11 @@ if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->se
$error++;
$action = 're-edit';
if ($object->error == "isFatherOfThis") {
setEventMessage($langs->trans("ErrorAssociationIsFatherOfThis"), 'errors');
} else {
setEventMessage($object->error, 'errors');
setEventMessages($langs->trans("ErrorAssociationIsFatherOfThis"), null, 'errors');
}
else
{
setEventMessages($object->error, $object->errors, 'errors');
}
}
}
@ -101,7 +103,7 @@ if ($action == 'add_prod' && ($user->rights->produit->creer || $user->rights->se
{
$error++;
$action = 're-edit';
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
}

View File

@ -75,7 +75,7 @@ if ($action == 'add')
$priceparser = new PriceParser($db);
$price_result = $priceparser->parseProductSupplierExpression($id, $expression, 0, 0);
if ($price_result < 0) { //Expression is not valid
setEventMessage($priceparser->translatedError(), 'errors');
setEventMessages($priceparser->translatedError(), null, 'errors');
}
else
{
@ -85,21 +85,21 @@ if ($action == 'add')
if ($result > 0) //created successfully, set the eid to newly created entry
{
$eid = $price_expression->id;
setEventMessage($langs->trans("RecordSaved"));
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
}
else
{
setEventMessage("add: ".$price_expression->error, 'errors');
setEventMessages("add: ".$price_expression->error, $price_expression->errors, 'errors');
}
}
}
else if ($result < 0)
{
setEventMessage("add find: ".$price_expression->error, 'errors');
setEventMessages("add find: ".$price_expression->error, $price_expression->errors, 'errors');
}
else
{
setEventMessage($langs->trans("ErrorRecordAlreadyExists"), 'errors');
setEventMessages($langs->trans("ErrorRecordAlreadyExists"), null, 'errors');
}
}
}
@ -115,7 +115,7 @@ if ($action == 'update')
$priceparser = new PriceParser($db);
$price_result = $priceparser->parseProductSupplierExpression($id, $expression, 0, 0);
if ($price_result < 0) { //Expression is not valid
setEventMessage($priceparser->translatedError(), 'errors');
setEventMessages($priceparser->translatedError(), null, 'errors');
}
else
{
@ -125,21 +125,21 @@ if ($action == 'update')
$result = $price_expression->update($user);
if ($result < 0)
{
setEventMessage("update: ".$price_expression->error, 'errors');
setEventMessages("update: ".$price_expression->error, $price_expression->errors, 'errors');
}
else
{
setEventMessage($langs->trans("RecordSaved"));
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
}
}
}
else if ($result < 0)
{
setEventMessage("update find: ".$price_expression->error, 'errors');
setEventMessages("update find: ".$price_expression->error, $price_expression->errors, 'errors');
}
else
{
setEventMessage($langs->trans("ErrorRecordAlreadyExists"), 'errors');
setEventMessages($langs->trans("ErrorRecordAlreadyExists"), null, 'errors');
}
}
}
@ -151,7 +151,7 @@ if ($action == 'delete')
$result = $price_expression->delete($eid, $user);
if ($result < 0)
{
setEventMessage("delete: ".$price_expression->error, 'errors');
setEventMessages("delete: ".$price_expression->error, $price_expression->errors, 'errors');
}
$eid = 0;
}

View File

@ -78,7 +78,7 @@ if ($action == 'add' && $user->rights->stock->creer)
$id = $object->create($user);
if ($id > 0)
{
setEventMessage($langs->trans("RecordSaved"));
setEventMessages($langs->trans("RecordSaved"), null, 'mesgs');
if (! empty($backtopage))
{
@ -94,11 +94,12 @@ if ($action == 'add' && $user->rights->stock->creer)
else
{
$action = 'create';
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
else {
setEventMessage($langs->trans("ErrorWarehouseRefRequired"), 'errors');
else
{
setEventMessages($langs->trans("ErrorWarehouseRefRequired"), null, 'errors');
$action="create"; // Force retour sur page creation
}
}
@ -116,7 +117,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->stock->su
}
else
{
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
$action='';
}
}
@ -143,13 +144,13 @@ if ($action == 'update' && $cancel <> $langs->trans("Cancel"))
else
{
$action = 'edit';
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
else
{
$action = 'edit';
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}

View File

@ -95,7 +95,7 @@ if ($action == 'addline')
{
$error++;
$langs->load("errors");
setEventMessage($langs->trans("ErrorWarehouseMustDiffers"),'errors');
setEventMessages($langs->trans("ErrorWarehouseMustDiffers"), null, 'errors');
}
if (! $qty)
{
@ -113,7 +113,7 @@ if ($action == 'addline')
if (empty($batch))
{
$error++;
setEventMessage($langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData"), 'errors');
setEventMessages($langs->trans("ErrorTryToMakeMoveOnProductRequiringBatchData"), null, 'errors');
}
}
}
@ -161,7 +161,7 @@ if ($action == 'createmovements')
if (! GETPOST("label"))
{
$error++;
setEventMessage($langs->trans("ErrorFieldRequired"),$langs->transnoentitiesnoconv("LabelMovement"));
setEventMessages($langs->trans("ErrorFieldRequired"),$langs->transnoentitiesnoconv("LabelMovement"), null, 'errors');
}
$db->begin();
@ -209,7 +209,7 @@ if ($action == 'createmovements')
if ($result1 < 0)
{
$error++;
setEventMessage($product->errors,'errors');
setEventMessages($product->errors, $product->errorss, 'errors');
}
// Add stock
@ -225,7 +225,7 @@ if ($action == 'createmovements')
if ($result2 < 0)
{
$error++;
setEventMessage($product->errors,'errors');
setEventMessages($product->errors, $product->errorss, 'errors');
}
}
else
@ -260,7 +260,7 @@ if ($action == 'createmovements')
if ($result1 < 0)
{
$error++;
setEventMessage($product->errors,'errors');
setEventMessages($product->errors, $product->errorss, 'errors');
}
// Add stock
@ -279,7 +279,7 @@ if ($action == 'createmovements')
if ($result2 < 0)
{
$error++;
setEventMessage($product->errors,'errors');
setEventMessages($product->errors, $product->errorss, 'errors');
}
}
}
@ -296,14 +296,14 @@ if ($action == 'createmovements')
unset($_SESSION['massstockmove']);
$db->commit();
setEventMessage($langs->trans("StockMovementRecorded"),'mesgs');
setEventMessages($langs->trans("StockMovementRecorded"), null, 'mesgs');
header("Location: ".DOL_URL_ROOT.'/product/stock/index.php'); // Redirect to avoid pb when using back
exit;
}
else
{
$db->rollback();
setEventMessage($langs->trans("Error"),'errors');
setEventMessages($langs->trans("Error"), null, 'errors');
}
}