diff --git a/htdocs/expedition/expedition.class.php b/htdocs/expedition/expedition.class.php index 3983eeed389..48213c6042b 100644 --- a/htdocs/expedition/expedition.class.php +++ b/htdocs/expedition/expedition.class.php @@ -237,16 +237,18 @@ class Expedition extends CommonObject global $conf; $sql = "SELECT e.rowid, e.fk_soc as socid, e.date_creation, e.ref, e.fk_user_author, e.fk_statut"; - $sql.= ", weight, weight_units, size, size_units, width, height"; + $sql.= ", e.weight, e.weight_units, e.size, e.size_units, e.width, e.height"; $sql.= ", ".$this->db->pdate("e.date_expedition")." as date_expedition, e.model_pdf, e.fk_adresse_livraison"; $sql.= ", e.fk_expedition_methode, e.tracking_number"; if ($conf->commande->enabled) { - $sql.=", ce.fk_commande as origin_id"; + $sql.= ", ce.fk_commande as origin_id"; + $sql.= ", c.ref_client"; } else { - $sql.=", pe.fk_propal as origin_id"; + $sql.= ", pe.fk_propal as origin_id"; + $sql.= ", p.ref_client"; } if ($conf->livraison_bon->enabled) $sql.=", l.rowid as livraison_id"; $sql.= " FROM ".MAIN_DB_PREFIX."expedition as e"; @@ -274,6 +276,7 @@ class Expedition extends CommonObject $this->id = $obj->rowid; $this->ref = $obj->ref; $this->socid = $obj->socid; + $this->ref_client = $obj->ref_client; $this->statut = $obj->fk_statut; $this->origin_id = $obj->origin_id; $this->livraison_id = $obj->livraison_id; @@ -503,22 +506,22 @@ class Expedition extends CommonObject if ($conf->livraison_bon->enabled) { if ($this->statut == 1) - { - // Expédition validée - include_once(DOL_DOCUMENT_ROOT."/livraison/livraison.class.php"); - $livraison = new Livraison($this->db); - $result=$livraison->create_from_sending($user, $this->id); - if ($result > 0) - { - return $result; - } - else - { - $this->error=$livraison->error; - return $result; - } - } - else return 0; + { + // Expédition validée + include_once(DOL_DOCUMENT_ROOT."/livraison/livraison.class.php"); + $livraison = new Livraison($this->db); + $result=$livraison->create_from_sending($user, $this->id); + if ($result > 0) + { + return $result; + } + else + { + $this->error=$livraison->error; + return $result; + } + } + else return 0; } else return 0; } diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 934b29ad807..18ab98062b1 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -646,7 +646,7 @@ else // Ref customer print ''.$langs->trans("RefCustomer").''; - print ''.$object->ref_client."\n"; + print ''.$expedition->ref_client."\n"; print ''; // Date diff --git a/htdocs/livraison/livraison.class.php b/htdocs/livraison/livraison.class.php index 355a831156d..369f079d328 100644 --- a/htdocs/livraison/livraison.class.php +++ b/htdocs/livraison/livraison.class.php @@ -50,6 +50,7 @@ class Livraison extends CommonObject var $origin; var $origin_id; var $socid; + var $ref_client; var $expedition_id; @@ -100,6 +101,7 @@ class Livraison extends CommonObject $sql.= "ref"; $sql.= ", entity"; $sql.= ", fk_soc"; + $sql.= ", ref_client"; $sql.= ", date_creation"; $sql.= ", fk_user_author"; $sql.= ", fk_adresse_livraison"; @@ -109,6 +111,7 @@ class Livraison extends CommonObject $sql.= "'(PROV)'"; $sql.= ", ".$conf->entity; $sql.= ", ".$this->socid; + $sql.= ", '".$this->ref_client."'"; $sql.= ", ".$this->db->idate(mktime()); $sql.= ", ".$user->id; $sql.= ", ".($this->adresse_livraison_id > 0 ? $this->adresse_livraison_id : "null"); @@ -514,6 +517,7 @@ class Livraison extends CommonObject $this->date_livraison = $expedition->date_livraison; $this->adresse_livraison_id = $expedition->adresse_livraison_id; $this->socid = $expedition->socid; + $this->ref_client = $expedition->ref_client; return $this->create($user); }