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