diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php
index 535bebefa75..ae462b27aa2 100644
--- a/htdocs/expedition/fiche.php
+++ b/htdocs/expedition/fiche.php
@@ -771,7 +771,7 @@ else
print '
'.$expedition->ref_customer." | \n";
print '';
- // Date
+ // Date creation
print '| '.$langs->trans("DateCreation").' | ';
print ''.dol_print_date($expedition->date_creation,"daytext")." | \n";
print '
';
diff --git a/htdocs/lib/sendings.lib.php b/htdocs/lib/sendings.lib.php
index 24637fb5802..fe6d84a6b30 100644
--- a/htdocs/lib/sendings.lib.php
+++ b/htdocs/lib/sendings.lib.php
@@ -123,10 +123,11 @@ function show_list_sending_receive($origin='commande',$origin_id,$filter='')
global $html;
$product_static=new Product($db);
+ $expedition=new Expedition($db);
$sql = "SELECT obj.rowid, obj.fk_product, obj.description, obj.product_type as fk_product_type, obj.qty as qty_asked";
- $sql.= ", ed.qty as qty_shipped, ed.fk_expedition as expedition_id";
- $sql.= ", e.ref as exp_ref, e.date_expedition,";
+ $sql.= ", ed.qty as qty_shipped, ed.fk_expedition as expedition_id, ed.fk_origin_line";
+ $sql.= ", e.rowid as sendingid, e.ref as exp_ref, e.date_creation, e.date_delivery, e.date_expedition,";
//if ($conf->livraison_bon->enabled) $sql .= " l.rowid as livraison_id, l.ref as livraison_ref, l.date_delivery, ld.qty as qty_received,";
$sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid,';
$sql.= ' p.description as product_desc';
@@ -160,13 +161,14 @@ function show_list_sending_receive($origin='commande',$origin_id,$filter='')
//print ''.$langs->trans("QtyOrdered").' | ';
print ''.$langs->trans("SendingSheet").' | ';
print ''.$langs->trans("Description").' | ';
+ print ''.$langs->trans("DateCreation").' | ';
+ print ''.$langs->trans("DateDeliveryPlanned").' | ';
print ''.$langs->trans("QtyShipped").' | ';
- print ''.$langs->trans("DateSending").' | ';
if ($conf->livraison_bon->enabled)
{
print ''.$langs->trans("DeliveryOrder").' | ';
- print ''.$langs->trans("QtyReceived").' | ';
- print ''.$langs->trans("DeliveryDate").' | ';
+ //print ''.$langs->trans("QtyReceived").' | ';
+ print ''.$langs->trans("DeliveryDate").' | ';
}
print "\n";
@@ -220,22 +222,48 @@ function show_list_sending_receive($origin='commande',$origin_id,$filter='')
//print ''.$objp->qty_asked.' | ';
+ // Date creation
+ print ''.dol_print_date($db->jdate($objp->date_creation),'day').' | ';
+
+ // Date shipping creation
+ print ''.dol_print_date($db->jdate($objp->date_delivery),'day').' | ';
+
+ // Qty shipped
print ''.$objp->qty_shipped.' | ';
- // Date shipping was planed
- print ''.dol_print_date($db->jdate($objp->date_expedition),'day').' | ';
-
-
+ // Informations on receipt
if ($conf->livraison_bon->enabled)
{
- if ($objp->livraison_id)
+ include_once(DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php');
+ $expedition->id=$objp->sendingid;
+ $expedition->load_object_linked($expedition->id,$expedition->element,-1,-1);
+ $livraison_id=$expedition->linked_object['delivery'][0];
+
+ if ($livraison_id)
{
+ $receiving=new Livraison($db);
+ $receiving->fetch($livraison_id);
+
+ // $expedition->fk_origin_line = id of det line of order
+ // $receiving->fk_origin_line = id of det line of order
+ // $receiving->origin may be 'shipping'
+ // $receiving->origin_id may be id of shipping
+
// Ref
- print ''.img_object($langs->trans("ShowSending"),'sending').' '.$objp->livraison_ref.' | ';
+ print '';
+ print $receiving->getNomUrl($db);
+ //print ''.img_object($langs->trans("ShowReceiving"),'sending').' '.$objp->livraison_ref.'';
+ print ' | ';
// Qty received
- print ''.$objp->qty_received.' | ';
+ //print '';
+ // TODO No solution for the moment to link a line det of receipt with a line det of shipping,
+ // so no way to know the qty received for this line of shipping.
+ //print $langs->trans("FeatureNotYetAvailable");
+ //print ' | ';
// Date shipping real
- print ''.dol_print_date($objp->date_delivery,'day').' | ';
+ print '';
+ print dol_print_date($receiving->date_delivery,'day');
+ print ' | ';
}
else
{
diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php
index 4374065db86..b836fbbd493 100644
--- a/htdocs/livraison/class/livraison.class.php
+++ b/htdocs/livraison/class/livraison.class.php
@@ -270,8 +270,8 @@ class Livraison extends CommonObject
$this->note = $obj->note;
$this->note_public = $obj->note_public;
$this->modelpdf = $obj->model_pdf;
- $this->origin = $obj->origin;
- $this->origin_id = $obj->origin_id;
+ $this->origin = $obj->origin; // May be 'shipping'
+ $this->origin_id = $obj->origin_id; // May be id of shipping
$this->db->free($result);
@@ -630,6 +630,31 @@ class Livraison extends CommonObject
}
}
+ /**
+ * \brief Renvoie nom clicable (avec eventuellement le picto)
+ * \param withpicto 0=Pas de picto, 1=Inclut le picto dans le lien, 2=Picto seul
+ * \return string Chaine avec URL
+ */
+ function getNomUrl($withpicto=0)
+ {
+ global $langs;
+
+ $result='';
+ $urlOption='';
+
+
+ $lien = '';
+ $lienfin='';
+
+ $picto='sending';
+ $label=$langs->trans("ShowReceiving").': '.$this->ref;
+
+ if ($withpicto) $result.=($lien.img_object($label,$picto).$lienfin);
+ if ($withpicto && $withpicto != 2) $result.=' ';
+ $result.=$lien.$this->ref.$lienfin;
+ return $result;
+ }
+
/**
*
*
@@ -871,45 +896,6 @@ class Livraison extends CommonObject
}
}
- /**
- * \brief Renvoie un tableau avec les livraisons par ligne
- * \param filtre_statut Filtre sur statut
- * \return int 0 si OK, <0 si KO
- * \TODO obsolete
- */
- function livraison_array($filtre_statut=-1)
- {
- $this->livraisons = array();
-
- $sql = 'SELECT cd.fk_product, SUM(ld.qty)';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'livraisondet as ld';
- $sql.= ', '.MAIN_DB_PREFIX.'livraison as l';
- $sql.= ', '.MAIN_DB_PREFIX.'commande as c';
- $sql.= ', '.MAIN_DB_PREFIX.'commandedet as cd';
- $sql.= ' WHERE ld.fk_livraison = l.rowid';
- $sql.= ' AND ld.fk_commande_ligne = cd .rowid';
- $sql.= ' AND cd.fk_commande = c.rowid';
- $sql.= ' AND cd.fk_commande =' .$this->id;
- if ($filtre_statut >= 0) $sql.=' AND l.fk_statut = '.$filtre_statut;
- $sql.= ' GROUP BY cd.fk_product ';
-
- $resql = $this->db->query($sql);
- if ($resql)
- {
- $num = $this->db->num_rows($resql);
- $i = 0;
- while ($i < $num)
- {
- $row = $this->db->fetch_row($resql);
- $this->livraisons[$row[0]] = $row[1];
- $i++;
- }
- $this->db->free();
- }
-
- return 0;
- }
-
}