|
1
|
|
|
<?php |
|
2
|
|
|
/* Copyright (C) 2010-2011 Juanjo Menent <[email protected]> |
|
3
|
|
|
* Copyright (C) 2010-2014 Laurent Destailleur <[email protected]> |
|
4
|
|
|
* Copyright (C) 2015 Marcos García <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* This program is free software; you can redistribute it and/or modify |
|
7
|
|
|
* it under the terms of the GNU General Public License as published by |
|
8
|
|
|
* the Free Software Foundation; either version 3 of the License, or |
|
9
|
|
|
* (at your option) any later version. |
|
10
|
|
|
* |
|
11
|
|
|
* This program is distributed in the hope that it will be useful, |
|
12
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14
|
|
|
* GNU General Public License for more details. |
|
15
|
|
|
* |
|
16
|
|
|
* You should have received a copy of the GNU General Public License |
|
17
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
18
|
|
|
* or see http://www.gnu.org/ |
|
19
|
|
|
*/ |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* \file htdocs/core/modules/supplier_invoice/pdf/pdf_canelle.modules.php |
|
23
|
|
|
* \ingroup fournisseur |
|
24
|
|
|
* \brief Class file to generate the supplier invoices with the canelle model |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/modules/supplier_payment/modules_supplier_payment.php'; |
|
28
|
|
|
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; |
|
29
|
|
|
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php'; |
|
30
|
|
|
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; |
|
31
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; |
|
32
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; |
|
33
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/functionsnumtoword.lib.php'; |
|
34
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Class to generate the supplier invoices with the canelle model |
|
38
|
|
|
*/ |
|
39
|
|
|
class pdf_cow extends ModelePDFSuppliersPayments |
|
40
|
|
|
{ |
|
41
|
|
|
var $db; |
|
42
|
|
|
var $name; |
|
43
|
|
|
var $description; |
|
44
|
|
|
var $type; |
|
45
|
|
|
|
|
46
|
|
|
var $phpmin = array(4,3,0); // Minimum version of PHP required by module |
|
47
|
|
|
var $version = 'dolibarr'; |
|
48
|
|
|
|
|
49
|
|
|
var $page_largeur; |
|
50
|
|
|
var $page_hauteur; |
|
51
|
|
|
var $format; |
|
52
|
|
|
var $marge_gauche; |
|
53
|
|
|
var $marge_droite; |
|
54
|
|
|
var $marge_haute; |
|
55
|
|
|
var $marge_basse; |
|
56
|
|
|
|
|
57
|
|
|
var $emetteur; // Objet societe qui emet |
|
58
|
|
|
|
|
59
|
|
|
|
|
60
|
|
|
/** |
|
61
|
|
|
* Constructor |
|
62
|
|
|
* |
|
63
|
|
|
* @param DoliDB $db Database handler |
|
64
|
|
|
*/ |
|
65
|
|
|
function __construct($db) |
|
66
|
|
|
{ |
|
67
|
|
|
global $conf,$langs,$mysoc; |
|
68
|
|
|
|
|
69
|
|
|
$langs->load("main"); |
|
70
|
|
|
$langs->load("bills"); |
|
71
|
|
|
|
|
72
|
|
|
$this->db = $db; |
|
73
|
|
|
$this->name = "cow"; |
|
74
|
|
|
$this->description = $langs->trans('SuppliersPaymentModel'); |
|
75
|
|
|
|
|
76
|
|
|
// Dimension page pour format A4 |
|
77
|
|
|
$this->type = 'pdf'; |
|
78
|
|
|
$formatarray=pdf_getFormat(); |
|
79
|
|
|
$this->page_largeur = $formatarray['width']; |
|
80
|
|
|
$this->page_hauteur = $formatarray['height']; |
|
81
|
|
|
$this->format = array($this->page_largeur,$this->page_hauteur); |
|
82
|
|
|
$this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
|
83
|
|
|
$this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
|
84
|
|
|
$this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
|
85
|
|
|
$this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
|
86
|
|
|
|
|
87
|
|
|
$this->option_logo = 1; // Affiche logo |
|
88
|
|
|
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
|
89
|
|
|
$this->option_modereg = 1; // Affiche mode reglement |
|
90
|
|
|
$this->option_condreg = 1; // Affiche conditions reglement |
|
91
|
|
|
$this->option_codeproduitservice = 1; // Affiche code produit-service |
|
92
|
|
|
$this->option_multilang = 1; // Dispo en plusieurs langues |
|
93
|
|
|
|
|
94
|
|
|
$this->franchise=!$mysoc->tva_assuj; |
|
95
|
|
|
|
|
96
|
|
|
// Defini position des colonnes |
|
97
|
|
|
$this->posxdate=$this->marge_gauche+1; |
|
98
|
|
|
$this->posxreffacturefourn=30; |
|
99
|
|
|
$this->posxreffacture=65; |
|
100
|
|
|
$this->posxtype=100; |
|
101
|
|
|
$this->posxtotalht=80; |
|
102
|
|
|
$this->posxtva=90; |
|
103
|
|
|
$this->posxtotalttc=180; |
|
104
|
|
|
|
|
105
|
|
|
//if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) $this->posxtva=$this->posxup; |
|
106
|
|
|
if ($this->page_largeur < 210) // To work with US executive format |
|
107
|
|
|
{ |
|
108
|
|
|
$this->posxreffacturefourn-=20; |
|
109
|
|
|
$this->posxreffacture-=20; |
|
110
|
|
|
$this->posxtype-=20; |
|
111
|
|
|
$this->posxtotalht-=20; |
|
112
|
|
|
$this->posxtva-=20; |
|
113
|
|
|
$this->posxtotalttc-=20; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
$this->tva=array(); |
|
117
|
|
|
$this->localtax1=array(); |
|
118
|
|
|
$this->localtax2=array(); |
|
119
|
|
|
$this->atleastoneratenotnull=0; |
|
120
|
|
|
$this->atleastonediscount=0; |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
|
|
124
|
|
|
/** |
|
125
|
|
|
* Function to build pdf onto disk |
|
126
|
|
|
* |
|
127
|
|
|
* @param PaiementFourn $object Id of object to generate |
|
128
|
|
|
* @param Translate $outputlangs Lang output object |
|
129
|
|
|
* @param string $srctemplatepath Full path of source filename for generator using a template file |
|
130
|
|
|
* @param int $hidedetails Do not show line details |
|
131
|
|
|
* @param int $hidedesc Do not show desc |
|
132
|
|
|
* @param int $hideref Do not show ref |
|
133
|
|
|
* @return int 1=OK, 0=KO |
|
134
|
|
|
*/ |
|
135
|
|
|
function write_file($object, $outputlangs='', $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0) |
|
136
|
|
|
{ |
|
137
|
|
|
global $user,$langs,$conf,$mysoc,$hookmanager; |
|
138
|
|
|
|
|
139
|
|
|
// Get source company |
|
140
|
|
|
if (! is_object($object->thirdparty)) $object->fetch_thirdparty(); |
|
141
|
|
|
if (! is_object($object->thirdparty)) $object->thirdparty=$mysoc; // If fetch_thirdparty fails, object has no socid (specimen) |
|
142
|
|
|
$this->emetteur=$object->thirdparty; |
|
143
|
|
|
if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
144
|
|
|
|
|
145
|
|
|
if (! is_object($outputlangs)) $outputlangs=$langs; |
|
146
|
|
|
// For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
|
147
|
|
|
if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
148
|
|
|
|
|
149
|
|
|
$outputlangs->load("main"); |
|
150
|
|
|
$outputlangs->load("dict"); |
|
151
|
|
|
$outputlangs->load("companies"); |
|
152
|
|
|
$outputlangs->load("bills"); |
|
153
|
|
|
$outputlangs->load("products"); |
|
154
|
|
|
$outputlangs->load("suppliers"); |
|
155
|
|
|
$object->factures = array(); |
|
156
|
|
|
|
|
157
|
|
|
if ($conf->fournisseur->payment->dir_output) |
|
158
|
|
|
{ |
|
159
|
|
|
$object->fetch_thirdparty(); |
|
160
|
|
|
/** |
|
161
|
|
|
* Supplier invoice list |
|
162
|
|
|
*/ |
|
163
|
|
|
$sql = 'SELECT f.rowid, f.ref, f.datef, f.ref_supplier, f.total_ht, f.total_tva, f.total_ttc, pf.amount, f.rowid as facid, f.paye'; |
|
164
|
|
|
$sql .= ', f.fk_statut, s.nom as name, s.rowid as socid'; |
|
165
|
|
|
$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf,'.MAIN_DB_PREFIX.'facture_fourn as f,'.MAIN_DB_PREFIX.'societe as s'; |
|
166
|
|
|
$sql .= ' WHERE pf.fk_facturefourn = f.rowid AND f.fk_soc = s.rowid'; |
|
167
|
|
|
$sql .= ' AND pf.fk_paiementfourn = '.$object->id; |
|
168
|
|
|
$resql=$this->db->query($sql); |
|
169
|
|
|
if ($resql) |
|
170
|
|
|
{ |
|
171
|
|
|
if ($this->db->num_rows($resql) > 0) |
|
172
|
|
|
{ |
|
173
|
|
|
while($objp = $this->db->fetch_object($resql)) { |
|
174
|
|
|
$objp->type = $outputlangs->trans('SupplierInvoice'); |
|
175
|
|
|
$object->lines[] = $objp; |
|
176
|
|
|
} |
|
177
|
|
|
} |
|
178
|
|
|
} |
|
179
|
|
|
|
|
180
|
|
|
$total = $object->montant; |
|
181
|
|
|
|
|
182
|
|
|
// Definition of $dir and $file |
|
183
|
|
|
if ($object->specimen) |
|
184
|
|
|
{ |
|
185
|
|
|
$dir = $conf->fournisseur->payment->dir_output; |
|
186
|
|
|
$file = $dir . "/SPECIMEN.pdf"; |
|
187
|
|
|
} |
|
188
|
|
|
else |
|
189
|
|
|
{ |
|
190
|
|
|
$objectref = dol_sanitizeFileName($object->ref); |
|
191
|
|
|
$objectrefsupplier = dol_sanitizeFileName($object->ref_supplier); |
|
192
|
|
|
$dir = $conf->fournisseur->payment->dir_output.'/'.$objectref; |
|
193
|
|
|
$file = $dir . "/" . $objectref . ".pdf"; |
|
194
|
|
|
if (! empty($conf->global->SUPPLIER_REF_IN_NAME)) $file = $dir . "/" . $objectref . ($objectrefsupplier?"_".$objectrefsupplier:"").".pdf"; |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
if (! file_exists($dir)) |
|
198
|
|
|
{ |
|
199
|
|
|
if (dol_mkdir($dir) < 0) |
|
200
|
|
|
{ |
|
201
|
|
|
$this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
|
202
|
|
|
return 0; |
|
203
|
|
|
} |
|
204
|
|
|
} |
|
205
|
|
|
|
|
206
|
|
|
if (file_exists($dir)) |
|
207
|
|
|
{ |
|
208
|
|
|
// Add pdfgeneration hook |
|
209
|
|
|
if (! is_object($hookmanager)) |
|
210
|
|
|
{ |
|
211
|
|
|
include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
|
212
|
|
|
$hookmanager=new HookManager($this->db); |
|
213
|
|
|
} |
|
214
|
|
|
$hookmanager->initHooks(array('pdfgeneration')); |
|
215
|
|
|
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
216
|
|
|
global $action; |
|
217
|
|
|
$reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
|
218
|
|
|
|
|
219
|
|
|
$nblignes = count($object->lines); |
|
220
|
|
|
|
|
221
|
|
|
$pdf=pdf_getInstance($this->format); |
|
222
|
|
|
$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
223
|
|
|
$heightforinfotot = 50; // Height reserved to output the info and total part |
|
224
|
|
|
$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 |
|
225
|
|
|
$heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
226
|
|
|
$pdf->SetAutoPageBreak(1,0); |
|
227
|
|
|
|
|
228
|
|
|
if (class_exists('TCPDF')) |
|
229
|
|
|
{ |
|
230
|
|
|
$pdf->setPrintHeader(false); |
|
231
|
|
|
$pdf->setPrintFooter(false); |
|
232
|
|
|
} |
|
233
|
|
|
$pdf->SetFont(pdf_getPDFFont($outputlangs)); |
|
234
|
|
|
// Set path to the background PDF File |
|
235
|
|
|
if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
236
|
|
|
{ |
|
237
|
|
|
$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); |
|
238
|
|
|
$tplidx = $pdf->importPage(1); |
|
239
|
|
|
} |
|
240
|
|
|
|
|
241
|
|
|
$pdf->Open(); |
|
242
|
|
|
$pagenb=0; |
|
243
|
|
|
$pdf->SetDrawColor(128,128,128); |
|
244
|
|
|
|
|
245
|
|
|
$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
|
246
|
|
|
$pdf->SetSubject($outputlangs->transnoentities("Invoice")); |
|
247
|
|
|
$pdf->SetCreator("Dolibarr ".DOL_VERSION); |
|
248
|
|
|
$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
|
249
|
|
|
$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
|
250
|
|
|
if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
251
|
|
|
|
|
252
|
|
|
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
|
253
|
|
|
|
|
254
|
|
|
|
|
255
|
|
|
// New page |
|
256
|
|
|
$pdf->AddPage(); |
|
257
|
|
|
if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
258
|
|
|
$pagenb++; |
|
259
|
|
|
$this->_pagehead($pdf, $object, 1, $outputlangs); |
|
260
|
|
|
$pdf->SetFont('','', $default_font_size - 1); |
|
261
|
|
|
$pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
262
|
|
|
$pdf->SetTextColor(0,0,0); |
|
263
|
|
|
|
|
264
|
|
|
$tab_top = 90; |
|
265
|
|
|
$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); |
|
266
|
|
|
$tab_height = 130; |
|
267
|
|
|
$tab_height_newpage = 150; |
|
268
|
|
|
|
|
269
|
|
|
// Incoterm |
|
270
|
|
|
$height_incoterms = 0; |
|
271
|
|
|
|
|
272
|
|
|
$height_note=0; |
|
273
|
|
|
|
|
274
|
|
|
$iniY = $tab_top + 7; |
|
275
|
|
|
$curY = $tab_top + 7; |
|
276
|
|
|
$nexY = $tab_top + 7; |
|
277
|
|
|
|
|
278
|
|
|
// Loop on each lines |
|
279
|
|
|
for ($i = 0 ; $i < $nblignes ; $i++) |
|
280
|
|
|
{ |
|
281
|
|
|
$curY = $nexY; |
|
282
|
|
|
$pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
283
|
|
|
$pdf->SetTextColor(0,0,0); |
|
284
|
|
|
|
|
285
|
|
|
$pdf->setTopMargin($tab_top_newpage); |
|
286
|
|
|
$pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
287
|
|
|
$pageposbefore=$pdf->getPage(); |
|
288
|
|
|
|
|
289
|
|
|
// Description of product line |
|
290
|
|
|
$curX = $this->posxdate-1; |
|
291
|
|
|
$showpricebeforepagebreak=1; |
|
292
|
|
|
|
|
293
|
|
|
$pdf->startTransaction(); |
|
294
|
|
|
//pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc,1); |
|
295
|
|
|
$pdf->writeHTMLCell($this->posxtva-$curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J',true); |
|
296
|
|
|
$pageposafter=$pdf->getPage(); |
|
297
|
|
|
if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
298
|
|
|
{ |
|
299
|
|
|
$pdf->rollbackTransaction(true); |
|
300
|
|
|
$pageposafter=$pageposbefore; |
|
301
|
|
|
//print $pageposafter.'-'.$pageposbefore;exit; |
|
302
|
|
|
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
303
|
|
|
//pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc,1); |
|
304
|
|
|
$pdf->writeHTMLCell($this->posxtva-$curX, 4, $curX, $curY, $object->lines[$i]->datef, 0, 1, false, true, 'J',true); |
|
305
|
|
|
$posyafter=$pdf->GetY(); |
|
306
|
|
|
if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
307
|
|
|
{ |
|
308
|
|
|
if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
309
|
|
|
{ |
|
310
|
|
|
$pdf->AddPage('','',true); |
|
311
|
|
|
if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
312
|
|
|
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
313
|
|
|
$pdf->setPage($pageposafter+1); |
|
314
|
|
|
} |
|
315
|
|
|
} |
|
316
|
|
|
else |
|
317
|
|
|
{ |
|
318
|
|
|
// We found a page break |
|
319
|
|
|
$showpricebeforepagebreak=0; |
|
320
|
|
|
} |
|
321
|
|
|
} |
|
322
|
|
|
else // No pagebreak |
|
323
|
|
|
{ |
|
324
|
|
|
$pdf->commitTransaction(); |
|
325
|
|
|
} |
|
326
|
|
|
|
|
327
|
|
|
$nexY = $pdf->GetY(); |
|
328
|
|
|
$pageposafter=$pdf->getPage(); |
|
329
|
|
|
$pdf->setPage($pageposbefore); |
|
330
|
|
|
$pdf->setTopMargin($this->marge_haute); |
|
331
|
|
|
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
332
|
|
|
|
|
333
|
|
|
// We suppose that a too long description is moved completely on next page |
|
334
|
|
|
if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
|
335
|
|
|
$pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
|
336
|
|
|
} |
|
337
|
|
|
|
|
338
|
|
|
$pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
|
339
|
|
|
|
|
340
|
|
|
// ref fourn |
|
341
|
|
|
$pdf->SetXY($this->posxreffacturefourn, $curY); |
|
342
|
|
|
$pdf->MultiCell($this->posxreffacturefourn-$this->posxup-0.8, 3, $object->lines[$i]->ref_supplier, 0, 'L', 0); |
|
343
|
|
|
|
|
344
|
|
|
// ref facture fourn |
|
345
|
|
|
$pdf->SetXY($this->posxreffacture, $curY); |
|
346
|
|
|
$pdf->MultiCell($this->posxreffacture-$this->posxup-0.8, 3, $object->lines[$i]->ref, 0, 'L', 0); |
|
347
|
|
|
|
|
348
|
|
|
// type |
|
349
|
|
|
$pdf->SetXY($this->posxtype, $curY); |
|
350
|
|
|
$pdf->MultiCell($this->posxtype-$this->posxup-0.8, 3, $object->lines[$i]->type, 0, 'L', 0); |
|
351
|
|
|
|
|
352
|
|
|
// Total ht |
|
353
|
|
|
$pdf->SetXY($this->posxtotalht, $curY); |
|
354
|
|
|
$pdf->MultiCell($this->posxtotalht-$this->posxup-0.8, 3, price($object->lines[$i]->total_ht), 0, 'R', 0); |
|
355
|
|
|
|
|
356
|
|
|
// Total tva |
|
357
|
|
|
$pdf->SetXY($this->posxtva, $curY); |
|
358
|
|
|
$pdf->MultiCell($this->posxtva-$this->posxup-0.8, 3, price($object->lines[$i]->total_tva), 0, 'R', 0); |
|
359
|
|
|
|
|
360
|
|
|
// Total TTC line |
|
361
|
|
|
$pdf->SetXY($this->posxtotalttc, $curY); |
|
362
|
|
|
$pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->posxtotalttc, 3, price($object->lines[$i]->total_ttc), 0, 'R', 0); |
|
363
|
|
|
|
|
364
|
|
|
|
|
365
|
|
|
// Add line |
|
366
|
|
|
if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
|
367
|
|
|
{ |
|
368
|
|
|
$pdf->setPage($pageposafter); |
|
369
|
|
|
$pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(80,80,80))); |
|
370
|
|
|
//$pdf->SetDrawColor(190,190,200); |
|
371
|
|
|
$pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); |
|
372
|
|
|
$pdf->SetLineStyle(array('dash'=>0)); |
|
373
|
|
|
} |
|
374
|
|
|
|
|
375
|
|
|
$nexY+=2; // Passe espace entre les lignes |
|
376
|
|
|
|
|
377
|
|
|
// Detect if some page were added automatically and output _tableau for past pages |
|
378
|
|
|
while ($pagenb < $pageposafter) |
|
379
|
|
|
{ |
|
380
|
|
|
$pdf->setPage($pagenb); |
|
381
|
|
|
if ($pagenb == 1) |
|
382
|
|
|
{ |
|
383
|
|
|
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
384
|
|
|
} |
|
385
|
|
|
else |
|
386
|
|
|
{ |
|
387
|
|
|
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
388
|
|
|
} |
|
389
|
|
|
$this->_pagefoot($pdf,$object,$outputlangs,1); |
|
390
|
|
|
$pagenb++; |
|
391
|
|
|
$pdf->setPage($pagenb); |
|
392
|
|
|
$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
393
|
|
|
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
394
|
|
|
} |
|
395
|
|
|
if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
|
396
|
|
|
{ |
|
397
|
|
|
if ($pagenb == 1) |
|
398
|
|
|
{ |
|
399
|
|
|
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
|
400
|
|
|
} |
|
401
|
|
|
else |
|
402
|
|
|
{ |
|
403
|
|
|
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
|
404
|
|
|
} |
|
405
|
|
|
$this->_pagefoot($pdf,$object,$outputlangs,1); |
|
406
|
|
|
// New page |
|
407
|
|
|
$pdf->AddPage(); |
|
408
|
|
|
if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
409
|
|
|
$pagenb++; |
|
410
|
|
|
if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
411
|
|
|
} |
|
412
|
|
|
} |
|
413
|
|
|
|
|
414
|
|
|
// Show square |
|
415
|
|
|
if ($pagenb == 1) |
|
416
|
|
|
{ |
|
417
|
|
|
$this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
418
|
|
|
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
419
|
|
|
} |
|
420
|
|
|
else |
|
421
|
|
|
{ |
|
422
|
|
|
$this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
423
|
|
|
$bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
|
424
|
|
|
} |
|
425
|
|
|
|
|
426
|
|
|
// Affiche zone cheèque |
|
427
|
|
|
$posy=$this->_tableau_cheque($pdf, $object, $bottomlasttab, $outputlangs); |
|
428
|
|
|
|
|
429
|
|
|
// Affiche zone totaux |
|
430
|
|
|
//$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); |
|
431
|
|
|
|
|
432
|
|
|
// Pied de page |
|
433
|
|
|
$this->_pagefoot($pdf, $object, $outputlangs); |
|
434
|
|
|
if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
|
435
|
|
|
|
|
436
|
|
|
$pdf->Close(); |
|
437
|
|
|
|
|
438
|
|
|
$pdf->Output($file,'F'); |
|
439
|
|
|
|
|
440
|
|
|
// Add pdfgeneration hook |
|
441
|
|
|
$hookmanager->initHooks(array('pdfgeneration')); |
|
442
|
|
|
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
|
443
|
|
|
global $action; |
|
444
|
|
|
$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
|
445
|
|
|
|
|
446
|
|
|
if (! empty($conf->global->MAIN_UMASK)) |
|
447
|
|
|
@chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
448
|
|
|
|
|
449
|
|
|
return 1; // Pas d'erreur |
|
450
|
|
|
} |
|
451
|
|
|
else |
|
452
|
|
|
{ |
|
453
|
|
|
$this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
|
454
|
|
|
return 0; |
|
455
|
|
|
} |
|
456
|
|
|
} |
|
457
|
|
|
else |
|
458
|
|
|
{ |
|
459
|
|
|
$this->error=$langs->trans("ErrorConstantNotDefined","SUPPLIER_OUTPUTDIR"); |
|
460
|
|
|
return 0; |
|
461
|
|
|
} |
|
462
|
|
|
} |
|
463
|
|
|
|
|
464
|
|
|
/** |
|
465
|
|
|
* Show total to pay |
|
466
|
|
|
* |
|
467
|
|
|
* @param PDF $pdf Object PDF |
|
468
|
|
|
* @param PaiementFourn $object Object PaiementFourn |
|
469
|
|
|
* @param int $posy Position depart |
|
470
|
|
|
* @param Translate $outputlangs Objet langs |
|
471
|
|
|
* @return int Position pour suite |
|
472
|
|
|
*/ |
|
473
|
|
|
function _tableau_cheque(&$pdf, $object, $posy, $outputlangs) |
|
474
|
|
|
{ |
|
475
|
|
|
global $conf,$mysoc; |
|
476
|
|
|
|
|
477
|
|
|
$default_font_size = pdf_getPDFFontSize($outputlangs); |
|
478
|
|
|
|
|
479
|
|
|
$pdf->SetFont('','', $default_font_size - 1); |
|
480
|
|
|
$pdf->SetFillColor(255,255,255); |
|
481
|
|
|
|
|
482
|
|
|
// N° payment |
|
483
|
|
|
$pdf->SetXY($this->marge_gauche, $posy); |
|
484
|
|
|
$pdf->MultiCell(30, 4, 'N° '.$outputlangs->transnoentities("Payment"), 0, 'L', 1); |
|
485
|
|
|
|
|
486
|
|
|
// Ref payment |
|
487
|
|
|
$pdf->SetXY($this->marge_gauche + 30, $posy); |
|
488
|
|
|
$pdf->MultiCell(50, 4, $object->ref, 0, 'L', 1); |
|
489
|
|
|
|
|
490
|
|
|
// Total payments |
|
491
|
|
|
$pdf->SetXY($this->page_largeur - $this->marge_droite - 50, $posy); |
|
492
|
|
|
$pdf->MultiCell(50, 4, price($object->montant), 0, 'R', 1); |
|
493
|
|
|
$posy += 20; |
|
494
|
|
|
|
|
495
|
|
|
// translate amount |
|
496
|
|
|
$currency = $conf->currency; |
|
497
|
|
|
$translateinletter = strtoupper(dol_convertToWord($object->montant,$outputlangs,$currency)); |
|
498
|
|
|
$pdf->SetXY($this->marge_gauche + 50, $posy); |
|
499
|
|
|
$pdf->MultiCell(90, 8, $translateinletter, 0, 'L', 1); |
|
500
|
|
|
$posy += 8; |
|
501
|
|
|
|
|
502
|
|
|
// To |
|
503
|
|
|
$pdf->SetXY($this->marge_gauche + 50, $posy); |
|
504
|
|
|
$pdf->MultiCell(150, 4, $object->thirdparty->nom, 0, 'L', 1); |
|
505
|
|
|
|
|
506
|
|
|
$pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy); |
|
507
|
|
|
$pdf->MultiCell(35, 4, str_pad(price($object->montant). ' '.$currency,18,'*',STR_PAD_LEFT), 0, 'R', 1); |
|
508
|
|
|
$posy += 10; |
|
509
|
|
|
|
|
510
|
|
|
|
|
511
|
|
|
// City |
|
512
|
|
|
$pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy); |
|
513
|
|
|
$pdf->MultiCell(150, 4, $mysoc->town, 0, 'L', 1); |
|
514
|
|
|
$posy += 4; |
|
515
|
|
|
|
|
516
|
|
|
// Date |
|
517
|
|
|
$pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy); |
|
518
|
|
|
$pdf->MultiCell(150, 4, date("d").' '.$outputlangs->transnoentitiesnoconv(date("F")).' '.date("Y"), 0, 'L', 1); |
|
519
|
|
|
|
|
520
|
|
|
} |
|
521
|
|
|
|
|
522
|
|
|
|
|
523
|
|
|
/** |
|
524
|
|
|
* Show table for lines |
|
525
|
|
|
* |
|
526
|
|
|
* @param PDF $pdf Object PDF |
|
527
|
|
|
* @param string $tab_top Top position of table |
|
528
|
|
|
* @param string $tab_height Height of table (rectangle) |
|
529
|
|
|
* @param int $nexY Y (not used) |
|
530
|
|
|
* @param Translate $outputlangs Langs object |
|
531
|
|
|
* @param int $hidetop Hide top bar of array |
|
532
|
|
|
* @param int $hidebottom Hide bottom bar of array |
|
533
|
|
|
* @return void |
|
534
|
|
|
*/ |
|
535
|
|
|
function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0) |
|
536
|
|
|
{ |
|
537
|
|
|
global $conf,$mysoc; |
|
538
|
|
|
|
|
539
|
|
|
// Force to disable hidetop and hidebottom |
|
540
|
|
|
$hidebottom=0; |
|
541
|
|
|
if ($hidetop) $hidetop=-1; |
|
542
|
|
|
|
|
543
|
|
|
$default_font_size = pdf_getPDFFontSize($outputlangs); |
|
544
|
|
|
|
|
545
|
|
|
// Amount in (at tab_top - 1) |
|
546
|
|
|
$pdf->SetTextColor(0,0,0); |
|
547
|
|
|
$pdf->SetFont('','',$default_font_size - 2); |
|
548
|
|
|
|
|
549
|
|
|
$titre = strtoupper($mysoc->town).', le '.date("d").' '.$outputlangs->transnoentitiesnoconv(date("F")).' '.date("Y"); |
|
550
|
|
|
$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3) - 60, $tab_top-6); |
|
551
|
|
|
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
|
552
|
|
|
|
|
553
|
|
|
$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->currency)); |
|
554
|
|
|
$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top); |
|
555
|
|
|
$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
|
556
|
|
|
|
|
557
|
|
|
|
|
558
|
|
|
$pdf->SetDrawColor(128,128,128); |
|
559
|
|
|
$pdf->SetFont('','', $default_font_size - 1); |
|
560
|
|
|
|
|
561
|
|
|
// Output Rect |
|
562
|
|
|
//$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 |
|
563
|
|
|
|
|
564
|
|
|
} |
|
565
|
|
|
|
|
566
|
|
|
|
|
567
|
|
|
/** |
|
568
|
|
|
* Show top header of page. |
|
569
|
|
|
* |
|
570
|
|
|
* @param PDF $pdf Object PDF |
|
571
|
|
|
* @param FactureFournisseur $object Object to show |
|
572
|
|
|
* @param int $showaddress 0=no, 1=yes |
|
573
|
|
|
* @param Translate $outputlangs Object lang for output |
|
574
|
|
|
* @return void |
|
575
|
|
|
*/ |
|
576
|
|
|
function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
|
577
|
|
|
{ |
|
578
|
|
|
global $langs,$conf,$mysoc; |
|
579
|
|
|
|
|
580
|
|
|
$outputlangs->load("main"); |
|
581
|
|
|
$outputlangs->load("bills"); |
|
582
|
|
|
$outputlangs->load("orders"); |
|
583
|
|
|
$outputlangs->load("companies"); |
|
584
|
|
|
$default_font_size = pdf_getPDFFontSize($outputlangs); |
|
585
|
|
|
|
|
586
|
|
|
// Do not add the BACKGROUND as this is for suppliers |
|
587
|
|
|
//pdf_pagehead($pdf,$outputlangs,$this->page_hauteur); |
|
588
|
|
|
|
|
589
|
|
|
$pdf->SetTextColor(0,0,60); |
|
590
|
|
|
$pdf->SetFont('','B', $default_font_size + 3); |
|
591
|
|
|
|
|
592
|
|
|
$posy=$this->marge_haute; |
|
593
|
|
|
$posx=$this->page_largeur-$this->marge_droite-100; |
|
594
|
|
|
|
|
595
|
|
|
$pdf->SetXY($this->marge_gauche,$posy); |
|
596
|
|
|
|
|
597
|
|
|
// Logo |
|
598
|
|
|
$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
599
|
|
|
if ($mysoc->logo) |
|
600
|
|
|
{ |
|
601
|
|
|
if (is_readable($logo)) |
|
602
|
|
|
{ |
|
603
|
|
|
$height=pdf_getHeightForLogo($logo); |
|
604
|
|
|
$pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
605
|
|
|
} |
|
606
|
|
|
else |
|
607
|
|
|
{ |
|
608
|
|
|
$pdf->SetTextColor(200,0,0); |
|
609
|
|
|
$pdf->SetFont('','B', $default_font_size - 2); |
|
610
|
|
|
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
611
|
|
|
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
|
612
|
|
|
} |
|
613
|
|
|
} |
|
614
|
|
|
else |
|
615
|
|
|
{ |
|
616
|
|
|
$text=$this->emetteur->name; |
|
617
|
|
|
$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
|
618
|
|
|
} |
|
619
|
|
|
/* |
|
620
|
|
|
$pdf->SetFont('','B', $default_font_size + 3); |
|
621
|
|
|
$pdf->SetXY($posx,$posy); |
|
622
|
|
|
$pdf->SetTextColor(0,0,60); |
|
623
|
|
|
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierInvoice")." ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); |
|
624
|
|
|
$posy+=1; |
|
625
|
|
|
|
|
626
|
|
|
if ($object->ref_supplier) |
|
627
|
|
|
{ |
|
628
|
|
|
$posy+=4; |
|
629
|
|
|
$pdf->SetFont('','B', $default_font_size); |
|
630
|
|
|
$pdf->SetXY($posx,$posy); |
|
631
|
|
|
$pdf->SetTextColor(0,0,60); |
|
632
|
|
|
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("RefSupplier")." : " . $object->ref_supplier, '', 'R'); |
|
633
|
|
|
$posy+=1; |
|
634
|
|
|
} |
|
635
|
|
|
|
|
636
|
|
|
$pdf->SetFont('','', $default_font_size - 1); |
|
637
|
|
|
|
|
638
|
|
|
if (! empty($conf->global->PDF_SHOW_PROJECT)) |
|
639
|
|
|
{ |
|
640
|
|
|
$object->fetch_projet(); |
|
641
|
|
|
if (! empty($object->project->ref)) |
|
642
|
|
|
{ |
|
643
|
|
|
$posy+=4; |
|
644
|
|
|
$pdf->SetXY($posx,$posy); |
|
645
|
|
|
$langs->load("projects"); |
|
646
|
|
|
$pdf->SetTextColor(0,0,60); |
|
647
|
|
|
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("Project")." : " . (empty($object->project->ref)?'':$object->projet->ref), '', 'R'); |
|
648
|
|
|
} |
|
649
|
|
|
} |
|
650
|
|
|
|
|
651
|
|
|
if ($object->date) |
|
652
|
|
|
{ |
|
653
|
|
|
$posy+=4; |
|
654
|
|
|
$pdf->SetXY($posx,$posy); |
|
655
|
|
|
$pdf->SetTextColor(0,0,60); |
|
656
|
|
|
$pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dol_print_date($object->date,"day",false,$outputlangs,true), '', 'R'); |
|
657
|
|
|
} |
|
658
|
|
|
else |
|
659
|
|
|
{ |
|
660
|
|
|
$posy+=4; |
|
661
|
|
|
$pdf->SetXY($posx,$posy); |
|
662
|
|
|
$pdf->SetTextColor(255,0,0); |
|
663
|
|
|
$pdf->MultiCell(100, 4, strtolower($outputlangs->transnoentities("OrderToProcess")), '', 'R'); |
|
664
|
|
|
} |
|
665
|
|
|
|
|
666
|
|
|
if ($object->thirdparty->code_fournisseur) |
|
667
|
|
|
{ |
|
668
|
|
|
$posy+=4; |
|
669
|
|
|
$pdf->SetXY($posx,$posy); |
|
670
|
|
|
$pdf->SetTextColor(0,0,60); |
|
671
|
|
|
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("SupplierCode")." : " . $outputlangs->transnoentities($object->thirdparty->code_fournisseur), '', 'R'); |
|
672
|
|
|
} |
|
673
|
|
|
|
|
674
|
|
|
$posy+=1; |
|
675
|
|
|
$pdf->SetTextColor(0,0,60); |
|
676
|
|
|
|
|
677
|
|
|
// Show list of linked objects |
|
678
|
|
|
$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); |
|
679
|
|
|
*/ |
|
680
|
|
|
if ($showaddress) |
|
681
|
|
|
{ |
|
682
|
|
|
// Sender properties |
|
683
|
|
|
$carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); |
|
684
|
|
|
|
|
685
|
|
|
// Show sender |
|
686
|
|
|
$posy=42; |
|
687
|
|
|
$posx=$this->marge_gauche; |
|
688
|
|
|
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
689
|
|
|
$hautcadre=40; |
|
690
|
|
|
/* |
|
691
|
|
|
// Show sender frame |
|
692
|
|
|
$pdf->SetTextColor(0,0,0); |
|
693
|
|
|
$pdf->SetFont('','', $default_font_size - 2); |
|
694
|
|
|
$pdf->SetXY($posx,$posy-5); |
|
695
|
|
|
$pdf->MultiCell(66,5, $outputlangs->transnoentities("BillFrom").":", 0, 'L'); |
|
696
|
|
|
$pdf->SetXY($posx,$posy); |
|
697
|
|
|
$pdf->SetFillColor(230,230,230); |
|
698
|
|
|
$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
|
699
|
|
|
$pdf->SetTextColor(0,0,60); |
|
700
|
|
|
|
|
701
|
|
|
// Show sender name |
|
702
|
|
|
$pdf->SetXY($posx+2,$posy+3); |
|
703
|
|
|
$pdf->SetFont('','B', $default_font_size); |
|
704
|
|
|
$pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L'); |
|
705
|
|
|
$posy=$pdf->getY(); |
|
706
|
|
|
|
|
707
|
|
|
// Show sender information |
|
708
|
|
|
$pdf->SetXY($posx+2,$posy); |
|
709
|
|
|
$pdf->SetFont('','', $default_font_size - 1); |
|
710
|
|
|
$pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); |
|
711
|
|
|
|
|
712
|
|
|
*/ |
|
713
|
|
|
|
|
714
|
|
|
// If BILLING contact defined on invoice, we use it |
|
715
|
|
|
$usecontact=false; |
|
716
|
|
|
$arrayidcontact=$object->getIdContact('internal','BILLING'); |
|
717
|
|
|
if (count($arrayidcontact) > 0) |
|
718
|
|
|
{ |
|
719
|
|
|
$usecontact=true; |
|
720
|
|
|
$result=$object->fetch_contact($arrayidcontact[0]); |
|
721
|
|
|
} |
|
722
|
|
|
|
|
723
|
|
|
//Recipient name |
|
724
|
|
|
// On peut utiliser le nom de la societe du contact |
|
725
|
|
|
if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
726
|
|
|
$thirdparty = $object->contact; |
|
727
|
|
|
} else { |
|
728
|
|
|
$thirdparty = $mysoc; |
|
729
|
|
|
} |
|
730
|
|
|
|
|
731
|
|
|
$carac_client_name= pdfBuildThirdpartyName($thirdparty, $outputlangs); |
|
732
|
|
|
|
|
733
|
|
|
$carac_client=pdf_build_address($outputlangs,$this->emetteur,$mysoc,((!empty($object->contact))?$object->contact:null),$usecontact,'target',$object); |
|
|
|
|
|
|
734
|
|
|
|
|
735
|
|
|
// Show recipient |
|
736
|
|
|
$widthrecbox=90; |
|
737
|
|
|
if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
738
|
|
|
$posy=42; |
|
739
|
|
|
$posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
|
740
|
|
|
if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
741
|
|
|
|
|
742
|
|
|
// Show recipient frame |
|
743
|
|
|
$pdf->SetTextColor(0,0,0); |
|
744
|
|
|
$pdf->SetFont('','', $default_font_size - 2); |
|
745
|
|
|
$pdf->SetXY($posx+2,$posy-5); |
|
746
|
|
|
$pdf->MultiCell($widthrecbox, 5, "",0,'L'); |
|
747
|
|
|
$pdf->Rect($posx, $posy, $widthrecbox, $hautcadre); |
|
748
|
|
|
|
|
749
|
|
|
// Show recipient name |
|
750
|
|
|
$pdf->SetXY($posx+2,$posy+3); |
|
751
|
|
|
$pdf->SetFont('','B', $default_font_size); |
|
752
|
|
|
$pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, 'L'); |
|
753
|
|
|
|
|
754
|
|
|
$posy = $pdf->getY(); |
|
755
|
|
|
|
|
756
|
|
|
// Show recipient information |
|
757
|
|
|
$pdf->SetFont('','', $default_font_size - 1); |
|
758
|
|
|
$pdf->SetXY($posx+2,$posy); |
|
759
|
|
|
$pdf->MultiCell($widthrecbox, 4, $carac_client, 0, 'L'); |
|
760
|
|
|
} |
|
761
|
|
|
} |
|
762
|
|
|
|
|
763
|
|
|
/** |
|
764
|
|
|
* Show footer of page. Need this->emetteur object |
|
765
|
|
|
* |
|
766
|
|
|
* @param PDF $pdf PDF |
|
767
|
|
|
* @param FactureFournisseur $object Object to show |
|
768
|
|
|
* @param Translate $outputlangs Object lang for output |
|
769
|
|
|
* @param int $hidefreetext 1=Hide free text |
|
770
|
|
|
* @return int Return height of bottom margin including footer text |
|
771
|
|
|
*/ |
|
772
|
|
|
function _pagefoot(&$pdf, $object, $outputlangs,$hidefreetext=0) |
|
773
|
|
|
{ |
|
774
|
|
|
global $conf; |
|
775
|
|
|
$showdetails=$conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; |
|
776
|
|
|
return pdf_pagefoot($pdf,$outputlangs,'SUPPLIER_INVOICE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur,$object,$showdetails,$hidefreetext); |
|
777
|
|
|
} |
|
778
|
|
|
|
|
779
|
|
|
} |
|
780
|
|
|
|
|
781
|
|
|
|
Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code: