[Qual] Uniformize code

This commit is contained in:
philippe grand 2015-12-04 19:45:39 +01:00
parent c91aa0aa90
commit 94fe00fe8d
4 changed files with 22 additions and 22 deletions

View File

@ -138,7 +138,7 @@ if (empty($reshook))
if (! empty($massaction) && count($toselect) < 1) if (! empty($massaction) && count($toselect) < 1)
{ {
$error++; $error++;
setEventMessage("NoLineChecked","warnings"); setEventMessages($langs->trans("NoLineChecked"), null, "warnings");
} }
if (! $error && $massaction == 'confirm_presend') if (! $error && $massaction == 'confirm_presend')

View File

@ -114,8 +114,8 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
$langs->load("other"); $langs->load("other");
$file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP). $file = $upload_dir . "/" . GETPOST('urlfile'); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
$ret=dol_delete_file($file); $ret=dol_delete_file($file);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
$result=$ecmdir->changeNbOfFiles('-'); $result=$ecmdir->changeNbOfFiles('-');
} }

View File

@ -98,7 +98,7 @@ if (($action == 'create') || ($action == 'add'))
if (! (GETPOST('entrepot_id','int') > 0)) if (! (GETPOST('entrepot_id','int') > 0))
{ {
$langs->load("errors"); $langs->load("errors");
setEventMessage($langs->trans("WarehouseMustBeSelectedAtFirstStepWhenProductBatchModuleOn"),'errors'); setEventMessages($langs->trans("WarehouseMustBeSelectedAtFirstStepWhenProductBatchModuleOn"), null, 'errors');
header("Location: ".DOL_URL_ROOT.'/expedition/shipment.php?id='.$origin_id); header("Location: ".DOL_URL_ROOT.'/expedition/shipment.php?id='.$origin_id);
exit; exit;
} }
@ -303,7 +303,7 @@ if (empty($reshook))
if ($result < 0) if ($result < 0)
{ {
$langs->load("errors"); $langs->load("errors");
setEventMessage($langs->trans($object->error),'errors'); setEventMessages($langs->trans($object->error), null, 'errors');
} }
else else
{ {
@ -338,7 +338,7 @@ if (empty($reshook))
else else
{ {
$langs->load("errors"); $langs->load("errors");
setEventMessage($langs->trans($object->error),'errors'); setEventMessages($langs->trans($object->error), null, 'errors');
} }
} }
@ -395,7 +395,7 @@ if (empty($reshook))
header("Location: card.php?id=".$object->id); header("Location: card.php?id=".$object->id);
exit; exit;
} }
setEventMessage($object->error,'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
$action=""; $action="";
@ -433,8 +433,8 @@ if (empty($reshook))
$upload_dir = $conf->expedition->dir_output . "/sending"; $upload_dir = $conf->expedition->dir_output . "/sending";
$file = $upload_dir . '/' . GETPOST('file'); $file = $upload_dir . '/' . GETPOST('file');
$ret=dol_delete_file($file,0,0,0,$object); $ret=dol_delete_file($file,0,0,0,$object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
} }
elseif ($action == 'classifybilled') elseif ($action == 'classifybilled')
@ -482,7 +482,7 @@ if ($action == 'create')
print load_fiche_titre($langs->trans("CreateASending")); print load_fiche_titre($langs->trans("CreateASending"));
if (! $origin) if (! $origin)
{ {
setEventMessage($langs->trans("ErrorBadParameters"),'errors'); setEventMessages($langs->trans("ErrorBadParameters"), null, 'errors');
} }
dol_htmloutput_mesg($mesg); dol_htmloutput_mesg($mesg);

View File

@ -139,7 +139,7 @@ if ($action == 'add' && $user->rights->expensereport->creer)
if ($object->periode_existe($user,$object->date_debut,$object->date_fin)) if ($object->periode_existe($user,$object->date_debut,$object->date_fin))
{ {
$error++; $error++;
setEventMessage($langs->trans("ErrorDoubleDeclaration"),'errors'); setEventMessages($langs->trans("ErrorDoubleDeclaration"), null, 'errors');
$action='create'; $action='create';
} }
@ -267,7 +267,7 @@ if ($action == "confirm_validate" && GETPOST("confirm") == "yes" && $id > 0 && $
if ($result) if ($result)
{ {
$mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2)); $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($emailFrom,2),$mailfile->getValidAddress($emailTo,2));
setEventMessage($mesg); setEventMessages($mesg, null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit; exit;
} }
@ -279,11 +279,11 @@ if ($action == "confirm_validate" && GETPOST("confirm") == "yes" && $id > 0 && $
$mesg=''; $mesg='';
$mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo); $mesg.=$langs->trans('ErrorFailedToSendMail', $emailFrom, $emailTo);
$mesg.='<br>'.$mailfile->error; $mesg.='<br>'.$mailfile->error;
setEventMessage($mesg,'errors'); setEventMessages($mesg, null, 'errors');
} }
else else
{ {
setEventMessage('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', 'warnings'); setEventMessages('No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS', null, 'warnings');
} }
} }
} }
@ -295,7 +295,7 @@ if ($action == "confirm_validate" && GETPOST("confirm") == "yes" && $id > 0 && $
} }
else else
{ {
setEventMessage($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), 'warnings'); setEventMessages($langs->trans("NoEmailSentBadSenderOrRecipientEmail"), null, 'warnings');
$action=''; $action='';
} }
} }
@ -490,15 +490,15 @@ if ($action == "confirm_approve" && GETPOST("confirm") == "yes" && $id > 0 && $u
// SEND // SEND
$result=$mailfile->sendfile(); $result=$mailfile->sendfile();
if ($result): if ($result):
setEventMessage($langs->trans("MailSuccessfulySent",$emailFrom,$emailTo)); setEventMessages($langs->trans("MailSuccessfulySent",$emailFrom,$emailTo), null, 'mesgs');
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit; exit;
else: else:
setEventMessage($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo),'errors'); setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors');
endif; endif;
else: else:
setEventMessage($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo),'errors'); setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors');
endif; endif;
// END - Send mail // END - Send mail
else : // if ($resultPDF) else : // if ($resultPDF)
@ -576,13 +576,13 @@ if ($action == "confirm_refuse" && GETPOST('confirm')=="yes" && $id > 0 && $user
$result=$mailfile->sendfile(); $result=$mailfile->sendfile();
if ($result) if ($result)
{ {
setEventMessage($langs->trans("MailSuccessfulySent",$emailFrom,$emailTo)); setEventMessages($langs->trans("MailSuccessfulySent",$emailFrom,$emailTo), null, 'mesgs');
Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); Header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id);
exit; exit;
} }
else else
{ {
setEventMessage($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo),'errors'); setEventMessages($langs->trans("ErrorFailedToSendMail",$emailFrom,$emailTo), null, 'errors');
$mesg="Impossible d'envoyer l'email."; $mesg="Impossible d'envoyer l'email.";
} }
// END - Send mail // END - Send mail
@ -1059,8 +1059,8 @@ else if ($action == 'remove_file')
$upload_dir = $conf->expensereport->dir_output; $upload_dir = $conf->expensereport->dir_output;
$file = $upload_dir . '/' . GETPOST('file'); $file = $upload_dir . '/' . GETPOST('file');
$ret=dol_delete_file($file,0,0,0,$object); $ret=dol_delete_file($file,0,0,0,$object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('urlfile'))); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('urlfile')), null, 'mesgs');
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), 'errors'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('urlfile')), null, 'errors');
$action=''; $action='';
} }
} }