dolibarr 19.0.3
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("banque")) {
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("banque")) {
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') && !$socid) {
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("banque")) {
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') && !$socid) {
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("banque")) {
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("banque")) {
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') && !$socid) {
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("banque")) {
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') && !$socid) {
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 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
341 $pdf->SetAutoPageBreak(1, 0);
342
343 // New page
344 $pdf->AddPage();
345 $pagenb++;
346 $this->_pagehead($pdf, $pagenb, 1, $outputlangs);
347 $pdf->SetFont('', '', 9);
348 $pdf->MultiCell(0, 3, ''); // Set interline to 3
349 $pdf->SetTextColor(0, 0, 0);
350
351
352 $this->Body($pdf, 1, $lines, $outputlangs);
353
354 if (method_exists($pdf, 'AliasNbPages')) {
355 $pdf->AliasNbPages();
356 }
357
358 $pdf->Close();
359
360 $pdf->Output($file, 'F');
361
362 // Add pdfgeneration hook
363 if (!is_object($hookmanager)) {
364 include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
365 $hookmanager = new HookManager($this->db);
366 }
367 $hookmanager->initHooks(array('pdfgeneration'));
368 $parameters = array('file'=>$file, 'object'=>$this, 'outputlangs'=>$outputlangs);
369 global $action;
370 $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
371 if ($reshook < 0) {
372 $this->error = $hookmanager->error;
373 $this->errors = $hookmanager->errors;
374 }
375
376 dolChmod($file);
377
378 $this->result = array('fullpath'=>$file);
379
380 return 1;
381 }
382
383 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
393 protected function _pagehead(&$pdf, $page, $showaddress, $outputlangs)
394 {
395 // phpcs:enable
396 global $langs, $conf;
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 = $conf->global->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("Account"), 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
456
457 // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
467 public function Body(&$pdf, $page, $lines, $outputlangs)
468 {
469 // phpcs:enable
470 global $langs, $conf;
471 $default_font_size = pdf_getPDFFontSize($outputlangs);
472
473 $pdf->SetFont('', '', $default_font_size - 1);
474 $oldprowid = 0;
475 $total_page = 0;
476 $total = 0;
477 $pdf->SetFillColor(220, 220, 220);
478 $yp = 0;
479 $numlines = count($lines);
480 if (($this->doc_type == 'client' && getDolGlobalString('PAYMENTS_REPORT_GROUP_BY_MOD')) || ($this->doc_type == 'fourn' && getDolGlobalString('PAYMENTS_FOURN_REPORT_GROUP_BY_MOD'))) {
481 $mod = $lines[0][2];
482 $total_mod = 0;
483 }
484 for ($j = 0; $j < $numlines; $j++) {
485 $i = $j;
486 if ($yp > $this->tab_height - 5) {
487 $page++;
488 $pdf->AddPage();
489 $this->_pagehead($pdf, $page, 0, $outputlangs);
490 $pdf->SetFont('', '', $default_font_size - 1);
491 $yp = 0;
492 }
493 if ($oldprowid != $lines[$j][7]) {
494 if ($yp > $this->tab_height - 15) {
495 $pdf->SetFillColor(255, 255, 255);
496 $pdf->Rect($this->marge_gauche + 1, $this->tab_top + 10 + $yp, $this->posxpaymentamount - $this->marge_droite - 3, $this->line_height, 'F', array(), array());
497 $pdf->line($this->marge_gauche, $this->tab_top + 10 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 10 + $yp, array('dash'=>1));
498 $pdf->line($this->marge_gauche, $this->tab_top + 15 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 15 + $yp);
499 $pdf->SetFont('', 'B', $default_font_size - 1);
500 $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
501 $pdf->MultiCell($this->posxpaymentamount - 2 - $this->marge_droite, $this->line_height, $langs->transnoentities('SubTotal')." : ", 0, 'R', 1);
502 $pdf->SetXY($this->posxpaymentamount - 1, $this->tab_top + 10 + $yp);
503 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount + 1, $this->line_height, price($total_page), 0, 'R', 1);
504 $pdf->SetFont('', '', $default_font_size - 1);
505 $pdf->SetFillColor(220, 220, 220);
506 $page++;
507 $pdf->AddPage();
508 $this->_pagehead($pdf, $page, 0, $outputlangs);
509 $pdf->SetFont('', '', $default_font_size - 1);
510 $yp = 0;
511 $total += $total_page;
512 $total_page = 0;
513 }
514
515 $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
516 $pdf->MultiCell($this->posxpaymenttype - $this->posxdate + 1, $this->line_height, $lines[$j][1], 0, 'L', 1);
517
518 $pdf->SetXY($this->posxpaymenttype, $this->tab_top + 10 + $yp);
519 $pdf->MultiCell($this->posxinvoiceamount - $this->posxpaymenttype, $this->line_height, $lines[$j][2].' '.$lines[$j][3], 0, 'L', 1);
520
521 $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
522 $pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount, $this->line_height, '', 0, 'R', 1);
523
524 $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
525 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][4], 0, 'R', 1);
526 $yp = $yp + 5;
527 $total_page += $lines[$j][9];
528 if (($this->doc_type == 'client' && getDolGlobalString('PAYMENTS_REPORT_GROUP_BY_MOD')) || ($this->doc_type == 'fourn' && getDolGlobalString('PAYMENTS_FOURN_REPORT_GROUP_BY_MOD'))) {
529 $total_mod += $lines[$j][9];
530 }
531 }
532
533 // Invoice number
534 $pdf->SetXY($this->posxinvoice, $this->tab_top + 10 + $yp);
535 $pdf->MultiCell($this->posxinvoice - $this->posxbankaccount, $this->line_height, $lines[$j][0], 0, 'L', 0);
536
537 // BankAccount
538 $pdf->SetXY($this->posxbankaccount, $this->tab_top + 10 + $yp);
539 $pdf->MultiCell($this->posxbankaccount - $this->posxdate, $this->line_height, $lines[$j][8], 0, 'L', 0);
540
541 // Invoice amount
542 $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
543 $pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, $this->line_height, $lines[$j][5], 0, 'R', 0);
544
545 // Payment amount
546 $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
547 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][6], 0, 'R', 0);
548 $yp = $yp + 5;
549
550 if ($oldprowid != $lines[$j][7]) {
551 $oldprowid = $lines[$j][7];
552 }
553
554 // Add line to add total by payment mode if mode reglement for nex line change
555 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])) {
556 $pdf->SetFillColor(245, 245, 245);
557 $pdf->Rect($this->marge_gauche + 1, $this->tab_top + 10 + $yp, $this->posxpaymentamount - $this->marge_droite - 3, $this->line_height, 'F', array(), array());
558 $pdf->line($this->marge_gauche, $this->tab_top + 10 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 10 + $yp, array('dash'=>1));
559 $pdf->line($this->marge_gauche, $this->tab_top + 15 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 15 + $yp);
560 $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
561 $pdf->SetFont('', 'I', $default_font_size - 1);
562 $pdf->MultiCell($this->posxpaymentamount - 2 - $this->marge_droite, $this->line_height, $langs->transnoentities('Total').' '.$mod." : ", 0, 'R', 1);
563 $pdf->SetXY($this->posxpaymentamount - 1, $this->tab_top + 10 + $yp);
564 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount + 1, $this->line_height, price($total_mod), 0, 'R', 1);
565 $pdf->SetFont('', '', $default_font_size - 1);
566 $mod = $lines[$j + 1][2];
567 $total_mod = 0;
568 $yp = $yp + 5;
569 if ($yp > $this->tab_height - 5) {
570 $page++;
571 $pdf->AddPage();
572 $this->_pagehead($pdf, $page, 0, $outputlangs);
573 $pdf->SetFont('', '', $default_font_size - 1);
574 $yp = 0;
575 }
576 $pdf->SetFillColor(220, 220, 220);
577 }
578 }
579 $total += $total_page;
580 $pdf->SetFillColor(255, 255, 255);
581 $pdf->Rect($this->marge_gauche + 1, $this->tab_top + 10 + $yp, $this->posxpaymentamount - $this->marge_droite - 3, $this->line_height, 'F', array(), array());
582 $pdf->line($this->marge_gauche, $this->tab_top + 10 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 10 + $yp, array('dash'=>1));
583 $pdf->line($this->marge_gauche, $this->tab_top + 15 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 15 + $yp);
584 $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
585 $pdf->SetFont('', 'B');
586 $pdf->MultiCell($this->posxpaymentamount - 2 - $this->marge_droite, $this->line_height, $langs->transnoentities('Total')." : ", 0, 'R', 1);
587 $pdf->SetXY($this->posxpaymentamount - 1, $this->tab_top + 10 + $yp);
588 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount + 1, $this->line_height, price($total), 0, 'R', 1);
589 $pdf->SetFillColor(220, 220, 220);
590 }
591}
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