New: Can use variables into the free text on PDF (__TOTAL_TTC_, __TOTAL_VAT...)

This commit is contained in:
Laurent Destailleur 2009-08-25 13:37:29 +00:00
parent 9494f78336
commit a5c7178a3d
17 changed files with 136 additions and 95 deletions

View File

@ -37,6 +37,7 @@ For users:
- New: Can split a discount into two smaller discount. This allows to use a - New: Can split a discount into two smaller discount. This allows to use a
discount on an invoice even if invoice amount is lower than discount discount on an invoice even if invoice amount is lower than discount
credit available. credit available.
- New: Can use variables into the free text on PDF (__TOTAL_TTC_, __TOTAL_VAT...)
- Fix: "Now" link works when date popup is not used. - Fix: "Now" link works when date popup is not used.
- Fix: Debug seriously the email notification module. - Fix: Debug seriously the email notification module.
- Fix: Error Call to a member function trans when refusing a supplier order. - Fix: Error Call to a member function trans when refusing a supplier order.

View File

@ -2646,14 +2646,13 @@ class Facture extends CommonObject
/** /**
* \brief Initialise la facture avec valeurs fictives al<EFBFBD>atoire * \brief Initialise an example of invoice with random values
* Sert <EFBFBD> g<EFBFBD>n<EFBFBD>rer une facture pour l'aperu des mod<EFBFBD>les ou dem * Used to build preivew of invoices or demo
*/ */
function initAsSpecimen() function initAsSpecimen()
{ {
global $user,$langs,$conf; global $user,$langs,$conf;
// Charge tableau des id de soci<63>t<EFBFBD> socids
$socids = array(); $socids = array();
$sql = "SELECT rowid"; $sql = "SELECT rowid";
@ -2676,7 +2675,6 @@ class Facture extends CommonObject
} }
} }
// Charge tableau des produits prodids
$prodids = array(); $prodids = array();
$sql = "SELECT rowid"; $sql = "SELECT rowid";

View File

@ -131,7 +131,7 @@ class BordereauChequeBlochet extends FPDF
$pdf->SetDrawColor(128,128,128); $pdf->SetDrawColor(128,128,128);
$pdf->SetDrawColor(128,128,128); $pdf->SetDrawColor(128,128,128);
$pdf->SetTitle($outputlangs->convToOutputCharset($fac->ref)); $pdf->SetTitle($outputlangs->transnoentities("CheckReceipt")." ".$number);
$pdf->SetSubject($outputlangs->transnoentities("CheckReceipt")); $pdf->SetSubject($outputlangs->transnoentities("CheckReceipt"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->fullname)); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->fullname));
@ -141,6 +141,7 @@ class BordereauChequeBlochet extends FPDF
$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
$pdf->SetAutoPageBreak(1,0); $pdf->SetAutoPageBreak(1,0);
$lignes=$this->line_per_page; // There is no line in such PDF.
$pages = intval($lignes / $this->line_per_page); $pages = intval($lignes / $this->line_per_page);
@ -313,15 +314,15 @@ class BordereauChequeBlochet extends FPDF
/** /**
* \brief Show footer of page * \brief Show footer of page
* \param pdf Object PDF * \param pdf Object PDF
* \param object Object invoice * \param object Object cheque receipt
* \param outputlang Object lang for output * \param outputlangs Object lang for output
* \remarks Need this->emetteur object * \remarks Need this->emetteur object
*/ */
function _pagefoot(&$pdf,$object,$outputlangs) function _pagefoot(&$pdf,$object,$outputlangs)
{ {
global $conf; global $conf;
//return pdf_pagefoot($pdf,$outputlangs,'BANK_CHEQUERECEIPT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur); //return pdf_pagefoot($pdf,$outputlangs,'BANK_CHEQUERECEIPT_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object);
$paramfreetext='BANK_CHEQUERECEIPT_FREE_TEXT'; $paramfreetext='BANK_CHEQUERECEIPT_FREE_TEXT';
$marge_basse=$this->marge_basse; $marge_basse=$this->marge_basse;
$marge_gauche=$this->marge_gauche; $marge_gauche=$this->marge_gauche;

View File

@ -494,13 +494,16 @@ class pdf_edison extends ModelePDFCommandes
$pdf->Text(11, 94, $outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->ref)); $pdf->Text(11, 94, $outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->ref));
} }
/* /**
* \brief Affiche le pied de page * \brief Show footer of page
* \param pdf objet PDF * \param pdf PDF factory
* \param object Object invoice
* \param outputlangs Object lang for output
* \remarks Need this->emetteur object
*/ */
function _pagefoot(&$pdf,$object,$outputlangs) function _pagefoot(&$pdf,$object,$outputlangs)
{ {
return pdf_pagefoot($pdf,$outputlangs,'COMMANDE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur); return pdf_pagefoot($pdf,$outputlangs,'COMMANDE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object);
} }
} }

View File

@ -317,7 +317,7 @@ class pdf_einstein extends ModelePDFCommandes
$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,$outputlangs); $this->_pagefoot($pdf,$com,$outputlangs);
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
@ -356,7 +356,7 @@ class pdf_einstein extends ModelePDFCommandes
} }
// Pied de page // Pied de page
$this->_pagefoot($pdf,$outputlangs); $this->_pagefoot($pdf,$com,$outputlangs);
$pdf->AliasNbPages(); $pdf->AliasNbPages();
$pdf->Close(); $pdf->Close();
@ -888,13 +888,16 @@ class pdf_einstein extends ModelePDFCommandes
} }
} }
/* /**
* \brief Affiche le pied de page * \brief Show footer of page
* \param pdf objet PDF * \param pdf PDF factory
* \param object Object invoice
* \param outputlangs Object lang for output
* \remarks Need this->emetteur object
*/ */
function _pagefoot(&$pdf,$outputlangs) function _pagefoot(&$pdf,$object,$outputlangs)
{ {
return pdf_pagefoot($pdf,$outputlangs,'COMMANDE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur); return pdf_pagefoot($pdf,$outputlangs,'COMMANDE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object);
} }
} }

View File

@ -224,7 +224,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
if ($nexY > ($tab_top+$tab_height-10) && $i < $nblignes - 1) if ($nexY > ($tab_top+$tab_height-10) && $i < $nblignes - 1)
{ {
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
$this->_pagefoot($pdf, $outputlangs); $this->_pagefoot($pdf, $object, $outputlangs);
$pdf->AliasNbPages(); $pdf->AliasNbPages();
$curY = $iniY; $curY = $iniY;
@ -239,7 +239,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
} }
} }
//Insertion du pied de page //Insertion du pied de page
$this->_pagefoot($pdf, $outputlangs); $this->_pagefoot($pdf, $object, $outputlangs);
$pdf->AliasNbPages(); $pdf->AliasNbPages();
@ -293,10 +293,13 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$pdf->Rect(10, $tab_top, 190, $tab_height); $pdf->Rect(10, $tab_top, 190, $tab_height);
} }
//******************************** /**
// Generation du Pied de page * \brief Show footer of page
//******************************** * \param pdf PDF factory
function _pagefoot(&$pdf, $outputlangs) * \param object Object invoice
* \param outputlangs Object lang for output
*/
function _pagefoot(&$pdf, $object, $outputlangs)
{ {
$pdf->SetFont('Arial','',8); $pdf->SetFont('Arial','',8);
$pdf->SetY(-23); $pdf->SetY(-23);

View File

@ -371,14 +371,14 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
/** /**
* \brief Show footer of page * \brief Show footer of page
* \param pdf Object PDF * \param pdf PDF factory
* \param object Object invoice * \param object Object invoice
* \param outputlang Object lang for output * \param outputlangs Object lang for output
* \remarks Need this->emetteur object * \remarks Need this->emetteur object
*/ */
function _pagefoot(&$pdf,$object,$outputlangs) function _pagefoot(&$pdf,$object,$outputlangs)
{ {
return pdf_pagefoot($pdf,$outputlangs,'SENDING_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur); return pdf_pagefoot($pdf,$outputlangs,'SENDING_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object);
} }
} }

View File

@ -872,7 +872,7 @@ class pdf_crabe extends ModelePDFFactures
* \param pdf Object PDF * \param pdf Object PDF
* \param object Object invoice * \param object Object invoice
* \param showadress 0=no, 1=yes * \param showadress 0=no, 1=yes
* \param outputlang Object lang for output * \param outputlangs Object lang for output
*/ */
function _pagehead(&$pdf, $object, $showadress=1, $outputlangs) function _pagehead(&$pdf, $object, $showadress=1, $outputlangs)
{ {
@ -1168,14 +1168,14 @@ class pdf_crabe extends ModelePDFFactures
/** /**
* \brief Show footer of page * \brief Show footer of page
* \param pdf Object PDF * \param pdf PDF factory
* \param object Object invoice * \param object Object invoice
* \param outputlang Object lang for output * \param outputlang Object lang for output
* \remarks Need this->emetteur object * \remarks Need this->emetteur object
*/ */
function _pagefoot(&$pdf,$object,$outputlangs) function _pagefoot(&$pdf,$object,$outputlangs)
{ {
return pdf_pagefoot($pdf,$outputlangs,'FACTURE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur); return pdf_pagefoot($pdf,$outputlangs,'FACTURE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object);
} }
} }

View File

