Qual: Uniformize code (ligne -> line)
This commit is contained in:
parent
996c6ceaff
commit
e976645b08
@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -995,7 +995,7 @@ else
|
||||
print '<br>';
|
||||
print '<table class="noborder" width="100%">';
|
||||
$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 '<form action="fiche.php?facid='.$fac->id.'&etat=1&ligne_id='.$fac->lignes[$i]->rowid.'" method="post">';
|
||||
print '<form action="fiche.php?facid='.$fac->id.'&etat=1&ligne_id='.$fac->lines[$i]->rowid.'" method="post">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="update_line">';
|
||||
print '<tr '.$bc[$var].'>';
|
||||
|
||||
// Show product and description
|
||||
print '<td>';
|
||||
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 '<input type="hidden" name="idprod" value="'.$fac->lignes[$i]->fk_product.'">';
|
||||
print '<input type="hidden" name="idprod" value="'.$fac->lines[$i]->fk_product.'">';
|
||||
$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 '<br>';
|
||||
}
|
||||
|
||||
@ -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 '</td>';
|
||||
|
||||
// VAT
|
||||
print '<td align="right">';
|
||||
$html->select_tva('tauxtva',$fac->lignes[$i]->tva_tx,$societe,$mysoc);
|
||||
$html->select_tva('tauxtva',$fac->lines[$i]->tva_tx,$societe,$mysoc);
|
||||
print '</td>';
|
||||
|
||||
// Unit price
|
||||
print '<td align="right" nowrap="nowrap"><input size="4" name="puht" type="text" value="'.price($fac->lignes[$i]->pu_ht).'"></td>';
|
||||
print '<td align="right" nowrap="nowrap"><input size="4" name="puht" type="text" value="'.price($fac->lines[$i]->pu_ht).'"></td>';
|
||||
|
||||
print '<td align="right" nowrap="nowrap"><input size="4" name="puttc" type="text" value=""></td>';
|
||||
|
||||
print '<td align="right"><input size="1" name="qty" type="text" value="'.$fac->lignes[$i]->qty.'"></td>';
|
||||
print '<td align="right"><input size="1" name="qty" type="text" value="'.$fac->lines[$i]->qty.'"></td>';
|
||||
|
||||
print '<td align="right" nowrap="nowrap"> </td>';
|
||||
|
||||
@ -1082,57 +1082,57 @@ else
|
||||
|
||||
// Show product and description
|
||||
print '<td>';
|
||||
if ($fac->lignes[$i]->fk_product)
|
||||
if ($fac->lines[$i]->fk_product)
|
||||
{
|
||||
print '<a name="'.$objp->rowid.'"></a>'; // 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)?'<br>'.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)?'<br>'.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 '</td>';
|
||||
|
||||
// VAT
|
||||
print '<td align="right">'.vatrate($fac->lignes[$i]->tva_tx).'%</td>';
|
||||
print '<td align="right">'.vatrate($fac->lines[$i]->tva_tx).'%</td>';
|
||||
|
||||
// Unit price
|
||||
print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->pu_ht,'MU').'</td>';
|
||||
print '<td align="right" nowrap="nowrap">'.price($fac->lines[$i]->pu_ht,'MU').'</td>';
|
||||
|
||||
print '<td align="right" nowrap="nowrap">'.($fac->lignes[$i]->pu_ttc?price($fac->lignes[$i]->pu_ttc,'MU'):' ').'</td>';
|
||||
print '<td align="right" nowrap="nowrap">'.($fac->lines[$i]->pu_ttc?price($fac->lines[$i]->pu_ttc,'MU'):' ').'</td>';
|
||||
|
||||
print '<td align="right">'.$fac->lignes[$i]->qty.'</td>';
|
||||
print '<td align="right">'.$fac->lines[$i]->qty.'</td>';
|
||||
|
||||
print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->total_ht).'</td>';
|
||||
print '<td align="right" nowrap="nowrap">'.price($fac->lines[$i]->total_ht).'</td>';
|
||||
|
||||
print '<td align="right" nowrap="nowrap">'.price($fac->lignes[$i]->total_ttc).'</td>';
|
||||
print '<td align="right" nowrap="nowrap">'.price($fac->lines[$i]->total_ttc).'</td>';
|
||||
|
||||
print '<td align="center" width="16">';
|
||||
if ($fac->statut == 0) print '<a href="fiche.php?facid='.$fac->id.'&action=mod_ligne&etat=0&ligne_id='.$fac->lignes[$i]->rowid.'">'.img_edit().'</a>';
|
||||
if ($fac->statut == 0) print '<a href="fiche.php?facid='.$fac->id.'&action=mod_ligne&etat=0&ligne_id='.$fac->lines[$i]->rowid.'">'.img_edit().'</a>';
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
|
||||
print '<td align="center" width="16">';
|
||||
if ($fac->statut == 0) print '<a href="fiche.php?facid='.$fac->id.'&action=confirm_delete_line&ligne_id='.$fac->lignes[$i]->rowid.'">'.img_delete().'</a>';
|
||||
if ($fac->statut == 0) print '<a href="fiche.php?facid='.$fac->id.'&action=confirm_delete_line&ligne_id='.$fac->lines[$i]->rowid.'">'.img_delete().'</a>';
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user