[Qual] Uniformize code

This commit is contained in:
philippe grand 2015-12-20 10:36:20 +01:00
parent f0802eb36b
commit 7a33e2983d
10 changed files with 80 additions and 61 deletions

View File

@ -165,7 +165,7 @@ if (empty($reshook))
else
{
$langs->load("errors");
setEventMessage($langs->trans($object->error), null, 'errors');
setEventMessages($langs->trans($object->error), null, 'errors');
$error++;
}
@ -204,13 +204,13 @@ if (empty($reshook))
if (empty($ref))
{
$error++;
//$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
//$_GET["id"]=$_POST["id"]; // We return on the project card
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Ref")), null, 'errors');
}
if (empty($_POST["title"]))
{
$error++;
//$_GET["id"]=$_POST["id"]; // On retourne sur la fiche projet
//$_GET["id"]=$_POST["id"]; // We return on the project card
setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")), null, 'errors');
}

View File

@ -122,7 +122,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
@ -181,7 +181,7 @@ for ($i=0; $i<$nblignes; $i++)
$testligneamodifier=true;
}
//test pour voir si une ligne est a modifier
//test to see if a line is to be modified
if (isset($_POST['validermodifier'.$i]))
{
$modifier=$i;
@ -293,11 +293,11 @@ print '<table class="resultats">'."\n";
// Show choice titles
if ($object->format=="D")
{
//affichage des sujets du sondage
//display of survey topics
print '<tr>'."\n";
print '<td></td>'."\n";
//affichage des années
//display of years
$colspan=1;
$nbofsujet=count($toutsujet);
for ($i=0;$i<$nbofsujet;$i++)
@ -314,7 +314,7 @@ if ($object->format=="D")
print '<tr>'."\n";
print '<td></td>'."\n";
//affichage des mois
//display of months
$colspan=1;
for ($i=0;$i<$nbofsujet;$i++) {
$cur = intval($toutsujet[$i]); // intval() est utiliser pour supprimer le suffixe @* qui déplaît logiquement à strftime()
@ -337,7 +337,7 @@ if ($object->format=="D")
print '<tr>'."\n";
print '<td></td>'."\n";
//affichage des jours
//display of days
$colspan=1;
for ($i=0;$i<$nbofsujet;$i++) {
$cur = intval($toutsujet[$i]);
@ -356,7 +356,7 @@ if ($object->format=="D")
print '</tr>'."\n";
//affichage des horaires
//Display schedules
if (strpos($object->sujet, '@') !== false) {
print '<tr>'."\n";
print '<td></td>'."\n";
@ -375,7 +375,7 @@ if ($object->format=="D")
}
else
{
//affichage des sujets du sondage
//display of survey topics
print '<tr>'."\n";
print '<td></td>'."\n";

View File

@ -74,7 +74,7 @@ if ($action == 'confirm_add_resource')
if (empty($ref))
{
$mesg=$langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref"));
setEventMessage($mesg, 'errors');
setEventMessages($mesg, null, 'errors');
$error++;
}
@ -90,14 +90,14 @@ if ($action == 'confirm_add_resource')
{
// Creation OK
$db->commit();
setEventMessage($langs->trans('ResourceCreatedWithSuccess'));
setEventMessages($langs->trans('ResourceCreatedWithSuccess'), null, 'mesgs');
Header("Location: card.php?id=" . $object->id);
return;
}
else
{
// Creation KO
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
$action = '';
}
}

View File

@ -96,14 +96,14 @@ if (empty($reshook))
}
else
{
setEventMessage($object->error, 'errors');
setEventMessages($object->error, $object->errors, 'errors');
$action='edit';
}
}
else
{
setEventMessage($object->error,'errors');
setEventMessages($object->error, $object->errors, 'errors');
$action='edit';
}
}
@ -122,17 +122,18 @@ if (empty($reshook))
if ($result >= 0)
{
setEventMessage($langs->trans('RessourceSuccessfullyDeleted'));
setEventMessages($langs->trans('RessourceSuccessfullyDeleted'), null, 'mesgs');
Header('Location: '.DOL_URL_ROOT.'/resource/list.php');
exit;
}
else {
setEventMessage($object->error,'errors');
else
{
setEventMessages($object->error, $object->errors, 'errors');
}
}
else
{
setEventMessage($object->error,'errors');
setEventMessages($object->error, $object->errors, 'errors');
}
}
}

View File

@ -93,7 +93,7 @@ if ($action == 'add_element_resource' && ! $cancel)
}
if (! $error && $res > 0)
{
setEventMessage($langs->trans('ResourceLinkedWithSuccess'),'mesgs');
setEventMessages($langs->trans('ResourceLinkedWithSuccess'), null, 'mesgs');
header("Location: ".$_SERVER['PHP_SELF'].'?element='.$element.'&element_id='.$element_id);
exit;
}
@ -112,12 +112,13 @@ if ($action == 'update_linked_resource' && $user->rights->resource->write && !GE
if ($result >= 0)
{
setEventMessage($langs->trans('RessourceLineSuccessfullyUpdated'));
setEventMessages($langs->trans('RessourceLineSuccessfullyUpdated'), null, 'mesgs');
header("Location: ".$_SERVER['PHP_SELF']."?element=".$element."&element_id=".$element_id);
exit;
}
else {
setEventMessage($object->error,'errors');
else
{
setEventMessages($object->error, $object->errors, 'errors');
}
}
}

View File

