From 9664f0af5fe9a154cbe2261b08bb48deebda7e78 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Thu, 9 Sep 2010 14:06:15 +0000 Subject: [PATCH] Qual: big uniformize code --- htdocs/compta/facture.php | 18 +-- htdocs/compta/facture/class/facture.class.php | 67 +++++------ htdocs/compta/paiement/fiche.php | 2 +- htdocs/compta/payment_sc/fiche.php | 2 +- htdocs/core/class/commonobject.class.php | 12 +- htdocs/expedition/class/expedition.class.php | 14 ++- htdocs/expedition/fiche.php | 6 +- .../class/fournisseur.commande.class.php | 46 ++++---- htdocs/fourn/commande/fiche.php | 16 +-- htdocs/fourn/commande/index.php | 2 +- .../modules/commande/modules_commande.php | 16 +-- .../modules/commande/pdf_einstein.modules.php | 80 ++++++-------- .../pdf/ModelePdfExpedition.class.php | 20 ++-- .../pdf/pdf_expedition_merou.modules.php | 32 +++--- .../pdf/pdf_expedition_rouget.modules.php | 10 +- .../modules/facture/modules_facture.php | 38 +++---- .../modules/facture/pdf_crabe.modules.php | 104 ++++++++---------- .../modules/facture/pdf_oursin.modules.php | 77 ++++++------- .../modules/livraison/modules_livraison.php | 26 ++--- .../livraison/pdf/pdf_sirocco.modules.php | 15 +-- .../livraison/pdf/pdf_typhon.modules.php | 15 +-- .../propale/pdf_propale_azur.modules.php | 9 +- .../propale/pdf_propale_jaune.modules.php | 59 +++++----- .../modules_commandefournisseur.php | 34 +++--- .../pdf/pdf_muscadet.modules.php | 61 +++++----- htdocs/lib/pdf.lib.php | 43 ++++---- htdocs/livraison/class/livraison.class.php | 31 +++--- htdocs/livraison/fiche.php | 8 +- scripts/invoices/rebuild_merge_pdf.php | 2 +- 29 files changed, 402 insertions(+), 463 deletions(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 34a547ec48f..bbcc385e953 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -158,7 +158,7 @@ if ($_REQUEST['action'] == 'confirm_deleteproductline' && $_REQUEST['confirm'] = $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - $result=facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs); + $result=facture_pdf_create($db, $fac, '', $fac->modelpdf, $outputlangs); if ($result > 0) { Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$facid); @@ -320,7 +320,7 @@ if ($_REQUEST['action'] == 'confirm_valid' && $_REQUEST['confirm'] == 'yes' && $ $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs); + facture_pdf_create($db, $fac, '', $fac->modelpdf, $outputlangs); } else { @@ -378,7 +378,7 @@ if ($_GET['action'] == 'modif' && $user->rights->facture->unvalidate) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs); + facture_pdf_create($db, $fac, '', $fac->modelpdf, $outputlangs); } } @@ -932,7 +932,7 @@ if (($_POST['action'] == 'addline' || $_POST['action'] == 'addline_predef') && $ $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs); + facture_pdf_create($db, $fac, '', $fac->modelpdf, $outputlangs); unset($_POST['qty']); unset($_POST['type']); @@ -1032,7 +1032,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs); + facture_pdf_create($db, $fac, '', $fac->modelpdf, $outputlangs); } } @@ -1064,7 +1064,7 @@ if ($_GET['action'] == 'up' && $user->rights->facture->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs); + facture_pdf_create($db, $fac, '', $fac->modelpdf, $outputlangs); Header ('Location: '.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'#'.$_GET['rowid']); exit; @@ -1087,7 +1087,7 @@ if ($_GET['action'] == 'down' && $user->rights->facture->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs); + facture_pdf_create($db, $fac, '', $fac->modelpdf, $outputlangs); Header ('Location: '.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'#'.$_GET['rowid']); exit; @@ -1320,7 +1320,7 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - $result=facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs); + $result=facture_pdf_create($db, $fac, '', $fac->modelpdf, $outputlangs); if ($result <= 0) { dol_print_error($db,$result); @@ -3211,7 +3211,7 @@ else $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - $result=facture_pdf_create($db, $fac->id, '', $_REQUEST['model'], $outputlangs); + $result=facture_pdf_create($db, $fac, '', $_REQUEST['model'], $outputlangs); if ($result <= 0) { dol_print_error($db,$result); diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 8b8a10f7d80..eaf1cc446b5 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -99,7 +99,8 @@ class Facture extends CommonObject var $mode_reglement_code; // Code in llx_c_paiement var $modelpdf; var $products=array(); - var $lignes=array(); + var $lignes=array(); // TODO deprecated + var $lines=array(); //! Pour board var $nbtodo; var $nbtodolate; @@ -688,41 +689,43 @@ class Facture extends CommonObject while ($i < $num) { $objp = $this->db->fetch_object($result); - $faclig = new FactureLigne($this->db); + $line = new FactureLigne($this->db); - $faclig->rowid = $objp->rowid; - $faclig->desc = $objp->description; // Description line - $faclig->product_type = $objp->product_type; // Type of line - $faclig->product_ref = $objp->product_ref; // Ref product - $faclig->libelle = $objp->label; // Label product - $faclig->product_desc = $objp->product_desc; // Description product - $faclig->fk_product_type = $objp->fk_product_type; // Type of product - $faclig->qty = $objp->qty; - $faclig->subprice = $objp->subprice; - $faclig->tva_tx = $objp->tva_tx; - $faclig->localtax1_tx = $objp->localtax1_tx; - $faclig->localtax2_tx = $objp->localtax2_tx; - $faclig->remise_percent = $objp->remise_percent; - $faclig->fk_remise_except = $objp->fk_remise_except; - $faclig->fk_product = $objp->fk_product; - $faclig->date_start = $this->db->jdate($objp->date_start); - $faclig->date_end = $this->db->jdate($objp->date_end); - $faclig->date_start = $this->db->jdate($objp->date_start); - $faclig->date_end = $this->db->jdate($objp->date_end); - $faclig->info_bits = $objp->info_bits; - $faclig->total_ht = $objp->total_ht; - $faclig->total_tva = $objp->total_tva; - $faclig->total_localtax1 = $objp->total_localtax1; - $faclig->total_localtax2 = $objp->total_localtax2; - $faclig->total_ttc = $objp->total_ttc; - $faclig->export_compta = $objp->fk_export_compta; - $faclig->code_ventilation = $objp->fk_code_ventilation; + $line->rowid = $objp->rowid; + $line->desc = $objp->description; // Description line + $line->product_type = $objp->product_type; // Type of line + $line->product_ref = $objp->product_ref; // Ref product + $line->libelle = $objp->label; // Label product + $line->product_desc = $objp->product_desc; // Description product + $line->fk_product_type = $objp->fk_product_type; // Type of product + $line->qty = $objp->qty; + $line->subprice = $objp->subprice; + $line->tva_tx = $objp->tva_tx; + $line->localtax1_tx = $objp->localtax1_tx; + $line->localtax2_tx = $objp->localtax2_tx; + $line->remise_percent = $objp->remise_percent; + $line->fk_remise_except = $objp->fk_remise_except; + $line->fk_product = $objp->fk_product; + $line->date_start = $this->db->jdate($objp->date_start); + $line->date_end = $this->db->jdate($objp->date_end); + $line->date_start = $this->db->jdate($objp->date_start); + $line->date_end = $this->db->jdate($objp->date_end); + $line->info_bits = $objp->info_bits; + $line->total_ht = $objp->total_ht; + $line->total_tva = $objp->total_tva; + $line->total_localtax1 = $objp->total_localtax1; + $line->total_localtax2 = $objp->total_localtax2; + $line->total_ttc = $objp->total_ttc; + $line->export_compta = $objp->fk_export_compta; + $line->code_ventilation = $objp->fk_code_ventilation; // Ne plus utiliser - $faclig->price = $objp->price; - $faclig->remise = $objp->remise; + $line->price = $objp->price; + $line->remise = $objp->remise; - $this->lignes[$i] = $faclig; + $this->lignes[$i] = $line; // TODO deprecated + $this->lines[$i] = $line; + $i++; } $this->db->free($result); diff --git a/htdocs/compta/paiement/fiche.php b/htdocs/compta/paiement/fiche.php index fc5847c1fff..d9e63c3c450 100644 --- a/htdocs/compta/paiement/fiche.php +++ b/htdocs/compta/paiement/fiche.php @@ -94,7 +94,7 @@ if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' && $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs); + facture_pdf_create($db, $fac, '', $fac->modelpdf, $outputlangs); } Header('Location: fiche.php?id='.$paiement->id); diff --git a/htdocs/compta/payment_sc/fiche.php b/htdocs/compta/payment_sc/fiche.php index 1735810d63b..30a5c3ec9a9 100644 --- a/htdocs/compta/payment_sc/fiche.php +++ b/htdocs/compta/payment_sc/fiche.php @@ -96,7 +96,7 @@ if ($_REQUEST['action'] == 'confirm_valide' && $_REQUEST['confirm'] == 'yes' && $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - facture_pdf_create($db, $fac->id, '', $fac->modelpdf, $outputlangs); + facture_pdf_create($db, $fac, '', $fac->modelpdf, $outputlangs); } Header('Location: fiche.php?id='.$paiement->id); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 11d4a1de853..c8d24244919 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -499,15 +499,15 @@ class CommonObject } /** - * \brief Read linked document + * Read linked origin object */ - function fetch_object() + function fetch_origin() { - $object = $this->origin; - // TODO uniformise code - if ($object == 'shipping') $object = 'expedition'; - if ($object == 'delivery') $object = 'livraison'; + if ($this->origin == 'shipping') $this->origin = 'expedition'; + if ($this->origin == 'delivery') $this->origin = 'livraison'; + + $object = $this->origin; $classname = ucfirst($object); $this->$object = new $classname($this->db); diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index 4fbf5aef231..dc27944b01b 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -50,7 +50,8 @@ class Expedition extends CommonObject var $modelpdf; var $origin; var $origin_id; - var $lignes; + var $lignes=array(); // TODO deprecated + var $lines=array(); var $expedition_method_id; var $statut; @@ -305,8 +306,6 @@ class Expedition extends CommonObject if ($this->statut == 0) $this->brouillon = 1; - $this->lignes = array(); - $file = $conf->expedition->dir_output . "/" .get_exdir($expedition->id,2) . "/" . $this->id.".pdf"; $this->pdf_filename = $file; @@ -768,13 +767,14 @@ class Expedition extends CommonObject $line = new ExpeditionLigne($this->db); $obj = $this->db->fetch_object($resql); - $line->origin_line_id = $obj->fk_origin_line; + $line->fk_origin_line = $obj->fk_origin_line; + $line->origin_line_id = $obj->fk_origin_line; // TODO deprecated $line->entrepot_id = $obj->fk_entrepot; $line->fk_product = $obj->fk_product; $line->fk_product_type = $obj->fk_product_type; $line->ref = $obj->ref; $line->label = $obj->label; - $line->libelle = $obj->label; // deprecated + $line->libelle = $obj->label; // TODO deprecated $line->description = $obj->description; $line->qty_asked = $obj->qty_asked; $line->qty_shipped = $obj->qty_shipped; @@ -783,7 +783,9 @@ class Expedition extends CommonObject $line->volume = $obj->volume; $line->volume_units = $obj->volume_units; - $this->lignes[$i] = $line; + $this->lignes[$i] = $line; // TODO deprecated + $this->lines[$i] = $line; + $i++; } $this->db->free($resql); diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index d844fa12924..57b194d35aa 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -164,7 +164,7 @@ if ($_REQUEST["action"] == 'confirm_valid' && $_REQUEST["confirm"] == 'yes' && $ $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - $result=expedition_pdf_create($db,$expedition->id,$expedition->modelpdf,$outputlangs); + $result=expedition_pdf_create($db,$expedition,$expedition->modelpdf,$outputlangs); if ($result <= 0) { dol_print_error($db,$result); @@ -284,7 +284,7 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - $result=expedition_pdf_create($db,$_REQUEST['id'],$_REQUEST['model'],$outputlangs); + $result=expedition_pdf_create($db,$shipment,$_REQUEST['model'],$outputlangs); if ($result <= 0) { dol_print_error($db,$result); @@ -668,7 +668,7 @@ else { $typeobject = $expedition->origin; $origin = $expedition->origin; - $expedition->fetch_object(); + $expedition->fetch_origin(); } if (dol_strlen($expedition->tracking_number)) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 431d6c79f81..b78918f5411 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -62,6 +62,8 @@ class CommandeFournisseur extends Commande { $this->db = $DB; $this->products = array(); + $this->lignes = array(); // TODO deprecated + $this->lines = array(); // List of language codes for status $this->statuts[0] = 'StatusOrderDraft'; @@ -127,9 +129,7 @@ class CommandeFournisseur extends Commande $this->db->free($resql); if ($this->statut == 0) $this->brouillon = 1; - - // Now load lines - $this->lignes = array(); + $sql = "SELECT l.rowid, l.ref as ref_fourn, l.fk_product, l.product_type, l.label, l.description,"; $sql.= " l.qty,"; @@ -153,30 +153,30 @@ class CommandeFournisseur extends Commande { $objp = $this->db->fetch_object($result); - $ligne = new CommandeFournisseurLigne($this->db); + $line = new CommandeFournisseurLigne($this->db); - $ligne->id = $objp->rowid; - $ligne->desc = $objp->description; // Description ligne - $ligne->description = $objp->description; // Description ligne - $ligne->qty = $objp->qty; - $ligne->tva_tx = $objp->tva_tx; - $ligne->subprice = $objp->subprice; - $ligne->remise_percent = $objp->remise_percent; - $ligne->total_ht = $objp->total_ht; - $ligne->total_tva = $objp->total_tva; - $ligne->total_ttc = $objp->total_ttc; - $ligne->product_type = $objp->product_type; + $line->id = $objp->rowid; + $line->desc = $objp->description; // Description ligne + $line->description = $objp->description; // Description ligne + $line->qty = $objp->qty; + $line->tva_tx = $objp->tva_tx; + $line->subprice = $objp->subprice; + $line->remise_percent = $objp->remise_percent; + $line->total_ht = $objp->total_ht; + $line->total_tva = $objp->total_tva; + $line->total_ttc = $objp->total_ttc; + $line->product_type = $objp->product_type; - $ligne->fk_product = $objp->fk_product; // Id du produit - $ligne->libelle = $objp->label; // Label produit - $ligne->product_desc = $objp->product_desc; // Description produit + $line->fk_product = $objp->fk_product; // Id du produit + $line->libelle = $objp->label; // Label produit + $line->product_desc = $objp->product_desc; // Description produit - $ligne->ref = $objp->ref; // Reference - $ligne->ref_fourn = $objp->ref_fourn; // Reference supplier + $line->ref = $objp->ref; // Reference + $line->ref_fourn = $objp->ref_fourn; // Reference supplier + + $this->lignes[$i] = $line; // TODO deprecated + $this->lines[$i] = $line; - $this->lignes[$i] = $ligne; - //dol_syslog("1 ".$ligne->desc); - //dol_syslog("2 ".$ligne->product_desc); $i++; } $this->db->free($result); diff --git a/htdocs/fourn/commande/fiche.php b/htdocs/fourn/commande/fiche.php index 867d6dda9d0..0b2ae6e2c2e 100644 --- a/htdocs/fourn/commande/fiche.php +++ b/htdocs/fourn/commande/fiche.php @@ -2,7 +2,7 @@ /* Copyright (C) 2004-2006 Rodolphe Quiedeville * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005 Eric Seigne - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2010 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -210,7 +210,7 @@ if ($_POST['action'] == 'addline' && $user->rights->fournisseur->commande->creer $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); + supplier_order_pdf_create($db, $commande, $commande->modelpdf, $outputlangs); unset($_POST['qty']); unset($_POST['type']); @@ -260,7 +260,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->fournisseur->commande->c $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); + supplier_order_pdf_create($db, $commande, $commande->modelpdf, $outputlangs); } else { @@ -283,7 +283,7 @@ if ($_REQUEST['action'] == 'confirm_deleteproductline' && $_REQUEST['confirm'] = $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - supplier_order_pdf_create($db, $id, $commande->modelpdf, $outputlangs); + supplier_order_pdf_create($db, $commande, $commande->modelpdf, $outputlangs); } } @@ -303,7 +303,7 @@ if ($_REQUEST['action'] == 'confirm_valid' && $_REQUEST['confirm'] == 'yes' && $ $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); + supplier_order_pdf_create($db, $commande, $commande->modelpdf, $outputlangs); } } @@ -436,7 +436,7 @@ if ($_GET['action'] == 'up' && $user->rights->fournisseur->commande->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); + supplier_order_pdf_create($db, $commande, $commande->modelpdf, $outputlangs); Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.$_GET['rowid']); exit; } @@ -453,7 +453,7 @@ if ($_GET['action'] == 'down' && $user->rights->fournisseur->commande->creer) $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - supplier_order_pdf_create($db, $commande->id, $commande->modelpdf, $outputlangs); + supplier_order_pdf_create($db, $commande, $commande->modelpdf, $outputlangs); Header ('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.$_GET['rowid']); exit; } @@ -480,7 +480,7 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($_REQUEST['lang_id']); } - $result=supplier_order_pdf_create($db, $commande->id,$commande->modelpdf,$outputlangs); + $result=supplier_order_pdf_create($db, $commande,$commande->modelpdf,$outputlangs); if ($result <= 0) { dol_print_error($db,$result); diff --git a/htdocs/fourn/commande/index.php b/htdocs/fourn/commande/index.php index 4f92c2890f5..1f5c4f2baaa 100644 --- a/htdocs/fourn/commande/index.php +++ b/htdocs/fourn/commande/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2008 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2010 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/htdocs/includes/modules/commande/modules_commande.php b/htdocs/includes/modules/commande/modules_commande.php index 2f0f3aac02b..3782766710f 100644 --- a/htdocs/includes/modules/commande/modules_commande.php +++ b/htdocs/includes/modules/commande/modules_commande.php @@ -135,13 +135,13 @@ class ModeleNumRefCommandes /** - * \brief Cree un bon de commande sur disque en fonction d'un modele - * \param db objet base de donnee - * \param id id de la propale a creer - * \param modele force le modele a utiliser ('' to not force) - * \param outputlangs objet lang a utiliser pour traduction + * Cree un bon de commande sur disque en fonction d'un modele + * @param db objet base de donnee + * @param object object order + * @param modele force le modele a utiliser ('' to not force) + * @param outputlangs objet lang a utiliser pour traduction */ -function commande_pdf_create($db, $id, $modele, $outputlangs) +function commande_pdf_create($db, $object, $modele, $outputlangs) { global $conf,$langs; $langs->load("orders"); @@ -183,11 +183,11 @@ function commande_pdf_create($db, $id, $modele, $outputlangs) // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($id, $outputlangs) > 0) + if ($obj->write_file($object, $outputlangs) > 0) { $outputlangs->charset_output=$sav_charset_output; // on supprime l'image correspondant au preview - commande_delete_preview($db, $id); + commande_delete_preview($db, $object->id); return 1; } else diff --git a/htdocs/includes/modules/commande/pdf_einstein.modules.php b/htdocs/includes/modules/commande/pdf_einstein.modules.php index 9ab074d09b9..5e07a950939 100644 --- a/htdocs/includes/modules/commande/pdf_einstein.modules.php +++ b/htdocs/includes/modules/commande/pdf_einstein.modules.php @@ -102,11 +102,11 @@ class pdf_einstein extends ModelePDFCommandes /** * \brief Fonction generant la commande sur le disque - * \param com Objet commande a generer + * \param object Objet commande a generer * \param outputlangs Lang object for output language * \return int 1=ok, 0=ko */ - function write_file($com,$outputlangs) + function write_file($object,$outputlangs) { global $user,$langs,$conf; @@ -123,29 +123,21 @@ class pdf_einstein extends ModelePDFCommandes if ($conf->commande->dir_output) { - // Definition de l'objet $com (pour compatibilite ascendante) - if (! is_object($com)) - { - $id = $com; - $com = new Commande($this->db,"",$id); - $ret=$com->fetch($id); - } - - $com->fetch_thirdparty(); + $object->fetch_thirdparty(); $deja_regle = ""; // Definition de $dir et $file - if ($com->specimen) + if ($object->specimen) { $dir = $conf->commande->dir_output; $file = $dir . "/SPECIMEN.pdf"; } else { - $comref = dol_sanitizeFileName($com->ref); - $dir = $conf->commande->dir_output . "/" . $comref; - $file = $dir . "/" . $comref . ".pdf"; + $objectref = dol_sanitizeFileName($object->ref); + $dir = $conf->commande->dir_output . "/" . $objectref; + $file = $dir . "/" . $objectref . ".pdf"; } if (! file_exists($dir)) @@ -159,7 +151,7 @@ class pdf_einstein extends ModelePDFCommandes if (file_exists($dir)) { - $nblignes = sizeof($com->lignes); + $nblignes = sizeof($object->lines); // Protection et encryption du pdf if ($conf->global->PDF_SECURITY_ENCRYPTION) @@ -186,11 +178,11 @@ class pdf_einstein extends ModelePDFCommandes $pagenb=0; $pdf->SetDrawColor(128,128,128); - $pdf->SetTitle($outputlangs->convToOutputCharset($com->ref)); + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("Order")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); - $pdf->SetKeyWords($outputlangs->convToOutputCharset($com->ref)." ".$outputlangs->transnoentities("Order")); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right @@ -199,7 +191,7 @@ class pdf_einstein extends ModelePDFCommandes // Positionne $this->atleastonediscount si on a au moins une remise for ($i = 0 ; $i < $nblignes ; $i++) { - if ($com->lignes[$i]->remise_percent) + if ($object->lines[$i]->remise_percent) { $this->atleastonediscount++; } @@ -208,7 +200,7 @@ class pdf_einstein extends ModelePDFCommandes // New page $pdf->AddPage(); $pagenb++; - $this->_pagehead($pdf, $com, 1, $outputlangs); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', 9); $pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -220,13 +212,13 @@ class pdf_einstein extends ModelePDFCommandes $tab_height_newpage = 150; // Affiche notes - if (! empty($com->note_public)) + if (! empty($object->note_public)) { $tab_top = 88; $pdf->SetFont('','', 9); // Dans boucle pour gerer multi-page $pdf->SetXY ($this->posxdesc-1, $tab_top); - $pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($com->note_public), 0, 'J'); + $pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($object->note_public), 0, 'J'); $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; @@ -252,7 +244,7 @@ class pdf_einstein extends ModelePDFCommandes $curY = $nexY; // Description of product line - $libelleproduitservice=pdf_getlinedesc($com->lignes[$i],$outputlangs); + $libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs); $pdf->SetFont('','', 9); // Dans boucle pour gerer multi-page $pdf->writeHTMLCell($this->posxtva-$this->posxdesc-1, 3, $this->posxdesc-1, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1); @@ -264,40 +256,40 @@ class pdf_einstein extends ModelePDFCommandes if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { $pdf->SetXY ($this->posxtva, $curY); - $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, vatrate($com->lignes[$i]->tva_tx,1,$com->lignes[$i]->info_bits), 0, 'R'); + $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, vatrate($object->lines[$i]->tva_tx,1,$object->lines[$i]->info_bits), 0, 'R'); } // Prix unitaire HT avant remise $pdf->SetXY ($this->posxup, $curY); - $pdf->MultiCell($this->posxqty-$this->posxup-1, 3, price($com->lignes[$i]->subprice), 0, 'R', 0); + $pdf->MultiCell($this->posxqty-$this->posxup-1, 3, price($object->lines[$i]->subprice), 0, 'R', 0); // Quantity $pdf->SetXY ($this->posxqty, $curY); - $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $com->lignes[$i]->qty, 0, 'R'); + $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $object->lines[$i]->qty, 0, 'R'); // Remise sur ligne $pdf->SetXY ($this->posxdiscount, $curY); - if ($com->lignes[$i]->remise_percent) + if ($object->lines[$i]->remise_percent) { - $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, dol_print_reduction($com->lignes[$i]->remise_percent,$outputlangs), 0, 'R'); + $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, dol_print_reduction($object->lines[$i]->remise_percent,$outputlangs), 0, 'R'); } // Total HT ligne $pdf->SetXY ($this->postotalht, $curY); - $total = price($com->lignes[$i]->total_ht); + $total = price($object->lines[$i]->total_ht); $pdf->MultiCell(26, 3, $total, 0, 'R', 0); // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva - $tvaligne=$com->lignes[$i]->total_tva; + $tvaligne=$object->lines[$i]->total_tva; - $localtax1ligne=$com->lignes[$i]->total_localtax1; - $localtax2ligne=$com->lignes[$i]->total_localtax2; + $localtax1ligne=$object->lines[$i]->total_localtax1; + $localtax2ligne=$object->lines[$i]->total_localtax2; - $vatrate=(string) $com->lignes[$i]->tva_tx; - $localtax1rate=(string) $com->lignes[$i]->localtax1_tx; - $localtax2rate=(string) $com->lignes[$i]->localtax2_tx; + $vatrate=(string) $object->lines[$i]->tva_tx; + $localtax1rate=(string) $object->lines[$i]->localtax1_tx; + $localtax2rate=(string) $object->lines[$i]->localtax2_tx; - if (($com->lignes[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; $this->tva[$vatrate] += $tvaligne; $this->localtax1[$localtax1rate]+=$localtax1ligne; $this->localtax2[$localtax2rate]+=$localtax2ligne; @@ -308,11 +300,11 @@ class pdf_einstein extends ModelePDFCommandes if ($i < ($nblignes - 1)) // If it's not last line { //on recupere la description du produit suivant - $follow_descproduitservice = $outputlangs->convToOutputCharset($com->lignes[$i+1]->desc); + $follow_descproduitservice = $outputlangs->convToOutputCharset($object->lines[$i+1]->desc); //on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) $nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4); // Et si on affiche dates de validite, on ajoute encore une ligne - if ($com->lignes[$i]->date_start && $com->lignes[$i]->date_end) + if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) { $nblineFollowDesc += 4; } @@ -344,12 +336,12 @@ class pdf_einstein extends ModelePDFCommandes $this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); } - $this->_pagefoot($pdf,$com,$outputlangs); + $this->_pagefoot($pdf,$object,$outputlangs); // New page $pdf->AddPage(); $pagenb++; - $this->_pagehead($pdf, $com, 0, $outputlangs); + $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->SetFont('','', 9); $pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -371,19 +363,19 @@ class pdf_einstein extends ModelePDFCommandes } // Affiche zone infos - $posy=$this->_tableau_info($pdf, $com, $bottomlasttab, $outputlangs); + $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); // Affiche zone totaux - $posy=$this->_tableau_tot($pdf, $com, $deja_regle, $bottomlasttab, $outputlangs); + $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); // Affiche zone versements if ($deja_regle) { - $posy=$this->_tableau_versements($pdf, $com, $posy, $outputlangs); + $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); } // Pied de page - $this->_pagefoot($pdf,$com,$outputlangs); + $this->_pagefoot($pdf,$object,$outputlangs); $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php b/htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php index 5754af5530b..c9ed58909d2 100644 --- a/htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php +++ b/htdocs/includes/modules/expedition/pdf/ModelePdfExpedition.class.php @@ -59,13 +59,13 @@ class ModelePdfExpedition /** - \brief Cree un bon d'expedition sur disque - \param db objet base de donnee - \param id id de la expedition a creer - \param modele force le modele a utiliser ('' to not force) - \param outputlangs objet lang a utiliser pour traduction -*/ -function expedition_pdf_create($db, $id, $modele, $outputlangs) + * Cree un bon d'expedition sur disque + * @param db objet base de donnee + * @param object object expedition + * @param modele force le modele a utiliser ('' to not force) + * @param outputlangs objet lang a utiliser pour traduction + */ +function expedition_pdf_create($db, $object, $modele, $outputlangs) { global $conf,$langs; $langs->load("sendings"); @@ -104,14 +104,12 @@ function expedition_pdf_create($db, $id, $modele, $outputlangs) $obj = new $classname($db); - $expedition = new Expedition($db); - $result=$expedition->fetch($id); - $result=$expedition->fetch_object($expedition->origin); + $result=$object->fetch_origin(); // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($expedition, $outputlangs) > 0) + if ($obj->write_file($object, $outputlangs) > 0) { $outputlangs->charset_output=$sav_charset_output; // on supprime l'image correspondant au preview diff --git a/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php b/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php index d34fcf2c2b0..ad5a452bcdd 100644 --- a/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php +++ b/htdocs/includes/modules/expedition/pdf/pdf_expedition_merou.modules.php @@ -96,6 +96,8 @@ Class pdf_expedition_merou extends ModelePdfExpedition if ($conf->expedition->dir_output."/sending") { $object->fetch_thirdparty(); + + $origin = $object->origin; //Creation de l expediteur $this->expediteur = $mysoc; @@ -104,11 +106,11 @@ Class pdf_expedition_merou extends ModelePdfExpedition $this->destinataire = new Contact($this->db); // $pdf->expe->commande->fetch($pdf->commande->id); //print_r($pdf->expe); - $idcontact = $object->commande->getIdContact('external','SHIPPING'); + $idcontact = $object->$origin->getIdContact('external','SHIPPING'); $this->destinataire->fetch($idcontact[0]); //Creation du livreur - $idcontact = $object->commande->getIdContact('internal','LIVREUR'); + $idcontact = $object->$origin->getIdContact('internal','LIVREUR'); $this->livreur = new User($this->db); if ($idcontact[0]) $this->livreur->fetch($idcontact[0]); @@ -198,13 +200,12 @@ Class pdf_expedition_merou extends ModelePdfExpedition $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); //Recuperation des produits de la commande. - $Produits = $object->commande->lignes; - $nblignes = sizeof($Produits); + $nblignes = sizeof($object->$origin->lines); for ($i = 0 ; $i < $nblignes ; $i++) { // Description de la ligne produit - $libelleproduitservice=pdf_getlinedesc($object->commande->lignes[$i],$outputlangs); + $libelleproduitservice=pdf_getlinedesc($object->$origin,$i,$outputlangs); //if ($i==1) { print $object->commande->lignes[$i]->libelle.' - '.$libelleproduitservice; exit; } //Creation des cases a cocher @@ -213,7 +214,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition //Insertion de la reference du produit $pdf->SetXY (30, $curY+1 ); $pdf->SetFont('','B', 7); - $pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($object->commande->lignes[$i]->ref), 0, 'L', 0); + $pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($object->$origin->lines[$i]->ref), 0, 'L', 0); //Insertion du libelle $pdf->SetFont('','', 7); $pdf->SetXY (50, $curY+1 ); @@ -221,11 +222,11 @@ Class pdf_expedition_merou extends ModelePdfExpedition //Insertion de la quantite commandee $pdf->SetFont('','', 7); $pdf->SetXY (140, $curY+1 ); - $pdf->MultiCell(30, 3, $object->lignes[$i]->qty_asked, 0, 'C', 0); + $pdf->MultiCell(30, 3, $object->lines[$i]->qty_asked, 0, 'C', 0); //Insertion de la quantite a envoyer $pdf->SetFont('','', 7); $pdf->SetXY (170, $curY+1 ); - $pdf->MultiCell(30, 3, $object->lignes[$i]->qty_shipped, 0, 'C', 0); + $pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'C', 0); //Generation de la page 2 $curY += (dol_nboflines_bis($libelleproduitservice,0,$outputlangs->charset_output)*3+1); @@ -334,6 +335,8 @@ Class pdf_expedition_merou extends ModelePdfExpedition function _pagehead(&$pdf, $object, $outputlangs) { global $conf, $langs; + + $origin = $object->origin; pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); @@ -398,19 +401,20 @@ Class pdf_expedition_merou extends ModelePdfExpedition $outputlangs->load('orders'); foreach($object->linked_object as $key => $val) { - if ($key == 'commande') + if ($key == $origin) { for ($i = 0; $idb); - $result=$newobject->fetch($val[$i]); + $classname = ucfirst($origin); + $linkedobject = new $classname($this->db); + $result=$linkedobject->fetch($val[$i]); if ($result >= 0) { $Yoff = $Yoff+4; $pdf->SetXY($Xoff,$Yoff); $pdf->SetFont('','',8); - $text=$newobject->ref; - if ($newobject->ref_client) $text.=' ('.$newobject->ref_client.')'; + $text=$linkedobject->ref; + if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; $pdf->MultiCell(0, 3, $outputlangs->transnoentities("RefOrder")." : ".$outputlangs->transnoentities($text), '', 'R'); } } @@ -479,7 +483,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition // If SHIPPING contact defined on order, we use it $usecontact=false; - $arrayidcontact=$object->commande->getIdContact('external','SHIPPING'); + $arrayidcontact=$object->$origin->getIdContact('external','SHIPPING'); if (sizeof($arrayidcontact) > 0) { $usecontact=true; diff --git a/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php b/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php index 1d26f9feee3..009ddfe58e8 100644 --- a/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php +++ b/htdocs/includes/modules/expedition/pdf/pdf_expedition_rouget.modules.php @@ -327,17 +327,17 @@ Class pdf_expedition_rouget extends ModelePdfExpedition $nexY = $this->tableau_top + 14; - for ($i = 0 ; $i < sizeof($object->lignes) ; $i++) + for ($i = 0 ; $i < sizeof($object->lines) ; $i++) { $curY = $nexY; if ($this->barcode->enabled) { - $pdf->i25($this->marge_gauche+3, ($curY - 2), "000000".$object->lignes[$i]->fk_product, 1, 8); + $pdf->i25($this->marge_gauche+3, ($curY - 2), "000000".$object->lines[$i]->fk_product, 1, 8); } // Description de la ligne produit - $libelleproduitservice=pdf_getlinedesc($object->lignes[$i],$outputlangs); + $libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs); $pdf->SetFont('','', 9); // Dans boucle pour gerer multi-page $pdf->writeHTMLCell(150, 3, $this->posxdesc, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1); @@ -346,10 +346,10 @@ Class pdf_expedition_rouget extends ModelePdfExpedition $nexY = $pdf->GetY(); $pdf->SetXY (160, $curY); - $pdf->MultiCell(30, 3, $object->lignes[$i]->qty_asked); + $pdf->MultiCell(30, 3, $object->lines[$i]->qty_asked); $pdf->SetXY (186, $curY); - $pdf->MultiCell(30, 3, $object->lignes[$i]->qty_shipped); + $pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped); $nexY+=2; // Passe espace entre les lignes } diff --git a/htdocs/includes/modules/facture/modules_facture.php b/htdocs/includes/modules/facture/modules_facture.php index 7eaa39addf9..bb2676279cd 100644 --- a/htdocs/includes/modules/facture/modules_facture.php +++ b/htdocs/includes/modules/facture/modules_facture.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2005 Rodolphe Quiedeville * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2010 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -134,15 +134,15 @@ class ModeleNumRefFactures /** - * \brief Cree un facture sur disque en fonction du modele de FACTURE_ADDON_PDF - * \param db objet base de donnee - * \param id Object invoice (or id of invoice) - * \param message message - * \param modele force le modele a utiliser ('' to not force) - * \param outputlangs objet lang a utiliser pour traduction - * \return int <0 if KO, >0 if OK + * Cree un facture sur disque en fonction du modele de FACTURE_ADDON_PDF + * @param db objet base de donnee + * @param object Object invoice + * @param message message + * @param modele force le modele a utiliser ('' to not force) + * @param outputlangs objet lang a utiliser pour traduction + * @return int <0 if KO, >0 if OK */ -function facture_pdf_create($db, $id, $message, $modele, $outputlangs) +function facture_pdf_create($db, $object, $message, $modele, $outputlangs) { global $conf,$langs; $langs->load("bills"); @@ -177,22 +177,12 @@ function facture_pdf_create($db, $id, $message, $modele, $outputlangs) // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($id, $outputlangs) > 0) + if ($obj->write_file($object, $outputlangs) > 0) { - if (! is_object($id)) // Old method - { - // Success in building document. We build meta file. - facture_meta_create($db, $id); - // et on supprime l'image correspondant au preview - facture_delete_preview($db, $id); - } - else - { - // Success in building document. We build meta file. - facture_meta_create($db, $id->id); - // et on supprime l'image correspondant au preview - facture_delete_preview($db, $id->id); - } + // Success in building document. We build meta file. + facture_meta_create($db, $object->id); + // et on supprime l'image correspondant au preview + facture_delete_preview($db, $object->id); $outputlangs->charset_output=$sav_charset_output; return 1; diff --git a/htdocs/includes/modules/facture/pdf_crabe.modules.php b/htdocs/includes/modules/facture/pdf_crabe.modules.php index 589f1ea02de..ea8e71c09a5 100644 --- a/htdocs/includes/modules/facture/pdf_crabe.modules.php +++ b/htdocs/includes/modules/facture/pdf_crabe.modules.php @@ -104,11 +104,11 @@ class pdf_crabe extends ModelePDFFactures /** * \brief Fonction generant la facture sur le disque - * \param fac Objet invoice to build (or id if old method) + * \param object Object invoice to build (or id if old method) * \param outputlangs Lang object for output language * \return int 1=ok, 0=ko */ - function write_file($fac,$outputlangs) + function write_file($object,$outputlangs) { global $user,$langs,$conf; @@ -124,31 +124,23 @@ class pdf_crabe extends ModelePDFFactures if ($conf->facture->dir_output) { - // Definition de l'objet $fac (pour compatibilite ascendante) - if (! is_object($fac)) - { - $id = $fac; - $fac = new Facture($this->db); - $ret=$fac->fetch($id); - } + $object->fetch_thirdparty(); - $fac->fetch_thirdparty(); - - $deja_regle = $fac->getSommePaiement(); - $amount_credit_notes_included = $fac->getSumCreditNotesUsed(); - $amount_deposits_included = $fac->getSumDepositsUsed(); + $deja_regle = $object->getSommePaiement(); + $amount_credit_notes_included = $object->getSumCreditNotesUsed(); + $amount_deposits_included = $object->getSumDepositsUsed(); // Definition of $dir and $file - if ($fac->specimen) + if ($object->specimen) { $dir = $conf->facture->dir_output; $file = $dir . "/SPECIMEN.pdf"; } else { - $facref = dol_sanitizeFileName($fac->ref); - $dir = $conf->facture->dir_output . "/" . $facref; - $file = $dir . "/" . $facref . ".pdf"; + $objectref = dol_sanitizeFileName($object->ref); + $dir = $conf->facture->dir_output . "/" . $objectref; + $file = $dir . "/" . $objectref . ".pdf"; } if (! file_exists($dir)) { @@ -161,7 +153,7 @@ class pdf_crabe extends ModelePDFFactures if (file_exists($dir)) { - $nblignes = sizeof($fac->lignes); + $nblignes = sizeof($object->lines); // Protection et encryption du pdf if ($conf->global->PDF_SECURITY_ENCRYPTION) @@ -189,11 +181,11 @@ class pdf_crabe extends ModelePDFFactures $pagenb=0; $pdf->SetDrawColor(128,128,128); - $pdf->SetTitle($outputlangs->convToOutputCharset($fac->ref)); + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("Invoice")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); - $pdf->SetKeyWords($outputlangs->convToOutputCharset($fac->ref)." ".$outputlangs->transnoentities("Invoice")); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Invoice")); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right @@ -202,7 +194,7 @@ class pdf_crabe extends ModelePDFFactures // Positionne $this->atleastonediscount si on a au moins une remise for ($i = 0 ; $i < $nblignes ; $i++) { - if ($fac->lignes[$i]->remise_percent) + if ($object->lines[$i]->remise_percent) { $this->atleastonediscount++; } @@ -211,7 +203,7 @@ class pdf_crabe extends ModelePDFFactures // New page $pdf->AddPage(); $pagenb++; - $this->_pagehead($pdf, $fac, 1, $outputlangs); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', 9); $pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -222,13 +214,13 @@ class pdf_crabe extends ModelePDFFactures $tab_height_newpage = 150; // Affiche notes - if (! empty($fac->note_public)) + if (! empty($object->note_public)) { $tab_top = 88; $pdf->SetFont('','', 9); $pdf->SetXY ($this->posxdesc-1, $tab_top); - $pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($fac->note_public), 0, 'J'); + $pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($object->note_public), 0, 'J'); $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; @@ -254,7 +246,7 @@ class pdf_crabe extends ModelePDFFactures $curY = $nexY; // Description of product line - $libelleproduitservice=pdf_getlinedesc($fac->lignes[$i],$outputlangs); + $libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs); $pdf->SetFont('','', 9); // Dans boucle pour gerer multi-page $pdf->writeHTMLCell($this->posxtva-$this->posxdesc-1, 3, $this->posxdesc-1, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1); @@ -266,43 +258,43 @@ class pdf_crabe extends ModelePDFFactures if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) { $pdf->SetXY ($this->posxtva, $curY); - $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, vatrate($fac->lignes[$i]->tva_tx,1,$fac->lignes[$i]->info_bits), 0, 'R'); + $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, vatrate($object->lines[$i]->tva_tx,1,$object->lines[$i]->info_bits), 0, 'R'); } // Prix unitaire HT avant remise $pdf->SetXY ($this->posxup, $curY); - $pdf->MultiCell($this->posxqty-$this->posxup-1, 3, price($fac->lignes[$i]->subprice), 0, 'R', 0); + $pdf->MultiCell($this->posxqty-$this->posxup-1, 3, price($object->lines[$i]->subprice), 0, 'R', 0); // Quantity $pdf->SetXY ($this->posxqty, $curY); - $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $fac->lignes[$i]->qty, 0, 'R'); // Enough for 6 chars + $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $object->lines[$i]->qty, 0, 'R'); // Enough for 6 chars // Remise sur ligne $pdf->SetXY ($this->posxdiscount, $curY); - if ($fac->lignes[$i]->remise_percent) + if ($object->lines[$i]->remise_percent) { - $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, dol_print_reduction($fac->lignes[$i]->remise_percent,$outputlangs), 0, 'R'); + $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, dol_print_reduction($object->lines[$i]->remise_percent,$outputlangs), 0, 'R'); } // Total HT ligne $pdf->SetXY ($this->postotalht, $curY); - $total = price($fac->lignes[$i]->total_ht); + $total = price($object->lines[$i]->total_ht); $pdf->MultiCell(26, 3, $total, 0, 'R', 0); // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva - $tvaligne=$fac->lignes[$i]->total_tva; - $localtax1ligne=$fac->lignes[$i]->total_localtax1; - $localtax2ligne=$fac->lignes[$i]->total_localtax2; + $tvaligne=$object->lines[$i]->total_tva; + $localtax1ligne=$object->lines[$i]->total_localtax1; + $localtax2ligne=$object->lines[$i]->total_localtax2; - if ($fac->remise_percent) $tvaligne-=($tvaligne*$fac->remise_percent)/100; - if ($fac->remise_percent) $localtax1ligne-=($localtax1ligne*$fac->remise_percent)/100; - if ($fac->remise_percent) $localtax2ligne-=($localtax2ligne*$fac->remise_percent)/100; + if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; + if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; + if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; - $vatrate=(string) $fac->lignes[$i]->tva_tx; - $localtax1rate=(string) $fac->lignes[$i]->localtax1_tx; - $localtax2rate=(string) $fac->lignes[$i]->localtax2_tx; + $vatrate=(string) $object->lines[$i]->tva_tx; + $localtax1rate=(string) $object->lines[$i]->localtax1_tx; + $localtax2rate=(string) $object->lines[$i]->localtax2_tx; - if (($fac->lignes[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; $this->tva[$vatrate] += $tvaligne; $this->localtax1[$localtax1rate]+=$localtax1ligne; $this->localtax2[$localtax2rate]+=$localtax2ligne; @@ -313,11 +305,11 @@ class pdf_crabe extends ModelePDFFactures if ($i < ($nblignes - 1)) // If it's not last line { //on recupere la description du produit suivant - $follow_descproduitservice = $fac->lignes[$i+1]->desc; + $follow_descproduitservice = $object->lines[$i+1]->desc; //on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) $nblineFollowDesc = dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4; // Et si on affiche dates de validite, on ajoute encore une ligne - if ($fac->lignes[$i]->date_start && $fac->lignes[$i]->date_end) + if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) { $nblineFollowDesc += 4; } @@ -349,12 +341,12 @@ class pdf_crabe extends ModelePDFFactures $this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); } - $this->_pagefoot($pdf,$fac,$outputlangs); + $this->_pagefoot($pdf,$object,$outputlangs); // New page $pdf->AddPage(); $pagenb++; - $this->_pagehead($pdf, $fac, 0, $outputlangs); + $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->SetFont('','', 9); $pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -377,19 +369,19 @@ class pdf_crabe extends ModelePDFFactures } // Affiche zone infos - $posy=$this->_tableau_info($pdf, $fac, $bottomlasttab, $outputlangs); + $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); // Affiche zone totaux - $posy=$this->_tableau_tot($pdf, $fac, $deja_regle, $bottomlasttab, $outputlangs); + $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); // Affiche zone versements if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) { - $posy=$this->_tableau_versements($pdf, $fac, $posy, $outputlangs); + $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); } // Pied de page - $this->_pagefoot($pdf,$fac,$outputlangs); + $this->_pagefoot($pdf,$object,$outputlangs); $pdf->AliasNbPages(); $pdf->Close(); @@ -424,7 +416,7 @@ class pdf_crabe extends ModelePDFFactures * \param outputlangs Object langs for output * \return int <0 if KO, >0 if OK */ - function _tableau_versements(&$pdf, $fac, $posy, $outputlangs) + function _tableau_versements(&$pdf, $object, $posy, $outputlangs) { $tab3_posx = 120; $tab3_top = $posy + 8; @@ -456,7 +448,7 @@ class pdf_crabe extends ModelePDFFactures $sql.= " re.description, re.fk_facture_source, re.fk_facture_source,"; $sql.= " f.type, f.datef"; $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re, ".MAIN_DB_PREFIX ."facture as f"; - $sql.= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$fac->id; + $sql.= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$object->id; $resql=$this->db->query($sql); if ($resql) { @@ -498,7 +490,7 @@ class pdf_crabe extends ModelePDFFactures // Loop on each payment $sql = "SELECT p.datep as date, pf.amount as amount, p.fk_paiement as type, p.num_paiement as num "; $sql.= "FROM ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."paiement_facture as pf "; - $sql.= "WHERE pf.fk_paiement = p.rowid and pf.fk_facture = ".$fac->id." "; + $sql.= "WHERE pf.fk_paiement = p.rowid and pf.fk_facture = ".$object->id." "; $sql.= "ORDER BY p.datep"; $resql=$this->db->query($sql); if ($resql) @@ -1039,11 +1031,11 @@ class pdf_crabe extends ModelePDFFactures $posy+=2; $pdf->SetFont('','',9); - $facidnext=$object->getIdReplacingInvoice('validated'); - if ($object->type == 0 && $facidnext) + $objectidnext=$object->getIdReplacingInvoice('validated'); + if ($object->type == 0 && $objectidnext) { $objectreplacing=new Facture($this->db); - $objectreplacing->fetch($facidnext); + $objectreplacing->fetch($objectidnext); $posy+=4; $pdf->SetXY(100,$posy); diff --git a/htdocs/includes/modules/facture/pdf_oursin.modules.php b/htdocs/includes/modules/facture/pdf_oursin.modules.php index c33fed52585..ff35567ef52 100644 --- a/htdocs/includes/modules/facture/pdf_oursin.modules.php +++ b/htdocs/includes/modules/facture/pdf_oursin.modules.php @@ -105,7 +105,7 @@ class pdf_oursin extends ModelePDFFactures * \param outputlangs Lang object for output language * \return int 1=ok, 0=ko */ - function write_file($fac,$outputlangs) + function write_file($object,$outputlangs) { global $user,$langs,$conf; @@ -121,30 +121,23 @@ class pdf_oursin extends ModelePDFFactures if ($conf->facture->dir_output) { - // Definition de l'objet $fac (pour compatibilite ascendante) - if (! is_object($fac)) - { - $id = $fac; - $fac = new Facture($this->db); - $ret=$fac->fetch($id); - } - $fac->fetch_thirdparty(); + $object->fetch_thirdparty(); - $deja_regle = $fac->getSommePaiement(); - $amount_credit_notes_included = $fac->getSumCreditNotesUsed(); - $amount_deposits_included = $fac->getSumDepositsUsed(); + $deja_regle = $object->getSommePaiement(); + $amount_credit_notes_included = $object->getSumCreditNotesUsed(); + $amount_deposits_included = $object->getSumDepositsUsed(); // Definition of $dir and $file - if ($fac->specimen) + if ($object->specimen) { $dir = $conf->facture->dir_output; $file = $dir . "/SPECIMEN.pdf"; } else { - $facref = dol_sanitizeFileName($fac->ref); - $dir = $conf->facture->dir_output . "/" . $facref; - $file = $dir . "/" . $facref . ".pdf"; + $objectref = dol_sanitizeFileName($object->ref); + $dir = $conf->facture->dir_output . "/" . $objectref; + $file = $dir . "/" . $objectref . ".pdf"; } if (! file_exists($dir)) @@ -184,11 +177,11 @@ class pdf_oursin extends ModelePDFFactures $pagenb=0; $pdf->SetDrawColor(128,128,128); - $pdf->SetTitle($outputlangs->convToOutputCharset($fac->ref)); + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("Invoice")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); - $pdf->SetKeyWords($outputlangs->convToOutputCharset($fac->ref)." ".$outputlangs->transnoentities("Invoice")); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Invoice")); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); $pdf->SetMargins(10, 10, 10); @@ -197,7 +190,7 @@ class pdf_oursin extends ModelePDFFactures // New page $pdf->AddPage(); $pagenb++; - $this->_pagehead($pdf, $fac, 1, $outputlangs); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', 9); $pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -212,7 +205,7 @@ class pdf_oursin extends ModelePDFFactures $iniY = $pdf->GetY(); $curY = $pdf->GetY(); $nexY = $pdf->GetY(); - $nblignes = sizeof($fac->lignes); + $nblignes = sizeof($object->lines); // Loop on each lines for ($i = 0 ; $i < $nblignes ; $i++) @@ -220,7 +213,7 @@ class pdf_oursin extends ModelePDFFactures $curY = $nexY; // Description of product line - $libelleproduitservice=pdf_getlinedesc($fac->lignes[$i],$outputlangs); + $libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs); $pdf->writeHTMLCell(108, 3, $this->posxdesc-1, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1); @@ -232,62 +225,62 @@ class pdf_oursin extends ModelePDFFactures if ($this->franchise!=1) { $pdf->SetXY ($this->marges['g']+119, $curY); - $pdf->MultiCell(10, 3, $fac->lignes[$i]->tva_tx, 0, 'R'); + $pdf->MultiCell(10, 3, $object->lines[$i]->tva_tx, 0, 'R'); } } // Prix unitaire HT avant remise $pdf->SetXY ($this->marges['g']+132, $curY); - $pdf->MultiCell(16, 3, price($fac->lignes[$i]->subprice), 0, 'R', 0); + $pdf->MultiCell(16, 3, price($object->lines[$i]->subprice), 0, 'R', 0); // Quantit $pdf->SetXY ($this->marges['g']+150, $curY); - $pdf->MultiCell(10, 3, $fac->lignes[$i]->qty, 0, 'R'); + $pdf->MultiCell(10, 3, $object->lines[$i]->qty, 0, 'R'); // Remise sur ligne $pdf->SetXY ($this->marges['g']+160, $curY); - if ($fac->lignes[$i]->remise_percent) { - $pdf->MultiCell(14, 3, $fac->lignes[$i]->remise_percent."%", 0, 'R'); + if ($object->lines[$i]->remise_percent) { + $pdf->MultiCell(14, 3, $object->lines[$i]->remise_percent."%", 0, 'R'); } // Total HT $pdf->SetXY ($this->marges['g']+168, $curY); - $total = price($fac->lignes[$i]->total_ht); + $total = price($object->lines[$i]->total_ht); $pdf->MultiCell(21, 3, $total, 0, 'R', 0); if ($nexY > 200 && $i < $nblignes - 1) { - $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $fac, $outputlangs); + $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $object, $outputlangs); $nexY = $iniY; // New page $pdf->AddPage(); $pagenb++; - $this->_pagehead($pdf, $fac, 0, $outputlangs); + $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->SetFont('','', 9); $pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3 $pdf->SetTextColor(0,0,0); } } - $posy=$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $fac, $outputlangs); + $posy=$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $object, $outputlangs); $bottomlasttab=$tab_top + $tab_height + 1; // Affiche zone infos - $posy=$this->_tableau_info($pdf, $fac, $bottomlasttab, $outputlangs); + $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); // Affiche zone totaux - $posy=$this->_tableau_tot($pdf, $fac, $deja_regle, $bottomlasttab, $outputlangs); + $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); // Affiche zone versements if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) { - $posy=$this->_tableau_versements($pdf, $fac, $posy, $outputlangs); + $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); } // Pied de page - $this->_pagefoot($pdf, $fac, $outputlangs); + $this->_pagefoot($pdf, $object, $outputlangs); $pdf->AliasNbPages(); $pdf->Close(); @@ -322,7 +315,7 @@ class pdf_oursin extends ModelePDFFactures * \param outputlangs Object langs for output * \return int <0 if KO, >0 if OK */ - function _tableau_versements(&$pdf, $fac, $posy, $outputlangs) + function _tableau_versements(&$pdf, $object, $posy, $outputlangs) { $tab3_posx = $this->marges['g']+110; $tab3_top = $posy + 8; @@ -353,7 +346,7 @@ class pdf_oursin extends ModelePDFFactures $sql.= " re.description, re.fk_facture_source, re.fk_facture_source,"; $sql.= " f.type, f.datef"; $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re, ".MAIN_DB_PREFIX ."facture as f"; - $sql.= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$fac->id; + $sql.= " WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".$object->id; $resql=$this->db->query($sql); if ($resql) { @@ -395,7 +388,7 @@ class pdf_oursin extends ModelePDFFactures // Loop on each payment $sql = "SELECT p.datep as date, pf.amount as amount, p.fk_paiement as type, p.num_paiement as num "; $sql.= "FROM ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."paiement_facture as pf "; - $sql.= "WHERE pf.fk_paiement = p.rowid and pf.fk_facture = ".$fac->id." "; + $sql.= "WHERE pf.fk_paiement = p.rowid and pf.fk_facture = ".$object->id." "; $sql.= "ORDER BY p.datep"; $resql=$this->db->query($sql); if ($resql) @@ -764,10 +757,10 @@ class pdf_oursin extends ModelePDFFactures $pdf->Text($this->marges['g']+135, $tab_top + 5,$outputlangs->transnoentities("PriceUHT")); $pdf->Text($this->marges['g']+153, $tab_top + 5, $outputlangs->transnoentities("Qty")); - $nblignes = sizeof($object->lignes); + $nblignes = sizeof($object->lines); $rem=0; for ($i = 0 ; $i < $nblignes ; $i++) - if ($object->lignes[$i]->remise_percent) + if ($object->lines[$i]->remise_percent) { $rem=1; } @@ -920,11 +913,11 @@ class pdf_oursin extends ModelePDFFactures $pdf->SetTextColor(0,0,0); $posy+=4; - $facidnext=$object->getIdReplacingInvoice('validated'); - if ($object->type == 0 && $facidnext) + $objectidnext=$object->getIdReplacingInvoice('validated'); + if ($object->type == 0 && $objectidnext) { $objectreplacing=new Facture($this->db); - $objectreplacing->fetch($facidnext); + $objectreplacing->fetch($objectidnext); $posy+=4; $pdf->SetXY($this->marges['g'],$posy); diff --git a/htdocs/includes/modules/livraison/modules_livraison.php b/htdocs/includes/modules/livraison/modules_livraison.php index b00a0f9034a..7d44cd756a0 100644 --- a/htdocs/includes/modules/livraison/modules_livraison.php +++ b/htdocs/includes/modules/livraison/modules_livraison.php @@ -132,14 +132,14 @@ class ModeleNumRefDeliveryOrder /** - * \brief Create object on disk - * \param db objet base de donnee - * \param deliveryid id object - * \param modele force le modele a utiliser ('' to not force) - * \param outputlangs objet lang a utiliser pour traduction - * \return int 0 si KO, 1 si OK + * Create object on disk + * @param db objet base de donnee + * @param object object delivery + * @param model force le modele a utiliser ('' to not force) + * @param outputlangs objet lang a utiliser pour traduction + * @return int 0 si KO, 1 si OK */ -function delivery_order_pdf_create($db, $deliveryid, $modele='', $outputlangs='') +function delivery_order_pdf_create($db, $object, $model='', $outputlangs='') { global $conf,$langs; $langs->load("deliveries"); @@ -147,11 +147,11 @@ function delivery_order_pdf_create($db, $deliveryid, $modele='', $outputlangs='' $dir = DOL_DOCUMENT_ROOT."/includes/modules/livraison/pdf/"; // Positionne modele sur le nom du modele de bon de livraison a utiliser - if (! dol_strlen($modele)) + if (! dol_strlen($model)) { if ($conf->global->LIVRAISON_ADDON_PDF) { - $modele = $conf->global->LIVRAISON_ADDON_PDF; + $model = $conf->global->LIVRAISON_ADDON_PDF; } else { @@ -160,10 +160,10 @@ function delivery_order_pdf_create($db, $deliveryid, $modele='', $outputlangs='' } } // Charge le modele - $file = "pdf_".$modele.".modules.php"; + $file = "pdf_".$model.".modules.php"; if (file_exists($dir.$file)) { - $classname = "pdf_".$modele; + $classname = "pdf_".$model; require_once($dir.$file); $obj = new $classname($db); @@ -171,10 +171,10 @@ function delivery_order_pdf_create($db, $deliveryid, $modele='', $outputlangs='' // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($deliveryid,$outputlangs) > 0) + if ($obj->write_file($object,$outputlangs) > 0) { // on supprime l'image correspondant au preview - delivery_order_delete_preview($db, $deliveryid); + delivery_order_delete_preview($db, $object->id); $outputlangs->charset_output=$sav_charset_output; return 1; diff --git a/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php b/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php index cecb1b15f72..4ff6fc1b5de 100644 --- a/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php +++ b/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php @@ -97,19 +97,6 @@ class pdf_sirocco extends ModelePDFDeliveryOrder if ($conf->expedition->dir_output."/receipt") { - // If $object is id instead of object - if (! is_object($object)) - { - $id = $object; - $object = new Livraison($this->db); - $object->fetch($id); - $object->id = $id; - if ($result < 0) - { - dol_print_error($db,$object->error); - } - } - $object->fetch_thirdparty(); $nblignes = sizeof($object->lignes); @@ -199,7 +186,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder $curY = $nexY; // Description de la ligne produit - $libelleproduitservice=pdf_getlinedesc($object->lignes[$i],$outputlangs); + $libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs); $pdf->SetFont('','', 9); // Dans boucle pour gerer multi-page diff --git a/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php index 0ea81a03624..197437c849f 100644 --- a/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php +++ b/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php @@ -119,19 +119,6 @@ class pdf_typhon extends ModelePDFDeliveryOrder if ($conf->expedition->dir_output."/receipt") { - // If $object is id instead of object - if (! is_object($object)) - { - $id = $object; - $object = new Livraison($this->db); - $object->fetch($id); - - if ($result < 0) - { - dol_print_error($db,$object->error); - } - } - $object->fetch_thirdparty(); $nblignes = sizeof($object->lignes); @@ -256,7 +243,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder $curY = $nexY; // Description de la ligne produit - $libelleproduitservice=pdf_getlinedesc($object->lignes[$i],$outputlangs); + $libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs); $pdf->SetFont('','', 9); // Dans boucle pour gerer multi-page diff --git a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php index 5aba1f71281..ee32f83bd22 100644 --- a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php @@ -124,6 +124,7 @@ class pdf_propale_azur extends ModelePDFPropales if ($conf->propale->dir_output) { $object->fetch_thirdparty(); + $deja_regle = ""; // Definition de $dir et $file @@ -134,9 +135,9 @@ class pdf_propale_azur extends ModelePDFPropales } else { - $propref = dol_sanitizeFileName($object->ref); - $dir = $conf->propale->dir_output . "/" . $propref; - $file = $dir . "/" . $propref . ".pdf"; + $objectref = dol_sanitizeFileName($object->ref); + $dir = $conf->propale->dir_output . "/" . $objectref; + $file = $dir . "/" . $objectref . ".pdf"; } if (! file_exists($dir)) @@ -244,7 +245,7 @@ class pdf_propale_azur extends ModelePDFPropales $curY = $nexY; // Description de la ligne produit - $libelleproduitservice=pdf_getlinedesc($object->lines[$i],$outputlangs); + $libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs); $pdf->SetFont('','', 9); // Dans boucle pour gerer multi-page diff --git a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php index a1748966a17..b05f7104b7e 100644 --- a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php @@ -80,7 +80,7 @@ class pdf_propale_jaune extends ModelePDFPropales * \param outputlangs Lang object for output language * \return int 1=ok, 0=ko */ - function write_file($propale,$outputlangs) + function write_file($object,$outputlangs) { global $user,$langs,$conf; @@ -98,27 +98,20 @@ class pdf_propale_jaune extends ModelePDFPropales if ($conf->propale->dir_output) { - // D�finition de l'objet $propal (pour compatibilite ascendante) - if (! is_object($propale)) - { - $id = $propale; - $propale = new Propal($this->db,"",$id); - $ret=$propale->fetch($id); - } - $propale->fetch_thirdparty(); + $object->fetch_thirdparty(); $deja_regle = ""; // Definition de $dir et $file - if ($propale->specimen) + if ($object->specimen) { $dir = $conf->propale->dir_output; $file = $dir . "/SPECIMEN.pdf"; } else { - $propref = dol_sanitizeFileName($propale->ref); - $dir = $conf->propale->dir_output . "/" . $propref; - $file = $dir . "/" . $propref . ".pdf"; + $objectref = dol_sanitizeFileName($object->ref); + $dir = $conf->propale->dir_output . "/" . $objectref; + $file = $dir . "/" . $objectref . ".pdf"; } if (! file_exists($dir)) @@ -138,7 +131,7 @@ class pdf_propale_jaune extends ModelePDFPropales $pdf=new FPDI_Protection('P','mm',$this->format); $pdfrights = array('print'); // Ne permet que l'impression du document $pdfuserpass = ''; // Mot de passe pour l'utilisateur final - $pdfownerpass = NULL; // Mot de passe du propri�taire, cr�� al�atoirement si pas d�fini + $pdfownerpass = NULL; // Mot de passe du proprietaire, cree aleatoirement si pas defini $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass); } else @@ -157,11 +150,11 @@ class pdf_propale_jaune extends ModelePDFPropales $pagenb=0; $pdf->SetDrawColor(128,128,128); - $pdf->SetTitle($outputlangs->convToOutputCharset($propale->ref)); + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("CommercialProposal")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); - $pdf->SetKeyWords($outputlangs->convToOutputCharset($propale->ref)." ".$outputlangs->transnoentities("CommercialProposal")); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("CommercialProposal")); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right @@ -170,7 +163,7 @@ class pdf_propale_jaune extends ModelePDFPropales // New page $pdf->AddPage(); $pagenb++; - $this->_pagehead($pdf, $propale, 1, $outputlangs); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', 9); $pdf->MultiCell(0, 4, '', 0, 'J'); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -184,7 +177,7 @@ class pdf_propale_jaune extends ModelePDFPropales $iniY = $tab_top + 12; $curY = $tab_top + 12; $nexY = $tab_top + 12; - $nblignes = sizeof($propale->lignes); + $nblignes = sizeof($object->lines); // Loop on each lines for ($i = 0 ; $i < $nblignes ; $i++) @@ -192,30 +185,30 @@ class pdf_propale_jaune extends ModelePDFPropales $curY = $nexY; // Description de la ligne produit - $libelleproduitservice=pdf_getlinedesc($propale->lignes[$i],$outputlangs); + $libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs); $pdf->SetFont('','', 9); // Dans boucle pour gerer multi-page $pdf->writeHTMLCell(102, 4, 30, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1); - $pdf->SetFont('','', 9); // On repositionne la police par d�faut + $pdf->SetFont('','', 9); // On repositionne la police par defaut $nexY = $pdf->GetY(); - $ref=dol_htmlentitiesbr($propale->lignes[$i]->ref); + $ref=dol_htmlentitiesbr($object->lines[$i]->ref); $pdf->SetXY (10, $curY ); $pdf->MultiCell(20, 4, $outputlangs->convToOutputCharset($ref), 0, 'L', 0); $pdf->SetXY (132, $curY ); - $pdf->MultiCell(12, 4, vatrate($propale->lignes[$i]->tva_tx,0,$propale->lignes[$i]->info_bits), 0, 'R'); + $pdf->MultiCell(12, 4, vatrate($object->lines[$i]->tva_tx,0,$object->lines[$i]->info_bits), 0, 'R'); $pdf->SetXY (144, $curY ); - $pdf->MultiCell(10, 4, price($propale->lignes[$i]->qty), 0, 'R', 0); + $pdf->MultiCell(10, 4, price($object->lines[$i]->qty), 0, 'R', 0); $pdf->SetXY (154, $curY ); - $pdf->MultiCell(22, 4, price($propale->lignes[$i]->price), 0, 'R', 0); + $pdf->MultiCell(22, 4, price($object->lines[$i]->price), 0, 'R', 0); $pdf->SetXY (176, $curY ); - $pdf->MultiCell(24, 4, price($propale->lignes[$i]->total_ht), 0, 'R', 0); + $pdf->MultiCell(24, 4, price($object->lines[$i]->total_ht), 0, 'R', 0); //$pdf->line(10, $curY, 200, $curY ); @@ -225,7 +218,7 @@ class pdf_propale_jaune extends ModelePDFPropales if ($i < ($nblignes - 1)) // If it's not last line { //on recupere la description du produit suivant - $follow_descproduitservice = $outputlangs->convToOutputCharset($propale->lignes[$i+1]->desc); + $follow_descproduitservice = $outputlangs->convToOutputCharset($object->lines[$i+1]->desc); //on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) $nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4); } @@ -237,14 +230,14 @@ class pdf_propale_jaune extends ModelePDFPropales // test si besoin nouvelle page if (($nexY+$nblineFollowDesc) > ($tab_top+$tab_height) && $i < ($nblignes - 1)) { - $this->_pagefoot($pdf,$propale,$outputlangs); + $this->_pagefoot($pdf,$object,$outputlangs); $this->_tableau($pdf, $tab_top, $tab_height, $nexY); // New page $pdf->AddPage(); $pagenb++; - $this->_pagehead($pdf, $propale, 0, $outputlangs); + $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->SetFont('','', 9); $pdf->MultiCell(0, 4, '', 0, 'J'); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -258,7 +251,7 @@ class pdf_propale_jaune extends ModelePDFPropales $bottomlasttab=$tab_top + $tab_height + 1; // Affiche zone infos - $this->_tableau_info($pdf, $propale, $bottomlasttab, $outputlangs); + $this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); $tab2_top = 254; $tab2_lh = 7; @@ -284,16 +277,16 @@ class pdf_propale_jaune extends ModelePDFPropales $pdf->MultiCell(42, $tab2_lh, $outputlangs->transnoentities("TotalTTC"), 1, 'R', 1); $pdf->SetXY (174, $tab2_top + 0); - $pdf->MultiCell(26, $tab2_lh, price($propale->total_ht), 0, 'R', 0); + $pdf->MultiCell(26, $tab2_lh, price($object->total_ht), 0, 'R', 0); $pdf->SetXY (174, $tab2_top + $tab2_lh); - $pdf->MultiCell(26, $tab2_lh, price($propale->total_tva), 0, 'R', 0); + $pdf->MultiCell(26, $tab2_lh, price($object->total_tva), 0, 'R', 0); $pdf->SetXY (174, $tab2_top + ($tab2_lh*2)); - $pdf->MultiCell(26, $tab2_lh, price($propale->total_ttc), 1, 'R', 1); + $pdf->MultiCell(26, $tab2_lh, price($object->total_ttc), 1, 'R', 1); // Pied de page - $this->_pagefoot($pdf,$propale,$outputlangs); + $this->_pagefoot($pdf,$object,$outputlangs); $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php b/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php index 854b0a2f0ea..562a4aa3727 100644 --- a/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php +++ b/htdocs/includes/modules/supplier_order/modules_commandefournisseur.php @@ -2,7 +2,7 @@ /* Copyright (C) 2003-2004 Rodolphe Quiedeville * Copyright (C) 2004-2005 Laurent Destailleur * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2006 Andre Cianfarani * * This program is free software; you can redistribute it and/or modify @@ -133,14 +133,14 @@ class ModeleNumRefSuppliersOrders /** - * \brief Create object on disk - * \param db objet base de donnee - * \param deliveryid id object - * \param modele force le modele a utiliser ('' to not force) - * \param outputlangs objet lang a utiliser pour traduction - * \return int 0 si KO, 1 si OK + * Create object on disk + * @param db objet base de donnee + * @param object object supplier order + * @param model force le modele a utiliser ('' to not force) + * @param outputlangs objet lang a utiliser pour traduction + * @return int 0 si KO, 1 si OK */ -function supplier_order_pdf_create($db, $comid, $modele,$outputlangs) +function supplier_order_pdf_create($db, $object, $model, $outputlangs) { global $langs; $langs->load("suppliers"); @@ -148,11 +148,11 @@ function supplier_order_pdf_create($db, $comid, $modele,$outputlangs) $dir = DOL_DOCUMENT_ROOT."/includes/modules/supplier_order/pdf/"; // Positionne modele sur le nom du modele de commande fournisseur a utiliser - if (! dol_strlen($modele)) + if (! dol_strlen($model)) { if (! empty($conf->global->COMMANDE_SUPPLIER_ADDON_PDF)) { - $modele = $conf->global->COMMANDE_SUPPLIER_ADDON_PDF; + $model = $conf->global->COMMANDE_SUPPLIER_ADDON_PDF; } else { @@ -161,10 +161,10 @@ function supplier_order_pdf_create($db, $comid, $modele,$outputlangs) } } // Charge le modele - $file = "pdf_".$modele.".modules.php"; + $file = "pdf_".$model.".modules.php"; if (file_exists($dir.$file)) { - $classname = "pdf_".$modele; + $classname = "pdf_".$model; require_once($dir.$file); $obj = new $classname($db); @@ -172,10 +172,10 @@ function supplier_order_pdf_create($db, $comid, $modele,$outputlangs) // We save charset_output to restore it because write_file can change it if needed for // output format that does not support UTF8. $sav_charset_output=$outputlangs->charset_output; - if ($obj->write_file($comid,$outputlangs) > 0) + if ($obj->write_file($object,$outputlangs) > 0) { // on supprime l'image correspondant au preview - supplier_order_delete_preview($db, $comid); + supplier_order_delete_preview($db, $object->id); $outputlangs->charset_output=$sav_charset_output; return 1; @@ -202,12 +202,12 @@ function supplier_order_pdf_create($db, $comid, $modele,$outputlangs) * @param $propalid * @return int */ -function supplier_order_delete_preview($db, $propalid) +function supplier_order_delete_preview($db, $objectid) { global $langs,$conf; - $comfourn = new CommandeFournisseur($db,"",$propalid); - $comfourn->fetch($propalid); + $comfourn = new CommandeFournisseur($db,"",$objectid); + $comfourn->fetch($objectid); $client = new Societe($db); $client->fetch($comfourn->socid); 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 b808ac0575e..ffaf0a39777 100644 --- a/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -97,7 +97,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders * \param outputlangs Lang output object * \return int 1=ok, 0=ko */ - function write_file($com,$outputlangs='') + function write_file($object,$outputlangs='') { global $user,$langs,$conf; @@ -114,26 +114,19 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if ($conf->fournisseur->dir_output.'/commande') { - // Definition de l'objet $com (pour compatibilite ascendante) - if (! is_object($com)) - { - $id = $com; - $com = new CommandeFournisseur($this->db); - $ret=$com->fetch($id); - } $deja_regle = ""; // Definition de $dir et $file - if ($com->specimen) + if ($object->specimen) { $dir = $conf->fournisseur->dir_output.'/commande'; $file = $dir . "/SPECIMEN.pdf"; } else { - $comref = dol_sanitizeFileName($com->ref); - $dir = $conf->fournisseur->dir_output . "/commande/" . $comref; - $file = $dir . "/" . $comref . ".pdf"; + $objectref = dol_sanitizeFileName($object->ref); + $dir = $conf->fournisseur->dir_output . "/commande/" . $objectref; + $file = $dir . "/" . $objectref . ".pdf"; } if (! file_exists($dir)) @@ -148,7 +141,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders if (file_exists($dir)) { - $nblignes = sizeof($com->lignes); + $nblignes = sizeof($object->lines); // Protection et encryption du pdf if ($conf->global->PDF_SECURITY_ENCRYPTION) @@ -175,11 +168,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pagenb=0; $pdf->SetDrawColor(128,128,128); - $pdf->SetTitle($outputlangs->convToOutputCharset($com->ref)); + $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetSubject($outputlangs->transnoentities("Order")); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); - $pdf->SetKeyWords($outputlangs->convToOutputCharset($com->ref)." ".$outputlangs->transnoentities("Order")); + $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right @@ -188,7 +181,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // Positionne $this->atleastonediscount si on a au moins une remise for ($i = 0 ; $i < $nblignes ; $i++) { - if ($com->lignes[$i]->remise_percent) + if ($object->lines[$i]->remise_percent) { $this->atleastonediscount++; } @@ -197,7 +190,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // New page $pdf->AddPage(); $pagenb++; - $this->_pagehead($pdf, $com, 1, $outputlangs); + $this->_pagehead($pdf, $object, 1, $outputlangs); $pdf->SetFont('','', 9); $pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -208,13 +201,13 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $tab_height_newpage = 150; // Affiche notes - if (! empty($com->note_public)) + if (! empty($object->note_public)) { $tab_top = 88; $pdf->SetFont('','', 9); // Dans boucle pour gerer multi-page $pdf->SetXY ($this->posxdesc-1, $tab_top); - $pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($com->note_public), 0, 'J'); + $pdf->MultiCell(190, 3, $outputlangs->convToOutputCharset($object->note_public), 0, 'J'); $nexY = $pdf->GetY(); $height_note=$nexY-$tab_top; @@ -240,7 +233,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $curY = $nexY; // Description de la ligne produit - $libelleproduitservice=pdf_getlinedesc($com->lignes[$i],$outputlangs,0,0,1); + $libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs,0,0,1); $pdf->SetFont('','', 9); // Dans boucle pour gerer multi-page @@ -252,33 +245,33 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // TVA $pdf->SetXY ($this->posxtva, $curY); - $pdf->MultiCell(10, 3, ($com->lignes[$i]->tva_tx < 0 ? '*':'').abs($com->lignes[$i]->tva_tx), 0, 'R'); + $pdf->MultiCell(10, 3, ($object->lines[$i]->tva_tx < 0 ? '*':'').abs($object->lines[$i]->tva_tx), 0, 'R'); // Unit price before discount $pdf->SetXY ($this->posxup, $curY); - $pdf->MultiCell(18, 3, price($com->lignes[$i]->subprice), 0, 'R', 0); + $pdf->MultiCell(18, 3, price($object->lines[$i]->subprice), 0, 'R', 0); // Quantity $pdf->SetXY ($this->posxqty, $curY); - $pdf->MultiCell(10, 3, $com->lignes[$i]->qty, 0, 'R'); + $pdf->MultiCell(10, 3, $object->lines[$i]->qty, 0, 'R'); // Discount on line $pdf->SetXY ($this->posxdiscount, $curY); - if ($com->lignes[$i]->remise_percent) + if ($object->lines[$i]->remise_percent) { - $pdf->MultiCell(14, 3, $com->lignes[$i]->remise_percent."%", 0, 'R'); + $pdf->MultiCell(14, 3, $object->lines[$i]->remise_percent."%", 0, 'R'); } // Total HT line $pdf->SetXY ($this->postotalht, $curY); - $total = price($com->lignes[$i]->total_ht); + $total = price($object->lines[$i]->total_ht); $pdf->MultiCell(23, 3, $total, 0, 'R', 0); // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva - $tvaligne=$com->lignes[$i]->total_tva; - if ($com->remise_percent) $tvaligne-=($tvaligne*$com->remise_percent)/100; - $vatrate=(string) $com->lignes[$i]->tva_tx; - if (($com->lignes[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; + $tvaligne=$object->lines[$i]->total_tva; + if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; + $vatrate=(string) $object->lines[$i]->tva_tx; + if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; $this->tva[$vatrate] += $tvaligne; $nexY+=2; // Passe espace entre les lignes @@ -305,12 +298,12 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); } - $this->_pagefoot($pdf, $com, $outputlangs); + $this->_pagefoot($pdf, $object, $outputlangs); // New page $pdf->AddPage(); $pagenb++; - $this->_pagehead($pdf, $com, 0, $outputlangs); + $this->_pagehead($pdf, $object, 0, $outputlangs); $pdf->SetFont('','', 9); $pdf->MultiCell(0, 3, '', 0, 'J'); // Set interline to 3 $pdf->SetTextColor(0,0,0); @@ -332,7 +325,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1; } - $posy=$this->_tableau_tot($pdf, $com, $deja_regle, $bottomlasttab, $outputlangs); + $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); if ($deja_regle) { @@ -355,7 +348,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders /* * Pied de page */ - $this->_pagefoot($pdf, $com, $outputlangs); + $this->_pagefoot($pdf, $object, $outputlangs); $pdf->AliasNbPages(); $pdf->Close(); diff --git a/htdocs/lib/pdf.lib.php b/htdocs/lib/pdf.lib.php index 83100a00314..38d4edb9eee 100644 --- a/htdocs/lib/pdf.lib.php +++ b/htdocs/lib/pdf.lib.php @@ -387,22 +387,23 @@ 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 hideref Hide reference - * \param hidedesc Hide description - * \param issupplierline Is it a line for a supplier object ? + * Return line description translated in outputlangs and encoded in UTF8 + * @param object Object + * @param $i Current line number + * @param outputlang Object lang for output + * @param hideref Hide reference + * @param hidedesc Hide description + * @param issupplierline Is it a line for a supplier object ? */ -function pdf_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierline=0) +function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issupplierline=0) { global $db, $conf, $langs; - $idprod=$line->fk_product; - $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=$object->lines[$i]->fk_product; + $label=$object->lines[$i]->label; if (empty($label)) $label=$object->lines[$i]->libelle; + $desc=$object->lines[$i]->desc; if (empty($desc)) $desc=$object->lines[$i]->description; + $ref_supplier=$object->lines[$i]->ref_supplier; if (empty($ref_supplier)) $ref_supplier=$object->lines[$i]->ref_fourn; // TODO Not yeld saved for supplier invoices, only supplier orders + $note=$object->lines[$i]->note; if ($issupplierline) $prodser = new ProductFournisseur($db); else $prodser = new Product($db); @@ -428,10 +429,10 @@ function pdf_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierli { if ($libelleproduitservice && !$hidedesc) $libelleproduitservice.="\n"; - if ($desc == '(CREDIT_NOTE)' && $line->fk_remise_except) + if ($desc == '(CREDIT_NOTE)' && $object->lines[$i]->fk_remise_except) { $discount=new DiscountAbsolute($db); - $discount->fetch($line->fk_remise_except); + $discount->fetch($object->lines[$i]->fk_remise_except); $libelleproduitservice=$outputlangs->transnoentitiesnoconv("DiscountFromCreditNote",$discount->ref_facture_source); } else @@ -480,20 +481,20 @@ function pdf_getlinedesc($line,$outputlangs,$hideref=0,$hidedesc=0,$issupplierli } $libelleproduitservice=dol_htmlentitiesbr($libelleproduitservice,1); - if ($line->date_start || $line->date_end) + if ($object->lines[$i]->date_start || $object->lines[$i]->date_end) { // Show duration if exists - if ($line->date_start && $line->date_end) + if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) { - $period='('.$outputlangs->transnoentitiesnoconv('DateFromTo',dol_print_date($line->date_start, $format, false, $outputlangs),dol_print_date($line->date_end, $format, false, $outputlangs)).')'; + $period='('.$outputlangs->transnoentitiesnoconv('DateFromTo',dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs),dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')'; } - if ($line->date_start && ! $line->date_end) + if ($object->lines[$i]->date_start && ! $object->lines[$i]->date_end) { - $period='('.$outputlangs->transnoentitiesnoconv('DateFrom',dol_print_date($line->date_start, $format, false, $outputlangs)).')'; + $period='('.$outputlangs->transnoentitiesnoconv('DateFrom',dol_print_date($object->lines[$i]->date_start, $format, false, $outputlangs)).')'; } - if (! $line->date_start && $line->date_end) + if (! $object->lines[$i]->date_start && $object->lines[$i]->date_end) { - $period='('.$outputlangs->transnoentitiesnoconv('DateUntil',dol_print_date($line->date_end, $format, false, $outputlangs)).')'; + $period='('.$outputlangs->transnoentitiesnoconv('DateUntil',dol_print_date($object->lines[$i]->date_end, $format, false, $outputlangs)).')'; } //print '>'.$outputlangs->charset_output.','.$period; $libelleproduitservice.="
".dol_htmlentitiesbr($period,1); diff --git a/htdocs/livraison/class/livraison.class.php b/htdocs/livraison/class/livraison.class.php index 3020f2cc3e5..3484b0a371b 100644 --- a/htdocs/livraison/class/livraison.class.php +++ b/htdocs/livraison/class/livraison.class.php @@ -65,7 +65,8 @@ class Livraison extends CommonObject function Livraison($DB) { $this->db = $DB; - $this->lignes = array(); + $this->lignes = array(); // TODO deprecated + $this->lines = array(); $this->products = array(); // List of short language codes for status @@ -676,25 +677,27 @@ class Livraison extends CommonObject $i = 0; while ($i < $num) { - $ligne = new LivraisonLigne($this->db); + $line = new LivraisonLigne($this->db); $obj = $this->db->fetch_object($resql); - $ligne->description = $obj->description; - $ligne->fk_product = $obj->fk_product; - $ligne->qty_asked = $obj->qty_asked; - $ligne->qty_shipped = $obj->qty_shipped; + $line->description = $obj->description; + $line->fk_product = $obj->fk_product; + $line->qty_asked = $obj->qty_asked; + $line->qty_shipped = $obj->qty_shipped; - $ligne->ref = $obj->ref; - $ligne->libelle = $obj->label; // Label produit - $ligne->label = $obj->label; - $ligne->product_desc = $obj->product_desc; // Description produit - $ligne->product_type = $obj->fk_product_type; + $line->ref = $obj->ref; + $line->libelle = $obj->label; // Label produit + $line->label = $obj->label; + $line->product_desc = $obj->product_desc; // Description produit + $line->product_type = $obj->fk_product_type; - $ligne->price = $obj->price; - $ligne->total_ht = $obj->total_ht; + $line->price = $obj->price; + $line->total_ht = $obj->total_ht; - $this->lignes[$i] = $ligne; + $this->lignes[$i] = $line; // TODO deprecated + $this->lines[$i] = $line; + $i++; } $this->db->free($resql); diff --git a/htdocs/livraison/fiche.php b/htdocs/livraison/fiche.php index 85bc393be77..2f46dedb3e9 100644 --- a/htdocs/livraison/fiche.php +++ b/htdocs/livraison/fiche.php @@ -74,7 +74,7 @@ if ($_POST["action"] == 'add') $commande = new Commande($db); $commande->fetch($delivery->commande_id); $commande->fetch_lines(); - for ($i = 0 ; $i < sizeof($commande->lignes) ; $i++) + for ($i = 0 ; $i < sizeof($commande->lines) ; $i++) { $qty = "qtyl".$i; $idl = "idl".$i; @@ -118,7 +118,7 @@ if ($_REQUEST["action"] == 'confirm_valid' && $_REQUEST["confirm"] == 'yes' && $ $outputlangs = new Translate("",$conf); $outputlangs->setDefaultLang($newlang); } - $result=delivery_order_pdf_create($db, $_REQUEST['id'],$_REQUEST['model'],$outputlangs); + $result=delivery_order_pdf_create($db, $delivery,$_REQUEST['model'],$outputlangs); if ($result <= 0) { dol_print_error($db,$result); @@ -170,7 +170,7 @@ if ($_REQUEST['action'] == 'builddoc') // En get ou en post $outputlangs->setDefaultLang($newlang); } - $result=delivery_order_pdf_create($db, $_REQUEST['id'],$_REQUEST['model'],$outputlangs); + $result=delivery_order_pdf_create($db, $delivery,$_REQUEST['model'],$outputlangs); if ($result <= 0) { dol_print_error($db,$result); @@ -392,7 +392,7 @@ else if ($delivery->origin_id) { - $delivery->fetch_object(); + $delivery->fetch_origin(); } if ( $delivery->id > 0) diff --git a/scripts/invoices/rebuild_merge_pdf.php b/scripts/invoices/rebuild_merge_pdf.php index dab21c61f69..179a0c8e3d8 100644 --- a/scripts/invoices/rebuild_merge_pdf.php +++ b/scripts/invoices/rebuild_merge_pdf.php @@ -227,7 +227,7 @@ if ( $resql=$db->query($sql) ) } } print "Build PDF for invoice ".$obj->facnumber." - Lang = ".$outputlangs->defaultlang."\n"; - $result=facture_pdf_create($db, $fac->id, '', $newmodel?$newmodel:$fac->modelpdf, $outputlangs); + $result=facture_pdf_create($db, $fac, '', $newmodel?$newmodel:$fac->modelpdf, $outputlangs); // Add file into files array $files[] = $conf->facture->dir_output.'/'.$fac->ref.'/'.$fac->ref.'.pdf';