Uniformize code

This commit is contained in:
Juanjo Menent 2011-08-31 14:28:42 +00:00
parent 72e6650d71
commit 873f5d44b9
5 changed files with 261 additions and 131 deletions

View File

@ -2,6 +2,7 @@
/* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr> * Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -33,27 +34,27 @@ $langs->load("deliveries");
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
$action=GETPOST("action");
if ($action == 'activate_sending')
if ($_GET["action"] == 'activate_sending')
{ {
dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1",'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_SUBMODULE_EXPEDITION", "1",'chaine',0,'',$conf->entity);
Header("Location: confexped.php"); Header("Location: confexped.php");
exit; exit;
} }
else if ($_GET["action"] == 'disable_sending') else if ($action == 'disable_sending')
{ {
dolibarr_del_const($db, "MAIN_SUBMODULE_EXPEDITION",$conf->entity); dolibarr_del_const($db, "MAIN_SUBMODULE_EXPEDITION",$conf->entity);
Header("Location: confexped.php"); Header("Location: confexped.php");
exit; exit;
} }
else if ($_GET["action"] == 'activate_delivery') else if ($action == 'activate_delivery')
{ {
dolibarr_set_const($db, "MAIN_SUBMODULE_LIVRAISON", "1",'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_SUBMODULE_LIVRAISON", "1",'chaine',0,'',$conf->entity);
Header("Location: confexped.php"); Header("Location: confexped.php");
exit; exit;
} }
else if ($_GET["action"] == 'disable_delivery') else if ($action == 'disable_delivery')
{ {
dolibarr_del_const($db, "MAIN_SUBMODULE_LIVRAISON",$conf->entity); dolibarr_del_const($db, "MAIN_SUBMODULE_LIVRAISON",$conf->entity);
Header("Location: confexped.php"); Header("Location: confexped.php");
@ -119,11 +120,11 @@ print '<td align="center" width="100">';
if($conf->global->MAIN_SUBMODULE_EXPEDITION == 0) if($conf->global->MAIN_SUBMODULE_EXPEDITION == 0)
{ {
print '<a href="confexped.php?action=activate_sending">'.img_picto($langs->trans("Disabled"),'off').'</a>'; print '<a href="confexped.php?action=activate_sending">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
} }
else if($conf->global->MAIN_SUBMODULE_EXPEDITION == 1) else if($conf->global->MAIN_SUBMODULE_EXPEDITION == 1)
{ {
print '<a href="confexped.php?action=disable_sending">'.img_picto($langs->trans("Enabled"),'on').'</a>'; print '<a href="confexped.php?action=disable_sending">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
} }
print "</td>"; print "</td>";
@ -139,11 +140,11 @@ print '<td align="center" width="100">';
if($conf->global->MAIN_SUBMODULE_LIVRAISON == 0) if($conf->global->MAIN_SUBMODULE_LIVRAISON == 0)
{ {
print '<a href="confexped.php?action=activate_delivery">'.img_picto($langs->trans("Disabled"),'off').'</a>'; print '<a href="confexped.php?action=activate_delivery">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
} }
else if($conf->global->MAIN_SUBMODULE_LIVRAISON == 1) else if($conf->global->MAIN_SUBMODULE_LIVRAISON == 1)
{ {
print '<a href="confexped.php?action=disable_delivery">'.img_picto($langs->trans("Enabled"),'on').'</a>'; print '<a href="confexped.php?action=disable_delivery">'.img_picto($langs->trans("Enabled"),'switch_on').'</a>';
} }
print "</td>"; print "</td>";

View File

@ -32,13 +32,14 @@ require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'); require_once(DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php');
$langs->load("admin"); $langs->load("admin");
$langs->load("bills");
$langs->load("other");
$langs->load("sendings"); $langs->load("sendings");
$langs->load("deliveries"); $langs->load("deliveries");
if (!$user->admin) accessforbidden(); if (!$user->admin) accessforbidden();
$action=GETPOST("action");
$value=GETPOST("value");
if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) if (empty($conf->global->EXPEDITION_ADDON_NUMBER))
{ {
$conf->global->EXPEDITION_ADDON_NUMBER='mod_expedition_safor'; $conf->global->EXPEDITION_ADDON_NUMBER='mod_expedition_safor';
@ -48,9 +49,9 @@ if (empty($conf->global->EXPEDITION_ADDON_NUMBER))
/* /*
* Actions * Actions
*/ */
if ($_GET["action"] == 'specimen') if ($action == 'specimen')
{ {
$modele=$_GET["module"]; $modele=GETPOST("module");
$exp = new Expedition($db); $exp = new Expedition($db);
$exp->initAsSpecimen(); $exp->initAsSpecimen();
@ -73,25 +74,28 @@ if ($_GET["action"] == 'specimen')
} }
else else
{ {
$mesg='<div class="error">'.$obj->error.'</div>'; $mesg='<font class="error">'.$obj->error.'</font>';
dol_syslog($obj->error, LOG_ERR); dol_syslog($obj->error, LOG_ERR);
} }
} }
else else
{ {
$mesg='<div class="error">'.$langs->trans("ErrorModuleNotFound").'</div>'; $mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} }
// Activate a model // Activate a model
if ($_GET["action"] == 'set') if ($action == 'set')
{ {
$label = GETPOST("label");
$scandir = GETPOST("scandir");
$type='shipping'; $type='shipping';
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
$sql.= " VALUES ('".$db->escape($_GET["value"])."','".$type."',".$conf->entity.", "; $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
$sql.= ($_GET["label"]?"'".$db->escape($_GET["label"])."'":'null').", "; $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
$sql.= (! empty($_GET["scandir"])?"'".$db->escape($_GET["scandir"])."'":"null"); $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
$sql.= ")"; $sql.= ")";
if ($db->query($sql)) if ($db->query($sql))
{ {
@ -99,11 +103,11 @@ if ($_GET["action"] == 'set')
} }
} }
if ($_GET["action"] == 'del') if ($action == 'del')
{ {
$type='shipping'; $type='shipping';
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE nom = '".$_GET["value"]."'"; $sql.= " WHERE nom = '".$value."'";
$sql.= " AND type = '".$type."'"; $sql.= " AND type = '".$type."'";
$sql.= " AND entity = ".$conf->entity; $sql.= " AND entity = ".$conf->entity;
@ -114,27 +118,30 @@ if ($_GET["action"] == 'del')
} }
// Set default model // Set default model
if ($_GET["action"] == 'setdoc') if ($action == 'setdoc')
{ {
$label = GETPOST("label");
$scandir = GETPOST("scandir");
$db->begin(); $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 // On active le modele
$type='shipping'; $type='shipping';
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; $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 type = '".$type."'";
$sql_del.= " AND entity = ".$conf->entity; $sql_del.= " AND entity = ".$conf->entity;
$result1=$db->query($sql_del); $result1=$db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
$sql.= " VALUES ('".$db->escape($_GET["value"])."', '".$type."', ".$conf->entity.", "; $sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", ";
$sql.= ($_GET["label"]?"'".$db->escape($_GET["label"])."'":'null').", "; $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
$sql.= (! empty($_GET["scandir"])?"'".$db->escape($_GET["scandir"])."'":"null"); $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
$sql.= ")"; $sql.= ")";
$result2=$db->query($sql); $result2=$db->query($sql);
if ($result1 && $result2) if ($result1 && $result2)
@ -148,11 +155,11 @@ if ($_GET["action"] == 'setdoc')
} }
// TODO A quoi servent les methode d'expedition ? // TODO A quoi servent les methode d'expedition ?
if ($_GET["action"] == 'setmethod' || $_GET["action"] == 'setmod') if ($action == 'setmethod' || $action== 'setmod')
{ {
$module=$_GET["module"]; $module=GETPOST("module");
$moduleid=$_GET["moduleid"]; $moduleid=GETPOST("moduleid");
$statut=$_GET["statut"]; $statut=GETPOST("statut");
require_once(DOL_DOCUMENT_ROOT."/includes/modules/expedition/methode_expedition_$module.modules.php"); 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; $sql.= " WHERE rowid = ".$moduleid;
$resql = $db->query($sql); $resql = $db->query($sql);
if ($resql && ($statut == 1 || $_GET["action"] == 'setmod')) if ($resql && ($statut == 1 || $action == 'setmod'))
{ {
$db->begin(); $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(); $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 // TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated // 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']; $maskconst=GETPOST("maskconstexpedition");
$maskvalue=$_POST['maskexpedition']; $maskvalue=GETPOST("maskexpedition");
if ($maskconst) dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity); if ($maskconst) $res = dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
} }
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 = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
} }
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 = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
} }
@ -263,7 +307,7 @@ print_fiche_titre($langs->trans("SendingsSetup"),$linkback,'setup');
print '<br>'; print '<br>';
if ($mesg) print $mesg.'<br>'; //if ($mesg) print $mesg.'<br>';
$h = 0; $h = 0;
@ -351,12 +395,12 @@ foreach ($conf->file->dol_document_root as $dirroot)
print '<td align="center">'; print '<td align="center">';
if ($conf->global->EXPEDITION_ADDON_NUMBER == "$file") if ($conf->global->EXPEDITION_ADDON_NUMBER == "$file")
{ {
print img_picto($langs->trans("Activated"),'on'); print img_picto($langs->trans("Activated"),'switch_on');
} }
else else
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmodel&amp;value='.$file.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmodel&amp;value='.$file.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
print img_picto($langs->trans("Disabled"),'off'); print img_picto($langs->trans("Disabled"),'switch_off');
print '</a>'; print '</a>';
} }
print '</td>'; print '</td>';
@ -475,19 +519,19 @@ foreach ($conf->file->dol_document_root as $dirroot)
if ($conf->global->EXPEDITION_ADDON_PDF != $name) if ($conf->global->EXPEDITION_ADDON_PDF != $name)
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'">';
print img_picto($langs->trans("Activated"),'on'); print img_picto($langs->trans("Activated"),'switch_on');
print '</a>'; print '</a>';
} }
else else
{ {
print img_picto($langs->trans("Activated"),'on'); print img_picto($langs->trans("Activated"),'switch_on');
} }
print "</td>"; print "</td>";
} }
else else
{ {
print "<td align=\"center\">\n"; print "<td align=\"center\">\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
print "</td>"; print "</td>";
} }
@ -495,11 +539,11 @@ foreach ($conf->file->dol_document_root as $dirroot)
print "<td align=\"center\">"; print "<td align=\"center\">";
if ($conf->global->EXPEDITION_ADDON_PDF == $name) if ($conf->global->EXPEDITION_ADDON_PDF == $name)
{ {
print img_picto($langs->trans("Default"),'on'); print img_picto($langs->trans("Default"),'switch_on');
} }
else else
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
} }
print '</td>'; print '</td>';
@ -568,6 +612,8 @@ print '</form>';
print '</table>'; print '</table>';
dol_htmloutput_mesg($mesg);
$db->close(); $db->close();
llxFooter(); llxFooter();

