Clean and update code

This commit is contained in:
Philippe GRAND 2018-07-27 14:49:33 +02:00
parent 4eacad52f2
commit 541e919ae0
7 changed files with 30 additions and 30 deletions

View File

@ -67,7 +67,7 @@ if ($action == 'add')
if ($actionid <= 0) if ($actionid <= 0)
{ {
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Action")), 'errors'); setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Action")), null, 'errors');
$error++; $error++;
} }

View File

@ -31,15 +31,15 @@ if ($_POST) {
$value = GETPOST('PRODUIT_ATTRIBUTES_HIDECHILD'); $value = GETPOST('PRODUIT_ATTRIBUTES_HIDECHILD');
if (dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_HIDECHILD', $value, 'chaine', 0, '', $conf->entity)) { if (dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_HIDECHILD', $value, 'chaine', 0, '', $conf->entity)) {
setEventMessage($langs->trans('RecordSaved')); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
} else { } else {
setEventMessage($langs->trans('CoreErrorMessage'), 'errors'); setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors');
} }
if (dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_SEPARATOR', GETPOST('PRODUIT_ATTRIBUTES_SEPARATOR'), 'chaine', 0, '', $conf->entity)) { if (dolibarr_set_const($db, 'PRODUIT_ATTRIBUTES_SEPARATOR', GETPOST('PRODUIT_ATTRIBUTES_SEPARATOR'), 'chaine', 0, '', $conf->entity)) {
setEventMessage($langs->trans('RecordSaved')); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
} else { } else {
setEventMessage($langs->trans('CoreErrorMessage'), 'errors'); setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors');
} }
} }

View File

