Fix: Fix pagebreak. Fix also position for non A4 format.

This commit is contained in:
Laurent Destailleur 2012-10-31 17:14:11 +01:00
parent 0b3a2b744e
commit 8bd2f9cfb5
9 changed files with 705 additions and 409 deletions

View File

@ -78,10 +78,10 @@ class pdf_einstein extends ModelePDFCommandes
$this->page_largeur = $formatarray['width']; $this->page_largeur = $formatarray['width'];
$this->page_hauteur = $formatarray['height']; $this->page_hauteur = $formatarray['height'];
$this->format = array($this->page_largeur,$this->page_hauteur); $this->format = array($this->page_largeur,$this->page_hauteur);
$this->marge_gauche=10; $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
$this->marge_droite=10; $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
$this->marge_haute=10; $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
$this->marge_basse=10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
$this->option_logo = 1; // Affiche logo $this->option_logo = 1; // Affiche logo
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
@ -98,7 +98,7 @@ class pdf_einstein extends ModelePDFCommandes
// Get source company // Get source company
$this->emetteur=$mysoc; $this->emetteur=$mysoc;
if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined
// Define position of columns // Define position of columns
$this->posxdesc=$this->marge_gauche+1; $this->posxdesc=$this->marge_gauche+1;
@ -107,14 +107,14 @@ class pdf_einstein extends ModelePDFCommandes
$this->posxqty=145; $this->posxqty=145;
$this->posxdiscount=162; $this->posxdiscount=162;
$this->postotalht=174; $this->postotalht=174;
if ($this->page_largeur < 210) // To work with US executive format if ($this->page_largeur < 210) // To work with US executive format
{ {
$this->posxtva-=20; $this->posxtva-=20;
$this->posxup-=20; $this->posxup-=20;
$this->posxqty-=20; $this->posxqty-=20;
$this->posxdiscount-=20; $this->posxdiscount-=20;
$this->postotalht-=20; $this->postotalht-=20;
} }
$this->tva=array(); $this->tva=array();
$this->localtax1=array(); $this->localtax1=array();
@ -126,13 +126,13 @@ class pdf_einstein extends ModelePDFCommandes
/** /**
* Function to build pdf onto disk * Function to build pdf onto disk
* *
* @param int $object Id of object to generate * @param Object $object Object to generate
* @param object $outputlangs Lang output object * @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file * @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details * @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc * @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref * @param int $hideref Do not show ref
* @param object $hookmanager Hookmanager object * @param object $hookmanager Hookmanager object
* @return int 1=OK, 0=KO * @return int 1=OK, 0=KO
*/ */
function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
@ -184,9 +184,11 @@ class pdf_einstein extends ModelePDFCommandes
{ {
$nblignes = count($object->lines); $nblignes = count($object->lines);
$pdf=pdf_getInstance($this->format); // Create pdf instance
$heightforinfotot = 50; // Height reserved to output the info and total part (value include bottom margin) $pdf=pdf_getInstance($this->format);
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin) $heightforinfotot = 50; // Height reserved to output the info and total part
$heightforfreetext= 5; // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 10; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0); $pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
@ -273,12 +275,45 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->setTopMargin($tab_top_newpage); $pdf->setTopMargin($tab_top_newpage);
$pdf->setPageOrientation('', 1, $heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore=$pdf->getPage(); $pageposbefore=$pdf->getPage();
// Description of product line // Description of product line
$curX = $this->posxdesc-1; $curX = $this->posxdesc-1;
$showpricebeforepagebreak=1;
$pdf->startTransaction();
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,0,$hookmanager); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
$pageposafter=$pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak
{
$pdf->rollbackTransaction(true);
$pageposafter=$pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
$posyafter=$pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('','',true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
$pdf->setPage($pagenb+1);
}
}
else
{
// We found a page break
$showpricebeforepagebreak=0;
}
}
else // No pagebreak
{
$pdf->commitTransaction();
}
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$pageposafter=$pdf->getPage(); $pageposafter=$pdf->getPage();
@ -287,7 +322,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $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 is moved completely on next page // We suppose that a too long description is moved completely on next page
if ($pageposafter > $pageposbefore) { if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
$pdf->setPage($pageposafter); $curY = $tab_top_newpage; $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
} }
@ -388,13 +423,13 @@ class pdf_einstein extends ModelePDFCommandes
// Show square // Show square
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, 1, 0); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} }
// Affiche zone infos // Affiche zone infos
@ -489,7 +524,9 @@ class pdf_einstein extends ModelePDFCommandes
$posy=$pdf->GetY()+4; $posy=$pdf->GetY()+4;
} }
// Show payments conditions $posxval=52;
// Show payments conditions
if ($object->cond_reglement_code || $object->cond_reglement) if ($object->cond_reglement_code || $object->cond_reglement)
{ {
$pdf->SetFont('','B', $default_font_size - 2); $pdf->SetFont('','B', $default_font_size - 2);
@ -498,7 +535,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->MultiCell(80, 4, $titre, 0, 'L'); $pdf->MultiCell(80, 4, $titre, 0, 'L');
$pdf->SetFont('','', $default_font_size - 2); $pdf->SetFont('','', $default_font_size - 2);
$pdf->SetXY(52, $posy); $pdf->SetXY($posxval, $posy);
$lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc); $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement); $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
$pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L'); $pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
@ -515,7 +552,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetTextColor(200,0,0); $pdf->SetTextColor(200,0,0);
$pdf->SetFont('','B', $default_font_size - 2); $pdf->SetFont('','B', $default_font_size - 2);
$pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0); $pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0);
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$posy=$pdf->GetY()+1; $posy=$pdf->GetY()+1;
@ -533,7 +570,7 @@ class pdf_einstein extends ModelePDFCommandes
$pdf->MultiCell(80, 5, $titre, 0, 'L'); $pdf->MultiCell(80, 5, $titre, 0, 'L');
$pdf->SetFont('','', $default_font_size - 2); $pdf->SetFont('','', $default_font_size - 2);
$pdf->SetXY(50, $posy); $pdf->SetXY($posxval, $posy);
$lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
$pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
@ -817,7 +854,7 @@ class pdf_einstein extends ModelePDFCommandes
* @param string $tab_height Height of table (rectangle) * @param string $tab_height Height of table (rectangle)
* @param int $nexY Y (not used) * @param int $nexY Y (not used)
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @param int $hidetop Hide top bar of array * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
* @param int $hidebottom Hide bottom bar of array * @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -24,17 +24,16 @@
* \brief Fichier de la classe permettant de generer les bordereaux envoi au modele Merou * \brief Fichier de la classe permettant de generer les bordereaux envoi au modele Merou
*/ */
require_once DOL_DOCUMENT_ROOT."/core/modules/expedition/modules_expedition.php"; require_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php';
require_once DOL_DOCUMENT_ROOT."/contact/class/contact.class.php"; require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php';
require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php"); require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'); require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
/** /**
* \class pdf_expedition_merou * Classe permettant de generer les borderaux envoi au modele Merou
* \brief Classe permettant de generer les borderaux envoi au modele Merou
*/ */
Class pdf_expedition_merou extends ModelePdfExpedition class pdf_expedition_merou extends ModelePdfExpedition
{ {
var $emetteur; // Objet societe qui emet var $emetteur; // Objet societe qui emet
@ -50,7 +49,6 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$this->db = $db; $this->db = $db;
$this->name = "merou"; $this->name = "merou";
//$this->description = "Modele Merou A5";
$this->description = $langs->trans("DocumentModelMerou"); $this->description = $langs->trans("DocumentModelMerou");
$this->type = 'pdf'; $this->type = 'pdf';
@ -58,12 +56,12 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$this->page_largeur = $formatarray['width']; $this->page_largeur = $formatarray['width'];
$this->page_hauteur = round($formatarray['height']/2); $this->page_hauteur = round($formatarray['height']/2);
$this->format = array($this->page_largeur,$this->page_hauteur); $this->format = array($this->page_largeur,$this->page_hauteur);
$this->marge_gauche=10; $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
$this->marge_droite=10; $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
$this->marge_haute=10; $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
$this->marge_basse=10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
$this->option_logo = 1; // Affiche logo $this->option_logo = 1;
// Recupere emmetteur // Recupere emmetteur
$this->emetteur=$mysoc; $this->emetteur=$mysoc;
@ -72,13 +70,18 @@ Class pdf_expedition_merou extends ModelePdfExpedition
/** /**
* Fonction generant le document sur le disque * Function to build pdf onto disk
* *
* @param Object &$object Objet expedition a generer (ou id si ancienne methode) * @param Object &$object Object expedition to generate (or id if old method)
* @param Translate $outputlangs Lang output object * @param Translate $outputlangs Lang output object
* @return int 1=ok, 0=ko * @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref
* @param object $hookmanager Hookmanager object
* @return int 1=OK, 0=KO
*/ */
function write_file(&$object, $outputlangs) function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
{ {
global $user,$conf,$langs,$mysoc; global $user,$conf,$langs,$mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
@ -95,13 +98,9 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$outputlangs->load("bills"); $outputlangs->load("bills");
$outputlangs->load("products"); $outputlangs->load("products");
$outputlangs->load("propal"); $outputlangs->load("propal");
$outputlangs->load("sendings");
$outputlangs->load("deliveries"); $outputlangs->load("deliveries");
$outputlangs->load("sendings");
//Generation de la fiche
$this->expe = $object;
//Verification de la configuration
if ($conf->expedition->dir_output) if ($conf->expedition->dir_output)
{ {
$object->fetch_thirdparty(); $object->fetch_thirdparty();
@ -114,13 +113,12 @@ Class pdf_expedition_merou extends ModelePdfExpedition
//Creation du destinataire //Creation du destinataire
$idcontact = $object->$origin->getIdContact('external','SHIPPING'); $idcontact = $object->$origin->getIdContact('external','SHIPPING');
$this->destinataire = new Contact($this->db); $this->destinataire = new Contact($this->db);
if ($idcontact[0]) $this->destinataire->fetch($idcontact[0]); if (! empty($idcontact[0])) $this->destinataire->fetch($idcontact[0]);
//Creation du livreur //Creation du livreur
$idcontact = $object->$origin->getIdContact('internal','LIVREUR'); $idcontact = $object->$origin->getIdContact('internal','LIVREUR');
$this->livreur = new User($this->db); $this->livreur = new User($this->db);
if ($idcontact[0]) $this->livreur->fetch($idcontact[0]); if (! empty($idcontact[0])) $this->livreur->fetch($idcontact[0]);
// Definition de $dir et $file // Definition de $dir et $file
if ($object->specimen) if ($object->specimen)
@ -139,15 +137,20 @@ Class pdf_expedition_merou extends ModelePdfExpedition
{ {
if (dol_mkdir($dir) < 0) if (dol_mkdir($dir) < 0)
{ {
$this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir",$dir); $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
return 0; return 0;
} }
} }
//Si le dossier existe
if (file_exists($dir)) if (file_exists($dir))
{ {
$pdf=pdf_getInstance($this->format,'mm','l'); $nblignes = count($object->lines);
$pdf=pdf_getInstance($this->format,'mm','l');
$heightforinfotot = 0; // Height reserved to output the info and total part
$heightforfreetext= 5; // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 10; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
@ -166,91 +169,130 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$pagenb=0; $pagenb=0;
$pdf->SetDrawColor(128,128,128); $pdf->SetDrawColor(128,128,128);
//Generation de l entete du fichier $pdf->AliasNbPages();
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
$pdf->SetSubject($outputlangs->transnoentities("Sending")); $pdf->SetSubject($outputlangs->transnoentities("Sending"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Sending")); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Sending"));
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); 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 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
$pdf->SetFont('','', $default_font_size - 3);
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
$pagenb++; $pagenb++;
$this->_pagehead($pdf, $this->expe, 1, $outputlangs); $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager);
$pdf->SetFont('','', $default_font_size - 3); $pdf->SetFont('','', $default_font_size - 3);
$pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
//Initialisation des coordonnees $tab_top = 52;
$tab_top = 53; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
$tab_height = $this->page_hauteur - 78; $tab_height = $this->page_hauteur - $tab_top - $heightforfooter;
$tab_height_newpage = $this->page_hauteur - $tab_top_newpage - $heightforfooter;
$pdf->SetFillColor(240,240,240); $pdf->SetFillColor(240,240,240);
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->SetFont('','', $default_font_size - 3);
$pdf->SetXY(10, $tab_top + 5); $pdf->SetXY(10, $tab_top + 5);
$iniY = $pdf->GetY();
$curY = $pdf->GetY();
$nexY = $pdf->GetY();
//Generation du tableau
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs);
$nblignes = count($object->lines); $iniY = $tab_top + 7;
$curY = $tab_top + 7;
$nexY = $tab_top + 7;
for ($i = 0 ; $i < $nblignes ; $i++) $num=count($object->lines);
// Loop on each lines
for ($i = 0; $i < $num; $i++)
{ {
$curY = $nexY;
$pdf->SetFont('','', $default_font_size - 3);
$pdf->SetTextColor(0,0,0);
$pdf->setTopMargin($tab_top_newpage);
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
$pageposbefore=$pdf->getPage();
// Description de la ligne produit // Description de la ligne produit
$libelleproduitservice = pdf_writelinedesc($pdf,$object,$i,$outputlangs,90,3,50,$curY,0,1);
$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 is moved completely on next page
if ($pageposafter > $pageposbefore) {
$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
}
$pdf->SetFont('','', $default_font_size - 3);
//Creation des cases a cocher //Creation des cases a cocher
$pdf->Rect(10+3, $curY+1, 3, 3); $pdf->Rect(10+3, $curY, 3, 3);
$pdf->Rect(20+3, $curY+1, 3, 3); $pdf->Rect(20+3, $curY, 3, 3);
//Insertion de la reference du produit //Insertion de la reference du produit
$pdf->SetXY(30, $curY+1); $pdf->SetXY(30, $curY);
$pdf->SetFont('','B', $default_font_size - 3); $pdf->SetFont('','B', $default_font_size - 3);
$pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($object->lines[$i]->ref), 0, 'L', 0); $pdf->MultiCell(24, 3, $outputlangs->convToOutputCharset($object->lines[$i]->ref), 0, 'L', 0);
//Insertion du libelle
$pdf->SetFont('','', $default_font_size - 3); $pdf->SetXY(140, $curY);
$pdf->SetXY(50, $curY+1);
//$libelleproduitservice=pdf_getlinedesc($object->$origin,$i,$outputlangs);
$libelleproduitservice = pdf_writelinedesc($pdf,$object->$origin,$i,$outputlangs,90,3,50,$curY+1,1);
//$pdf->writeHTMLCell(90, 3, 50, $curY+1, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 'L', 0);
//Insertion de la quantite commandee
$pdf->SetFont('','', $default_font_size - 3);
$pdf->SetXY(140, $curY+1);
$pdf->MultiCell(30, 3, $object->lines[$i]->qty_asked, 0, 'C', 0); $pdf->MultiCell(30, 3, $object->lines[$i]->qty_asked, 0, 'C', 0);
//Insertion de la quantite a envoyer
$pdf->SetFont('','', $default_font_size - 3); $pdf->SetXY(170, $curY);
$pdf->SetXY(170, $curY+1);
$pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'C', 0); $pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped, 0, 'C', 0);
//Generation de la page 2 $nexY+=2; // Passe espace entre les lignes
$curY += (dol_nboflines_bis($libelleproduitservice,0,$outputlangs->charset_output)*3+1);
$nexY = $curY; // Detect if some page were added automatically and output _tableau for past pages
if ($nexY > ($tab_top+$tab_height-10) && $i < $nblignes - 1) while ($pagenb < $pageposafter)
{ {
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $pdf->setPage($pagenb);
$this->_pagefoot($pdf, $object, $outputlangs); if ($pagenb == 1)
$pdf->AliasNbPages(); {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
$curY = $iniY; }
else
{
$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
}
$this->_pagefoot($pdf,$object,$outputlangs,1);
$pagenb++;
$pdf->setPage($pagenb);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
}
if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
{
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
}
else
{
$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
}
$this->_pagefoot($pdf,$object,$outputlangs,1);
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
$pagenb++; $pagenb++;
$this->_pagehead($pdf, $this->expe, 0, $outputlangs);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('','', $default_font_size - 3);
} }
} }
//Insertion du pied de page
$this->_pagefoot($pdf, $object, $outputlangs);
// Show square
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
else
{
$this->_tableau($pdf, $tab_top_newpage - 1, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
}
// Pied de page
$this->_pagefoot($pdf, $object, $outputlangs);
$pdf->AliasNbPages(); $pdf->AliasNbPages();
$pdf->Close(); $pdf->Close();
@ -285,9 +327,11 @@ Class pdf_expedition_merou extends ModelePdfExpedition
* @param string $tab_height Height of table (rectangle) * @param string $tab_height Height of table (rectangle)
* @param int $nexY Y * @param int $nexY Y
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @param int $hidetop Hide top bar of array
* @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
{ {
global $langs; global $langs;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
@ -295,21 +339,24 @@ Class pdf_expedition_merou extends ModelePdfExpedition
$langs->load("main"); $langs->load("main");
$langs->load("bills"); $langs->load("bills");
$pdf->SetFont('','B', $default_font_size - 2); if (empty($hidetop))
$pdf->SetXY(10,$tab_top); {
$pdf->MultiCell(10,5,"LS",0,'C',1); $pdf->SetFont('','B', $default_font_size - 2);
$pdf->line(20, $tab_top, 20, $tab_top + $tab_height); $pdf->SetXY(10,$tab_top);
$pdf->SetXY(20,$tab_top); $pdf->MultiCell(10,5,"LS",0,'C',1);
$pdf->MultiCell(10,5,"LR",0,'C',1); $pdf->line(20, $tab_top, 20, $tab_top + $tab_height);
$pdf->line(30, $tab_top, 30, $tab_top + $tab_height); $pdf->SetXY(20,$tab_top);
$pdf->SetXY(30,$tab_top); $pdf->MultiCell(10,5,"LR",0,'C',1);
$pdf->MultiCell(20,5,$outputlangs->transnoentities("Ref"),0,'C',1); $pdf->line(30, $tab_top, 30, $tab_top + $tab_height);
$pdf->SetXY(50,$tab_top); $pdf->SetXY(30,$tab_top);
$pdf->MultiCell(90,5,$outputlangs->transnoentities("Description"),0,'L',1); $pdf->MultiCell(20,5,$outputlangs->transnoentities("Ref"),0,'C',1);
$pdf->SetXY(140,$tab_top); $pdf->SetXY(50,$tab_top);
$pdf->MultiCell(30,5,$outputlangs->transnoentities("QtyOrdered"),0,'C',1); $pdf->MultiCell(90,5,$outputlangs->transnoentities("Description"),0,'L',1);
$pdf->SetXY(170,$tab_top); $pdf->SetXY(140,$tab_top);
$pdf->MultiCell(30,5,$outputlangs->transnoentities("QtyToShip"),0,'C',1); $pdf->MultiCell(30,5,$outputlangs->transnoentities("QtyOrdered"),0,'C',1);
$pdf->SetXY(170,$tab_top);
$pdf->MultiCell(30,5,$outputlangs->transnoentities("QtyToShip"),0,'C',1);
}
$pdf->Rect(10, $tab_top, 190, $tab_height); $pdf->Rect(10, $tab_top, 190, $tab_height);
} }
@ -319,9 +366,10 @@ Class pdf_expedition_merou extends ModelePdfExpedition
* @param PDF &$pdf PDF * @param PDF &$pdf PDF
* @param Object $object Object to show * @param Object $object Object to show
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output
* @param int $hidefreetext 1=Hide free text
* @return void * @return void
*/ */
function _pagefoot(&$pdf, $object, $outputlangs) function _pagefoot(&$pdf, $object, $outputlangs,$hidefreetext=0)
{ {
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
$pdf->SetFont('','', $default_font_size - 2); $pdf->SetFont('','', $default_font_size - 2);
@ -534,7 +582,7 @@ Class pdf_expedition_merou extends ModelePdfExpedition
if (! empty($usecontact)) if (! empty($usecontact))
{ {
// On peut utiliser le nom de la societe du contact // On peut utiliser le nom de la societe du contact
if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname; if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
else $socname = $object->client->nom; else $socname = $object->client->nom;
$carac_client_name=$outputlangs->convToOutputCharset($socname); $carac_client_name=$outputlangs->convToOutputCharset($socname);
} }

View File

@ -1,6 +1,6 @@
<?php <?php
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2005-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -24,16 +24,15 @@
* \brief Fichier de la classe permettant de generer les bordereaux envoi au modele Rouget * \brief Fichier de la classe permettant de generer les bordereaux envoi au modele Rouget
*/ */
require_once DOL_DOCUMENT_ROOT."/core/modules/expedition/modules_expedition.php"; require_once DOL_DOCUMENT_ROOT.'/core/modules/expedition/modules_expedition.php';
require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php"); require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'); require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
/** /**
* \class pdf_expedition_dorade * Classe permettant de generer les borderaux envoi au modele Rouget
* \brief Classe permettant de generer les borderaux envoi au modele Rouget
*/ */
Class pdf_expedition_rouget extends ModelePdfExpedition class pdf_expedition_rouget extends ModelePdfExpedition
{ {
var $emetteur; // Objet societe qui emet var $emetteur; // Objet societe qui emet
@ -56,10 +55,10 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$this->page_largeur = $formatarray['width']; $this->page_largeur = $formatarray['width'];
$this->page_hauteur = $formatarray['height']; $this->page_hauteur = $formatarray['height'];
$this->format = array($this->page_largeur,$this->page_hauteur); $this->format = array($this->page_largeur,$this->page_hauteur);
$this->marge_gauche=10; $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
$this->marge_droite=10; $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
$this->marge_haute=10; $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
$this->marge_basse=10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
$this->option_logo = 1; $this->option_logo = 1;
@ -69,18 +68,23 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
// Defini position des colonnes // Defini position des colonnes
$this->posxdesc=$this->marge_gauche+1; $this->posxdesc=$this->marge_gauche+1;
$this->posxqtyordered=120; $this->posxqtyordered=$this->page_largeur - $this->marge_droite - 70;
$this->posxqtytoship=160; $this->posxqtytoship=$this->page_largeur - $this->marge_droite - 35;
} }
/** /**
* Fonction generant le document sur le disque * Function to build pdf onto disk
* *
* @param Object &$object Objet expedition a generer (ou id si ancienne methode) * @param Object &$object Object expedition to generate (or id if old method)
* @param Translate $outputlangs Lang output object * @param Translate $outputlangs Lang output object
* @return int 1=ok, 0=ko * @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details
* @param int $hidedesc Do not show desc
* @param int $hideref Do not show ref
* @param object $hookmanager Hookmanager object
* @return int 1=OK, 0=KO
*/ */
function write_file(&$object, $outputlangs) function write_file(&$object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false)
{ {
global $user,$conf,$langs; global $user,$conf,$langs;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
@ -119,14 +123,20 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
{ {
if (dol_mkdir($dir) < 0) if (dol_mkdir($dir) < 0)
{ {
$this->error=$outputlangs->transnoentities("ErrorCanNotCreateDir",$dir); $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir);
return 0; return 0;
} }
} }
if (file_exists($dir)) if (file_exists($dir))
{ {
$pdf=pdf_getInstance($this->format); $nblignes = count($object->lines);
$pdf=pdf_getInstance($this->format);
$heightforinfotot = 0; // Height reserved to output the info and total part
$heightforfreetext= 5; // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 10; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
@ -151,23 +161,24 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$pdf->SetSubject($outputlangs->transnoentities("Sending")); $pdf->SetSubject($outputlangs->transnoentities("Sending"));
$pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($fac->ref)." ".$outputlangs->transnoentities("Sending")); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Sending"));
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); 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 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++; $pagenb++;
$this->_pagehead($pdf, $object, 1, $outputlangs); $this->_pagehead($pdf, $object, 1, $outputlangs, $hookmanager);
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3 $pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$tab_top = 90; $tab_top = 90;
$tab_height = 170; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
$tab_height = 130;
$tab_height_newpage = 150;
if (! empty($object->note_public) || ! empty($object->tracking_number)) if (! empty($object->note_public) || ! empty($object->tracking_number))
{ {
@ -213,32 +224,92 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$height_note=0; $height_note=0;
} }
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $iniY = $tab_top + 7;
$curY = $tab_top + 7;
$nexY = $tab_top + 7; $nexY = $tab_top + 7;
$num=count($object->lines); $num=count($object->lines);
// Loop on each lines
for ($i = 0; $i < $num; $i++) for ($i = 0; $i < $num; $i++)
{ {
$curY = $nexY; $curY = $nexY;
$pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page $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();
// Description de la ligne produit // Description de la ligne produit
pdf_writelinedesc($pdf,$object,$i,$outputlangs,150,3,$this->posxdesc,$curY,0,1); pdf_writelinedesc($pdf,$object,$i,$outputlangs,150,3,$this->posxdesc,$curY,0,1);
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
$nexY = $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.
$pdf->SetXY($this->posxqtyordered+5, $curY); // We suppose that a too long description is moved completely on next page
$pdf->MultiCell(30, 3, $object->lines[$i]->qty_asked,'','C'); if ($pageposafter > $pageposbefore) {
$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
}
$pdf->SetXY($this->posxqtytoship+5, $curY); $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
$pdf->MultiCell(30, 3, $object->lines[$i]->qty_shipped,'','C');
$pdf->SetXY($this->posxqtyordered, $curY);
$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,'','C');
$pdf->SetXY($this->posxqtytoship, $curY);
$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxqtytoship), 3, $object->lines[$i]->qty_shipped,'','C');
$nexY+=2; // Passe espace entre les lignes $nexY+=2; // Passe espace entre les lignes
// Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter)
{
$pdf->setPage($pagenb);
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
}
$this->_pagefoot($pdf,$object,$outputlangs,1);
$pagenb++;
$pdf->setPage($pagenb);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
}
if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
{
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
}
$this->_pagefoot($pdf,$object,$outputlangs,1);
// New page
$pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++;
}
} }
// Show square
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext - $heightforinfotot, 0, $outputlangs, 0, 0);
$bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfreetext - $heightforinfotot + 1;
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter - $heightforfreetext - $heightforinfotot, 0, $outputlangs, 1, 0);
$bottomlasttab=$this->page_hauteur - $heightforfooter - $heightforfreetext - $heightforinfotot + 1;
}
// Pied de page // Pied de page
$this->_pagefoot($pdf,$object,$outputlangs); $this->_pagefoot($pdf,$object,$outputlangs);
@ -275,34 +346,51 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
* @param string $tab_height Height of table (rectangle) * @param string $tab_height Height of table (rectangle)
* @param int $nexY Y * @param int $nexY Y
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @param int $hidetop Hide top bar of array
* @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
{ {
global $conf; global $conf;
// Force to disable hidetop and hidebottom
$hidebottom=0;
if ($hidetop) $hidetop=-1;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
// Amount in (at tab_top - 1)
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->SetDrawColor(128,128,128);
// Rect prend une longueur en 3eme param
$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
// line prend une position y en 3eme param
$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);
$pdf->SetFont('','',$default_font_size - 1); $pdf->SetFont('','',$default_font_size - 1);
$pdf->SetXY($this->posxdesc-1, $tab_top+1); // Output Rect
$pdf->MultiCell(108, 2, $outputlangs->transnoentities("Description"), '', 'L'); $this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect prend une longueur en 3eme param et 4eme param
$pdf->SetDrawColor(128,128,128);
$pdf->SetFont('','',$default_font_size - 1);
if (empty($hidetop))
{
$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);
$pdf->SetXY($this->posxdesc-1, $tab_top+1);
$pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities("Description"), '', 'L');
}
$pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height); $pdf->line($this->posxqtyordered-1, $tab_top, $this->posxqtyordered-1, $tab_top + $tab_height);
$pdf->SetXY($this->posxqtyordered-1, $tab_top+1); if (empty($hidetop))
$pdf->MultiCell(40,2, $outputlangs->transnoentities("QtyOrdered"),'','C'); {
$pdf->SetXY($this->posxqtyordered, $tab_top+1);
$pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities("QtyOrdered"),'','C');
}
$pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height); $pdf->line($this->posxqtytoship-1, $tab_top, $this->posxqtytoship-1, $tab_top + $tab_height);
$pdf->SetXY($this->posxqtytoship-1, $tab_top+1); if (empty($hidetop))
$pdf->MultiCell(40,2, $outputlangs->transnoentities("QtyToShip"),'','C'); {
$pdf->SetXY($this->posxqtytoship, $tab_top+1);
$pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxqtytoship), 2, $outputlangs->transnoentities("QtyToShip"),'','C');
}
} }
/** /**
@ -361,7 +449,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
} }
// Show barcode // Show barcode
if ($conf->barcode->enabled) if (! empty($conf->barcode->enabled))
{ {
$posx=105; $posx=105;
} }
@ -370,7 +458,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$posx=$this->marge_gauche+3; $posx=$this->marge_gauche+3;
} }
//$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30); //$pdf->Rect($this->marge_gauche, $this->marge_haute, $this->page_largeur-$this->marge_gauche-$this->marge_droite, 30);
if ($conf->barcode->enabled) if (! empty($conf->barcode->enabled))
{ {
// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
@ -378,7 +466,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
} }
$pdf->SetDrawColor(128,128,128); $pdf->SetDrawColor(128,128,128);
if ($conf->barcode->enabled) if (! empty($conf->barcode->enabled))
{ {
// TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref // TODO Build code bar with function writeBarCode of barcode module for sending ref $object->ref
//$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3); //$pdf->SetXY($this->marge_gauche+3, $this->marge_haute+3);
@ -386,7 +474,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
} }
$posx=100; $posx=$this->page_largeur - 100 - $this->marge_droite;
$posy=$this->marge_haute; $posy=$this->marge_haute;
$pdf->SetFont('','B', $default_font_size + 2); $pdf->SetFont('','B', $default_font_size + 2);
@ -442,8 +530,8 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$text=$linkedobject->ref; $text=$linkedobject->ref;
if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')'; if ($linkedobject->ref_client) $text.=' ('.$linkedobject->ref_client.')';
$Yoff = $Yoff+8; $Yoff = $Yoff+8;
$pdf->SetXY($this->page_largeur - $this->marge_droite - 60,$Yoff); $pdf->SetXY($this->page_largeur - $this->marge_droite - 100,$Yoff);
$pdf->MultiCell(60, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R'); $pdf->MultiCell(100, 2, $outputlangs->transnoentities("RefOrder") ." : ".$outputlangs->transnoentities($text), 0, 'R');
$Yoff = $Yoff+4; $Yoff = $Yoff+4;
$pdf->SetXY($this->page_largeur - $this->marge_droite - 60,$Yoff); $pdf->SetXY($this->page_largeur - $this->marge_droite - 60,$Yoff);
$pdf->MultiCell(60, 2, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->commande->date,"daytext",false,$outputlangs,true), 0, 'R'); $pdf->MultiCell(60, 2, $outputlangs->transnoentities("Date")." : ".dol_print_date($object->commande->date,"daytext",false,$outputlangs,true), 0, 'R');
@ -454,8 +542,9 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
{ {
// Sender properties // Sender properties
$carac_emetteur=''; $carac_emetteur='';
// Add internal contact of proposal if defined // Add internal contact of origin element if defined
$arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); $arrayidcontact=array();
if (! empty($origin) && is_object($object->$origin)) $arrayidcontact=$object->$origin->getIdContact('internal','SALESREPFOLL');
if (count($arrayidcontact) > 0) if (count($arrayidcontact) > 0)
{ {
$object->fetch_user($arrayidcontact[0]); $object->fetch_user($arrayidcontact[0]);
@ -468,7 +557,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$posx=$this->marge_gauche; $posx=$this->marge_gauche;
$posy=42; $posy=42;
$hautcadre=40; $hautcadre=40;
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=118; if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur - 80 - $this->marge_droite;
// Show sender frame // Show sender frame
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
@ -493,7 +582,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
// If SHIPPING contact defined, we use it // If SHIPPING contact defined, we use it
$usecontact=false; $usecontact=false;
$arrayidcontact=$object->getIdContact('external','SHIPPING'); $arrayidcontact=$object->$origin->getIdContact('external','SHIPPING');
if (count($arrayidcontact) > 0) if (count($arrayidcontact) > 0)
{ {
$usecontact=true; $usecontact=true;
@ -504,7 +593,7 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
if (! empty($usecontact)) if (! empty($usecontact))
{ {
// On peut utiliser le nom de la societe du contact // On peut utiliser le nom de la societe du contact
if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname; if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
else $socname = $object->client->nom; else $socname = $object->client->nom;
$carac_client_name=$outputlangs->convToOutputCharset($socname); $carac_client_name=$outputlangs->convToOutputCharset($socname);
} }
@ -516,27 +605,29 @@ Class pdf_expedition_rouget extends ModelePdfExpedition
$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target'); $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');
// Show recipient // Show recipient
$widthrecbox=100;
if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
$posy=42; $posy=42;
$posx=100; $posx=$this->page_largeur - $this->marge_droite - $widthrecbox;
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
// Show recipient frame // Show recipient frame
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->SetFont('','', $default_font_size - 2); $pdf->SetFont('','', $default_font_size - 2);
$pdf->SetXY($posx,$posy-5); $pdf->SetXY($posx,$posy-5);
$pdf->MultiCell(80, 4, $outputlangs->transnoentities("Recipient").":", 0, 'L'); $pdf->MultiCell($widthrecbox, 4, $outputlangs->transnoentities("Recipient").":", 0, 'L');
$pdf->Rect($posx, $posy, 100, $hautcadre); $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
// Show recipient name // Show recipient name
$pdf->SetXY($posx+2,$posy+3); $pdf->SetXY($posx+2,$posy+3);
$pdf->SetFont('','B', $default_font_size); $pdf->SetFont('','B', $default_font_size);
$pdf->MultiCell(96,4, $carac_client_name, 0, 'L'); $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
// Show recipient information // Show recipient information
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4)); $pdf->SetXY($posx+2,$posy+4+(dol_nboflines_bis($carac_client_name,50)*4));
$pdf->MultiCell(86,4, $carac_client, 0, 'L'); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
} }
} }

View File

@ -78,10 +78,10 @@ class pdf_crabe extends ModelePDFFactures
$this->page_largeur = $formatarray['width']; $this->page_largeur = $formatarray['width'];
$this->page_hauteur = $formatarray['height']; $this->page_hauteur = $formatarray['height'];
$this->format = array($this->page_largeur,$this->page_hauteur); $this->format = array($this->page_largeur,$this->page_hauteur);
$this->marge_gauche=10; $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
$this->marge_droite=10; $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
$this->marge_haute=10; $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
$this->marge_basse=10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
$this->option_logo = 1; // Affiche logo $this->option_logo = 1; // Affiche logo
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
@ -109,12 +109,12 @@ class pdf_crabe extends ModelePDFFactures
$this->postotalht=174; $this->postotalht=174;
if ($this->page_largeur < 210) // To work with US executive format if ($this->page_largeur < 210) // To work with US executive format
{ {
$this->posxtva-=20; $this->posxtva-=20;
$this->posxup-=20; $this->posxup-=20;
$this->posxqty-=20; $this->posxqty-=20;
$this->posxdiscount-=20; $this->posxdiscount-=20;
$this->postotalht-=20; $this->postotalht-=20;
} }
$this->tva=array(); $this->tva=array();
$this->localtax1=array(); $this->localtax1=array();
@ -187,7 +187,8 @@ class pdf_crabe extends ModelePDFFactures
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 50; // Height reserved to output the info and total part $heightforinfotot = 50; // Height reserved to output the info and total part
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin) $heightforfreetext= 5; // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 10; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0); $pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
@ -252,8 +253,6 @@ class pdf_crabe extends ModelePDFFactures
// Rect prend une longueur en 3eme param // Rect prend une longueur en 3eme param
$pdf->SetDrawColor(192,192,192); $pdf->SetDrawColor(192,192,192);
//print $pdf->getStringHeight(200,'SPECIMEN',false,false);
//print "$this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1";exit;
$pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1);
$tab_height = $tab_height - $height_note; $tab_height = $tab_height - $height_note;
@ -276,12 +275,47 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->setTopMargin($tab_top_newpage); $pdf->setTopMargin($tab_top_newpage);
$pdf->setPageOrientation('', 1, $heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore=$pdf->getPage(); $pageposbefore=$pdf->getPage();
// Description of product line // Description of product line
$curX = $this->posxdesc-1; $curX = $this->posxdesc-1;
$showpricebeforepagebreak=1;
$pdf->startTransaction();
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,0,$hookmanager); pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
$pageposafter=$pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak
{
$pdf->rollbackTransaction(true);
$pageposafter=$pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
$pageposafter=$pdf->getPage();
$posyafter=$pdf->GetY();
//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('','',true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
$pdf->setPage($pagenb+1);
}
}
else
{
// We found a page break
$showpricebeforepagebreak=0;
}
}
else // No pagebreak
{
$pdf->commitTransaction();
}
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$pageposafter=$pdf->getPage(); $pageposafter=$pdf->getPage();
@ -290,7 +324,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $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 is moved completely on next page // We suppose that a too long description is moved completely on next page
if ($pageposafter > $pageposbefore) { if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
$pdf->setPage($pageposafter); $curY = $tab_top_newpage; $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
} }
@ -390,13 +424,13 @@ class pdf_crabe extends ModelePDFFactures
// Show square // Show square
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, 1, 0); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} }
// Affiche zone infos // Affiche zone infos
@ -466,14 +500,18 @@ class pdf_crabe extends ModelePDFFactures
$tab3_top = $posy + 8; $tab3_top = $posy + 8;
$tab3_width = 80; $tab3_width = 80;
$tab3_height = 4; $tab3_height = 4;
if ($this->page_largeur < 210) // To work with US executive format
{
$tab3_posx -= 20;
}
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
$pdf->SetFont('','', $default_font_size - 2); $pdf->SetFont('','', $default_font_size - 3);
$pdf->SetXY($tab3_posx, $tab3_top - 5); $pdf->SetXY($tab3_posx, $tab3_top - 4);
$pdf->MultiCell(60, 5, $outputlangs->transnoentities("PaymentsAlreadyDone"), 0, 'L', 0); $pdf->MultiCell(60, 3, $outputlangs->transnoentities("PaymentsAlreadyDone"), 0, 'L', 0);
$pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height); $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width, $tab3_top);
$pdf->SetFont('','', $default_font_size - 4); $pdf->SetFont('','', $default_font_size - 4);
$pdf->SetXY($tab3_posx, $tab3_top); $pdf->SetXY($tab3_posx, $tab3_top);
@ -485,6 +523,8 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetXY($tab3_posx+58, $tab3_top); $pdf->SetXY($tab3_posx+58, $tab3_top);
$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0); $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0);
$pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height);
$y=0; $y=0;
$pdf->SetFont('','', $default_font_size - 4); $pdf->SetFont('','', $default_font_size - 4);
@ -602,6 +642,8 @@ class pdf_crabe extends ModelePDFFactures
$posy=$pdf->GetY()+4; $posy=$pdf->GetY()+4;
} }
$posxval=52;
// Show payments conditions // Show payments conditions
if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement))
{ {
@ -611,7 +653,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->MultiCell(80, 4, $titre, 0, 'L'); $pdf->MultiCell(80, 4, $titre, 0, 'L');
$pdf->SetFont('','', $default_font_size - 2); $pdf->SetFont('','', $default_font_size - 2);
$pdf->SetXY(52, $posy); $pdf->SetXY($posxval, $posy);
$lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc); $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement); $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
$pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L'); $pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
@ -629,7 +671,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
$pdf->SetTextColor(200,0,0); $pdf->SetTextColor(200,0,0);
$pdf->SetFont('','B', $default_font_size - 2); $pdf->SetFont('','B', $default_font_size - 2);
$pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0); $pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0);
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$posy=$pdf->GetY()+1; $posy=$pdf->GetY()+1;
@ -646,7 +688,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->MultiCell(80, 5, $titre, 0, 'L'); $pdf->MultiCell(80, 5, $titre, 0, 'L');
$pdf->SetFont('','', $default_font_size - 2); $pdf->SetFont('','', $default_font_size - 2);
$pdf->SetXY(50, $posy); $pdf->SetXY($posxval, $posy);
$lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
$pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');

View File

@ -3,6 +3,7 @@
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be> * Copyright (C) 2007 Franky Van Liedekerke <franky.van.liedekerke@telenet.be>
* Copyright (C) 2008 Chiptronik * Copyright (C) 2008 Chiptronik
* Copyright (C) 2011-2012 Philippe Grand <philippe.grand@atoo-net.com>
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -26,17 +27,15 @@
* \author Laurent Destailleur * \author Laurent Destailleur
*/ */
require_once(DOL_DOCUMENT_ROOT."/core/modules/livraison/modules_livraison.php"); require_once DOL_DOCUMENT_ROOT.'/core/modules/livraison/modules_livraison.php';
require_once(DOL_DOCUMENT_ROOT."/livraison/class/livraison.class.php"); require_once DOL_DOCUMENT_ROOT.'/livraison/class/livraison.class.php';
require_once(DOL_DOCUMENT_ROOT."/core/lib/company.lib.php"); require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'); require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
/** /**
* \class pdf_typhon * Classe permettant de generer les bons de livraison au modele Typho
* \brief Classe permettant de generer les bons de livraison au modele Typho
*/ */
class pdf_typhon extends ModelePDFDeliveryOrder class pdf_typhon extends ModelePDFDeliveryOrder
{ {
var $emetteur; // Objet societe qui emet var $emetteur; // Objet societe qui emet
@ -65,10 +64,10 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$this->page_largeur = $formatarray['width']; $this->page_largeur = $formatarray['width'];
$this->page_hauteur = $formatarray['height']; $this->page_hauteur = $formatarray['height'];
$this->format = array($this->page_largeur,$this->page_hauteur); $this->format = array($this->page_largeur,$this->page_hauteur);
$this->marge_gauche=10; $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
$this->marge_droite=10; $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
$this->marge_haute=10; $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
$this->marge_basse=10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
$this->option_logo = 1; // Affiche logo FAC_PDF_LOGO $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
@ -88,6 +87,15 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$this->posxqty=168; $this->posxqty=168;
$this->posxdiscount=162; $this->posxdiscount=162;
$this->postotalht=177; $this->postotalht=177;
if ($this->page_largeur < 210) // To work with US executive format
{
$this->posxcomm-=20;
//$this->posxtva-=20;
$this->posxup-=20;
$this->posxqty-=20;
$this->posxdiscount-=20;
$this->postotalht-=20;
}
$this->tva=array(); $this->tva=array();
$this->atleastoneratenotnull=0; $this->atleastoneratenotnull=0;
@ -142,6 +150,10 @@ class pdf_typhon extends ModelePDFDeliveryOrder
if (file_exists($dir)) if (file_exists($dir))
{ {
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 50; // Height reserved to output the info and total part
$heightforfreetext= 5; // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 10; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
{ {
@ -177,10 +189,9 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetCreator("Dolibarr ".DOL_VERSION);
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("DeliveryOrder")); $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("DeliveryOrder"));
if ($conf->global->MAIN_DISABLE_PDF_COMPRESSION) $pdf->SetCompression(false); 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 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
/* /*
// Positionne $this->atleastonediscount si on a au moins une remise // Positionne $this->atleastonediscount si on a au moins une remise
@ -203,8 +214,8 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$tab_top = 90; $tab_top = 90;
$tab_top_newpage = 50; $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
$tab_height = 110; $tab_height = 130;
$tab_height_newpage = 150; $tab_height_newpage = 150;
// Affiche notes // Affiche notes
@ -233,20 +244,35 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$curY = $tab_top + 7; $curY = $tab_top + 7;
$nexY = $tab_top + 7; $nexY = $tab_top + 7;
// Boucle sur les lignes // Loop on each lines
for ($i = 0 ; $i < $nblines ; $i++) for ($i = 0 ; $i < $nblines ; $i++)
{ {
$curY = $nexY; $curY = $nexY;
$pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page $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();
// Description de la ligne produit // Description of product line
//$libelleproduitservice=pdf_getlinedesc($object,$i,$outputlangs); $curX = $this->posxdesc-1;
pdf_writelinedesc($pdf,$object,$i,$outputlangs,108,3,$this->posxdesc-1,$curY); pdf_writelinedesc($pdf,$object,$i,$outputlangs,108,3,$curX,$curY);
//$pdf->writeHTMLCell(108, 3, $this->posxdesc-1, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1);
$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 is moved completely on next page
if ($pageposafter > $pageposbefore) {
$pdf->setPage($pageposafter); $curY = $tab_top_newpage;
}
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
$nexY = $pdf->GetY();
$nexY = $pdf->GetY()+4;
/* /*
// TVA // TVA
@ -281,68 +307,53 @@ class pdf_typhon extends ModelePDFDeliveryOrder
*/ */
$nexY+=2; // Passe espace entre les lignes $nexY+=2; // Passe espace entre les lignes
// Cherche nombre de lignes a venir pour savoir si place suffisante // Detect if some page were added automatically and output _tableau for past pages
if ($i < ($nblines - 1) && empty($hidedesc)) // If it's not last line while ($pagenb < $pageposafter)
{
//on recupere la description du produit suivant
$follow_descproduitservice = $object->lines[$i+1]->desc;
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres)
$nblineFollowDesc = (dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4);
}
else // If it's last line
{
$nblineFollowDesc = 0;
}
// Test if a new page is required
if ($pagenb == 1)
{
$tab_top_in_current_page=$tab_top;
$tab_height_in_current_page=$tab_height;
}
else
{
$tab_top_in_current_page=$tab_top_newpage;
$tab_height_in_current_page=$tab_height_newpage;
}
if (($nexY+$nblineFollowDesc) > ($tab_top_in_current_page+$tab_height_in_current_page) && $i < ($nblines - 1))
{ {
$pdf->setPage($pagenb);
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
} }
$this->_pagefoot($pdf,$object,$outputlangs,1);
$this->_pagefoot($pdf, $object, $outputlangs); $pagenb++;
$pdf->setPage($pagenb);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
}
if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak)
{
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
}
$this->_pagefoot($pdf,$object,$outputlangs,1);
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
$pagenb++; $pagenb++;
$this->_pagehead($pdf, $object, 0, $outputlangs);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->MultiCell(0, 3, ''); // Set interline to 3
$pdf->SetTextColor(0,0,0);
$nexY = $tab_top_newpage + 7;
} }
} }
// Show square // Show square
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
$bottomlasttab=$tab_top + $tab_height + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1;
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
$bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1;
} }
/* /*
* Pied de page * Pied de page
*/ */
@ -384,7 +395,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
if ($pdf->GetY() > 250) if ($pdf->GetY() > 250)
{ {
$this->_pagefoot($pdf,$object,$outputlangs); $this->_pagefoot($pdf,$object,$outputlangs,1);
$pdf->AddPage('P', 'A4'); $pdf->AddPage('P', 'A4');
@ -415,7 +426,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
if (! empty($conf->global->MAIN_UMASK)) if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK)); @chmod($file, octdec($conf->global->MAIN_UMASK));
return 1; // Pas d'erreur return 1;
} }
else else
{ {
@ -437,9 +448,11 @@ class pdf_typhon extends ModelePDFDeliveryOrder
* @param string $tab_height Height of table (rectangle) * @param string $tab_height Height of table (rectangle)
* @param int $nexY Y * @param int $nexY Y
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @param int $hidetop Hide top bar of array
* @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
{ {
global $conf,$mysoc; global $conf,$mysoc;
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
@ -624,9 +637,6 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$pdf->SetXY(102,$posy-5); $pdf->SetXY(102,$posy-5);
$pdf->MultiCell(80,5, $outputlangs->transnoentities("DeliveryAddress").":", 0, 'L'); $pdf->MultiCell(80,5, $outputlangs->transnoentities("DeliveryAddress").":", 0, 'L');
// Cadre client destinataire
$pdf->Rect(100, $posy, 100, $hautcadre);
// If SHIPPING contact defined on invoice, we use it // If SHIPPING contact defined on invoice, we use it
$usecontact=false; $usecontact=false;
$arrayidcontact=$object->commande->getIdContact('external','SHIPPING'); $arrayidcontact=$object->commande->getIdContact('external','SHIPPING');
@ -640,7 +650,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder
if (! empty($usecontact)) if (! empty($usecontact))
{ {
// On peut utiliser le nom de la societe du contact // On peut utiliser le nom de la societe du contact
if ($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) $socname = $object->contact->socname; if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socname = $object->contact->socname;
else $socname = $object->client->nom; else $socname = $object->client->nom;
$carac_client_name=$outputlangs->convToOutputCharset($socname); $carac_client_name=$outputlangs->convToOutputCharset($socname);
} }
@ -651,14 +661,29 @@ class pdf_typhon extends ModelePDFDeliveryOrder
$carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target'); $carac_client=pdf_build_address($outputlangs,$this->emetteur,$object->client,$object->contact,$usecontact,'target');
// Show customer/recipient // Show recipient
$pdf->SetXY(102,$posy+3); $widthrecbox=100;
$pdf->SetFont('','B', $default_font_size); if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format
$pdf->MultiCell(106,4, $carac_client_name, 0, 'L'); $posy=42;
$posx=$this->page_largeur-$this->marge_droite-$widthrecbox;
//if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche;
// Show recipient frame
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('','', $default_font_size - 2);
$pdf->SetXY($posx+2,$posy-5);
//$pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities("BillTo").":",0,'L');
$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
// Show recipient name
$pdf->SetXY($posx+2,$posy+3);
$pdf->SetFont('','B', $default_font_size);
$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L');
// Show recipient information
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY(102,$posy+8); $pdf->SetXY($posx+2,$posy+8);
$pdf->MultiCell(86,4, $carac_client, 0, 'L'); $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L');
} }
} }

