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 107: Line 107:
*Result : [[File:Invoices module template Modification Result 2.png|none|thumb]]
*Result : [[File:Invoices module template Modification Result 2.png|none|thumb]]


= Special Case for Extrafields type Select list =
=Special Case for Extrafields type "Select list"=


==Configuration==
==Configuration==
Line 120: Line 120:
On the php invoice template, if you use the classical php code to print the extrafield, you will print the code (1 or 2 in our exemple) instead of printing the label (Hello Word or Hello Alone in our exemple).
On the php invoice template, if you use the classical php code to print the extrafield, you will print the code (1 or 2 in our exemple) instead of printing the label (Hello Word or Hello Alone in our exemple).


To display the label instead of the code, you shoudl replace the :
To display the label instead of the code, you should replace the :
<source lang="php">$outputlangs->convToOutputCharset($object->array_options['options_my_extra'])</source>
<source lang="php">$outputlangs->convToOutputCharset($object->array_options['options_my_extra'])</source>
by :
by :
<source lang="php">$extrafields->showOutputField('my_extra', $object->array_options['options_my_extra'])</source>
<source lang="php">$extrafields->showOutputField('my_extra', $object->array_options['options_my_extra'])</source>
=Special Case for Extrafields type "Date"=
==Configuration==
You can create a line or a module extrafield with the type '''Date'''
[[File:Date Extrafield.png|none|thumb]]
==Verification on the Invoices Module==
You should have a Module or Line extrafield (on this print screen this a Module)
[[File:Date Extrafield Invoice.png|none|thumb]]
==Invoice Template==
On the php invoice template, if you use the classical php code to print the extrafield, you will print the timestamp (1570450273 for exemple) instead of printing the date in human readable format (10/7/2019 12:11:13).
To display the date in human readable format, you should replace the :
<source lang="php">$outputlangs->convToOutputCharset($object->array_options['options_my_extra'])</source>
by :
<source lang="php">dol_print_date($object->array_options['options_my_extra'],"dayhour",false,$outputlangs,true)</source>
676

edits

Navigation menu