Fix: remove obsolete code

Conflicts:
	htdocs/admin/expedition.php
This commit is contained in:
Regis Houssin 2012-08-25 10:59:41 +02:00
parent e260997e0b
commit c5728843a5
2 changed files with 87 additions and 232 deletions

View File

@ -4,7 +4,7 @@
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* 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-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011-2012 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com> * Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com>
* *
@ -28,18 +28,23 @@
* \brief Page d'administration/configuration du module Expedition * \brief Page d'administration/configuration du module Expedition
*/ */
require("../main.inc.php"); require '../main.inc.php';
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); require_once DOL_DOCUMENT_ROOT.'/core/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("sendings"); $langs->load("sendings");
$langs->load("deliveries"); $langs->load("deliveries");
$langs->load('other');
if (!$user->admin) accessforbidden(); if (! $user->admin)
accessforbidden();
$action=GETPOST('action','alpha'); $action=GETPOST('action','alpha');
$value=GETPOST('value','alpha'); $value=GETPOST('value','alpha');
$label = GETPOST('label','alpha');
$scandir = GETPOST('scandir','alpha');
$type='shipping';
if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) if (empty($conf->global->EXPEDITION_ADDON_NUMBER))
{ {
@ -50,6 +55,59 @@ if (empty($conf->global->EXPEDITION_ADDON_NUMBER))
/* /*
* Actions * 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 = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
}
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 = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
}
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 = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
}
if ($action == 'specimen') if ($action == 'specimen')
{ {
$modele=GETPOST('module','alpha'); $modele=GETPOST('module','alpha');
@ -73,7 +131,7 @@ if ($action == 'specimen')
if ($filefound) if ($filefound)
{ {
require_once($file); require_once $file;
$module = new $classname($db); $module = new $classname($db);
@ -98,210 +156,23 @@ if ($action == 'specimen')
// Activate a model // Activate a model
if ($action == 'set') if ($action == 'set')
{ {
$label = GETPOST('label','alpha'); $ret = addDocumentModel($value, $type, $label, $scandir);
$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') if ($action == 'del')
{ {
$type='shipping'; $ret = delDocumentModel($value, $type);
$sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; if ($ret > 0)
$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); if ($conf->global->EXPEDITION_ADDON_PDF == "$value") dolibarr_del_const($db, 'EXPEDITION_ADDON_PDF',$conf->entity);
} }
} }
// 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))
{
$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($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)
{
$db->commit();
}
else
{
$db->rollback();
}
}
// TODO A quoi servent les methode d'expedition ?
if ($action == 'setmethod' || $action== 'setmod')
{
$module=GETPOST('module','alpha');
$moduleid=GETPOST('moduleid','alpha');
$statut=GETPOST('statut','alpha');
require_once(DOL_DOCUMENT_ROOT."/core/modules/expedition/methode_expedition_$module.modules.php");
$classname = "methode_expedition_$module";
$expem = new $classname($db);
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."c_shipment_mode";
$sql.= " WHERE rowid = ".$moduleid;
$resql = $db->query($sql);
if ($resql && ($statut == 1 || $action == 'setmod'))
{
$db->begin();
$sqlu = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode";
$sqlu.= " SET statut=1";
$sqlu.= " WHERE rowid=".$moduleid;
$result=$db->query($sqlu);
if ($result)
{
$db->commit();
}
else
{
$db->rollback();
}
}
if ($statut == 1 || $action == 'setmod')
{
$db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_shipment_mode (rowid,code,libelle,description,statut)";
$sql.= " VALUES (".$moduleid.",'".$expem->code."','".$expem->name."','".$expem->description."',1)";
$result=$db->query($sql);
if ($result)
{
$db->commit();
}
else
{
//dol_print_error($db);
$db->rollback();
}
}
else if ($statut == 0)
{
$db->begin();
$sql = "UPDATE ".MAIN_DB_PREFIX."c_shipment_mode";
$sql.= " SET statut=0";
$sql.= " WHERE rowid=".$moduleid;
$result=$db->query($sql);
if ($result)
{
$db->commit();
}
else
{
$db->rollback();
}
}
}
if ($action == 'setmod')
{
// TODO Verifier si module numerotation choisi peut etre active
// par appel methode canBeActivated
$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 = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
}
if ($action == 'setmodel') if ($action == 'setmodel')
{ {
dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity); 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 = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
}
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 = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
}
/* /*
* View * View
@ -372,12 +243,11 @@ foreach ($dirmodels as $reldir)
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
if (preg_match('/^(mod_.*)\.php$/i',$file,$reg)) if (substr($file, 0, 15) == 'mod_expedition_' && substr($file, dol_strlen($file)-3, 3) == 'php')
{ {
$file = $reg[1]; $file = substr($file, 0, dol_strlen($file)-4);
$classname = substr($file,4);
require_once(DOL_DOCUMENT_ROOT ."/core/modules/expedition/".$file.".php"); require_once DOL_DOCUMENT_ROOT ."/core/modules/expedition/".$file.'.php';
$module = new $file; $module = new $file;
@ -420,7 +290,6 @@ foreach ($dirmodels as $reldir)
// Info // Info
$htmltooltip=''; $htmltooltip='';
$htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>'; $htmltooltip.=''.$langs->trans("Version").': <b>'.$module->getVersion().'</b><br>';
$facture->type=0;
$nextval=$module->getNextValue($mysoc,$expedition); $nextval=$module->getNextValue($mysoc,$expedition);
if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval if ("$nextval" != $langs->trans("NotAvailable")) // Keep " on nextval
{ {
@ -511,10 +380,10 @@ foreach ($dirmodels as $reldir)
$classname = substr($file, 0, dol_strlen($file) - 12); $classname = substr($file, 0, dol_strlen($file) - 12);
$var=!$var; $var=!$var;
print "<tr $bc[$var]><td>"; print '<tr '.$bc[$var].'><td>';
print $name; print $name;
print "</td><td>\n"; print "</td><td>\n";
require_once($dir.$file); require_once $dir.$file;
$module = new $classname(); $module = new $classname();
print $module->description; print $module->description;
@ -524,16 +393,9 @@ foreach ($dirmodels as $reldir)
if (in_array($name, $def)) if (in_array($name, $def))
{ {
print "<td align=\"center\">\n"; print "<td align=\"center\">\n";
//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"),'switch_on'); print img_picto($langs->trans("Activated"),'switch_on');
print '</a>'; print '</a>';
//}
//else
//{
// print img_picto($langs->trans("Activated"),'switch_on');
//}
print "</td>"; print "</td>";
} }
else else

View File

@ -84,10 +84,10 @@ class modExpedition extends DolibarrModules
$this->const[$r][4] = 0; $this->const[$r][4] = 0;
$r++; $r++;
$this->const[$r][0] = "EXPEDITION_ADDON"; $this->const[$r][0] = "EXPEDITION_ADDON_NUMBER";
$this->const[$r][1] = "chaine"; $this->const[$r][1] = "chaine";
$this->const[$r][2] = "elevement"; $this->const[$r][2] = "mod_expedition_safor";
$this->const[$r][3] = 'Nom du gestionnaire du type d\'expedition'; $this->const[$r][3] = 'Nom du gestionnaire de numerotation des expeditions';
$this->const[$r][4] = 0; $this->const[$r][4] = 0;
$r++; $r++;
@ -105,13 +105,6 @@ class modExpedition extends DolibarrModules
$this->const[$r][4] = 0; $this->const[$r][4] = 0;
$r++; $r++;
$this->const[$r][0] = "EXPEDITION_ADDON_NUMBER";
$this->const[$r][1] = "chaine";
$this->const[$r][2] = "mod_expedition_safor";
$this->const[$r][3] = 'Nom du gestionnaire de numerotation des expeditions';
$this->const[$r][4] = 0;
$r++;
// Boxes // Boxes
$this->boxes = array(); $this->boxes = array();