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