Qual: uniformize code

This commit is contained in:
Regis Houssin 2010-09-09 06:00:52 +00:00
parent 1918fb582e
commit 24962e786a

View File

@ -105,7 +105,7 @@ class pdf_propale_azur extends ModelePDFPropales
* \param outputlangs Lang object for output language * \param outputlangs Lang object for output language
* \return int 1=ok, 0=ko * \return int 1=ok, 0=ko
*/ */
function write_file($propale,$outputlangs) function write_file($object,$outputlangs)
{ {
global $user,$langs,$conf; global $user,$langs,$conf;
@ -123,25 +123,25 @@ class pdf_propale_azur extends ModelePDFPropales
if ($conf->propale->dir_output) if ($conf->propale->dir_output)
{ {
// Definition de l'objet $propale (pour compatibilite ascendante) // Definition de l'objet $object (pour compatibilite ascendante)
if (! is_object($propale)) if (! is_object($object))
{ {
$id = $propale; $id = $object;
$propale = new Propal($this->db,"",$id); $object = new Propal($this->db,"",$id);
$ret=$propale->fetch($id); $ret=$object->fetch($id);
} }
$propale->fetch_thirdparty(); $object->fetch_thirdparty();
$deja_regle = ""; $deja_regle = "";
// Definition de $dir et $file // Definition de $dir et $file
if ($propale->specimen) if ($object->specimen)
{ {
$dir = $conf->propale->dir_output; $dir = $conf->propale->dir_output;
$file = $dir . "/SPECIMEN.pdf"; $file = $dir . "/SPECIMEN.pdf";
} }
else else
{ {
$propref = dol_sanitizeFileName($propale->ref); $propref = dol_sanitizeFileName($object->ref);
$dir = $conf->propale->dir_output . "/" . $propref; $dir = $conf->propale->dir_output . "/" . $propref;
$file = $dir . "/" . $propref . ".pdf"; $file = $dir . "/" . $propref . ".pdf";
} }
@ -157,7 +157,7 @@ class pdf_propale_azur extends ModelePDFPropales
if (file_exists($dir)) if (file_exists($dir))
{ {
$nblignes = sizeof($propale->lignes); $nblignes = sizeof($object->lines);
// Protection et encryption du pdf // Protection et encryption du pdf
if ($conf->global->PDF_SECURITY_ENCRYPTION) if ($conf->global->PDF_SECURITY_ENCRYPTION)
@ -184,11 +184,11 @@ class pdf_propale_azur extends ModelePDFPropales
$pagenb=0; $pagenb=0;
$pdf->SetDrawColor(128,128,128); $pdf->SetDrawColor(128,128,128);
$pdf->SetTitle($outputlangs->convToOutputCharset($propale->ref)); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
$pdf->SetSubject($outputlangs->transnoentities("CommercialProposal")); $pdf->SetSubject($outputlangs->transnoentities("CommercialProposal"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $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); if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false);
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
@ -197,7 +197,7 @@ class pdf_propale_azur extends ModelePDFPropales
// Positionne $this->atleastonediscount si on a au moins une remise // Positionne $this->atleastonediscount si on a au moins une remise
for ($i = 0 ; $i < $nblignes ; $i++) for ($i = 0 ; $i < $nblignes ; $i++)
{ {
if ($propale->lignes[$i]->remise_percent) if ($object->lines[$i]->remise_percent)
{ {
$this->atleastonediscount++; $this->atleastonediscount++;
} }
@ -206,7 +206,7 @@ class pdf_propale_azur extends ModelePDFPropales
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
$pagenb++; $pagenb++;
$this->_pagehead($pdf, $propale, 1, $outputlangs); $this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('','', 9); $pdf->SetFont('','', 9);
$pdf->MultiCell(0, 4, '', 0, 'J'); // Set interline to 4 $pdf->MultiCell(0, 4, '', 0, 'J'); // Set interline to 4
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
@ -219,13 +219,13 @@ class pdf_propale_azur extends ModelePDFPropales
$tab_height_newpage = 150; $tab_height_newpage = 150;
// Affiche notes // Affiche notes
if (! empty($propale->note_public)) if (! empty($object->note_public))
{ {
$tab_top = 88; $tab_top = 88;
$pdf->SetFont('','', 9); // Dans boucle pour gerer multi-page $pdf->SetFont('','', 9); // Dans boucle pour gerer multi-page
$pdf->SetXY ($this->posxdesc-1, $tab_top); $pdf->SetXY ($this->posxdesc-1, $tab_top);
$pdf->MultiCell(190, 4, $outputlangs->convToOutputCharset($propale->note_public), 0, 'J'); $pdf->MultiCell(190, 4, $outputlangs->convToOutputCharset($object->note_public), 0, 'J');
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$height_note=$nexY-$tab_top; $height_note=$nexY-$tab_top;
@ -251,7 +251,7 @@ class pdf_propale_azur extends ModelePDFPropales
$curY = $nexY; $curY = $nexY;
// Description de la ligne produit // Description de la ligne produit
$libelleproduitservice=pdf_getlinedesc($propale->lignes[$i],$outputlangs); $libelleproduitservice=pdf_getlinedesc($object->lines[$i],$outputlangs);
$pdf->SetFont('','', 9); // Dans boucle pour gerer multi-page $pdf->SetFont('','', 9); // Dans boucle pour gerer multi-page
@ -265,51 +265,51 @@ class pdf_propale_azur extends ModelePDFPropales
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{ {
$pdf->SetXY ($this->posxtva, $curY); $pdf->SetXY ($this->posxtva, $curY);
$pdf->MultiCell($this->posxup-$this->posxtva-1, 4, vatrate($propale->lignes[$i]->tva_tx,1,$propale->lignes[$i]->info_bits), 0, 'R'); $pdf->MultiCell($this->posxup-$this->posxtva-1, 4, vatrate($object->lines[$i]->tva_tx,1,$object->lines[$i]->info_bits), 0, 'R');
} }
// Prix unitaire HT avant remise // Prix unitaire HT avant remise
$pdf->SetXY ($this->posxup, $curY); $pdf->SetXY ($this->posxup, $curY);
$pdf->MultiCell($this->posxqty-$this->posxup-1, 4, price($propale->lignes[$i]->subprice), 0, 'R', 0); $pdf->MultiCell($this->posxqty-$this->posxup-1, 4, price($object->lines[$i]->subprice), 0, 'R', 0);
// Quantity // Quantity
$pdf->SetXY ($this->posxqty, $curY); $pdf->SetXY ($this->posxqty, $curY);
if ($propale->lignes[$i]->special_code != 3) $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 4, $propale->lignes[$i]->qty, 0, 'R'); if ($object->lines[$i]->special_code != 3) $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 4, $object->lines[$i]->qty, 0, 'R');
// Remise sur ligne // Remise sur ligne
$pdf->SetXY ($this->posxdiscount, $curY); $pdf->SetXY ($this->posxdiscount, $curY);
if ($propale->lignes[$i]->remise_percent && $propale->lignes[$i]->special_code != 3) if ($object->lines[$i]->remise_percent && $object->lines[$i]->special_code != 3)
{ {
$pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 4, dol_print_reduction($propale->lignes[$i]->remise_percent,$outputlangs), 0, 'R'); $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 4, dol_print_reduction($object->lines[$i]->remise_percent,$outputlangs), 0, 'R');
} }
// Total HT ligne // Total HT ligne
$pdf->SetXY ($this->postotalht, $curY); $pdf->SetXY ($this->postotalht, $curY);
if ($propale->lignes[$i]->special_code == 3) if ($object->lines[$i]->special_code == 3)
{ {
// Ligne produit en option // Ligne produit en option
$pdf->MultiCell(26, 4, $outputlangs->transnoentities("Option"), 0, 'R', 0); $pdf->MultiCell(26, 4, $outputlangs->transnoentities("Option"), 0, 'R', 0);
} }
else else
{ {
$total = price($propale->lignes[$i]->total_ht); $total = price($object->lines[$i]->total_ht);
$pdf->MultiCell(26, 4, $total, 0, 'R', 0); $pdf->MultiCell(26, 4, $total, 0, 'R', 0);
} }
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
$tvaligne=$propale->lignes[$i]->total_tva; $tvaligne=$object->lines[$i]->total_tva;
$localtax1ligne=$propale->lignes[$i]->total_localtax1; $localtax1ligne=$object->lines[$i]->total_localtax1;
$localtax2ligne=$propale->lignes[$i]->total_localtax2; $localtax2ligne=$object->lines[$i]->total_localtax2;
if ($propale->remise_percent) $tvaligne-=($tvaligne*$propale->remise_percent)/100; if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
if ($propale->remise_percent) $localtax1ligne-=($localtax1ligne*$propale->remise_percent)/100; if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
if ($propale->remise_percent) $localtax2ligne-=($localtax2ligne*$propale->remise_percent)/100; if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;
$vatrate=(string) $propale->lignes[$i]->tva_tx; $vatrate=(string) $object->lines[$i]->tva_tx;
$localtax1rate=(string) $propale->lignes[$i]->localtax1_tx; $localtax1rate=(string) $object->lines[$i]->localtax1_tx;
$localtax2rate=(string) $propale->lignes[$i]->localtax2_tx; $localtax2rate=(string) $object->lines[$i]->localtax2_tx;
if (($propale->lignes[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
$this->tva[$vatrate] += $tvaligne; $this->tva[$vatrate] += $tvaligne;
$this->localtax1[$localtax1rate]+=$localtax1ligne; $this->localtax1[$localtax1rate]+=$localtax1ligne;
@ -321,7 +321,7 @@ class pdf_propale_azur extends ModelePDFPropales
if ($i < ($nblignes - 1)) // If it's not last line if ($i < ($nblignes - 1)) // If it's not last line
{ {
//on recupere la description du produit suivant //on recupere la description du produit suivant
$follow_descproduitservice = $propale->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) //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); $nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4);
} }
@ -352,12 +352,12 @@ class pdf_propale_azur extends ModelePDFPropales
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs);
} }
$this->_pagefoot($pdf,$propale,$outputlangs); $this->_pagefoot($pdf,$object,$outputlangs);
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
$pagenb++; $pagenb++;
$this->_pagehead($pdf, $propale, 0, $outputlangs); $this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->SetFont('','', 9); $pdf->SetFont('','', 9);
$pdf->MultiCell(0, 4, '', 0, 'J'); // Set interline to 3 $pdf->MultiCell(0, 4, '', 0, 'J'); // Set interline to 3
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
@ -380,19 +380,19 @@ class pdf_propale_azur extends ModelePDFPropales
} }
// Affiche zone infos // Affiche zone infos
$posy=$this->_tableau_info($pdf, $propale, $bottomlasttab, $outputlangs); $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
// Affiche zone totaux // Affiche zone totaux
$posy=$this->_tableau_tot($pdf, $propale, $deja_regle, $bottomlasttab, $outputlangs); $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
// Affiche zone versements // Affiche zone versements
if ($deja_regle) if ($deja_regle)
{ {
$posy=$this->_tableau_versements($pdf, $propale, $posy, $outputlangs); $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
} }
// Pied de page // Pied de page
$this->_pagefoot($pdf,$propale,$outputlangs); $this->_pagefoot($pdf,$object,$outputlangs);
$pdf->AliasNbPages(); $pdf->AliasNbPages();
$pdf->Close(); $pdf->Close();