From 2998d68260dcd7de787bff0cf9fb29ea949cff75 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 4 Jul 2009 11:55:45 +0000 Subject: [PATCH] Fix: Show the supplier ref on supplier orders. --- htdocs/fourn/fournisseur.commande.class.php | 3 +- .../pdf/pdf_muscadet.modules.php | 12 +++---- htdocs/lib/pdf.lib.php | 34 +++++++++++-------- htdocs/product.class.php | 2 +- mysql/migration/2.6.0-2.7.0.sql | 3 ++ mysql/tables/llx_commande_fournisseurdet.sql | 12 +++---- mysql/tables/llx_facture_fourn_det.sql | 2 ++ 7 files changed, 40 insertions(+), 28 deletions(-) diff --git a/htdocs/fourn/fournisseur.commande.class.php b/htdocs/fourn/fournisseur.commande.class.php index 003dbffc4c1..db2841adf45 100644 --- a/htdocs/fourn/fournisseur.commande.class.php +++ b/htdocs/fourn/fournisseur.commande.class.php @@ -1432,7 +1432,7 @@ class CommandeFournisseur extends Commande $this->cond_reglement_code = 'RECEP'; $this->mode_reglement_code = 'CHQ'; $this->note_public='SPECIMEN'; - $nbp = rand(1, 9); + $nbp = rand(3, 5); $xnbp = 0; while ($xnbp < $nbp) { @@ -1441,6 +1441,7 @@ class CommandeFournisseur extends Commande $ligne->qty=1; $ligne->subprice=100; $ligne->tva_tx=19.6; + $ligne->ref_fourn='SUPPLIER_REF_'.$xnbp; $prodid = rand(1, $num_prods); $ligne->produit_id=$prodids[$prodid]; $this->lignes[$xnbp]=$ligne; diff --git a/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php index a5d77d3f1e8..6fbd9d50ef0 100644 --- a/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -242,7 +242,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $curY = $nexY; // Description de la ligne produit - $libelleproduitservice=pdf_getlinedesc($com->lignes[$i],$outputlangs); + $libelleproduitservice=pdf_getlinedesc($com->lignes[$i],$outputlangs,1,1); $pdf->SetFont('Arial','', 9); // Dans boucle pour gerer multi-page @@ -256,7 +256,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetXY ($this->posxtva, $curY); $pdf->MultiCell(10, 3, ($com->lignes[$i]->tva_tx < 0 ? '*':'').abs($com->lignes[$i]->tva_tx), 0, 'R'); - // Prix unitaire HT avant remise + // Unit price before discount $pdf->SetXY ($this->posxup, $curY); $pdf->MultiCell(18, 3, price($com->lignes[$i]->subprice), 0, 'R', 0); @@ -264,14 +264,14 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetXY ($this->posxqty, $curY); $pdf->MultiCell(10, 3, $com->lignes[$i]->qty, 0, 'R'); - // Remise sur ligne + // Discount on line $pdf->SetXY ($this->posxdiscount, $curY); if ($com->lignes[$i]->remise_percent) { $pdf->MultiCell(14, 3, $com->lignes[$i]->remise_percent."%", 0, 'R'); } - // Total HT ligne + // Total HT line $pdf->SetXY ($this->postotalht, $curY); $total = price($com->lignes[$i]->total_ht); $pdf->MultiCell(23, 3, $total, 0, 'R', 0); @@ -563,7 +563,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); } $pdf->SetXY ($this->postotalht-1, $tab_top+2); - $pdf->MultiCell(23,2, $outputlangs->transnoentities("TotalHT"),'','C'); + $pdf->MultiCell(23,2, $outputlangs->transnoentities("TotalHTShort"),'','C'); } @@ -673,7 +673,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetTextColor(0,0,0); $pdf->SetFont('Arial','',8); $pdf->SetXY(100,$posy-5); - $pdf->MultiCell(96, 4, $outputlangs->transnoentities("BillTo").":"); + $pdf->MultiCell(96, 4, $outputlangs->transnoentities("Supplier").":"); // $client = new Societe($this->db); $client->fetch($object->socid); diff --git a/htdocs/lib/pdf.lib.php b/htdocs/lib/pdf.lib.php index 2182981e9fe..643517bd25b 100644 --- a/htdocs/lib/pdf.lib.php +++ b/htdocs/lib/pdf.lib.php @@ -210,25 +210,25 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass /** - * \brief Return line description translated in outputlangs and encoded in UTF8 - * \param line Line to format - * \param outputlang Object lang for output - * \param showref Show reference + * \brief Return line description translated in outputlangs and encoded in UTF8 + * \param line Line to format + * \param outputlang Object lang for output + * \param showref Show reference + * \param issupplierline Is it a line for a supplier object ? */ -function pdf_getlinedesc($line,$outputlangs,$showref=1) +function pdf_getlinedesc($line,$outputlangs,$showref=1,$issupplierline=0) { global $db, $conf, $langs; - $label=$line->label; - $desc=$line->desc; + $idprod=$line->fk_product; if (empty($idprod)) $idprod=$line->produit_id; + $label=$line->label; if (empty($label)) $label=$line->libelle; + $desc=$line->desc; if (empty($desc)) $desc=$line->description; + $ref_supplier=$line->ref_supplier; if (empty($ref_supplier)) $ref_supplier=$line->ref_fourn; // TODO Not yeld saved for supplier invoices, only supplier orders $note=$line->note; - $idprod=$line->fk_product; - if (empty($label)) $label=$line->libelle; - if (empty($desc)) $desc=$line->description; - if (empty($idprod)) $idprod=$line->produit_id; + if ($issupplierline) $prodser = new ProductFournisseur($db); + else $prodser = new Product($db); - $prodser = new Product($db); if ($idprod) { $prodser->fetch($idprod); @@ -269,7 +269,7 @@ function pdf_getlinedesc($line,$outputlangs,$showref=1) } } - // Si ligne associee a un code produit + // If line linked to a product if ($idprod) { // On ajoute la ref @@ -289,7 +289,13 @@ function pdf_getlinedesc($line,$outputlangs,$showref=1) } } - if ($showref) $ref_prodserv = $prodser->ref." - "; + if ($showref) + { + if ($issupplierline) $ref_prodserv = $prodser->ref.' ('.$outputlangs->trans("SupplierRef").' '.$ref_supplier.')'; // Show local ref and supplier ref + else $ref_prodserv = $prodser->ref; // Show local ref only + + $ref_prodserv .= " - "; + } $libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice; } diff --git a/htdocs/product.class.php b/htdocs/product.class.php index 4445a6146f8..fcb873f95cc 100644 --- a/htdocs/product.class.php +++ b/htdocs/product.class.php @@ -1034,7 +1034,7 @@ class Product extends CommonObject if (!$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE p.rowid = pd.fk_propal"; $sql.= " AND p.fk_soc = s.rowid"; - $sql.= " AND s.entity = ".$conf->entity; + $sql.= " AND s.entity = ".$conf->entity; $sql.= " AND pd.fk_product = ".$this->id; if (!$user->rights->societe->client->voir && !$socid) $sql .= " AND p.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id; //$sql.= " AND pr.fk_statut != 0"; diff --git a/mysql/migration/2.6.0-2.7.0.sql b/mysql/migration/2.6.0-2.7.0.sql index 7cee7457ab1..1b02429afa0 100644 --- a/mysql/migration/2.6.0-2.7.0.sql +++ b/mysql/migration/2.6.0-2.7.0.sql @@ -229,3 +229,6 @@ insert into llx_c_departements ( code_departement, fk_region, cheflieu, tncc, nc insert into llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) values ('WI', 110, '', 0, 'WISCONSIN', 'Wisconsin', 1); insert into llx_c_departements ( code_departement, fk_region, cheflieu, tncc, ncc, nom, active) values ('WY', 110, '', 0, 'WYOMONG', 'Wyoming', 1); +alter table llx_facture_fourn_det add column ref varchar(50) after fk_product; +alter table llx_facture_fourn_det add column label varchar(255) after ref; + diff --git a/mysql/tables/llx_commande_fournisseurdet.sql b/mysql/tables/llx_commande_fournisseurdet.sql index ab12d187ff1..8c55afd53b5 100644 --- a/mysql/tables/llx_commande_fournisseurdet.sql +++ b/mysql/tables/llx_commande_fournisseurdet.sql @@ -24,17 +24,17 @@ create table llx_commande_fournisseurdet rowid integer AUTO_INCREMENT PRIMARY KEY, fk_commande integer NOT NULL, fk_product integer, - ref varchar(50), - label varchar(255), + ref varchar(50), -- supplier product ref + label varchar(255), -- product label description text, tva_tx double(6,3) DEFAULT 0, -- taux tva - qty real, -- quantité + qty real, -- quantity remise_percent real DEFAULT 0, -- pourcentage de remise remise real DEFAULT 0, -- montant de la remise subprice double(24,8) DEFAULT 0, -- prix unitaire - total_ht double(24,8) DEFAULT 0, -- Total HT de la ligne toute quantité et incluant remise ligne et globale - total_tva double(24,8) DEFAULT 0, -- Total TVA de la ligne toute quantité et incluant remise ligne et globale - total_ttc double(24,8) DEFAULT 0, -- Total TTC de la ligne toute quantité et incluant remise ligne et globale + total_ht double(24,8) DEFAULT 0, -- Total HT de la ligne toute quantit� et incluant remise ligne et globale + total_tva double(24,8) DEFAULT 0, -- Total TVA de la ligne toute quantit� et incluant remise ligne et globale + total_ttc double(24,8) DEFAULT 0, -- Total TTC de la ligne toute quantit� et incluant remise ligne et globale product_type integer DEFAULT 0, date_start datetime DEFAULT NULL, -- date debut si service date_end datetime DEFAULT NULL, -- date fin si service diff --git a/mysql/tables/llx_facture_fourn_det.sql b/mysql/tables/llx_facture_fourn_det.sql index 6dc58145384..86642719954 100644 --- a/mysql/tables/llx_facture_fourn_det.sql +++ b/mysql/tables/llx_facture_fourn_det.sql @@ -24,6 +24,8 @@ create table llx_facture_fourn_det rowid integer AUTO_INCREMENT PRIMARY KEY, fk_facture_fourn integer NOT NULL, fk_product integer NULL, + ref varchar(50), -- supplier product ref + label varchar(255), -- product label description text, pu_ht double(24,8), pu_ttc double(24,8),