Qual: Uniformize code

This commit is contained in:
Juanjo Menent
2011-09-03 14:53:40 +00:00
parent e87e89262f
commit 8fc9b10760

View File

@@ -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 = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
}
/*
* Actions
* View
*/
$html = new Form($db);
@@ -294,6 +318,8 @@ print '</table>';
print "<br>";
dol_htmloutput_mesg($mesg);
$db->close();
llxFooter();