From 67c06225a5e16249e8e8d75ddba0060a24eaf52e Mon Sep 17 00:00:00 2001 From: frederic34 Date: Fri, 22 Feb 2013 14:18:51 +0100 Subject: [PATCH] WIP : Admin for carriers --- htdocs/admin/carrier.php | 22 +++-- htdocs/expedition/class/expedition.class.php | 83 ++++++++++++------- .../mysql/data/llx_c_shipment_mode.sql | 17 ++-- .../install/mysql/migration/3.3.0-3.4.0.sql | 4 + .../mysql/tables/llx_c_shipment_mode.sql | 1 + 5 files changed, 85 insertions(+), 42 deletions(-) diff --git a/htdocs/admin/carrier.php b/htdocs/admin/carrier.php index 5b8eb3724cc..53f18ae0ca1 100644 --- a/htdocs/admin/carrier.php +++ b/htdocs/admin/carrier.php @@ -105,11 +105,12 @@ print_titre($langs->trans("CarrierList")); print ''; print ''; -print ''; -print ''; +print ''; +print ''; print ''; -print ''; +print ''; print ''; +print ''; print "\n"; for ($i=0; $ilistmeths); $i++) { @@ -118,8 +119,8 @@ for ($i=0; $ilistmeths); $i++) print ''; print ''; print ''; - print ''; - print ''; + print ''; } -print ''; print "\n"; print '
'.$langs->trans("Code").''.$langs->trans("Name").''.$langs->trans("Code").''.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("TracingUrl").''.$langs->trans("TrackingUrl").''.$langs->trans("Status").''.$langs->trans("Edit").'
'.$object->listmeths[$i][code].''.$object->listmeths[$i][libelle].''.$object->listmeths[$i][description].''.$object->listmeths[$i][tracing].''; + print ''.$object->listmeths[$i][tracking].''; if($object->listmeths[$i][active] == 0) { print ''.img_picto($langs->trans("Disabled"),'switch_off').''; @@ -128,8 +129,17 @@ for ($i=0; $ilistmeths); $i++) { print ''.img_picto($langs->trans("Enabled"),'switch_on').''; } + print ''; + if($object->listmeths[$i][editable] == 1) + { + print ''.img_picto($langs->trans("Edit"),'edit').''; + } + else + { + print ' '; + } + print '

'; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index ca8c5ea2dfe..22c0593a632 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1176,12 +1176,11 @@ class Expedition extends CommonObject function all_delivery_methods() { global $langs; - $meths = array(); + $listmeths = array(); $i=0; - $sql = "SELECT em.rowid, em.code, em.libelle, em.description, em.active"; + $sql = "SELECT em.rowid, em.code, em.libelle, em.description, em.tracking, em.active"; $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; - //$sql.= " ORDER BY em.libelle ASC"; $resql = $this->db->query($sql); if ($resql) @@ -1193,6 +1192,25 @@ class Expedition extends CommonObject $label=$langs->trans('SendingMethod'.$obj->code); $this->listmeths[$i][libelle] = ($label != 'SendingMethod'.$obj->code?$label:$obj->libelle); $this->listmeths[$i][description] = $obj->description; + if ($obj->tracking) + { + $this->listmeths[$i][tracking] = $obj->tracking; + $this->listmeths[$i][editable] = 1; + } + else + { + if ($obj->code) + { + $classname = "methode_expedition_".strtolower($obj->code); + + if (file_exists(DOL_DOCUMENT_ROOT."/core/modules/expedition/methode_expedition_".strtolower($obj->code).".modules.php") ) + { + require_once DOL_DOCUMENT_ROOT."/core/modules/expedition/methode_expedition_".strtolower($obj->code).'.modules.php'; + $shipmethod = new $classname(); + $this->listmeths[$i][tracking] = $shipmethod->provider_url_status('{TRACKID}'); + } + } + } $this->listmeths[$i][active] = $obj->active; $i++; } @@ -1239,7 +1257,7 @@ class Expedition extends CommonObject if (! empty($this->expedition_method_id)) { - $sql = "SELECT em.code"; + $sql = "SELECT em.code, em.tracking"; $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; $sql.= " WHERE em.rowid = ".$this->expedition_method_id; @@ -1249,36 +1267,45 @@ class Expedition extends CommonObject if ($obj = $this->db->fetch_object($resql)) { $code = $obj->code; + $tracking = $obj->tracking; } } } - if ($code) - { - $classname = "methode_expedition_".strtolower($code); + 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); - } + $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 ($url) + { + $this->tracking_url = sprintf(''.($value?$value:'url').'',$url,$url); + } + else + { + $this->tracking_url = $value; + } + } + else + { + $this->tracking_url = $value; + } + } + } /** * Classify the shipping as invoiced diff --git a/htdocs/install/mysql/data/llx_c_shipment_mode.sql b/htdocs/install/mysql/data/llx_c_shipment_mode.sql index 3bb5a056ed2..74b8eaea6ce 100644 --- a/htdocs/install/mysql/data/llx_c_shipment_mode.sql +++ b/htdocs/install/mysql/data/llx_c_shipment_mode.sql @@ -29,11 +29,12 @@ -- -- Sending method -- -INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,active) VALUES (1,'CATCH','Catch','Catch by client',1); -INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,active) VALUES (2,'TRANS','Transporter','Generic transporter',1); -INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,active) VALUES (3,'COLSUI','Colissimo Suivi','Colissimo Suivi',0); -INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,active) VALUES (4,'LETTREMAX','Lettre Max','Courrier Suivi et Lettre Max',0); -INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,active) VALUES (5,'UPS','UPS','United Parcel Service',0); -INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,active) VALUES (6,'KIALA','KIALA','Relais Kiala',0); -INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,active) VALUES (7,'GLS','GLS','General Logistics Systems',0); -INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,active) VALUES (8,'CHRONO','Chronopost','Chronopost',0); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (1,'CATCH','Catch','Catch by client','',1); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (2,'TRANS','Transporter','Generic transporter','',1); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (3,'COLSUI','Colissimo Suivi','Colissimo Suivi','',0); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (4,'LETTREMAX','Lettre Max','Courrier Suivi et Lettre Max','',0); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (5,'UPS','UPS','United Parcel Service','',0); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (6,'KIALA','KIALA','Relais Kiala','',0); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (7,'GLS','GLS','General Logistics Systems','',0); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (8,'CHRONO','Chronopost','Chronopost','',0); +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (9,'EDIT','EDITABLE','Transporteur Modifiable','http://www.website.com/dir/{TRACKID}',0); diff --git a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql index 97f8bc60bac..cf31f6eb9bb 100755 --- a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql +++ b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql @@ -1,3 +1,4 @@ +alter table llx_contratdet add column fk_product_fournisseur_price integer after info_bits; -- -- Be carefull to requests order. -- This file must be loaded by calling /install/index.php page @@ -50,3 +51,6 @@ INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,active) VALUES ( INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,active) VALUES (6,'KIALA','KIALA','Relais Kiala',0); INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,active) VALUES (7,'GLS','GLS','General Logistics Systems',0); INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,active) VALUES (8,'CHRONO','Chronopost','Chronopost',0); + +ALTER TABLE llx_c_shipment_mode ADD COLUMN tracking VARCHAR(256) NOT NULL AFTER description; +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,tracking,active) VALUES (9,'EDIT','EDITABLE','Transporteur Modifiable','http://www.website.com/dir/{TRACKID}',0); diff --git a/htdocs/install/mysql/tables/llx_c_shipment_mode.sql b/htdocs/install/mysql/tables/llx_c_shipment_mode.sql index 7733c980ab4..591e3ff9b93 100644 --- a/htdocs/install/mysql/tables/llx_c_shipment_mode.sql +++ b/htdocs/install/mysql/tables/llx_c_shipment_mode.sql @@ -23,6 +23,7 @@ create table llx_c_shipment_mode code varchar(30) NOT NULL, libelle varchar(50) NOT NULL, description text, + tracking varchar(256) NOT NULL, active tinyint DEFAULT 0, module varchar(32) NULL )ENGINE=innodb;