From f213b4f555a6719efdc7cab9743d56460c6b2836 Mon Sep 17 00:00:00 2001
From: Regis Houssin <regis@dolibarr.fr>
Date: Sat, 13 Mar 2010 17:44:27 +0000
Subject: [PATCH] Fix: best autonomy of modules Fix: uniformise fields and code
 !! not stable !!

---
 htdocs/commande/commande.class.php     |  2 +-
 htdocs/expedition/expedition.class.php |  2 +-
 htdocs/expedition/fiche.php            | 40 +++++++++++++++-----------
 htdocs/expedition/shipment.php         | 22 +++++++-------
 htdocs/lib/sendings.lib.php            |  4 +--
 5 files changed, 38 insertions(+), 32 deletions(-)

diff --git a/htdocs/commande/commande.class.php b/htdocs/commande/commande.class.php
index c197c78ce87..eb0659cef42 100644
--- a/htdocs/commande/commande.class.php
+++ b/htdocs/commande/commande.class.php
@@ -1,7 +1,7 @@
 <?php
 /* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  * Copyright (C) 2004-2009 Laurent Destailleur  <eldy@users.sourceforge.net>
- * Copyright (C) 2005-2009 Regis Houssin        <regis@dolibarr.fr>
+ * Copyright (C) 2005-2010 Regis Houssin        <regis@dolibarr.fr>
  * Copyright (C) 2006      Andre Cianfarani     <acianfa@free.fr>
  *
  * This program is free software; you can redistribute it and/or modify
diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php
index da61c6f3b47..5d4cf854d34 100644
--- a/htdocs/expedition/expedition.class.php
+++ b/htdocs/expedition/expedition.class.php
@@ -231,7 +231,7 @@ class Expedition extends CommonObject
 	 *		\brief		Lit une expedition
 	 *		\param		id
 	 */