View File

@ -5,6 +5,7 @@
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr> * Copyright (C) 2008 Raphael Bertrand (Resultic) <raphael.bertrand@resultic.fr>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * 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'); require_once(DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php');
$langs->load("admin"); $langs->load("admin");
$langs->load("bills"); $langs->load("errors");
$langs->load("other"); /*$langs->load("other");
$langs->load("interventions"); $langs->load("interventions");*/
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
$action = GETPOST("action");
$value = GETPOST("value");
/* /*
* Actions * Actions
*/ */
if ($_POST["action"] == 'updateMask') if ($action == 'updateMask')
{ {
$maskconst=$_POST['maskconst']; $maskconst=GETPOST("maskconst");
$maskvalue=$_POST['maskvalue']; $maskvalue=getpost("maskvalue");
if ($maskconst) dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity); if ($maskconst) $res = dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
} }
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 = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
} }
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 = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
} }
if ($_GET["action"] == 'specimen') if ($action == 'specimen')
{ {
$modele=$_GET["module"]; $modele=$_GET["module"];
@ -83,24 +122,27 @@ if ($_GET["action"] == 'specimen')
} }
else else
{ {
$mesg='<div class="error">'.$obj->error.'</div>'; $mesg='<font class="error">'.$obj->error.'</font>';
dol_syslog($obj->error, LOG_ERR); dol_syslog($obj->error, LOG_ERR);
} }
} }
else else
{ {
$mesg='<div class="error">'.$langs->trans("ErrorModuleNotFound").'</div>'; $mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} }
if ($_GET["action"] == 'set') if ($action == 'set')
{ {
$label = GETPOST("label");
$scandir = GETPOST("scandir");
$type='ficheinter'; $type='ficheinter';
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
$sql.= " VALUES ('".$db->escape($_GET["value"])."','".$type."',".$conf->entity.", "; $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
$sql.= ($_GET["label"]?"'".$db->escape($_GET["label"])."'":'null').", "; $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
$sql.= (! empty($_GET["scandir"])?"'".$db->escape($_GET["scandir"])."'":"null"); $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
$sql.= ")"; $sql.= ")";
if ($db->query($sql)) if ($db->query($sql))
{ {
@ -108,11 +150,11 @@ if ($_GET["action"] == 'set')
} }
} }
if ($_GET["action"] == 'del') if ($action == 'del')
{ {
$type='ficheinter'; $type='ficheinter';
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE nom = '".$_GET["value"]."'"; $sql.= " WHERE nom = '".$value."'";
$sql.= " AND type = '".$type."'"; $sql.= " AND type = '".$type."'";
$sql.= " AND entity = ".$conf->entity; $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(); $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 // La constante qui a ete lue en avant du nouveau set
// on passe donc par une variable pour avoir un affichage coherent // 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 // On active le modele
$type='ficheinter'; $type='ficheinter';
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; $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 type = '".$type."'";
$sql_del.= " AND entity = ".$conf->entity; $sql_del.= " AND entity = ".$conf->entity;
dol_syslog("fichinter: sql_del=".$sql_del); dol_syslog("fichinter: sql_del=".$sql_del);
$result1=$db->query($sql_del); $result1=$db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
$sql.= " VALUES ('".$db->escape($_GET["value"])."', '".$type."', ".$conf->entity.", "; $sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", ";
$sql.= ($_GET["label"]?"'".$db->escape($_GET["label"])."'":'null').", "; $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
$sql.= (! empty($_GET["scandir"])?"'".$db->escape($_GET["scandir"])."'":"null"); $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
$sql.= ")"; $sql.= ")";
dol_syslog("fichinter: sql_del=".$sql_del); dol_syslog("fichinter: sql_del=".$sql_del);
$result2=$db->query($sql); $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 // TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated // 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 // 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"] == '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"] == '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"] == '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); if ($_POST["action"] == 'setNumRestart') dolibarr_set_const($db, "FICHEINTER_NUM_RESTART_BEGIN_YEAR",$_POST["numrestart"],'chaine',0,'',$conf->entity);
*/
/* /*
* Affichage page * Affichage page
@ -244,11 +290,11 @@ foreach ($conf->file->dol_document_root as $dirroot)
print '<td align="center">'; print '<td align="center">';
if ($conf->global->FICHEINTER_ADDON == $classname) if ($conf->global->FICHEINTER_ADDON == $classname)
{ {
print img_picto($langs->trans("Activated"),'on'); print img_picto($langs->trans("Activated"),'switch_on');
} }
else else
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$classname.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
} }
print '</td>'; print '</td>';
@ -352,19 +398,19 @@ foreach ($conf->file->dol_document_root as $dirroot)
if ($conf->global->FICHEINTER_ADDON_PDF != "$name") if ($conf->global->FICHEINTER_ADDON_PDF != "$name")
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
print img_picto($langs->trans("Enabled"),'on'); print img_picto($langs->trans("Enabled"),'switch_on');
print '</a>'; print '</a>';
} }
else else
{ {
print img_picto($langs->trans("Enabled"),'on'); print img_picto($langs->trans("Enabled"),'switch_on');
} }
print "</td>"; print "</td>";
} }
else else
{ {
print "<td align=\"center\">\n"; print "<td align=\"center\">\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
print "</td>"; print "</td>";
} }
@ -372,11 +418,11 @@ foreach ($conf->file->dol_document_root as $dirroot)
print "<td align=\"center\">"; print "<td align=\"center\">";
if ($conf->global->FICHEINTER_ADDON_PDF == "$name") if ($conf->global->FICHEINTER_ADDON_PDF == "$name")
{ {
print img_picto($langs->trans("Default"),'on'); print img_picto($langs->trans("Default"),'switch_on');
} }
else else
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
} }
print '</td>'; print '</td>';
@ -449,6 +495,8 @@ print '</table>';
print '<br>'; print '<br>';
dol_htmloutput_mesg($mesg);
$db->close(); $db->close();
llxFooter(); llxFooter();

View File

@ -5,7 +5,8 @@
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com> * Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* * Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
*
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * 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"); require_once(DOL_DOCUMENT_ROOT."/livraison/class/livraison.class.php");
$langs->load("admin"); $langs->load("admin");
$langs->load("bills");
$langs->load("other");
$langs->load("sendings"); $langs->load("sendings");
$langs->load("deliveries"); $langs->load("deliveries");
if (!$user->admin) accessforbidden(); if (!$user->admin) accessforbidden();
$action = GETPOST("action");
$value = GETPOST("value");
/* /*
* Actions * Actions
*/ */
if ($_POST["action"] == 'updateMask') if ($action == 'updateMask')
{ {
$maskconstdelivery=$_POST['maskconstdelivery']; $maskconstdelivery=GETPOST("maskconstdelivery");
$maskdelivery=$_POST['maskdelivery']; $maskdelivery=GETPOST("maskdelivery");
if ($maskconstdelivery) dolibarr_set_const($db,$maskconstdelivery,$maskdelivery,'chaine',0,'',$conf->entity); if ($maskconstdelivery) $res = dolibarr_set_const($db,$maskconstdelivery,$maskdelivery,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
} }
if ($_GET["action"] == 'specimen') if ($action == 'specimen')
{ {
$modele=$_GET["module"]; $modele=GETPOST("module");
$sending = new Livraison($db); $sending = new Livraison($db);
$sending->initAsSpecimen(); $sending->initAsSpecimen();
//$sending->fetch_commande(); //$sending->fetch_commande();
@ -74,24 +86,27 @@ if ($_GET["action"] == 'specimen')
} }
else else
{ {
$mesg='<div class="error">'.$obj->error.'</div>'; $mesg='<font class="error">'.$obj->error.'</font>';
dol_syslog($obj->error, LOG_ERR); dol_syslog($obj->error, LOG_ERR);
} }
} }
else else
{ {
$mesg='<div class="error">'.$langs->trans("ErrorModuleNotFound").'</div>'; $mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} }
if ($_GET["action"] == 'set') if ($action == 'set')
{ {
$label = GETPOST("label");
$scandir = GETPOST("scandir");
$type='delivery'; $type='delivery';
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
$sql.= " VALUES ('".$db->escape($_GET["value"])."','".$type."',".$conf->entity.", "; $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", ";
$sql.= ($_GET["label"]?"'".$db->escape($_GET["label"])."'":'null').", "; $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
$sql.= (! empty($_GET["scandir"])?"'".$db->escape($_GET["scandir"])."'":"null"); $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
$sql.= ")"; $sql.= ")";
if ($db->query($sql)) if ($db->query($sql))
{ {
@ -99,11 +114,11 @@ if ($_GET["action"] == 'set')
} }
} }
if ($_GET["action"] == 'del') if ($action == 'del')
{ {
$type='delivery'; $type='delivery';
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
$sql.= " WHERE nom = '".$_GET["value"]."'"; $sql.= " WHERE nom = '".$value."'";
$sql.= " AND type = '".$type."'"; $sql.= " AND type = '".$type."'";
$sql.= " AND entity = ".$conf->entity; $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(); $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 // On active le modele
$type='delivery'; $type='delivery';
$sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; $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 type = '".$type."'";
$sql_del.= " AND entity = ".$conf->entity; $sql_del.= " AND entity = ".$conf->entity;
$result1=$db->query($sql_del); $result1=$db->query($sql_del);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
$sql.= " VALUES ('".$db->escape($_GET["value"])."', '".$type."', ".$conf->entity.", "; $sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", ";
$sql.= ($_GET["label"]?"'".$db->escape($_GET["label"])."'":'null').", "; $sql.= ($label?"'".$db->escape($label)."'":'null').", ";
$sql.= (! empty($_GET["scandir"])?"'".$db->escape($_GET["scandir"])."'":"null"); $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null");
$sql.= ")"; $sql.= ")";
$result2=$db->query($sql); $result2=$db->query($sql);
if ($result1 && $result2) 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 = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
} }
if ($_GET["action"] == 'setmod') if ($action == 'setmod')
{ {
// TODO Verifier si module numerotation choisi peut etre active // TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated // 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 // Show example of numbering module
print '<td nowrap="nowrap">'; print '<td nowrap="nowrap">';
$tmp=$module->getExample(); $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; else print $tmp;
print '</td>'."\n"; print '</td>'."\n";
print '<td align="center">'; print '<td align="center">';
if ($conf->global->LIVRAISON_ADDON == "$file") if ($conf->global->LIVRAISON_ADDON == "$file")
{ {
print img_picto($langs->trans("Activated"),'on'); print img_picto($langs->trans("Activated"),'switch_on');
} }
else else
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setmod&amp;value='.$file.'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
} }
print '</td>'; print '</td>';
@ -372,19 +405,19 @@ foreach ($conf->file->dol_document_root as $dirroot)
if ($conf->global->LIVRAISON_ADDON_PDF != "$name") if ($conf->global->LIVRAISON_ADDON_PDF != "$name")
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=del&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">';
print img_picto($langs->trans("Enabled"),'on'); print img_picto($langs->trans("Enabled"),'switch_on');
print '</a>'; print '</a>';
} }
else else
{ {
print img_picto($langs->trans("Enabled"),'on'); print img_picto($langs->trans("Enabled"),'switch_on');
} }
print "</td>"; print "</td>";
} }
else else
{ {
print "<td align=\"center\">\n"; print "<td align=\"center\">\n";
print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=set&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
print "</td>"; print "</td>";
} }
@ -392,11 +425,11 @@ foreach ($conf->file->dol_document_root as $dirroot)
print "<td align=\"center\">"; print "<td align=\"center\">";
if ($conf->global->LIVRAISON_ADDON_PDF == "$name") if ($conf->global->LIVRAISON_ADDON_PDF == "$name")
{ {
print img_picto($langs->trans("Default"),'on'); print img_picto($langs->trans("Default"),'switch_on');
} }
else else
{ {
print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').'</a>'; print '<a href="'.$_SERVER["PHP_SELF"].'?action=setdoc&amp;value='.$name.'&amp;scandir='.$module->scandir.'&amp;label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'switch_off').'</a>';
} }
print '</td>'; print '</td>';
@ -451,6 +484,8 @@ print '</form>';
print '</table>'; print '</table>';
dol_htmloutput_mesg($mesg);
$db->close(); $db->close();
llxFooter(); llxFooter();

View File

@ -88,13 +88,13 @@ if ($action == 'specimen')
} }
else else
{ {
$mesg='<font class=\"error\">'.$module->error.'</font>'; $mesg='<font class="error">'.$module->error.'</font>';
dol_syslog($module->error, LOG_ERR); dol_syslog($module->error, LOG_ERR);
} }
} }
else else
{ {
$mesg='<font class=\"error\">'.$langs->trans("ErrorModuleNotFound").'</font>'; $mesg='<font class="error">'.$langs->trans("ErrorModuleNotFound").'</font>';
dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
} }
} }