View File

@ -62,10 +62,10 @@ class pdf_baleine extends ModelePDFProjects
$this->page_largeur = $formatarray['width']; $this->page_largeur = $formatarray['width'];
$this->page_hauteur = $formatarray['height']; $this->page_hauteur = $formatarray['height'];
$this->format = array($this->page_largeur,$this->page_hauteur); $this->format = array($this->page_largeur,$this->page_hauteur);
$this->marge_gauche=10; $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
$this->marge_droite=10; $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
$this->marge_haute=10; $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
$this->marge_basse=10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
$this->option_logo = 1; // Affiche logo FAC_PDF_LOGO $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
@ -128,7 +128,8 @@ class pdf_baleine extends ModelePDFProjects
{ {
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 50; // Height reserved to output the info and total part $heightforinfotot = 50; // Height reserved to output the info and total part
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin) $heightforfreetext= 5; // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 10; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0); $pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
@ -265,13 +266,13 @@ class pdf_baleine extends ModelePDFProjects
// Show square // Show square
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, 1, 0); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} }
/* /*

View File

@ -77,10 +77,10 @@ class pdf_azur extends ModelePDFPropales
$this->page_largeur = $formatarray['width']; $this->page_largeur = $formatarray['width'];
$this->page_hauteur = $formatarray['height']; $this->page_hauteur = $formatarray['height'];
$this->format = array($this->page_largeur,$this->page_hauteur); $this->format = array($this->page_largeur,$this->page_hauteur);
$this->marge_gauche=10; $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
$this->marge_droite=10; $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
$this->marge_haute=10; $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
$this->marge_basse=10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
$this->option_logo = 1; // Affiche logo $this->option_logo = 1; // Affiche logo
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
@ -97,7 +97,7 @@ class pdf_azur extends ModelePDFPropales
// Get source company // Get source company
$this->emetteur=$mysoc; $this->emetteur=$mysoc;
if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined
// Define position of columns // Define position of columns
$this->posxdesc=$this->marge_gauche+1; $this->posxdesc=$this->marge_gauche+1;
@ -106,14 +106,14 @@ class pdf_azur extends ModelePDFPropales
$this->posxqty=145; $this->posxqty=145;
$this->posxdiscount=162; $this->posxdiscount=162;
$this->postotalht=174; $this->postotalht=174;
if ($this->page_largeur < 210) // To work with US executive format if ($this->page_largeur < 210) // To work with US executive format
{ {
$this->posxtva-=20; $this->posxtva-=20;
$this->posxup-=20; $this->posxup-=20;
$this->posxqty-=20; $this->posxqty-=20;
$this->posxdiscount-=20; $this->posxdiscount-=20;
$this->postotalht-=20; $this->postotalht-=20;
} }
$this->tva=array(); $this->tva=array();
$this->localtax1=array(); $this->localtax1=array();
@ -186,7 +186,8 @@ class pdf_azur extends ModelePDFPropales
// Create pdf instance // Create pdf instance
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 50; // Height reserved to output the info and total part $heightforinfotot = 50; // Height reserved to output the info and total part
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin) $heightforfreetext= 5; // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 10; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0); $pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
@ -234,10 +235,8 @@ class pdf_azur extends ModelePDFPropales
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$tab_top = 90; $tab_top = 90;
$tab_top_middlepage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10);
$tab_height = 130; $tab_height = 130;
$tab_height_middlepage = 200;
$tab_height_newpage = 150; $tab_height_newpage = 150;
// Affiche notes // Affiche notes
@ -274,12 +273,46 @@ class pdf_azur extends ModelePDFPropales
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->setTopMargin($tab_top_newpage); $pdf->setTopMargin($tab_top_newpage);
$pdf->setPageOrientation('', 1, $heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore=$pdf->getPage(); $pageposbefore=$pdf->getPage();
// Description of product line // Description of product line
$curX = $this->posxdesc-1; $curX = $this->posxdesc-1;
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
$showpricebeforepagebreak=1;
$pdf->startTransaction();
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
$pageposafter=$pdf->getPage();
if ($pageposafter > $pageposbefore) // There is a pagebreak
{
$pdf->rollbackTransaction(true);
$pageposafter=$pageposbefore;
//print $pageposafter.'-'.$pageposbefore;exit;
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,0,$hookmanager);
$pageposafter=$pdf->getPage();
$posyafter=$pdf->GetY();
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text
{
if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page
{
$pdf->AddPage('','',true);
if (! empty($tplidx)) $pdf->useTemplate($tplidx);
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs, $hookmanager);
$pdf->setPage($pagenb+1);
}
}
else
{
// We found a page break
$showpricebeforepagebreak=0;
}
}
else // No pagebreak
{
$pdf->commitTransaction();
}
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$pageposafter=$pdf->getPage(); $pageposafter=$pdf->getPage();
@ -288,7 +321,7 @@ class pdf_azur extends ModelePDFPropales
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $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 is moved completely on next page // We suppose that a too long description is moved completely on next page
if ($pageposafter > $pageposbefore) { if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
$pdf->setPage($pageposafter); $curY = $tab_top_newpage; $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
} }
@ -299,31 +332,31 @@ class pdf_azur extends ModelePDFPropales
{ {
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager); $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY($this->posxtva, $curY); $pdf->SetXY($this->posxtva, $curY);
$pdf->MultiCell($this->posxup-$this->posxtva-1, 4, $vat_rate, 0, 'R'); $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, $vat_rate, 0, 'R');
} }
// Unit price before discount // Unit price before discount
$up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager); $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY($this->posxup, $curY); $pdf->SetXY($this->posxup, $curY);
$pdf->MultiCell($this->posxqty-$this->posxup-1, 4, $up_excl_tax, 0, 'R', 0); $pdf->MultiCell($this->posxqty-$this->posxup-1, 3, $up_excl_tax, 0, 'R', 0);
// Quantity // Quantity
$qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails, $hookmanager); $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY($this->posxqty, $curY); $pdf->SetXY($this->posxqty, $curY);
$pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 4, $qty, 0, 'R'); $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $qty, 0, 'R'); // Enough for 6 chars
// Discount on line // Discount on line
$pdf->SetXY($this->posxdiscount, $curY);
if ($object->lines[$i]->remise_percent) if ($object->lines[$i]->remise_percent)
{ {
$pdf->SetXY($this->posxdiscount-2, $curY);
$remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails, $hookmanager); $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 4, $remise_percent, 0, 'R'); $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R');
} }
// Total HT line // Total HT line
$total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager); $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails, $hookmanager);
$pdf->SetXY($this->postotalht, $curY); $pdf->SetXY($this->postotalht, $curY);
$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 4, $total_excl_tax, 0, 'R', 0); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0);
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
$tvaligne=$object->lines[$i]->total_tva; $tvaligne=$object->lines[$i]->total_tva;
@ -388,13 +421,13 @@ class pdf_azur extends ModelePDFPropales
// Show square // Show square
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, 1, 0); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} }
// Affiche zone infos // Affiche zone infos
@ -456,7 +489,7 @@ class pdf_azur extends ModelePDFPropales
* Show payments table * Show payments table
* *
* @param PDF &$pdf Object PDF * @param PDF &$pdf Object PDF
* @param Object $object Object invoice * @param Object $object Object proposal
* @param int $posy Position y in PDF * @param int $posy Position y in PDF
* @param Translate $outputlangs Object langs for output * @param Translate $outputlangs Object langs for output
* @return int <0 if KO, >0 if OK * @return int <0 if KO, >0 if OK
@ -493,6 +526,8 @@ class pdf_azur extends ModelePDFPropales
$posy=$pdf->GetY()+4; $posy=$pdf->GetY()+4;
} }
$posxval=52;
// Show shipping date // Show shipping date
if ($object->date_livraison) if ($object->date_livraison)
{ {
@ -502,7 +537,7 @@ class pdf_azur extends ModelePDFPropales
$titre = $outputlangs->transnoentities("DateDeliveryPlanned").':'; $titre = $outputlangs->transnoentities("DateDeliveryPlanned").':';
$pdf->MultiCell(80, 4, $titre, 0, 'L'); $pdf->MultiCell(80, 4, $titre, 0, 'L');
$pdf->SetFont('','', $default_font_size - 2); $pdf->SetFont('','', $default_font_size - 2);
$pdf->SetXY(82, $posy); $pdf->SetXY($posxval, $posy);
$dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true); $dlp=dol_print_date($object->date_livraison,"daytext",false,$outputlangs,true);
$pdf->MultiCell(80, 4, $dlp, 0, 'L'); $pdf->MultiCell(80, 4, $dlp, 0, 'L');
@ -516,7 +551,7 @@ class pdf_azur extends ModelePDFPropales
$pdf->MultiCell(80, 4, $titre, 0, 'L'); $pdf->MultiCell(80, 4, $titre, 0, 'L');
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->SetFont('','', $default_font_size - 2); $pdf->SetFont('','', $default_font_size - 2);
$pdf->SetXY(82, $posy); $pdf->SetXY($posxval, $posy);
$lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset($object->availability); $lib_availability=$outputlangs->transnoentities("AvailabilityType".$object->availability_code)!=('AvailabilityType'.$object->availability_code)?$outputlangs->transnoentities("AvailabilityType".$object->availability_code):$outputlangs->convToOutputCharset($object->availability);
$lib_availability=str_replace('\n',"\n",$lib_availability); $lib_availability=str_replace('\n',"\n",$lib_availability);
$pdf->MultiCell(80, 4, $lib_availability, 0, 'L'); $pdf->MultiCell(80, 4, $lib_availability, 0, 'L');
@ -525,7 +560,7 @@ class pdf_azur extends ModelePDFPropales
} }
// Show payments conditions // Show payments conditions
if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement)) if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement))
{ {
$pdf->SetFont('','B', $default_font_size - 2); $pdf->SetFont('','B', $default_font_size - 2);
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
@ -533,7 +568,7 @@ class pdf_azur extends ModelePDFPropales
$pdf->MultiCell(80, 4, $titre, 0, 'L'); $pdf->MultiCell(80, 4, $titre, 0, 'L');
$pdf->SetFont('','', $default_font_size - 2); $pdf->SetFont('','', $default_font_size - 2);
$pdf->SetXY(52, $posy); $pdf->SetXY($posxval, $posy);
$lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc); $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement_doc);
$lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement); $lib_condition_paiement=str_replace('\n',"\n",$lib_condition_paiement);
$pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L'); $pdf->MultiCell(80, 4, $lib_condition_paiement,0,'L');
@ -541,8 +576,7 @@ class pdf_azur extends ModelePDFPropales
$posy=$pdf->GetY()+3; $posy=$pdf->GetY()+3;
} }
if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTTERMCOND))
if (empty($conf->global->PROPALE_PDF_HIDE_PAYMENTERMCOND))
{ {
// Check a payment mode is defined // Check a payment mode is defined
/* Not required on a proposal /* Not required on a proposal
@ -570,7 +604,7 @@ class pdf_azur extends ModelePDFPropales
$titre = $outputlangs->transnoentities("PaymentMode").':'; $titre = $outputlangs->transnoentities("PaymentMode").':';
$pdf->MultiCell(80, 5, $titre, 0, 'L'); $pdf->MultiCell(80, 5, $titre, 0, 'L');
$pdf->SetFont('','', $default_font_size - 2); $pdf->SetFont('','', $default_font_size - 2);
$pdf->SetXY(50, $posy); $pdf->SetXY($posxval, $posy);
$lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); $lib_mode_reg=$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code)!=('PaymentType'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentType".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement);
$pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L');
@ -656,12 +690,13 @@ class pdf_azur extends ModelePDFPropales
// Tableau total // Tableau total
$col1x = 120; $col2x = 170; $col1x = 120; $col2x = 170;
if ($this->page_largeur < 210) // To work with US executive format if ($this->page_largeur < 210) // To work with US executive format
{ {
$col2x-=20; $col2x-=20;
} }
$largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
$useborder=0;
$index = 0; $index = 0;
// Total HT // Total HT
@ -670,7 +705,7 @@ class pdf_azur extends ModelePDFPropales
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + 0); $pdf->SetXY($col2x, $tab2_top + 0);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + $object->remise), 0, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + (! empty($object->remise)?$object->remise:0)), 0, 'R', 1);
// Show VAT by rates and total // Show VAT by rates and total
$pdf->SetFillColor(248,248,248); $pdf->SetFillColor(248,248,248);
@ -723,9 +758,9 @@ class pdf_azur extends ModelePDFPropales
{ {
$index++; $index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code), 0, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT1".$mysoc->country_code), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), 0, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax1), $useborder, 'R', 1);
} }
// Total LocalTax2 // Total LocalTax2
@ -733,9 +768,9 @@ class pdf_azur extends ModelePDFPropales
{ {
$index++; $index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->pays_code), 0, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalLT2".$mysoc->country_code), $useborder, 'L', 1);
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), 0, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_localtax2), $useborder, 'R', 1);
} }
} }
else else
@ -758,7 +793,7 @@ class pdf_azur extends ModelePDFPropales
$tvakey=str_replace('*','',$tvakey); $tvakey=str_replace('*','',$tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
} }
$totalvat = $outputlangs->transnoentities("TotalLT1".$mysoc->pays_code).' '; $totalvat = $outputlangs->transnoentities("TotalLT1".$mysoc->country_code).' ';
$totalvat.=vatrate($tvakey,1).$tvacompl; $totalvat.=vatrate($tvakey,1).$tvacompl;
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
@ -786,7 +821,7 @@ class pdf_azur extends ModelePDFPropales
$tvakey=str_replace('*','',$tvakey); $tvakey=str_replace('*','',$tvakey);
$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
} }
$totalvat =$outputlangs->transnoentities("TotalLT2".$mysoc->pays_code).' '; $totalvat =$outputlangs->transnoentities("TotalLT2".$mysoc->country_code).' ';
$totalvat.=vatrate($tvakey,1).$tvacompl; $totalvat.=vatrate($tvakey,1).$tvacompl;
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
@ -798,8 +833,6 @@ class pdf_azur extends ModelePDFPropales
} }
} }
$useborder=0;
// Total TTC // Total TTC
$index++; $index++;
$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@ -854,7 +887,6 @@ class pdf_azur extends ModelePDFPropales
$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1);
// Fin
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetFont('','', $default_font_size - 1);
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
} }
@ -869,9 +901,9 @@ class pdf_azur extends ModelePDFPropales
* @param PDF &$pdf Object PDF * @param PDF &$pdf Object PDF
* @param string $tab_top Top position of table * @param string $tab_top Top position of table
* @param string $tab_height Height of table (rectangle) * @param string $tab_height Height of table (rectangle)
* @param int $nexY Y * @param int $nexY Y (not used)
* @param Translate $outputlangs Langs object * @param Translate $outputlangs Langs object
* @param int $hidetop Hide top bar of array * @param int $hidetop 1=Hide top bar of array and title, 0=Hide nothing, -1=Hide only title
* @param int $hidebottom Hide bottom bar of array * @param int $hidebottom Hide bottom bar of array
* @return void * @return void
*/ */

View File

@ -77,10 +77,10 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$this->page_largeur = $formatarray['width']; $this->page_largeur = $formatarray['width'];
$this->page_hauteur = $formatarray['height']; $this->page_hauteur = $formatarray['height'];
$this->format = array($this->page_largeur,$this->page_hauteur); $this->format = array($this->page_largeur,$this->page_hauteur);
$this->marge_gauche=10; $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
$this->marge_droite=10; $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
$this->marge_haute=10; $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
$this->marge_basse=10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
$this->option_logo = 1; // Affiche logo $this->option_logo = 1; // Affiche logo
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
@ -103,14 +103,14 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$this->posxqty=145; $this->posxqty=145;
$this->posxdiscount=162; $this->posxdiscount=162;
$this->postotalht=174; $this->postotalht=174;
if ($this->page_largeur < 210) // To work with US executive format if ($this->page_largeur < 210) // To work with US executive format
{ {
$this->posxtva-=20; $this->posxtva-=20;
$this->posxup-=20; $this->posxup-=20;
$this->posxqty-=20; $this->posxqty-=20;
$this->posxdiscount-=20; $this->posxdiscount-=20;
$this->postotalht-=20; $this->postotalht-=20;
} }
$this->tva=array(); $this->tva=array();
$this->localtax1=array(); $this->localtax1=array();
@ -132,7 +132,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
* @param object $hookmanager Hookmanager object * @param object $hookmanager Hookmanager object
* @return int 1=OK, 0=KO * @return int 1=OK, 0=KO
*/ */
function write_file($object,$outputlangs='',$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0,$hookmanager=false) function write_file($object, $outputlangs='', $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0, $hookmanager=false)
{ {
global $user,$langs,$conf,$mysoc; global $user,$langs,$conf,$mysoc;
@ -185,7 +185,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 50; // Height reserved to output the info and total part $heightforinfotot = 50; // Height reserved to output the info and total part
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin) $heightforfreetext= 5; // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 10; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0); $pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
@ -271,7 +272,7 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->setTopMargin($tab_top_newpage); $pdf->setTopMargin($tab_top_newpage);
$pdf->setPageOrientation('', 1, $heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore=$pdf->getPage(); $pageposbefore=$pdf->getPage();
// Description of product line // Description of product line
@ -284,10 +285,10 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
$pdf->setTopMargin($this->marge_haute); $pdf->setTopMargin($this->marge_haute);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $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 is moved completely on next page // We suppose that a too long description is moved completely on next page
if ($pageposafter > $pageposbefore) { if ($pageposafter > $pageposbefore) {
$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 $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
@ -376,13 +377,13 @@ if ($pageposafter > $pageposbefore) {
// Show square // Show square
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, 1, 0); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} }
// Affiche zone totaux // Affiche zone totaux
@ -738,14 +739,18 @@ if ($pageposafter > $pageposbefore) {
$tab3_top = $posy + 8; $tab3_top = $posy + 8;
$tab3_width = 80; $tab3_width = 80;
$tab3_height = 4; $tab3_height = 4;
if ($this->page_largeur < 210) // To work with US executive format
{
$tab3_posx -= 20;
}
$default_font_size = pdf_getPDFFontSize($outputlangs); $default_font_size = pdf_getPDFFontSize($outputlangs);
$pdf->SetFont('','', $default_font_size - 2); $pdf->SetFont('','', $default_font_size - 3);
$pdf->SetXY($tab3_posx, $tab3_top - 5); $pdf->SetXY($tab3_posx, $tab3_top - 4);
$pdf->MultiCell(60, 5, $outputlangs->transnoentities("PaymentsAlreadyDone"), 0, 'L', 0); $pdf->MultiCell(60, 3, $outputlangs->transnoentities("PaymentsAlreadyDone"), 0, 'L', 0);
$pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height); $pdf->line($tab3_posx, $tab3_top, $tab3_posx+$tab3_width, $tab3_top);
$pdf->SetFont('','', $default_font_size - 4); $pdf->SetFont('','', $default_font_size - 4);
$pdf->SetXY($tab3_posx, $tab3_top); $pdf->SetXY($tab3_posx, $tab3_top);
@ -757,6 +762,8 @@ if ($pageposafter > $pageposbefore) {
$pdf->SetXY($tab3_posx+58, $tab3_top); $pdf->SetXY($tab3_posx+58, $tab3_top);
$pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0); $pdf->MultiCell(20, 3, $outputlangs->transnoentities("Num"), 0, 'L', 0);
$pdf->line($tab3_posx, $tab3_top-1+$tab3_height, $tab3_posx+$tab3_width, $tab3_top-1+$tab3_height);
$y=0; $y=0;
$pdf->SetFont('','', $default_font_size - 4); $pdf->SetFont('','', $default_font_size - 4);
@ -809,9 +816,10 @@ if ($pageposafter > $pageposbefore) {
* @param Object $object Object to show * @param Object $object Object to show
* @param int $showaddress 0=no, 1=yes * @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output
* @param object $hookmanager Hookmanager object
* @return void * @return void
*/ */
function _pagehead(&$pdf, $object, $showaddress, $outputlangs) function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager)
{ {
global $langs,$conf,$mysoc; global $langs,$conf,$mysoc;
@ -887,6 +895,12 @@ if ($pageposafter > $pageposbefore) {
$pdf->MultiCell(100, 4, strtolower($outputlangs->transnoentities("OrderToProcess")), '', 'R'); $pdf->MultiCell(100, 4, strtolower($outputlangs->transnoentities("OrderToProcess")), '', 'R');
} }
$posy+=2;
$pdf->SetTextColor(0,0,60);
// Show list of linked objects
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager);
if ($showaddress) if ($showaddress)
{ {
// Sender properties // Sender properties

View File

@ -80,10 +80,10 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$this->page_largeur = $formatarray['width']; $this->page_largeur = $formatarray['width'];
$this->page_hauteur = $formatarray['height']; $this->page_hauteur = $formatarray['height'];
$this->format = array($this->page_largeur,$this->page_hauteur); $this->format = array($this->page_largeur,$this->page_hauteur);
$this->marge_gauche=10; $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10;
$this->marge_droite=10; $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10;
$this->marge_haute=10; $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10;
$this->marge_basse=10; $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10;
$this->option_logo = 1; // Affiche logo $this->option_logo = 1; // Affiche logo
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
@ -112,14 +112,14 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$this->posxqty=145; $this->posxqty=145;
$this->posxdiscount=162; $this->posxdiscount=162;
$this->postotalht=174; $this->postotalht=174;
if ($this->page_largeur < 210) // To work with US executive format if ($this->page_largeur < 210) // To work with US executive format
{ {
$this->posxtva-=20; $this->posxtva-=20;
$this->posxup-=20; $this->posxup-=20;
$this->posxqty-=20; $this->posxqty-=20;
$this->posxdiscount-=20; $this->posxdiscount-=20;
$this->postotalht-=20; $this->postotalht-=20;
} }
$this->tva=array(); $this->tva=array();
$this->localtax1=array(); $this->localtax1=array();
@ -197,7 +197,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$heightforinfotot = 50; // Height reserved to output the info and total part $heightforinfotot = 50; // Height reserved to output the info and total part
$heightforfooter = 25; // Height reserved to output the footer (value include bottom margin) $heightforfreetext= 5; // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 10; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0); $pdf->SetAutoPageBreak(1,0);
if (class_exists('TCPDF')) if (class_exists('TCPDF'))
@ -283,7 +284,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->setTopMargin($tab_top_newpage); $pdf->setTopMargin($tab_top_newpage);
$pdf->setPageOrientation('', 1, $heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it.
$pageposbefore=$pdf->getPage(); $pageposbefore=$pdf->getPage();
// Description of product line // Description of product line
@ -296,10 +297,10 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
$pdf->setTopMargin($this->marge_haute); $pdf->setTopMargin($this->marge_haute);
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. $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 is moved completely on next page // We suppose that a too long description is moved completely on next page
if ($pageposafter > $pageposbefore) { if ($pageposafter > $pageposbefore) {
$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 $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut
@ -393,13 +394,13 @@ if ($pageposafter > $pageposbefore) {
// Show square // Show square
if ($pagenb == 1) if ($pagenb == 1)
{ {
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0); $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} }
else else
{ {
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, 1, 0); $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfooter + 1; $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
} }
// Affiche zone infos // Affiche zone infos
@ -908,9 +909,10 @@ if ($pageposafter > $pageposbefore) {
* @param Object $object Object to show * @param Object $object Object to show
* @param int $showaddress 0=no, 1=yes * @param int $showaddress 0=no, 1=yes
* @param Translate $outputlangs Object lang for output * @param Translate $outputlangs Object lang for output
* @param object $hookmanager Hookmanager object
* @return void * @return void
*/ */
function _pagehead(&$pdf, $object, $showaddress, $outputlangs) function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $hookmanager)
{ {
global $langs,$conf,$mysoc; global $langs,$conf,$mysoc;
@ -992,6 +994,10 @@ if ($pageposafter > $pageposbefore) {
} }
$posy+=2; $posy+=2;
$pdf->SetTextColor(0,0,60);
// Show list of linked objects
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size, $hookmanager);
if ($showaddress) if ($showaddress)
{ {