dolibarr 24.0.0-beta
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 * Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
7 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 * or see https://www.gnu.org/
22 */
23
30require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
31require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php';
33
34
39{
43 public $tab_top;
44
48 public $line_height;
49
53 public $line_per_page;
54
58 public $tab_height;
59
63 public $posxdate;
64
68 public $posxpaymenttype;
72 public $posxinvoice;
76 public $posxbankaccount;
80 public $posxinvoiceamount;
84 public $posxpaymentamount;
85
89 public $doc_type;
90
94 public $year;
95
99 public $month;
100
104 public $day;
105
111 public function __construct($db)
112 {
113 global $langs, $conf;
114
115 // Load translation files required by the page
116 $langs->loadLangs(array("bills", "compta", "main"));
117
118 $this->db = $db;
119 $this->description = $langs->transnoentities("ListOfCustomerPayments");
120
121 // Page size for A4 format
122 $this->type = 'pdf';
123 $formatarray = pdf_getFormat();
124 $this->page_largeur = $formatarray['width'];
125 $this->page_hauteur = $formatarray['height'];
126 $this->format = array($this->page_largeur, $this->page_hauteur);
127 $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
128 $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
129 $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
130 $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
131
132 $this->tab_top = 30;
133
134 $this->line_height = 5;
135 $this->line_per_page = 40;
136 $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;
137
138 $this->posxdate = $this->marge_gauche + 2;
139 $this->posxpaymenttype = 32;
140 $this->posxinvoice = 72;
141 $this->posxbankaccount = 115;
142 $this->posxinvoiceamount = 135;
143 $this->posxpaymentamount = 167;
144 if ($this->page_largeur < 210) { // To work with US executive format
145 $this->line_per_page = 35;
146 $this->posxpaymenttype -= 10;
147 $this->posxinvoice -= 0;
148 $this->posxinvoiceamount -= 10;
149 $this->posxpaymentamount -= 20;
150 }
151
152 // which type of document will be generated: clients (client) or providers (fourn) invoices
153 $this->doc_type = "client";
154 }
155
156
157 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
168 public function write_file($_dir, $month, $year, $outputlangs, $day = 0)
169 {
170 // phpcs:enable
171 include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
172
173 global $conf, $hookmanager, $langs, $user;
174
175 $socid = 0;
176 if ($user->socid) {
177 $socid = $user->socid;
178 }
179
180 if (!is_object($outputlangs)) {
181 $outputlangs = $langs;
182 }
183 // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
184 if (getDolGlobalString('MAIN_USE_FPDF')) {
185 $outputlangs->charset_output = 'ISO-8859-1';
186 }
187
188 $this->month = $month;
189 $this->year = $year;
190 $this->day = $day;
191 $dir = $_dir.'/'.$year;
192
193 if (!is_dir($dir)) {
194 $result = dol_mkdir($dir);
195 if ($result < 0) {
196 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
197 return -1;
198 }
199 }
200
201 $month = sprintf("%02d", $month);
202 $year = sprintf("%04d", $year);
203 $day = sprintf("%02d", $day);
204
205 $file = $dir."/payments-".$year."-".$month.($this->day ? "-".$day : "").".pdf";
206 switch ($this->doc_type) {
207 case "client":
208 $file = $dir."/payments-".$year."-".$month.($this->day ? "-".$day : "").".pdf";
209 break;
210 case "fourn":
211 $file = $dir."/supplier_payments-".$year."-".$month.($this->day ? "-".$day : "").".pdf";
212 break;
213 }
214
215
216 // Add pdfgeneration hook
217 if (!is_object($hookmanager)) {
218 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
219 $hookmanager = new HookManager($this->db);
220 }
221 $hookmanager->initHooks(array('pdfgeneration'));
222 $parameters = array('file' => $file, 'object' => $this, 'outputlangs' => $outputlangs);
223 global $action;
224 $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $this, $action); // Note that $action and $this may have been modified by some hooks
225
226 $pdf = pdf_getInstance($this->format);
227 $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
228
229 if (class_exists('TCPDF')) {
230 $pdf->setPrintHeader(false);
231 $pdf->setPrintFooter(false);
232 }
233 $pdf->SetFont(pdf_getPDFFont($outputlangs));
234
235 $num = 0;
236 $lines = array();
237
238 // count number of lines of payment
239 $sql = "SELECT p.rowid as prowid";
240 switch ($this->doc_type) {
241 case "client":
242 $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p";
243 break;
244 case "fourn":
245 $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
246 break;
247 }
248 if ($this->day) {
249 $sql .= " WHERE p.datep BETWEEN '".$this->db->idate(dol_mktime(0, 0, 0, (int) $month, (int) $day, (int) $year))."' AND '".$this->db->idate(dol_mktime(23, 59, 59, (int) $month, (int) $day, (int) $year))."'";
250 } else {
251 $sql .= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day((int) $year, (int) $month))."' AND '".$this->db->idate(dol_get_last_day((int) $year, (int) $month))."'";
252 }
253 $sql .= " AND p.entity = ".$conf->entity;
254 $result = $this->db->query($sql);
255 if ($result) {
256 $numpaiement = $this->db->num_rows($result);
257 } else {
258 $numpaiement = 0;
259 }
260
261 // number of bill
262 switch ($this->doc_type) {
263 case "client":
264 $sql = "SELECT p.datep as dp, f.ref";
265 $sql .= ", c.code as paiement_code, p.num_paiement as num_payment";
266 $sql .= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
267 $sql .= ", pf.amount as pf_amount";
268 if (isModEnabled("bank")) {
269 $sql .= ", ba.ref as bankaccount";
270 }
271 $sql .= ", p.rowid as prowid";
272 $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
273 $sql .= ", ".MAIN_DB_PREFIX."facture as f,";
274 $sql .= " ".MAIN_DB_PREFIX."paiement_facture as pf,";
275 if (isModEnabled("bank")) {
276 $sql .= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
277 }
278 $sql .= " ".MAIN_DB_PREFIX."societe as s";
279 if (!$user->hasRight('societe', 'client', 'voir')) {
280 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
281 }
282 $sql .= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid";
283 if (isModEnabled("bank")) {
284 $sql .= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
285 }
286 $sql .= " AND f.entity IN (".getEntity('invoice').")";
287 if ($this->day) {
288 $sql .= " AND p.datep BETWEEN '".$this->db->idate(dol_mktime(0, 0, 0, (int) $month, (int) $day, (int) $year))."' AND '".$this->db->idate(dol_mktime(23, 59, 59, (int) $month, (int) $day, (int) $year))."'";
289 } else {
290 $sql .= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day((int) $year, (int) $month))."' AND '".$this->db->idate(dol_get_last_day((int) $year, (int) $month))."'";
291 }
292 if (!$user->hasRight('societe', 'client', 'voir')) {
293 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
294 }
295 if (!empty($socid)) {
296 $sql .= " AND s.rowid = ".((int) $socid);
297 }
298 // If global param PAYMENTS_REPORT_GROUP_BY_MOD is set, payment are ordered by paiement_code
299 if (getDolGlobalString('PAYMENTS_REPORT_GROUP_BY_MOD')) {
300 $sql .= " ORDER BY paiement_code ASC, p.datep ASC, pf.fk_paiement ASC";
301 } else {
302 $sql .= " ORDER BY p.datep ASC, pf.fk_paiement ASC";
303 }
304 break;
305 case "fourn":
306 $sql = "SELECT p.datep as dp, f.ref as ref";
307 $sql .= ", c.code as paiement_code, p.num_paiement as num_payment";
308 $sql .= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
309 $sql .= ", pf.amount as pf_amount";
310 if (isModEnabled("bank")) {
311 $sql .= ", ba.ref as bankaccount";
312 }
313 $sql .= ", p.rowid as prowid";
314 $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
315 $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f,";
316 $sql .= " ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
317 if (isModEnabled("bank")) {
318 $sql .= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
319 }
320 $sql .= " ".MAIN_DB_PREFIX."societe as s";
321 if (!$user->hasRight('societe', 'client', 'voir')) {
322 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
323 }
324 $sql .= " WHERE f.fk_soc = s.rowid AND pf.fk_facturefourn = f.rowid AND pf.fk_paiementfourn = p.rowid";
325 if (isModEnabled("bank")) {
326 $sql .= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
327 }
328 $sql .= " AND f.entity IN (".getEntity('invoice').")";
329 if ($this->day) {
330 $sql .= " AND p.datep BETWEEN '".$this->db->idate(dol_mktime(0, 0, 0, (int) $month, (int) $day, (int) $year))."' AND '".$this->db->idate(dol_mktime(23, 59, 59, (int) $month, (int) $day, (int) $year))."'";
331 } else {
332 $sql .= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day((int) $year, (int) $month))."' AND '".$this->db->idate(dol_get_last_day((int) $year, (int) $month))."'";
333 }
334 if (!$user->hasRight('societe', 'client', 'voir')) {
335 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
336 }
337 if (!empty($socid)) {
338 $sql .= " AND s.rowid = ".((int) $socid);
339 }
340 // If global param PAYMENTS_FOURN_REPORT_GROUP_BY_MOD is set, payment fourn are ordered by paiement_code
341 if (getDolGlobalString('PAYMENTS_FOURN_REPORT_GROUP_BY_MOD')) {
342 $sql .= " ORDER BY paiement_code ASC, p.datep ASC, pf.fk_paiementfourn ASC";
343 } else {
344 $sql .= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC";
345 }
346 break;
347 }
348
349 dol_syslog(get_class($this)."::write_file", LOG_DEBUG);
350 $result = $this->db->query($sql);
351 if ($result) {
352 $num = $this->db->num_rows($result);
353 $i = 0;
354
355 while ($i < $num) {
356 $objp = $this->db->fetch_object($result);
357
358 $lines[$i][0] = $objp->ref;
359 $lines[$i][1] = dol_print_date($this->db->jdate($objp->dp), "day", false, $outputlangs, true);
360 $lines[$i][2] = $langs->transnoentities("PaymentTypeShort".$objp->paiement_code);
361 $lines[$i][3] = $objp->num_payment;
362 $lines[$i][4] = price($objp->paiement_amount);
363 $lines[$i][5] = price($objp->facture_amount);
364 $lines[$i][6] = price($objp->pf_amount);
365 $lines[$i][7] = $objp->prowid;
366 $lines[$i][8] = $objp->bankaccount;
367 $lines[$i][9] = $objp->paiement_amount;
368 $i++;
369 }
370 } else {
371 dol_print_error($this->db);
372 }
373
374 $pages = intval(($num + $numpaiement) / $this->line_per_page);
375
376 if ((($num + $numpaiement) % $this->line_per_page) > 0) {
377 $pages++;
378 }
379
380 if ($pages == 0) {
381 // force to build at least one page if report has no line
382 $pages = 1;
383 }
384
385 $pdf->Open();
386 $pagenb = 0;
387 $pdf->SetDrawColor(128, 128, 128);
388
389 $pdf->SetTitle($outputlangs->transnoentities("Payments"));
390 $pdf->SetSubject($outputlangs->transnoentities("Payments"));
391 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
392 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getAnonymisableFullName($outputlangs)));
393 //$pdf->SetKeyWords();
394 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
395 $pdf->SetCompression(false);
396 }
397
398 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
399 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
400 $pdf->setAutoPageBreak(true, 0);
401
402 // New page
403 $pdf->AddPage();
404 $pagenb++;
405 $this->_pagehead($pdf, $pagenb, 1, $outputlangs);
406 $pdf->SetFont('', '', 9);
407 $pdf->MultiCell(0, 3, ''); // Set interline to 3
408 $pdf->SetTextColor(0, 0, 0);
409
410
411 $this->Body($pdf, 1, $lines, $outputlangs);
412
413 if (method_exists($pdf, 'AliasNbPages')) {
414 $pdf->AliasNbPages(); // @phan-suppress-current-line PhanUndeclaredMethod
415 }
416
417 $pdf->Close();
418
419 $pdf->Output($file, 'F');
420
421 // Add pdfgeneration hook
422 if (!is_object($hookmanager)) {
423 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
424 $hookmanager = new HookManager($this->db);
425 }
426 $hookmanager->initHooks(array('pdfgeneration'));
427 $parameters = array('file' => $file, 'object' => $this, 'outputlangs' => $outputlangs);
428 global $action;
429 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
430 $this->warnings = $hookmanager->warnings;
431 if ($reshook < 0) {
432 $this->error = $hookmanager->error;
433 $this->errors = $hookmanager->errors;
434 dolChmod($file);
435 return -1;
436 }
437
438 dolChmod($file);
439
440 $this->result = array('fullpath' => $file);
441
442 return 1;
443 }
444
445 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
455 protected function _pagehead(&$pdf, $page, $showaddress, $outputlangs)
456 {
457 // phpcs:enable
458
459 // Do not add the BACKGROUND as this is a report
460 //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
461
462 $default_font_size = pdf_getPDFFontSize($outputlangs);
463
464 $title = getDolGlobalString('MAIN_INFO_SOCIETE_NOM');
465 switch ($this->doc_type) {
466 case "client":
467 $title .= ' - '.$outputlangs->transnoentities("ListOfCustomerPayments");
468 break;
469 case "fourn":
470 $title .= ' - '.$outputlangs->transnoentities("ListOfSupplierPayments");
471 break;
472 }
473 $title .= ' - '.dol_print_date(dol_mktime(0, 0, 0, $this->month, 1, $this->year), "%B %Y", false, $outputlangs, true);
474 $pdf->SetFont('', 'B', $default_font_size + 1);
475 $pdf->SetXY($this->marge_gauche, 10);
476 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->marge_gauche, 2, $title, 0, 'C');
477
478 $pdf->SetFont('', '', $default_font_size);
479
480 $pdf->SetXY($this->posxdate, 16);
481 $pdf->MultiCell(80, 2, $outputlangs->transnoentities("DateBuild")." : ".dol_print_date(time(), "day", false, $outputlangs, true), 0, 'L');
482
483 $pdf->SetXY($this->posxdate + 100, 16);
484 $pdf->MultiCell(80, 2, $outputlangs->transnoentities("Page")." : ".$page, 0, 'R');
485
486
487 // Title line
488 $pdf->SetXY($this->posxdate, $this->tab_top + 2);
489 $pdf->MultiCell($this->posxpaymenttype - $this->posxdate, 2, 'Date');
490
491 $pdf->line($this->posxpaymenttype - 1, $this->tab_top, $this->posxpaymenttype - 1, $this->tab_top + $this->tab_height + 10);
492 $pdf->SetXY($this->posxpaymenttype, $this->tab_top + 2);
493 $pdf->MultiCell($this->posxinvoice - $this->posxpaymenttype, 2, $outputlangs->transnoentities("PaymentMode"), 0, 'L');
494
495 $pdf->line($this->posxinvoice - 1, $this->tab_top, $this->posxinvoice - 1, $this->tab_top + $this->tab_height + 10);
496 $pdf->SetXY($this->posxinvoice, $this->tab_top + 2);
497 $pdf->MultiCell($this->posxbankaccount - $this->posxinvoice, 2, $outputlangs->transnoentities("Invoice"), 0, 'L');
498
499 $pdf->line($this->posxbankaccount - 1, $this->tab_top, $this->posxbankaccount - 1, $this->tab_top + $this->tab_height + 10);
500 $pdf->SetXY($this->posxbankaccount, $this->tab_top + 2);
501 $pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, 2, $outputlangs->transnoentities("BankAccount"), 0, 'L');
502
503
504 $pdf->line($this->posxinvoiceamount - 1, $this->tab_top, $this->posxinvoiceamount - 1, $this->tab_top + $this->tab_height + 10);
505 $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 2);
506 $pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, 2, $outputlangs->transnoentities("AmountInvoice"), 0, 'R');
507
508 $pdf->line($this->posxpaymentamount - 1, $this->tab_top, $this->posxpaymentamount - 1, $this->tab_top + $this->tab_height + 10);
509 $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 2);
510 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount - 1, 2, $outputlangs->transnoentities("AmountPayment"), 0, 'R');
511
512 $pdf->line($this->marge_gauche, $this->tab_top + 10, $this->page_largeur - $this->marge_droite, $this->tab_top + 10);
513
514 $pdf->Rect($this->marge_gauche, $this->tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $this->tab_height + 10);
515
516 return 0;
517 }
518
519
520 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
530 public function Body(&$pdf, $page, $lines, $outputlangs)
531 {
532 // phpcs:enable
533 global $langs, $conf;
534 $default_font_size = pdf_getPDFFontSize($outputlangs);
535
536 $pdf->SetFont('', '', $default_font_size - 1);
537 $oldprowid = 0;
538 $total_page = 0;
539 $total_mod = 0;
540 $mod = 0;
541 $total = 0;
542 $pdf->SetFillColor(220, 220, 220);
543 $yp = 0;
544 $numlines = count($lines);
545 if (($this->doc_type == 'client' && getDolGlobalString('PAYMENTS_REPORT_GROUP_BY_MOD')) || ($this->doc_type == 'fourn' && getDolGlobalString('PAYMENTS_FOURN_REPORT_GROUP_BY_MOD'))) {
546 $mod = $lines[0][2];
547 }
548 for ($j = 0; $j < $numlines; $j++) {
549 $i = $j;
550 if ($yp > $this->tab_height - 5) {
551 $page++;
552 $pdf->AddPage();
553 $this->_pagehead($pdf, $page, 0, $outputlangs);
554 $pdf->SetFont('', '', $default_font_size - 1);
555 $yp = 0;
556 }
557 if ($oldprowid != $lines[$j][7]) {
558 if ($yp > $this->tab_height - 15) {
559 $pdf->SetFillColor(255, 255, 255);
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->SetFont('', 'B', $default_font_size - 1);
564 $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
565 $pdf->MultiCell($this->posxpaymentamount - 2 - $this->marge_droite, $this->line_height, $langs->transnoentities('SubTotal')." : ", 0, 'R', true);
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_page), 0, 'R', true);
568 $pdf->SetFont('', '', $default_font_size - 1);
569 $pdf->SetFillColor(220, 220, 220);
570 $page++;
571 $pdf->AddPage();
572 $this->_pagehead($pdf, $page, 0, $outputlangs);
573 $pdf->SetFont('', '', $default_font_size - 1);
574 $yp = 0;
575 $total += $total_page;
576 $total_page = 0;
577 }
578
579 $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
580 $pdf->MultiCell($this->posxpaymenttype - $this->posxdate + 1, $this->line_height, $lines[$j][1], 0, 'L', true);
581
582 $pdf->SetXY($this->posxpaymenttype, $this->tab_top + 10 + $yp);
583 $pdf->MultiCell($this->posxinvoiceamount - $this->posxpaymenttype, $this->line_height, $lines[$j][2].' '.$lines[$j][3], 0, 'L', true);
584
585 $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
586 $pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount, $this->line_height, '', 0, 'R', true);
587
588 $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
589 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][4], 0, 'R', true);
590 $yp += 5;
591 $total_page += (float) $lines[$j][9];
592 if (($this->doc_type == 'client' && getDolGlobalString('PAYMENTS_REPORT_GROUP_BY_MOD')) || ($this->doc_type == 'fourn' && getDolGlobalString('PAYMENTS_FOURN_REPORT_GROUP_BY_MOD'))) {
593 $total_mod += (float) $lines[$j][9];
594 }
595 }
596
597 // Invoice number
598 $pdf->SetXY($this->posxinvoice, $this->tab_top + 10 + $yp);
599 $pdf->MultiCell($this->posxinvoice - $this->posxbankaccount, $this->line_height, $lines[$j][0], 0, 'L', false);
600
601 // BankAccount
602 $pdf->SetXY($this->posxbankaccount, $this->tab_top + 10 + $yp);
603 $pdf->MultiCell($this->posxbankaccount - $this->posxdate, $this->line_height, $lines[$j][8], 0, 'L', false);
604
605 // Invoice amount
606 $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
607 $pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, $this->line_height, $lines[$j][5], 0, 'R', false);
608
609 // Payment amount
610 $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
611 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][6], 0, 'R', false);
612 $yp += 5;
613
614 if ($oldprowid != $lines[$j][7]) {
615 $oldprowid = $lines[$j][7];
616 }
617
618 // Add line to add total by payment mode if mode reglement for nex line change
619 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])) {
620 $pdf->SetFillColor(245, 245, 245);
621 $pdf->Rect($this->marge_gauche + 1, $this->tab_top + 10 + $yp, $this->posxpaymentamount - $this->marge_droite - 3, $this->line_height, 'F', array(), array());
622 $pdf->line($this->marge_gauche, $this->tab_top + 10 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 10 + $yp, array('dash' => 1));
623 $pdf->line($this->marge_gauche, $this->tab_top + 15 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 15 + $yp);
624 $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
625 $pdf->SetFont('', 'I', $default_font_size - 1);
626 $pdf->MultiCell($this->posxpaymentamount - 2 - $this->marge_droite, $this->line_height, $langs->transnoentities('Total').' '.$mod." : ", 0, 'R', true);
627 $pdf->SetXY($this->posxpaymentamount - 1, $this->tab_top + 10 + $yp);
628 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount + 1, $this->line_height, price($total_mod), 0, 'R', true);
629 $pdf->SetFont('', '', $default_font_size - 1);
630 $mod = $lines[$j + 1][2];
631 $total_mod = 0;
632 $yp += 5;
633 if ($yp > $this->tab_height - 5) {
634 $page++;
635 $pdf->AddPage();
636 $this->_pagehead($pdf, $page, 0, $outputlangs);
637 $pdf->SetFont('', '', $default_font_size - 1);
638 $yp = 0;
639 }
640 $pdf->SetFillColor(220, 220, 220);
641 }
642 }
643 $total += $total_page;
644 $pdf->SetFillColor(255, 255, 255);
645 $pdf->Rect($this->marge_gauche + 1, $this->tab_top + 10 + $yp, $this->posxpaymentamount - $this->marge_droite - 3, $this->line_height, 'F', array(), array());
646 $pdf->line($this->marge_gauche, $this->tab_top + 10 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 10 + $yp, array('dash' => 1));
647 $pdf->line($this->marge_gauche, $this->tab_top + 15 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 15 + $yp);
648 $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
649 $pdf->SetFont('', 'B');
650 $pdf->MultiCell($this->posxpaymentamount - 2 - $this->marge_droite, $this->line_height, $langs->transnoentities('Total')." : ", 0, 'R', true);
651 $pdf->SetXY($this->posxpaymentamount - 1, $this->tab_top + 10 + $yp);
652 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount + 1, $this->line_height, price($total), 0, 'R', true);
653 $pdf->SetFillColor(220, 220, 220);
654 }
655}
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.
write_file($_dir, $month, $year, $outputlangs, $day=0)
Fonction generant la rapport sur le disque.
__construct($db)
Constructor.
Body(&$pdf, $page, $lines, $outputlangs)
Output body.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition date.lib.php:604
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition date.lib.php:623
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.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
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, $decorate=0)
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 a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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_getFormat($outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition pdf.lib.php:87
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:294
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:273
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition pdf.lib.php:129
if(preg_match('/(crypted|dolcrypt):/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
'integer', 'integer:ObjectClass:PathToClass[:AddCreateButtonOrNot[:Filter[:Sortfield]]]',...
Definition repair.php:130