Add Extrafields on PDF Models: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
m (https://www.dolibarr.fr/forum/12-howto--aide/62681-wiki-dolibarr-org?start=270#116247)
Tag: 2017 source edit
mNo edit summary
Line 3: Line 3:
This page give you some advises how to integrate complementary attributes (extrafields) into PDF models of Dolibarr.
This page give you some advises how to integrate complementary attributes (extrafields) into PDF models of Dolibarr.


This is a exemple many done on the Invoice template and may needs to be adapted to your needs.
This is a exemple done on the Invoice template and may needs to be adapted to your needs.
It is based on billing document but it will be the same for the others modules
It is based on billing document but it will be the same for the others documents on other modules (propal/order...)


=Prerequisite=
=Prerequisite=
You can read the following links before, some paragraph will come from these pages :
You may need to read the following links before starting to read this one, some paragraph will come from these links :


*[[Create a PDF document template]]
*[[Create a PDF document template]]
Line 149: Line 149:
==Invoice Template==
==Invoice Template==


=== Include Product Extrafield===
===Include Product Extrafield===
 
*Find <source lang="php">// Loop on each lines
*Find <source lang="php">// Loop on each lines
for ($i = 0; $i < $nblignes; $i++)
for ($i = 0; $i < $nblignes; $i++)
{</source>
{</source>
* Just after add :
*Just after add :
 
<source lang="php"> if ($object->lines[$i]->fk_product)
<source lang="php"> if ($object->lines[$i]->fk_product)
{
{
Line 166: Line 168:
}</source>
}</source>


=== Display Product Extrafield===
===Display Product Extrafield===
Instead of using that :
Instead of using that :
<source lang="php">$outputlangs->convToOutputCharset($object->array_options['options_my_extra'])</source>
<source lang="php">$outputlangs->convToOutputCharset($object->array_options['options_my_extra'])</source>
Should be replace by :
Should be replace by :
<source lang="php">$outputlangs->convToOutputCharset($product->array_options['options_my_product_extra'])</source>
<source lang="php">$outputlangs->convToOutputCharset($product->array_options['options_my_product_extra'])</source>
676

edits

Navigation menu