dolibarr 21.0.0-alpha
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 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{
40 public $tab_top;
41
42 public $line_height;
43
44 public $line_per_page;
45
46 public $tab_height;
47
48 public $posxdate;
49
50 public $posxpaymenttype;
51 public $posxinvoice;
52 public $posxbankaccount;
53 public $posxinvoiceamount;
54 public $posxpaymentamount;
55
56 public $doc_type;
57
61 public $year;
62
66 public $month;
67
73 public function __construct($db)
74 {
75 global $langs, $conf;
76
77 // Load translation files required by the page
78 $langs->loadLangs(array("bills", "compta", "main"));
79
80 $this->db = $db;
81 $this->description = $langs->transnoentities("ListOfCustomerPayments");
82
83 // Page size for A4 format
84 $this->type = 'pdf';
85 $formatarray = pdf_getFormat();
86 $this->page_largeur = $formatarray['width'];
87 $this->page_hauteur = $formatarray['height'];
88 $this->format = array($this->page_largeur, $this->page_hauteur);
89 $this->marge_gauche = getDolGlobalInt('MAIN_PDF_MARGIN_LEFT', 10);
90 $this->marge_droite = getDolGlobalInt('MAIN_PDF_MARGIN_RIGHT', 10);
91 $this->marge_haute = getDolGlobalInt('MAIN_PDF_MARGIN_TOP', 10);
92 $this->marge_basse = getDolGlobalInt('MAIN_PDF_MARGIN_BOTTOM', 10);
93
94 $this->tab_top = 30;
95
96 $this->line_height = 5;
97 $this->line_per_page = 40;
98 $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;
99
100 $this->posxdate = $this->marge_gauche + 2;
101 $this->posxpaymenttype = 42;
102 $this->posxinvoice = 82;
103 $this->posxbankaccount = 110;
104 $this->posxinvoiceamount = 132;
105 $this->posxpaymentamount = 162;
106 if ($this->page_largeur < 210) { // To work with US executive format
107 $this->line_per_page = 35;
108 $this->posxpaymenttype -= 10;
109 $this->posxinvoice -= 0;
110 $this->posxinvoiceamount -= 10;
111 $this->posxpaymentamount -= 20;
112 }
113 // which type of document will be generated: clients (client) or providers (fourn) invoices
114 $this->doc_type = "client";
115 }
116
117
118 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
128 public function write_file($_dir, $month, $year, $outputlangs)
129 {
130 // phpcs:enable
131 include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
132
133 global $conf, $hookmanager, $langs, $user;
134
135 $socid = 0;
136 if ($user->socid) {
137 $socid = $user->socid;
138 }
139
140 if (!is_object($outputlangs)) {
141 $outputlangs = $langs;
142 }
143 // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
144 if (getDolGlobalString('MAIN_USE_FPDF')) {
145 $outputlangs->charset_output = 'ISO-8859-1';
146 }
147
148 $this->month = $month;
149 $this->year = $year;
150 $dir = $_dir.'/'.$year;
151
152 if (!is_dir($dir)) {
153 $result = dol_mkdir($dir);
154 if ($result < 0) {
155 $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
156 return -1;
157 }
158 }
159
160 $month = sprintf("%02d", $month);
161 $year = sprintf("%04d", $year);
162
163 $file = $dir."/payments-".$year."-".$month.".pdf";
164 switch ($this->doc_type) {
165 case "client":
166 $file = $dir."/payments-".$year."-".$month.".pdf";
167 break;
168 case "fourn":
169 $file = $dir."/supplier_payments-".$year."-".$month.".pdf";
170 break;
171 }
172
173
174 // Add pdfgeneration hook
175 if (!is_object($hookmanager)) {
176 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
177 $hookmanager = new HookManager($this->db);
178 }
179 $hookmanager->initHooks(array('pdfgeneration'));
180 $parameters = array('file' => $file, 'object' => $this, 'outputlangs' => $outputlangs);
181 global $action;
182 $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $this, $action); // Note that $action and $this may have been modified by some hooks
183
184 $pdf = pdf_getInstance($this->format);
185 $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
186
187 if (class_exists('TCPDF')) {
188 $pdf->setPrintHeader(false);
189 $pdf->setPrintFooter(false);
190 }
191 $pdf->SetFont(pdf_getPDFFont($outputlangs));
192
193 $num = 0;
194 $lines = array();
195
196 // count number of lines of payment
197 $sql = "SELECT p.rowid as prowid";
198 switch ($this->doc_type) {
199 case "client":
200 $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p";
201 break;
202 case "fourn":
203 $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
204 break;
205 }
206 $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))."'";
207 $sql .= " AND p.entity = ".$conf->entity;
208 $result = $this->db->query($sql);
209 if ($result) {
210 $numpaiement = $this->db->num_rows($result);
211 }
212
213 // number of bill
214 switch ($this->doc_type) {
215 case "client":
216 $sql = "SELECT p.datep as dp, f.ref";
217 $sql .= ", c.code as paiement_code, p.num_paiement as num_payment";
218 $sql .= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
219 $sql .= ", pf.amount as pf_amount";
220 if (isModEnabled("bank")) {
221 $sql .= ", ba.ref as bankaccount";
222 }
223 $sql .= ", p.rowid as prowid";
224 $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
225 $sql .= ", ".MAIN_DB_PREFIX."facture as f,";
226 $sql .= " ".MAIN_DB_PREFIX."paiement_facture as pf,";
227 if (isModEnabled("bank")) {
228 $sql .= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
229 }
230 $sql .= " ".MAIN_DB_PREFIX."societe as s";
231 if (!$user->hasRight('societe', 'client', 'voir')) {
232 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
233 }
234 $sql .= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid";
235 if (isModEnabled("bank")) {
236 $sql .= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
237 }
238 $sql .= " AND f.entity IN (".getEntity('invoice').")";
239 $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))."'";
240 if (!$user->hasRight('societe', 'client', 'voir')) {
241 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
242 }
243 if (!empty($socid)) {
244 $sql .= " AND s.rowid = ".((int) $socid);
245 }
246 // If global param PAYMENTS_REPORT_GROUP_BY_MOD is set, payment are ordered by paiement_code
247 if (getDolGlobalString('PAYMENTS_REPORT_GROUP_BY_MOD')) {
248 $sql .= " ORDER BY paiement_code ASC, p.datep ASC, pf.fk_paiement ASC";
249 } else {
250 $sql .= " ORDER BY p.datep ASC, pf.fk_paiement ASC";
251 }
252 break;
253 case "fourn":
254 $sql = "SELECT p.datep as dp, f.ref as ref";
255 $sql .= ", c.code as paiement_code, p.num_paiement as num_payment";
256 $sql .= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
257 $sql .= ", pf.amount as pf_amount";
258 if (isModEnabled("bank")) {
259 $sql .= ", ba.ref as bankaccount";
260 }
261 $sql .= ", p.rowid as prowid";
262 $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
263 $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f,";
264 $sql .= " ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
265 if (isModEnabled("bank")) {
266 $sql .= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
267 }
268 $sql .= " ".MAIN_DB_PREFIX."societe as s";
269 if (!$user->hasRight('societe', 'client', 'voir')) {
270 $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
271 }
272 $sql .= " WHERE f.fk_soc = s.rowid AND pf.fk_facturefourn = f.rowid AND pf.fk_paiementfourn = p.rowid";
273 if (isModEnabled("bank")) {
274 $sql .= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
275 }
276 $sql .= " AND f.entity IN (".getEntity('invoice').")";
277 $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))."'";
278 if (!$user->hasRight('societe', 'client', 'voir')) {
279 $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".((int) $user->id);
280 }
281 if (!empty($socid)) {
282 $sql .= " AND s.rowid = ".((int) $socid);
283 }
284 // If global param PAYMENTS_FOURN_REPORT_GROUP_BY_MOD is set, payment fourn are ordered by paiement_code
285 if (getDolGlobalString('PAYMENTS_FOURN_REPORT_GROUP_BY_MOD')) {
286 $sql .= " ORDER BY paiement_code ASC, p.datep ASC, pf.fk_paiementfourn ASC";
287 } else {
288 $sql .= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC";
289 }
290 break;
291 }
292
293 dol_syslog(get_class($this)."::write_file", LOG_DEBUG);
294 $result = $this->db->query($sql);
295 if ($result) {
296 $num = $this->db->num_rows($result);
297 $i = 0;
298
299 while ($i < $num) {
300 $objp = $this->db->fetch_object($result);
301
302 $lines[$i][0] = $objp->ref;
303 $lines[$i][1] = dol_print_date($this->db->jdate($objp->dp), "day", false, $outputlangs, true);
304 $lines[$i][2] = $langs->transnoentities("PaymentTypeShort".$objp->paiement_code);
305 $lines[$i][3] = $objp->num_payment;
306 $lines[$i][4] = price($objp->paiement_amount);
307 $lines[$i][5] = price($objp->facture_amount);
308 $lines[$i][6] = price($objp->pf_amount);
309 $lines[$i][7] = $objp->prowid;
310 $lines[$i][8] = $objp->bankaccount;
311 $lines[$i][9] = $objp->paiement_amount;
312 $i++;
313 }
314 } else {
315 dol_print_error($this->db);
316 }
317
318 $pages = intval(($num + $numpaiement) / $this->line_per_page);
319
320 if ((($num + $numpaiement) % $this->line_per_page) > 0) {
321 $pages++;
322 }
323
324 if ($pages == 0) {
325 // force to build at least one page if report has no line
326 $pages = 1;
327 }
328
329 $pdf->Open();
330 $pagenb = 0;
331 $pdf->SetDrawColor(128, 128, 128);
332
333 $pdf->SetTitle($outputlangs->transnoentities("Payments"));
334 $pdf->SetSubject($outputlangs->transnoentities("Payments"));
335 $pdf->SetCreator("Dolibarr ".DOL_VERSION);
336 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
337 //$pdf->SetKeyWords();
338 if (getDolGlobalString('MAIN_DISABLE_PDF_COMPRESSION')) {
339 $pdf->SetCompression(false);
340 }
341
342 // @phan-suppress-next-line PhanPluginSuspiciousParamOrder
343 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
344 $pdf->SetAutoPageBreak(1, 0);
345
346 // New page
347 $pdf->AddPage();
348 $pagenb++;
349 $this->_pagehead($pdf, $pagenb, 1, $outputlangs);
350 $pdf->SetFont('', '', 9);
351 $pdf->MultiCell(0, 3, ''); // Set interline to 3
352 $pdf->SetTextColor(0, 0, 0);
353
354
355 $this->Body($pdf, 1, $lines, $outputlangs);
356
357 if (method_exists($pdf, 'AliasNbPages')) {
358 $pdf->AliasNbPages(); // @phan-suppress-current-line PhanUndeclaredMethod
359 }
360
361 $pdf->Close();
362
363 $pdf->Output($file, 'F');
364
365 // Add pdfgeneration hook
366 if (!is_object($hookmanager)) {
367 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
368 $hookmanager = new HookManager($this->db);
369 }
370 $hookmanager->initHooks(array('pdfgeneration'));
371 $parameters = array('file' => $file, 'object' => $this, 'outputlangs' => $outputlangs);
372 global $action;
373 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
374 if ($reshook < 0) {
375 $this->error = $hookmanager->error;
376 $this->errors = $hookmanager->errors;
377 }
378
379 dolChmod($file);
380
381 $this->result = array('fullpath' => $file);
382
383 return 1;
384 }
385
386 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
396 protected function _pagehead(&$pdf, $page, $showaddress, $outputlangs)
397 {
398 // phpcs:enable
399
400 // Do not add the BACKGROUND as this is a report
401 //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
402
403 $default_font_size = pdf_getPDFFontSize($outputlangs);
404
405 $title = getDolGlobalString('MAIN_INFO_SOCIETE_NOM');
406 switch ($this->doc_type) {
407 case "client":
408 $title .= ' - '.$outputlangs->transnoentities("ListOfCustomerPayments");
409 break;
410 case "fourn":
411 $title .= ' - '.$outputlangs->transnoentities("ListOfSupplierPayments");
412 break;
413 }
414 $title .= ' - '.dol_print_date(dol_mktime(0, 0, 0, $this->month, 1, $this->year), "%B %Y", false, $outputlangs, true);
415 $pdf->SetFont('', 'B', $default_font_size + 1);
416 $pdf->SetXY($this->marge_gauche, 10);
417 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->marge_gauche, 2, $title, 0, 'C');
418
419 $pdf->SetFont('', '', $default_font_size);
420
421 $pdf->SetXY($this->posxdate, 16);
422 $pdf->MultiCell(80, 2, $outputlangs->transnoentities("DateBuild")." : ".dol_print_date(time(), "day", false, $outputlangs, true), 0, 'L');
423
424 $pdf->SetXY($this->posxdate + 100, 16);
425 $pdf->MultiCell(80, 2, $outputlangs->transnoentities("Page")." : ".$page, 0, 'R');
426
427
428 // Title line
429 $pdf->SetXY($this->posxdate, $this->tab_top + 2);
430 $pdf->MultiCell($this->posxpaymenttype - $this->posxdate, 2, 'Date');
431
432 $pdf->line($this->posxpaymenttype - 1, $this->tab_top, $this->posxpaymenttype - 1, $this->tab_top + $this->tab_height + 10);
433 $pdf->SetXY($this->posxpaymenttype, $this->tab_top + 2);
434 $pdf->MultiCell($this->posxinvoice - $this->posxpaymenttype, 2, $outputlangs->transnoentities("PaymentMode"), 0, 'L');
435
436 $pdf->line($this->posxinvoice - 1, $this->tab_top, $this->posxinvoice - 1, $this->tab_top + $this->tab_height + 10);
437 $pdf->SetXY($this->posxinvoice, $this->tab_top + 2);
438 $pdf->MultiCell($this->posxbankaccount - $this->posxinvoice, 2, $outputlangs->transnoentities("Invoice"), 0, 'L');
439
440 $pdf->line($this->posxbankaccount - 1, $this->tab_top, $this->posxbankaccount - 1, $this->tab_top + $this->tab_height + 10);
441 $pdf->SetXY($this->posxbankaccount, $this->tab_top + 2);
442 $pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, 2, $outputlangs->transnoentities("BankAccount"), 0, 'L');
443
444
445 $pdf->line($this->posxinvoiceamount - 1, $this->tab_top, $this->posxinvoiceamount - 1, $this->tab_top + $this->tab_height + 10);
446 $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 2);
447 $pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, 2, $outputlangs->transnoentities("AmountInvoice"), 0, 'R');
448
449 $pdf->line($this->posxpaymentamount - 1, $this->tab_top, $this->posxpaymentamount - 1, $this->tab_top + $this->tab_height + 10);
450 $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 2);
451 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount - 1, 2, $outputlangs->transnoentities("AmountPayment"), 0, 'R');
452
453 $pdf->line($this->marge_gauche, $this->tab_top + 10, $this->page_largeur - $this->marge_droite, $this->tab_top + 10);
454
455 $pdf->Rect($this->marge_gauche, $this->tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $this->tab_height + 10);
456
457 return 0;
458 }
459
460
461 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
471 public function Body(&$pdf, $page, $lines, $outputlangs)
472 {
473 // phpcs:enable
474 global $langs, $conf;
475 $default_font_size = pdf_getPDFFontSize($outputlangs);
476
477 $pdf->SetFont('', '', $default_font_size - 1);
478 $oldprowid = 0;
479 $total_page = 0;
480 $total = 0;
481 $pdf->SetFillColor(220, 220, 220);
482 $yp = 0;
483 $numlines = count($lines);
484 if (($this->doc_type == 'client' && getDolGlobalString('PAYMENTS_REPORT_GROUP_BY_MOD')) || ($this->doc_type == 'fourn' && getDolGlobalString('PAYMENTS_FOURN_REPORT_GROUP_BY_MOD'))) {
485 $mod = $lines[0][2];
486 $total_mod = 0;
487 }
488 for ($j = 0; $j < $numlines; $j++) {
489 $i = $j;
490 if ($yp > $this->tab_height - 5) {
491 $page++;
492 $pdf->AddPage();
493 $this->_pagehead($pdf, $page, 0, $outputlangs);
494 $pdf->SetFont('', '', $default_font_size - 1);
495 $yp = 0;
496 }
497 if ($oldprowid != $lines[$j][7]) {
498 if ($yp > $this->tab_height - 15) {
499 $pdf->SetFillColor(255, 255, 255);
500 $pdf->Rect($this->marge_gauche + 1, $this->tab_top + 10 + $yp, $this->posxpaymentamount - $this->marge_droite - 3, $this->line_height, 'F', array(), array());
501 $pdf->line($this->marge_gauche, $this->tab_top + 10 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 10 + $yp, array('dash' => 1));
502 $pdf->line($this->marge_gauche, $this->tab_top + 15 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 15 + $yp);
503 $pdf->SetFont('', 'B', $default_font_size - 1);
504 $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
505 $pdf->MultiCell($this->posxpaymentamount - 2 - $this->marge_droite, $this->line_height, $langs->transnoentities('SubTotal')." : ", 0, 'R', 1);
506 $pdf->SetXY($this->posxpaymentamount - 1, $this->tab_top + 10 + $yp);
507 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount + 1, $this->line_height, price($total_page), 0, 'R', 1);
508 $pdf->SetFont('', '', $default_font_size - 1);
509 $pdf->SetFillColor(220, 220, 220);
510 $page++;
511 $pdf->AddPage();
512 $this->_pagehead($pdf, $page, 0, $outputlangs);
513 $pdf->SetFont('', '', $default_font_size - 1);
514 $yp = 0;
515 $total += $total_page;
516 $total_page = 0;
517 }
518
519 $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
520 $pdf->MultiCell($this->posxpaymenttype - $this->posxdate + 1, $this->line_height, $lines[$j][1], 0, 'L', 1);
521
522 $pdf->SetXY($this->posxpaymenttype, $this->tab_top + 10 + $yp);
523 $pdf->MultiCell($this->posxinvoiceamount - $this->posxpaymenttype, $this->line_height, $lines[$j][2].' '.$lines[$j][3], 0, 'L', 1);
524
525 $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
526 $pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount, $this->line_height, '', 0, 'R', 1);
527
528 $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
529 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][4], 0, 'R', 1);
530 $yp += 5;
531 $total_page += $lines[$j][9];
532 if (($this->doc_type == 'client' && getDolGlobalString('PAYMENTS_REPORT_GROUP_BY_MOD')) || ($this->doc_type == 'fourn' && getDolGlobalString('PAYMENTS_FOURN_REPORT_GROUP_BY_MOD'))) {
533 $total_mod += $lines[$j][9];
534 }
535 }
536
537 // Invoice number
538 $pdf->SetXY($this->posxinvoice, $this->tab_top + 10 + $yp);
539 $pdf->MultiCell($this->posxinvoice - $this->posxbankaccount, $this->line_height, $lines[$j][0], 0, 'L', 0);
540
541 // BankAccount
542 $pdf->SetXY($this->posxbankaccount, $this->tab_top + 10 + $yp);
543 $pdf->MultiCell($this->posxbankaccount - $this->posxdate, $this->line_height, $lines[$j][8], 0, 'L', 0);
544
545 // Invoice amount
546 $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
547 $pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, $this->line_height, $lines[$j][5], 0, 'R', 0);
548
549 // Payment amount
550 $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
551 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][6], 0, 'R', 0);
552 $yp += 5;
553
554 if ($oldprowid != $lines[$j][7]) {
555 $oldprowid = $lines[$j][7];
556 }
557
558 // Add line to add total by payment mode if mode reglement for nex line change
559 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])) {
560 $pdf->SetFillColor(245, 245, 245);
561 $pdf->Rect($this->marge_gauche + 1, $this->tab_top + 10 + $yp, $this->posxpaymentamount - $this->marge_droite - 3, $this->line_height, 'F', array(), array());
562 $pdf->line($this->marge_gauche, $this->tab_top + 10 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 10 + $yp, array('dash' => 1));
563 $pdf->line($this->marge_gauche, $this->tab_top + 15 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 15 + $yp);
564 $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
565 $pdf->SetFont('', 'I', $default_font_size - 1);
566 $pdf->MultiCell($this->posxpaymentamount - 2 - $this->marge_droite, $this->line_height, $langs->transnoentities('Total').' '.$mod." : ", 0, 'R', 1);
567 $pdf->SetXY($this->posxpaymentamount - 1, $this->tab_top + 10 + $yp);
568 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount + 1, $this->line_height, price($total_mod), 0, 'R', 1);
569 $pdf->SetFont('', '', $default_font_size - 1);
570 $mod = $lines[$j + 1][2];
571 $total_mod = 0;
572 $yp += 5;
573 if ($yp > $this->tab_height - 5) {
574 $page++;
575 $pdf->AddPage();
576 $this->_pagehead($pdf, $page, 0, $outputlangs);
577 $pdf->SetFont('', '', $default_font_size - 1);
578 $yp = 0;
579 }
580 $pdf->SetFillColor(220, 220, 220);
581 }
582 }
583 $total += $total_page;
584 $pdf->SetFillColor(255, 255, 255);
585 $pdf->Rect($this->marge_gauche + 1, $this->tab_top + 10 + $yp, $this->posxpaymentamount - $this->marge_droite - 3, $this->line_height, 'F', array(), array());
586 $pdf->line($this->marge_gauche, $this->tab_top + 10 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 10 + $yp, array('dash' => 1));
587 $pdf->line($this->marge_gauche, $this->tab_top + 15 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 15 + $yp);
588 $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
589 $pdf->SetFont('', 'B');
590 $pdf->MultiCell($this->posxpaymentamount - 2 - $this->marge_droite, $this->line_height, $langs->transnoentities('Total')." : ", 0, 'R', 1);
591 $pdf->SetXY($this->posxpaymentamount - 1, $this->tab_top + 10 + $yp);
592 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount + 1, $this->line_height, price($total), 0, 'R', 1);
593 $pdf->SetFillColor(220, 220, 220);
594 }
595}
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:596
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition date.lib.php:615
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 a 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_getFormat($outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition pdf.lib.php:86
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition pdf.lib.php:288
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition pdf.lib.php:265
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