From 0fe64c6091be75e222f13cfaa6d25e7aeea4982c Mon Sep 17 00:00:00 2001 From: philippe grand Date: Mon, 14 Dec 2015 20:54:55 +0100 Subject: [PATCH] [Qual] Uniformize code --- htdocs/product/card.php | 44 ++++++++++++++++-------------- htdocs/product/document.php | 6 ++-- htdocs/product/fournisseurs.php | 16 +++++------ htdocs/product/list.php | 2 +- htdocs/product/price.php | 36 ++++++++++++------------ htdocs/product/stock/mouvement.php | 2 +- htdocs/product/stock/product.php | 4 +-- htdocs/product/stock/replenish.php | 8 +++--- htdocs/product/traduction.php | 6 ++-- 9 files changed, 63 insertions(+), 61 deletions(-) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 77b14b24c7a..e166b15c8ee 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -149,21 +149,21 @@ if (empty($reshook)) else $errors[] = 'FailedToValidateBarCode'; $error++; - setEventMessage($errors,'errors'); + setEventMessages($errors, null, 'errors'); } } if ($action == 'setaccountancy_code_buy') { $result = $object->setAccountancyCode('buy', GETPOST('accountancy_code_buy')); - if ($result < 0) setEventMessage(join(',',$object->errors), 'errors'); + if ($result < 0) setEventMessages(join(',',$object->errors), null, 'errors'); $action=""; } if ($action == 'setaccountancy_code_sell') { $result = $object->setAccountancyCode('sell', GETPOST('accountancy_code_sell')); - if ($result < 0) setEventMessage(join(',',$object->errors), 'errors'); + if ($result < 0) setEventMessages(join(',',$object->errors), null, 'errors'); $action=""; } @@ -174,13 +174,13 @@ if (empty($reshook)) if (! GETPOST('label')) { - setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentities('Label')), 'errors'); + setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('Label')), null, 'errors'); $action = "create"; $error++; } if (empty($ref)) { - setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')), 'errors'); + setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentities('Ref')), null, 'errors'); $action = "create"; $error++; } @@ -224,7 +224,8 @@ if (empty($reshook)) if ($result < 0) { $error++; - setEventMessage('Failed to get bar code type information '.$stdobject->error, 'errors'); + $mesg='Failed to get bar code type information '; + setEventMessages($mesg.$stdobject->error, $mesg.$stdobject->errors, 'errors'); } $object->barcode_type_code = $stdobject->barcode_type_code; $object->barcode_type_coder = $stdobject->barcode_type_coder; @@ -290,8 +291,8 @@ if (empty($reshook)) } else { - if (count($object->errors)) setEventMessage($object->errors, 'errors'); - else setEventMessage($langs->trans($object->error), 'errors'); + if (count($object->errors)) setEventMessages($object->error, $object->errors, 'errors'); + else setEventMessages($langs->trans($object->error), null, 'errors'); $action = "create"; } } @@ -353,7 +354,8 @@ if (empty($reshook)) if ($result < 0) { $error++; - setEventMessage('Failed to get bar code type information '.$stdobject->error, 'errors'); + $mesg='Failed to get bar code type information '; + setEventMessages($mesg.$stdobject->error, $mesg.$stdobject->errors, 'errors'); } $object->barcode_type_code = $stdobject->barcode_type_code; $object->barcode_type_coder = $stdobject->barcode_type_coder; @@ -378,15 +380,15 @@ if (empty($reshook)) } else { - if (count($object->errors)) setEventMessage($object->errors, 'errors'); - else setEventMessage($langs->trans($object->error), 'errors'); + if (count($object->errors)) setEventMessages($object->error, $object->errors, 'errors'); + else setEventMessages($langs->trans($object->error), null, 'errors'); $action = 'edit'; } } else { - if (count($object->errors)) setEventMessage($object->errors, 'errors'); - else setEventMessage($langs->trans("ErrorProductBadRefOrLabel"), 'errors'); + if (count($object->errors)) setEventMessages($object->error, $object->errors, 'errors'); + else setEventMessages($langs->trans("ErrorProductBadRefOrLabel"), null, 'errors'); $action = 'edit'; } } @@ -400,7 +402,7 @@ if (empty($reshook)) { if (! GETPOST('clone_content') && ! GETPOST('clone_prices') ) { - setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); + setEventMessages($langs->trans("NoCloneOptionsSpecified"), null, 'errors'); } else { @@ -427,7 +429,7 @@ if (empty($reshook)) if ($result < 1) { $db->rollback(); - setEventMessage($langs->trans('ErrorProductClone'), 'errors'); + setEventMessages($langs->trans('ErrorProductClone'), null, 'errors'); header("Location: ".$_SERVER["PHP_SELF"]."?id=".$originalId); exit; } @@ -454,7 +456,7 @@ if (empty($reshook)) $mesg=$langs->trans("ErrorProductAlreadyExists",$object->ref); $mesg.=' '.$langs->trans("ShowCardHere").'.'; - setEventMessage($mesg, 'errors'); + setEventMessages($mesg, null, 'errors'); $object->fetch($id); } else @@ -462,12 +464,12 @@ if (empty($reshook)) $db->rollback(); if (count($object->errors)) { - setEventMessage($object->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); dol_print_error($db,$object->errors); } else { - setEventMessage($langs->trans($object->error), 'errors'); + setEventMessages($langs->trans($object->error), null, 'errors'); dol_print_error($db,$object->error); } } @@ -498,7 +500,7 @@ if (empty($reshook)) } else { - setEventMessage($langs->trans($object->error), 'errors'); + setEventMessages($langs->trans($object->error), null, 'errors'); $reload = 0; $action=''; } @@ -624,7 +626,7 @@ if (empty($reshook)) return; } - setEventMessage($langs->trans("ErrorUnknown") . ": $result", 'errors'); + setEventMessages($langs->trans("ErrorUnknown") . ": $result", null, 'errors'); } elseif (GETPOST('commandeid') > 0) { $result = $commande->addline( $desc, @@ -696,7 +698,7 @@ if (empty($reshook)) } else { $action=""; - setEventMessage($langs->trans("WarningSelectOneDocument"), 'warnings'); + setEventMessages($langs->trans("WarningSelectOneDocument"), null, 'warnings'); } } diff --git a/htdocs/product/document.php b/htdocs/product/document.php index ecb3d12bb52..8a4c68990c6 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -105,7 +105,7 @@ if (empty($reshook)) $filetomerge->file_name=$filename; $result=$filetomerge->delete_by_file($user); if ($result<0) { - setEventMessage($filetomerge->error,'errors'); + setEventMessages($filetomerge->error, $filetomerge->errors, 'errors'); } } } @@ -137,7 +137,7 @@ if ($action=='filemerge') $result=$filetomerge->delete_by_product($user, $object->id); } if ($result<0) { - setEventMessage($filetomerge->error,'errors'); + setEventMessages($filetomerge->error, $filetomerge->errors, 'errors'); } // for each file checked add it to the product @@ -152,7 +152,7 @@ if ($action=='filemerge') $result=$filetomerge->create($user); if ($result<0) { - setEventMessage($filetomerge->error,'errors'); + setEventMessages($filetomerge->error, $filetomerge->errors, 'errors'); } } } diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index 04007d2ede1..1f5e35a043a 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -101,7 +101,7 @@ if (empty($reshook)) if ($result > 0) { $object->cost_price = price2num($cost_price); - setEventMessage($langs->trans("RecordSaved")); + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); } else { @@ -119,7 +119,7 @@ if (empty($reshook)) $action = ''; $result=$object->remove_product_fournisseur_price($rowid); if($result > 0){ - setEventMessage($langs->trans("PriceRemoved")); + setEventMessages($langs->trans("PriceRemoved"), null, 'mesgs'); }else{ $error++; setEventMessages($object->error, $object->errors, 'errors'); @@ -151,7 +151,7 @@ if (empty($reshook)) { $error++; $langs->load("errors"); - setEventMessage($langs->trans("ErrorFieldMustBeANumeric",'eeee'), 'errors'); + setEventMessages($langs->trans("ErrorFieldMustBeANumeric",'eeee'), null, 'errors'); } if (empty($quantity)) { @@ -199,12 +199,12 @@ if (empty($reshook)) $object->fetch($object->product_id_already_linked); $productLink = $object->getNomUrl(1,'supplier'); - setEventMessage($langs->trans("ReferenceSupplierIsAlreadyAssociatedWithAProduct",$productLink), 'errors'); + setEventMessages($langs->trans("ReferenceSupplierIsAlreadyAssociatedWithAProduct",$productLink), null, 'errors'); } else if ($ret < 0) { $error++; - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -220,7 +220,7 @@ if (empty($reshook)) { $error++; - setEventMessage($object->error, $object->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } else { @@ -231,7 +231,7 @@ if (empty($reshook)) $price_result = $priceparser->parseProductSupplier($id, $price_expression, $quantity, $tva_tx); if ($price_result < 0) { //Expression is not valid $error++; - setEventMessage($priceparser->translatedError(), 'errors'); + setEventMessages($priceparser->translatedError(), null, 'errors'); } } if (! $error && ! empty($conf->dynamicprices->enabled)) { @@ -239,7 +239,7 @@ if (empty($reshook)) if ($ret < 0) { $error++; - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } diff --git a/htdocs/product/list.php b/htdocs/product/list.php index b656b88efc6..335f6cd346a 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -293,7 +293,7 @@ else // Displays product removal confirmation if (GETPOST('delprod')) { - setEventMessage($langs->trans("ProductDeleted", GETPOST('delprod'))); + setEventMessages($langs->trans("ProductDeleted", GETPOST('delprod')), null, 'mesgs'); } if ($sref) $param="&sref=".$sref; diff --git a/htdocs/product/price.php b/htdocs/product/price.php index 2a770841c60..e5b93d981af 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -6,7 +6,7 @@ * Copyright (C) 2006 Andre Cianfarani * Copyright (C) 2014 Florian Henry * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2014 Philippe Grand + * Copyright (C) 2014-2015 Philippe Grand * Copyright (C) 2014 Ion agorria * Copyright (C) 2015 Alexandre Spangaro * Copyright (C) 2015 Marcos GarcĂ­a @@ -131,7 +131,7 @@ if (empty($reshook)) if ($priceparser->parseProduct($object) < 0) { $error ++; - setEventMessage($priceparser->translatedError(), 'errors'); + setEventMessages($priceparser->translatedError(), null, 'errors'); } } } @@ -194,7 +194,7 @@ if (empty($reshook)) $newprice_min = price2num($val['price_min'], 'MU'); if (!empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $newprice_min < $maxpricesupplier) { - setEventMessage($langs->trans("MinimumPriceLimit", price($maxpricesupplier, 0, '', 1, - 1, - 1, 'auto')), 'errors'); + setEventMessages($langs->trans("MinimumPriceLimit", price($maxpricesupplier, 0, '', 1, - 1, - 1, 'auto')), null, 'errors'); $error ++; break; } @@ -203,7 +203,7 @@ if (empty($reshook)) if ($res < 0) { $error ++; - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); break; } } @@ -211,12 +211,12 @@ if (empty($reshook)) if (!$error && $object->update($object->id, $user) < 0) { $error++; - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } if (empty($error)) { $action = ''; - setEventMessage($langs->trans("RecordSaved")); + setEventMessages($langs->trans("RecordSaved"), null, 'mesgs'); $db->commit(); } else { $action = 'edit_price'; @@ -229,7 +229,7 @@ if (empty($reshook)) { $result = $object->log_price_delete($user, $_GET ["lineid"]); if ($result < 0) { - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -341,7 +341,7 @@ if (empty($reshook)) if (! empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE) && $prodcustprice->price_min<$maxpricesupplier) { - setEventMessage($langs->trans("MinimumPriceLimit",price($maxpricesupplier,0,'',1,-1,-1,'auto')),'errors'); + setEventMessages($langs->trans("MinimumPriceLimit",price($maxpricesupplier,0,'',1,-1,-1,'auto')), null, 'errors'); $error++; $action='add_customer_price'; } @@ -351,9 +351,9 @@ if (empty($reshook)) $result = $prodcustprice->create($user, 0, $update_child_soc); if ($result < 0) { - setEventMessage($prodcustprice->error, 'errors'); + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); } else { - setEventMessage($langs->trans('RecordSaved'), 'mesgs'); + setEventMessages($langs->trans('RecordSaved'), null, 'mesgs'); } $action = ''; @@ -367,9 +367,9 @@ if (empty($reshook)) $result = $prodcustprice->delete($user); if ($result < 0) { - setEventMessage($prodcustprice->error, 'mesgs'); + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'mesgs'); } else { - setEventMessage($langs->trans('RecordDeleted'), 'errors'); + setEventMessages($langs->trans('RecordDeleted'), null, 'errors'); } $action = ''; } @@ -391,7 +391,7 @@ if (empty($reshook)) if ($prodcustprice->price_min<$maxpricesupplier && !empty($conf->global->PRODUCT_MINIMUM_RECOMMENDED_PRICE)) { - setEventMessage($langs->trans("MinimumPriceLimit",price($maxpricesupplier,0,'',1,-1,-1,'auto')),'errors'); + setEventMessages($langs->trans("MinimumPriceLimit",price($maxpricesupplier,0,'',1,-1,-1,'auto')), null, 'errors'); $error++; $action='update_customer_price'; } @@ -401,9 +401,9 @@ if (empty($reshook)) $result = $prodcustprice->update($user, 0, $update_child_soc); if ($result < 0) { - setEventMessage($prodcustprice->error, 'errors'); + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); } else { - setEventMessage($langs->trans('Save'), 'mesgs'); + setEventMessages($langs->trans('Save'), null, 'mesgs'); } $action = ''; @@ -1257,7 +1257,7 @@ if (! empty($conf->global->PRODUIT_CUSTOMER_PRICES)) $result = $prodcustprice->fetch(GETPOST('lineid', 'int')); if ($result < 0) { - setEventMessage($prodcustprice->error, 'errors'); + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); } print '
'; @@ -1346,7 +1346,7 @@ 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'); + setEventMessages($prodcustprice->error, $prodcustprice->errors, 'errors'); } $option = '&socid=' . GETPOST('socid', 'int') . '&id=' . $object->id; @@ -1422,7 +1422,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/product/stock/mouvement.php b/htdocs/product/stock/mouvement.php index a6085699a63..463ac8c5468 100644 --- a/htdocs/product/stock/mouvement.php +++ b/htdocs/product/stock/mouvement.php @@ -100,7 +100,7 @@ if ($action == "correct_stock") if (! is_numeric($_POST["nbpiece"])) { $error++; - setEventMessage($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv("NumberOfUnit")), 'errors'); + setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentitiesnoconv("NumberOfUnit")), null, 'errors'); $action='correction'; } diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 0476a459f60..ad4acbe362a 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -77,7 +77,7 @@ if ($action == 'setstocklimit') $object->seuil_stock_alerte=$stocklimit; $result=$object->update($object->id,$user,0,'update'); if ($result < 0) - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $action=''; } @@ -89,7 +89,7 @@ if ($action == 'setdesiredstock') $object->desiredstock=$desiredstock; $result=$object->update($object->id,$user,0,'update'); if ($result < 0) - setEventMessage($object->error, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $action=''; } diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index 620f1acbb40..5df580877c5 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -176,7 +176,7 @@ if ($action == 'order' && isset($_POST['valid'])) $fail++; $msg = $langs->trans('OrderFail') . " : "; $msg .= $order->error; - setEventMessage($msg, 'errors'); + setEventMessages($msg, null, 'errors'); } else { $id = $result; } @@ -195,7 +195,7 @@ if ($action == 'order' && isset($_POST['valid'])) $fail++; $msg = $langs->trans('OrderFail') . " : "; $msg .= $order->error; - setEventMessage($msg, 'errors'); + setEventMessages($msg, null, 'errors'); } $i++; } @@ -205,7 +205,7 @@ if ($action == 'order' && isset($_POST['valid'])) { $db->commit(); - setEventMessage($langs->trans('OrderCreated'), 'mesgs'); + setEventMessages($langs->trans('OrderCreated'), null, 'mesgs'); header('Location: replenishorders.php'); exit; } @@ -216,7 +216,7 @@ if ($action == 'order' && isset($_POST['valid'])) } if ($box == 0) { - setEventMessage($langs->trans('SelectProductWithNotNullQty'), 'warnings'); + setEventMessages($langs->trans('SelectProductWithNotNullQty'), null, 'warnings'); } } diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index a40b7b15cd9..96c94e9efff 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -94,7 +94,7 @@ $cancel != $langs->trans("Cancel") && else { $action = 'add'; - setEventMessage($object->error,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -130,7 +130,7 @@ $cancel != $langs->trans("Cancel") && else { $action = 'edit'; - setEventMessage($object->error,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -151,7 +151,7 @@ $cancel != $langs->trans("Cancel") && else { $action = 'edit'; - setEventMessage($object->error,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } }