Changes

Line 459: Line 459:  
This is where the lines are filled with margin infos. The price has just been fetched here, and we will now modify it with the coefficient before the price gets used for margin computation.
 
This is where the lines are filled with margin infos. The price has just been fetched here, and we will now modify it with the coefficient before the price gets used for margin computation.
   −
Just below the code we found (and just above the comment: "// calcul des marges"), paste the following:
+
To optimize things up, we will load the custom fields before the loop (because they don't change between product/service lines, they are the custom fields of the parent object), and then apply the global_coefficient inside the loop.
 +
 
 +
Just above the code we found (just before the for loop), paste the following:
    
<source lang="php">
 
<source lang="php">
Line 468: Line 470:  
// Load custom fields records
 
// Load custom fields records
 
$customfields = customfields_fill_object($this);
 
$customfields = customfields_fill_object($this);
 +
</source>
 +
 +
And now, just below the code we found, inside the loop (and just above the comment: "// calcul des marges"), paste the following:
 +
 +
<source lang="php">
 +
// Global coefficient (CustomFields)
 
// Apply the coefficient
 
// Apply the coefficient
 
if (!empty($this->customfields->cf_global_coefficient)) {
 
if (!empty($this->customfields->cf_global_coefficient)) {
439

edits