diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index e019d28ba6b..31b4bc4bc29 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -96,10 +96,11 @@ class Form * @param paramkey Key of parameter (unique if there is several parameter to show) * @param perm Permission to allow button to edit parameter * @param typeofdata Type of data ('string' by default, 'email', 'text', ...) + * @param editvalue Use this value instead $preselected * @return string HTML edit field * TODO no GET or POST in class file, use a param */ - function editfieldval($text,$htmlname,$preselected,$paramkey,$paramvalue,$perm,$typeofdata='string') + function editfieldval($text,$htmlname,$preselected,$paramkey,$paramvalue,$perm,$typeofdata='string',$editvalue='') { global $langs; $ret=''; @@ -114,11 +115,11 @@ class Form $ret.=''; if (in_array($typeofdata,array('string','email'))) { - $ret.=''; + $ret.=''; } else if ($typeofdata == 'text') { - $ret.=''; + $ret.=''; } $ret.=''; $ret.=''; diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index c42e752081b..0e66300a0bf 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -1054,18 +1054,23 @@ class Expedition extends CommonObject /** * Get tracking url status */ - function GetUrlTrackingStatus() + function GetUrlTrackingStatus($value='') { - $sql = "SELECT em.code"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; - $sql.= " WHERE em.rowid = ".$this->expedition_method_id; - - $resql = $this->db->query($sql); - if ($resql) + $code=''; + + if (! empty($this->expedition_method_id)) { - if ($obj = $this->db->fetch_object($resql)) + $sql = "SELECT em.code"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; + $sql.= " WHERE em.rowid = ".$this->expedition_method_id; + + $resql = $this->db->query($sql); + if ($resql) { - $code = $obj->code; + if ($obj = $this->db->fetch_object($resql)) + { + $code = $obj->code; + } } } @@ -1083,16 +1088,16 @@ class Expedition extends CommonObject if ($url) { - $this->tracking_url = sprintf('url',$url,$url); + $this->tracking_url = sprintf(''.($value?$value:'url').'',$url,$url); } else { - $this->tracking_url = ''; + $this->tracking_url = $value; } } else { - $this->tracking_url = ''; + $this->tracking_url = $value; } } } diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index dc1f2f3928b..f76e12b85d4 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -672,11 +672,6 @@ else $expedition->fetch_origin(); } - if (dol_strlen($expedition->tracking_number)) - { - $expedition->GetUrlTrackingStatus(); - } - $soc = new Societe($db); $soc->fetch($expedition->socid); @@ -930,17 +925,11 @@ else print ''; // Tracking Number + $expedition->GetUrlTrackingStatus($expedition->tracking_number); print ''.$html->editfieldkey("TrackingNumber",'trackingnumber',$expedition->tracking_number,'id',$expedition->id,$user->rights->expedition->creer).''; - print $html->editfieldval("TrackingNumber",'trackingnumber',$expedition->tracking_number,'id',$expedition->id,$user->rights->expedition->creer); + print $html->editfieldval("TrackingNumber",'trackingnumber',$expedition->tracking_url,'id',$expedition->id,$user->rights->expedition->creer,'string',$expedition->tracking_number); print ''; - if ($expedition->tracking_url) - { - print ''.$html->editfieldkey("TrackingUrl",'trackingurl',$expedition->tracking_url,'id',$expedition->id,$user->rights->expedition->creer).''; - print $html->editfieldval("TrackingUrl",'trackingurl',$expedition->tracking_url,'id',$expedition->id,$user->rights->expedition->creer); - print ''; - } - print "\n"; /* diff --git a/htdocs/includes/modules/expedition/methode_expedition_lettremax.modules.php b/htdocs/includes/modules/expedition/methode_expedition_lettremax.modules.php new file mode 100644 index 00000000000..19e78218ea6 --- /dev/null +++ b/htdocs/includes/modules/expedition/methode_expedition_lettremax.modules.php @@ -0,0 +1,45 @@ + + * + * 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 2 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/includes/modules/expedition/methode_expedition_lettremax.modules.php + * \ingroup expedition + * \version $Id$ + */ + +include_once "methode_expedition.modules.php"; + + +class methode_expedition_lettremax extends ModeleShippingMethod +{ + + function methode_expedition_lettremax($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"; + } + + 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/install/mysql/data/llx_c_shipment_mode.sql b/htdocs/install/mysql/data/llx_c_shipment_mode.sql index 88e23b1d0a9..d9d8069a124 100644 --- a/htdocs/install/mysql/data/llx_c_shipment_mode.sql +++ b/htdocs/install/mysql/data/llx_c_shipment_mode.sql @@ -3,7 +3,7 @@ -- Copyright (C) 2004-2009 Laurent Destailleur -- Copyright (C) 2004 Benoit Mortier -- Copyright (C) 2004 Guillaume Delecourt --- Copyright (C) 2005-2009 Regis Houssin +-- Copyright (C) 2005-2011 Regis Houssin -- Copyright (C) 2007 Patrick Raguin -- -- This program is free software; you can redistribute it and/or modify @@ -34,3 +34,4 @@ 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); diff --git a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql index d3b4fde1e03..ed97836d30f 100755 --- a/htdocs/install/mysql/migration/3.0.0-3.1.0.sql +++ b/htdocs/install/mysql/migration/3.0.0-3.1.0.sql @@ -122,6 +122,8 @@ ALTER TABLE llx_expedition ADD COLUMN ref_int varchar(30) AFTER ref_ext; ALTER TABLE llx_livraison ADD COLUMN ref_ext varchar(30) AFTER fk_soc; ALTER TABLE llx_livraison ADD COLUMN ref_int varchar(30) AFTER ref_ext; +INSERT INTO llx_c_shipment_mode (rowid,code,libelle,description,active) VALUES (4,'LETTREMAX','Lettre Max','Courrier Suivi et Lettre Max',0); + --Add Chile data (id pays=67) -- Regions Chile INSERT INTO llx_c_regions (rowid, code_region, fk_pays, cheflieu, tncc, nom, active) VALUES (6701, 6701, 67, NULL, NULL, 'Tarapacá', 1);