Removed hard coded dependency on an external module

This commit is contained in:
Laurent Destailleur 2020-04-15 02:20:57 +02:00
parent c337bd91fe
commit 1dd951495b

View File

@ -759,16 +759,15 @@ class pdf_sponge extends ModelePDFFactures
$parameters = array(
'object' => $object,
'i' => $i,
'pdf' =>& $pdf,
'curY' =>& $curY,
'nexY' =>& $nexY,
'pdf' => &$pdf,
'curY' => &$curY,
'nexY' => &$nexY,
'outputlangs' => $outputlangs,
'hidedetails' => $hidedetails
);
$reshook = $hookmanager->executeHooks('printPDFline', $parameters, $this); // Note that $object may have been modified by hook
$sign = 1;
if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
@ -1249,7 +1248,7 @@ class pdf_sponge extends ModelePDFFactures
*/
protected function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{
global $conf, $mysoc;
global $conf, $mysoc, $hookmanager;
$sign = 1;
if ($object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
@ -1278,16 +1277,22 @@ class pdf_sponge extends ModelePDFFactures
$outputlangsbis->loadLangs(array("main", "dict", "companies", "bills", "products", "propal"));
}
// Add trigger to allow to edit $object
$parameters = array(
'object' => &$object,
'outputlangs' => $outputlangs,
);
$hookmanager->executeHooks('beforePercentCalculation', $parameters, $this); // Note that $object may have been modified by hook
// overall percentage of advancement
$percent = 0;
$i = 0;
foreach ($object->lines as $line)
{
if (!class_exists('TSubtotal') || !TSubtotal::isModSubtotalLine($line)) {
$percent += $line->situation_percent;
$i++;
}
$percent += $line->situation_percent;
$i++;
}
if (!empty($i)) {
$avancementGlobal = $percent / $i;
}
@ -1316,7 +1321,6 @@ class pdf_sponge extends ModelePDFFactures
$total_a_payer_ttc = 0;
}
$deja_paye = 0;
$i = 1;
if (!empty($TPreviousIncoice)) {
$pdf->setY($tab2_top);
@ -1348,7 +1352,6 @@ class pdf_sponge extends ModelePDFFactures
$pdf->MultiCell($largcol2, $tab2_hl, $displayAmount, 0, 'R', 1);
$i++;
$deja_paye += $fac->total_ht;
$posy += $tab2_hl;
$pdf->setY($posy);
@ -1675,7 +1678,7 @@ class pdf_sponge extends ModelePDFFactures
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities('SituationTotalRayToRest'), 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer_ttc-$deja_paye, 0, $outputlangs), 0, 'R', 1);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer_ttc-$deja_regle, 0, $outputlangs), 0, 'R', 1);
}*/