Skip to content

Commit

Permalink
Fix PDF: Page break was ko when breaking 2 pages or more.
Browse files Browse the repository at this point in the history
Fix PDF: pdf_canelle was missing code to manage pagebreak.
Fix PDF: The width of picture was hardcoded into some templates.
Fix PDF: The atleastonediscount was not used into some templates.
  • Loading branch information
eldy committed Mar 19, 2014
1 parent 5d14322 commit bf735ca
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 40 deletions.
19 changes: 14 additions & 5 deletions htdocs/core/modules/commande/doc/pdf_einstein.modules.php
@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
Expand Down Expand Up @@ -109,7 +109,7 @@ function __construct($db)
$this->posxdiscount=162;
$this->postotalht=174;
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
$this->posxpicture=$this->posxtva - 16; // width of images
$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?16:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
if ($this->page_largeur < 210) // To work with US executive format
{
$this->posxpicture-=20;
Expand Down Expand Up @@ -153,7 +153,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$outputlangs->load("products");
$outputlangs->load("orders");
$outputlangs->load("deliveries");

if ($conf->commande->dir_output)
{
$object->fetch_thirdparty();
Expand Down Expand Up @@ -228,6 +228,15 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$this->atleastonediscount++;
}
}
if (empty($this->atleastonediscount))
{
$this->posxpicture+=($this->postotalht - $this->posxdiscount);
$this->posxtva+=($this->postotalht - $this->posxdiscount);
$this->posxup+=($this->postotalht - $this->posxdiscount);
$this->posxqty+=($this->postotalht - $this->posxdiscount);
$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
//$this->postotalht;
}

// New page
$pdf->AddPage();
Expand Down Expand Up @@ -304,7 +313,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$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($pagenb+1);
$pdf->setPage($pageposafter+1);
}
}
else
Expand Down Expand Up @@ -589,7 +598,7 @@ function _tableau_info(&$pdf, $object, $posy, $outputlangs)
$pdf->SetFont('','B', $default_font_size - 2);
$text=$outputlangs->transnoentities("DeliveryDate").':';
$pdf->MultiCell(80, 3, $text, 0, 'L', 0);

$pdf->SetFont('','', $default_font_size - 2);
$pdf->SetXY($posxval, $posy);
$text=dol_print_date($object->date_livraison,'day','',$outputlangs);
Expand Down
15 changes: 12 additions & 3 deletions htdocs/core/modules/commande/doc/pdf_proforma.modules.php
@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
Expand Down Expand Up @@ -109,7 +109,7 @@ function __construct($db)
$this->posxdiscount=162;
$this->postotalht=174;
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
$this->posxpicture=$this->posxtva - 16; // width of images
$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?16:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
if ($this->page_largeur < 210) // To work with US executive format
{
$this->posxpicture-=20;
Expand Down Expand Up @@ -227,6 +227,15 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$this->atleastonediscount++;
}
}
if (empty($this->atleastonediscount))
{
$this->posxpicture+=($this->postotalht - $this->posxdiscount);
$this->posxtva+=($this->postotalht - $this->posxdiscount);
$this->posxup+=($this->postotalht - $this->posxdiscount);
$this->posxqty+=($this->postotalht - $this->posxdiscount);
$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
//$this->postotalht;
}

// New page
$pdf->AddPage();
Expand Down Expand Up @@ -303,7 +312,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$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($pagenb+1);
$pdf->setPage($pageposafter+1);
}
}
else
Expand Down
17 changes: 13 additions & 4 deletions htdocs/core/modules/facture/doc/pdf_crabe.modules.php
@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
Expand Down Expand Up @@ -109,7 +109,7 @@ function __construct($db)
$this->posxdiscount=162;
$this->postotalht=174;
if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup;
$this->posxpicture=$this->posxtva - 16; // width of images
$this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?16:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
if ($this->page_largeur < 210) // To work with US executive format
{
$this->posxpicture-=20;
Expand Down Expand Up @@ -228,6 +228,15 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$this->atleastonediscount++;
}
}
if (empty($this->atleastonediscount))
{
$this->posxpicture+=($this->postotalht - $this->posxdiscount);
$this->posxtva+=($this->postotalht - $this->posxdiscount);
$this->posxup+=($this->postotalht - $this->posxdiscount);
$this->posxqty+=($this->postotalht - $this->posxdiscount);
$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
//$this->postotalht;
}

