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