From 5cbd809f732aa999fd5d8bb44b4a03b2c49481aa Mon Sep 17 00:00:00 2001
From: Regis Houssin <regis@dolibarr.fr>
Date: Sun, 19 Jun 2011 19:47:09 +0000
Subject: [PATCH] Fix: uniformize code

---
 htdocs/core/class/html.formmail.class.php    |  4 +++-
 htdocs/expedition/class/expedition.class.php | 16 +++++++++++-----
 htdocs/expedition/fiche.php                  |  1 -
 htdocs/langs/fr_FR/sendings.lang             |  1 +
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index 8e24402e51e..1b310d4147c 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -59,6 +59,7 @@ class FormMail
 	var $withtoreadonly;
 	var $withtoccreadonly;
 	var $withtopicreadonly;
+	var $withfilereadonly;
 	var $withdeliveryreceipt;
 	var $withcancel;
 
@@ -94,6 +95,7 @@ class FormMail
 		$this->withtoccreadonly=0;
 		$this->witherrorstoreadonly=0;
 		$this->withtopicreadonly=0;
+		$this->withfilereadonly=0;
 		$this->withbodyreadonly=0;
 		$this->withdeliveryreceiptreadonly=0;
 
@@ -492,7 +494,7 @@ class FormMail
 				foreach($listofpaths as $key => $val)
 				{
 					$out.= img_mime($listofnames[$key]).' '.$listofnames[$key];
-					$out.= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key+1).'" id="removedfile" name="removedfile" />';
+					if (! $this->withfilereadonly) $out.= ' <input type="image" style="border: 0px;" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/delete.png" value="'.($key+1).'" id="removedfile" name="removedfile" />';
 					$out.= '<br>';
 				}
 			}
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index bc47a8dd2fc..204679d3eae 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -56,6 +56,8 @@ class Expedition extends CommonObject
 	var $lines=array();
 	var $expedition_method_id; // TODO deprecated
 	var $shipping_method_id;
+	var $tracking_number;
+	var $tracking_url;
 	var $statut;
 
 	var $trueWeight;
@@ -350,7 +352,8 @@ class Expedition extends CommonObject
 				$this->date_delivery        = $this->db->jdate($obj->date_delivery);	// Date planed
 				$this->fk_delivery_address  = $obj->fk_address;
 				$this->modelpdf             = $obj->model_pdf;
-				$this->expedition_method_id = $obj->fk_expedition_methode;
+				$this->expedition_method_id = $obj->fk_expedition_methode; // TODO deprecated
+				$this->shipping_method_id	= $obj->fk_expedition_methode;
 				$this->tracking_number      = $obj->tracking_number;
 				$this->origin               = ($obj->origin?$obj->origin:'commande'); // For compatibility
 				$this->origin_id            = $obj->origin_id;
@@ -375,6 +378,9 @@ class Expedition extends CommonObject
 
 				$file = $conf->expedition->dir_output . "/" .get_exdir($expedition->id,2) . "/" . $this->id.".pdf";
 				$this->pdf_filename = $file;
+				
+				// Tracking url
+				$this->GetUrlTrackingStatus($obj->tracking_number);
 
 				/*
 				 * Lines
@@ -1099,13 +1105,13 @@ class Expedition extends CommonObject
 	function GetUrlTrackingStatus($value='')
 	{
 		$code='';
-		
+
 		if (! empty($this->expedition_method_id))
 		{
 			$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)
 			{
@@ -1124,8 +1130,8 @@ class Expedition extends CommonObject
 			if (file_exists(DOL_DOCUMENT_ROOT."/includes/modules/expedition/methode_expedition_".strtolower($code).".modules.php") && ! empty($this->tracking_number))
 			{
 				require_once(DOL_DOCUMENT_ROOT."/includes/modules/expedition/methode_expedition_".strtolower($code).".modules.php");
-				$obj = new $classname();
-				$url = $obj->provider_url_status($this->tracking_number);
+				$shipmethod = new $classname();
+				$url = $shipmethod->provider_url_status($this->tracking_number);
 			}
 
 			if ($url)
diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php
index a4a7bd01900..e219919ae1d 100644
--- a/htdocs/expedition/fiche.php
+++ b/htdocs/expedition/fiche.php
@@ -1097,7 +1097,6 @@ else
 			print '</tr>';
 
 			// Tracking Number
-			$object->GetUrlTrackingStatus($object->tracking_number);
 			print '<tr><td>'.$html->editfieldkey("TrackingNumber",'trackingnumber',$object->tracking_number,'id',$object->id,$user->rights->expedition->creer).'</td><td colspan="3">';
 			print $html->editfieldval("TrackingNumber",'trackingnumber',$object->tracking_url,'id',$object->id,$user->rights->expedition->creer,'string',$object->tracking_number);
 			print '</td></tr>';
diff --git a/htdocs/langs/fr_FR/sendings.lang b/htdocs/langs/fr_FR/sendings.lang
index 1e6c8f8d37d..4be0a7f3e25 100644
--- a/htdocs/langs/fr_FR/sendings.lang
+++ b/htdocs/langs/fr_FR/sendings.lang
@@ -59,6 +59,7 @@ LinkToTrackYourPackage=Lien pour suivi de votre colis
 SendingMethodCATCH=Enlèvement par le client
 SendingMethodTRANS=Transporteur
 SendingMethodCOLSUI=Colissimo Suivi
+SendingMethodLETTREMAX=Lettre Max
 
 # ModelDocument
 DocumentModelSirocco=Modèle de bon de réception/livraison simple
-- 
GitLab