From 0cb1e4fe7c2cd8a7940e3161ac6e927c2ad87f30 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Wed, 11 Apr 2012 14:37:36 +0200
Subject: [PATCH] New: Add supplier ref on supplier orders

---
 ChangeLog                                       |  3 ++-
 .../fourn/class/fournisseur.commande.class.php  |  7 ++++---
 htdocs/fourn/commande/fiche.php                 | 17 +++++++++++++----
 3 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 644be54c311..5a1ef2ce49b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,7 +3,8 @@ English Dolibarr ChangeLog
 --------------------------------------------------------------
 
 ***** ChangeLog for 3.3 compared to 3.2 *****
-
+For users:
+- New: Add supplier ref on supplier orders
 
 
 ***** ChangeLog for 3.2 compared to 3.1 *****
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index e186337fcc0..4c3e5a3c173 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -69,7 +69,7 @@ class CommandeFournisseur extends Commande
     var $cond_reglement_code;
     var $mode_reglement_id;
     var $mode_reglement_code;
-    
+
     var $extraparams=array();
 
 
@@ -111,7 +111,7 @@ class CommandeFournisseur extends Commande
         // Check parameters
         if (empty($id) && empty($ref)) return -1;
 
-        $sql = "SELECT c.rowid, c.ref, c.date_creation, c.fk_soc, c.fk_user_author, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva,";
+        $sql = "SELECT c.rowid, c.ref, ref_supplier, c.date_creation, c.fk_soc, c.fk_user_author, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva,";
         $sql.= " c.localtax1, c.localtax2, ";
         $sql.= " c.date_commande as date_commande, c.date_livraison as date_livraison, c.fk_cond_reglement, c.fk_mode_reglement, c.fk_projet as fk_project, c.remise_percent, c.source, c.fk_methode_commande,";
         $sql.= " c.note as note_private, c.note_public, c.model_pdf, c.extraparams,";
@@ -140,6 +140,7 @@ class CommandeFournisseur extends Commande
 
             $this->id					= $obj->rowid;
             $this->ref					= $obj->ref;
+            $this->ref_supplier			= $obj->ref_supplier;
             $this->socid				= $obj->fk_soc;
             $this->fourn_id				= $obj->fk_soc;
             $this->statut				= $obj->fk_statut;
@@ -170,7 +171,7 @@ class CommandeFournisseur extends Commande
             $this->note_private			= $obj->note_private;
             $this->note_public			= $obj->note_public;
             $this->modelpdf				= $obj->model_pdf;
-            
+
             $this->extraparams			= (array) json_decode($obj->extraparams, true);
 
             $this->db->free($resql);
diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php
index caf83271bbd..7b06d9d87fb 100644
--- a/htdocs/fourn/commande/fiche.php
+++ b/htdocs/fourn/commande/fiche.php
@@ -72,6 +72,12 @@ $object = new CommandeFournisseur($db);
 /*
  * Actions
  */
+if ($action == 'setref_supplier' && $user->rights->fournisseur->commande->creer)
+{
+    $object->fetch($id);
+    $result=$object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha'));
+    if ($result < 0) dol_print_error($db, $object->error);
+}
 
 // conditions de reglement
 if ($action == 'setconditions' && $user->rights->fournisseur->commande->creer)
@@ -1037,10 +1043,12 @@ if ($id > 0 || ! empty($ref))
         print '</tr>';
 
         // Ref supplier
-        /*		print '<tr><td>'.$langs->trans("RefSupplier")."</td>";
-        print '<td colspan="2">'.$object->ref_supplier.'</td>';
-        print '</tr>';
-        */
+        print '<tr><td>';
+        print $form->editfieldkey("RefSupplier",'ref_supplier',$langs->trans($object->ref_supplier),$object,$user->rights->fournisseur->commande->creer);
+        print '</td><td colspan="2">';
+        print $form->editfieldval("RefSupplier",'ref_supplier',$langs->trans($object->ref_supplier),$object,$user->rights->fournisseur->commande->creer);
+        print '</td></tr>';
+
         // Fournisseur
         print '<tr><td>'.$langs->trans("Supplier")."</td>";
         print '<td colspan="2">'.$soc->getNomUrl(1,'supplier').'</td>';
@@ -1758,5 +1766,6 @@ if ($id > 0 || ! empty($ref))
 
 // End of page
 llxFooter();
+
 $db->close();
 ?>
\ No newline at end of file
-- 
GitLab