dolibarr  13.0.2
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 = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
58  $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
59  $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
60  $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->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  {
76  $this->line_per_page = 35;
77  $this->posxpaymenttype -= 10;
78  $this->posxinvoice -= 0;
79  $this->posxinvoiceamount -= 10;
80  $this->posxpaymentamount -= 20;
81  }
82  // which type of document will be generated: clients (client) or providers (fourn) invoices
83  $this->doc_type = "client";
84  }
85 
86 
87  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
97  public function write_file($_dir, $month, $year, $outputlangs)
98  {
99  // phpcs:enable
100  include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
101 
102  global $conf, $hookmanager, $langs, $user;
103 
104  $socid = 0;
105  if ($user->socid) $socid = $user->socid;
106 
107  if (!is_object($outputlangs)) $outputlangs = $langs;
108  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
109  if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output = 'ISO-8859-1';
110 
111  $this->month = $month;
112  $this->year = $year;
113  $dir = $_dir.'/'.$year;
114 
115  if (!is_dir($dir))
116  {
117  $result = dol_mkdir($dir);
118  if ($result < 0)
119  {
120  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
121  return -1;
122  }
123  }
124 
125  $month = sprintf("%02d", $month);
126  $year = sprintf("%04d", $year);
127 
128  $file = $dir."/payments-".$year."-".$month.".pdf";
129  switch ($this->doc_type) {
130  case "client":
131  $file = $dir."/payments-".$year."-".$month.".pdf";
132  break;
133  case "fourn":
134  $file = $dir."/supplier_payments-".$year."-".$month.".pdf";
135  break;
136  }
137 
138 
139  // Add pdfgeneration hook
140  if (!is_object($hookmanager))
141  {
142  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
143  $hookmanager = new HookManager($this->db);
144  }
145  $hookmanager->initHooks(array('pdfgeneration'));
146  $parameters = array('file'=>$file, 'outputlangs'=>$outputlangs);
147  global $action;
148  $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
149 
150  $pdf = pdf_getInstance($this->format);
151  $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
152 
153  if (class_exists('TCPDF'))
154  {
155  $pdf->setPrintHeader(false);
156  $pdf->setPrintFooter(false);
157  }
158  $pdf->SetFont(pdf_getPDFFont($outputlangs));
159 
160  $num = 0;
161  $lines = array();
162 
163  // count number of lines of payment
164  $sql = "SELECT p.rowid as prowid";
165  switch ($this->doc_type) {
166  case "client":
167  $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p";
168  break;
169  case "fourn":
170  $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p";
171  break;
172  }
173  $sql .= " WHERE p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."'";
174  $sql .= " AND p.entity = ".$conf->entity;
175  $result = $this->db->query($sql);
176  if ($result)
177  {
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 (!empty($conf->banque->enabled))
189  $sql .= ", ba.ref as bankaccount";
190  $sql .= ", p.rowid as prowid";
191  $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
192  $sql .= ", ".MAIN_DB_PREFIX."facture as f,";
193  $sql .= " ".MAIN_DB_PREFIX."paiement_facture as pf,";
194  if (!empty($conf->banque->enabled))
195  $sql .= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
196  $sql .= " ".MAIN_DB_PREFIX."societe as s";
197  if (!$user->rights->societe->client->voir && !$socid)
198  {
199  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
200  }
201  $sql .= " WHERE f.fk_soc = s.rowid AND pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid";
202  if (!empty($conf->banque->enabled))
203  $sql .= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
204  $sql .= " AND f.entity IN (".getEntity('invoice').")";
205  $sql .= " AND p.datep BETWEEN '".$this->db->idate(dol_get_first_day($year, $month))."' AND '".$this->db->idate(dol_get_last_day($year, $month))."'";
206  if (!$user->rights->societe->client->voir && !$socid)
207  {
208  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
209  }
210  if (!empty($socid)) $sql .= " AND s.rowid = ".$socid;
211  // If global param PAYMENTS_REPORT_GROUP_BY_MOD is set, payement are ordered by paiement_code
212  if (!empty($conf->global->PAYMENTS_REPORT_GROUP_BY_MOD))
213  $sql .= " ORDER BY paiement_code ASC, p.datep ASC, pf.fk_paiement ASC";
214  else $sql .= " ORDER BY p.datep ASC, pf.fk_paiement ASC";
215  break;
216  case "fourn":
217  $sql = "SELECT p.datep as dp, f.ref as ref";
218  $sql .= ", c.code as paiement_code, p.num_paiement as num_payment";
219  $sql .= ", p.amount as paiement_amount, f.total_ttc as facture_amount";
220  $sql .= ", pf.amount as pf_amount";
221  if (!empty($conf->banque->enabled))
222  $sql .= ", ba.ref as bankaccount";
223  $sql .= ", p.rowid as prowid";
224  $sql .= " FROM ".MAIN_DB_PREFIX."paiementfourn as p LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_paiement = c.id";
225  $sql .= ", ".MAIN_DB_PREFIX."facture_fourn as f,";
226  $sql .= " ".MAIN_DB_PREFIX."paiementfourn_facturefourn as pf,";
227  if (!empty($conf->banque->enabled))
228  $sql .= " ".MAIN_DB_PREFIX."bank as b, ".MAIN_DB_PREFIX."bank_account as ba,";
229  $sql .= " ".MAIN_DB_PREFIX."societe as s";
230  if (!$user->rights->societe->client->voir && !$socid)
231  {
232  $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
233  }
234  $sql .= " WHERE f.fk_soc = s.rowid AND pf.fk_facturefourn = f.rowid AND pf.fk_paiementfourn = p.rowid";
235  if (!empty($conf->banque->enabled))
236  $sql .= " AND p.fk_bank = b.rowid AND b.fk_account = ba.rowid ";
237  $sql .= " AND f.entity = ".$conf->entity;
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->rights->societe->client->voir && !$socid)
240  {
241  $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
242  }
243  if (!empty($socid)) $sql .= " AND s.rowid = ".$socid;
244  // If global param PAYMENTS_FOURN_REPORT_GROUP_BY_MOD is set, payement fourn are ordered by paiement_code
245  if (!empty($conf->global->PAYMENTS_FOURN_REPORT_GROUP_BY_MOD))
246  $sql .= " ORDER BY paiement_code ASC, p.datep ASC, pf.fk_paiementfourn ASC";
247  else $sql .= " ORDER BY p.datep ASC, pf.fk_paiementfourn ASC";
248  break;
249  }
250 
251  dol_syslog(get_class($this)."::write_file", LOG_DEBUG);
252  $result = $this->db->query($sql);
253  if ($result)
254  {
255  $num = $this->db->num_rows($result);
256  $i = 0;
257 
258  while ($i < $num)
259  {
260  $objp = $this->db->fetch_object($result);
261 
262  $lines[$i][0] = $objp->ref;
263  $lines[$i][1] = dol_print_date($this->db->jdate($objp->dp), "day", false, $outputlangs, true);
264  $lines[$i][2] = $langs->transnoentities("PaymentTypeShort".$objp->paiement_code);
265  $lines[$i][3] = $objp->num_payment;
266  $lines[$i][4] = price($objp->paiement_amount);
267  $lines[$i][5] = price($objp->facture_amount);
268  $lines[$i][6] = price($objp->pf_amount);
269  $lines[$i][7] = $objp->prowid;
270  $lines[$i][8] = $objp->bankaccount;
271  $lines[$i][9] = $objp->paiement_amount;
272  $i++;
273  }
274  } else {
275  dol_print_error($this->db);
276  }
277 
278  $pages = intval(($num + $numpaiement) / $this->line_per_page);
279 
280  if ((($num + $numpaiement) % $this->line_per_page) > 0)
281  {
282  $pages++;
283  }
284 
285  if ($pages == 0)
286  {
287  // force to build at least one page if report has no line
288  $pages = 1;
289  }
290 
291  $pdf->Open();
292  $pagenb = 0;
293  $pdf->SetDrawColor(128, 128, 128);
294 
295  $pdf->SetTitle($outputlangs->transnoentities("Payments"));
296  $pdf->SetSubject($outputlangs->transnoentities("Payments"));
297  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
298  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
299  //$pdf->SetKeyWords();
300  if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
301 
302  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
303  $pdf->SetAutoPageBreak(1, 0);
304 
305  // New page
306  $pdf->AddPage();
307  $pagenb++;
308  $this->_pagehead($pdf, $pagenb, 1, $outputlangs);
309  $pdf->SetFont('', '', 9);
310  $pdf->MultiCell(0, 3, ''); // Set interline to 3
311  $pdf->SetTextColor(0, 0, 0);
312 
313 
314  $this->Body($pdf, 1, $lines, $outputlangs);
315 
316  if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages();
317 
318  $pdf->Close();
319 
320  $pdf->Output($file, 'F');
321 
322  // Add pdfgeneration hook
323  if (!is_object($hookmanager))
324  {
325  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
326  $hookmanager = new HookManager($this->db);
327  }
328  $hookmanager->initHooks(array('pdfgeneration'));
329  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
330  global $action;
331  $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
332  if ($reshook < 0)
333  {
334  $this->error = $hookmanager->error;
335  $this->errors = $hookmanager->errors;
336  }
337 
338  if (!empty($conf->global->MAIN_UMASK))
339  @chmod($file, octdec($conf->global->MAIN_UMASK));
340 
341  $this->result = array('fullpath'=>$file);
342 
343  return 1;
344  }
345 
346  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
356  protected function _pagehead(&$pdf, $page, $showaddress, $outputlangs)
357  {
358  // phpcs:enable
359  global $langs, $conf;
360 
361  // Do not add the BACKGROUND as this is a report
362  //pdf_pagehead($pdf,$outputlangs,$this->page_hauteur);
363 
364  $default_font_size = pdf_getPDFFontSize($outputlangs);
365 
366  $title = $conf->global->MAIN_INFO_SOCIETE_NOM;
367  switch ($this->doc_type) {
368  case "client":
369  $title .= ' - '.$outputlangs->transnoentities("ListOfCustomerPayments");
370  break;
371  case "fourn":
372  $title .= ' - '.$outputlangs->transnoentities("ListOfSupplierPayments");
373  break;
374  }
375  $title .= ' - '.dol_print_date(dol_mktime(0, 0, 0, $this->month, 1, $this->year), "%B %Y", false, $outputlangs, true);
376  $pdf->SetFont('', 'B', $default_font_size + 1);
377  $pdf->SetXY($this->marge_gauche, 10);
378  $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->marge_gauche, 2, $title, 0, 'C');
379 
380  $pdf->SetFont('', '', $default_font_size);
381 
382  $pdf->SetXY($this->posxdate, 16);
383  $pdf->MultiCell(80, 2, $outputlangs->transnoentities("DateBuild")." : ".dol_print_date(time(), "day", false, $outputlangs, true), 0, 'L');
384 
385  $pdf->SetXY($this->posxdate + 100, 16);
386  $pdf->MultiCell(80, 2, $outputlangs->transnoentities("Page")." : ".$page, 0, 'R');
387 
388 
389  // Title line
390  $pdf->SetXY($this->posxdate, $this->tab_top + 2);
391  $pdf->MultiCell($this->posxpaymenttype - $this->posxdate, 2, 'Date');
392 
393  $pdf->line($this->posxpaymenttype - 1, $this->tab_top, $this->posxpaymenttype - 1, $this->tab_top + $this->tab_height + 10);
394  $pdf->SetXY($this->posxpaymenttype, $this->tab_top + 2);
395  $pdf->MultiCell($this->posxinvoice - $this->posxpaymenttype, 2, $outputlangs->transnoentities("PaymentMode"), 0, 'L');
396 
397  $pdf->line($this->posxinvoice - 1, $this->tab_top, $this->posxinvoice - 1, $this->tab_top + $this->tab_height + 10);
398  $pdf->SetXY($this->posxinvoice, $this->tab_top + 2);
399  $pdf->MultiCell($this->posxbankaccount - $this->posxinvoice, 2, $outputlangs->transnoentities("Invoice"), 0, 'L');
400 
401  $pdf->line($this->posxbankaccount - 1, $this->tab_top, $this->posxbankaccount - 1, $this->tab_top + $this->tab_height + 10);
402  $pdf->SetXY($this->posxbankaccount, $this->tab_top + 2);
403  $pdf->MultiCell($this->posxinvoiceamount - $this->posxbankaccount, 2, $outputlangs->transnoentities("Account"), 0, 'L');
404 
405 
406  $pdf->line($this->posxinvoiceamount - 1, $this->tab_top, $this->posxinvoiceamount - 1, $this->tab_top + $this->tab_height + 10);
407  $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 2);
408  $pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, 2, $outputlangs->transnoentities("AmountInvoice"), 0, 'R');
409 
410  $pdf->line($this->posxpaymentamount - 1, $this->tab_top, $this->posxpaymentamount - 1, $this->tab_top + $this->tab_height + 10);
411  $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 2);
412  $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount - 1, 2, $outputlangs->transnoentities("AmountPayment"), 0, 'R');
413 
414  $pdf->line($this->marge_gauche, $this->tab_top + 10, $this->page_largeur - $this->marge_droite, $this->tab_top + 10);
415 
416  $pdf->Rect($this->marge_gauche, $this->tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $this->tab_height + 10);
417  }
418 
419 
420  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
430  public function Body(&$pdf, $page, $lines, $outputlangs)
431  {
432  // phpcs:enable
433  global $langs, $conf;
434  $default_font_size = pdf_getPDFFontSize($outputlangs);
435 
436  $pdf->SetFont('', '', $default_font_size - 1);
437  $oldprowid = 0;
438  $total_page = 0;
439  $total = 0;
440  $pdf->SetFillColor(220, 220, 220);
441  $yp = 0;
442  $numlines = count($lines);
443  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)))
444  {
445  $mod = $lines[0][2];
446  $total_mod = 0;
447  }
448  for ($j = 0; $j < $numlines; $j++)
449  {
450  $i = $j;
451  if ($yp > $this->tab_height - 5)
452  {
453  $page++;
454  $pdf->AddPage();
455  $this->_pagehead($pdf, $page, 0, $outputlangs);
456  $pdf->SetFont('', '', $default_font_size - 1);
457  $yp = 0;
458  }
459  if ($oldprowid <> $lines[$j][7])
460  {
461  if ($yp > $this->tab_height - 15)
462  {
463  $pdf->SetFillColor(255, 255, 255);
464  $pdf->Rect($this->marge_gauche + 1, $this->tab_top + 10 + $yp, $this->posxpaymentamount - $this->marge_droite - 3, $this->line_height, 'F', array(), array());
465  $pdf->line($this->marge_gauche, $this->tab_top + 10 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 10 + $yp, array('dash'=>1));
466  $pdf->line($this->marge_gauche, $this->tab_top + 15 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 15 + $yp);
467  $pdf->SetFont('', 'B', $default_font_size - 1);
468  $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
469  $pdf->MultiCell($this->posxpaymentamount - 2 - $this->marge_droite, $this->line_height, $langs->transnoentities('SubTotal')." : ", 0, 'R', 1);
470  $pdf->SetXY($this->posxpaymentamount - 1, $this->tab_top + 10 + $yp);
471  $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount + 1, $this->line_height, price($total_page), 0, 'R', 1);
472  $pdf->SetFont('', '', $default_font_size - 1);
473  $pdf->SetFillColor(220, 220, 220);
474  $page++;
475  $pdf->AddPage();
476  $this->_pagehead($pdf, $page, 0, $outputlangs);
477  $pdf->SetFont('', '', $default_font_size - 1);
478  $yp = 0;
479  $total += $total_page;
480  $total_page = 0;
481  }
482 
483  $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
484  $pdf->MultiCell($this->posxpaymenttype - $this->posxdate + 1, $this->line_height, $lines[$j][1], 0, 'L', 1);
485 
486  $pdf->SetXY($this->posxpaymenttype, $this->tab_top + 10 + $yp);
487  $pdf->MultiCell($this->posxinvoiceamount - $this->posxpaymenttype, $this->line_height, $lines[$j][2].' '.$lines[$j][3], 0, 'L', 1);
488 
489  $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
490  $pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount, $this->line_height, '', 0, 'R', 1);
491 
492  $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
493  $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][4], 0, 'R', 1);
494  $yp = $yp + 5;
495  $total_page += $lines[$j][9];
496  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))) $total_mod += $lines[$j][9];
497  }
498 
499  // Invoice number
500  $pdf->SetXY($this->posxinvoice, $this->tab_top + 10 + $yp);
501  $pdf->MultiCell($this->posxinvoice - $this->posxbankaccount, $this->line_height, $lines[$j][0], 0, 'L', 0);
502 
503  // BankAccount
504  $pdf->SetXY($this->posxbankaccount, $this->tab_top + 10 + $yp);
505  $pdf->MultiCell($this->posxbankaccount - $this->posxdate, $this->line_height, $lines[$j][8], 0, 'L', 0);
506 
507  // Invoice amount
508  $pdf->SetXY($this->posxinvoiceamount, $this->tab_top + 10 + $yp);
509  $pdf->MultiCell($this->posxpaymentamount - $this->posxinvoiceamount - 1, $this->line_height, $lines[$j][5], 0, 'R', 0);
510 
511  // Payment amount
512  $pdf->SetXY($this->posxpaymentamount, $this->tab_top + 10 + $yp);
513  $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount, $this->line_height, $lines[$j][6], 0, 'R', 0);
514  $yp = $yp + 5;
515 
516  if ($oldprowid <> $lines[$j][7])
517  {
518  $oldprowid = $lines[$j][7];
519  }
520 
521  // Add line to add total by payment mode if mode reglement for nex line change
522  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]))
523  {
524  $pdf->SetFillColor(245, 245, 245);
525  $pdf->Rect($this->marge_gauche + 1, $this->tab_top + 10 + $yp, $this->posxpaymentamount - $this->marge_droite - 3, $this->line_height, 'F', array(), array());
526  $pdf->line($this->marge_gauche, $this->tab_top + 10 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 10 + $yp, array('dash'=>1));
527  $pdf->line($this->marge_gauche, $this->tab_top + 15 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 15 + $yp);
528  $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
529  $pdf->SetFont('', 'I', $default_font_size - 1);
530  $pdf->MultiCell($this->posxpaymentamount - 2 - $this->marge_droite, $this->line_height, $langs->transnoentities('Total').' '.$mod." : ", 0, 'R', 1);
531  $pdf->SetXY($this->posxpaymentamount - 1, $this->tab_top + 10 + $yp);
532  $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount + 1, $this->line_height, price($total_mod), 0, 'R', 1);
533  $pdf->SetFont('', '', $default_font_size - 1);
534  $mod = $lines[$j + 1][2];
535  $total_mod = 0;
536  $yp = $yp + 5;
537  if ($yp > $this->tab_height - 5)
538  {
539  $page++;
540  $pdf->AddPage();
541  $this->_pagehead($pdf, $page, 0, $outputlangs);
542  $pdf->SetFont('', '', $default_font_size - 1);
543  $yp = 0;
544  }
545  $pdf->SetFillColor(220, 220, 220);
546  }
547  }
548  $total += $total_page;
549  $pdf->SetFillColor(255, 255, 255);
550  $pdf->Rect($this->marge_gauche + 1, $this->tab_top + 10 + $yp, $this->posxpaymentamount - $this->marge_droite - 3, $this->line_height, 'F', array(), array());
551  $pdf->line($this->marge_gauche, $this->tab_top + 10 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 10 + $yp, array('dash'=>1));
552  $pdf->line($this->marge_gauche, $this->tab_top + 15 + $yp, $this->page_largeur - $this->marge_droite, $this->tab_top + 15 + $yp);
553  $pdf->SetXY($this->posxdate - 1, $this->tab_top + 10 + $yp);
554  $pdf->SetFont('', 'B');
555  $pdf->MultiCell($this->posxpaymentamount - 2 - $this->marge_droite, $this->line_height, $langs->transnoentities('Total')." : ", 0, 'R', 1);
556  $pdf->SetXY($this->posxpaymentamount - 1, $this->tab_top + 10 + $yp);
557  $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxpaymentamount + 1, $this->line_height, price($total), 0, 'R', 1);
558  $pdf->SetFillColor(220, 220, 220);
559  }
560 }
pdf_getFormat(Translate $outputlangs=null, $mode= 'setup')
Return array with format properties of default PDF format.
Definition: pdf.lib.php:45
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...
_pagehead(&$pdf, $page, $showaddress, $outputlangs)
Show top header of page.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Definition: replenish.php:750
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition: pdf.lib.php:245
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:481
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:222
$conf db
API class for accounts.
Definition: inc.php:54
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...
Class to manage hooks.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
write_file($_dir, $month, $year, $outputlangs)
Fonction generant la rapport sur le disque.
Classe permettant de generer les rapports de paiement.
pdf_getInstance($format= '', $metric= 'mm', $pagetype= 'P')
Return a PDF instance object.
Definition: pdf.lib.php:88
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:498
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Body(&$pdf, $page, $lines, $outputlangs)
Output body.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
__construct($db)
Constructor.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:105
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)