i want to change invoice design. for example, i don’t want to print my firm information on pdf documents, because i have printed my firm information on my invoice…
You have 2 ways to do it: either the “harsh” way, by editing the PDF template. You have to do some php programming (not very hard, but the code is very messy as you have to use the FPDF methods all the time). More infos:
http://wiki.dolibarr.org/index.php/Create_a_PDF_document_template
Or either the ODT way, which is way more simple but has less possibilities. Basically you create an ODT document on your computer (it’s like a word document) with special tags, and then these tags gets replaced dynamically when you generate your document in Dolibarr. The main drawback is that it’s only available for invoices at the moment, not for the other modules. More infos:
http://wiki.dolibarr.org/index.php/Create_an_ODT_document_template
An alternative way would be to use a third-party extension like PDML (http://www.pdml-pdf.net/) which integrates easily with FPDF and permits to create templates with an HTML-like syntax. PDML is not natively implemented into Dolibarr, but if you know some programming, it should be easy to add the libraries and then you will gain a lot of time while templating.
For the 2nd method, how do you import the new design into Dolibarr?
I don’t see this to come up anywhere in the interface.
I updated to the 3.0.1rc and still don’t see the “odt” file I’ve created.
Indeed, it’s not written in the wiki, but you have to activate the ODT support in the Invoices module administration (just like activating any template). You should then be able to generate ODT files.
I have looked several times over the past few days for the place to activate ODT and I do not find it.
Where is the location in the Invoices module administration-setup?
I’ve looked this panel over repeatedly and find no reference to set up with ODT documents.
John Lance wrote:
i found. Setup - Modules - at the end of the Invoice row. (computer icon)
but i can’t find any odt teamplate activete button.
odt support is available with 3.1 only and higher
I’m using the 3.1.0 release candidate.
Maybe I should reinstall?
did it help reinstalling?
having the same problems traing to edit an odt template and placing it.
useing 3.1 rc too
Hi,
I want create a script to generate a invoice with html code and the same variables of the odt files.
I used the fpdf scripts.
But I have a few problems:
1 - I can’t save the file
2 - I can’t use the variables used in odt files.
I belive that used the wrong functions (write_file). Can someone help me?
<?php
require_once(DOL_DOCUMENT_ROOT."/core/modules/facture/modules_facture.php");
require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/functions2.lib.php");
require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php');
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/doc.lib.php");
require('html2pdf.php');
/**
* Define array with couple substitution key => substitution value
*
* @param Object $object Main object to use as data source
* @param Translate $outputlangs Lang object to use for output
* @return array Array of substitution
*/
function get_substitutionarray_object($object,$outputlangs)
{
global $conf;
$invoice_source=new Facture($this->db);
if ($object->fk_facture_source > 0)
{
$invoice_source->fetch($object->fk_facture_source);
}
$alreadypayed=price($object->getSommePaiement(),0,$outputlangs);
return array(
'object_id'=>$object->id,
'object_ref'=>$object->ref,
'object_ref_ext'=>$object->ref_ext,
'object_ref_customer'=>$object->ref_client,
'object_ref_supplier'=>$object->ref_fournisseur,
'object_source_invoice_ref'=>$invoice_source->ref,
'object_date'=>dol_print_date($object->date,'day'),
'object_date_limit'=>dol_print_date($object->date_lim_reglement,'day'),
'object_date_creation'=>dol_print_date($object->date_creation,'day'),
'object_date_modification'=>dol_print_date($object->date_modification,'day'),
'object_date_validation'=>dol_print_date($object->date_validation,'dayhour'),
'object_payment_mode_code'=>$object->mode_reglement_code,
'object_payment_mode'=>($outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code)!='PaymentType'.$object->mode_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentType'.$object->mode_reglement_code):$object->mode_reglement),
'object_payment_term_code'=>$object->cond_reglement_code,
'object_payment_term'=>($outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code)!='PaymentCondition'.$object->cond_reglement_code?$outputlangs->transnoentitiesnoconv('PaymentCondition'.$object->cond_reglement_code):$object->cond_reglement),
'object_total_ht'=>price($object->total_ht,0,$outputlangs),
'object_total_vat'=>price($object->total_tva,0,$outputlangs),
'object_total_ttc'=>price($object->total_ttc,0,$outputlangs),
'object_vatrate'=>vatrate($object->tva),
'object_note_private'=>$object->note,
'object_note'=>$object->note_public,
// Payments
'object_already_payed'=>$alreadypayed,
'object_remain_to_pay'=>price($object->total_ttc - $alreadypayed,0,$outputlangs)
);
}
/**
* Define array with couple substitution key => substitution value
*
* @param array $line Array of lines
* @param Translate $outputlangs Lang object to use for output
* @return array Return substitution array
*/
function get_substitutionarray_lines($line,$outputlangs)
{
global $conf;
return array(
'line_fulldesc'=>doc_getlinedesc($line,$outputlangs),
'line_product_ref'=>$line->product_ref,
'line_product_label'=>$line->product_label,
'line_desc'=>$line->desc,
'line_vatrate'=>vatrate($line->tva_tx,true,$line->info_bits),
'line_up'=>price($line->subprice, 0, $outputlangs),
'line_qty'=>$line->qty,
'line_discount_percent'=>($line->remise_percent?$line->remise_percent.'%':''),
'line_price_ht'=>price($line->total_ht, 0, $outputlangs),
'line_price_ttc'=>price($line->total_ttc, 0, $outputlangs),
'line_price_vat'=>price($line->total_tva, 0, $outputlangs),
'line_date_start'=>$line->date_start,
'line_date_end'=>$line->date_end
);
}
//Function to build a document on disk using the html2pdf converter.
function write_file($object,$outputlangs)
{
//global $user,$langs,$conf,$mysoc;
$pdf=new PDF();
$pdf->AddPage();
$pdf->SetFont('Arial','',12);
$html='<table border="1">
<tr>
<td width="300" height="30">{mycompany_name}</td><td width="300" height="30" bgcolor="#D0D0FF">{mycompany_address}</td>
</tr>
<tr>
<td width="300" height="30">{mycompany_zip}</td><td width="300" height="30">{mycompany_town}</td>
</tr>
</table>';
$pdf->WriteHTML($html);
$pdf->Output();
}
?>
Regards,
Marcelo