Skip to content
Snippets Groups Projects
Commit dd87195a authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

Merge branch '3.9' of git@github.com:Dolibarr/dolibarr.git into 3.9

parents ed0ab05b 10df0e33
No related branches found
No related tags found
No related merge requests found
<?php <?php
/* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2015 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com> * Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
* Copyright (C) 2016 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
...@@ -68,7 +69,6 @@ class pdf_standard extends ModeleExpenseReport ...@@ -68,7 +69,6 @@ class pdf_standard extends ModeleExpenseReport
$langs->load("main"); $langs->load("main");
$langs->load("trips"); $langs->load("trips");
$langs->load("project"); $langs->load("project");
$langs->load("trips");
$this->db = $db; $this->db = $db;
$this->name = ""; $this->name = "";
...@@ -91,8 +91,8 @@ class pdf_standard extends ModeleExpenseReport ...@@ -91,8 +91,8 @@ class pdf_standard extends ModeleExpenseReport
$this->option_condreg = 1; // Affiche conditions reglement $this->option_condreg = 1; // Affiche conditions reglement
$this->option_codeproduitservice = 1; // Affiche code produit-service $this->option_codeproduitservice = 1; // Affiche code produit-service
$this->option_multilang = 1; // Dispo en plusieurs langues $this->option_multilang = 1; // Dispo en plusieurs langues
$this->option_escompte = 1; // Affiche si il y a eu escompte $this->option_escompte = 0; // Affiche si il y a eu escompte
$this->option_credit_note = 1; // Support credit notes $this->option_credit_note = 0; // Support credit notes
$this->option_freetext = 1; // Support add of a personalised text $this->option_freetext = 1; // Support add of a personalised text
$this->option_draft_watermark = 1; // Support add of a watermark on drafts $this->option_draft_watermark = 1; // Support add of a watermark on drafts
...@@ -104,14 +104,14 @@ class pdf_standard extends ModeleExpenseReport ...@@ -104,14 +104,14 @@ class pdf_standard extends ModeleExpenseReport
// Define position of columns // Define position of columns
$this->posxpiece=$this->marge_gauche+1; $this->posxpiece=$this->marge_gauche+1;
$this->posxdesc=20; $this->posxcomment=$this->marge_gauche+10;
$this->posxdate=85; $this->posxdate=80;
$this->posxtype=105; $this->posxtype=97;
$this->posxprojet=125; $this->posxprojet=116;
$this->posxtva=145; $this->posxtva=136;
$this->posxup=162; $this->posxup=148;
$this->posxqty=176; $this->posxqty=166;
$this->postotalttc=186; $this->postotalttc=178;
if ($this->page_largeur < 210) // To work with US executive format if ($this->page_largeur < 210) // To work with US executive format
{ {
$this->posxdate-=20; $this->posxdate-=20;
...@@ -127,7 +127,6 @@ class pdf_standard extends ModeleExpenseReport ...@@ -127,7 +127,6 @@ class pdf_standard extends ModeleExpenseReport
$this->localtax1=array(); $this->localtax1=array();
$this->localtax2=array(); $this->localtax2=array();
$this->atleastoneratenotnull=0; $this->atleastoneratenotnull=0;
$this->atleastonediscount=0;
} }
...@@ -199,7 +198,7 @@ class pdf_standard extends ModeleExpenseReport ...@@ -199,7 +198,7 @@ class pdf_standard extends ModeleExpenseReport
// Create pdf instance // Create pdf instance
$pdf=pdf_getInstance($this->format); $pdf=pdf_getInstance($this->format);
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
$heightforinfotot = 50; // Height reserved to output the info and total part $heightforinfotot = 40; // Height reserved to output the info and total part
$heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page $heightforfreetext= (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT)?$conf->global->MAIN_PDF_FREETEXT_HEIGHT:5); // Height reserved to output the free text on last page
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
$pdf->SetAutoPageBreak(1,0); $pdf->SetAutoPageBreak(1,0);
...@@ -230,15 +229,6 @@ class pdf_standard extends ModeleExpenseReport ...@@ -230,15 +229,6 @@ class pdf_standard extends ModeleExpenseReport
$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
// Positionne $this->atleastonediscount si on a au moins une remise
for ($i = 0 ; $i < $nblignes ; $i++)
{
if ($object->lines[$i]->remise_percent)
{
$this->atleastonediscount++;
}
}
// New page // New page
$pdf->AddPage(); $pdf->AddPage();
if (! empty($tplidx)) $pdf->useTemplate($tplidx); if (! empty($tplidx)) $pdf->useTemplate($tplidx);
...@@ -249,9 +239,9 @@ class pdf_standard extends ModeleExpenseReport ...@@ -249,9 +239,9 @@ class pdf_standard extends ModeleExpenseReport
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$tab_top = 95; $tab_top = 95;
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?95:10); $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?65:10);
$tab_height = 110; $tab_height = 130;
$tab_height_newpage = 110; $tab_height_newpage = 150;
// Show notes // Show notes
$notetoshow=empty($object->note_public)?'':$object->note_public; $notetoshow=empty($object->note_public)?'':$object->note_public;
...@@ -297,7 +287,7 @@ class pdf_standard extends ModeleExpenseReport ...@@ -297,7 +287,7 @@ class pdf_standard extends ModeleExpenseReport
$piece_comptable = $i +1; $piece_comptable = $i +1;
$curY = $nexY; $curY = $nexY;
$pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage $pdf->SetFont('','', $default_font_size - 2); // Into loop to work with multipage
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->setTopMargin($tab_top_newpage); $pdf->setTopMargin($tab_top_newpage);
...@@ -305,18 +295,17 @@ class pdf_standard extends ModeleExpenseReport ...@@ -305,18 +295,17 @@ class pdf_standard extends ModeleExpenseReport
$pageposbefore=$pdf->getPage(); $pageposbefore=$pdf->getPage();
// Description of product line // Description of product line
$curX = $this->posxdesc-1; $curX = $this->posxcomment-1;
$showpricebeforepagebreak=1; $showpricebeforepagebreak=1;
// Accountancy piece // Accountancy piece
$pdf->SetFont('','', $default_font_size - 1); $pdf->SetXY($this->posxpiece, $curY);
$pdf->writeHTMLCell($this->posxcomment-$this->posxpiece-1, 3, $this->posxpiece-1, $curY, $piece_comptable, 0, 1); $pdf->MultiCell($this->posxcomment-$this->posxpiece-0.8, 4, $piece_comptable, 0, 'C');
// Comments // Comments
$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY($this->posxcomment, $curY); $pdf->SetXY($this->posxcomment, $curY);
$pdf->writeHTMLCell($this->posxdate-$this->posxdesc-1, 3, $this->posxdesc-1, $curY, $object->lines[$i]->comments, 0, 1); $pdf->writeHTMLCell($this->posxdate-$this->posxcomment-0.8, 4, $this->posxcomment-1, $curY, $object->lines[$i]->comments, 0, 1);
//nexY //nexY
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
...@@ -326,65 +315,51 @@ class pdf_standard extends ModeleExpenseReport ...@@ -326,65 +315,51 @@ class pdf_standard extends ModeleExpenseReport
$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.
// Date // Date
$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY($this->posxdate, $curY); $pdf->SetXY($this->posxdate, $curY);
$pdf->MultiCell($this->posxtype-$this->posxdate-1, 3,dol_print_date($object->lines[$i]->date,"day",false,$outpulangs), 0, 'C'); $pdf->MultiCell($this->posxtype-$this->posxdate-0.8, 4,dol_print_date($object->lines[$i]->date,"day",false,$outpulangs), 0, 'C');
// Type // Type
$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY($this->posxtype, $curY); $pdf->SetXY($this->posxtype, $curY);
$pdf->MultiCell($this->posxprojet-$this->posxtype-1, 3,$outputlangs->transnoentities($object->lines[$i]->type_fees_code), 0, 'C'); $pdf->MultiCell($this->posxprojet-$this->posxtype-0.8, 4,$outputlangs->transnoentities($object->lines[$i]->type_fees_code), 0, 'C');
// Project // Project
$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY($this->posxprojet, $curY); $pdf->SetXY($this->posxprojet, $curY);
$pdf->MultiCell($this->posxtva-$this->posxprojet-1, 3,$object->lines[$i]->projet_ref, 0, 'C'); $pdf->MultiCell($this->posxtva-$this->posxprojet-0.8, 4,$object->lines[$i]->projet_ref, 0, 'C');
// VAT Rate // VAT Rate
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{ {
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY($this->posxtva, $curY); $pdf->SetXY($this->posxtva, $curY);
$pdf->MultiCell($this->posxup-$this->posxtva-1, 3,$vat_rate, 0, 'R'); $pdf->MultiCell($this->posxup-$this->posxtva-0.8, 4,$vat_rate, 0, 'C');
} }
// Unit price // Unit price
$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY($this->posxup, $curY); $pdf->SetXY($this->posxup, $curY);
$pdf->MultiCell($this->posxqty-$this->posxup-1, 3,price($object->lines[$i]->value_unit), 0, 'R'); $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 4,price($object->lines[$i]->value_unit), 0, 'R');
// Quantity // Quantity
$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY($this->posxqty, $curY); $pdf->SetXY($this->posxqty, $curY);
$pdf->MultiCell($this->postotalttc-$this->posxqty, 3,$object->lines[$i]->qty, 0, 'C'); $pdf->MultiCell($this->postotalttc-$this->posxqty-0.8, 4,$object->lines[$i]->qty, 0, 'C');
// Total with all taxes // Total with all taxes
$pdf->SetFont('','', $default_font_size - 1);
$pdf->SetXY($this->postotalttc-1, $curY); $pdf->SetXY($this->postotalttc-1, $curY);
$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 3, price($object->lines[$i]->total_ttc), 0, 'R'); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 4, price($object->lines[$i]->total_ttc), 0, 'R');
$nexY+=5;
// Cherche nombre de lignes a venir pour savoir si place suffisante // Cherche nombre de lignes a venir pour savoir si place suffisante
if ($i < ($nblignes - 1)) // If it's not last line if ($i < ($nblignes - 1)) // If it's not last line
{ {
//on recupere la description du produit suivant //on recupere la description du produit suivant
$follow_descproduitservice = $object->lines[$i+1]->desc; $follow_comment = $object->lines[$i+1]->comments;
//on compte le nombre de ligne afin de verifier la place disponible (largeur de ligne 52 caracteres) //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; $nblineFollowComment = dol_nboflines_bis($follow_descproduitservice,52,$outputlangs->charset_output)*4;
// Et si on affiche dates de validite, on ajoute encore une ligne
if ($object->lines[$i]->date_start && $object->lines[$i]->date_end)
{
$nblineFollowDesc += 4;
}
} }
else // If it's last line else // If it's last line
{ {
$nblineFollowDesc = 0; $nblineFollowComment = 0;
} }
$nexY+=2; // Passe espace entre les lignes $nexY+=4; // Passe espace entre les lignes
// Detect if some page were added automatically and output _tableau for past pages // Detect if some page were added automatically and output _tableau for past pages
while ($pagenb < $pageposafter) while ($pagenb < $pageposafter)
...@@ -591,6 +566,8 @@ class pdf_standard extends ModeleExpenseReport ...@@ -591,6 +566,8 @@ class pdf_standard extends ModeleExpenseReport
$pdf->SetTextColor(111,81,124); $pdf->SetTextColor(111,81,124);
$pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $object->getLibStatut(0), '', 'R'); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$posx, 3, $object->getLibStatut(0), '', 'R');
if ($showaddress)
{
// Sender properties // Sender properties
$carac_emetteur = ''; $carac_emetteur = '';
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->address); $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->address);
...@@ -714,23 +691,30 @@ class pdf_standard extends ModeleExpenseReport ...@@ -714,23 +691,30 @@ class pdf_standard extends ModeleExpenseReport
$pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_PAIEMENT")." : ".dol_print_date($object->date_paiement,"day",false,$outpulangs),0,'L'); $pdf->MultiCell(96,4,$outputlangs->transnoentities("DATE_PAIEMENT")." : ".dol_print_date($object->date_paiement,"day",false,$outpulangs),0,'L');
} }
} }
}
} }
/** /**
* Affiche la grille des lignes de factures * Show table for lines
* *
* @param PDF $pdf Object PDF * @param PDF $pdf Object PDF
* @param int $tab_top Tab top * @param int $tab_top Tab top
* @param int $tab_height Tab height * @param int $tab_height Tab height
* @param int $nexY next y * @param int $nexY next y
* @param Translate $outputlangs Output langs * @param Translate $outputlangs Output langs
* @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
* @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) // Amount in (at tab_top - 1)
...@@ -745,56 +729,86 @@ class pdf_standard extends ModeleExpenseReport ...@@ -745,56 +729,86 @@ class pdf_standard extends ModeleExpenseReport
// Rect prend une longueur en 3eme param // 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); $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 // line prend une position y en 3eme param
if (empty($hidetop))
{
$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5);
}
$pdf->SetFont('','',8); $pdf->SetFont('','',8);
// Accountancy piece // Accountancy piece
if (empty($hidetop))
{
$pdf->SetXY($this->posxpiece-1, $tab_top+1); $pdf->SetXY($this->posxpiece-1, $tab_top+1);
$pdf->MultiCell($this->posxdesc-$this->posxpiece-1,1,'','','R'); $pdf->MultiCell($this->posxcomment-$this->posxpiece-1,1,'','','R');
}
// Comments // Comments
$pdf->line($this->posxdesc-1, $tab_top, $this->posxdesc-1, $tab_top + $tab_height); $pdf->line($this->posxcomment-1, $tab_top, $this->posxcomment-1, $tab_top + $tab_height);
$pdf->SetXY($this->posxdesc-1, $tab_top+1); if (empty($hidetop))
$pdf->MultiCell($this->posxdate-$this->posxdesc-1,1,$outputlangs->transnoentities("Description"),'','L'); {
$pdf->SetXY($this->posxcomment-1, $tab_top+1);
$pdf->MultiCell($this->posxdate-$this->posxcomment-1,1,$outputlangs->transnoentities("Description"),'','L');
}
// Date // Date
$pdf->line($this->posxdate-1, $tab_top, $this->posxdate-1, $tab_top + $tab_height); $pdf->line($this->posxdate-1, $tab_top, $this->posxdate-1, $tab_top + $tab_height);
if (empty($hidetop))
{
$pdf->SetXY($this->posxdate-1, $tab_top+1); $pdf->SetXY($this->posxdate-1, $tab_top+1);
$pdf->MultiCell($this->posxtype-$this->posxdate-1,2, $outputlangs->transnoentities("Date"),'','C'); $pdf->MultiCell($this->posxtype-$this->posxdate-1,2, $outputlangs->transnoentities("Date"),'','C');
}
// Type // Type
$pdf->line($this->posxtype-1, $tab_top, $this->posxtype-1, $tab_top + $tab_height); $pdf->line($this->posxtype-1, $tab_top, $this->posxtype-1, $tab_top + $tab_height);
if (empty($hidetop))
{
$pdf->SetXY($this->posxtype-1, $tab_top+1); $pdf->SetXY($this->posxtype-1, $tab_top+1);
$pdf->MultiCell($this->posxprojet-$this->posxtype-1,2, $outputlangs->transnoentities("Type"),'','C'); $pdf->MultiCell($this->posxprojet-$this->posxtype-1,2, $outputlangs->transnoentities("Type"),'','C');
}
// Project // Project
$pdf->line($this->posxprojet-1, $tab_top, $this->posxprojet-1, $tab_top + $tab_height); $pdf->line($this->posxprojet-1, $tab_top, $this->posxprojet-1, $tab_top + $tab_height);
if (empty($hidetop))
{
$pdf->SetXY($this->posxprojet-1, $tab_top+1); $pdf->SetXY($this->posxprojet-1, $tab_top+1);
$pdf->MultiCell($this->posxtva-$this->posxprojet-1,2, $outputlangs->transnoentities("Project"),'','C'); $pdf->MultiCell($this->posxtva-$this->posxprojet-1,2, $outputlangs->transnoentities("Project"),'','C');
}
// VAT // VAT
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
{ {
$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
if (empty($hidetop))
{
$pdf->SetXY($this->posxtva-1, $tab_top+1); $pdf->SetXY($this->posxtva-1, $tab_top+1);
$pdf->MultiCell($this->posxup-$this->posxtva-1,2, $outputlangs->transnoentities("VAT"),'','C'); $pdf->MultiCell($this->posxup-$this->posxtva-1,2, $outputlangs->transnoentities("VAT"),'','C');
} }
}
// Unit price // Unit price
$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
if (empty($hidetop))
{
$pdf->SetXY($this->posxup-1, $tab_top+1); $pdf->SetXY($this->posxup-1, $tab_top+1);
$pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceU"),'','C'); $pdf->MultiCell($this->posxqty-$this->posxup-1,2, $outputlangs->transnoentities("PriceU"),'','C');
}
// Quantity // Quantity
$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
if (empty($hidetop))
{
$pdf->SetXY($this->posxqty-1, $tab_top+1); $pdf->SetXY($this->posxqty-1, $tab_top+1);
$pdf->MultiCell($this->postotalttc-$this->posxqty,2, $outputlangs->transnoentities("Qty"),'','R'); $pdf->MultiCell($this->postotalttc-$this->posxqty,2, $outputlangs->transnoentities("Qty"),'','R');
}
// Total with all taxes // Total with all taxes
$pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height); $pdf->line($this->postotalttc, $tab_top, $this->postotalttc, $tab_top + $tab_height);
if (empty($hidetop))
{
$pdf->SetXY($this->postotalttc-1, $tab_top+1); $pdf->SetXY($this->postotalttc-1, $tab_top+1);
$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"),'','R'); $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalttc, 2, $outputlangs->transnoentities("TotalTTC"),'','R');
}
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment