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