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
@ -832,15 +833,14 @@ 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;
}
/**
@ -853,8 +853,8 @@ 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);
@ -1031,7 +1031,6 @@ abstract class CommonDocGenerator
$colDef = $this->cols[$colKey];
$pdf->MultiCell( $this->getColumnContentWidth($colKey),2, $columnText,'',$colDef['content']['align']);
}
}

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);
@ -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;
@ -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;
@ -1241,8 +1243,6 @@ class pdf_eratosthene extends ModelePDFCommandes
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,7 +1463,7 @@ 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;
@ -1482,8 +1482,8 @@ 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
@ -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);
@ -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,8 +172,9 @@ 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;
@ -800,15 +803,15 @@ class pdf_sponge extends ModelePDFFactures
}
// 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
@ -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;
@ -1532,8 +1534,6 @@ class pdf_sponge extends ModelePDFFactures
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
}
}
/**
@ -1835,8 +1835,8 @@ 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
@ -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,7 +66,7 @@ class pdf_cyan extends ModelePDFPropales
*
* @param DoliDB $db Database handler
*/
function __construct($db)
public function __construct($db)
{
global $conf,$langs,$mysoc;
@ -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;
@ -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);
@ -1410,8 +1412,6 @@ class pdf_cyan extends ModelePDFPropales
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);
@ -1698,8 +1698,8 @@ 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
@ -1885,7 +1885,5 @@ class pdf_cyan extends ModelePDFPropales
{
$this->cols = $hookmanager->resArray;
}
}
}