@ -77,11 +77,11 @@ if ($action == 'updateoptions')
if (! $res > 0) $error++;
if (! $error)
{
setEventMessage($langs->trans("SetupSaved"));
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessage($langs->trans("Error"), 'errors');
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
@ -92,11 +92,11 @@ if ($action == 'updateoptions')
if (! $res > 0) $error++;
if (! $error)
{
setEventMessage($langs->trans("SetupSaved"));
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
}
else
{
setEventMessage($langs->trans("Error"), 'errors');
setEventMessages($langs->trans("Error"), null, 'errors');
}
}
}
@ -121,12 +121,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');
}
}
@ -217,11 +217,11 @@ if ($action=="setaddrefinlist") {
if (! $res > 0) $error++;
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

@ -468,7 +468,7 @@ if ($resql)
// Show delete result message
if (GETPOST('delsoc'))
{
setEventMessage($langs->trans("CompanyDeleted",GETPOST('delsoc')));
setEventMessages($langs->trans("CompanyDeleted",GETPOST('delsoc')), null, 'mesgs');
}
$langs->load("other");

View File

@ -69,10 +69,13 @@ if ($action == 'add_customer_price_confirm' && ! $_POST ["cancel"] && ($user->ri
$result = $prodcustprice->create($user, 0, $update_child_soc);
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
} else {
setEventMessage($langs->trans('Save'), 'mesgs');
if ($result < 0)
{
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
}
else
{
setEventMessages($langs->trans('Save'), null, 'mesgs');
}
$action = '';
@ -83,10 +86,13 @@ if ($action == 'delete_customer_price' && ($user->rights->produit->creer || $use
$prodcustprice->id = GETPOST('lineid');
$result = $prodcustprice->delete($user);
if ($result < 0) {
setEventMessage($prodcustprice->error, 'mesgs');
} else {
setEventMessage($langs->trans('Delete'), 'errors');
if ($result < 0)
{
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
}
else
{
setEventMessages($langs->trans('Delete'), null, 'mesgs');
}
$action = '';
}
@ -105,10 +111,13 @@ if ($action == 'update_customer_price_confirm' && ! $_POST ["cancel"] && ($user-
$prodcustprice->recuperableonly = (preg_match('/\*/', GETPOST("tva_tx")) ? 1 : 0);
$result = $prodcustprice->update($user, 0, $update_child_soc);
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
} else {
setEventMessage($langs->trans('Save'), 'mesgs');
if ($result < 0)
{
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
}
else
{
setEventMessages($langs->trans('Save'), null, 'mesgs');
}
$action = '';
@ -284,8 +293,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print load_fiche_titre($langs->trans('PriceByCustomer'));
$result = $prodcustprice->fetch(GETPOST('lineid', 'int'));
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
if ($result < 0)
{
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
}
print '<form action="' . $_SERVER["PHP_SELF"] . '?socid=' . $object->id . '" method="POST">';
@ -369,8 +379,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
}
$result = $prodcustprice->fetch_all_log($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
if ($result < 0) {
setEventMessage($prodcustprice->error, 'errors');
if ($result < 0)
{
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
}
$option = '&socid=' . GETPOST('socid', 'int') . '&prodid=' . GETPOST('prodid', 'int');
@ -423,7 +434,9 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
print '</td>';
}
print "</table>";
} else {
}
else
{
print $langs->trans('None');
}
@ -459,7 +472,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
$result = $prodcustprice->fetch_all($sortorder, $sortfield, $conf->liste_limit, $offset, $filter);
if ($result < 0)
{
setEventMessage($prodcustprice->error, 'errors');
setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors');
}
$option = '&search_soc=' . $search_soc . '&id=' . $object->id;

View File

@ -81,7 +81,7 @@ if ($action == 'update' && ! $_POST["cancel"])
$result = $account->update($user);
if (! $result)
{
setEventMessage($account->error, 'errors');
setEventMessages($account->error, $account->errors, 'errors');
$_GET["action"]='edit'; // Force chargement page edition
}
else
@ -161,8 +161,10 @@ if ($action == 'setasdefault')
$url=DOL_URL_ROOT.'/societe/rib.php?socid='.$object->id;
header('Location: '.$url);
exit;
} else {
setEventMessage($db->lasterror, 'errors');
}
else
{
setEventMessages($db->lasterror, null, 'errors');
}
}
@ -180,12 +182,12 @@ if ($action == 'confirm_delete' && $_GET['confirm'] == 'yes')
}
else
{
setEventMessage($account->error, 'errors');
setEventMessages($account->error, $account->errors, 'errors');
}
}
else
{
setEventMessage($account->error, 'errors');
setEventMessages($account->error, $account->errors, 'errors');
}
}

View File

@ -121,14 +121,14 @@ if (empty($reshook))
{
$langs->load('errors');
$langs->load('companies');
setEventMessage($langs->trans('ErrorProdIdIsMandatory', $langs->trans('MergeOriginThirdparty')), 'errors');
setEventMessages($langs->trans('ErrorProdIdIsMandatory', $langs->trans('MergeOriginThirdparty')), null, 'errors');
}
else
{
if (!$errors && $soc_origin->fetch($soc_origin_id) < 1)
{
setEventMessage($langs->trans('ErrorRecordNotFound'), 'errors');
setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors');
$errors++;
}
@ -197,10 +197,12 @@ if (empty($reshook))
if (!$errors)
{
setEventMessage($langs->trans('ThirdpartiesMergeSuccess'));
setEventMessages($langs->trans('ThirdpartiesMergeSuccess'), null, 'mesgs');
$db->commit();
} else {
setEventMessage($langs->trans('ErrorsThirdpartyMerge'), 'errors');
}
else
{
setEventMessages($langs->trans('ErrorsThirdpartyMerge'), null, 'errors');
$db->rollback();
}
}