diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php
index c38dfd2cb33..68091000c7f 100644
--- a/htdocs/fourn/commande/fiche.php
+++ b/htdocs/fourn/commande/fiche.php
@@ -671,153 +671,135 @@ if ($id > 0)
else print '
';
/*
- * Lignes de commandes
+ * Lignes de commandes
*/
print '
| '.$langs->trans('Label').' | '; + print ''.$langs->trans('VAT').' | '; + print ''.$langs->trans('PriceUHT').' | '; + print ''.$langs->trans('Qty').' | '; + print ''.$langs->trans('ReductionShort').' | '; + print ''.$langs->trans('AmountHT').' | '; + print ''; + print " | |||||
| '.$langs->trans('Label').' | '; - print ''.$langs->trans('VAT').' | '; - print ''.$langs->trans('PriceUHT').' | '; - print ''.$langs->trans('Qty').' | '; - print ''.$langs->trans('ReductionShort').' | '; - print ''.$langs->trans('AmountHT').' | '; - print ''; - print " | |||||
| ';
- print ''; // ancre pour retourner sur la ligne
-
- // Affiche ligne produit
- $text = '';
- $text.= img_object($langs->trans('ShowProduct'),'product');
- $text.= ' '.$objp->ref_fourn.'';
- $text.= ' ('.$objp->ref.')';
- $text.= ' - '.$objp->product;
- $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
- print $html->textwithtooltip($text,$description,3,'','',$i);
- if ($conf->global->PRODUIT_DESC_IN_FORM)
- {
- print ($objp->description && $objp->description!=$objp->product)?' '.dol_htmlentitiesbr($objp->description):''; - } - - print " | ";
- }
- else
- {
- print ''; - print ''; // ancre pour retourner sur la ligne - print nl2br($objp->description); - print ' | '; - } - print ''.vatrate($objp->tva_tx).'% | '; - print ''.price($objp->subprice)." | \n"; - print ''.$objp->qty.' | '; - if ($objp->remise_percent > 0) - { - print ''.dolibarr_print_reduction($objp->remise_percent)." | \n"; - } - else - { - print ''; - } - //Todo: Modifier la classe pour utiliser le champ total_ttc - print ' | '.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100).' | '; - if ($commande->statut == 0 && $user->rights->fournisseur->commande->creer) - { - print 'id.'&action=editline&rowid='.$objp->rowid.'#'.$objp->rowid.'">'; - print img_edit(); - print ' | '; - - print 'id.'&action=delete_product_line&lineid='.$objp->rowid.'">'; - print img_delete(); - print ' | '; - } - else - { - print ''; - } - print " | '; + print ''; // ancre pour retourner sur la ligne + print nl2br($objp->product_desc); + print ' | '; + } + print ''.vatrate($objp->tva_tx).'% | '; + print ''.price($objp->subprice)." | \n"; + print ''.$objp->qty.' | '; + if ($objp->remise_percent > 0) + { + print ''.dolibarr_print_reduction($objp->remise_percent)." | \n"; + } + else + { + print ''; + } + //Todo: Modifier la classe pour utiliser le champ total_ttc + print ' | '.price($objp->total_ht).' | '; + if ($commande->statut == 0 && $user->rights->fournisseur->commande->creer) + { + print 'id.'&action=editline&rowid='.$objp->rowid.'#'.$objp->rowid.'">'; + print img_edit(); + print ' | '; + + print 'id.'&action=delete_product_line&lineid='.$objp->rowid.'">'; + print img_delete(); + print ' | '; + } + else + { + print ''; + } + print ""; } - $db->free(); - } - else - { - dolibarr_print_error($db); + + // Ligne en mode update + if ($_GET["action"] == 'editline' && $user->rights->fournisseur->commande->creer && $_GET["rowid"] == $objp->rowid) + { + print '\n"; + } + $i++; } /* diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php index 4b278d5fe44..f36541d78dc 100644 --- a/htdocs/fourn/fournisseur.commande.class.php +++ b/htdocs/fourn/fournisseur.commande.class.php @@ -71,7 +71,8 @@ class CommandeFournisseur extends Commande /** - * Lit une commande + * \brief Load a supplier order + * \param Id of order to load */ function fetch($id) { @@ -115,21 +116,20 @@ class CommandeFournisseur extends Commande $this->db->free(); if ($this->statut == 0) $this->brouillon = 1; - - // export pdf ----------- - + + // Now load lines $this->lignes = array(); - $sql = 'SELECT l.fk_product, l.description, l.total_ht, l.total_tva, l.total_ttc, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice'; - $sql.= ', p.label, p.description as product_desc, p.rowid as prodid'; - $sql.= ', pf.ref_fourn'; - $sql.= ' FROM '.MAIN_DB_PREFIX.'commande_fournisseurdet as l'; - - //Todo: revoir le fonctionnement de la base produit fournisseurs - - $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product_fournisseur as pf ON l.fk_product = pf.fk_product AND l.ref = pf.ref_fourn'; + + $sql = "SELECT l.rowid, l.ref as ref_fourn, l.fk_product, l.label, l.description, l.qty,"; + $sql.= " l.tva_tx, l.remise_percent, l.subprice,"; + $sql.= " l.total_ht, l.total_tva, l.total_ttc,"; + $sql.= " p.rowid as product_id, p.ref, p.label as product, p.description as product_desc"; + $sql.= " FROM ".MAIN_DB_PREFIX."commande_fournisseurdet as l"; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; - $sql.= ' WHERE l.fk_commande = '.$this->id; - $sql.= ' ORDER BY l.rowid'; + $sql.= " WHERE l.fk_commande = ".$this->id; + $sql.= " ORDER BY l.rowid"; + + dolibarr_syslog("CommandeFournisseur::fetch sql=".$sql,LOG_DEBUG); $result = $this->db->query($sql); if ($result) { @@ -151,12 +151,13 @@ class CommandeFournisseur extends Commande $ligne->total_tva = $objp->total_tva; $ligne->total_ttc = $objp->total_ttc; - $ligne->fk_product = $objp->fk_product; // Id du produit + $ligne->fk_product = $objp->product_id; // Id du produit $ligne->libelle = $objp->label; // Label produit $ligne->product_desc = $objp->product_desc; // Description produit + $ligne->ref = $objp->ref; // Reference $ligne->ref_fourn = $objp->ref_fourn; // Reference supplier - + $this->lignes[$i] = $ligne; //dolibarr_syslog("1 ".$ligne->desc); //dolibarr_syslog("2 ".$ligne->product_desc); @@ -169,14 +170,14 @@ class CommandeFournisseur extends Commande else { $this->error=$this->db->error()." sql=".$sql; - dolibarr_syslog("CommandeFournisseur::Fetch ".$this->error); + dolibarr_syslog("CommandeFournisseur::Fetch ".$this->error, LOG_ERR); return -1; } } else { $this->error=$this->db->error()." sql=".$sql; - dolibarr_syslog("CommandeFournisseur::Fetch ".$this->error); + dolibarr_syslog("CommandeFournisseur::Fetch ".$this->error, LOG_ERR); return -1; } } |