From bfb05c78cd151d2f04d2f90f958f0ba42e8471bd Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Fri, 19 Apr 2013 20:20:10 +0200 Subject: [PATCH] Change carrier config into dict instead of dedicated conf page --- htdocs/admin/carrier.php | 222 ------------------ htdocs/admin/confexped.php | 4 - htdocs/admin/expedition.php | 4 - htdocs/admin/livraison.php | 4 - .../expedition/methode_expedition.modules.php | 68 ------ .../methode_expedition_colsui.modules.php | 56 ----- .../methode_expedition_enl.modules.php | 57 ----- .../methode_expedition_lettremax.modules.php | 57 ----- .../methode_expedition_trans.modules.php | 59 ----- htdocs/expedition/class/expedition.class.php | 49 +--- 10 files changed, 11 insertions(+), 569 deletions(-) delete mode 100644 htdocs/admin/carrier.php delete mode 100644 htdocs/core/modules/expedition/methode_expedition.modules.php delete mode 100644 htdocs/core/modules/expedition/methode_expedition_colsui.modules.php delete mode 100644 htdocs/core/modules/expedition/methode_expedition_enl.modules.php delete mode 100644 htdocs/core/modules/expedition/methode_expedition_lettremax.modules.php delete mode 100644 htdocs/core/modules/expedition/methode_expedition_trans.modules.php diff --git a/htdocs/admin/carrier.php b/htdocs/admin/carrier.php deleted file mode 100644 index edb995d3fe7..00000000000 --- a/htdocs/admin/carrier.php +++ /dev/null @@ -1,222 +0,0 @@ - - * - * 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 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/admin/carrier.php - * \ingroup expedition - * \brief Page to setup carriers. TODO Delete this page. We mut use dictionnary instead. - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/expedition/class/expedition.class.php'; - -$langs->load("admin"); -$langs->load("sendings"); -$langs->load("deliveries"); -$langs->load('other'); - -if (! $user->admin) - accessforbidden(); - -$action=GETPOST('action','alpha'); -$carrier=GETPOST('carrier','int'); - -$object = new Expedition($db); - - -/* - * Actions - */ -//if ($action==setvalue AND $carrier) -if ($action=='setvalue') -{ - // need to add check on values - $object->update['code']=GETPOST('code','alpha'); - $object->update['libelle']=GETPOST('libelle','alpha'); - $object->update['description']=GETPOST('description','alpha'); - $object->update['tracking']=GETPOST('tracking','alpha'); - $object->update_delivery_method($carrier); - header("Location: carrier.php"); - exit; -} - -if ($action=='activate_carrier' && $carrier!='') -{ - $object->activ_delivery_method($carrier); -} - -if ($action=='disable_carrier' && $carrier!='') -{ - $object->disable_delivery_method($carrier); -} - -/* - * View - */ - -$form=new Form($db); - -llxHeader("",""); - -$linkback=''.$langs->trans("BackToModuleList").''; -print_fiche_titre($langs->trans("SendingsSetup"),$linkback,'setup'); -print '
'; - - -//if ($mesg) print $mesg.'
'; - - -$h = 0; - -$head[$h][0] = DOL_URL_ROOT."/admin/confexped.php"; -$head[$h][1] = $langs->trans("Setup"); -$h++; - -$head[$h][0] = DOL_URL_ROOT."/admin/carrier.php"; -$head[$h][1] = $langs->trans("Carriers"); -$hselected=$h; -$h++; - -if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) -{ - $head[$h][0] = DOL_URL_ROOT."/admin/expedition.php"; - $head[$h][1] = $langs->trans("Sending"); - $h++; -} - -if (! empty($conf->global->MAIN_SUBMODULE_LIVRAISON)) -{ - $head[$h][0] = DOL_URL_ROOT."/admin/livraison.php"; - $head[$h][1] = $langs->trans("Receivings"); - $h++; -} - -dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); - -/* - * Carrier List - */ -if ($action=='edit_carrier' || $action=='setvalue') -{ - // Carrier Edit - if ($carrier!='') $object->list_delivery_methods($carrier); - print_titre($langs->trans("CarrierEdit")); - - print '
'; - print ''; - print ''; - - - print ''; - - $var=true; - print ''; - print ''; - print ''; - print "\n"; - - $var=!$var; - print ''; - - $var=!$var; - print ''; - - $var=!$var; - print ''; - - $var=!$var; - print ''; - - if ($carrier) - { - print ''; - } - else - { - print ''; - } - - print '
'.$langs->trans("CarrierParameter").''.$langs->trans("Value").'
'; - print $langs->trans("Code").''; - print ''; - print '   '.$langs->trans("Example").': CODE'; - print '
'; - print $langs->trans("Name").''; - print ''; - print '
'; - print $langs->trans("Description").''; - print ''; - print '
'; - print $langs->trans("Tracking").''; - print ''; - print '   '.$langs->trans("Example").': http://www.website.com/dir/{TRACKID}'; - print '