@ -50,9 +50,9 @@ if ($_POST) {
$object->label = $label; $object->label = $label;
if ($object->update($user) < 1) { if ($object->update($user) < 1) {
setEventMessage($langs->trans('CoreErrorMessage'), 'errors'); setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors');
} else { } else {
setEventMessage($langs->trans('RecordSaved')); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
header('Location: '.dol_buildpath('/variants/card.php?id='.$id, 2)); header('Location: '.dol_buildpath('/variants/card.php?id='.$id, 2));
exit(); exit();
} }
@ -77,9 +77,9 @@ if ($_POST) {
if (! $error) if (! $error)
{ {
if ($objectval->update($user) > 0) { if ($objectval->update($user) > 0) {
setEventMessage($langs->trans('RecordSaved')); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
} else { } else {
setEventMessage($langs->trans('CoreErrorMessage'), 'errors'); setEventMessage($langs->trans('CoreErrorMessage'), null, 'errors');
} }
} }
} }
@ -99,11 +99,11 @@ if ($confirm == 'yes') {
if ($res < 1 || ($object->delete() < 1)) { if ($res < 1 || ($object->delete() < 1)) {
$db->rollback(); $db->rollback();
setEventMessage($langs->trans('CoreErrorMessage'), 'errors'); setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors');
header('Location: '.dol_buildpath('/variants/card.php?id='.$object->id, 2)); header('Location: '.dol_buildpath('/variants/card.php?id='.$object->id, 2));
} else { } else {
$db->commit(); $db->commit();
setEventMessage($langs->trans('RecordSaved')); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
header('Location: '.dol_buildpath('/variants/list.php', 2)); header('Location: '.dol_buildpath('/variants/list.php', 2));
} }
exit(); exit();
@ -113,9 +113,9 @@ if ($confirm == 'yes') {
if ($objectval->fetch($valueid) > 0) { if ($objectval->fetch($valueid) > 0) {
if ($objectval->delete() < 1) { if ($objectval->delete() < 1) {
setEventMessage($langs->trans('CoreErrorMessage'), 'errors'); setEventMessages($langs->trans('CoreErrorMessage'), null, 'errors');
} else { } else {
setEventMessage($langs->trans('RecordSaved')); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
} }
header('Location: '.dol_buildpath('/variants/card.php?id='.$object->id, 2)); header('Location: '.dol_buildpath('/variants/card.php?id='.$object->id, 2));

View File

@ -104,7 +104,7 @@ if ($_POST) {
$features = $_SESSION['addvariant_'.$object->id]; $features = $_SESSION['addvariant_'.$object->id];
if (!$features) { if (!$features) {
setEventMessage($langs->trans('ErrorFieldsRequired'), 'errors'); setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors');
} }
else else
{ {
@ -147,7 +147,7 @@ if ($_POST) {
$result = $prodcomb->createProductCombination($object, $sanit_features, array(), $price_impact_percent, $price_impact, $weight_impact); $result = $prodcomb->createProductCombination($object, $sanit_features, array(), $price_impact_percent, $price_impact, $weight_impact);
if ($result > 0) if ($result > 0)
{ {
setEventMessage($langs->trans('RecordSaved')); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
unset($_SESSION['addvariant_'.$object->id]); unset($_SESSION['addvariant_'.$object->id]);
$db->commit(); $db->commit();
@ -214,7 +214,7 @@ if ($_POST) {
} else { } else {
$db->commit(); $db->commit();
setEventMessage($langs->trans('RecordSaved')); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
} }
} }
@ -230,7 +230,7 @@ if ($_POST) {
$prodcomb->variation_weight = $weight_impact; $prodcomb->variation_weight = $weight_impact;
if ($prodcomb->update($user) > 0) { if ($prodcomb->update($user) > 0) {
setEventMessage($langs->trans('RecordSaved')); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
header('Location: '.dol_buildpath('/variants/combinations.php?id='.$id, 2)); header('Location: '.dol_buildpath('/variants/combinations.php?id='.$id, 2));
exit(); exit();
} else { } else {
@ -250,13 +250,13 @@ if ($action === 'confirm_deletecombination') {
if ($prodcomb->delete($user) > 0 && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete($user) > 0) { if ($prodcomb->delete($user) > 0 && $prodstatic->fetch($prodcomb->fk_product_child) > 0 && $prodstatic->delete($user) > 0) {
$db->commit(); $db->commit();
setEventMessage($langs->trans('RecordSaved')); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
header('Location: '.dol_buildpath('/variants/combinations.php?id='.$object->id, 2)); header('Location: '.dol_buildpath('/variants/combinations.php?id='.$object->id, 2));
exit(); exit();
} }
$db->rollback(); $db->rollback();
setEventMessage($langs->trans('ProductCombinationAlreadyUsed'), 'errors'); setEventMessages($langs->trans('ProductCombinationAlreadyUsed'), null, 'errors');
$action = ''; $action = '';
} }
} elseif ($action === 'edit') { } elseif ($action === 'edit') {
@ -284,12 +284,12 @@ if ($action === 'confirm_deletecombination') {
header('Location: '.dol_buildpath('/variants/combinations.php?id='.$prodstatic->id, 2)); header('Location: '.dol_buildpath('/variants/combinations.php?id='.$prodstatic->id, 2));
exit(); exit();
} else { } else {
setEventMessage($langs->trans('ErrorCopyProductCombinations'), 'errors'); setEventMessages($langs->trans('ErrorCopyProductCombinations'), null, 'errors');
} }
} }
} else { } else {
setEventMessage($langs->trans('ErrorDestinationProductNotFound'), 'errors'); setEventMessages($langs->trans('ErrorDestinationProductNotFound'), null, 'errors');
} }
} }

View File

@ -29,7 +29,7 @@ $backtopage = GETPOST('backtopage', 'alpha');
if ($_POST) { if ($_POST) {
if (empty($ref) || empty($label)) { if (empty($ref) || empty($label)) {
setEventMessage($langs->trans('ErrorFieldsRequired'), 'errors'); setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors');
} else { } else {
$prodattr = new ProductAttribute($db); $prodattr = new ProductAttribute($db);
@ -38,7 +38,7 @@ if ($_POST) {
$resid = $prodattr->create($user); $resid = $prodattr->create($user);
if ($resid > 0) { if ($resid > 0) {
setEventMessage($langs->trans('RecordSaved')); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
if ($backtopage) if ($backtopage)
{ {
header('Location: '.$backtopage); header('Location: '.$backtopage);

View File

@ -58,7 +58,7 @@ if ($cancel)
if ($action == 'add') if ($action == 'add')
{ {
if (empty($ref) || empty($value)) { if (empty($ref) || empty($value)) {
setEventMessage($langs->trans('ErrorFieldsRequired'), 'errors'); setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors');
} else { } else {
$objectval->fk_product_attribute = $object->id; $objectval->fk_product_attribute = $object->id;
@ -66,11 +66,11 @@ if ($action == 'add')
$objectval->value = $value; $objectval->value = $value;
if ($objectval->create($user) > 0) { if ($objectval->create($user) > 0) {
setEventMessage($langs->trans('RecordSaved')); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
header('Location: '.DOL_URL_ROOT.'/variants/card.php?id='.$object->id); header('Location: '.DOL_URL_ROOT.'/variants/card.php?id='.$object->id);
exit(); exit();
} else { } else {
setEventMessage($langs->trans('ErrorCreatingProductAttributeValue'), 'errors'); setEventMessages($langs->trans('ErrorCreatingProductAttributeValue'), null, 'errors');
} }
} }
} }

View File

@ -115,18 +115,18 @@ if ($_POST) {
if ($res > 0) { if ($res > 0) {
$db->commit(); $db->commit();
setEventMessage($langs->trans('RecordSaved')); setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
header('Location: '.dol_buildpath('/variants/combinations.php?id='.$id, 2)); header('Location: '.dol_buildpath('/variants/combinations.php?id='.$id, 2));
exit; exit;
} }
} else { } else {
setEventMessage($langs->trans('ErrorDeletingGeneratedProducts'), 'errors'); setEventMessages($langs->trans('ErrorDeletingGeneratedProducts'), null, 'errors');
} }
$db->rollback(); $db->rollback();
} else { } else {
setEventMessage($langs->trans('ErrorFieldsRequired'), 'errors'); setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors');
} }
} }