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

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016 Abbes Bahfir <contact@dolibarrpar.com>
*
@ -67,7 +67,7 @@ if ($action == 'add')
if ($actionid <= 0)
{
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Action")), 'errors');
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Action")), null, 'errors');
$error++;
}

View File

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

View File

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

View File

@ -104,7 +104,7 @@ if ($_POST) {
$features = $_SESSION['addvariant_'.$object->id];
if (!$features) {
setEventMessage($langs->trans('ErrorFieldsRequired'), 'errors');
setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors');
}
else
{
@ -147,7 +147,7 @@ if ($_POST) {
$result = $prodcomb->createProductCombination($object, $sanit_features, array(), $price_impact_percent, $price_impact, $weight_impact);
if ($result > 0)
{
setEventMessage($langs->trans('RecordSaved'));
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
unset($_SESSION['addvariant_'.$object->id]);
$db->commit();
@ -214,7 +214,7 @@ if ($_POST) {
} else {
$db->commit();
setEventMessage($langs->trans('RecordSaved'));
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
}
}
@ -230,7 +230,7 @@ if ($_POST) {
$prodcomb->variation_weight = $weight_impact;
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));
exit();
} 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) {
$db->commit();
setEventMessage($langs->trans('RecordSaved'));
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
header('Location: '.dol_buildpath('/variants/combinations.php?id='.$object->id, 2));
exit();
}
$db->rollback();
setEventMessage($langs->trans('ProductCombinationAlreadyUsed'), 'errors');
setEventMessages($langs->trans('ProductCombinationAlreadyUsed'), null, 'errors');
$action = '';
}
} elseif ($action === 'edit') {
@ -284,12 +284,12 @@ if ($action === 'confirm_deletecombination') {
header('Location: '.dol_buildpath('/variants/combinations.php?id='.$prodstatic->id, 2));
exit();
} else {
setEventMessage($langs->trans('ErrorCopyProductCombinations'), 'errors');
setEventMessages($langs->trans('ErrorCopyProductCombinations'), null, 'errors');
}
}
} 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 (empty($ref) || empty($label)) {
setEventMessage($langs->trans('ErrorFieldsRequired'), 'errors');
setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors');
} else {
$prodattr = new ProductAttribute($db);
@ -38,7 +38,7 @@ if ($_POST) {
$resid = $prodattr->create($user);
if ($resid > 0) {
setEventMessage($langs->trans('RecordSaved'));
setEventMessages($langs->trans('RecordSaved'), null, 'mesgs');
if ($backtopage)
{
header('Location: '.$backtopage);

View File

@ -58,7 +58,7 @@ if ($cancel)
if ($action == 'add')
{
if (empty($ref) || empty($value)) {
setEventMessage($langs->trans('ErrorFieldsRequired'), 'errors');
setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors');
} else {
$objectval->fk_product_attribute = $object->id;
@ -66,11 +66,11 @@ if ($action == 'add')
$objectval->value = $value;
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);
exit();
} else {
setEventMessage($langs->trans('ErrorCreatingProductAttributeValue'), 'errors');
setEventMessages($langs->trans('ErrorCreatingProductAttributeValue'), null, 'errors');
}
}
}

View File

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