Fix: Long name wrapping. Sender address is third party for supplier

order/invoice
This commit is contained in:
Laurent Destailleur 2012-04-07 21:34:42 +02:00
parent f482ba18c3
commit e9292515bc
5 changed files with 213 additions and 166 deletions

View File

@ -34,8 +34,7 @@ require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php');
/** /**
* \class pdf_einstein * Classe permettant de generer les commandes au modele Einstein
* \brief Classe permettant de generer les commandes au modele Einstein
*/ */
class pdf_einstein extends ModelePDFCommandes class pdf_einstein extends ModelePDFCommandes
{ {
@ -91,16 +90,16 @@ class pdf_einstein extends ModelePDFCommandes
$this->option_condreg = 1; // Affiche conditions reglement $this->option_condreg = 1; // Affiche conditions reglement
$this->option_codeproduitservice = 1; // Affiche code produit-service $this->option_codeproduitservice = 1; // Affiche code produit-service
$this->option_multilang = 1; // Dispo en plusieurs langues $this->option_multilang = 1; // Dispo en plusieurs langues
$this->option_escompte = 1; // Affiche si il y a eu escompte $this->option_escompte = 0; // Affiche si il y a eu escompte
$this->option_credit_note = 1; // Support credit notes $this->option_credit_note = 0; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text $this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 1; //Support add of a watermark on drafts $this->option_draft_watermark = 1; // Support add of a watermark on drafts
$this->franchise=!$mysoc->tva_assuj; $this->franchise=!$mysoc->tva_assuj;
// Recupere emmetteur // Get source company
$this->emetteur=$mysoc; $this->emetteur=$mysoc;
if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // By default, if was not defined if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined
// Defini position des colonnes // Defini position des colonnes
$this->posxdesc=$this->marge_gauche+1; $this->posxdesc=$this->marge_gauche+1;
@ -118,7 +117,7 @@ class pdf_einstein extends ModelePDFCommandes
} }
/** /**
* Function to build pdf onto disk * Build document onto disk
* *
* @param int $object Id of object to generate * @param int $object Id of object to generate
* @param object $outputlangs Lang output object * @param object $outputlangs Lang output object
@ -235,12 +234,12 @@ class pdf_einstein extends ModelePDFCommandes
{ {
$tab_top = 88; $tab_top = 88;
$pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page $pdf->SetFont('','', $default_font_size - 1); // Into loop to manage multipages
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, $outputlangs->convToOutputCharset($object->note_public), 0, 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, $outputlangs->convToOutputCharset($object->note_public), 0, 1);
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$height_note=$nexY-$tab_top; $height_note=$nexY-$tab_top;
// Rect prend une longueur en 3eme et 4eme param // Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192); $pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
@ -261,16 +260,16 @@ class pdf_einstein extends ModelePDFCommandes
{ {
$curY = $nexY; $curY = $nexY;
$pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
// Description of product line // Description of product line
$curX = $this->posxdesc-1; $curX = $this->posxdesc-1;
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
// TVA // VAT Rate
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{ {
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager); $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager);
@ -278,7 +277,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R');
} }
// Prix unitaire HT avant remise // Unit price before discount
$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager); $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY($this->posxup, $curY); $pdf->SetXY($this->posxup, $curY);
$pdf->MultiCell($this->posxqty-$this->posxup-1, 3, $up_excl_tax, 0, 'R', 0); $pdf->MultiCell($this->posxqty-$this->posxup-1, 3, $up_excl_tax, 0, 'R', 0);
@ -288,7 +287,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetXY($this->posxqty, $curY); $pdf->SetXY($this->posxqty, $curY);
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $qty, 0, 'R'); $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $qty, 0, 'R');
// Remise sur ligne // Discount on line
$pdf->SetXY($this->posxdiscount, $curY); $pdf->SetXY($this->posxdiscount, $curY);
if ($object->lines[$i]->remise_percent) if ($object->lines[$i]->remise_percent)
{ {
@ -296,10 +295,10 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent, 0, 'R'); $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, $remise_percent, 0, 'R');
} }
// Total HT ligne // Total HT line
$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager); $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY($this->postotalht, $curY); $pdf->SetXY($this->postotalht, $curY);
$pdf->MultiCell(26, 3, $total_excl_tax, 0, 'R', 0); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 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=$object->lines[$i]->total_tva; $tvaligne=$object->lines[$i]->total_tva;
@ -307,6 +306,10 @@ class pdf_einstein extends ModelePDFCommandes
$localtax1ligne=$object->lines[$i]->total_localtax1; $localtax1ligne=$object->lines[$i]->total_localtax1;
$localtax2ligne=$object->lines[$i]->total_localtax2; $localtax2ligne=$object->lines[$i]->total_localtax2;
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) $object->lines[$i]->tva_tx; $vatrate=(string) $object->lines[$i]->tva_tx;
$localtax1rate=(string) $object->lines[$i]->localtax1_tx; $localtax1rate=(string) $object->lines[$i]->localtax1_tx;
$localtax2rate=(string) $object->lines[$i]->localtax2_tx; $localtax2rate=(string) $object->lines[$i]->localtax2_tx;
@ -405,7 +408,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->Output($file,'F'); $pdf->Output($file,'F');
// Actions on extra fields (by external module or standard code) // Add pdfgeneration hook
if (! is_object($hookmanager)) if (! is_object($hookmanager))
{ {
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'); include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
@ -647,7 +650,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
} }
} }
if (! $this->atleastoneratenotnull) // If not vat at all if (! $this->atleastoneratenotnull) // If no vat at all
{ {
$index++; $index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@ -661,7 +664,7 @@ class pdf_einstein extends ModelePDFCommandes
{ {
$index++; $index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code), $useborder, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->country_code), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1);
} }
@ -671,7 +674,7 @@ class pdf_einstein extends ModelePDFCommandes
{ {
$index++; $index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code), $useborder, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->country_code), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1);
} }
@ -696,7 +699,7 @@ class pdf_einstein extends ModelePDFCommandes
$tvakey=str_replace('*','',$tvakey); $tvakey=str_replace('*','',$tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
} }
$totalvat =$outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' '; $totalvat =$outputlangs->transnoentities("TotalLT1".$mysoc->country_code).' ';
$totalvat.=vatrate($tvakey,1).$tvacompl; $totalvat.=vatrate($tvakey,1).$tvacompl;
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
@ -724,7 +727,7 @@ class pdf_einstein extends ModelePDFCommandes
$tvakey=str_replace('*','',$tvakey); $tvakey=str_replace('*','',$tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
} }
$totalvat =$outputlangs->transnoentities("TotalLT2".$mysoc->pays_code).' '; $totalvat =$outputlangs->transnoentities("TotalLT2".$mysoc->country_code).' ';
$totalvat.=vatrate($tvakey,1).$tvacompl; $totalvat.=vatrate($tvakey,1).$tvacompl;
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
@ -748,6 +751,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1);
} }
$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
if ($deja_regle > 0) if ($deja_regle > 0)
@ -762,7 +766,6 @@ class pdf_einstein extends ModelePDFCommandes
$resteapayer = $object->total_ttc - $deja_regle; $resteapayer = $object->total_ttc - $deja_regle;
$index++; $index++;
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
$pdf->SetFillColor(224,224,224); $pdf->SetFillColor(224,224,224);
@ -772,7 +775,6 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
// Fin
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
} }

View File

@ -19,15 +19,14 @@
/** /**
* \file htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php * \file htdocs/core/modules/supplier_invoice/modules_facturefournisseur.php
* \ingroup facture fourniseur * \ingroup facture fournisseur
* \brief File that contain parent class for supplier invoices models * \brief File that contain parent class for supplier invoices models
*/ */
require_once(DOL_DOCUMENT_ROOT."/core/class/commondocgenerator.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/commondocgenerator.class.php");
/** /**
* \class ModelePDFSuppliersInvoices * Parent class for supplier invoices models
* \brief Parent class for supplier invoices models
*/ */
abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator
{ {
@ -57,15 +56,18 @@ abstract class ModelePDFSuppliersInvoices extends CommonDocGenerator
} }
/** /**
* Create object on disk. * Create a document onto disk according to template module.
* *
* @param DoliDB $db objet base de donnee * @param DoliDB $db Database handler
* @param Object $object object supplier invoice * @param Object $object Object supplier invoice
* @param string $modele Force template to use ('' to not force) * @param string $modele Force template to use ('' to not force)
* @param Translate $outputlangs objet lang a utiliser pour traduction * @param Translate $outputlangs Object lang a utiliser pour traduction
* @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description
* @param int $hideref Hide ref
* @return int 0 if KO, 1 if OK * @return int 0 if KO, 1 if OK
*/ */
function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs) function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
{ {
global $conf, $user, $langs; global $conf, $user, $langs;
@ -81,7 +83,7 @@ function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs)
$srctemplatepath=''; $srctemplatepath='';
// Positionne modele sur le nom du modele de invoice fournisseur a utiliser // Positionne le modele sur le nom du modele a utiliser
if (! dol_strlen($modele)) if (! dol_strlen($modele))
{ {
if (! empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF)) if (! empty($conf->global->INVOICE_SUPPLIER_ADDON_PDF))
@ -102,7 +104,7 @@ function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs)
$srctemplatepath=$tmp[1]; $srctemplatepath=$tmp[1];
} }
// Search template file // Search template files
$file=''; $classname=''; $filefound=0; $file=''; $classname=''; $filefound=0;
$dirmodels=array('/'); $dirmodels=array('/');
if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']); if (is_array($conf->modules_parts['models'])) $dirmodels=array_merge($dirmodels,$conf->modules_parts['models']);
@ -134,7 +136,7 @@ function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs)
// We save charset_output to restore it because write_file can change it if needed for // We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8. // output format that does not support UTF8.
$sav_charset_output=$outputlangs->charset_output; $sav_charset_output=$outputlangs->charset_output;
if ($obj->write_file($object,$outputlangs) > 0) if ($obj->write_file($object, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc) > 0)
{ {
$outputlangs->charset_output=$sav_charset_output; $outputlangs->charset_output=$sav_charset_output;
@ -145,7 +147,7 @@ function supplier_invoice_pdf_create($db, $object, $modele, $outputlangs)
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($db); $interface=new Interfaces($db);
$result=$interface->run_triggers('BILL_BUILDDOC',$object,$user,$langs,$conf); $result=$interface->run_triggers('SUPPLIER_INVOICE_BUILDDOC',$object,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers // Fin appel triggers

View File

@ -113,7 +113,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
/** /**
* Write the invoice as a document onto disk * Build document onto disk
* *
* @param Object $object Object invoice to build (or id if old method) * @param Object $object Object invoice to build (or id if old method)
* @param Translate $outputlangs Lang object for output language * @param Translate $outputlangs Lang object for output language
@ -873,7 +873,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
// Show sender information // Show sender information
$pdf->SetXY($posx+2,$posy+8); $pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($this->emetteur->name,44)*4));
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');

View File

@ -23,7 +23,7 @@
/** /**
* \file htdocs/core/modules/supplier_order/modules_commandefournisseur.php * \file htdocs/core/modules/supplier_order/modules_commandefournisseur.php
* \ingroup commande * \ingroup commande fournisseur
* \brief File that contain parent class for supplier orders models * \brief File that contain parent class for supplier orders models
* and parent class for supplier orders numbering models * and parent class for supplier orders numbering models
*/ */
@ -32,8 +32,7 @@ require_once(DOL_DOCUMENT_ROOT."/compta/bank/class/account.class.php"); // requi
/** /**
* \class ModelePDFSuppliersOrders * Parent class for supplier orders models
* \brief Parent class for supplier orders models
*/ */
abstract class ModelePDFSuppliersOrders extends CommonDocGenerator abstract class ModelePDFSuppliersOrders extends CommonDocGenerator
{ {
@ -65,8 +64,7 @@ abstract class ModelePDFSuppliersOrders extends CommonDocGenerator
/** /**
* \class ModeleNumRefSuppliersOrders * Classe mere des modeles de numerotation des references de commandes fournisseurs
* \brief Classe mere des modeles de numerotation des references de commandes fournisseurs
*/ */
abstract class ModeleNumRefSuppliersOrders abstract class ModeleNumRefSuppliersOrders
{ {
@ -140,20 +138,20 @@ abstract class ModeleNumRefSuppliersOrders
/** /**
* Create a document onto disk accordign to template module. * Create a document onto disk according to template module.
* *
* @param DoliDB $db data base object * @param DoliDB $db Database handler
* @param Object $object object order * @param Object $object Object supplier order
* @param string $model force le modele a utiliser ('' to not force) * @param string $modele Force template to use ('' to not force)
* @param Translate $outputlangs Objet lang a utiliser pour traduction * @param Translate $outputlangs Object lang a utiliser pour traduction
* @param int $hidedetails Hide details of lines * @param int $hidedetails Hide details of lines
* @param int $hidedesc Hide description * @param int $hidedesc Hide description
* @param int $hideref Hide ref * @param int $hideref Hide ref
* @return int 0 if KO, 1 if OK * @return int 0 if KO, 1 if OK
*/ */
function supplier_order_pdf_create($db, $object, $model, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0) function supplier_order_pdf_create($db, $object, $modele, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
{ {
global $conf,$langs; global $conf, $user, $langs;
$langs->load("suppliers"); $langs->load("suppliers");
$error=0; $error=0;
@ -214,7 +212,7 @@ function supplier_order_pdf_create($db, $object, $model, $outputlangs, $hidedeta
{ {
require_once($file); require_once($file);
$obj = new $classname($db); $obj = new $classname($db,$object);
// We save charset_output to restore it because write_file can change it if needed for // We save charset_output to restore it because write_file can change it if needed for
// output format that does not support UTF8. // output format that does not support UTF8.
@ -226,6 +224,14 @@ function supplier_order_pdf_create($db, $object, $model, $outputlangs, $hidedeta
// we delete preview files // we delete preview files
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
dol_delete_preview($object); dol_delete_preview($object);
// Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($db);
$result=$interface->run_triggers('SUPPLIER_ORDER_BUILDDOC',$object,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers
return 1; return 1;
} }
else else

View File

@ -34,8 +34,7 @@ require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php');
/** /**
* \class pdf_muscadet * Class to generate the supplier orders with the muscadet model
* \brief Classe permettant de generer les commandes fournisseurs au modele Muscadet
*/ */
class pdf_muscadet extends ModelePDFSuppliersOrders class pdf_muscadet extends ModelePDFSuppliersOrders
{ {
@ -63,7 +62,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
* *
* @param DoliDB $db Database handler * @param DoliDB $db Database handler
*/ */
function __construct($db) function __construct($db,$object)
{ {
global $conf,$langs,$mysoc; global $conf,$langs,$mysoc;
@ -91,11 +90,16 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$this->option_condreg = 1; // Affiche conditions reglement $this->option_condreg = 1; // Affiche conditions reglement
$this->option_codeproduitservice = 1; // Affiche code produit-service $this->option_codeproduitservice = 1; // Affiche code produit-service
$this->option_multilang = 1; // Dispo en plusieurs langues $this->option_multilang = 1; // Dispo en plusieurs langues
$this->option_escompte = 0; // Affiche si il y a eu escompte
$this->option_credit_note = 0; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 1; // Support add of a watermark on drafts
$this->franchise=!$mysoc->tva_assuj; $this->franchise=!$mysoc->tva_assuj;
// Get source company // Get source company
$this->emetteur=$mysoc; if (! is_object($object->thirdparty)) $object->fetch_thirdparty();
$this->emetteur=$object->thirdparty;
if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined
// Defini position des colonnes // Defini position des colonnes
@ -115,13 +119,18 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
/** /**
* Write the order as a document onto disk * Build document onto disk
* *
* @param int $object Id of object to generate * @param int $object Id of object to generate
* @param object $outputlangs Lang output object * @param object $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref
* @param object $hookmanager Hookmanager object
* @return int 1=OK, 0=KO * @return int 1=OK, 0=KO
*/ */
function write_file($object,$outputlangs='') function write_file($object,$outputlangs='',$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
{ {
global $user,$langs,$conf; global $user,$langs,$conf;
@ -165,7 +174,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
{ {
if (dol_mkdir($dir) < 0) if (dol_mkdir($dir) < 0)
{ {
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir); $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
return 0; return 0;
} }
@ -217,7 +226,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->AddPage(); $pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++; $pagenb++;
$this->_pagehead($pdf, $object, 1, $outputlangs); $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager);
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
@ -232,7 +241,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
{ {
$tab_top = 88; $tab_top = 88;
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1); // Into loop to manage multipages
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, $outputlangs->convToOutputCharset($object->note_public), 0, 1); $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, $outputlangs->convToOutputCharset($object->note_public), 0, 1);
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$height_note=$nexY-$tab_top; $height_note=$nexY-$tab_top;
@ -258,10 +267,11 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
{ {
$curY = $nexY; $curY = $nexY;
// Description of product line
$pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
// Description of product line
$curX = $this->posxdesc-1; $curX = $this->posxdesc-1;
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,0,0,1); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,0,0,1,$hookmanager);
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
@ -269,7 +279,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
// VAT Rate // VAT Rate
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{ {
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs); $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY($this->posxtva, $curY); $pdf->SetXY($this->posxtva, $curY);
$pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R'); $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R');
} }
@ -321,7 +331,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
//on recupere la description du produit suivant //on recupere la description du produit suivant
$follow_descproduitservice = $object->lines[$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);
// Et si on affiche dates de validite, on ajoute encore une ligne // Et si on affiche dates de validite, on ajoute encore une ligne
if ($object->lines[$i]->date_start && $object->lines[$i]->date_end) if ($object->lines[$i]->date_start && $object->lines[$i]->date_end)
{ {
@ -361,7 +371,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->AddPage(); $pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++; $pagenb++;
$this->_pagehead($pdf, $object, 0, $outputlangs); $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
@ -436,6 +446,21 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
} }
/**
* Affiche tableau des versement
*
* @param PDF &$pdf Object PDF
* @param Object $object Object order
* @param int $posy Position y in PDF
* @param Translate $outputlangs Object langs for output
* @return int <0 if KO, >0 if OK
*/
function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
{
}
/** /**
* Show miscellaneous information (payment mode, payment term, ...) * Show miscellaneous information (payment mode, payment term, ...)
* *
@ -464,7 +489,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
} }
// Show payments conditions // Show payments conditions
if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) if ($object->cond_reglement_code || $object->cond_reglement)
{ {
$pdf->SetFont('','B', $default_font_size - 2); $pdf->SetFont('','B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
@ -480,11 +505,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$posy=$pdf->GetY()+3; $posy=$pdf->GetY()+3;
} }
if ($object->type != 2)
{
// Check a payment mode is defined // Check a payment mode is defined
/* /* Not used with orders
if (empty($object->mode_reglement_code) if (empty($object->mode_reglement_code)
&& ! $conf->global->FACTURE_CHQ_NUMBER && ! $conf->global->FACTURE_CHQ_NUMBER
&& ! $conf->global->FACTURE_RIB_NUMBER) && ! $conf->global->FACTURE_RIB_NUMBER)
@ -496,28 +518,31 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$posy=$pdf->GetY()+1; $posy=$pdf->GetY()+1;
}*/ }
*/
// Show payment mode // Show payment mode
if ($object->mode_reglement_code) if ($object->mode_reglement_code
// && $object->mode_reglement_code != 'CHQ' // && $object->mode_reglement_code != 'CHQ'
// && $object->mode_reglement_code != 'VIR') // && $object->mode_reglement_code != 'VIR'
)
{ {
$pdf->SetFont('','B', $default_font_size - 2); $pdf->SetFont('','B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
$titre = $outputlangs->transnoentities("PaymentMode").':'; $titre = $outputlangs->transnoentities("PaymentMode").':';
$pdf->MultiCell(80, 5, $titre, 0, 'L'); $pdf->MultiCell(80, 4, $titre, 0, 'L');
$pdf->SetFont('','', $default_font_size - 2); $pdf->SetFont('','', $default_font_size - 2);
$pdf->SetXY(50, $posy); $pdf->SetXY(52, $posy);
$lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
$pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); $pdf->MultiCell(80, 4, $lib_mode_reg,0,'L');
$posy=$pdf->GetY()+2; $posy=$pdf->GetY()+2;
} }
// Show payment mode CHQ // Show payment mode CHQ
/* if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') /*
if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ')
{ {
// Si mode reglement non force ou si force a CHQ // Si mode reglement non force ou si force a CHQ
if ($conf->global->FACTURE_CHQ_NUMBER) if ($conf->global->FACTURE_CHQ_NUMBER)
@ -531,7 +556,6 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetFont('','B', $default_font_size - 2); $pdf->SetFont('','B', $default_font_size - 2);
$pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio).':',0,'L',0); $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio).':',0,'L',0);
$posy=$pdf->GetY()+1; $posy=$pdf->GetY()+1;
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetFont('','', $default_font_size - 2); $pdf->SetFont('','', $default_font_size - 2);
$pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($account->adresse_proprio), 0, 'L', 0); $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($account->adresse_proprio), 0, 'L', 0);
@ -568,8 +592,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$posy+=2; $posy+=2;
} }
} }
*/ */
}
return $posy; return $posy;
} }
@ -652,7 +676,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->country_code), 0, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->country_code), 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), 0, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1);
} }
// Total LocalTax2 // Total LocalTax2
@ -662,7 +686,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->country_code), 0, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->country_code), 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), 0, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1);
} }
} }
else else
@ -746,14 +770,16 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
if ($deja_regle > 0) if ($deja_regle > 0)
{ {
// Already paid + Deposits
$index++; $index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPaid"), 0, 'L', 0);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0);
$resteapayer = $object->total_ttc - $deja_regle;
$index++; $index++;
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
$pdf->SetFillColor(224,224,224); $pdf->SetFillColor(224,224,224);
@ -762,6 +788,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
} }
@ -859,15 +886,23 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
// Do not add the BACKGROUND as this is for suppliers // Do not add the BACKGROUND as this is for suppliers
//pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
//Affiche le filigrane brouillon - Print Draft Watermark
/*if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) )
{
pdf_watermark($pdf,$outputlangs,$this->page_hauteur,$this->page_largeur,'mm',$conf->global->COMMANDE_DRAFT_WATERMARK);
}*/
//Print content
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
$pdf->SetFont('','B',$default_font_size + 3); $pdf->SetFont('','B',$default_font_size + 3);
$posy=$this->marge_haute;
$posx=$this->page_largeur-$this->marge_droite-100; $posx=$this->page_largeur-$this->marge_droite-100;
$posy=$this->marge_haute;
$pdf->SetXY($this->marge_gauche,$posy); $pdf->SetXY($this->marge_gauche,$posy);
// Logo // Logo
/*
$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
if ($mysoc->logo) if ($mysoc->logo)
{ {
@ -885,33 +920,33 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
} }
} }
else else
{ {*/
$text=$this->emetteur->name; $text=$this->emetteur->name;
$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
} //}
$pdf->SetFont('','B',$default_font_size + 3); $pdf->SetFont('', 'B', $default_font_size + 3);
$pdf->SetXY($posx,$posy); $pdf->SetXY($posx,$posy);
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
$title=$outputlangs->transnoentities("SupplierOrder"); $title=$outputlangs->transnoentities("SupplierOrder");
$pdf->MultiCell(100, 3, $title, '', 'R'); $pdf->MultiCell(100, 3, $title, '', 'R');
$pdf->SetFont('','B',$default_font_size); $pdf->SetFont('', 'B', $default_font_size + 2);
$posy+=5; $posy+=6;
$pdf->SetXY($posx,$posy); $pdf->SetXY($posx,$posy);
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R'); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R');
$posy+=1; $posy+=2;
$pdf->SetFont('','', $default_font_size -1); $pdf->SetFont('','', $default_font_size -1);
$posy+=4; $posy+=5;
$pdf->SetXY($posx,$posy); $pdf->SetXY($posx,$posy);
if ($object->date_commande) if ($object->date_commande)
{ {
$pdf->SetTextColor(0,0,60); $pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date_commande,"day",false,$outputlangs,true), '', 'R'); $pdf->MultiCell(100, 4, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date_commande,"day",false,$outputlangs,true), '', 'R');
} }
else else
{ {
@ -919,6 +954,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->MultiCell(100, 4, strtolower($outputlangs->transnoentities("OrderToProcess")), '', 'R'); $pdf->MultiCell(100, 4, strtolower($outputlangs->transnoentities("OrderToProcess")), '', 'R');
} }
$posy+=2;
if ($showaddress) if ($showaddress)
{ {
// Sender properties // Sender properties
@ -946,13 +983,13 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
// Show sender information // Show sender information
$pdf->SetXY($posx+2,$posy+8); $pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($this->emetteur->name,44)*4));
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
// If BILLING contact defined on invoice, we use it // If BILLING contact defined on order, we use it
$usecontact=false; $usecontact=false;
$arrayidcontact=$object->getIdContact('internal','BILLING'); $arrayidcontact=$object->getIdContact('internal','BILLING');
if (count($arrayidcontact) > 0) if (count($arrayidcontact) > 0)