Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX #7594 Expense report multi pagebreak #13563

Merged
merged 2 commits into from
Apr 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 33 additions & 5 deletions htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Copyright (C) 2018 Francis Appels <francis.appels@z-application.com>
* Copyright (C) 2019 Markus Welters <markus@welters.de>
* Copyright (C) 2019 Rafael Ingenleuf <ingenleuf@welters.de>
* Copyright (C) 2020 Marc Guenneugues <marc.guenneugues@simicar.fr>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -350,13 +351,18 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
$initialY = $tab_top + 7;
$nexY = $tab_top + 7;

$showpricebeforepagebreak = 1;
$pdf->setTopMargin($tab_top_newpage);
// Loop on each lines
for ($i = 0 ; $i < $nblines ; $i++) {
$i = 0;
while ($i < $nblines) {
$pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);

$pdf->setTopMargin($tab_top_newpage);
$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
if (empty($showpricebeforepagebreak)) {
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
} else {
$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
}
$pageposbefore = $pdf->getPage();
$curY = $nexY;
$pdf->startTransaction();
Expand All @@ -367,7 +373,27 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
$pdf->rollbackTransaction(true);
$pageposafter = $pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
if (empty($showpricebeforepagebreak)) {
$pdf->AddPage('', '', true);
if (!empty($tplidx)) {
$pdf->useTemplate($tplidx);
}
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
$this->_pagehead($pdf, $object, 0, $outputlangs);
}
$pdf->setPage($pageposafter + 1);
$showpricebeforepagebreak = 1;
$nexY = $tab_top_newpage;
$nexY += ($pdf->getFontSize() * 1.3); // Passe espace entre les lignes
$pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);

$pdf->setTopMargin($tab_top_newpage);
continue;
} else {
$pdf->setPageOrientation('', 1, $heightforfooter);
$showpricebeforepagebreak = 0;
}
$this->printLine($pdf, $object, $i, $curY, $default_font_size, $outputlangs, $hidedetails);
$pageposafter = $pdf->getPage();
$posyafter = $pdf->GetY();
Expand Down Expand Up @@ -397,6 +423,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
{
$pdf->commitTransaction();
}
$i++;
//nexY
$nexY = $pdf->GetY();
$pageposafter = $pdf->getPage();
Expand Down Expand Up @@ -426,6 +453,7 @@ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidede
while ($pagenb < $pageposafter)
{
$pdf->setPage($pagenb);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
Expand Down