// New page
$pdf->AddPage();
Expand Down Expand Up @@ -306,7 +315,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$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($pagenb+1);
$pdf->setPage($pageposafter+1);
}
}
else
Expand Down Expand Up @@ -378,7 +387,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100;

$vatrate=(string) $object->lines[$i]->tva_tx;

// Retrieve type from database for backward compatibility with old records
if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined
&& (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax
Expand Down
31 changes: 20 additions & 11 deletions htdocs/core/modules/livraison/pdf/pdf_typhon.modules.php
@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* Copyright (C) 2008 Chiptronik
Expand Down Expand Up @@ -223,15 +223,24 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right

/*
// Positionne $this->atleastonediscount si on a au moins une remise
for ($i = 0 ; $i < $nblines ; $i++)
{
if ($object->lines[$i]->remise_percent)
{
$this->atleastonediscount++;
}
}
*/
// Positionne $this->atleastonediscount si on a au moins une remise
for ($i = 0 ; $i < $nblines ; $i++)
{
if ($object->lines[$i]->remise_percent)
{
$this->atleastonediscount++;
}
}
if (empty($this->atleastonediscount))
{
$this->posxpicture+=($this->postotalht - $this->posxdiscount);
$this->posxtva+=($this->postotalht - $this->posxdiscount);
$this->posxup+=($this->postotalht - $this->posxdiscount);
$this->posxqty+=($this->postotalht - $this->posxdiscount);
$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
//$this->postotalht;
}
*/

// New page
$pdf->AddPage();
Expand Down Expand Up @@ -307,7 +316,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$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($pagenb+1);
$pdf->setPage($pageposafter+1);
}
}
else
Expand Down
22 changes: 16 additions & 6 deletions htdocs/core/modules/propale/doc/pdf_azur.modules.php
@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2004-2013 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2004-2014 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2008 Raphael Bertrand <raphael.bertrand@resultic.fr>
* Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
Expand Down Expand Up @@ -153,15 +153,15 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$outputlangs->load("products");

$nblignes = count($object->lines);

// Loop on each lines to detect if there is at least one image to show
$realpatharray=array();
if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
{
for ($i = 0 ; $i < $nblignes ; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;

$objphoto = new Product($this->db);
$objphoto->fetch($object->lines[$i]->fk_product);

Expand All @@ -185,7 +185,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
if ($conf->propal->dir_output)
{
$object->fetch_thirdparty();

// $deja_regle = 0;

// Definition of $dir and $file
Expand Down Expand Up @@ -254,6 +254,15 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$this->atleastonediscount++;
}
}
if (empty($this->atleastonediscount))
{
$this->posxpicture+=($this->postotalht - $this->posxdiscount);
$this->posxtva+=($this->postotalht - $this->posxdiscount);
$this->posxup+=($this->postotalht - $this->posxdiscount);
$this->posxqty+=($this->postotalht - $this->posxdiscount);
$this->posxdiscount+=($this->postotalht - $this->posxdiscount);
//$this->postotalht;
}

// New page
$pdf->AddPage();
Expand Down Expand Up @@ -320,7 +329,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$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($pagenb+1);
$pdf->setPage($pageposbefore+1);

$curY = $tab_top_newpage;
$showpricebeforepagebreak=0;
Expand Down Expand Up @@ -358,7 +367,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid
$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($pagenb+1);
$pdf->setPage($pageposafter+1);
}
}
else
Expand All @@ -375,6 +384,7 @@ function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hid

$nexY = $pdf->GetY();
$pageposafter=$pdf->getPage();

$pdf->setPage($pageposbefore);
$pdf->setTopMargin($this->marge_haute);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
Expand Down

0 comments on commit bf735ca

Please sign in to comment.