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

@ -36,7 +36,8 @@ For users:
- New: Added a "force LDAP synchronize" on member and contact cards.
- 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
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: Debug seriously the email notification module.
- 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
* Sert <EFBFBD> g<EFBFBD>n<EFBFBD>rer une facture pour l'aperu des mod<EFBFBD>les ou dem
* \brief Initialise an example of invoice with random values
* Used to build preivew of invoices or demo
*/
function initAsSpecimen()
{
global $user,$langs,$conf;
// Charge tableau des id de soci<63>t<EFBFBD> socids
$socids = array();
$sql = "SELECT rowid";
@ -2668,15 +2667,14 @@ class Facture extends CommonObject
$num_socs = $this->db->num_rows($resql);
$i = 0;
while ($i < $num_socs)
{
$i++;
{
$i++;
$row = $this->db->fetch_row($resql);
$socids[$i] = $row[0];
}
$row = $this->db->fetch_row($resql);
$socids[$i] = $row[0];
}
}
// Charge tableau des produits prodids
$prodids = array();
$sql = "SELECT rowid";
@ -2690,11 +2688,11 @@ class Facture extends CommonObject
$num_prods = $this->db->num_rows($resql);
$i = 0;
while ($i < $num_prods)
{
$i++;
$row = $this->db->fetch_row($resql);
$prodids[$i] = $row[0];
}
{
$i++;
$row = $this->db->fetch_row($resql);
$prodids[$i] = $row[0];
}
}
// Initialize parameters
@ -3057,7 +3055,7 @@ class FactureLigne
{
global $user,$langs,$conf;
// Clean parameters
// Clean parameters
$this->desc=trim($this->desc);
// Check parameters

View File

@ -131,7 +131,7 @@ class BordereauChequeBlochet extends FPDF
$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->SetCreator("Dolibarr ".DOL_VERSION);
$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->SetAutoPageBreak(1,0);
$lignes=$this->line_per_page; // There is no line in such PDF.
$pages = intval($lignes / $this->line_per_page);
@ -313,15 +314,15 @@ class BordereauChequeBlochet extends FPDF
/**
* \brief Show footer of page
* \param pdf Object PDF
* \param object Object invoice
* \param outputlang Object lang for output
* \param object Object cheque receipt
* \param outputlangs Object lang for output
* \remarks Need this->emetteur object
*/
function _pagefoot(&$pdf,$object,$outputlangs)
{
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';
$marge_basse=$this->marge_basse;
$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));
}
/*
* \brief Affiche le pied de page
* \param pdf objet PDF
*/
function _pagefoot(&$pdf,$object,$outputlangs)
/**
* \brief Show footer of page
* \param pdf PDF factory
* \param object Object invoice
* \param outputlangs Object lang for output
* \remarks Need this->emetteur object
*/
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->_pagefoot($pdf,$outputlangs);
$this->_pagefoot($pdf,$com,$outputlangs);
// New page
$pdf->AddPage();
@ -356,7 +356,7 @@ class pdf_einstein extends ModelePDFCommandes
}
// Pied de page
$this->_pagefoot($pdf,$outputlangs);
$this->_pagefoot($pdf,$com,$outputlangs);
$pdf->AliasNbPages();
$pdf->Close();
@ -888,13 +888,16 @@ class pdf_einstein extends ModelePDFCommandes
}
}
/*
* \brief Affiche le pied de page
* \param pdf objet PDF
/**
* \brief Show footer of page
* \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)
{
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
$this->_pagefoot($pdf, $outputlangs);
$this->_pagefoot($pdf, $object, $outputlangs);
$pdf->AliasNbPages();
$curY = $iniY;
@ -239,7 +239,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
}
}
//Insertion du pied de page
$this->_pagefoot($pdf, $outputlangs);
$this->_pagefoot($pdf, $object, $outputlangs);
$pdf->AliasNbPages();
@ -293,10 +293,13 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$pdf->Rect(10, $tab_top, 190, $tab_height);
}
//********************************
// Generation du Pied de page
//********************************
function _pagefoot(&$pdf, $outputlangs)
/**
* \brief Show footer of page
* \param pdf PDF factory
* \param object Object invoice
* \param outputlangs Object lang for output
*/
function _pagefoot(&$pdf, $object, $outputlangs)
{
$pdf->SetFont('Arial','',8);
$pdf->SetY(-23);

View File

@ -371,14 +371,14 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
/**
* \brief Show footer of page
* \param pdf Object PDF
* \param pdf PDF factory
* \param object Object invoice
* \param outputlang Object lang for output
* \param outputlangs Object lang for output
* \remarks Need this->emetteur object
*/
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 object Object invoice
* \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)
{
@ -1168,14 +1168,14 @@ class pdf_crabe extends ModelePDFFactures
/**
* \brief Show footer of page
* \param pdf Object PDF
* \param pdf PDF factory
* \param object Object invoice
* \param outputlang Object lang for output
* \remarks Need this->emetteur object
*/
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);
}
/*
* \brief Affiche le pied de page de la facture
* \param pdf objet PDF
* \param fac objet facture
/**
* \brief Show footer of page
* \param pdf PDF factory
* \param object Object invoice
* \param outputlang Object lang for output
* \remarks Need this->emetteur object
*/
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
$this->_pagefoot($pdf,$outputlangs);
$this->_pagefoot($pdf,$fichinter,$outputlangs);
$pdf->AliasNbPages();
$pdf->Close();
@ -343,13 +343,16 @@ class pdf_soleil extends ModelePDFFicheinter
return 0; // Erreur par defaut
}
/*
* \brief Affiche le pied de page
* \param pdf objet PDF
/**
* \brief Show footer of page
* \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->_pagefoot($pdf, $outputlangs);
$this->_pagefoot($pdf, $object, $outputlangs);
// New page
$pdf->AddPage();
@ -299,7 +299,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
/*
* Pied de page
*/
$this->_pagefoot($pdf,$outputlangs);
$this->_pagefoot($pdf, $object, $outputlangs);
$pdf->AliasNbPages();
$pdf->Close();
@ -501,12 +501,15 @@ class pdf_sirocco extends ModelePDFDeliveryOrder
}
/**
* \brief Affiche le pied de page
* \param pdf objet PDF
* \brief Show footer of page
* \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->_pagefoot($pdf, $outputlangs);
$this->_pagefoot($pdf, $object, $outputlangs);
// New page
$pdf->AddPage();
@ -363,7 +363,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
/*
* Pied de page
*/
$this->_pagefoot($pdf,$outputlangs);
$this->_pagefoot($pdf,$object,$outputlangs);
$pdf->AliasNbPages();
$pdf->Close();
@ -638,12 +638,15 @@ class pdf_typhon extends ModelePDFDeliveryOrder
}
/**
* \brief Affiche le pied de page
* \param pdf objet PDF
* \brief Show footer of page
* \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->_pagefoot($pdf,$outputlangs);
$this->_pagefoot($pdf,$propale,$outputlangs);
// New page
$pdf->AddPage();
@ -372,7 +372,7 @@ class pdf_propale_azur extends ModelePDFPropales
}
// Pied de page
$this->_pagefoot($pdf,$outputlangs);
$this->_pagefoot($pdf,$propale,$outputlangs);
$pdf->AliasNbPages();
$pdf->Close();
@ -963,13 +963,16 @@ class pdf_propale_azur extends ModelePDFPropales
}
}
/*
* \brief Affiche le pied de page
* \param pdf objet PDF
/**
* \brief Show footer of page
* \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);
}
/*
* \brief Affiche le pied de page
* \param pdf Object PDF
* \param object Object proposal
/**
* \brief Show footer of page
* \param pdf PDF factory
* \param object Object invoice
* \param outputlangs Object lang for output
* \remarks Need this->emetteur object
*/
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->_pagefoot($pdf, $outputlangs);
$this->_pagefoot($pdf, $com, $outputlangs);
// New page
$pdf->AddPage();
@ -356,7 +356,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
/*
* Pied de page
*/
$this->_pagefoot($pdf, $outputlangs);
$this->_pagefoot($pdf, $com, $outputlangs);
$pdf->AliasNbPages();
$pdf->Close();
@ -572,7 +572,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
* \param pdf Object PDF
* \param object Object invoice
* \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)
{
@ -705,12 +705,14 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
/**
* \brief Show footer of page
* \param pdf Object PDF
* \param pdf PDF factory
* \param object Object invoice
* \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)
{
$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;
}

View File

@ -105,22 +105,36 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account)
/**
* \brief Show footer of page for PDF generation
* \param pdf Object PDF
* \param pdf The PDF factory
* \param outputlang Object lang for output
* \param paramfreetext Constant name of free text
* \param fromcompany Object company
* \param marge_basse
* \param marge_gauche
* \param page_hauteur
* \param marge_basse Margin bottom
* \param marge_gauche Margin left
* \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;
$outputlangs->load("dict");
$ligne='';
// 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
@ -176,7 +190,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
$pdf->SetDrawColor(224,224,224);
// On positionne le debut du bas de page selon nbre de lignes de ce bas de page
$nbofligne=dol_nboflines_bis($ligne,0,$outputlangs->charset_output);
$nbofligne=dol_nboflines_bis($ligne,0,$outputlangs->charset_output);
//print 'nbofligne='.$nbofligne; exit;
//print 'e'.$ligne.'t'.dol_nboflines($ligne);exit;
$posy=$marge_basse + ($nbofligne*3) + ($ligne1?3:0) + ($ligne2?3:0);
@ -186,7 +200,7 @@ function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_bass
$pdf->SetXY($marge_gauche,-$posy);
$width=20000; $align='L'; // By default, ask a manual break: We use a large value 20000, to not have automatic wrap. This make user understand, he need to add CR on its text.
if ($conf->global->MAIN_USE_AUTOWRAP_ON_FREETEXT) { $width=200; $align='C'; }
$pdf->MultiCell($width, 3, $ligne, 0, $align, 0);
$pdf->MultiCell($width, 3, $ligne, 0, $align, 0);
$posy-=($nbofligne*3); // 6 of ligne + 3 of MultiCell
}