diff --git a/htdocs/admin/confexped.php b/htdocs/admin/confexped.php index adfff3fa60f..8920fee2885 100644 --- a/htdocs/admin/confexped.php +++ b/htdocs/admin/confexped.php @@ -2,6 +2,7 @@ /* Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2006 Andre Cianfarani + * 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 @@ -33,27 +34,27 @@ $langs->load("deliveries"); if (!$user->admin) accessforbidden(); +$action=GETPOST("action"); - -if ($_GET["action"] == 'activate_sending') +if ($action == 'activate_sending') { dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1",'chaine',0,'',$conf->entity); Header("Location: confexped.php"); exit; } -else if ($_GET["action"] == 'disable_sending') +else if ($action == 'disable_sending') { dolibarr_del_const($db, "MAIN_SUBMODULE_EXPEDITION",$conf->entity); Header("Location: confexped.php"); exit; } -else if ($_GET["action"] == 'activate_delivery') +else if ($action == 'activate_delivery') { dolibarr_set_const($db, "MAIN_SUBMODULE_LIVRAISON", "1",'chaine',0,'',$conf->entity); Header("Location: confexped.php"); exit; } -else if ($_GET["action"] == 'disable_delivery') +else if ($action == 'disable_delivery') { dolibarr_del_const($db, "MAIN_SUBMODULE_LIVRAISON",$conf->entity); Header("Location: confexped.php"); @@ -119,11 +120,11 @@ print ''; if($conf->global->MAIN_SUBMODULE_EXPEDITION == 0) { - print ''.img_picto($langs->trans("Disabled"),'off').''; + print ''.img_picto($langs->trans("Disabled"),'switch_off').''; } else if($conf->global->MAIN_SUBMODULE_EXPEDITION == 1) { - print ''.img_picto($langs->trans("Enabled"),'on').''; + print ''.img_picto($langs->trans("Enabled"),'switch_on').''; } print ""; @@ -139,11 +140,11 @@ print ''; if($conf->global->MAIN_SUBMODULE_LIVRAISON == 0) { - print ''.img_picto($langs->trans("Disabled"),'off').''; + print ''.img_picto($langs->trans("Disabled"),'switch_off').''; } else if($conf->global->MAIN_SUBMODULE_LIVRAISON == 1) { - print ''.img_picto($langs->trans("Enabled"),'on').''; + print ''.img_picto($langs->trans("Enabled"),'switch_on').''; } print ""; diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 9e82ec1fc96..f0e468c7c53 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -32,13 +32,14 @@ require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); require_once(DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'); $langs->load("admin"); -$langs->load("bills"); -$langs->load("other"); $langs->load("sendings"); $langs->load("deliveries"); if (!$user->admin) accessforbidden(); +$action=GETPOST("action"); +$value=GETPOST("value"); + if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) { $conf->global->EXPEDITION_ADDON_NUMBER='mod_expedition_safor'; @@ -48,9 +49,9 @@ if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) /* * Actions */ -if ($_GET["action"] == 'specimen') +if ($action == 'specimen') { - $modele=$_GET["module"]; + $modele=GETPOST("module"); $exp = new Expedition($db); $exp->initAsSpecimen(); @@ -73,25 +74,28 @@ if ($_GET["action"] == 'specimen') } else { - $mesg='
'.$obj->error.'
'; + $mesg=''.$obj->error.''; dol_syslog($obj->error, LOG_ERR); } } else { - $mesg='
'.$langs->trans("ErrorModuleNotFound").'
'; + $mesg=''.$langs->trans("ErrorModuleNotFound").''; dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } // Activate a model -if ($_GET["action"] == 'set') +if ($action == 'set') { + $label = GETPOST("label"); + $scandir = GETPOST("scandir"); + $type='shipping'; $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 +103,11 @@ if ($_GET["action"] == 'set') } } -if ($_GET["action"] == 'del') +if ($action == 'del') { $type='shipping'; $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; @@ -114,27 +118,30 @@ if ($_GET["action"] == 'del') } // Set default model -if ($_GET["action"] == 'setdoc') +if ($action == 'setdoc') { + $label = GETPOST("label"); + $scandir = GETPOST("scandir"); + $db->begin(); - if (dolibarr_set_const($db, "EXPEDITION_ADDON_PDF",$_GET["value"],'chaine',0,'',$conf->entity)) + if (dolibarr_set_const($db, "EXPEDITION_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) { - $conf->global->EXPEDITION_ADDON_PDF = $_GET["value"]; + $conf->global->EXPEDITION_ADDON_PDF = $value; } // On active le modele $type='shipping'; $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 ('".$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.= ")"; $result2=$db->query($sql); if ($result1 && $result2) @@ -148,11 +155,11 @@ if ($_GET["action"] == 'setdoc') } // TODO A quoi servent les methode d'expedition ? -if ($_GET["action"] == 'setmethod' || $_GET["action"] == 'setmod') +if ($action == 'setmethod' || $action== 'setmod') { - $module=$_GET["module"]; - $moduleid=$_GET["moduleid"]; - $statut=$_GET["statut"]; + $module=GETPOST("module"); + $moduleid=GETPOST("moduleid"); + $statut=GETPOST("statut"); require_once(DOL_DOCUMENT_ROOT."/includes/modules/expedition/methode_expedition_$module.modules.php"); @@ -163,7 +170,7 @@ if ($_GET["action"] == 'setmethod' || $_GET["action"] == 'setmod') $sql.= " WHERE rowid = ".$moduleid; $resql = $db->query($sql); - if ($resql && ($statut == 1 || $_GET["action"] == 'setmod')) + if ($resql && ($statut == 1 || $action == 'setmod')) { $db->begin(); @@ -182,7 +189,7 @@ if ($_GET["action"] == 'setmethod' || $_GET["action"] == 'setmod') } } - if ($statut == 1 || $_GET["action"] == 'setmod') + if ($statut == 1 || $action == 'setmod') { $db->begin(); @@ -218,34 +225,71 @@ if ($_GET["action"] == 'setmethod' || $_GET["action"] == 'setmod') } } -if ($_GET["action"] == 'setmod') +if ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active // par appel methode canBeActivated - - dolibarr_set_const($db, "EXPEDITION_ADDON",$_GET["module"],'chaine',0,'',$conf->entity); + + $module=GETPOST("module"); + + dolibarr_set_const($db, "EXPEDITION_ADDON",$module,'chaine',0,'',$conf->entity); + } -if ($_POST["action"] == 'updateMask') +if ($action == 'updateMask') { - $maskconst=$_POST['maskconstexpedition']; - $maskvalue=$_POST['maskexpedition']; - if ($maskconst) dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity); + $maskconst=GETPOST("maskconstexpedition"); + $maskvalue=GETPOST("maskexpedition"); + if ($maskconst) $res = dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + $mesg = "".$langs->trans("SetupSaved").""; + } + else + { + $mesg = "".$langs->trans("Error").""; + } } -if ($_GET["action"] == 'setmodel') +if ($action == 'setmodel') { - dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER",$_GET["value"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity); } -if ($_POST["action"] == 'set_SHIPPING_DRAFT_WATERMARK') +if ($action == 'set_SHIPPING_DRAFT_WATERMARK') { - dolibarr_set_const($db, "SHIPPING_DRAFT_WATERMARK",trim($_POST["SHIPPING_DRAFT_WATERMARK"]),'chaine',0,'',$conf->entity); + $draft=GETPOST("SHIPPING_DRAFT_WATERMARK"); + $res = dolibarr_set_const($db, "SHIPPING_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_SHIPPING_FREE_TEXT') +if ($action == 'set_SHIPPING_FREE_TEXT') { - dolibarr_set_const($db, "SHIPPING_FREE_TEXT",$_POST["SHIPPING_FREE_TEXT"],'chaine',0,'',$conf->entity); + $free=GETPOST("SHIPPING_FREE_TEXT"); + $res = dolibarr_set_const($db, "SHIPPING_FREE_TEXT",$free,'chaine',0,'',$conf->entity); + if (! $res > 0) $error++; + + if (! $error) + { + $mesg = "".$langs->trans("SetupSaved").""; + } + else + { + $mesg = "".$langs->trans("Error").""; + } } @@ -263,7 +307,7 @@ print_fiche_titre($langs->trans("SendingsSetup"),$linkback,'setup'); print '
'; -if ($mesg) print $mesg.'
'; +//if ($mesg) print $mesg.'
'; $h = 0; @@ -351,12 +395,12 @@ foreach ($conf->file->dol_document_root as $dirroot) print ''; if ($conf->global->EXPEDITION_ADDON_NUMBER == "$file") { - 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 ''; @@ -475,19 +519,19 @@ foreach ($conf->file->dol_document_root as $dirroot) if ($conf->global->EXPEDITION_ADDON_PDF != $name) { print ''; - 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'); } print ""; } else { print "\n"; - print ''.img_picto($langs->trans("Disabled"),'off').''; + print ''.img_picto($langs->trans("Disabled"),'switch_off').''; print ""; } @@ -495,11 +539,11 @@ foreach ($conf->file->dol_document_root as $dirroot) print ""; if ($conf->global->EXPEDITION_ADDON_PDF == $name) { - print img_picto($langs->trans("Default"),'on'); + print img_picto($langs->trans("Default"),'switch_on'); } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').''; } print ''; @@ -568,6 +612,8 @@ print ''; print ''; +dol_htmloutput_mesg($mesg); + $db->close(); llxFooter(); diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 3c85e3b4ee2..c3ed4a97ec0 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -5,6 +5,7 @@ * Copyright (C) 2004 Benoit Mortier * 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 @@ -31,35 +32,73 @@ require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); require_once(DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php'); $langs->load("admin"); -$langs->load("bills"); -$langs->load("other"); -$langs->load("interventions"); +$langs->load("errors"); +/*$langs->load("other"); +$langs->load("interventions");*/ if (!$user->admin) accessforbidden(); +$action = GETPOST("action"); +$value = GETPOST("value"); /* * Actions */ -if ($_POST["action"] == 'updateMask') +if ($action == 'updateMask') { - $maskconst=$_POST['maskconst']; - $maskvalue=$_POST['maskvalue']; - if ($maskconst) dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity); + $maskconst=GETPOST("maskconst"); + $maskvalue=getpost("maskvalue"); + if ($maskconst) $res = dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + $mesg = "".$langs->trans("SetupSaved").""; + } + else + { + $mesg = "".$langs->trans("Error").""; + } } -if ($_POST["action"] == 'set_FICHINTER_FREE_TEXT') +if ($action == 'set_FICHINTER_FREE_TEXT') { - dolibarr_set_const($db, "FICHINTER_FREE_TEXT",$_POST["FICHINTER_FREE_TEXT"],'chaine',0,'',$conf->entity); + $freetext= GETPOST("FICHINTER_FREE_TEXT"); + $res = dolibarr_set_const($db, "FICHINTER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + $mesg = "".$langs->trans("SetupSaved").""; + } + else + { + $mesg = "".$langs->trans("Error").""; + } } -if ($_POST["action"] == 'set_FICHINTER_DRAFT_WATERMARK') +if ($action == 'set_FICHINTER_DRAFT_WATERMARK') { - dolibarr_set_const($db, "FICHINTER_DRAFT_WATERMARK",trim($_POST["FICHINTER_DRAFT_WATERMARK"]),'chaine',0,'',$conf->entity); + $draft= GETPOST("FICHINTER_DRAFT_WATERMARK"); + + $res = dolibarr_set_const($db, "FICHINTER_DRAFT_WATERMARK",trim($draft),'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"]; @@ -83,24 +122,27 @@ if ($_GET["action"] == 'specimen') } else { - $mesg='
'.$obj->error.'
'; + $mesg=''.$obj->error.''; dol_syslog($obj->error, LOG_ERR); } } else { - $mesg='
'.$langs->trans("ErrorModuleNotFound").'
'; + $mesg=''.$langs->trans("ErrorModuleNotFound").''; dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } -if ($_GET["action"] == 'set') +if ($action == 'set') { + $label = GETPOST("label"); + $scandir = GETPOST("scandir"); + $type='ficheinter'; $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)) { @@ -108,11 +150,11 @@ if ($_GET["action"] == 'set') } } -if ($_GET["action"] == 'del') +if ($action == 'del') { $type='ficheinter'; $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; @@ -122,30 +164,33 @@ if ($_GET["action"] == 'del') } } -if ($_GET["action"] == 'setdoc') +if ($action == 'setdoc') { + $label = GETPOST("label"); + $scandir = GETPOST("scandir"); + $db->begin(); - if (dolibarr_set_const($db, "FICHEINTER_ADDON_PDF",$_GET["value"],'chaine',0,'',$conf->entity)) + if (dolibarr_set_const($db, "FICHEINTER_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) { // La constante qui a ete lue en avant du nouveau set // on passe donc par une variable pour avoir un affichage coherent - $conf->global->FICHEINTER_ADDON_PDF = $_GET["value"]; + $conf->global->FICHEINTER_ADDON_PDF = $value; } // On active le modele $type='ficheinter'; $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; dol_syslog("fichinter: sql_del=".$sql_del); $result1=$db->query($sql_del); $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.= ")"; dol_syslog("fichinter: sql_del=".$sql_del); $result2=$db->query($sql); @@ -159,20 +204,21 @@ 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, "FICHEINTER_ADDON",$_GET["value"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "FICHEINTER_ADDON",$value,'chaine',0,'',$conf->entity); } +/* // defini les constantes du modele arctic if ($_POST["action"] == 'updateMatrice') dolibarr_set_const($db, "FICHEINTER_NUM_MATRICE",$_POST["matrice"],'chaine',0,'',$conf->entity); if ($_POST["action"] == 'updatePrefix') dolibarr_set_const($db, "FICHEINTER_NUM_PREFIX",$_POST["prefix"],'chaine',0,'',$conf->entity); if ($_POST["action"] == 'setOffset') dolibarr_set_const($db, "FICHEINTER_NUM_DELTA",$_POST["offset"],'chaine',0,'',$conf->entity); if ($_POST["action"] == 'setNumRestart') dolibarr_set_const($db, "FICHEINTER_NUM_RESTART_BEGIN_YEAR",$_POST["numrestart"],'chaine',0,'',$conf->entity); - +*/ /* * Affichage page @@ -244,11 +290,11 @@ foreach ($conf->file->dol_document_root as $dirroot) print ''; if ($conf->global->FICHEINTER_ADDON == $classname) { - print img_picto($langs->trans("Activated"),'on'); + print img_picto($langs->trans("Activated"),'switch_on'); } else { - print ''.img_picto($langs->trans("Disabled"),'off').''; + print ''.img_picto($langs->trans("Disabled"),'switch_off').''; } print ''; @@ -352,19 +398,19 @@ foreach ($conf->file->dol_document_root as $dirroot) if ($conf->global->FICHEINTER_ADDON_PDF != "$name") { print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Enabled"),'on'); + print img_picto($langs->trans("Enabled"),'switch_on'); print ''; } else { - print img_picto($langs->trans("Enabled"),'on'); + print img_picto($langs->trans("Enabled"),'switch_on'); } print ""; } else { print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; print ""; } @@ -372,11 +418,11 @@ foreach ($conf->file->dol_document_root as $dirroot) print ""; if ($conf->global->FICHEINTER_ADDON_PDF == "$name") { - print img_picto($langs->trans("Default"),'on'); + print img_picto($langs->trans("Default"),'switch_on'); } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').''; } print ''; @@ -449,6 +495,8 @@ print ''; print '
'; +dol_htmloutput_mesg($mesg); + $db->close(); llxFooter(); diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index dea2fe3e2f1..ca93bb35313 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -5,7 +5,8 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2011 Regis Houssin - * + * 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 * the Free Software Foundation; either version 2 of the License, or @@ -30,29 +31,40 @@ require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php"); require_once(DOL_DOCUMENT_ROOT."/livraison/class/livraison.class.php"); $langs->load("admin"); -$langs->load("bills"); -$langs->load("other"); $langs->load("sendings"); $langs->load("deliveries"); if (!$user->admin) accessforbidden(); +$action = GETPOST("action"); +$value = GETPOST("value"); /* * Actions */ -if ($_POST["action"] == 'updateMask') +if ($action == 'updateMask') { - $maskconstdelivery=$_POST['maskconstdelivery']; - $maskdelivery=$_POST['maskdelivery']; - if ($maskconstdelivery) dolibarr_set_const($db,$maskconstdelivery,$maskdelivery,'chaine',0,'',$conf->entity); + $maskconstdelivery=GETPOST("maskconstdelivery"); + $maskdelivery=GETPOST("maskdelivery"); + if ($maskconstdelivery) $res = dolibarr_set_const($db,$maskconstdelivery,$maskdelivery,'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"]; - + $modele=GETPOST("module"); + $sending = new Livraison($db); $sending->initAsSpecimen(); //$sending->fetch_commande(); @@ -74,24 +86,27 @@ if ($_GET["action"] == 'specimen') } else { - $mesg='
'.$obj->error.'
'; + $mesg=''.$obj->error.''; dol_syslog($obj->error, LOG_ERR); } } else { - $mesg='
'.$langs->trans("ErrorModuleNotFound").'
'; + $mesg=''.$langs->trans("ErrorModuleNotFound").''; dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } -if ($_GET["action"] == 'set') +if ($action == 'set') { + $label = GETPOST("label"); + $scandir = GETPOST("scandir"); + $type='delivery'; $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 +114,11 @@ if ($_GET["action"] == 'set') } } -if ($_GET["action"] == 'del') +if ($action == 'del') { $type='delivery'; $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 +128,29 @@ if ($_GET["action"] == 'del') } } -if ($_GET["action"] == 'setdoc') +if ($action == 'setdoc') { + $label = GETPOST("label"); + $scandir = GETPOST("scandir"); $db->begin(); - if (dolibarr_set_const($db, "LIVRAISON_ADDON_PDF",$_GET["value"],'chaine',0,'',$conf->entity)) + if (dolibarr_set_const($db, "LIVRAISON_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) { - $conf->global->LIVRAISON_ADDON_PDF = $_GET["value"]; + $conf->global->LIVRAISON_ADDON_PDF = $value; } // On active le modele $type='delivery'; $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 ('".$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.= ")"; $result2=$db->query($sql); if ($result1 && $result2) @@ -146,17 +163,29 @@ if ($_GET["action"] == 'setdoc') } } -if ($_POST["action"] == 'set_DELIVERY_FREE_TEXT') +if ($action == 'set_DELIVERY_FREE_TEXT') { - dolibarr_set_const($db, "DELIVERY_FREE_TEXT",$_POST["DELIVERY_FREE_TEXT"],'chaine',0,'',$conf->entity); + $free=GETPOST("DELIVERY_FREE_TEXT"); + $res=dolibarr_set_const($db, "DELIVERY_FREE_TEXT",$free,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + $mesg = "".$langs->trans("SetupSaved").""; + } + else + { + $mesg = "".$langs->trans("Error").""; + } } -if ($_GET["action"] == 'setmod') +if ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active // par appel methode canBeActivated - dolibarr_set_const($db, "LIVRAISON_ADDON",$_GET["value"],'chaine',0,'',$conf->entity); + dolibarr_set_const($db, "LIVRAISON_ADDON",$value,'chaine',0,'',$conf->entity); } @@ -244,18 +273,22 @@ foreach ($conf->file->dol_document_root as $dirroot) // Show example of numbering module print ''; $tmp=$module->getExample(); - if (preg_match('/^Error/',$tmp)) print $langs->trans($tmp); + if (preg_match('/^Error/',$tmp)) + { + $langs->load("errors"); + print $langs->trans($tmp); + } else print $tmp; print ''."\n"; print ''; if ($conf->global->LIVRAISON_ADDON == "$file") { - print img_picto($langs->trans("Activated"),'on'); + print img_picto($langs->trans("Activated"),'switch_on'); } else { - print ''.img_picto($langs->trans("Disabled"),'off').''; + print ''.img_picto($langs->trans("Disabled"),'switch_off').''; } print ''; @@ -372,19 +405,19 @@ foreach ($conf->file->dol_document_root as $dirroot) if ($conf->global->LIVRAISON_ADDON_PDF != "$name") { print 'scandir.'&label='.urlencode($module->name).'">'; - print img_picto($langs->trans("Enabled"),'on'); + print img_picto($langs->trans("Enabled"),'switch_on'); print ''; } else { - print img_picto($langs->trans("Enabled"),'on'); + print img_picto($langs->trans("Enabled"),'switch_on'); } print ""; } else { print "\n"; - print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; print ""; } @@ -392,11 +425,11 @@ foreach ($conf->file->dol_document_root as $dirroot) print ""; if ($conf->global->LIVRAISON_ADDON_PDF == "$name") { - print img_picto($langs->trans("Default"),'on'); + print img_picto($langs->trans("Default"),'switch_on'); } else { - print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').''; } print ''; @@ -451,6 +484,8 @@ print ''; print ''; +dol_htmloutput_mesg($mesg); + $db->close(); llxFooter(); diff --git a/htdocs/admin/propale.php b/htdocs/admin/propale.php index f1590913fdb..72212a285cc 100644 --- a/htdocs/admin/propale.php +++ b/htdocs/admin/propale.php @@ -88,13 +88,13 @@ if ($action == 'specimen') } else { - $mesg=''.$module->error.''; + $mesg=''.$module->error.''; dol_syslog($module->error, LOG_ERR); } } else { - $mesg=''.$langs->trans("ErrorModuleNotFound").''; + $mesg=''.$langs->trans("ErrorModuleNotFound").''; dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } }