fix new pdf

This commit is contained in:
Frédéric FRANCE 2018-10-19 18:20:06 +02:00
parent fecb6e49c6
commit c811d5a371
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
4 changed files with 379 additions and 387 deletions

View File

@ -1,10 +1,11 @@
<?php
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
/* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Eric Seigne <eric.seigne@ryxeo.com>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2016 Charlie Benke <charlie@patas-monkey.com>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.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
@ -823,8 +824,8 @@ abstract class CommonDocGenerator
if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
$pdf->line($x, $y+$h, $x, $y);
}
/**
* uasort callback function to Sort colums fields
*
@ -832,17 +833,16 @@ abstract class CommonDocGenerator
* @param array $b PDF lines array fields configs
* @return int Return compare result
*/
function columnSort($a, $b) {
function columnSort($a, $b)
{
if(empty($a['rank'])){ $a['rank'] = 0; }
if(empty($b['rank'])){ $b['rank'] = 0; }
if ($a['rank'] == $b['rank']) {
return 0;
}
return ($a['rank'] > $b['rank']) ? -1 : 1;
}
/**
* Prepare Array Column Field
*
@ -853,34 +853,34 @@ abstract class CommonDocGenerator
* @param int $hideref Do not show ref
* @return null
*/
function prepareArrayColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0){
function prepareArrayColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0)
{
global $conf;
$this->defineColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref);
// Sorting
uasort ( $this->cols, array( $this, 'columnSort' ) );
// Positionning
$curX = $this->page_largeur-$this->marge_droite; // start from right
// Array witdh
$arrayWidth = $this->page_largeur-$this->marge_droite-$this->marge_gauche;
// Count flexible column
$totalDefinedColWidth = 0;
$countFlexCol = 0;
foreach ($this->cols as $colKey =>& $colDef)
{
if(!$this->getColumnStatus($colKey)) continue; // continue if desable
if(!empty($colDef['scale'])){
// In case of column widht is defined by percentage
$colDef['width'] = abs($arrayWidth * $colDef['scale'] / 100 );
}
if(empty($colDef['width'])){
$countFlexCol++;
}
@ -888,7 +888,7 @@ abstract class CommonDocGenerator
$totalDefinedColWidth += $colDef['width'];
}
}
foreach ($this->cols as $colKey =>& $colDef)
{
// setting empty conf with default
@ -898,7 +898,7 @@ abstract class CommonDocGenerator
else{
$colDef['title'] = $this->defaultTitlesFieldsStyle;
}
// setting empty conf with default
if(!empty($colDef['content'])){
$colDef['content'] = array_replace($this->defaultContentsFieldsStyle, $colDef['content']);
@ -906,14 +906,14 @@ abstract class CommonDocGenerator
else{
$colDef['content'] = $this->defaultContentsFieldsStyle;
}
if($this->getColumnStatus($colKey))
{
// In case of flexible column
if(empty($colDef['width'])){
$colDef['width'] = abs(($arrayWidth - $totalDefinedColWidth)) / $countFlexCol;
}
// Set positions
$lastX = $curX;
$curX = $lastX - $colDef['width'];
@ -922,7 +922,7 @@ abstract class CommonDocGenerator
}
}
}
/**
* get column content width from column key
*
@ -934,8 +934,8 @@ abstract class CommonDocGenerator
$colDef = $this->cols[$colKey];
return $colDef['width'] - $colDef['content']['padding'][3] - $colDef['content']['padding'][1];
}
/**
* get column content X (abscissa) left position from column key
*
@ -947,7 +947,7 @@ abstract class CommonDocGenerator
$colDef = $this->cols[$colKey];
return $colDef['xStartPos'] + $colDef['content']['padding'][3];
}
/**
* get column position rank from column key
*
@ -959,7 +959,7 @@ abstract class CommonDocGenerator
if(!isset($this->cols[$colKey]['rank'])) return -1;
return $this->cols[$colKey]['rank'];
}
/**
* get column position rank from column key
*
@ -973,21 +973,21 @@ abstract class CommonDocGenerator
{
// prepare wanted rank
$rank = -1;
// try to get rank from target column
if(!empty($targetCol)){
$rank = $this->getColumnRank($targetCol);
if($rank>=0 && $insertAfterTarget){ $rank++; }
}
// get rank from new column definition
if($rank<0 && !empty($defArray['rank'])){
$rank = $defArray['rank'];
}
// error: no rank
if($rank<0){ return -1; }
foreach ($this->cols as $colKey =>& $colDef)
{
if( $rank <= $colDef['rank'])
@ -995,14 +995,14 @@ abstract class CommonDocGenerator
$colDef['rank'] = $colDef['rank'] + 1;
}
}
$defArray['rank'] = $rank;
$this->cols[$newColKey] = $defArray; // array_replace is used to preserve keys
return $rank;
}
/**
* print standard column content
*
@ -1015,7 +1015,7 @@ abstract class CommonDocGenerator
function printStdColumnContent($pdf, &$curY, $colKey, $columnText = '')
{
global $hookmanager;
$parameters=array(
'object' => $object,
'curY' =>& $curY,
@ -1031,10 +1031,9 @@ abstract class CommonDocGenerator
$colDef = $this->cols[$colKey];
$pdf->MultiCell( $this->getColumnContentWidth($colKey),2, $columnText,'',$colDef['content']['align']);
}
}
/**
* get column status from column key
*

View File

@ -7,6 +7,7 @@
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.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
@ -67,7 +68,7 @@ class pdf_eratosthene extends ModelePDFCommandes
public $type;
/**
* @var array() Minimum version of PHP required by module.
* @var array Minimum version of PHP required by module.
* e.g.: PHP 5.3 = array(5, 3)
*/
public $phpmin = array(5, 2);
@ -136,7 +137,7 @@ class pdf_eratosthene extends ModelePDFCommandes
// Define position of columns
$this->posxdesc=$this->marge_gauche+1;
$this->tva=array();
$this->localtax1=array();
@ -145,7 +146,8 @@ class pdf_eratosthene extends ModelePDFCommandes
$this->atleastonediscount=0;
}
/**
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Function to build pdf onto disk
*
* @param Object $object Object to generate
@ -156,8 +158,9 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param int $hideref Do not show ref
* @return int 1=OK, 0=KO
*/
function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
public function write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
{
// phpcs:enable
global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes;
if (! is_object($outputlangs)) $outputlangs=$langs;
@ -252,7 +255,7 @@ class pdf_eratosthene extends ModelePDFCommandes
break;
}
}
if (empty($this->atleastonediscount) && empty($conf->global->PRODUCT_USE_UNITS))
{
$this->posxpicture+=($this->postotalht - $this->posxdiscount);
@ -316,25 +319,25 @@ class pdf_eratosthene extends ModelePDFCommandes
{
$tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite;
$pageposbeforenote = $pagenb;
$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
$tab_top -= 2;
$pdf->startTransaction();
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
// Description
$pageposafternote=$pdf->getPage();
$posyafter = $pdf->GetY();
if($pageposafternote>$pageposbeforenote )
{
$pdf->rollbackTransaction(true);
// prepar pages to receive notes
while ($pagenb < $pageposafternote) {
$pdf->AddPage();
@ -346,16 +349,16 @@ class pdf_eratosthene extends ModelePDFCommandes
// The only function to edit the bottom margin of current page to set it.
$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
}
// back to start
$pdf->setPage($pageposbeforenote);
$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
$pageposafternote=$pdf->getPage();
$posyafter = $pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20))) // There is no space left for total+free text
{
$pdf->AddPage('','',true);
@ -367,14 +370,14 @@ class pdf_eratosthene extends ModelePDFCommandes
$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
//$posyafter = $tab_top_newpage;
}
// apply note frame to previus pages
$i = $pageposbeforenote;
while ($i < $pageposafternote) {
$pdf->setPage($i);
$pdf->SetDrawColor(128,128,128);
// Draw note frame
if($i>$pageposbeforenote){
@ -385,21 +388,21 @@ class pdf_eratosthene extends ModelePDFCommandes
$height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
$pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1);
}
// Add footer
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
$this->_pagefoot($pdf,$object,$outputlangs,1);
$i++;
}
// apply note frame to last page
$pdf->setPage($pageposafternote);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$height_note=$posyafter-$tab_top_newpage;
$pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1);
}
else // No pagebreak
{
@ -407,8 +410,8 @@ class pdf_eratosthene extends ModelePDFCommandes
$posyafter = $pdf->GetY();
$height_note=$posyafter-$tab_top;
$pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note+1);
if($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)) )
{
// not enough space, need to add page
@ -418,12 +421,12 @@ class pdf_eratosthene extends ModelePDFCommandes
$pdf->setPage($pageposafternote);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$posyafter = $tab_top_newpage;
}
}
$tab_height = $tab_height - $height_note;
$tab_top = $posyafter +6;
}
@ -435,10 +438,10 @@ class pdf_eratosthene extends ModelePDFCommandes
$iniY = $tab_top + 7;
$curY = $tab_top + 7;
$nexY = $tab_top + 7;
// Use new auto collum system
$this->prepareArrayColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref);
// Loop on each lines
$pageposbeforeprintlines=$pdf->getPage();
$pagenb = $pageposbeforeprintlines;
@ -456,7 +459,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$curX = $this->posxdesc-1;
$showpricebeforepagebreak=1;
if($this->getColumnStatus('desc'))
{
$pdf->startTransaction();
@ -493,7 +496,7 @@ class pdf_eratosthene extends ModelePDFCommandes
}
$posYAfterDescription=$pdf->GetY();
}
$nexY = $pdf->GetY();
$pageposafter=$pdf->getPage();
@ -515,7 +518,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
$nexY = max($pdf->GetY(),$nexY);
}
// Unit price before discount
if ($this->getColumnStatus('subprice'))
{
@ -523,7 +526,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
$nexY = max($pdf->GetY(),$nexY);
}
// Quantity
// Enough for 6 chars
if ($this->getColumnStatus('qty'))
@ -532,8 +535,8 @@ class pdf_eratosthene extends ModelePDFCommandes
$this->printStdColumnContent($pdf, $curY, 'qty', $qty);
$nexY = max($pdf->GetY(),$nexY);
}
// Unit
if ($this->getColumnStatus('unit'))
{
@ -541,7 +544,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$this->printStdColumnContent($pdf, $curY, 'unit', $unit);
$nexY = max($pdf->GetY(),$nexY);
}
// Discount on line
if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent)
{
@ -549,7 +552,7 @@ class pdf_eratosthene extends ModelePDFCommandes
$this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
$nexY = max($pdf->GetY(),$nexY);
}
// Total HT line
if ($this->getColumnStatus('totalexcltax'))
{
@ -557,8 +560,8 @@ class pdf_eratosthene extends ModelePDFCommandes
$this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
$nexY = max($pdf->GetY(),$nexY);
}
$parameters=array(
'object' => $object,
'i' => $i,
@ -569,7 +572,7 @@ class pdf_eratosthene extends ModelePDFCommandes
'hidedetails' => $hidedetails
);
$reshook=$hookmanager->executeHooks('printPDFline',$parameters,$this); // Note that $object may have been modified by hook
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
@ -664,16 +667,16 @@ class pdf_eratosthene extends ModelePDFCommandes
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
// Affiche zone infos
$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
$posy=$this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
// Affiche zone totaux
$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
$posy=$this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
// Affiche zone versements
/*
if ($deja_regle)
{
$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
$posy=$this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
}
*/
@ -720,9 +723,8 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param Translate $outputlangs Object langs for output
* @return int <0 if KO, >0 if OK
*/
function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
private function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
{
}
@ -735,7 +737,7 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param Translate $outputlangs Langs object
* @return void
*/
function _tableau_info(&$pdf, $object, $posy, $outputlangs)
private function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
{
global $conf;
$default_font_size = pdf_getPDFFontSize($outputlangs);
@ -922,7 +924,7 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param Translate $outputlangs Objet langs
* @return int Position pour suite
*/
function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
private function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{
global $conf,$mysoc;
@ -1185,7 +1187,7 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param string $currency Currency code
* @return void
*/
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
{
global $conf;
@ -1220,29 +1222,27 @@ class pdf_eratosthene extends ModelePDFCommandes
foreach ($this->cols as $colKey => $colDef)
{
if(!$this->getColumnStatus($colKey)) continue;
// get title label
$colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']);
// Add column separator
if(!empty($colDef['border-left'])){
$pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height);
}
if (empty($hidetop))
{
$pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0] );
$textWidth = $colDef['width'] - $colDef['title']['padding'][3] -$colDef['title']['padding'][1];
$pdf->MultiCell($textWidth,2,$colDef['title']['label'],'',$colDef['title']['align']);
}
}
if (empty($hidetop)){
$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param
}
}
/**
@ -1255,7 +1255,7 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param string $titlekey Translation key to show as title of document
* @return void
*/
function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle")
private function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="PdfOrderTitle")
{
global $conf,$langs,$hookmanager;
@ -1463,15 +1463,15 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param int $hidefreetext 1=Hide free text
* @return int Return height of bottom margin including footer text
*/
function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
private function _pagefoot(&$pdf,$object,$outputlangs,$hidefreetext=0)
{
global $conf;
$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
return pdf_pagefoot($pdf,$outputlangs,'ORDER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
}
/**
* Define Array Column Field
*
@ -1482,22 +1482,22 @@ class pdf_eratosthene extends ModelePDFCommandes
* @param int $hideref Do not show ref
* @return null
*/
function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0){
public function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0)
{
global $conf, $hookmanager;
// Default field style for content
$this->defaultContentsFieldsStyle = array(
'align' => 'R', // R,C,L
'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
);
// Default field style for content
$this->defaultTitlesFieldsStyle = array(
'align' => 'C', // R,C,L
'padding' => array(0.5,0,0.5,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
);
/*
* For exemple
$this->cols['theColKey'] = array(
@ -1515,7 +1515,7 @@ class pdf_eratosthene extends ModelePDFCommandes
),
);
*/
$rank=0; // do not use negative rank
$this->cols['desc'] = array(
'rank' => $rank,
@ -1532,7 +1532,7 @@ class pdf_eratosthene extends ModelePDFCommandes
'align' => 'L',
),
);
$rank = $rank + 10;
$this->cols['photo'] = array(
'rank' => $rank,
@ -1547,13 +1547,13 @@ class pdf_eratosthene extends ModelePDFCommandes
),
'border-left' => false, // remove left line separator
);
if (! empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE))
{
$this->cols['photo']['status'] = true;
}
$rank = $rank + 10;
$this->cols['vat'] = array(
'rank' => $rank,
@ -1564,12 +1564,12 @@ class pdf_eratosthene extends ModelePDFCommandes
),
'border-left' => true, // add left line separator
);
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
{
$this->cols['vat']['status'] = true;
}
$rank = $rank + 10;
$this->cols['subprice'] = array(
'rank' => $rank,
@ -1580,7 +1580,7 @@ class pdf_eratosthene extends ModelePDFCommandes
),
'border-left' => true, // add left line separator
);
$rank = $rank + 10;
$this->cols['qty'] = array(
'rank' => $rank,
@ -1591,7 +1591,7 @@ class pdf_eratosthene extends ModelePDFCommandes
),
'border-left' => true, // add left line separator
);
$rank = $rank + 10;
$this->cols['progress'] = array(
'rank' => $rank,
@ -1602,12 +1602,12 @@ class pdf_eratosthene extends ModelePDFCommandes
),
'border-left' => false, // add left line separator
);
if($this->situationinvoice)
{
$this->cols['progress']['status'] = true;
}
$rank = $rank + 10;
$this->cols['unit'] = array(
'rank' => $rank,
@ -1621,7 +1621,7 @@ class pdf_eratosthene extends ModelePDFCommandes
if($conf->global->PRODUCT_USE_UNITS){
$this->cols['unit']['status'] = true;
}
$rank = $rank + 10;
$this->cols['discount'] = array(
'rank' => $rank,
@ -1635,7 +1635,7 @@ class pdf_eratosthene extends ModelePDFCommandes
if ($this->atleastonediscount){
$this->cols['discount']['status'] = true;
}
$rank = $rank + 10;
$this->cols['totalexcltax'] = array(
'rank' => $rank,
@ -1646,8 +1646,8 @@ class pdf_eratosthene extends ModelePDFCommandes
),
'border-left' => true, // add left line separator
);
$parameters=array(
'object' => $object,
'outputlangs' => $outputlangs,
@ -1655,7 +1655,7 @@ class pdf_eratosthene extends ModelePDFCommandes
'hidedesc' => $hidedesc,
'hideref' => $hideref
);
$reshook=$hookmanager->executeHooks('defineColumnField',$parameters,$this); // Note that $object may have been modified by hook
if ($reshook < 0)
{
@ -1669,7 +1669,5 @@ class pdf_eratosthene extends ModelePDFCommandes
{
$this->cols = $hookmanager->resArray;
}
}
}

