dolibarr 20.0.2
pdf_paiement.class.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2003-2006 Rodolphe Quiedeville <rodolphe@quiedeville.org>
3 * Copyright (C) 2006-2014 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2015-2018 Charlene BENKE <charlie@patas-monkey.com>
5 * Copyright (C) 2020 Maxime DEMAREST <maxime@indelog.fr>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * or see https://www.gnu.org/
20 */
21
28require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
29require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
30require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
31
32
37{
38 public $tab_top;
39
40 public $line_height;
41
42 public $line_per_page;
43
44 public $tab_height;
45
46 public $posxdate;
47
48 public $posxpaymenttype;
49 public $posxinvoice;
50 public $posxbankaccount;
51 public $posxinvoiceamount;
52 public $posxpaymentamount;
53
54 public $doc_type;
55
59 public $year;
60
64 public $month;
65
71 public function __construct($db)
72 {
73 global $langs, $conf;
74
75 // Load translation files required by the page
76 $langs->loadLangs(array("bills", "compta", "main"));
77
78 $this->db = $db;
79 $this->description = $langs->transnoentities("ListOfCustomerPayments");
80
81 // Page size for A4 format
82 $this->type = 'pdf';
83 $formatarray = pdf_getFormat();
84 $this->page_largeur = $formatarray['width'];
85 $this->page_hauteur = $formatarray['height'];
86 $this->format = array($this->page_largeur, $this->page_hauteur);
87 $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
88 $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
89 $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
90 $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
91
92 $this->tab_top = 30;
93
94 $this->line_height = 5;
95 $this->line_per_page = 40;
96 $this->tab_height = $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5; // must be > $this->line_height * $this->line_per_page and < $this->page_hauteur - $this->marge_haute - $this->marge_basse - $this->tab_top - 5;
97
98 $this->posxdate = $this->marge_gauche + 2;
99 $this->posxpaymenttype = 32;
100 $this->posxinvoice = 72;
101 $this->posxbankaccount = 115;
102 $this->posxinvoiceamount = 135;
103 $this->posxpaymentamount = 167;
104 if ($this->page_largeur < 210) { // To work with US executive format
105 $this->line_per_page = 35;
106 $this->posxpaymenttype -= 10;
107 $this->posxinvoice -= 0;
108 $this->posxinvoiceamount -= 10;
109 $this->posxpaymentamount -= 20;
110 }
111
112 // which type of document will be generated: clients (client) or providers (fourn) invoices
113 $this->doc_type = "client";
114 }
115
116
117 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
127 public function write_file($_dir, $month, $year, $outputlangs)
128 {
129 // phpcs:enable
130 include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
131
132 global $conf, $hookmanager, $langs, $user;
133
134 $socid = 0;
135 if ($user->socid) {
136 $socid = $user->socid;
137 }
138
139 if (!is_object($outputlangs)) {
140 $outputlangs = $langs;
141 }
142 // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
143 if (getDolGlobalString('MAIN_USE_FPDF')) {
144 $outputlangs->charset_output = 'ISO-8859-1';
145 }
146
147 $this->month = $month;
148 $this->year = $year;
149 $dir = $_dir.'/'.$year;
150
151 if (!is_dir($dir)) {
152 $result = dol_mkdir($dir);
153 if ($result < 0) {
154 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
155 return -1;
156 }
157 }
158
159 $month = sprintf("%02d", $month);
160 $year = sprintf("%04d", $year);
161
162 $file = $dir."/payments-".$year."-".$month.".pdf";
163 switch ($this->doc_type) {
164 case "client":
165 $file = $dir."/payments-".$year."-".$month.".pdf";
166 break;
167 case "fourn":
168 $file = $dir."/supplier_payments-".$year."-".$month.".pdf";
169 break;
170 }
171
172
173 // Add pdfgeneration hook
174 if (!is_object($hookmanager)) {
175 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
176 $hookmanager = new HookManager($this->db);
177 }
178 $hookmanager->initHooks(array('pdfgeneration'));
179 $parameters = array('file' => $file, 'object' => $this, 'outputlangs' => $outputlangs);
180 global $action;
181 $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $this, $action); // Note that $action and $this may have been modified by some hooks
182
183 $pdf = pdf_getInstance($this->format);
184 $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
185
186 if (class_exists('TCPDF')) {
187 $pdf->setPrintHeader(false);
188 $pdf->setPrintFooter(false);
189 }
190 $pdf->SetFont(pdf_getPDFFont($outputlangs));
191
192 $num = 0;
193 $lines = array();
194
195 // count number of lines of payment
196 $sql = "SELECT p.rowid as prowid";
197 switch ($this->doc_type) {
198 case "client":
199 $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p";
200 break;
201 case "fourn":
202 $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
203 break;
204 }
205 $sql .= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."'";
206 $sql .= " AND p.entity = ".$conf->entity;
207 $result = $this->db->query($sql);
208 if ($result) {
209 $numpaiement = $this->db->num_rows($result);
210 }
211
212 // number of bill
213 switch ($this->doc_type) {
214 case "client":
215 $sql = "SELECT p.datep as dp, f.ref";
216 $sql .= ", c.code as paiement_code, p.num_paiement as num_payment";
217 $sql .= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
218 $sql .= ", pf.amount as pf_amount";
219 if (isModEnabled("bank")) {
220 $sql .= ", ba.ref as bankaccount";
221 }
222 $sql .= ", p.rowid as prowid";
223 $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
224 $sql .= ", ".MAIN_DB_PREFIX."facture as f,";
225 $sql .= " ".MAIN_DB_PREFIX."paiement_facture as pf,";
226 if (isModEnabled("bank")) {
227 $sql .= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
228 }
229 $sql .= " ".MAIN_DB_PREFIX."societe as s";
230 if (!$user->hasRight('societe', 'client', 'voir')) {
231 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
232 }
233 $sql .= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid";
234 if (isModEnabled("bank")) {
235 $sql .= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
236 }
237 $sql .= " AND f.entity IN (".getEntity('invoice').")";
238 $sql .= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."'";
239 if (!$user->hasRight('societe', 'client', 'voir')) {
240 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
241 }
242 if (!empty($socid)) {
243 $sql .= " AND s.rowid = ".((int) $socid);
244 }
245 // If global param PAYMENTS_REPORT_GROUP_BY_MOD is set, payment are ordered by paiement_code
246 if (getDolGlobalString('PAYMENTS_REPORT_GROUP_BY_MOD')) {
247 $sql .= " ORDER BY paiement_code ASC, p.datep ASC, pf.fk_paiement ASC";
248 } else {
249 $sql .= " ORDER BY p.datep ASC, pf.fk_paiement ASC";
250 }
251 break;
252 case "fourn":
253 $sql = "SELECT p.datep as dp, f.ref as ref";
254 $sql .= ", c.code as paiement_code, p.num_paiement as num_payment";
255 $sql .= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
256 $sql .= ", pf.amount as pf_amount";
257 if (isModEnabled("bank")) {
258 $sql .= ", ba.ref as bankaccount";
259 }
260 $sql .= ", p.rowid as prowid";
261 $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
262 $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f,";
263 $sql .= " ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
264 if (isModEnabled("bank")) {
265 $sql .= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
266 }
267 $sql .= " ".MAIN_DB_PREFIX."societe as s";
268 if (!$user->hasRight('societe', 'client', 'voir')) {
269 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
270 }
271 $sql .= " WHERE f.fk_soc = s.rowid AND pf.fk_facturefourn = f.rowid AND pf.fk_paiementfourn = p.rowid";
272 if (isModEnabled("bank")) {
273 $sql .= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
274 }
275 $sql .= " AND f.entity IN (".getEntity('invoice').")";
276 $sql .= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."'";
277 if (!$user->hasRight('societe', 'client', 'voir')) {
278 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
279 }
280 if (!empty($socid)) {
281 $sql .= " AND s.rowid = ".((int) $socid);
282 }
283 // If global param PAYMENTS_FOURN_REPORT_GROUP_BY_MOD is set, payment fourn are ordered by paiement_code
284 if (getDolGlobalString('PAYMENTS_FOURN_REPORT_GROUP_BY_MOD')) {
285 $sql .= " ORDER BY paiement_code ASC, p.datep ASC, pf.fk_paiementfourn ASC";
286 } else {
287 $sql .= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC";
288 }
289 break;
290 }
291
292 dol_syslog(get_class($this)."::write_file", LOG_DEBUG);
293 $result = $this->db->query($sql);
294 if ($result) {
295 $num = $this->db->num_rows($result);
296 $i = 0;
297
298 while ($i < $num) {
299 $objp = $this->db->fetch_object($result);
300
301 $lines[$i][0] = $objp->ref;
302 $lines[$i][1] = dol_print_date($this->db->jdate($objp->dp), "day", false, $outputlangs, true);
303 $lines[$i][2] = $langs->transnoentities("PaymentTypeShort".$objp->paiement_code);
304 $lines[$i][3] = $objp->num_payment;
305 $lines[$i][4] = price($objp->paiement_amount);
306 $lines[$i][5] = price($objp->facture_amount);
307 $lines[$i][6] = price($objp->pf_amount);
308 $lines[$i][7] = $objp->prowid;
309 $lines[$i][8] = $objp->bankaccount;
310 $lines[$i][9] = $objp->paiement_amount;
311 $i++;
312 }
313 } else {
314 dol_print_error($this->db);
315 }
316
317 $pages = intval(($num + $numpaiement) / $this->line_per_page);
318
319 if ((($num + $numpaiement) % $this->line_per_page) > 0) {
320 $pages++;
321 }
322
323 if ($pages == 0) {
324 // force to build at least one page if report has no line
325 $pages = 1;
326 }
327
328 $pdf->Open();
329 $pagenb = 0;
330 $pdf->SetDrawColor(128, 128, 128);
331
332 $pdf->SetTitle($outputlangs->transnoentities("Payments"));
333 $pdf->SetSubject($outputlangs->transnoentities("Payments"));
334 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
335 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
336 //$pdf->SetKeyWords();
337 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
338 $pdf->SetCompression(false);
339 }
340
341 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
342 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
343 $pdf->SetAutoPageBreak(1, 0);
344
345 // New page
346 $pdf->AddPage();
347 $pagenb++;
348 $this->_pagehead($pdf, $pagenb, 1, $outputlangs);
349 $pdf->SetFont('', '', 9);
350 $pdf->MultiCell(0, 3, ''); // Set interline to 3
351 $pdf->SetTextColor(0, 0, 0);
352
353
354 $this->Body($pdf, 1, $lines, $outputlangs);
355
356 if (method_exists($pdf, 'AliasNbPages')) {
357 $pdf->AliasNbPages();
358 }
359
360 $pdf->Close();
361
362 $pdf->Output($file, 'F');
363
364 // Add pdfgeneration hook
365 if (!is_object($hookmanager)) {
366 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
367 $hookmanager = new HookManager($this->db);
368 }
369 $hookmanager->initHooks(array('pdfgeneration'));
370 $parameters = array('file' => $file, 'object' => $this, 'outputlangs' => $outputlangs);
371 global $action;
372 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
373 if ($reshook < 0) {
374 $this->error = $hookmanager->error;
375 $this->errors = $hookmanager->errors;
376 }
377
378 dolChmod($file);
379
380 $this->result = array('fullpath' => $file);
381
382 return 1;
383 }
384
385 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
395 protected function _pagehead(&$pdf, $page, $showaddress, $outputlangs)
396 {
397 // phpcs:enable
398
399 // Do not add the BACKGROUND as this is a report
400 //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
401
402 $default_font_size = pdf_getPDFFontSize($outputlangs);
403
404 $title = getDolGlobalString('MAIN_INFO_SOCIETE_NOM');
405 switch ($this->doc_type) {
406 case "client":
407 $title .= ' - '.$outputlangs->transnoentities("ListOfCustomerPayments");
408 break;
409 case "fourn":
410 $title .= ' - '.$outputlangs->transnoentities("ListOfSupplierPayments");
411 break;
412 }
413 $title .= ' - '.dol_print_date(dol_mktime(0, 0, 0, $this->month, 1, $this->year), "%B %Y", false, $outputlangs, true);
414 $pdf->SetFont('', 'B', $default_font_size + 1);
415 $pdf->SetXY($this->marge_gauche, 10);
416 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->marge_gauche, 2, $title, 0, 'C');
417
418 $pdf->SetFont('', '', $default_font_size);
419
420 $pdf->SetXY($this->posxdate, 16);
421 $pdf->MultiCell(80, 2, $outputlangs->transnoentities("DateBuild")." : ".dol_print_date(time(), "day", false, $outputlangs, true), 0, 'L');
422
423 $pdf->SetXY($this->posxdate + 100, 16);
424 $pdf->MultiCell(80, 2, $outputlangs->transnoentities("Page")." : ".$page, 0, 'R');
425
426
427 // Title line
428 $pdf->SetXY($this->posxdate, $this->tab_top + 2);
429 $pdf->MultiCell($this->posxpaymenttype - $this->posxdate, 2, 'Date');
430
431 $pdf->line($this->posxpaymenttype - 1, $this->tab_top, $this->posxpaymenttype - 1, $this->tab_top + $this->tab_height + 10);
432 $pdf->SetXY($this->posxpaymenttype, $this->tab_top + 2);
433 $pdf->MultiCell($this->posxinvoice - $this->posxpaymenttype, 2, $outputlangs->transnoentities("PaymentMode"), 0, 'L');
434
435 $pdf->line($this->posxinvoice - 1, $this->tab_top, $this->posxinvoice - 1, $this->tab_top + $this->tab_height + 10);
436 $pdf->SetXY($this->posxinvoice, $this->tab_top + 2);
437 $pdf->MultiCell($this->posxbankaccount - $this->posxinvoice, 2, $outputlangs->transnoentities("Invoice"), 0, 'L');
438
439 $pdf->line($this->posxbankaccount - 1, $this->tab_top, $this->posxbankaccount - 1, $this->tab_top + $this->tab_height + 10);
440 $pdf->SetXY($this->posxbankaccount, $this->tab_top + 2);
441 $pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, 2, $outputlangs->transnoentities("BankAccount"), 0, 'L');
442
443
444 $pdf->line($this->posxinvoiceamount - 1, $this->tab_top, $this->posxinvoiceamount - 1, $this->tab_top + $this->tab_height + 10);
445 $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 2);
446 $pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, 2, $outputlangs->transnoentities("AmountInvoice"), 0, 'R');
447
448 $pdf->line($this->posxpaymentamount - 1, $this->tab_top, $this->posxpaymentamount - 1, $this->tab_top + $this->tab_height + 10);
449 $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 2);
450 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount - 1, 2, $outputlangs->transnoentities("AmountPayment"), 0, 'R');
451
452 $pdf->line($this->marge_gauche, $this->tab_top + 10, $this->page_largeur - $this->marge_droite, $this->tab_top + 10);
453
454 $pdf->Rect($this->marge_gauche, $this->tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $this->tab_height + 10);
455
456 return 0;
457 }
458
459
460 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
470 public function Body(&$pdf, $page, $lines, $outputlangs)
471 {
472 // phpcs:enable
473 global $langs, $conf;
474 $default_font_size = pdf_getPDFFontSize($outputlangs);
475
476 $pdf->SetFont('', '', $default_font_size - 1);
477 $oldprowid = 0;
478 $total_page = 0;
479 $total = 0;
480 $pdf->SetFillColor(220, 220, 220);
481 $yp = 0;
482 $numlines = count($lines);
483 if (($this->doc_type == 'client' && getDolGlobalString('PAYMENTS_REPORT_GROUP_BY_MOD')) || ($this->doc_type == 'fourn' && getDolGlobalString('PAYMENTS_FOURN_REPORT_GROUP_BY_MOD'))) {
484 $mod = $lines[0][2];
485 $total_mod = 0;
486 }
487 for ($j = 0; $j < $numlines; $j++) {
488 $i = $j;
489 if ($yp > $this->tab_height - 5) {
490 $page++;
491 $pdf->AddPage();
492 $this->_pagehead($pdf, $page, 0, $outputlangs);
493 $pdf->SetFont('', '', $default_font_size - 1);
494 $yp = 0;
495 }
496 if ($oldprowid != $lines[$j][7]) {
497 if ($yp > $this->tab_height - 15) {
498 $pdf->SetFillColor(255, 255, 255);
499 $pdf->Rect($this->marge_gauche + 1, $this->tab_top + 10 + $yp, $this->posxpaymentamount - $this->marge_droite - 3, $this->line_height, 'F', array(), array());
500 $pdf->line($this->marge_gauche, $this->tab_top + 10 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 10 + $yp, array('dash' => 1));
501 $pdf->line($this->marge_gauche, $this->tab_top + 15 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 15 + $yp);
502 $pdf->SetFont('', 'B', $default_font_size - 1);
503 $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
504 $pdf->MultiCell($this->posxpaymentamount - 2 - $this->marge_droite, $this->line_height, $langs->transnoentities('SubTotal')." : ", 0, 'R', 1);
505 $pdf->SetXY($this->posxpaymentamount - 1, $this->tab_top + 10 + $yp);
506 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount + 1, $this->line_height, price($total_page), 0, 'R', 1);
507 $pdf->SetFont('', '', $default_font_size - 1);
508 $pdf->SetFillColor(220, 220, 220);
509 $page++;
510 $pdf->AddPage();
511 $this->_pagehead($pdf, $page, 0, $outputlangs);
512 $pdf->SetFont('', '', $default_font_size - 1);
513 $yp = 0;
514 $total += $total_page;
515 $total_page = 0;
516 }
517
518 $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
519 $pdf->MultiCell($this->posxpaymenttype - $this->posxdate + 1, $this->line_height, $lines[$j][1], 0, 'L', 1);
520
521 $pdf->SetXY($this->posxpaymenttype, $this->tab_top + 10 + $yp);
522 $pdf->MultiCell($this->posxinvoiceamount - $this->posxpaymenttype, $this->line_height, $lines[$j][2].' '.$lines[$j][3], 0, 'L', 1);
523
524 $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
525 $pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount, $this->line_height, '', 0, 'R', 1);
526
527 $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
528 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][4], 0, 'R', 1);
529 $yp = $yp + 5;
530 $total_page += $lines[$j][9];
531 if (($this->doc_type == 'client' && getDolGlobalString('PAYMENTS_REPORT_GROUP_BY_MOD')) || ($this->doc_type == 'fourn' && getDolGlobalString('PAYMENTS_FOURN_REPORT_GROUP_BY_MOD'))) {
532 $total_mod += $lines[$j][9];
533 }
534 }
535
536 // Invoice number
537 $pdf->SetXY($this->posxinvoice, $this->tab_top + 10 + $yp);
538 $pdf->MultiCell($this->posxinvoice - $this->posxbankaccount, $this->line_height, $lines[$j][0], 0, 'L', 0);
539
540 // BankAccount
541 $pdf->SetXY($this->posxbankaccount, $this->tab_top + 10 + $yp);
542 $pdf->MultiCell($this->posxbankaccount - $this->posxdate, $this->line_height, $lines[$j][8], 0, 'L', 0);
543
544 // Invoice amount
545 $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
546 $pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, $this->line_height, $lines[$j][5], 0, 'R', 0);
547
548 // Payment amount
549 $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
550 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][6], 0, 'R', 0);
551 $yp = $yp + 5;
552
553 if ($oldprowid != $lines[$j][7]) {
554 $oldprowid = $lines[$j][7];
555 }
556
557 // Add line to add total by payment mode if mode reglement for nex line change
558 if ((($this->doc_type == 'client' && getDolGlobalString('PAYMENTS_REPORT_GROUP_BY_MOD')) || ($this->doc_type == 'fourn' && getDolGlobalString('PAYMENTS_FOURN_REPORT_GROUP_BY_MOD'))) && ($mod != $lines[$j + 1][2])) {
559 $pdf->SetFillColor(245, 245, 245);
560 $pdf->Rect($this->marge_gauche + 1, $this->tab_top + 10 + $yp, $this->posxpaymentamount - $this->marge_droite - 3, $this->line_height, 'F', array(), array());
561 $pdf->line($this->marge_gauche, $this->tab_top + 10 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 10 + $yp, array('dash' => 1));
562 $pdf->line($this->marge_gauche, $this->tab_top + 15 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 15 + $yp);
563 $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
564 $pdf->SetFont('', 'I', $default_font_size - 1);
565 $pdf->MultiCell($this->posxpaymentamount - 2 - $this->marge_droite, $this->line_height, $langs->transnoentities('Total').' '.$mod." : ", 0, 'R', 1);
566 $pdf->SetXY($this->posxpaymentamount - 1, $this->tab_top + 10 + $yp);
567 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount + 1, $this->line_height, price($total_mod), 0, 'R', 1);
568 $pdf->SetFont('', '', $default_font_size - 1);
569 $mod = $lines[$j + 1][2];
570 $total_mod = 0;
571 $yp = $yp + 5;
572 if ($yp > $this->tab_height - 5) {
573 $page++;
574 $pdf->AddPage();
575 $this->_pagehead($pdf, $page, 0, $outputlangs);
576 $pdf->SetFont('', '', $default_font_size - 1);
577 $yp = 0;
578 }
579 $pdf->SetFillColor(220, 220, 220);
580 }
581 }
582 $total += $total_page;
583 $pdf->SetFillColor(255, 255, 255);
584 $pdf->Rect($this->marge_gauche + 1, $this->tab_top + 10 + $yp, $this->posxpaymentamount - $this->marge_droite - 3, $this->line_height, 'F', array(), array());
585 $pdf->line($this->marge_gauche, $this->tab_top + 10 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 10 + $yp, array('dash' => 1));
586 $pdf->line($this->marge_gauche, $this->tab_top + 15 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 15 + $yp);
587 $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
588 $pdf->SetFont('', 'B');
589 $pdf->MultiCell($this->posxpaymentamount - 2 - $this->marge_droite, $this->line_height, $langs->transnoentities('Total')." : ", 0, 'R', 1);
590 $pdf->SetXY($this->posxpaymentamount - 1, $this->tab_top + 10 + $yp);
591 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount + 1, $this->line_height, price($total), 0, 'R', 1);
592 $pdf->SetFillColor(220, 220, 220);
593 }
594}
Parent class for documents (PDF, ODT, ...) generators.
Class to manage hooks.
Class to manage reporting of payments.
_pagehead(&$pdf, $page, $showaddress, $outputlangs)
Show top header of page.
__construct($db)
Constructor.
Body(&$pdf, $page, $lines, $outputlangs)
Output body.
write_file($_dir, $month, $year, $outputlangs)
Fonction generant la rapport sur le disque.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition date.lib.php:595
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition date.lib.php:614
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_mktime($hour, $minute, $second, $month, $day, $year, $gm='auto', $check=1)
Return a timestamp date built from detailed information (by default a local PHP server timestamp) Rep...
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:290
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition pdf.lib.php:86
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:267
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition pdf.lib.php:128
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition repair.php:137