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