From 0e663354f06576d9495c7e8a798f544d06ef7b84 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 2 Oct 2010 11:47:15 +0000 Subject: [PATCH] Fix: Preview was broken after renaming lignes into lines --- htdocs/comm/propal/class/propal.class.php | 32 ++++++----- htdocs/commande/class/commande.class.php | 13 ++--- htdocs/compta/facture/class/facture.class.php | 40 ++++++------- .../class/fournisseur.commande.class.php | 57 ++++++------------- .../fourn/class/fournisseur.facture.class.php | 53 +++++------------ 5 files changed, 76 insertions(+), 119 deletions(-) diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index 3ed94691f14..2ef0c20ecb1 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -1898,7 +1898,8 @@ class Propal extends CommonObject /** - * \brief Initialise object with default value to be used as example + * Initialise an example of instance with random values + * Used to build previews or test instances */ function initAsSpecimen() { @@ -1908,8 +1909,7 @@ class Propal extends CommonObject $prodids = array(); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE tosell = 1"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " WHERE entity = ".$conf->entity; $resql = $this->db->query($sql); if ($resql) { @@ -1938,22 +1938,24 @@ class Propal extends CommonObject $this->note_public='This is a comment (public)'; $this->note='This is a comment (private)'; // Lines - $nbp = rand(1, 9); + $nbp = 5; $xnbp = 0; while ($xnbp < $nbp) { - $ligne=new PropaleLigne($this->db); - $ligne->desc=$langs->trans("Description")." ".$xnbp; - $ligne->qty=1; - $ligne->subprice=100; - $ligne->price=100; - $ligne->tva_tx=19.6; - $ligne->total_ht=100; - $ligne->total_ttc=119.6; - $ligne->total_tva=19.6; + $line=new PropaleLigne($this->db); + $line->desc=$langs->trans("Description")." ".$xnbp; + $line->qty=1; + $line->subprice=100; + $line->price=100; + $line->tva_tx=19.6; + $line->total_ht=100; + $line->total_ttc=119.6; + $line->total_tva=19.6; $prodid = rand(1, $num_prods); - $ligne->fk_product=$prodids[$prodid]; - $this->lignes[$xnbp]=$ligne; + $line->fk_product=$prodids[$prodid]; + + $this->lines[$xnbp]=$line; + $xnbp++; } diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 35aa4ec1014..0548cb8f9d4 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2253,8 +2253,8 @@ class Commande extends CommonObject /** - * \brief Initialise la commande avec valeurs fictives aleatoire - * Sert a generer une commande pour l'aperu des modeles ou demo + * Initialise an example of instance with random values + * Used to build previews or test instances */ function initAsSpecimen() { @@ -2266,8 +2266,7 @@ class Commande extends CommonObject $prodids = array(); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE tosell = 1"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " WHERE entity = ".$conf->entity; $resql = $this->db->query($sql); if ($resql) { @@ -2293,14 +2292,12 @@ class Commande extends CommonObject $this->note_public='This is a comment (public)'; $this->note='This is a comment (private)'; // Lines - $nbp = rand(1, 9); + $nbp = 5; $xnbp = 0; while ($xnbp < $nbp) { $line=new OrderLine($this->db); - $prodid = rand(1, $num_prods); - $line->desc=$langs->trans("Description")." ".$xnbp; $line->qty=1; $line->subprice=100; @@ -2310,9 +2307,9 @@ class Commande extends CommonObject $line->total_ttc=119.6; $line->total_tva=19.6; $line->remise_percent=0; + $prodid = rand(1, $num_prods); $line->fk_product=$prodids[$prodid]; - $this->lignes[$xnbp]=$line; // TODO: deprecated $this->lines[$xnbp]=$line; $xnbp++; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 4c24ac5c8ca..3e62344833a 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -2854,8 +2854,8 @@ class Facture extends CommonObject /** - * \brief Initialise an example of invoice with random values - * Used to build preview of invoices or demo + * Initialise an example of invoice with random values + * Used to build previews or test instances */ function initAsSpecimen() { @@ -2864,8 +2864,7 @@ class Facture extends CommonObject $prodids = array(); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE tosell = 1"; - $sql.= " AND entity = ".$conf->entity; + $sql.= " WHERE entity = ".$conf->entity; $resql = $this->db->query($sql); if ($resql) { @@ -2890,27 +2889,30 @@ class Facture extends CommonObject $this->cond_reglement_code = 'RECEP'; $this->mode_reglement_id = 7; $this->mode_reglement_code = ''; // No particular payment mode defined - $this->note_public='SPECIMEN'; + $this->note_public='This is a comment (public)'; + $this->note='This is a comment (private)'; // Lines $nbp = 5; $xnbp = 0; while ($xnbp < $nbp) { - $ligne=new FactureLigne($this->db); - $ligne->desc=$langs->trans("Description")." ".$xnbp; - $ligne->qty=1; - $ligne->subprice=100; - $ligne->price=100; - $ligne->tva_tx=19.6; - $ligne->localtax1_tx=0; - $ligne->localtax2_tx=0; - $ligne->remise_percent=10; - $ligne->total_ht=90; - $ligne->total_ttc=107.64; // 90 * 1.196 - $ligne->total_tva=17.64; + $line=new FactureLigne($this->db); + $line->desc=$langs->trans("Description")." ".$xnbp; + $line->qty=1; + $line->subprice=100; + $line->price=100; + $line->tva_tx=19.6; + $line->localtax1_tx=0; + $line->localtax2_tx=0; + $line->remise_percent=10; + $line->total_ht=90; + $line->total_ttc=107.64; // 90 * 1.196 + $line->total_tva=17.64; $prodid = rand(1, $num_prods); - $ligne->fk_product=$prodids[$prodid]; - $this->lignes[$xnbp]=$ligne; + $line->fk_product=$prodids[$prodid]; + + $this->lines[$xnbp]=$line; + $xnbp++; } diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index 5783ca1bb01..715f4ac85f9 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -129,7 +129,7 @@ class CommandeFournisseur extends Commande $this->db->free($resql); if ($this->statut == 0) $this->brouillon = 1; - + $sql = "SELECT l.rowid, l.ref as ref_fourn, l.fk_product, l.product_type, l.label, l.description,"; $sql.= " l.qty,"; @@ -1417,8 +1417,8 @@ class CommandeFournisseur extends Commande /** - * \brief Initialise la commande avec valeurs fictives aleatoire - * Sert a generer une commande pour l'aperu des modeles ou demo + * Initialise an example of instance with random values + * Used to build previews or test instances */ function initAsSpecimen() { @@ -1426,35 +1426,11 @@ class CommandeFournisseur extends Commande dol_syslog("CommandeFournisseur::initAsSpecimen"); - // Charge tableau des id de societe socids - $socids = array(); - - $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe"; - $sql.= " WHERE fournisseur=1"; - $sql.= " AND entity = ".$conf->entity; - $sql.= " LIMIT 10"; - - $resql = $this->db->query($sql); - if ($resql) - { - $num_socs = $this->db->num_rows($resql); - $i = 0; - while ($i < $num_socs) - { - $i++; - - $row = $this->db->fetch_row($resql); - $socids[$i] = $row[0]; - } - } - // Charge tableau des produits prodids $prodids = array(); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE tobuy = 1"; $sql.= " AND entity = ".$conf->entity; $resql = $this->db->query($sql); @@ -1474,26 +1450,29 @@ class CommandeFournisseur extends Commande $this->id=0; $this->ref = 'SPECIMEN'; $this->specimen=1; - $socid = rand(1, $num_socs); - $this->socid = $socids[$socid]; + $this->socid = 1; $this->date = time(); $this->date_lim_reglement=$this->date+3600*24*30; $this->cond_reglement_code = 'RECEP'; $this->mode_reglement_code = 'CHQ'; - $this->note_public='SPECIMEN'; - $nbp = rand(3, 5); + $this->note_public='This is a comment (public)'; + $this->note='This is a comment (private)'; + // Lines + $nbp = 5; $xnbp = 0; while ($xnbp < $nbp) { - $ligne=new CommandeFournisseurLigne($this->db); - $ligne->desc=$langs->trans("Description")." ".$xnbp; - $ligne->qty=1; - $ligne->subprice=100; - $ligne->tva_tx=19.6; - $ligne->ref_fourn='SUPPLIER_REF_'.$xnbp; + $line=new CommandeFournisseurLigne($this->db); + $line->desc=$langs->trans("Description")." ".$xnbp; + $line->qty=1; + $line->subprice=100; + $line->tva_tx=19.6; + $line->ref_fourn='SUPPLIER_REF_'.$xnbp; $prodid = rand(1, $num_prods); - $ligne->fk_product=$prodids[$prodid]; - $this->lignes[$xnbp]=$ligne; + $line->fk_product=$prodids[$prodid]; + + $this->lines[$xnbp]=$line; + $xnbp++; } diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 75fe1b1a0dd..7c8ce40e3e9 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -968,42 +968,18 @@ class FactureFournisseur extends Facture /** - * \brief Initialise la facture avec valeurs fictives aleatoire - * Sert a generer une facture pour l'aperu des modeles ou demo + * Initialise an example of instance with random values + * Used to build previews or test instances */ function initAsSpecimen() { global $user,$langs,$conf; - // Charge tableau des id de societe socids - $socids = array(); - - $sql = "SELECT rowid"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe"; - $sql.= " WHERE fournisseur = 1"; - $sql.= " AND entity = ".$conf->entity; - $sql.= " LIMIT 10"; - - $resql = $this->db->query($sql); - if ($resql) - { - $num_socs = $this->db->num_rows($resql); - $i = 0; - while ($i < $num_socs) - { - $i++; - - $row = $this->db->fetch_row($resql); - $socids[$i] = $row[0]; - } - } - // Charge tableau des produits prodids $prodids = array(); $sql = "SELECT rowid"; $sql.= " FROM ".MAIN_DB_PREFIX."product"; - $sql.= " WHERE tobuy = 1"; $sql.= " AND entity = ".$conf->entity; $resql = $this->db->query($sql); @@ -1023,28 +999,29 @@ class FactureFournisseur extends Facture $this->id=0; $this->ref = 'SPECIMEN'; $this->specimen=1; - $socid = rand(1, $num_socs); - $this->socid = $socids[$socid]; + $this->socid = 1; $this->date = time(); $this->date_lim_reglement=$this->date+3600*24*30; $this->cond_reglement_code = 'RECEP'; $this->mode_reglement_code = 'CHQ'; - $this->note_public='SPECIMEN'; + $this->note_public='This is a comment (public)'; + $this->note='This is a comment (private)'; + // Lines $nbp = 5; $xnbp = 0; while ($xnbp < $nbp) { - $ligne=new FactureLigne($this->db); - $ligne->desc=$langs->trans("Description")." ".$xnbp; - $ligne->qty=1; - $ligne->subprice=100; - $ligne->price=100; - $ligne->tva_tx=19.6; + $line=new FactureLigne($this->db); + $line->desc=$langs->trans("Description")." ".$xnbp; + $line->qty=1; + $line->subprice=100; + $line->price=100; + $line->tva_tx=19.6; $prodid = rand(1, $num_prods); - $ligne->fk_product=$prodids[$prodid]; - $ligne->product_type=0; + $line->fk_product=$prodids[$prodid]; + $line->product_type=0; - $this->lignes[$xnbp]=$ligne; + $this->lines[$xnbp]=$line; $xnbp++; }