From e976645b08bfcbfc614c7c3035c4f8b554e36460 Mon Sep 17 00:00:00 2001 From: Juanjo Menent Date: Thu, 28 Oct 2010 08:43:53 +0000 Subject: [PATCH] Qual: Uniformize code (ligne -> line) --- .../fourn/class/fournisseur.facture.class.php | 78 +++++++++---------- htdocs/fourn/facture/fiche.php | 62 +++++++-------- .../pdf/pdf_canelle.modules.php | 20 ++--- 3 files changed, 79 insertions(+), 81 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 5f71540c547..9e05eb60909 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -74,8 +74,7 @@ class FactureFournisseur extends Facture var $note_public; var $propalid; - var $lignes; - var $lines; //For write pdf compatibility. + var $lines; var $fournisseur; /** @@ -102,8 +101,7 @@ class FactureFournisseur extends Facture $this->propalid = 0; $this->products = array(); - $this->lignes = array(); - $this->lines = array(); //For write pdf compatibility + $this->lines = array(); } /** @@ -158,7 +156,7 @@ class FactureFournisseur extends Facture if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn'); - foreach ($this->lignes as $i => $val) + foreach ($this->lines as $i => $val) { $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture_fourn_det (fk_facture_fourn)'; $sql .= ' VALUES ('.$this->id.');'; @@ -170,14 +168,14 @@ class FactureFournisseur extends Facture $idligne = $this->db->last_insert_id(MAIN_DB_PREFIX.'facture_fourn_det'); $this->updateline($idligne, - $this->lignes[$i]->description, - $this->lignes[$i]->pu_ht, - $this->lignes[$i]->tva_tx, - $this->lignes[$i]->qty, - $this->lignes[$i]->fk_product, + $this->lines[$i]->description, + $this->lines[$i]->pu_ht, + $this->lines[$i]->tva_tx, + $this->lines[$i]->qty, + $this->lines[$i]->fk_product, 'HT', - $this->lignes[$i]->info_bits, - $this->lignes[$i]->product_type + $this->lines[$i]->info_bits, + $this->lines[$i]->product_type ); } } @@ -313,7 +311,7 @@ class FactureFournisseur extends Facture /** - * \brief Load this->lignes + * \brief Load this->lines * \return int 1 si ok, < 0 si erreur */ function fetch_lines() @@ -338,23 +336,23 @@ class FactureFournisseur extends Facture while ($i < $num_rows) { $obj = $this->db->fetch_object($resql_rows); - $this->lignes[$i]->rowid = $obj->rowid; - $this->lignes[$i]->description = $obj->description; - $this->lignes[$i]->ref = $obj->ref; // Reference interne du produit - //$this->lignes[$i]->ref_fourn = $obj->ref_fourn; // Reference fournisseur du produit - $this->lignes[$i]->libelle = $obj->label; // Label du produit - $this->lignes[$i]->product_desc = $obj->product_desc; // Description du produit - $this->lignes[$i]->pu_ht = $obj->pu_ht; - $this->lignes[$i]->pu_ttc = $obj->pu_ttc; - $this->lignes[$i]->tva_tx = $obj->tva_tx; - $this->lignes[$i]->qty = $obj->qty; - $this->lignes[$i]->tva = $obj->tva; - $this->lignes[$i]->total_ht = $obj->total_ht; - $this->lignes[$i]->total_tva = $obj->total_tva; - $this->lignes[$i]->total_ttc = $obj->total_ttc; - $this->lignes[$i]->fk_product = $obj->fk_product; - $this->lignes[$i]->product_type = $obj->product_type; - $this->lines[$i] = $this->lignes[$i]; //For write pdf compatibility. + $this->lines[$i]->rowid = $obj->rowid; + $this->lines[$i]->description = $obj->description; + $this->lines[$i]->ref = $obj->ref; // Reference interne du produit + //$this->lines[$i]->ref_fourn = $obj->ref_fourn; // Reference fournisseur du produit + $this->lines[$i]->libelle = $obj->label; // Label du produit + $this->lines[$i]->product_desc = $obj->product_desc; // Description du produit + $this->lines[$i]->pu_ht = $obj->pu_ht; + $this->lines[$i]->pu_ttc = $obj->pu_ttc; + $this->lines[$i]->tva_tx = $obj->tva_tx; + $this->lines[$i]->qty = $obj->qty; + $this->lines[$i]->tva = $obj->tva; + $this->lines[$i]->total_ht = $obj->total_ht; + $this->lines[$i]->total_tva = $obj->total_tva; + $this->lines[$i]->total_ttc = $obj->total_ttc; + $this->lines[$i]->fk_product = $obj->fk_product; + $this->lines[$i]->product_type = $obj->product_type; + $i++; } } @@ -601,14 +599,14 @@ class FactureFournisseur extends Facture { require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"); - for ($i = 0 ; $i < sizeof($this->lignes) ; $i++) + for ($i = 0 ; $i < sizeof($this->lines) ; $i++) { - if ($this->lignes[$i]->fk_product && $this->lignes[$i]->product_type == 0) + if ($this->lines[$i]->fk_product && $this->lines[$i]->product_type == 0) { $mouvP = new MouvementStock($this->db); // We increase stock for product $entrepot_id = "1"; // TODO ajouter possibilite de choisir l'entrepot - $result=$mouvP->reception($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty, $this->lignes[$i]->pu_ht); + $result=$mouvP->reception($user, $this->lines[$i]->fk_product, $entrepot_id, $this->lines[$i]->qty, $this->lines[$i]->pu_ht); if ($result < 0) { $error++; } } } @@ -675,14 +673,14 @@ class FactureFournisseur extends Facture { require_once(DOL_DOCUMENT_ROOT."/product/stock/class/mouvementstock.class.php"); - for ($i = 0 ; $i < sizeof($this->lignes) ; $i++) + for ($i = 0 ; $i < sizeof($this->lines) ; $i++) { - if ($this->lignes[$i]->fk_product && $this->lignes[$i]->product_type == 0) + if ($this->lines[$i]->fk_product && $this->lines[$i]->product_type == 0) { $mouvP = new MouvementStock($this->db); // We increase stock for product $entrepot_id = "1"; // TODO ajouter possibilite de choisir l'entrepot - $result=$mouvP->livraison($user, $this->lignes[$i]->fk_product, $entrepot_id, $this->lignes[$i]->qty, $this->lignes[$i]->subprice); + $result=$mouvP->livraison($user, $this->lines[$i]->fk_product, $entrepot_id, $this->lines[$i]->qty, $this->lines[$i]->subprice); } } } @@ -718,7 +716,7 @@ class FactureFournisseur extends Facture * \param date_start Date de debut de validite du service * \param date_end Date de fin de validite du service * \param ventil Code de ventilation comptable - * \param info_bits Bits de type de lignes + * \param info_bits Bits de type de lines * \param price_base_type HT ou TTC * \param type Type of line (0=product, 1=service) * \remarks Les parametres sont deja cense etre juste et avec valeurs finales a l'appel @@ -1077,11 +1075,11 @@ class FactureFournisseur extends Facture $object->close_note = ''; // Loop on each line of new invoice - foreach($object->lignes as $i => $line) + foreach($object->lines as $i => $line) { - if (($object->lignes[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts + if (($object->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts { - unset($object->lignes[$i]); + unset($object->lines[$i]); } } diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 0d1dc33b997..ecff8ad3ec8 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -995,7 +995,7 @@ else print '
'; print ''; $var=1; - for ($i = 0 ; $i < sizeof($fac->lignes) ; $i++) + for ($i = 0 ; $i < sizeof($fac->lines) ; $i++) { if ($i == 0) { @@ -1012,29 +1012,29 @@ else } // Show product and description - $type=$fac->lignes[$i]->product_type?$fac->lignes[$i]->product_type:$fac->lignes[$i]->fk_product_type; + $type=$fac->lines[$i]->product_type?$fac->lines[$i]->product_type:$fac->lines[$i]->fk_product_type; // Try to enhance type detection using date_start and date_end for free lines where type // was not saved. - if (! empty($fac->lignes[$i]->date_start)) $type=1; - if (! empty($fac->lignes[$i]->date_end)) $type=1; + if (! empty($fac->lines[$i]->date_start)) $type=1; + if (! empty($fac->lines[$i]->date_end)) $type=1; $var=!$var; // Edit line - if ($fac->statut == 0 && $_GET['action'] == 'mod_ligne' && $_GET['etat'] == '0' && $_GET['ligne_id'] == $fac->lignes[$i]->rowid) + if ($fac->statut == 0 && $_GET['action'] == 'mod_ligne' && $_GET['etat'] == '0' && $_GET['ligne_id'] == $fac->lines[$i]->rowid) { - print ''; + print ''; print ''; print ''; print ''; // Show product and description print ''; // VAT print ''; // Unit price - print ''; + print ''; print ''; - print ''; + print ''; print ''; @@ -1082,57 +1082,57 @@ else // Show product and description print ''; // VAT - print ''; + print ''; // Unit price - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; - print ''; + print ''; print ''; print ''; @@ -1285,7 +1285,7 @@ else if ($_GET['action'] != 'edit' && $fac->statut == 0) { - if (sizeof($fac->lignes)) + if (sizeof($fac->lines)) { if ($user->rights->fournisseur->facture->valider) { diff --git a/htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php b/htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php index 5478601ec50..403fa2bd553 100755 --- a/htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php +++ b/htdocs/includes/modules/supplier_invoice/pdf/pdf_canelle.modules.php @@ -139,7 +139,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices if (file_exists($dir)) { - $nblignes = sizeof($object->lignes); + $nblignes = sizeof($object->lines); // Protection et encryption du pdf if ($conf->global->PDF_SECURITY_ENCRYPTION) @@ -233,33 +233,33 @@ class pdf_canelle extends ModelePDFSuppliersInvoices // TVA $pdf->SetXY ($this->posxtva, $curY); - $pdf->MultiCell(10, 3, ($object->lignes[$i]->tva_tx < 0 ? '*':'').abs($object->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($object->lignes[$i]->pu_ht), 0, 'R', 0); + $pdf->MultiCell(18, 3, price($object->lines[$i]->pu_ht), 0, 'R', 0); // Quantity $pdf->SetXY ($this->posxqty, $curY); - $pdf->MultiCell(10, 3, $object->lignes[$i]->qty, 0, 'R'); + $pdf->MultiCell(10, 3, $object->lines[$i]->qty, 0, 'R'); // Discount on line $pdf->SetXY ($this->posxdiscount, $curY); - if ($object->lignes[$i]->remise_percent) + if ($object->lines[$i]->remise_percent) { - $pdf->MultiCell(14, 3, $object->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($object->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=$object->lignes[$i]->total_tva; + $tvaligne=$object->lines[$i]->total_tva; if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; - $vatrate=(string) $object->lignes[$i]->tva_tx; - if (($object->lignes[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; + $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
'; - if (($conf->product->enabled || $conf->service->enabled) && $fac->lignes[$i]->fk_product) + if (($conf->product->enabled || $conf->service->enabled) && $fac->lines[$i]->fk_product) { - print ''; + print ''; $product_static=new ProductFournisseur($db); - $product_static->fetch($fac->lignes[$i]->fk_product); + $product_static->fetch($fac->lines[$i]->fk_product); $text=$product_static->getNomUrl(1); $text.= ' - '.$product_static->libelle; print $text; @@ -1042,7 +1042,7 @@ else } else { - print $html->select_type_of_lines($fac->lignes[$i]->product_type,'type',1); + print $html->select_type_of_lines($fac->lines[$i]->product_type,'type',1); if ($conf->product->enabled && $conf->service->enabled) print '
'; } @@ -1050,21 +1050,21 @@ else require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php"); $nbrows=ROWS_2; if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; - $doleditor=new DolEditor('label',$fac->lignes[$i]->description,200,'dolibarr_details','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); + $doleditor=new DolEditor('label',$fac->lines[$i]->description,200,'dolibarr_details','',false,true,$conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS,$nbrows,70); $doleditor->Create(); print '
'; - $html->select_tva('tauxtva',$fac->lignes[$i]->tva_tx,$societe,$mysoc); + $html->select_tva('tauxtva',$fac->lines[$i]->tva_tx,$societe,$mysoc); print ' '; - if ($fac->lignes[$i]->fk_product) + if ($fac->lines[$i]->fk_product) { print ''; // ancre pour retourner sur la ligne $product_static=new ProductFournisseur($db); - $product_static->fetch($fac->lignes[$i]->fk_product); + $product_static->fetch($fac->lines[$i]->fk_product); $text=$product_static->getNomUrl(1); $text.= ' - '.$product_static->libelle; - $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($fac->lignes[$i]->description)); + $description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($fac->lines[$i]->description)); print $html->textwithtooltip($text,$description,3,'','',$i); // Show range - print_date_range($fac->lignes[$i]->date_start,$fac->lignes[$i]->date_end); + print_date_range($fac->lines[$i]->date_start,$fac->lines[$i]->date_end); // Add description in form - if ($conf->global->PRODUIT_DESC_IN_FORM) print ($fac->lignes[$i]->description && $fac->lignes[$i]->description!=$product_static->libelle)?'
'.dol_htmlentitiesbr($fac->lignes[$i]->description):''; + if ($conf->global->PRODUIT_DESC_IN_FORM) print ($fac->lines[$i]->description && $fac->lines[$i]->description!=$product_static->libelle)?'
'.dol_htmlentitiesbr($fac->lines[$i]->description):''; } // Description - Editor wysiwyg - if (! $fac->lignes[$i]->fk_product) + if (! $fac->lines[$i]->fk_product) { if ($type==1) $text = img_object($langs->trans('Service'),'service'); else $text = img_object($langs->trans('Product'),'product'); - print $text.' '.nl2br($fac->lignes[$i]->description); + print $text.' '.nl2br($fac->lines[$i]->description); // Show range - print_date_range($fac->lignes[$i]->date_start,$fac->lignes[$i]->date_end); + print_date_range($fac->lines[$i]->date_start,$fac->lines[$i]->date_end); } print '
'.vatrate($fac->lignes[$i]->tva_tx).'%'.vatrate($fac->lines[$i]->tva_tx).'%'.price($fac->lignes[$i]->pu_ht,'MU').''.price($fac->lines[$i]->pu_ht,'MU').''.($fac->lignes[$i]->pu_ttc?price($fac->lignes[$i]->pu_ttc,'MU'):' ').''.($fac->lines[$i]->pu_ttc?price($fac->lines[$i]->pu_ttc,'MU'):' ').''.$fac->lignes[$i]->qty.''.$fac->lines[$i]->qty.''.price($fac->lignes[$i]->total_ht).''.price($fac->lines[$i]->total_ht).''.price($fac->lignes[$i]->total_ttc).''.price($fac->lines[$i]->total_ttc).''; - if ($fac->statut == 0) print ''.img_edit().''; + if ($fac->statut == 0) print ''.img_edit().''; else print ' '; print ''; - if ($fac->statut == 0) print ''.img_delete().''; + if ($fac->statut == 0) print ''.img_delete().''; else print ' '; print '