View File

@ -8,6 +8,7 @@
* Copyright (C) 2012-2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.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
@ -68,7 +69,7 @@ class pdf_sponge extends ModelePDFFactures
public $type;
/**
* @var array() Minimum version of PHP required by module.
* @var array Minimum version of PHP required by module.
* e.g.: PHP 5.3 = array(5, 3)
*/
public $phpmin = array(5, 2);
@ -108,7 +109,7 @@ class pdf_sponge extends ModelePDFFactures
function __construct($db)
{
global $conf,$langs,$mysoc;
// Translations
$langs->loadLangs(array("main", "bills"));
@ -147,8 +148,8 @@ class pdf_sponge extends ModelePDFFactures
// Define position of columns
$this->posxdesc=$this->marge_gauche+1; // used for notes ans other stuff
// Use new system for position of columns, view $this->defineColumnField()
// Use new system for position of columns, view $this->defineColumnField()
$this->tva=array();
$this->localtax1=array();
@ -159,7 +160,8 @@ class pdf_sponge extends ModelePDFFactures
}
/**
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Function to build pdf onto disk
*
* @param Object $object Object to generate
@ -170,30 +172,31 @@ class pdf_sponge extends ModelePDFFactures
* @param int $hideref Do not show ref
* @return int 1=OK, 0=KO
*/
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
public function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
{
// phpcs:enable
global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
if (! is_object($outputlangs)) $outputlangs=$langs;
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1';
// Translations
$outputlangs->loadLangs(array("main", "bills", "products", "dict", "companies"));
$nblignes = count($object->lines);
// Loop on each lines to detect if there is at least one image to show
$realpatharray=array();
$this->atleastonephoto = false;
if (! empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE))
{
$objphoto = new Product($this->db);
for ($i = 0 ; $i < $nblignes ; $i++)
{
if (empty($object->lines[$i]->fk_product)) continue;
$objphoto->fetch($object->lines[$i]->fk_product);
//var_dump($objphoto->ref);exit;
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
@ -206,14 +209,14 @@ class pdf_sponge extends ModelePDFFactures
$pdir[0] = get_exdir(0,0,0,0,$objphoto,'product') . dol_sanitizeFileName($objphoto->ref).'/'; // default
$pdir[1] = get_exdir($objphoto->id,2,0,0,$objphoto,'product') . $objphoto->id ."/photos/"; // alternative
}
$arephoto = false;
foreach ($pdir as $midir)
{
if (! $arephoto)
{
$dir = $conf->product->dir_output.'/'.$midir;
foreach ($objphoto->liste_photos($dir,1) as $key => $obj)
{
if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) // If CAT_HIGH_QUALITY_IMAGES not defined, we use thumb if defined and then original photo
@ -231,28 +234,28 @@ class pdf_sponge extends ModelePDFFactures
{
$filename=$obj['photo'];
}
$realpath = $dir.$filename;
$arephoto = true;
$this->atleastonephoto = true;
}
}
}
if ($realpath && $arephoto) $realpatharray[$i]=$realpath;
}
}
//if (count($realpatharray) == 0) $this->posxpicture=$this->posxtva;
if ($conf->facture->dir_output)
{
$object->fetch_thirdparty();
$deja_regle = $object->getSommePaiement(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
$amount_credit_notes_included = $object->getSumCreditNotesUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
$amount_deposits_included = $object->getSumDepositsUsed(($conf->multicurrency->enabled && $object->multicurrency_tx != 1) ? 1 : 0);
// Definition of $dir and $file
if ($object->specimen)
{
@ -273,7 +276,7 @@ class pdf_sponge extends ModelePDFFactures
return 0;
}
}
if (file_exists($dir))
{
// Add pdfgeneration hook
@ -286,47 +289,47 @@ class pdf_sponge extends ModelePDFFactures
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
// Set nblignes with the new facture lines content after hook
$nblignes = count($object->lines);
$nbpayments = count($object->getListOfPayments());
// Create pdf instance
$pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$pdf->SetAutoPageBreak(1,0);
$heightforinfotot = 50+(4*$nbpayments); // Height reserved to output the info and total part and payment part
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)?12:22); // Height reserved to output the footer (value include bottom margin)
if (class_exists('TCPDF'))
{
$pdf->setPrintHeader(false);
$pdf->setPrintFooter(false);
}
$pdf->SetFont(pdf_getPDFFont($outputlangs));
// Set path to the background PDF File
if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
{
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
$tplidx = $pdf->importPage(1);
}
$pdf->Open();
$pagenb=0;
$pdf->SetDrawColor(128,128,128);
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
$pdf->SetSubject($outputlangs->transnoentities("PdfInvoiceTitle"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfInvoiceTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
// Does we have at least one line with discount $this->atleastonediscount
foreach ($object->lines as $line) {
if ($line->remise_percent){
@ -334,30 +337,30 @@ class pdf_sponge extends ModelePDFFactures
break;
}
}
// Situation invoice handling
if ($object->situation_cycle_ref)
{
$this->situationinvoice = true;
}
// New page
$pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
$top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
$tab_top = 90+$top_shift;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
$tab_height = 130-$top_shift;
$tab_height_newpage = 150;
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $tab_height_newpage -= $top_shift;
// Incoterm
$height_incoterms = 0;
if ($conf->incoterm->enabled)
@ -366,21 +369,21 @@ class pdf_sponge extends ModelePDFFactures
if ($desc_incoterms)
{
$tab_top -= 2;
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top-1, dol_htmlentitiesbr($desc_incoterms), 0, 1);
$nexY = max($pdf->GetY(),$nexY);
$height_incoterms=$nexY-$tab_top;
// Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192);
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_incoterms+1);
$tab_top = $nexY+6;
$height_incoterms += 4;
}
}
// Affiche notes
$notetoshow=empty($object->note_public)?'':$object->note_public;
if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
@ -394,7 +397,7 @@ class pdf_sponge extends ModelePDFFactures
if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature);
}
}
$pagenb = $pdf->getPage();
if ($notetoshow)
{
@ -402,24 +405,24 @@ class pdf_sponge extends ModelePDFFactures
$tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite;
$pageposbeforenote = $pagenb;
$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
$pdf->startTransaction();
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
// Description
$pageposafternote=$pdf->getPage();
$posyafter = $pdf->GetY();
if($pageposafternote>$pageposbeforenote )
{
$pdf->rollbackTransaction(true);
// prepar pages to receive notes
while ($pagenb < $pageposafternote) {
$pdf->AddPage();
@ -431,16 +434,16 @@ class pdf_sponge extends ModelePDFFactures
// The only function to edit the bottom margin of current page to set it.
$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
}
// back to start
$pdf->setPage($pageposbeforenote);
$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
$pageposafternote=$pdf->getPage();
$posyafter = $pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20))) // There is no space left for total+free text
{
$pdf->AddPage('','',true);
@ -452,14 +455,14 @@ class pdf_sponge extends ModelePDFFactures
$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
//$posyafter = $tab_top_newpage;
}
// apply note frame to previus pages
$i = $pageposbeforenote;
while ($i < $pageposafternote) {
$pdf->setPage($i);
$pdf->SetDrawColor(128,128,128);
// Draw note frame
if($i>$pageposbeforenote){
@ -470,21 +473,21 @@ class pdf_sponge extends ModelePDFFactures
$height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
$pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1);
}
// Add footer
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
$this->_pagefoot($pdf,$object,$outputlangs,1);
$i++;
}
// apply note frame to last page
$pdf->setPage($pageposafternote);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$height_note=$posyafter-$tab_top_newpage;
$pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1);
}
else // No pagebreak
{
@ -492,8 +495,8 @@ class pdf_sponge extends ModelePDFFactures
$posyafter = $pdf->GetY();
$height_note=$posyafter-$tab_top;
$pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note+1);
if($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)) )
{
// not enough space, need to add page
@ -503,12 +506,12 @@ class pdf_sponge extends ModelePDFFactures
$pdf->setPage($pageposafternote);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$posyafter = $tab_top_newpage;
}
}
$tab_height = $tab_height - $height_note;
$tab_top = $posyafter +6;
}
@ -516,36 +519,36 @@ class pdf_sponge extends ModelePDFFactures
{
$height_note=0;
}
$iniY = $tab_top + 7;
$curY = $tab_top + 7;
$nexY = $tab_top + 7;
// Use new auto collum system
$this->prepareArrayColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref);
// Loop on each lines
$pageposbeforeprintlines=$pdf->getPage();
$pagenb = $pageposbeforeprintlines;
for ($i = 0; $i < $nblignes; $i++)
{
$curY = $nexY;
$pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0,0,0);
// Define size of image if we need it
$imglinesize=array();
if (! empty($realpatharray[$i])) $imglinesize=pdf_getSizeForImage($realpatharray[$i]);
$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.
$pageposbefore=$pdf->getPage();
$showpricebeforepagebreak=1;
$posYAfterImage=0;
$posYAfterDescription=0;
if($this->getColumnStatus('photo'))
{
// We start with Photo of product line
@ -554,11 +557,11 @@ class pdf_sponge extends ModelePDFFactures
$pdf->AddPage('','',true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pdf->setPage($pageposbefore+1);
$curY = $tab_top_newpage;
$showpricebeforepagebreak=0;
}
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
{
$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
@ -566,7 +569,7 @@ class pdf_sponge extends ModelePDFFactures
$posYAfterImage=$curY+$imglinesize['height'];
}
}
// Description of product line
if ($this->getColumnStatus('desc'))
{
@ -604,20 +607,20 @@ class pdf_sponge extends ModelePDFFactures
}
$posYAfterDescription=$pdf->GetY();
}
$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.
// We suppose that a too long description or photo were moved completely on next page
if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
}
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
// VAT Rate
if ($this->getColumnStatus('vat'))
{
@ -625,7 +628,7 @@ class pdf_sponge extends ModelePDFFactures
$this->printStdColumnContent($pdf, $curY, 'vat', $vat_rate);
$nexY = max($pdf->GetY(),$nexY);
}
// Unit price before discount
if ($this->getColumnStatus('subprice'))
{
@ -633,7 +636,7 @@ class pdf_sponge extends ModelePDFFactures
$this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
$nexY = max($pdf->GetY(),$nexY);
}
// Quantity
// Enough for 6 chars
if ($this->getColumnStatus('qty'))
@ -642,7 +645,7 @@ class pdf_sponge extends ModelePDFFactures
$this->printStdColumnContent($pdf, $curY, 'qty', $qty);
$nexY = max($pdf->GetY(),$nexY);
}
// Situation progress
if ($this->getColumnStatus('progress'))
{
@ -650,7 +653,7 @@ class pdf_sponge extends ModelePDFFactures
$this->printStdColumnContent($pdf, $curY, 'progress', $progress);
$nexY = max($pdf->GetY(),$nexY);
}
// Unit
if ($this->getColumnStatus('unit'))
{
@ -658,7 +661,7 @@ class pdf_sponge extends ModelePDFFactures
$this->printStdColumnContent($pdf, $curY, 'unit', $unit);
$nexY = max($pdf->GetY(),$nexY);
}
// Discount on line
if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent)
{
@ -666,7 +669,7 @@ class pdf_sponge extends ModelePDFFactures
$this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
$nexY = max($pdf->GetY(),$nexY);
}
// Total HT line
if ($this->getColumnStatus('totalexcltax'))
{
@ -674,8 +677,8 @@ class pdf_sponge extends ModelePDFFactures
$this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
$nexY = max($pdf->GetY(),$nexY);
}
$parameters=array(
'object' => $object,
'i' => $i,
@ -686,9 +689,9 @@ class pdf_sponge extends ModelePDFFactures
'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
@ -701,20 +704,20 @@ class pdf_sponge extends ModelePDFFactures
if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne= $sign * $object->lines[$i]->multicurrency_total_tva;
else $tvaligne= $sign * $object->lines[$i]->total_tva;
}
$localtax1ligne=$object->lines[$i]->total_localtax1;
$localtax2ligne=$object->lines[$i]->total_localtax2;
$localtax1_rate=$object->lines[$i]->localtax1_tx;
$localtax2_rate=$object->lines[$i]->localtax2_tx;
$localtax1_type=$object->lines[$i]->localtax1_type;
$localtax2_type=$object->lines[$i]->localtax2_type;
if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100;
if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100;
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
@ -723,19 +726,19 @@ class pdf_sponge extends ModelePDFFactures
$localtax1_type = $localtaxtmp_array[0];
$localtax2_type = $localtaxtmp_array[2];
}
// retrieve global local tax
if ($localtax1_type && $localtax1ligne != 0)
$this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne;
if ($localtax2_type && $localtax2ligne != 0)
$this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne;
if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*';
if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0;
$this->tva[$vatrate] += $tvaligne;
$nexY = max($nexY,$posYAfterImage);
// Add line
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1))
{
@ -745,9 +748,9 @@ class pdf_sponge extends ModelePDFFactures
$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1);
$pdf->SetLineStyle(array('dash'=>0));
}
$nexY+=2; // Passe espace entre les lignes
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
{
@ -766,7 +769,7 @@ class pdf_sponge extends ModelePDFFactures
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
}
if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
{
if ($pagenb == $pageposafter)
@ -784,9 +787,9 @@ class pdf_sponge extends ModelePDFFactures
$pagenb++;
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
}
}
// Show square
if ($pagenb == $pageposbeforeprintlines)
{
@ -798,38 +801,38 @@ class pdf_sponge extends ModelePDFFactures
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
// Affiche zone infos
$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
$posy=$this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
// Affiche zone totaux
$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
$posy=$this->drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
// Affiche zone versements
if (($deja_regle || $amount_credit_notes_included || $amount_deposits_included) && empty($conf->global->INVOICE_NO_PAYMENT_DETAILS))
{
$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
$posy=$this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
}
// Pied de page
$this->_pagefoot($pdf,$object,$outputlangs);
if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages();
$pdf->Close();
$pdf->Output($file,'F');
// Add pdfgeneration hook
$hookmanager->initHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
$this->result = array('fullpath'=>$file);
return 1; // No error
}
else
@ -855,7 +858,7 @@ class pdf_sponge extends ModelePDFFactures
* @param Translate $outputlangs Object langs for output
* @return int <0 if KO, >0 if OK
*/
function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
{
global $conf;
@ -982,7 +985,6 @@ class pdf_sponge extends ModelePDFFactures
$this->error=$this->db->lasterror();
return -1;
}
}
@ -995,7 +997,7 @@ class pdf_sponge extends ModelePDFFactures
* @param Translate $outputlangs Langs object
* @return void
*/
function _tableau_info(&$pdf, $object, $posy, $outputlangs)
private function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
{
global $conf;
@ -1153,7 +1155,7 @@ class pdf_sponge extends ModelePDFFactures
* @param Translate $outputlangs Objet langs
* @return int Position pour suite
*/
function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
private function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{
global $conf,$mysoc;
@ -1511,29 +1513,27 @@ class pdf_sponge extends ModelePDFFactures
foreach ($this->cols as $colKey => $colDef)
{
if(!$this->getColumnStatus($colKey)) continue;
// get title label
$colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']);
// Add column separator
if(!empty($colDef['border-left'])){
$pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height);
}
if (empty($hidetop))
{
$pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0] );
$textWidth = $colDef['width'] - $colDef['title']['padding'][3] -$colDef['title']['padding'][1];
$pdf->MultiCell($textWidth,2,$colDef['title']['label'],'',$colDef['title']['align']);
}
}
if (empty($hidetop)){
$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param
}
}
/**
@ -1548,7 +1548,7 @@ class pdf_sponge extends ModelePDFFactures
function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
{
global $conf, $langs;
// Translations
$outputlangs->loadLangs(array("main", "bills", "propal", "companies"));
@ -1822,9 +1822,9 @@ class pdf_sponge extends ModelePDFFactures
return pdf_pagefoot($pdf,$outputlangs,'INVOICE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext);
}
/**
* Define Array Column Field
*
@ -1835,22 +1835,22 @@ class pdf_sponge extends ModelePDFFactures
* @param int $hideref Do not show ref
* @return null
*/
function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0){
function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0)
{
global $conf, $hookmanager;
// Default field style for content
$this->defaultContentsFieldsStyle = array(
'align' => 'R', // R,C,L
'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
);
// Default field style for content
$this->defaultTitlesFieldsStyle = array(
'align' => 'C', // R,C,L
'align' => 'C', // R,C,L
'padding' => array(0.5,0,0.5,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
);
/*
* For exemple
$this->cols['theColKey'] = array(
@ -1859,19 +1859,19 @@ class pdf_sponge extends ModelePDFFactures
'title' => array(
'textkey' => 'yourLangKey', // if there is no label, yourLangKey will be translated to replace label
'label' => ' ', // the final label : used fore final generated text
'align' => 'L', // text alignement : R,C,L
'align' => 'L', // text alignement : R,C,L
'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
),
'content' => array(
'align' => 'L', // text alignement : R,C,L
'align' => 'L', // text alignement : R,C,L
'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
),
);
*/
$rank=0; // do not use negative rank
$this->cols['desc'] = array(
'rank' => $rank,
'rank' => $rank,
'width' => false, // only for desc
'status' => true,
'title' => array(
@ -1885,7 +1885,7 @@ class pdf_sponge extends ModelePDFFactures
'align' => 'L',
),
);
// PHOTO
$rank = $rank + 10;
$this->cols['photo'] = array(
@ -1894,20 +1894,20 @@ class pdf_sponge extends ModelePDFFactures
'status' => false,
'title' => array(
'textkey' => 'Photo',
'label' => ' '
'label' => ' '
),
'content' => array(
'padding' => array(0,0,0,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
),
'border-left' => false, // remove left line separator
);
if (! empty($conf->global->MAIN_GENERATE_INVOICES_WITH_PICTURE) && !empty($this->atleastonephoto))
{
$this->cols['photo']['status'] = true;
}
$rank = $rank + 10;
$this->cols['vat'] = array(
'rank' => $rank,
@ -1918,12 +1918,12 @@ class pdf_sponge extends ModelePDFFactures
),
'border-left' => true, // add left line separator
);
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
{
$this->cols['vat']['status'] = true;
}
$rank = $rank + 10;
$this->cols['subprice'] = array(
'rank' => $rank,
@ -1934,7 +1934,7 @@ class pdf_sponge extends ModelePDFFactures
),
'border-left' => true, // add left line separator
);
$rank = $rank + 10;
$this->cols['qty'] = array(
'rank' => $rank,
@ -1945,7 +1945,7 @@ class pdf_sponge extends ModelePDFFactures
),
'border-left' => true, // add left line separator
);
$rank = $rank + 10;
$this->cols['progress'] = array(
'rank' => $rank,
@ -1956,12 +1956,12 @@ class pdf_sponge extends ModelePDFFactures
),
'border-left' => true, // add left line separator
);
if($this->situationinvoice)
{
$this->cols['progress']['status'] = true;
}
$rank = $rank + 10;
$this->cols['unit'] = array(
'rank' => $rank,
@ -1975,7 +1975,7 @@ class pdf_sponge extends ModelePDFFactures
if($conf->global->PRODUCT_USE_UNITS){
$this->cols['unit']['status'] = true;
}
$rank = $rank + 10;
$this->cols['discount'] = array(
'rank' => $rank,
@ -1989,7 +1989,7 @@ class pdf_sponge extends ModelePDFFactures
if ($this->atleastonediscount){
$this->cols['discount']['status'] = true;
}
$rank = $rank + 10;
$this->cols['totalexcltax'] = array(
'rank' => $rank,
@ -2000,8 +2000,8 @@ class pdf_sponge extends ModelePDFFactures
),
'border-left' => true, // add left line separator
);
$parameters=array(
'object' => $object,
'outputlangs' => $outputlangs,
@ -2009,7 +2009,7 @@ class pdf_sponge extends ModelePDFFactures
'hidedesc' => $hidedesc,
'hideref' => $hideref
);
$reshook=$hookmanager->executeHooks('defineColumnField',$parameters,$this); // Note that $object may have been modified by hook
if ($reshook < 0)
{
@ -2023,8 +2023,5 @@ class pdf_sponge extends ModelePDFFactures
{
$this->cols = $hookmanager->resArray;
}
}
}