'; - print '
'; - -} -else -{ - // Display List - $object->list_delivery_methods(); - $var=true; - print_titre($langs->trans("CarrierList")); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - $numlistmeths=count($object->listmeths); - for ($i=0; $i<$numlistmeths; $i++) - { - $var=!$var; - print ""; - print ''; - print ''; - print ''; - print ''; - print ''; - print "\n"; - } - print ''; - - print '
'.$langs->trans("Code").''.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("TrackingUrl").''.$langs->trans("Status").''.$langs->trans("Edit").'
'.$object->listmeths[$i]['code'].''.$object->listmeths[$i]['libelle'].''.$object->listmeths[$i]['description'].''.dol_trunc($object->listmeths[$i]['tracking'],92,'middle').''; - if($object->listmeths[$i]['active'] == 0) - { - print ''.img_picto($langs->trans("Disabled"),'switch_off').''; - } - else - { - print ''.img_picto($langs->trans("Enabled"),'switch_on').''; - } - print ''; - print ''.img_picto($langs->trans("Edit"),'edit').''; - print '

'.$langs->trans("Add").'

'; - - print ''; -} - -llxFooter(); - -$db->close(); -?> diff --git a/htdocs/admin/confexped.php b/htdocs/admin/confexped.php index 6653badfb36..d9be768461f 100644 --- a/htdocs/admin/confexped.php +++ b/htdocs/admin/confexped.php @@ -84,10 +84,6 @@ $head[$h][1] = $langs->trans("Setup"); $hselected=$h; $h++; -$head[$h][0] = DOL_URL_ROOT."/admin/carrier.php"; -$head[$h][1] = $langs->trans("Carriers"); -$h++; - if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) { $head[$h][0] = DOL_URL_ROOT."/admin/expedition.php"; diff --git a/htdocs/admin/expedition.php b/htdocs/admin/expedition.php index 34535b1d321..28e5b912de2 100644 --- a/htdocs/admin/expedition.php +++ b/htdocs/admin/expedition.php @@ -201,10 +201,6 @@ $head[$h][0] = DOL_URL_ROOT."/admin/confexped.php"; $head[$h][1] = $langs->trans("Setup"); $h++; -$head[$h][0] = DOL_URL_ROOT."/admin/carrier.php"; -$head[$h][1] = $langs->trans("Carriers"); -$h++; - $head[$h][0] = DOL_URL_ROOT."/admin/expedition.php"; $head[$h][1] = $langs->trans("Sending"); $hselected=$h; diff --git a/htdocs/admin/livraison.php b/htdocs/admin/livraison.php index 49cbeee9026..677e2b3773b 100644 --- a/htdocs/admin/livraison.php +++ b/htdocs/admin/livraison.php @@ -189,10 +189,6 @@ $head[$h][0] = DOL_URL_ROOT."/admin/confexped.php"; $head[$h][1] = $langs->trans("Setup"); $h++; -$head[$h][0] = DOL_URL_ROOT."/admin/carrier.php"; -$head[$h][1] = $langs->trans("Carriers"); -$h++; - if (! empty($conf->global->MAIN_SUBMODULE_EXPEDITION)) { $head[$h][0] = DOL_URL_ROOT."/admin/expedition.php"; diff --git a/htdocs/core/modules/expedition/methode_expedition.modules.php b/htdocs/core/modules/expedition/methode_expedition.modules.php deleted file mode 100644 index 3ea7ba97ce9..00000000000 --- a/htdocs/core/modules/expedition/methode_expedition.modules.php +++ /dev/null @@ -1,68 +0,0 @@ - - * Copyright (C) 2007 Laurent Destailleur - * - * 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 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * or see http://www.gnu.org/ - */ - -/** - * \file htdocs/core/modules/expedition/methode_expedition.modules.php - * \ingroup expedition - * \brief Fichier contenant la classe mere de generation de bon de livraison en PDF - * et la classe mere de numerotation des bons de livraisons - */ -require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; - - -/** - * Parent class for shipping method classes - */ -class ModeleShippingMethod -{ - /** - * Constructo - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - $this->name = "NOT DEFINED"; - $this->description = "ERROR IN MODULE DESCRIPTION"; - } - - - /** - * Return list of active generation modules - * - * @param DoliDB $db Database handler - * @param string $maxfilenamelength Max length of value to show - * @return array List of templates - */ - static function liste_modeles($db,$maxfilenamelength=0) - { - global $conf; - - $type='???'; - $liste=array(); - - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $liste=getListOfModels($db,$type,$maxfilenamelength); - - return $liste; - } -} - -?> diff --git a/htdocs/core/modules/expedition/methode_expedition_colsui.modules.php b/htdocs/core/modules/expedition/methode_expedition_colsui.modules.php deleted file mode 100644 index fca7ffc38ff..00000000000 --- a/htdocs/core/modules/expedition/methode_expedition_colsui.modules.php +++ /dev/null @@ -1,56 +0,0 @@ - - * Copyright (C) 2008 Bearstech - http://bearstech.com/ - * - * 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 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/core/modules/expedition/methode_expedition_colsui.modules.php - * \ingroup expedition - */ -include_once 'methode_expedition.modules.php'; - -/** - * Class to manage shipment Colsui - */ -class methode_expedition_colsui extends ModeleShippingMethod -{ - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db=0) - { - $this->db = $db; - $this->id = 3; // Do not change this value - $this->code = "COLSUI"; // Do not change this value - $this->name = "Colissimo Suivi"; - $this->description = "Colissimo Suivi"; - } - - /** - * Return URL of provider - * - * @param string $tracking_number Tracking number - * @return string URL for tracking - */ - function provider_url_status($tracking_number) - { - return sprintf("http://www.coliposte.net/particulier/suivi_particulier.jsp?colispart=%s",$tracking_number); - } -} - -?> diff --git a/htdocs/core/modules/expedition/methode_expedition_enl.modules.php b/htdocs/core/modules/expedition/methode_expedition_enl.modules.php deleted file mode 100644 index 17e5cf35be9..00000000000 --- a/htdocs/core/modules/expedition/methode_expedition_enl.modules.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * 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 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/core/modules/expedition/methode_expedition_enl.modules.php - * \ingroup expedition - */ -include_once 'methode_expedition.modules.php'; - - -/** - * Class to manage shipment Enl - */ -class methode_expedition_enl extends ModeleShippingMethod -{ - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db=0) - { - global $langs; - $this->db = $db; - $this->id = 1; // Do not change this value - $this->name = "Enlevement"; - $this->code = "ENL"; - $this->description = $langs->trans("Enlevement"); - } - - /** - * Return URL of provider - * - * @param string $tracking_number Tracking number - * @return string URL for tracking - */ - function provider_url_status($tracking_number) - { - return ''; - } -} - -?> diff --git a/htdocs/core/modules/expedition/methode_expedition_lettremax.modules.php b/htdocs/core/modules/expedition/methode_expedition_lettremax.modules.php deleted file mode 100644 index c8150af9497..00000000000 --- a/htdocs/core/modules/expedition/methode_expedition_lettremax.modules.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * 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 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/core/modules/expedition/methode_expedition_lettremax.modules.php - * \ingroup expedition - */ - -include_once 'methode_expedition.modules.php'; - - -/** - * Class to manage shipment lettremax - */ -class methode_expedition_lettremax extends ModeleShippingMethod -{ - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db=0) - { - $this->db = $db; - $this->id = 4; // Do not change this value - $this->code = "LETTREMAX"; // Do not change this value - $this->name = "Lettre max"; - $this->description = "Courrier suivi et lettre max"; - } - - /** - * Return URL of provider - * - * @param string $tracking_number Tracking number - * @return string URL for tracking - */ - function provider_url_status($tracking_number) - { - return sprintf("http://www.csuivi.courrier.laposte.fr/default.asp?EZ_ACTION=rechercheRapide&numObjet=%s",$tracking_number); - } -} - -?> diff --git a/htdocs/core/modules/expedition/methode_expedition_trans.modules.php b/htdocs/core/modules/expedition/methode_expedition_trans.modules.php deleted file mode 100644 index d974b7c161a..00000000000 --- a/htdocs/core/modules/expedition/methode_expedition_trans.modules.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * 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 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -/** - * \file htdocs/core/modules/expedition/methode_expedition_trans.modules.php - * \ingroup expedition - */ -include_once 'methode_expedition.modules.php'; - - -/** - * Class to manage shipment Trans - */ -class methode_expedition_trans extends ModeleShippingMethod -{ - - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db=0) - { - global $langs; - - $this->db = $db; - $this->id = 2; // Ne pas changer cette valeur - $this->code = "TRANS"; - $this->name = "Transporteur"; - $this->description = $langs->trans("GenericTransport"); - } - - /** - * Return URL of provider - * - * @param string $tracking_number Tracking number - * @return string URL for tracking - */ - function provider_url_status($tracking_number) - { - return ''; - } -} - -?> diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index f3db4dafc8b..99621b2d16c 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1309,8 +1309,6 @@ class Expedition extends CommonObject */ function GetUrlTrackingStatus($value='') { - $code=''; - if (! empty($this->shipping_method_id)) { $sql = "SELECT em.code, em.tracking"; @@ -1322,46 +1320,21 @@ class Expedition extends CommonObject { if ($obj = $this->db->fetch_object($resql)) { - $code = $obj->code; - $tracking = $obj->tracking; + $tracking = $obj->tracking; } } } - if ($tracking) - { - $url = str_replace('{TRACKID}', $value, $tracking); - $this->tracking_url = sprintf(''.($value?$value:'url').'',$url,$url); - } - else - { - if ($code) - { - $classname = "methode_expedition_".strtolower($code); - - $url=''; - if (file_exists(DOL_DOCUMENT_ROOT."/core/modules/expedition/methode_expedition_".strtolower($code).".modules.php") && ! empty($this->tracking_number)) - { - require_once DOL_DOCUMENT_ROOT."/core/modules/expedition/methode_expedition_".strtolower($code).'.modules.php'; - $shipmethod = new $classname(); - $url = $shipmethod->provider_url_status($this->tracking_number); - } - - if ($url) - { - $this->tracking_url = sprintf(''.($value?$value:'url').'',$url,$url); - } - else - { - $this->tracking_url = $value; - } - } - else - { - $this->tracking_url = $value; - } - } - } + if (!empty($tracking)) + { + $url = str_replace('{TRACKID}', $value, $tracking); + $this->tracking_url = sprintf(''.($value?$value:'url').'',$url,$url); + } + else + { + $this->tracking_url = $value; + } + } /** * Classify the shipping as invoiced