diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php
index a8b0325dc5d..2a6d12bbec0 100644
--- a/htdocs/admin/expedition.php
+++ b/htdocs/admin/expedition.php
@@ -40,9 +40,6 @@ if (!$user->admin) accessforbidden();
$action=GETPOST('action','alpha');
$value=GETPOST('value','alpha');
-$label = GETPOST('label','alpha');
-$scandir = GETPOST('scandir','alpha');
-$type='shipping';
if (empty($conf->global->EXPEDITION_ADDON_NUMBER))
{
@@ -53,59 +50,6 @@ if (empty($conf->global->EXPEDITION_ADDON_NUMBER))
/*
* Actions
*/
- if ($action == 'updateMask')
-{
- $maskconst=GETPOST('maskconstexpedition','alpha');
- $maskvalue=GETPOST('maskexpedition','alpha');
- 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 ($action == 'set_SHIPPING_FREE_TEXT')
-{
- $freetext=GETPOST('SHIPPING_FREE_TEXT','alpha');
- $res = dolibarr_set_const($db, "SHIPPING_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity);
-
- if (! $res > 0) $error++;
-
- if (! $error)
- {
- $mesg = "".$langs->trans("SetupSaved")."";
- }
- else
- {
- $mesg = "".$langs->trans("Error")."";
- }
-}
-
-if ($action == 'set_SHIPPING_DRAFT_WATERMARK')
-{
- $draft=GETPOST('SHIPPING_DRAFT_WATERMARK','alpha');
-
- $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 ($action == 'specimen')
{
$modele=GETPOST('module','alpha');
@@ -140,8 +84,8 @@ if ($action == 'specimen')
}
else
{
- $mesg=''.$obj->error.'';
- dol_syslog($obj->error, LOG_ERR);
+ $mesg=''.$module->error.'';
+ dol_syslog($module->error, LOG_ERR);
}
}
else
@@ -154,13 +98,30 @@ if ($action == 'specimen')
// Activate a model
if ($action == 'set')
{
- $ret = addDocumentModel($value, $type, $label, $scandir);
+ $label = GETPOST('label','alpha');
+ $scandir = GETPOST('scandir','alpha');
+
+ $type='shipping';
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)";
+ $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))
+ {
+
+ }
}
if ($action == 'del')
{
- $ret = delDocumentModel($value, $type);
- if ($ret > 0)
+ $type='shipping';
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
+ $sql.= " WHERE nom = '".$db->escape($value)."'";
+ $sql.= " AND type = '".$type."'";
+ $sql.= " AND entity = ".$conf->entity;
+
+ if ($db->query($sql))
{
if ($conf->global->EXPEDITION_ADDON_PDF == "$value") dolibarr_del_const($db, 'EXPEDITION_ADDON_PDF',$conf->entity);
}
@@ -169,18 +130,37 @@ if ($action == 'del')
// Set default model
if ($action == 'setdoc')
{
+ $label = GETPOST('label','alpha');
+ $scandir = GETPOST('scandir','alpha');
+
+ $db->begin();
+
if (dolibarr_set_const($db, "EXPEDITION_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->EXPEDITION_ADDON_PDF = $value;
}
// On active le modele
- $ret = delDocumentModel($value, $type);
- if ($ret > 0)
+ $type='shipping';
+ $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model";
+ $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($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)
{
- $ret = addDocumentModel($value, $type, $label, $scandir);
+ $db->commit();
+ }
+ else
+ {
+ $db->rollback();
}
}
@@ -260,8 +240,28 @@ if ($action == 'setmod')
// TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated
- dolibarr_set_const($db, "EXPEDITION_ADDON",$value,'chaine',0,'',$conf->entity);
+ $module=GETPOST('module','alpha');
+ dolibarr_set_const($db, "EXPEDITION_ADDON",$module,'chaine',0,'',$conf->entity);
+
+}
+
+if ($action == 'updateMask')
+{
+ $maskconst=GETPOST('maskconstexpedition','alpha');
+ $maskvalue=GETPOST('maskexpedition','alpha');
+ 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 ($action == 'setmodel')
@@ -269,6 +269,39 @@ if ($action == 'setmodel')
dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity);
}
+if ($action == 'set_SHIPPING_DRAFT_WATERMARK')
+{
+ $draft=GETPOST('SHIPPING_DRAFT_WATERMARK','alpha');
+ $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 ($action == 'set_SHIPPING_FREE_TEXT')
+{
+ $free=GETPOST('SHIPPING_FREE_TEXT','alpha');
+ $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")."";
+ }
+}
+
/*
* View