Changes

Line 323: Line 323:  
== Implementing the change of price in the Dolibarr interface ==
 
== Implementing the change of price in the Dolibarr interface ==
   −
Unluckily there is not (yet) any hooking context to modify how lines of products/services are printed, thus the only thing you can do is directly edit the '''htdocs/core/tpl/objectline_view.tpl.php''' template file, then load your customfield manually and print it the way you want using HTML formatting, for example:
+
Unluckily there is not (yet) any hooking context to modify how lines of products/services are printed, thus the only thing you can do is directly edit the '''htdocs/core/tpl/objectline_view.tpl.php''' template file, then load your customfield manually and print it the way you want using HTML formatting, for our example:
    +
In objectline_view.tpl.php, find the following code:
 
<source lang="php">
 
<source lang="php">
 +
<?php echo price($line->total_ht); ?>
 +
</source>
    +
And replace it by:
 +
<source lang="php">
 +
<?php
 +
// Include the facade API of CustomFields
 +
dol_include_once('/customfields/lib/customfields_aux.lib.php');
 +
 +
// Filling the $object with customfields (you can then access customfields by doing $object->customfields->cf_yourfield)
 +
$linecf = new stdClass();
 +
$linecf->id = $line->rowid;
 +
$linecf->table_element = 'facturedet';
 +
$customfields = customfields_fill_object($linecf);
 +
 +
// Modifying the TTC price and printing it on the Dolibarr's datasheet interface
 +
echo price($line->total_ttc * $linecf->customfields->cf_coefficient);
 +
?>
 
</source>
 
</source>
 +
 +
This should produce something like this:
 +
[[File:Cfe2.jpg]]
439

edits