View File

@ -7,6 +7,7 @@
* Copyright (C) 2012 Cedric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2017 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2018 Frédéric France <frederic.france@netlogic.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
@ -40,24 +41,24 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
*/
class pdf_cyan extends ModelePDFPropales
{
var $db;
var $name;
var $description;
var $update_main_doc_field; // Save the name of generated file as the main doc when generating a doc with this template
var $type;
public $db;
public $name;
public $description;
public $update_main_doc_field; // Save the name of generated file as the main doc when generating a doc with this template
public $type;
var $phpmin = array(4,3,0); // Minimum version of PHP required by module
var $version = 'development';
public $phpmin = array(4,3,0); // Minimum version of PHP required by module
public $version = 'development';
var $page_largeur;
var $page_hauteur;
var $format;
var $marge_gauche;
var $marge_droite;
var $marge_haute;
var $marge_basse;
public $page_largeur;
public $page_hauteur;
public $format;
public $marge_gauche;
public $marge_droite;
public $marge_haute;
public $marge_basse;
var $emetteur; // Objet societe qui emet
public $emetteur; // Objet societe qui emet
/**
@ -65,10 +66,10 @@ class pdf_cyan extends ModelePDFPropales
*
* @param DoliDB $db Database handler
*/
function __construct($db)
public function __construct($db)
{
global $conf,$langs,$mysoc;
// Translations
$langs->loadLangs(array("main", "bills"));
@ -107,8 +108,8 @@ class pdf_cyan extends ModelePDFPropales
// Define position of columns
$this->posxdesc=$this->marge_gauche+1;
$this->tva=array();
$this->localtax1=array();
@ -117,6 +118,7 @@ class pdf_cyan extends ModelePDFPropales
$this->atleastonediscount=0;
}
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.NotCamelCaps
/**
* Function to build pdf onto disk
*
@ -128,8 +130,9 @@ class pdf_cyan extends ModelePDFPropales
* @param int $hideref Do not show ref
* @return int 1=OK, 0=KO
*/
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
public function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0)
{
// phpcs:enable
global $user,$langs,$conf,$mysoc,$db,$hookmanager,$nblignes;
if (! is_object($outputlangs)) $outputlangs=$langs;
@ -286,8 +289,8 @@ class pdf_cyan extends ModelePDFPropales
break;
}
}
// New page
$pdf->AddPage();
@ -308,7 +311,7 @@ class pdf_cyan extends ModelePDFPropales
$tab_top = 90+$top_shift;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42+$top_shift:10);
// Incoterm
$height_incoterms = 0;
@ -353,7 +356,7 @@ class pdf_cyan extends ModelePDFPropales
if ($tmpuser->email) $notetoshow.=', Mail: '.$tmpuser->email;
if ($tmpuser->office_phone) $notetoshow.=', Tel: '.$tmpuser->office_phone;
}
$pagenb = $pdf->getPage();
if ($notetoshow)
{
@ -361,24 +364,24 @@ class pdf_cyan extends ModelePDFPropales
$tab_width = $this->page_largeur-$this->marge_gauche-$this->marge_droite;
$pageposbeforenote = $pagenb;
$substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object);
complete_substitutions_array($substitutionarray, $outputlangs, $object);
$notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
$pdf->startTransaction();
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
// Description
$pageposafternote=$pdf->getPage();
$posyafter = $pdf->GetY();
if($pageposafternote>$pageposbeforenote )
{
$pdf->rollbackTransaction(true);
// prepar pages to receive notes
while ($pagenb < $pageposafternote) {
$pdf->AddPage();
@ -390,16 +393,16 @@ class pdf_cyan extends ModelePDFPropales
// The only function to edit the bottom margin of current page to set it.
$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
}
// back to start
$pdf->setPage($pageposbeforenote);
$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
$pageposafternote=$pdf->getPage();
$posyafter = $pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20))) // There is no space left for total+free text
{
$pdf->AddPage('','',true);
@ -411,14 +414,14 @@ class pdf_cyan extends ModelePDFPropales
$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext);
//$posyafter = $tab_top_newpage;
}
// apply note frame to previus pages
$i = $pageposbeforenote;
while ($i < $pageposafternote) {
$pdf->setPage($i);
$pdf->SetDrawColor(128,128,128);
// Draw note frame
if($i>$pageposbeforenote){
@ -429,21 +432,21 @@ class pdf_cyan extends ModelePDFPropales
$height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
$pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1);
}
// Add footer
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
$this->_pagefoot($pdf,$object,$outputlangs,1);
$i++;
}
// apply note frame to last page
$pdf->setPage($pageposafternote);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$height_note=$posyafter-$tab_top_newpage;
$pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1);
}
else // No pagebreak
{
@ -451,8 +454,8 @@ class pdf_cyan extends ModelePDFPropales
$posyafter = $pdf->GetY();
$height_note=$posyafter-$tab_top;
$pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note+1);
if($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20)) )
{
// not enough space, need to add page
@ -462,12 +465,12 @@ class pdf_cyan extends ModelePDFPropales
$pdf->setPage($pageposafternote);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$posyafter = $tab_top_newpage;
}
}
$tab_height = $tab_height - $height_note;
$tab_top = $posyafter +6;
}
@ -479,10 +482,10 @@ class pdf_cyan extends ModelePDFPropales
$iniY = $tab_top + 7;
$curY = $tab_top + 7;
$nexY = $tab_top + 7;
// Use new auto collum system
$this->prepareArrayColumnField($object,$outputlangs,$hidedetails,$hidedesc,$hideref);
// Loop on each lines
$pageposbeforeprintlines=$pdf->getPage();
$pagenb = $pageposbeforeprintlines;
@ -513,12 +516,12 @@ class pdf_cyan extends ModelePDFPropales
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
//if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->setPage($pageposbefore+1);
$curY = $tab_top_newpage;
$showpricebeforepagebreak=0;
}
if (!empty($this->cols['photo']) && isset($imglinesize['width']) && isset($imglinesize['height']))
{
$pdf->Image($realpatharray[$i], $this->getColumnContentXStart('photo'), $curY, $imglinesize['width'], $imglinesize['height'], '', '', '', 2, 300); // Use 300 dpi
@ -526,7 +529,7 @@ class pdf_cyan extends ModelePDFPropales
$posYAfterImage=$curY+$imglinesize['height'];
}
}
// Description of product line
if($this->getColumnStatus('desc'))
{
@ -540,7 +543,7 @@ class pdf_cyan extends ModelePDFPropales
//print $pageposafter.'-'.$pageposbefore;exit;
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc);
$pageposafter=$pdf->getPage();
$posyafter=$pdf->GetY();
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
@ -596,7 +599,7 @@ class pdf_cyan extends ModelePDFPropales
$this->printStdColumnContent($pdf, $curY, 'subprice', $up_excl_tax);
$nexY = max($pdf->GetY(),$nexY);
}
// Quantity
// Enough for 6 chars
if ($this->getColumnStatus('qty'))
@ -605,8 +608,8 @@ class pdf_cyan extends ModelePDFPropales
$this->printStdColumnContent($pdf, $curY, 'qty', $qty);
$nexY = max($pdf->GetY(),$nexY);
}
// Unit
if ($this->getColumnStatus('unit'))
{
@ -614,7 +617,7 @@ class pdf_cyan extends ModelePDFPropales
$this->printStdColumnContent($pdf, $curY, 'unit', $unit);
$nexY = max($pdf->GetY(),$nexY);
}
// Discount on line
if ($this->getColumnStatus('discount') && $object->lines[$i]->remise_percent)
{
@ -622,7 +625,7 @@ class pdf_cyan extends ModelePDFPropales
$this->printStdColumnContent($pdf, $curY, 'discount', $remise_percent);
$nexY = max($pdf->GetY(),$nexY);
}
// Total HT line
if ($this->getColumnStatus('totalexcltax'))
{
@ -630,8 +633,8 @@ class pdf_cyan extends ModelePDFPropales
$this->printStdColumnContent($pdf, $curY, 'totalexcltax', $total_excl_tax);
$nexY = max($pdf->GetY(),$nexY);
}
$parameters=array(
'object' => $object,
'i' => $i,
@ -642,8 +645,8 @@ class pdf_cyan extends ModelePDFPropales
'hidedetails' => $hidedetails
);
$reshook=$hookmanager->executeHooks('printPDFline',$parameters,$this); // Note that $object may have been modified by hook
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva;
@ -745,23 +748,23 @@ class pdf_cyan extends ModelePDFPropales
}
// Affiche zone infos
$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
$posy=$this->drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
// Affiche zone totaux
$posy=$this->_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
$posy=$this->drawTotalTable($pdf, $object, 0, $bottomlasttab, $outputlangs);
// Affiche zone versements
/*
if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included)
{
$posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs);
$posy=$this->drawPaymentsTable($pdf, $object, $posy, $outputlangs);
}
*/
// Customer signature area
if (empty($conf->global->PROPAL_DISABLE_SIGNATURE))
{
$posy=$this->_signature_area($pdf, $object, $posy, $outputlangs);
$posy=$this->drawSignatureArea($pdf, $object, $posy, $outputlangs);
}
// Pied de page
@ -872,7 +875,7 @@ class pdf_cyan extends ModelePDFPropales
}
}
/**
/**
* Show payments table
*
* @param TCPDF $pdf Object PDF
@ -881,9 +884,8 @@ class pdf_cyan extends ModelePDFPropales
* @param Translate $outputlangs Object langs for output
* @return int <0 if KO, >0 if OK
*/
function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
private function drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
{
}
@ -896,7 +898,7 @@ class pdf_cyan extends ModelePDFPropales
* @param Translate $outputlangs Langs object
* @return void
*/
function _tableau_info(&$pdf, $object, $posy, $outputlangs)
function drawInfoTable(&$pdf, $object, $posy, $outputlangs)
{
global $conf;
$default_font_size = pdf_getPDFFontSize($outputlangs);
@ -1076,7 +1078,7 @@ class pdf_cyan extends ModelePDFPropales
* @param Translate $outputlangs Objet langs
* @return int Position pour suite
*/
function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
private function drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
{
global $conf,$mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs);
@ -1389,29 +1391,27 @@ class pdf_cyan extends ModelePDFPropales
foreach ($this->cols as $colKey => $colDef)
{
if(!$this->getColumnStatus($colKey)) continue;
// get title label
$colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']);
// Add column separator
if(!empty($colDef['border-left'])){
$pdf->line($colDef['xStartPos'], $tab_top, $colDef['xStartPos'], $tab_top + $tab_height);
}
if (empty($hidetop))
{
$pdf->SetXY($colDef['xStartPos'] + $colDef['title']['padding'][3], $tab_top + $colDef['title']['padding'][0] );
$textWidth = $colDef['width'] - $colDef['title']['padding'][3] -$colDef['title']['padding'][1];
$pdf->MultiCell($textWidth,2,$colDef['title']['label'],'',$colDef['title']['align']);
}
}
if (empty($hidetop)){
$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line prend une position y en 2eme param et 4eme param
}
}
/**
@ -1661,7 +1661,7 @@ class pdf_cyan extends ModelePDFPropales
* @param Translate $outputlangs Objet langs
* @return int Position pour suite
*/
function _signature_area(&$pdf, $object, $posy, $outputlangs)
private function drawSignatureArea(&$pdf, $object, $posy, $outputlangs)
{
global $conf;
$default_font_size = pdf_getPDFFontSize($outputlangs);
@ -1686,8 +1686,8 @@ class pdf_cyan extends ModelePDFPropales
return ($tab_hl*7);
}
/**
* Define Array Column Field
*
@ -1698,22 +1698,22 @@ class pdf_cyan extends ModelePDFPropales
* @param int $hideref Do not show ref
* @return null
*/
function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0){
function defineColumnField($object,$outputlangs,$hidedetails=0,$hidedesc=0,$hideref=0)
{
global $conf, $hookmanager;
// Default field style for content
$this->defaultContentsFieldsStyle = array(
'align' => 'R', // R,C,L
'padding' => array(0.5,0.5,0.5,0.5), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
);
// Default field style for content
$this->defaultTitlesFieldsStyle = array(
'align' => 'C', // R,C,L
'padding' => array(0.5,0,0.5,0), // Like css 0 => top , 1 => right, 2 => bottom, 3 => left
);
/*
* For exemple
$this->cols['theColKey'] = array(
@ -1731,7 +1731,7 @@ class pdf_cyan extends ModelePDFPropales
),
);
*/
$rank=0; // do not use negative rank
$this->cols['desc'] = array(
'rank' => $rank,
@ -1748,7 +1748,7 @@ class pdf_cyan extends ModelePDFPropales
'align' => 'L',
),
);
$rank = $rank + 10;
$this->cols['photo'] = array(
'rank' => $rank,
@ -1763,13 +1763,13 @@ class pdf_cyan extends ModelePDFPropales
),
'border-left' => false, // remove left line separator
);
if (! empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE) && !empty($this->atleastonephoto))
{
$this->cols['photo']['status'] = true;
}
$rank = $rank + 10;
$this->cols['vat'] = array(
'rank' => $rank,
@ -1780,12 +1780,12 @@ class pdf_cyan extends ModelePDFPropales
),
'border-left' => true, // add left line separator
);
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
{
$this->cols['vat']['status'] = true;
}
$rank = $rank + 10;
$this->cols['subprice'] = array(
'rank' => $rank,
@ -1796,7 +1796,7 @@ class pdf_cyan extends ModelePDFPropales
),
'border-left' => true, // add left line separator
);
$rank = $rank + 10;
$this->cols['qty'] = array(
'rank' => $rank,
@ -1807,7 +1807,7 @@ class pdf_cyan extends ModelePDFPropales
),
'border-left' => true, // add left line separator
);
$rank = $rank + 10;
$this->cols['progress'] = array(
'rank' => $rank,
@ -1818,12 +1818,12 @@ class pdf_cyan extends ModelePDFPropales
),
'border-left' => false, // add left line separator
);
if($this->situationinvoice)
{
$this->cols['progress']['status'] = true;
}
$rank = $rank + 10;
$this->cols['unit'] = array(
'rank' => $rank,
@ -1837,7 +1837,7 @@ class pdf_cyan extends ModelePDFPropales
if($conf->global->PRODUCT_USE_UNITS){
$this->cols['unit']['status'] = true;
}
$rank = $rank + 10;
$this->cols['discount'] = array(
'rank' => $rank,
@ -1851,7 +1851,7 @@ class pdf_cyan extends ModelePDFPropales
if ($this->atleastonediscount){
$this->cols['discount']['status'] = true;
}
$rank = $rank + 10;
$this->cols['totalexcltax'] = array(
'rank' => $rank,
@ -1862,8 +1862,8 @@ class pdf_cyan extends ModelePDFPropales
),
'border-left' => true, // add left line separator
);
$parameters=array(
'object' => $object,
'outputlangs' => $outputlangs,
@ -1871,7 +1871,7 @@ class pdf_cyan extends ModelePDFPropales
'hidedesc' => $hidedesc,
'hideref' => $hideref
);
$reshook=$hookmanager->executeHooks('defineColumnField',$parameters,$this); // Note that $object may have been modified by hook
if ($reshook < 0)
{
@ -1885,7 +1885,5 @@ class pdf_cyan extends ModelePDFPropales
{
$this->cols = $hookmanager->resArray;
}
}
}