@ -1061,14 +1061,16 @@ class pdf_oursin extends ModelePDFFactures
$pdf->Text(200 - $pdf->GetStringWidth($titre), 94, $titre); $pdf->Text(200 - $pdf->GetStringWidth($titre), 94, $titre);
} }
/* /**
* \brief Affiche le pied de page de la facture * \brief Show footer of page
* \param pdf objet PDF * \param pdf PDF factory
* \param fac objet facture * \param object Object invoice
* \param outputlang Object lang for output
* \remarks Need this->emetteur object
*/ */
function _pagefoot(&$pdf, $object, $outputlangs) function _pagefoot(&$pdf, $object, $outputlangs)
{ {
return pdf_pagefoot($pdf,$outputlangs,'FACTURE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur); return pdf_pagefoot($pdf,$outputlangs,'FACTURE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object);
} }
} }

View File

@ -317,7 +317,7 @@ class pdf_soleil extends ModelePDFFicheinter
$pdf->SetFont('Arial','', 9); // On repositionne la police par defaut $pdf->SetFont('Arial','', 9); // On repositionne la police par defaut
$this->_pagefoot($pdf,$outputlangs); $this->_pagefoot($pdf,$fichinter,$outputlangs);
$pdf->AliasNbPages(); $pdf->AliasNbPages();
$pdf->Close(); $pdf->Close();
@ -343,13 +343,16 @@ class pdf_soleil extends ModelePDFFicheinter
return 0; // Erreur par defaut return 0; // Erreur par defaut
} }
/* /**
* \brief Affiche le pied de page * \brief Show footer of page
* \param pdf objet PDF * \param pdf PDF factory
* \param object Object invoice
* \param outputlangs Object lang for output
* \remarks Need this->emetteur object
*/ */
function _pagefoot(&$pdf,$outputlangs) function _pagefoot(&$pdf,$object,$outputlangs)
{ {
return pdf_pagefoot($pdf,$outputlangs,'FICHEINTER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur); return pdf_pagefoot($pdf,$outputlangs,'FICHEINTER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object);
} }
} }

View File

@ -270,7 +270,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
$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, $outputlangs); $this->_pagefoot($pdf, $object, $outputlangs);
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
@ -299,7 +299,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
/* /*
* Pied de page * Pied de page
*/ */
$this->_pagefoot($pdf,$outputlangs); $this->_pagefoot($pdf, $object, $outputlangs);
$pdf->AliasNbPages(); $pdf->AliasNbPages();
$pdf->Close(); $pdf->Close();
@ -501,12 +501,15 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
} }
/** /**
* \brief Affiche le pied de page * \brief Show footer of page
* \param pdf objet PDF * \param pdf PDF factory
* \param object Object invoice
* \param outputlangs Object lang for output
* \remarks Need this->emetteur object
*/ */
function _pagefoot(&$pdf,$outputlangs) function _pagefoot(&$pdf,$object,$outputlangs)
{ {
return pdf_pagefoot($pdf,$outputlangs,'DELIVERY_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur); return pdf_pagefoot($pdf,$outputlangs,'DELIVERY_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object);
} }
} }

View File

@ -333,7 +333,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$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, $outputlangs); $this->_pagefoot($pdf, $object, $outputlangs);
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
@ -363,7 +363,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
/* /*
* Pied de page * Pied de page
*/ */
$this->_pagefoot($pdf,$outputlangs); $this->_pagefoot($pdf,$object,$outputlangs);
$pdf->AliasNbPages(); $pdf->AliasNbPages();
$pdf->Close(); $pdf->Close();
@ -638,12 +638,15 @@ class pdf_typhon extends ModelePDFDeliveryOrder
} }
/** /**
* \brief Affiche le pied de page * \brief Show footer of page
* \param pdf objet PDF * \param pdf PDF factory
* \param object Object invoice
* \param outputlangs Object lang for output
* \remarks Need this->emetteur object
*/ */
function _pagefoot(&$pdf,$outputlangs) function _pagefoot(&$pdf,$object,$outputlangs)
{ {
return pdf_pagefoot($pdf,$outputlangs,'DELIVERY_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur); return pdf_pagefoot($pdf,$outputlangs,'DELIVERY_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object);
} }
} }

View File

@ -332,7 +332,7 @@ 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,$outputlangs); $this->_pagefoot($pdf,$propale,$outputlangs);
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
@ -372,7 +372,7 @@ class pdf_propale_azur extends ModelePDFPropales
} }
// Pied de page // Pied de page
$this->_pagefoot($pdf,$outputlangs); $this->_pagefoot($pdf,$propale,$outputlangs);
$pdf->AliasNbPages(); $pdf->AliasNbPages();
$pdf->Close(); $pdf->Close();
@ -963,13 +963,16 @@ class pdf_propale_azur extends ModelePDFPropales
} }
} }
/* /**
* \brief Affiche le pied de page * \brief Show footer of page
* \param pdf objet PDF * \param pdf PDF factory
* \param object Object invoice
* \param outputlangs Object lang for output
* \remarks Need this->emetteur object
*/ */
function _pagefoot(&$pdf,$outputlangs) function _pagefoot(&$pdf,$object,$outputlangs)
{ {
return pdf_pagefoot($pdf,$outputlangs,'PROPALE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur); return pdf_pagefoot($pdf,$outputlangs,'PROPALE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object);
} }
} }