-	function fetch ($id)
+	function fetch($id)
 	{
 		global $conf;
 
diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php
index a3f3fef98ed..bce6266f274 100644
--- a/htdocs/expedition/fiche.php
+++ b/htdocs/expedition/fiche.php
@@ -52,7 +52,7 @@ $origin_id = isset($_GET["id"])?$_GET["id"]:'';
 $id = $origin_id;
 
 $origin     = $_GET["origin"]?$_GET["origin"]:$_POST["origin"];				// Example: commande, propal
-$origin_id  = $_GET["object_id"]?$_GET["object_id"]:$_POST["object_id"];	// Id of order or propal
+$origin_id  = $_GET["origin_id"]?$_GET["origin_id"]:$_POST["origin_id"];	// Id of order or propal
 
 
 // Security check
@@ -60,7 +60,6 @@ if ($user->societe_id) $socid=$user->societe_id;
 $result=restrictedArea($user,$origin,$origin_id,'');
 
 
-
 /*
  * Actions
  */
@@ -72,16 +71,16 @@ if ($_POST["action"] == 'add')
 	// Creation de l'objet expedition
 	$expedition = new Expedition($db);
 
-	$expedition->date_expedition  = time();
-	$expedition->note             = $_POST["note"];
-	$expedition->origin           = $origin;
-	$expedition->origin_id        = $origin_id;
-	$expedition->weight			= $_POST["weight"]==""?"NULL":$_POST["weight"];
-	$expedition->sizeH			= $_POST["sizeH"]==""?"NULL":$_POST["sizeH"];
-	$expedition->sizeW			= $_POST["sizeW"]==""?"NULL":$_POST["sizeW"];
-	$expedition->sizeS			= $_POST["sizeS"]==""?"NULL":$_POST["sizeS"];
-	$expedition->size_units		= $_POST["size_units"];
-	$expedition->weight_units	= $_POST["weight_units"];
+	$expedition->date_expedition	= time();
+	$expedition->note				= $_POST["note"];
+	$expedition->origin				= $origin;
+	$expedition->origin_id			= $origin_id;
+	$expedition->weight				= $_POST["weight"]==""?"NULL":$_POST["weight"];
+	$expedition->sizeH				= $_POST["sizeH"]==""?"NULL":$_POST["sizeH"];
+	$expedition->sizeW				= $_POST["sizeW"]==""?"NULL":$_POST["sizeW"];
+	$expedition->sizeS				= $_POST["sizeS"]==""?"NULL":$_POST["sizeS"];
+	$expedition->size_units			= $_POST["size_units"];
+	$expedition->weight_units		= $_POST["weight_units"];
 
 	// On boucle sur chaque ligne du document d'origine pour completer objet expedition
 	// avec qte a livrer
@@ -90,10 +89,12 @@ if ($_POST["action"] == 'add')
 	$object->fetch($expedition->origin_id);
 	//$object->fetch_lines();
 
-	$expedition->socid  = $object->socid;
-	$expedition->fk_delivery_address = $object->fk_delivery_address;
-	$expedition->expedition_method_id = $_POST["expedition_method_id"];
-	$expedition->tracking_number = $_POST["tracking_number"];
+	$expedition->socid					= $object->socid;
+	$expedition->ref_customer			= $object->ref_client;
+	$expedition->date_delivery			= $object->date_livraison;
+	$expedition->fk_delivery_address	= $object->fk_delivery_address;
+	$expedition->expedition_method_id	= $_POST["expedition_method_id"];
+	$expedition->tracking_number		= $_POST["tracking_number"];
 
 	for ($i = 0 ; $i < sizeof($object->lignes) ; $i++)
 	{
@@ -278,7 +279,7 @@ if ($_GET["action"] == 'create')
 			print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
 			print '<input type="hidden" name="action" value="add">';
 			print '<input type="hidden" name="origin" value="'.$origin.'">';
-			print '<input type="hidden" name="object_id" value="'.$object->id.'">';
+			print '<input type="hidden" name="origin_id" value="'.$object->id.'">';
 			if ($_GET["entrepot_id"])
 			{
 				print '<input type="hidden" name="entrepot_id" value="'.$_GET["entrepot_id"].'">';
@@ -314,6 +315,11 @@ if ($_GET["action"] == 'create')
 			// Date
 			print "<tr><td>".$langs->trans("Date")."</td>";
 			print '<td colspan="3">'.dol_print_date($object->date,"day")."</td></tr>\n";
+			
+			// Date delivery planned
+			print '<tr><td>'.$langs->trans("DateDeliveryPlanned").'</td>';
+			print '<td colspan="3">'.dol_print_date($object->date_livraison,'day')."</td>\n";
+			print '</tr>';
 
 			// Delivery address
 			if (($origin == 'commande' && $conf->global->COMMANDE_ADD_DELIVERY_ADDRESS)
diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php
index 990961e702e..835af4e636e 100644
--- a/htdocs/expedition/shipment.php
+++ b/htdocs/expedition/shipment.php
@@ -75,14 +75,14 @@ if ($_POST["action"] == 'confirm_cloture' && $_POST["confirm"] == 'yes')
 }
 
 // Positionne ref commande client
-if ($_POST['action'] == 'set_ref_client' && $user->rights->commande->creer)
+if ($_POST['action'] == 'setrefcustomer' && $user->rights->commande->creer)
 {
 	$commande = new Commande($db);
 	$commande->fetch($_GET['id']);
-	$commande->set_ref_client($user, $_POST['ref_client']);
+	$commande->set_ref_client($user, $_POST['ref_customer']);
 }
 
-if ($_POST['action'] == 'setdate_livraison' && $user->rights->commande->creer)
+if ($_POST['action'] == 'setdatedelivery' && $user->rights->commande->creer)
 {
 	//print "x ".$_POST['liv_month'].", ".$_POST['liv_day'].", ".$_POST['liv_year'];
 	$datelivraison=dol_mktime(0, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year']);
@@ -96,11 +96,11 @@ if ($_POST['action'] == 'setdate_livraison' && $user->rights->commande->creer)
 	}
 }
 
-if ($_POST['action'] == 'setdeliveryadress' && $user->rights->commande->creer)
+if ($_POST['action'] == 'setdeliveryaddress' && $user->rights->commande->creer)
 {
 	$commande = new Commande($db);
 	$commande->fetch($_GET['id']);
-	$commande->set_adresse_livraison($user,$_POST['adresse_livraison_id']);
+	$commande->set_adresse_livraison($user,$_POST['delivery_address_id']);
 }
 
 if ($_POST['action'] == 'setmode' && $user->rights->commande->creer)
@@ -187,8 +187,8 @@ if ($id > 0 || ! empty($ref))
 		{
 			print '<form action="'.$_SERVER['PHP_SELF'].'?id='.$id.'" method="POST">';
 			print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-			print '<input type="hidden" name="action" value="set_ref_client">';
-			print '<input type="text" class="flat" size="20" name="ref_client" value="'.$commande->ref_client.'">';
+			print '<input type="hidden" name="action" value="setrefcustomer">';
+			print '<input type="text" class="flat" size="20" name="ref_customer" value="'.$commande->ref_client.'">';
 			print ' <input type="submit" class="button" value="'.$langs->trans('Modify').'">';
 			print '</form>';
 		}
@@ -261,8 +261,8 @@ if ($id > 0 || ! empty($ref))
 		{
 			print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'" method="post">';
 			print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
-			print '<input type="hidden" name="action" value="setdate_livraison">';
-			$html->select_date($commande->date_livraison,'liv_','','','',"setdate_livraison");
+			print '<input type="hidden" name="action" value="setdatedelivery">';
+			$html->select_date($commande->date_livraison,'liv_','','','',"setdatedelivery");
 			print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
 			print '</form>';
 		}
@@ -290,7 +290,7 @@ if ($id > 0 || ! empty($ref))
 
 			if ($_GET['action'] == 'editdelivery_adress')
 			{
-				$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->fk_delivery_address,$_GET['socid'],'adresse_livraison_id','commande',$commande->id);
+				$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->fk_delivery_address,$_GET['socid'],'delivery_address_id','commande',$commande->id);
 			}
 			else
 			{
@@ -603,7 +603,7 @@ if ($id > 0 || ! empty($ref))
 				print '<input type="hidden" name="action" value="create">';
 				print '<input type="hidden" name="id" value="'.$commande->id.'">';
 				print '<input type="hidden" name="origin" value="commande">';
-				print '<input type="hidden" name="object_id" value="'.$commande->id.'">';
+				print '<input type="hidden" name="origin_id" value="'.$commande->id.'">';
 				print '<table class="border" width="100%">';
 
 				$entrepot = new Entrepot($db);
diff --git a/htdocs/lib/sendings.lib.php b/htdocs/lib/sendings.lib.php
index 57e551a0789..c207587132c 100644
--- a/htdocs/lib/sendings.lib.php
+++ b/htdocs/lib/sendings.lib.php
@@ -221,14 +221,14 @@ function show_list_sending_receive($origin='commande',$origin_id,$filter='')
 
 				print '<td align="center">'.$objp->qty_shipped.'</td>';
 
-				print '<td align="center" nowrap="nowrap">'.dol_print_date($objp->date_expedition,'dayhour').'</td>';
+				print '<td align="center" nowrap="nowrap">'.dol_print_date($objp->date_expedition,'day').'</td>';
 				if ($conf->livraison_bon->enabled)
 				{
 					if ($objp->livraison_id)
 					{
 						print '<td><a href="'.DOL_URL_ROOT.'/livraison/fiche.php?id='.$objp->livraison_id.'">'.img_object($langs->trans("ShowSending"),'sending').' '.$objp->livraison_ref.'<a></td>';
 						print '<td align="center">'.$objp->qty_received.'</td>';
-						print '<td>'.dol_print_date($objp->date_delivery,'dayhour').'</td>';
+						print '<td>'.dol_print_date($objp->date_delivery,'day').'</td>';
 					}
 					else
 					{
-- 
GitLab