diff --git a/htdocs/admin/barcode.php b/htdocs/admin/barcode.php
index dd47597da4e..6db0f3bf8ad 100644
--- a/htdocs/admin/barcode.php
+++ b/htdocs/admin/barcode.php
@@ -30,29 +30,40 @@ require_once(DOL_DOCUMENT_ROOT."/includes/barcode/html.formbarcode.class.php");
$langs->load("admin");
if (!$user->admin)
-accessforbidden();
+ accessforbidden();
-if ($_POST["action"] == 'setcoder')
+$action = GETPOST("action");
+
+/*
+ * Actions
+ */
+
+if ($action == 'setcoder')
{
+ $coder = GETPOST("coder");
+ $code_id = GETPOST("code_id");
$sqlp = "UPDATE ".MAIN_DB_PREFIX."c_barcode_type";
- $sqlp.= " SET coder = '" . $_POST["coder"]."'";
- $sqlp.= " WHERE rowid = ". $_POST["code_id"];
+ $sqlp.= " SET coder = '" . $coder."'";
+ $sqlp.= " WHERE rowid = ". $code_id;
$sqlp.= " AND entity = ".$conf->entity;
$resql=$db->query($sqlp);
//print $sqlp;
}
-else if ($_POST["action"] == 'setgenbarcodelocation')
+else if ($action == 'setgenbarcodelocation')
{
- dolibarr_set_const($db, "GENBARCODE_LOCATION",$_POST["genbarcodelocation"],'chaine',0,'',$conf->entity);
+ $location = GETPOST("genbarcodelocation");
+ $res = dolibarr_set_const($db, "GENBARCODE_LOCATION",$location,'chaine',0,'',$conf->entity);
}
-else if ($_POST["action"] == 'setdefaultbarcodetype')
+else if ($action == 'setdefaultbarcodetype')
{
- dolibarr_set_const($db, "PRODUIT_DEFAULT_BARCODE_TYPE", $_POST["coder_id"],'chaine',0,'',$conf->entity);
+ $coder_id = GETPOST("coder_id");
+ $res = dolibarr_set_const($db, "PRODUIT_DEFAULT_BARCODE_TYPE", $coder_id,'chaine',0,'',$conf->entity);
}
-else if ($_POST["action"] == 'GENBARCODE_BARCODETYPE_THIRDPARTY')
+else if ($action == 'GENBARCODE_BARCODETYPE_THIRDPARTY')
{
- dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $_POST["coder_id"],'chaine',0,'',$conf->entity);
+ $coder_id = GETPOST("coder_id");
+ $res = dolibarr_set_const($db, "GENBARCODE_BARCODETYPE_THIRDPARTY", $coder_id,'chaine',0,'',$conf->entity);
}
/*
else if ($_POST["action"] == 'setproductusebarcode')
@@ -63,9 +74,22 @@ else if ($_POST["action"] == 'GENBARCODE_BARCODETYPE_THIRDPARTY')
}
*/
+if($action && $action!='setcoder')
+{
+ if (! $res > 0) $error++;
+
+ if (! $error)
+ {
+ $mesg = "".$langs->trans("SetupSaved")."";
+ }
+ else
+ {
+ $mesg = "".$langs->trans("Error")."";
+ }
+}
/*
- * Actions
+ * View
*/
$html = new Form($db);
@@ -294,6 +318,8 @@ print '';
print "
";
+dol_htmloutput_mesg($mesg);
+
$db->close();
llxFooter();