View File

@ -499,14 +499,16 @@ class pdf_propale_jaune extends ModelePDFPropales
$pdf->MultiCell(86,4, $carac_client); $pdf->MultiCell(86,4, $carac_client);
} }
/* /**
* \brief Affiche le pied de page * \brief Show footer of page
* \param pdf Object PDF * \param pdf PDF factory
* \param object Object proposal * \param object Object invoice
* \param outputlangs Object lang for output
* \remarks Need this->emetteur object
*/ */
function _pagefoot(&$pdf,$object,$outputlangs) function _pagefoot(&$pdf,$object,$outputlangs)
{ {
return pdf_pagefoot($pdf,$outputlangs,'PROPALE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur); return pdf_pagefoot($pdf,$outputlangs,'PROPALE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object);
} }
} }

View File

@ -306,7 +306,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$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, $outputlangs); $this->_pagefoot($pdf, $com, $outputlangs);
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
@ -356,7 +356,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
/* /*
* Pied de page * Pied de page
*/ */
$this->_pagefoot($pdf, $outputlangs); $this->_pagefoot($pdf, $com, $outputlangs);
$pdf->AliasNbPages(); $pdf->AliasNbPages();
$pdf->Close(); $pdf->Close();
@ -572,7 +572,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
* \param pdf Object PDF * \param pdf Object PDF
* \param object Object invoice * \param object Object invoice
* \param showadress 0=no, 1=yes * \param showadress 0=no, 1=yes
* \param outputlang Object lang for output * \param outputlangs Object lang for output
*/ */
function _pagehead(&$pdf, $object, $showadress=1, $outputlangs) function _pagehead(&$pdf, $object, $showadress=1, $outputlangs)
{ {
@ -705,12 +705,14 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
/** /**
* \brief Show footer of page * \brief Show footer of page
* \param pdf Object PDF * \param pdf PDF factory
* \param object Object invoice
* \param outputlang Object lang for output * \param outputlang Object lang for output
* \remarks Need this->emetteur object
*/ */
function _pagefoot(&$pdf, $outputlangs) function _pagefoot(&$pdf, $object, $outputlangs)
{ {
return pdf_pagefoot($pdf,$outputlangs,'FACTURESUPPLIER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur); return pdf_pagefoot($pdf,$outputlangs,'FACTURESUPPLIER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object);
} }
} }

View File

@ -2767,7 +2767,7 @@ function make_substitutions($chaine,$substitutionarray)
{ {
foreach ($substitutionarray as $key => $value) foreach ($substitutionarray as $key => $value)
{ {
$chaine=ereg_replace($key,$value,$chaine); $chaine=ereg_replace("$key","$value",$chaine); // We must keep the " to work when value is 123.5 for example
} }
return $chaine; return $chaine;
} }

View File

@ -105,22 +105,36 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account)
/** /**
* \brief Show footer of page for PDF generation * \brief Show footer of page for PDF generation
* \param pdf Object PDF * \param pdf The PDF factory
* \param outputlang Object lang for output * \param outputlang Object lang for output
* \param paramfreetext Constant name of free text * \param paramfreetext Constant name of free text
* \param fromcompany Object company * \param fromcompany Object company
* \param marge_basse * \param marge_basse Margin bottom
* \param marge_gauche * \param marge_gauche Margin left
* \param page_hauteur * \param page_hauteur Page height
* \param object Object shown in PDF
*/ */
function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_basse,$marge_gauche,$page_hauteur) function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_basse,$marge_gauche,$page_hauteur,$object)
{ {
global $conf; global $conf;
$outputlangs->load("dict"); $outputlangs->load("dict");
$ligne='';
// Line of free text // Line of free text
$ligne=(! empty($conf->global->$paramfreetext))?$outputlangs->convToOutputCharset($conf->global->$paramfreetext):""; if (! empty($conf->global->$paramfreetext))
{
// Make substitution
$substitutionarray=array(
'__FROM_NAME__' => $fromcompany->nom,
'__FROM_EMAIL__' => $fromcompany->email,
'__TOTAL_TTC__' => $object->total_ttc,
'__TOTAL_HT__' => $object->total_ht,
'__TOTAL_VAT__' => $object->total_vat
);
$newfreetext=make_substitutions($conf->global->$paramfreetext,$substitutionarray);
$ligne.=$outputlangs->convToOutputCharset($newfreetext);
}
// First line of company infos // First line of company infos