diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 8f3dfdcfe64..63cdf3b1052 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -6,6 +6,7 @@ * Copyright (C) 2004 Andre Cianfarani * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) + * Copyright (C) 2011 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,18 +40,32 @@ $langs->load("orders"); if (!$user->admin) accessforbidden(); +$action = GETPOST("action"); +$value = GETPOST("value"); + /* * Actions */ -if ($_POST["action"] == 'updateMask') +if ($action == 'updateMask') { $maskconstorder=$_POST['maskconstorder']; $maskorder=$_POST['maskorder']; - if ($maskconstorder) dolibarr_set_const($db,$maskconstorder,$maskorder,'chaine',0,'',$conf->entity); + if ($maskconstorder) $res = dolibarr_set_const($db,$maskconstorder,$maskorder,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + $mesg = "".$langs->trans("SetupSaved").""; + } + else + { + $mesg = "".$langs->trans("Error").""; + } } -if ($_GET["action"] == 'specimen') +if ($action == 'specimen') { $modele=$_GET["module"]; @@ -85,13 +100,16 @@ if ($_GET["action"] == 'specimen') } } -if ($_GET["action"] == 'set') +if ($action == 'set') { + $label = GETPOST("label"); + $scandir = GETPOST("scandir"); + $type='order'; $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; - $sql.= " VALUES ('".$db->escape($_GET["value"])."','".$type."',".$conf->entity.", "; - $sql.= ($_GET["label"]?"'".$db->escape($_GET["label"])."'":'null').", "; - $sql.= (! empty($_GET["scandir"])?"'".$db->escape($_GET["scandir"])."'":"null"); + $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", "; + $sql.= ($label?"'".$db->escape($label)."'":'null').", "; + $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null"); $sql.= ")"; if ($db->query($sql)) { @@ -99,11 +117,11 @@ if ($_GET["action"] == 'set') } } -if ($_GET["action"] == 'del') +if ($action == 'del') { $type='order'; $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; - $sql.= " WHERE nom = '".$_GET["value"]."'"; + $sql.= " WHERE nom = '".$value."'"; $sql.= " AND type = '".$type."'"; $sql.= " AND entity = ".$conf->entity; @@ -113,27 +131,30 @@ if ($_GET["action"] == 'del') } } -if ($_GET["action"] == 'setdoc') +if ($action == 'setdoc') { + $label = GETPOST("label"); + $scandir = GETPOST("scandir"); + $db->begin(); - if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF",$_GET["value"],'chaine',0,'',$conf->entity)) + if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) { - $conf->global->COMMANDE_ADDON_PDF = $_GET["value"]; + $conf->global->COMMANDE_ADDON_PDF = $value; } // On active le modele $type='order'; $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; - $sql_del.= " WHERE nom = '".$db->escape($_GET["value"])."'"; + $sql_del.= " WHERE nom = '".$db->escape($value)."'"; $sql_del.= " AND type = '".$type."'"; $sql_del.= " AND entity = ".$conf->entity; $result1=$db->query($sql_del); $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; - $sql.= " VALUES ('".$_GET["value"]."', '".$type."', ".$conf->entity.", "; - $sql.= ($_GET["label"]?"'".$db->escape($_GET["label"])."'":'null').", "; - $sql.= (! empty($_GET["scandir"])?"'".$_GET["scandir"]."'":"null"); + $sql.= " VALUES ('".$value."', '".$type."', ".$conf->entity.", "; + $sql.= ($label?"'".$db->escape($label)."'":'null').", "; + $sql.= (! empty($scandir)?"'".$scandir."'":"null"); $sql.= ")"; $result2=$db->query($sql); if ($result1 && $result2) @@ -146,39 +167,63 @@ if ($_GET["action"] == 'setdoc') } } -if ($_GET["action"] == 'setmod') +if ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active // par appel methode canBeActivated - dolibarr_set_const($db, "COMMANDE_ADDON",$_GET["value"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "COMMANDE_ADDON",$value,'chaine',0,'',$conf->entity); } -if ($_POST["action"] == 'set_COMMANDE_DRAFT_WATERMARK') +if ($action == 'set_COMMANDE_DRAFT_WATERMARK') { - dolibarr_set_const($db, "COMMANDE_DRAFT_WATERMARK",trim($_POST["COMMANDE_DRAFT_WATERMARK"]),'chaine',0,'',$conf->entity); + $draft = GETPOST("COMMANDE_DRAFT_WATERMARK"); + $res = dolibarr_set_const($db, "COMMANDE_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + $mesg = "".$langs->trans("SetupSaved").""; + } + else + { + $mesg = "".$langs->trans("Error").""; + } } -if ($_POST["action"] == 'set_COMMANDE_FREE_TEXT') +if ($action == 'set_COMMANDE_FREE_TEXT') { - dolibarr_set_const($db, "COMMANDE_FREE_TEXT",$_POST["COMMANDE_FREE_TEXT"],'chaine',0,'',$conf->entity); -} + $freetext = GETPOST("COMMANDE_FREE_TEXT"); + $res = dolibarr_set_const($db, "COMMANDE_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; -if ($_POST["action"] == 'setvalidorder') + if (! $error) + { + $mesg = "".$langs->trans("SetupSaved").""; + } + else + { + $mesg = "".$langs->trans("Error").""; + } +} +/* +if ($action == 'setvalidorder') { dolibarr_set_const($db, "COMMANDE_VALID_AFTER_CLOSE_PROPAL",$_POST["validorder"],'chaine',0,'',$conf->entity); } -if ($_POST["action"] == 'deliverycostline') +if ($action == 'deliverycostline') { dolibarr_set_const($db, "COMMANDE_ADD_DELIVERY_COST_LINE",$_POST["addline"],'chaine',0,'',$conf->entity); } -if ($_POST["action"] == 'set_use_customer_contact_as_recipient') +if ($action == 'set_use_customer_contact_as_recipient') { dolibarr_set_const($db, "COMMANDE_USE_CUSTOMER_CONTACT_AS_RECIPIENT",$_POST["use_customer_contact_as_recipient"],'chaine',0,'',$conf->entity); } - +*/ /* * View @@ -254,12 +299,12 @@ foreach ($conf->file->dol_document_root as $dirroot) print ''; if ($conf->global->COMMANDE_ADDON == "$file") { - print img_picto($langs->trans("Activated"),'on'); + print img_picto($langs->trans("Activated"),'switch_on'); } else { print ''; - print img_picto($langs->trans("Disabled"),'off'); + print img_picto($langs->trans("Disabled"),'switch_off'); print ''; } print ''; @@ -376,18 +421,18 @@ foreach ($conf->file->dol_document_root as $dirroot) if ($conf->global->COMMANDE_ADDON_PDF != "$name") { print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Activated"),'on'); + print img_picto($langs->trans("Activated"),'switch_on'); print ''; } else { - print img_picto($langs->trans("Activated"),'on'); + print img_picto($langs->trans("Activated"),'switch_on'); } } else { print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Disabled"),'off'); + print img_picto($langs->trans("Disabled"),'switch_off'); print ''; } print ""; @@ -396,12 +441,12 @@ foreach ($conf->file->dol_document_root as $dirroot) print ""; if ($conf->global->COMMANDE_ADDON_PDF == "$name") { - print img_picto($langs->trans("Yes"),'on'); + print img_picto($langs->trans("Yes"),'switch_on'); } else { print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("No"),'off'); + print img_picto($langs->trans("No"),'switch_off'); print ''; } print ''; @@ -520,5 +565,9 @@ print ''; print '
'; +dol_htmloutput_mesg($mesg); + +$db->close(); + llxFooter(); ?>