From 7a33e2983d1d5bce6665e6fbcf12cdab0eee9913 Mon Sep 17 00:00:00 2001 From: philippe grand Date: Sun, 20 Dec 2015 10:36:20 +0100 Subject: [PATCH] [Qual] Uniformize code --- htdocs/projet/card.php | 6 ++-- htdocs/public/opensurvey/studs.php | 16 ++++----- htdocs/resource/add.php | 6 ++-- htdocs/resource/card.php | 13 ++++---- htdocs/resource/element_resource.php | 9 ++--- htdocs/societe/admin/societe.php | 16 ++++----- htdocs/societe/list.php | 2 +- htdocs/societe/price.php | 49 ++++++++++++++++++---------- htdocs/societe/rib.php | 12 ++++--- htdocs/societe/soc.php | 12 ++++--- 10 files changed, 80 insertions(+), 61 deletions(-) diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 031239f1a85..2266f012964 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -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'); } diff --git a/htdocs/public/opensurvey/studs.php b/htdocs/public/opensurvey/studs.php index 5af112ebfa0..33bd1ba1373 100644 --- a/htdocs/public/opensurvey/studs.php +++ b/htdocs/public/opensurvey/studs.php @@ -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 ''."\n"; // Show choice titles if ($object->format=="D") { - //affichage des sujets du sondage + //display of survey topics print ''."\n"; print ''."\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 ''."\n"; print ''."\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 ''."\n"; print ''."\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 ''."\n"; - //affichage des horaires + //Display schedules if (strpos($object->sujet, '@') !== false) { print ''."\n"; print ''."\n"; @@ -375,7 +375,7 @@ if ($object->format=="D") } else { - //affichage des sujets du sondage + //display of survey topics print ''."\n"; print ''."\n"; diff --git a/htdocs/resource/add.php b/htdocs/resource/add.php index f509bc82759..679ef545442 100644 --- a/htdocs/resource/add.php +++ b/htdocs/resource/add.php @@ -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 = ''; } } diff --git a/htdocs/resource/card.php b/htdocs/resource/card.php index 4e22175d21e..31fb6a955b1 100644 --- a/htdocs/resource/card.php +++ b/htdocs/resource/card.php @@ -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'); } } } diff --git a/htdocs/resource/element_resource.php b/htdocs/resource/element_resource.php index 21dad5afa05..77c23d5f8b4 100644 --- a/htdocs/resource/element_resource.php +++ b/htdocs/resource/element_resource.php @@ -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'); } } } diff --git a/htdocs/societe/admin/societe.php b/htdocs/societe/admin/societe.php index 0318caa665b..e69d098ea7d 100644 --- a/htdocs/societe/admin/societe.php +++ b/htdocs/societe/admin/societe.php @@ -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'); } } diff --git a/htdocs/societe/list.php b/htdocs/societe/list.php index 0b373ba9d5d..fcee0c2cdf7 100644 --- a/htdocs/societe/list.php +++ b/htdocs/societe/list.php @@ -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"); diff --git a/htdocs/societe/price.php b/htdocs/societe/price.php index 6341f1dd37e..6e8d7af4929 100644 --- a/htdocs/societe/price.php +++ b/htdocs/societe/price.php @@ -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 ''; @@ -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 ''; } print "
"; - } 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; diff --git a/htdocs/societe/rib.php b/htdocs/societe/rib.php index 65e61b458cb..1d0fccfe33d 100644 --- a/htdocs/societe/rib.php +++ b/htdocs/societe/rib.php @@ -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'); } } diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index b7465abe85b..a4c2688063d 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -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(); } }