Skip to content

Commit

Permalink
Merge pull request #7 from atm-greg/retours_btp_greg
Browse files Browse the repository at this point in the history
Correction comptage des lignes
  • Loading branch information
FAVRE Pierre-Henry authored Aug 31, 2017
2 parents 2ba0666 + 40bae16 commit f1edcf5
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 43 deletions.
122 changes: 80 additions & 42 deletions core/modules/facture/doc/pdf_crabe_btp.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
$pdf->SetFont('','', $default_font_size - 1);

// Tableau total
$col1x = 120; $col2x = 180;
$col1x = 120; $col2x = 170;
if ($this->page_largeur < 210) // To work with US executive format
{
$col2x-=20;
Expand All @@ -1127,57 +1127,80 @@ function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)

$useborder=0;
$index = 0;


// pourcentage global d'avancement
$percent = 0;
$i=0;
foreach ($object->lines as $line)
{
if(!class_exists('TSubtotal') || !TSubtotal::isModSubtotalLine($line)){
$percent += $line->situation_percent;
$i++;
}
}
$avancementGlobal = $percent/$i;

$object->fetchPreviousNextSituationInvoice();
$TPreviousIncoice = $object->tab_previous_situation_invoice;


$total_a_payer = 0;
foreach ($TPreviousIncoice as &$fac) $total_a_payer += $fac->total_ht;
$total_a_payer += $object->total_ht;
$total_a_payer = $total_a_payer * 100 / $avancementGlobal;

$deja_paye = 0;
$i = 1;
if(!empty($TPreviousIncoice)){
foreach ($TPreviousIncoice as $fac){
$pdf->SetFont('','B', $default_font_size - 1);
$pdf->SetFillColor(255,255,255);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities('BtpPreviousInvoice') . ' ' . $fac->ref, 0, 'L', 1);
$pdf->SetFont('','', $default_font_size - 2);
$index++;
// cumul précédent
$pdf->SetFillColor(255,255,255);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities('TotalHT'), 0, 'L', 1);
$total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($fac->total_ht, 0, $outputlangs), 0, 'R', 1);

$pdf->setY($tab2_top);
$posy = $pdf->GetY();

$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetFillColor(255,255,255);
$pdf->SetXY($col1x, $posy);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("BtpTotalProgress", $avancementGlobal), 0, 'L', 1);

$pdf->SetXY($col2x,$posy);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer*$avancementGlobal/100, 0, $outputlangs), 0, 'R', 1);
$pdf->SetFont('','', $default_font_size - 2);

$posy += $tab2_hl;

foreach ($TPreviousIncoice as &$fac){

if($posy > 180 ) {
$this->_pagefoot($pdf,$object,$outputlangs,1);
$pdf->addPage();
$pdf->setY($this->marge_haute);
$posy = $pdf->GetY();
}

// cumul TVA précédent
$index++;
$pdf->SetFillColor(255,255,255);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1);

$total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($fac->total_tva, 0, $outputlangs), 0, 'R', 1);

// cumul ttc précédent
$index++;
$pdf->SetFillColor(255,255,255);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), 0, 'L', 1);
$pdf->SetXY($col1x, $posy);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("PDFCrabeBtpTitle", $i).' '.$outputlangs->transnoentities("TotalHT"), 0, 'L', 1);

$pdf->SetXY($col2x,$posy);
$pdf->MultiCell($largcol2, $tab2_hl, ' - '.price($fac->total_ht, 0, $outputlangs), 0, 'R', 1);

$total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($fac->total_ttc, 0, $outputlangs), 0, 'R', 1);
$i++;
$deja_paye += $fac->total_ht;
$posy += $tab2_hl;

$index++;
$pdf->setY($posy);

}

$index++;
$pdf->SetFont('','B', $default_font_size - 1);
$pdf->SetFillColor(255,255,255);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("BtpRayToRest"), 0, 'L', 1);
$pdf->SetFont('','', $default_font_size - 2);
if($posy > 180 ) {
$pdf->addPage();
$pdf->setY($this->marge_haute);
$posy = $pdf->GetY();
}

$tab2_top = $posy;
$index=0;

}

// Total HT
Expand All @@ -1186,7 +1209,7 @@ function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);

$total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
$total_ht = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * ($total_ht + (! empty($object->remise)?$object->remise:0)), 0, $outputlangs), 0, 'R', 1);

Expand Down Expand Up @@ -1385,6 +1408,21 @@ function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
$total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($sign * $total_ttc, 0, $outputlangs), $useborder, 'R', 1);

if($object->type == Facture::TYPE_SITUATION)
{
// reste à payer total
$index++;

$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetFillColor(255,255,255);
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities('BtpTotalRayToRest'), 0, 'L', 1);

$total_ht = ($conf->multicurrency->enabled && $object->multicurrency_tx != 1 ? $object->multicurrency_total_ht : $object->total_ht);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($total_a_payer-$deja_paye-$object->total_ht, 0, $outputlangs), 0, 'R', 1);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/modules/modBtp.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct($db)
// (where XXX is value of numeric property 'numero' of module)
$this->description = "Description of module Btp";
// Possible values for version are: 'development', 'experimental' or version
$this->version = '1.0';
$this->version = '1.0.1';
// Key used in llx_const table to save module status enabled/disabled
// (where MYMODULE is value of property name of module in uppercase)
$this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
Expand Down
2 changes: 2 additions & 0 deletions langs/fr_FR/btp.lang
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,6 @@ BtpNewCumul=Nouveau cumul
BtpAnteCumul=Cumul antérieur
BtpTotalSituationTTC=TOTAL SITUATION - TTC
BtpRetenueGarantie=Retenue Garantie - TTC
BtpTotalProgress=Total progression %d %%
BtpTotalRayToRest=Reste à payer total HT
BtpRayToRest=MONTANT A PAYER - TTC

0 comments on commit f1edcf5

Please sign in to comment.