From 536eb7e008b8ce0d1e8229feb7e1492b0f4aa4c3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 14 Feb 2018 17:25:13 +0100 Subject: [PATCH] Fix label of invoice --- htdocs/fourn/card.php | 33 ++++++++++--------- .../fourn/class/fournisseur.facture.class.php | 2 ++ 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 5a47ce17089..8d10d55b3bd 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -107,7 +107,7 @@ if (empty($reshook)) // Fill array 'array_options' with data from update form $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute')); - + if ($ret < 0) $error++; if (! $error) { @@ -456,7 +456,7 @@ if ($object->id > 0) /* - * Last supplier proposal + * Latest supplier proposal */ $proposalstatic = new SupplierProposal($db); @@ -465,7 +465,7 @@ if ($object->id > 0) $sql = "SELECT p.rowid, p.ref, p.date_valid as dc, p.fk_statut, p.total_ht, p.tva as total_tva, p.total as total_ttc"; $sql.= " FROM ".MAIN_DB_PREFIX."supplier_proposal as p "; $sql.= " WHERE p.fk_soc =".$object->id; - $sql.= " AND p.entity =".$conf->entity; + $sql.= " AND p.entity IN (".getEntity('supplier_proposal').")"; $sql.= " ORDER BY p.date_valid DESC"; $sql.= " ".$db->plimit($MAXLIST); @@ -528,7 +528,7 @@ if ($object->id > 0) } /* - * Last supplier orders + * Latest supplier orders */ $orderstatic = new CommandeFournisseur($db); @@ -541,6 +541,7 @@ if ($object->id > 0) $sql2.= ' FROM '.MAIN_DB_PREFIX.'societe as s'; $sql2.= ', '.MAIN_DB_PREFIX.'commande_fournisseur as c'; $sql2.= ' WHERE c.fk_soc = s.rowid'; + $sql2.= " AND c.entity IN (".getEntity('commande_fournisseur').")"; $sql2.= ' AND s.rowid = '.$object->id; // Show orders with status validated, shipping started and delivered (well any order we can bill) $sql2.= " AND c.fk_statut IN (5)"; @@ -558,9 +559,9 @@ if ($object->id > 0) // TODO move to DAO class $sql = "SELECT count(p.rowid) as total"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p "; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p"; $sql.= " WHERE p.fk_soc =".$object->id; - $sql.= " AND p.entity =".$conf->entity; + $sql.= " AND p.entity IN (".getEntity('commande_fournisseur').")"; $resql=$db->query($sql); if ($resql) { @@ -569,9 +570,9 @@ if ($object->id > 0) } $sql = "SELECT p.rowid,p.ref, p.date_commande as dc, p.fk_statut, p.total_ht, p.tva as total_tva, p.total_ttc"; - $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p "; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseur as p"; $sql.= " WHERE p.fk_soc =".$object->id; - $sql.= " AND p.entity =".$conf->entity; + $sql.= " AND p.entity IN (".getEntity('commande_fournisseur').")"; $sql.= " ORDER BY p.date_commande DESC"; $sql.= " ".$db->plimit($MAXLIST); $resql=$db->query($sql); @@ -632,7 +633,7 @@ if ($object->id > 0) } /* - * Last supplier invoices + * Latest supplier invoices */ $langs->load('bills'); @@ -646,7 +647,7 @@ if ($object->id > 0) $sql.= ' FROM '.MAIN_DB_PREFIX.'facture_fourn as f'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf ON f.rowid=pf.fk_facturefourn'; $sql.= ' WHERE f.fk_soc = '.$object->id; - $sql.= " AND f.entity =".$conf->entity; + $sql.= " AND f.entity IN (".getEntity('facture_fourn').")"; $sql.= ' GROUP BY f.rowid,f.libelle,f.ref,f.ref_supplier,f.fk_statut,f.datef,f.total_ht,f.total_tva,f.total_ttc,f.paye'; $sql.= ' ORDER BY f.datef DESC'; $resql=$db->query($sql); @@ -674,15 +675,15 @@ if ($object->id > 0) print ''; print ''; $facturestatic->id=$obj->rowid; - $facturestatic->ref=($obj->ref?$obj->ref:$obj->rowid).($obj->ref_supplier?' - '.$obj->ref_supplier:''); - $facturestatic->ref_supplier = $obj->ref_supplier; - $facturestatic->total_ht = $obj->total_ht; + $facturestatic->ref=($obj->ref?$obj->ref:$obj->rowid); + $facturestatic->ref_supplier = $obj->ref_supplier; + $facturestatic->libelle = $obj->libelle; + $facturestatic->total_ht = $obj->total_ht; $facturestatic->total_tva = $obj->total_tva; $facturestatic->total_ttc = $obj->total_ttc; - //$facturestatic->ref_supplier=$obj->ref_supplier; print $facturestatic->getNomUrl(1); - //print img_object($langs->trans('ShowBill'),'bill').' '.($obj->ref?$obj->ref:$obj->rowid).' - '.$obj->ref_supplier.''; - print ' '.dol_trunc($obj->libelle,14); + print $obj->ref_supplier?' - '.$obj->ref_supplier:''; + print ($obj->libelle?' - ':'').dol_trunc($obj->libelle,14); print ''; print ''.dol_print_date($db->jdate($obj->df),'day').''; print ''.price($obj->amount).''; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 444eb5d200a..292466ea0d8 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1929,6 +1929,8 @@ class FactureFournisseur extends CommonInvoice $label .= '
' . $langs->trans('Ref') . ': ' . $this->ref; if (! empty($this->ref_supplier)) $label.= '
' . $langs->trans('RefSupplier') . ': ' . $this->ref_supplier; + if (! empty($this->libelle)) + $label.= '
' . $langs->trans('Label') . ': ' . $this->libelle; if (! empty($this->total_ht)) $label.= '
' . $langs->trans('AmountHT') . ': ' . price($this->total_ht, 0, $langs, 0, -1, -1, $conf->currency); if (! empty($this->total_tva))