From 954f2afbc584ed3c3c80bd12f66d66752892cdc1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 25 Aug 2012 10:49:59 +0200 Subject: [PATCH] Fix: remove obsolete code --- htdocs/admin/expedition.php | 180 ++++---------------- htdocs/core/modules/modExpedition.class.php | 21 +-- 2 files changed, 40 insertions(+), 161 deletions(-) diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index d13378000c3..1ed96bd2e8c 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -1,12 +1,12 @@ - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2004 Sebastien Di Cintio - * Copyright (C) 2004 Benoit Mortier - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2011 Regis Houssin - * Copyright (C) 2011-2012 Juanjo Menent - * Copyright (C) 2011-2012 Philippe Grand +/* Copyright (C) 2003-2008 Rodolphe Quiedeville + * Copyright (C) 2004-2011 Laurent Destailleur + * Copyright (C) 2004 Sebastien Di Cintio + * Copyright (C) 2004 Benoit Mortier + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2011-2012 Juanjo Menent + * Copyright (C) 2011-2012 Philippe Grand * * 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 @@ -37,7 +37,8 @@ $langs->load("sendings"); $langs->load("deliveries"); $langs->load('other'); -if (!$user->admin) accessforbidden(); +if (! $user->admin) + accessforbidden(); $action=GETPOST('action','alpha'); $value=GETPOST('value','alpha'); @@ -54,22 +55,20 @@ if (empty($conf->global->EXPEDITION_ADDON_NUMBER)) /* * Actions */ - if ($action == 'updateMask') +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 (! empty($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 (isset($res)) + { + if ($res < 0) + setEventMessage($langs->trans("SetupSaved")); + else + setEventMessage($langs->trans("Error"), 'errors'); + } } if ($action == 'set_SHIPPING_FREE_TEXT') @@ -77,34 +76,21 @@ 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 ($res < 0) + setEventMessage($langs->trans("SetupSaved")); + else + setEventMessage($langs->trans("Error"), 'errors'); } 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 ($res < 0) + setEventMessage($langs->trans("SetupSaved")); + else + setEventMessage($langs->trans("Error"), 'errors'); } if ($action == 'specimen') @@ -141,13 +127,13 @@ if ($action == 'specimen') } else { - $mesg=''.$module->error.''; + setEventMessage($module->error, 'errors'); dol_syslog($module->error, LOG_ERR); } } else { - $mesg=''.$langs->trans("ErrorModuleNotFound").''; + setEventMessage($langs->trans("ErrorModuleNotFound"), 'errors'); dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); } } @@ -167,104 +153,6 @@ if ($action == 'del') } } -// Set default model -if ($action == 'setdoc') -{ - 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) - { - $ret = addDocumentModel($value, $type, $label, $scandir); - } -} - -// 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 - - dolibarr_set_const($db, "EXPEDITION_ADDON",$value,'chaine',0,'',$conf->entity); - -} - if ($action == 'setmodel') { dolibarr_set_const($db, "EXPEDITION_ADDON_NUMBER",$value,'chaine',0,'',$conf->entity); @@ -489,10 +377,10 @@ foreach ($dirmodels as $reldir) // Active if (in_array($name, $def)) { - print "\n"; + print "\n"; print ''; print img_picto($langs->trans("Activated"),'switch_on'); - print ''; + print ''; print ""; } else @@ -577,9 +465,7 @@ print ''; print ''; -dol_htmloutput_mesg($mesg); - -$db->close(); llxFooter(); +$db->close(); ?> \ No newline at end of file diff --git a/htdocs/core/modules/modExpedition.class.php b/htdocs/core/modules/modExpedition.class.php index c47c9710d27..487f39e51ea 100644 --- a/htdocs/core/modules/modExpedition.class.php +++ b/htdocs/core/modules/modExpedition.class.php @@ -84,11 +84,11 @@ class modExpedition extends DolibarrModules $this->const[$r][4] = 0; $r++; - $this->const[$r][0] = "EXPEDITION_ADDON"; - $this->const[$r][1] = "chaine"; - $this->const[$r][2] = "elevement"; - $this->const[$r][3] = 'Nom du gestionnaire du type d\'expedition'; - $this->const[$r][4] = 0; + $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++; $this->const[$r][0] = "LIVRAISON_ADDON_PDF"; @@ -105,13 +105,6 @@ class modExpedition extends DolibarrModules $this->const[$r][4] = 0; $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 $this->boxes = array(); @@ -211,8 +204,8 @@ class modExpedition extends DolibarrModules $sql = array( "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[0][2]."' AND entity = ".$conf->entity, "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[0][2]."','shipping',".$conf->entity.")", - "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[1][2]."' AND entity = ".$conf->entity, - "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[1][2]."','delivery',".$conf->entity.")", + "DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->const[2][2]."' AND entity = ".$conf->entity, + "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->const[2][2]."','delivery',".$conf->entity.")", ); return $this->_init($sql,$options);