Add Extrafields on PDF Models: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
Tag: 2017 source edit
No edit summary
Tag: 2017 source edit
Line 142: Line 142:
by :
by :
<source lang="php">dol_print_date($object->array_options['options_my_extra'],"dayhour",false,$outputlangs,true)</source>
<source lang="php">dol_print_date($object->array_options['options_my_extra'],"dayhour",false,$outputlangs,true)</source>
=Special Case for Product extrafields on invoice Line=
If you have defined a Product complementary attribute and you use that product on a Invoice Line, you may would like to be able to display it. In that case you should include the following code:
==Invoice Template==
=== Include Product Extrafield===
*Find <source lang="php">// Loop on each lines
for ($i = 0; $i < $nblignes; $i++)
{</source>
* Just after add :
<source lang="php"> if ($object->lines[$i]->fk_product)
{
require_once (DOL_DOCUMENT_ROOT."/product/class/product.class.php");
$product = new Product($this->db);
$product->fetch($object->lines[$i]->fk_product);
$extrafields_product = new ExtraFields($this->db)
$extralabels_product = $extrafields_product->fetch_name_optionals_label($product->table_element);
$product->fetch_optionals($product->rowid, $extralabels_product);
}</source>
=== Display Product Extrafield===
Instead of using that :
<source lang="php">$outputlangs->convToOutputCharset($object->array_options['options_my_extra'])</source>
Should be replace by :
<source lang="php">$outputlangs->convToOutputCharset($product->array_options['options_my_porduct_extra'])</source>
676

edits

Navigation menu