dolibarr  16.0.5
pdf_standard.modules.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017 Laurent Destailleur <eldy@stocks.sourceforge.net>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program. If not, see <https://www.gnu.org/licenses/>.
16  * or see https://www.gnu.org/
17  */
18 
25 require_once DOL_DOCUMENT_ROOT.'/core/modules/stock/modules_movement.php';
26 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/entrepot.class.php';
27 require_once DOL_DOCUMENT_ROOT.'/product/stock/class/mouvementstock.class.php';
28 require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php';
29 require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
30 require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
31 require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
32 require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php';
33 
34 
38 class pdf_standard extends ModelePDFMovement
39 {
43  public $db;
44 
48  public $name;
49 
53  public $description;
54 
58  public $update_main_doc_field;
59 
63  public $type;
64 
69  public $phpmin = array(5, 6);
70 
75  public $version = 'dolibarr';
76 
81  public $emetteur;
82 
83 
84  public $wref;
85  public $posxidref;
86  public $posxdatemouv;
87  public $posxdesc;
88  public $posxlabel;
89  public $posxtva;
90  public $posxqty;
91  public $posxup;
92  public $posxunit;
93  public $posxdiscount;
94  public $postotalht;
95 
96 
102  public function __construct($db)
103  {
104  global $conf, $langs, $mysoc;
105 
106  // Load traductions files required by page
107  $langs->loadLangs(array("main", "companies"));
108 
109  $this->db = $db;
110  $this->name = "stdmouvement";
111  $this->description = $langs->trans("DocumentModelStandardPDF");
112 
113  // Dimension page
114  $this->type = 'pdf';
115  $formatarray = pdf_getFormat();
116  $this->page_largeur = $formatarray['width'];
117  $this->page_hauteur = $formatarray['height'];
118  $this->format = array($this->page_largeur, $this->page_hauteur);
119  $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
120  $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
121  $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
122  $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
123 
124  $this->option_logo = 1; // Display logo
125  $this->option_codestockservice = 0; // Display stock-service code
126  $this->option_multilang = 1; // Available in several languages
127  $this->option_freetext = 0; // Support add of a personalised text
128 
129  // Get source company
130  $this->emetteur = $mysoc;
131  if (empty($this->emetteur->country_code)) {
132  $this->emetteur->country_code = substr($langs->defaultlang, -2); // By default if not defined
133  }
134 
135  // Define position of columns
136  $this->wref = 15;
137  $this->posxidref = $this->marge_gauche;
138  $this->posxdatemouv = $this->marge_gauche + 8;
139  $this->posxdesc = 37;
140  $this->posxlabel = 50;
141  $this->posxtva = 80;
142  $this->posxqty = 105;
143  $this->posxup = 119;
144  $this->posxunit = 136;
145  $this->posxdiscount = 167;
146  $this->postotalht = 180;
147 
148  if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
149  $this->posxtva = $this->posxup;
150  }
151  $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images
152  if ($this->page_largeur < 210) { // To work with US executive format
153  $this->posxpicture -= 20;
154  $this->posxtva -= 20;
155  $this->posxup -= 20;
156  $this->posxqty -= 20;
157  $this->posxunit -= 20;
158  $this->posxdiscount -= 20;
159  $this->postotalht -= 20;
160  }
161  }
162 
163 
164  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
176  public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
177  {
178  // phpcs:enable
179  global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
180 
181  dol_syslog("write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang : 'null'));
182 
183  if (!is_object($outputlangs)) {
184  $outputlangs = $langs;
185  }
186  // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO
187  if (!empty($conf->global->MAIN_USE_FPDF)) {
188  $outputlangs->charset_output = 'ISO-8859-1';
189  }
190 
191  // Load traductions files required by the page
192  $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "stocks", "orders", "deliveries"));
193 
198  $id = GETPOST('id', 'int');
199  $ref = GETPOST('ref', 'alpha');
200  $msid = GETPOST('msid', 'int');
201  $product_id = GETPOST("product_id");
202  $action = GETPOST('action', 'aZ09');
203  $cancel = GETPOST('cancel', 'alpha');
204  $contextpage = GETPOST('contextpage', 'aZ') ?GETPOST('contextpage', 'aZ') : 'movementlist';
205 
206  $idproduct = GETPOST('idproduct', 'int');
207  $year = GETPOST("year");
208  $month = GETPOST("month");
209  $search_ref = GETPOST('search_ref', 'alpha');
210  $search_movement = GETPOST("search_movement");
211  $search_product_ref = trim(GETPOST("search_product_ref"));
212  $search_product = trim(GETPOST("search_product"));
213  $search_warehouse = trim(GETPOST("search_warehouse"));
214  $search_inventorycode = trim(GETPOST("search_inventorycode"));
215  $search_user = trim(GETPOST("search_user"));
216  $search_batch = trim(GETPOST("search_batch"));
217  $search_qty = trim(GETPOST("search_qty"));
218  $search_type_mouvement = GETPOST('search_type_mouvement', 'int');
219 
220  $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
221  $page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
222  $sortfield = GETPOST('sortfield', 'aZ09comma');
223  $sortorder = GETPOST('sortorder', 'aZ09comma');
224  if (empty($page) || $page == -1) {
225  $page = 0;
226  } // If $page is not defined, or '' or -1
227  $offset = $limit * $page;
228  if (!$sortfield) {
229  $sortfield = "m.datem";
230  }
231  if (!$sortorder) {
232  $sortorder = "DESC";
233  }
234 
235  $pdluoid = GETPOST('pdluoid', 'int');
236 
237  // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
238  $hookmanager->initHooks(array('movementlist'));
239  $extrafields = new ExtraFields($this->db);
240 
241  // fetch optionals attributes and labels
242  $extrafields->fetch_name_optionals_label('movement');
243  $search_array_options = $extrafields->getOptionalsFromPost('movement', '', 'search_');
244 
245  $productlot = new ProductLot($this->db);
246  $productstatic = new Product($this->db);
247  $warehousestatic = new Entrepot($this->db);
248  $movement = new MouvementStock($this->db);
249  $userstatic = new User($this->db);
250  $element = 'movement';
251 
252  $sql = "SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
253  $sql .= " e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,";
254  $sql .= " m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
255  $sql .= " m.batch, m.price,";
256  $sql .= " m.type_mouvement,";
257  $sql .= " pl.rowid as lotid, pl.eatby, pl.sellby,";
258  $sql .= " u.login, u.photo, u.lastname, u.firstname";
259  // Add fields from extrafields
260  if (!empty($extrafields->attributes[$element]['label'])) {
261  foreach ($extrafields->attributes[$element]['label'] as $key => $val) {
262  $sql .= ($extrafields->attributes[$element]['type'][$key] != 'separate' ? ", ef.".$key." as options_".$key : '');
263  }
264  }
265  // Add fields from hooks
266  $parameters = array();
267  $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $object may have been modified by hook
268  $sql .= $hookmanager->resPrint;
269  $sql .= " FROM ".MAIN_DB_PREFIX."entrepot as e,";
270  $sql .= " ".MAIN_DB_PREFIX."product as p,";
271  $sql .= " ".MAIN_DB_PREFIX."stock_mouvement as m";
272  if (is_array($extrafields->attributes[$object->table_element]['label']) && count($extrafields->attributes[$object->table_element]['label'])) {
273  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element."_extrafields as ef on (m.rowid = ef.fk_object)";
274  }
275  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON m.fk_user_author = u.rowid";
276  $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
277  $sql .= " WHERE m.fk_product = p.rowid";
278  if ($msid > 0) {
279  $sql .= " AND m.rowid = ".((int) $msid);
280  }
281  $sql .= " AND m.fk_entrepot = e.rowid";
282  $sql .= " AND e.entity IN (".getEntity('stock').")";
283  if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
284  $sql .= " AND p.fk_product_type = 0";
285  }
286  if ($id > 0) {
287  $sql .= " AND e.rowid = ".((int) $id);
288  }
289  if ($month > 0) {
290  if ($year > 0) {
291  $sql .= " AND m.datem BETWEEN '".$this->db->idate(dol_get_first_day($year, $month, false))."' AND '".$this->db->idate(dol_get_last_day($year, $month, false))."'";
292  } else {
293  $sql .= " AND date_format(m.datem, '%m') = '".((int) $month)."'";
294  }
295  } elseif ($year > 0) {
296  $sql .= " AND m.datem BETWEEN '".$this->db->idate(dol_get_first_day($year, 1, false))."' AND '".$this->db->idate(dol_get_last_day($year, 12, false))."'";
297  }
298  if ($idproduct > 0) {
299  $sql .= " AND p.rowid = ".((int) $idproduct);
300  }
301  if (!empty($search_ref)) {
302  $sql .= natural_search('m.rowid', $search_ref, 1);
303  }
304  if (!empty($search_movement)) {
305  $sql .= natural_search('m.label', $search_movement);
306  }
307  if (!empty($search_inventorycode)) {
308  $sql .= natural_search('m.inventorycode', $search_inventorycode);
309  }
310  if (!empty($search_product_ref)) {
311  $sql .= natural_search('p.ref', $search_product_ref);
312  }
313  if (!empty($search_product)) {
314  $sql .= natural_search('p.label', $search_product);
315  }
316  if ($search_warehouse > 0) {
317  $sql .= " AND e.rowid = ".((int) $this->db->escape($search_warehouse));
318  }
319  if (!empty($search_user)) {
320  $sql .= natural_search('u.login', $search_user);
321  }
322  if (!empty($search_batch)) {
323  $sql .= natural_search('m.batch', $search_batch);
324  }
325  if ($search_qty != '') {
326  $sql .= natural_search('m.value', $search_qty, 1);
327  }
328  if ($search_type_mouvement > 0) {
329  $sql .= " AND m.type_mouvement = '".$this->db->escape($search_type_mouvement)."'";
330  }
331  // Add where from extra fields
332  include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_sql.tpl.php';
333  // Add where from hooks
334  $parameters = array();
335  $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $object may have been modified by hook
336  $sql .= $hookmanager->resPrint;
337  $sql .= $this->db->order($sortfield, $sortorder);
338 
339  $nbtotalofrecords = '';
340  if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
341  $result = $this->db->query($sql);
342  $nbtotalofrecords = $this->db->num_rows($result);
343  if (($page * $limit) > $nbtotalofrecords) { // if total resultset is smaller then paging size (filtering), goto and load page 0
344  $page = 0;
345  $offset = 0;
346  }
347  }
348 
349  if (empty($search_inventorycode)) {
350  $sql .= $this->db->plimit($limit + 1, $offset);
351  }
352 
353 
354  $resql = $this->db->query($sql);
355  $nbtotalofrecords = $this->db->num_rows($result);
356 
357  /*
358  * END TODO
359  **/
360 
361  //$nblines = count($object->lines);
362 
363  if ($conf->stock->dir_output) {
364  if ($resql) {
365  $product = new Product($this->db);
366  $object = new Entrepot($this->db);
367 
368  if ($idproduct > 0) {
369  $product->fetch($idproduct);
370  }
371  if ($id > 0 || $ref) {
372  $result = $object->fetch($id, $ref);
373  if ($result < 0) {
374  dol_print_error($this->db);
375  }
376  }
377 
378  $num = $this->db->num_rows($resql);
379  }
380 
381  // Definition of $dir and $file
382  if ($object->specimen) {
383  $dir = $conf->stock->dir_output."/movement";
384  $file = $dir."/SPECIMEN.pdf";
385  } else {
386  $objectref = dol_sanitizeFileName($object->ref);
387  if (!empty($search_inventorycode)) {
388  $objectref .= "_".$id."_".$search_inventorycode;
389  }
390  if ($search_type_mouvement) {
391  $objectref .= "_".$search_type_mouvement;
392  }
393  $dir = $conf->stock->dir_output."/movement/".$objectref;
394  $file = $dir."/".$objectref.".pdf";
395  }
396 
397  $stockFournisseur = new ProductFournisseur($this->db);
398  $supplierprices = $stockFournisseur->list_product_fournisseur_price($object->id);
399  $object->supplierprices = $supplierprices;
400 
401  $productstatic = new Product($this->db);
402 
403  if (!file_exists($dir)) {
404  if (dol_mkdir($dir) < 0) {
405  $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir);
406  return -1;
407  }
408  }
409 
410  if (file_exists($dir)) {
411  // Add pdfgeneration hook
412  if (!is_object($hookmanager)) {
413  include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php';
414  $hookmanager = new HookManager($this->db);
415  }
416  $hookmanager->initHooks(array('pdfgeneration'));
417  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
418  global $action;
419  $reshook = $hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
420 
421  // Create pdf instance
422  $pdf = pdf_getInstance($this->format);
423  $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
424  $pdf->SetAutoPageBreak(1, 0);
425 
426  $heightforinfotot = 40; // Height reserved to output the info and total part
427  $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page
428  $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
429 
430  if (class_exists('TCPDF')) {
431  $pdf->setPrintHeader(false);
432  $pdf->setPrintFooter(false);
433  }
434  $pdf->SetFont(pdf_getPDFFont($outputlangs));
435  // Set path to the background PDF File
436  if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
437  $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
438  $tplidx = $pdf->importPage(1);
439  }
440 
441  $pdf->Open();
442  $pagenb = 0;
443  $pdf->SetDrawColor(128, 128, 128);
444 
445  $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
446  $pdf->SetSubject($outputlangs->transnoentities("Stock"));
447  $pdf->SetCreator("Dolibarr ".DOL_VERSION);
448  $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
449  $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Stock")." ".$outputlangs->convToOutputCharset($object->label));
450  if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
451  $pdf->SetCompression(false);
452  }
453 
454  $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
455 
456 
457  // New page
458  $pdf->AddPage();
459  if (!empty($tplidx)) {
460  $pdf->useTemplate($tplidx);
461  }
462  $pagenb++;
463  $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs);
464  $pdf->SetFont('', '', $default_font_size - 1);
465  $pdf->MultiCell(0, 3, ''); // Set interline to 3
466  $pdf->SetTextColor(0, 0, 0);
467 
468  $tab_top = 42;
469  $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
470 
471  $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
472 
473  // Show list of product of the MouvementStock
474 
475  $nexY = $tab_top - 1;
476 
477  $nexY = $pdf->GetY();
478  $nexY += 10;
479 
480  $totalunit = 0;
481  $totalvalue = $totalvaluesell = 0;
482  $arrayofuniqueproduct = array();
483 
484  //dol_syslog('List products', LOG_DEBUG);
485  $resql = $this->db->query($sql);
486  if ($resql) {
487  $num = $this->db->num_rows($resql);
488  $i = 0;
489  $nblines = $num;
490  for ($i = 0; $i < $nblines; $i++) {
491  $objp = $this->db->fetch_object($resql);
492 
493  // Multilangs
494  if (!empty($conf->global->MAIN_MULTILANGS)) { // si l'option est active
495  $sql = "SELECT label";
496  $sql .= " FROM ".MAIN_DB_PREFIX."product_lang";
497  $sql .= " WHERE fk_product = ".((int) $objp->rowid);
498  $sql .= " AND lang = '".$this->db->escape($langs->getDefaultLang())."'";
499  $sql .= " LIMIT 1";
500 
501  $result = $this->db->query($sql);
502  if ($result) {
503  $objtp = $this->db->fetch_object($result);
504  if ($objtp->label != '') {
505  $objp->produit = $objtp->label;
506  }
507  }
508  }
509 
510  $curY = $nexY;
511  $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
512  $pdf->SetTextColor(0, 0, 0);
513 
514  $pdf->setTopMargin($tab_top_newpage);
515  $pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
516  $pageposbefore = $pdf->getPage();
517 
518  // Description of product line
519  $curX = $this->posxdesc - 1;
520 
521  $showpricebeforepagebreak = 1;
522 
523  $pdf->startTransaction();
524  pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc);
525  $pageposafter = $pdf->getPage();
526  if ($pageposafter > $pageposbefore) { // There is a pagebreak
527  $pdf->rollbackTransaction(true);
528  $pageposafter = $pageposbefore;
529  //print $pageposafter.'-'.$pageposbefore;exit;
530  $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
531  pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc);
532  $pageposafter = $pdf->getPage();
533  $posyafter = $pdf->GetY();
534  if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) { // There is no space left for total+free text
535  if ($i == ($nblines - 1)) { // No more lines, and no space left to show total, so we create a new page
536  $pdf->AddPage('', '', true);
537  if (!empty($tplidx)) {
538  $pdf->useTemplate($tplidx);
539  }
540  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
541  $this->_pagehead($pdf, $object, 0, $outputlangs);
542  }
543  $pdf->setPage($pageposafter + 1);
544  }
545  } else {
546  // We found a page break
547 
548  // Allows data in the first page if description is long enough to break in multiples pages
549  if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
550  $showpricebeforepagebreak = 1;
551  } else {
552  $showpricebeforepagebreak = 0;
553  }
554  }
555  } else // No pagebreak
556  {
557  $pdf->commitTransaction();
558  }
559  $posYAfterDescription = $pdf->GetY();
560 
561  $nexY = $pdf->GetY();
562  $pageposafter = $pdf->getPage();
563 
564  $pdf->setPage($pageposbefore);
565  $pdf->setTopMargin($this->marge_haute);
566  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
567 
568  // We suppose that a too long description is moved completely on next page
569  if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
570  $pdf->setPage($pageposafter);
571  $curY = $tab_top_newpage;
572  }
573 
574  $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut
575 
576  // $objp = $this->db->fetch_object($resql);
577 
578  $userstatic->id = $objp->fk_user_author;
579  $userstatic->login = $objp->login;
580  $userstatic->lastname = $objp->lastname;
581  $userstatic->firstname = $objp->firstname;
582  $userstatic->photo = $objp->photo;
583 
584  $productstatic->id = $objp->rowid;
585  $productstatic->ref = $objp->product_ref;
586  $productstatic->label = $objp->produit;
587  $productstatic->type = $objp->type;
588  $productstatic->entity = $objp->entity;
589  $productstatic->status_batch = $objp->tobatch;
590 
591  $productlot->id = $objp->lotid;
592  $productlot->batch = $objp->batch;
593  $productlot->eatby = $objp->eatby;
594  $productlot->sellby = $objp->sellby;
595 
596  $warehousestatic->id = $objp->entrepot_id;
597  $warehousestatic->label = $objp->warehouse_ref;
598  $warehousestatic->lieu = $objp->lieu;
599 
600  $arrayofuniqueproduct[$objp->rowid] = $objp->produit;
601  if (!empty($objp->fk_origin)) {
602  $origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
603  } else {
604  $origin = '';
605  }
606 
607  // Id movement.
608  $pdf->SetXY($this->posxidref, $curY);
609  $pdf->MultiCell($this->posxdesc - $this->posxidref - 0.8, 3, $objp->mid, 0, 'L');
610 
611  // Date.
612  $pdf->SetXY($this->posxdatemouv, $curY);
613  $pdf->MultiCell($this->posxdesc - $this->posxdatemouv - 0.8, 6, dol_print_date($this->db->jdate($objp->datem), 'dayhour'), 0, 'L');
614 
615  // Ref.
616  $pdf->SetXY($this->posxdesc, $curY);
617  $pdf->MultiCell($this->posxlabel - $this->posxdesc - 0.8, 3, $productstatic->ref, 0, 'L');
618 
619  // Label
620  $pdf->SetXY($this->posxlabel + 0.8, $curY);
621  $pdf->MultiCell($this->posxqty - $this->posxlabel - 0.8, 6, $productstatic->label, 0, 'L');
622 
623  // Lot/serie
624  $pdf->SetXY($this->posxqty, $curY);
625  $pdf->MultiCell($this->posxup - $this->posxqty - 0.8, 3, $productlot->batch, 0, 'R');
626 
627  // Inv. code
628  $pdf->SetXY($this->posxup, $curY);
629  $pdf->MultiCell($this->posxunit - $this->posxup - 0.8, 3, $objp->inventorycode, 0, 'R');
630 
631  // Label mouvement
632  $pdf->SetXY($this->posxunit, $curY);
633  $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 3, $objp->label, 0, 'R');
634  $totalvalue += price2num($objp->ppmp * $objp->value, 'MT');
635 
636  // Origin
637  $pricemin = $objp->price;
638  $pdf->SetXY($this->posxdiscount, $curY);
639  $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 3, $origin, 0, 'R', 0);
640 
641  // Qty
642  $valtoshow = price2num($objp->qty, 'MS');
643  $towrite = (empty($valtoshow) ? '0' : $valtoshow);
644  $totalunit += $objp->qty;
645 
646  $pdf->SetXY($this->postotalht, $curY);
647  $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $objp->qty, 0, 'R', 0);
648 
649  $totalvaluesell += price2num($pricemin * $objp->value, 'MT');
650 
651  $nexY += 3.5; // Add space between lines
652  // Add line
653  if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
654  $pdf->setPage($pageposafter);
655  $pdf->SetLineStyle(array('dash'=>'1,1', 'color'=>array(80, 80, 80)));
656  //$pdf->SetDrawColor(190,190,200);
657  $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
658  $pdf->SetLineStyle(array('dash'=>0));
659  }
660 
661  $nexY += 2; // Add space between lines
662 
663  // Detect if some page were added automatically and output _tableau for past pages
664  while ($pagenb < $pageposafter) {
665  $pdf->setPage($pagenb);
666  if ($pagenb == 1) {
667  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
668  } else {
669  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
670  }
671  $this->_pagefoot($pdf, $object, $outputlangs, 1);
672  $pagenb++;
673  $pdf->setPage($pagenb);
674  $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
675  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
676  $this->_pagehead($pdf, $object, 0, $outputlangs);
677  }
678  if (!empty($tplidx)) {
679  $pdf->useTemplate($tplidx);
680  }
681  }
682  if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
683  if ($pagenb == 1) {
684  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
685  } else {
686  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
687  }
688  $this->_pagefoot($pdf, $object, $outputlangs, 1);
689  // New page
690  $pdf->AddPage();
691  if (!empty($tplidx)) {
692  $pdf->useTemplate($tplidx);
693  }
694  $pagenb++;
695  if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
696  $this->_pagehead($pdf, $object, 0, $outputlangs);
697  }
698  }
699  }
700 
701  $this->db->free($resql);
702 
706  $nexY = $pdf->GetY();
707  $nexY += 5;
708  $curY = $nexY;
709 
710  $pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26)));
711  $pdf->line($this->marge_gauche, $curY - 1, $this->page_largeur - $this->marge_droite, $curY - 1);
712  $pdf->SetLineStyle(array('dash'=>0));
713 
714  $pdf->SetFont('', 'B', $default_font_size - 1);
715  $pdf->SetTextColor(0, 0, 120);
716 
717  // Total
718  $pdf->SetXY($this->posxidref, $curY);
719  $pdf->MultiCell($this->posxdesc - $this->posxidref, 3, $langs->trans("Total"), 0, 'L');
720 
721  // Total Qty
722  $pdf->SetXY($this->postotalht, $curY);
723  $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $totalunit, 0, 'R', 0);
724  } else {
725  dol_print_error($this->db);
726  }
727 
728  if ($notetoshow) {
729  $substitutionarray = pdf_getSubstitutionArray($outputlangs, null, $object);
730  complete_substitutions_array($substitutionarray, $outputlangs, $object);
731  $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs);
732  $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow);
733 
734  $tab_top = 88;
735 
736  $pdf->SetFont('', '', $default_font_size - 1);
737  $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1);
738  $nexY = $pdf->GetY();
739  $height_note = $nexY - $tab_top;
740 
741  // Rect takes a length in 3rd parameter
742  $pdf->SetDrawColor(192, 192, 192);
743  $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
744 
745  $tab_height = $tab_height - $height_note;
746  $tab_top = $nexY + 6;
747  } else {
748  $height_note = 0;
749  }
750 
751  $iniY = $tab_top + 7;
752  $curY = $tab_top + 7;
753  $nexY = $tab_top + 7;
754 
755  $tab_top = $tab_top_newpage + 21;
756 
757  // Show square
758  if ($pagenb == 1) {
759  $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
760  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
761  } else {
762  $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
763  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
764  }
765 
766  $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
767 
768  // Affiche zone infos
769  //$posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
770 
771  // Affiche zone totaux
772  //$posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
773 
774  // Pied de page
775  $this->_pagefoot($pdf, $object, $outputlangs);
776  if (method_exists($pdf, 'AliasNbPages')) {
777  $pdf->AliasNbPages();
778  }
779 
780  $pdf->Close();
781 
782  $pdf->Output($file, 'F');
783 
784  // Add pdfgeneration hook
785  $hookmanager->initHooks(array('pdfgeneration'));
786  $parameters = array('file'=>$file, 'object'=>$object, 'outputlangs'=>$outputlangs);
787  global $action;
788  $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
789  if ($reshook < 0) {
790  $this->error = $hookmanager->error;
791  $this->errors = $hookmanager->errors;
792  }
793 
794  if (!empty($conf->global->MAIN_UMASK)) {
795  @chmod($file, octdec($conf->global->MAIN_UMASK));
796  }
797 
798  $this->result = array('fullpath'=>$file);
799 
800  return 1; // No error
801  } else {
802  $this->error = $langs->trans("ErrorCanNotCreateDir", $dir);
803  return 0;
804  }
805  } else {
806  $this->error = $langs->trans("ErrorConstantNotDefined", "PRODUCT_OUTPUTDIR");
807  return 0;
808  }
809  }
810 
811  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
825  protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
826  {
827  global $conf;
828 
829  // Force to disable hidetop and hidebottom
830  $hidebottom = 0;
831  if ($hidetop) {
832  $hidetop = -1;
833  }
834 
835  $currency = !empty($currency) ? $currency : $conf->currency;
836  $default_font_size = pdf_getPDFFontSize($outputlangs);
837 
838  // Amount in (at tab_top - 1)
839  $pdf->SetTextColor(0, 0, 0);
840  $pdf->SetFont('', '', $default_font_size - 2);
841 
842  if (empty($hidetop)) {
843  $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
844  $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
845  $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
846 
847  //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230';
848  if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
849  $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
850  }
851  }
852 
853  $pdf->SetDrawColor(128, 128, 128);
854  $pdf->SetFont('', 'B', $default_font_size - 3);
855 
856  // Output Rect
857  //$this->printRect($pdf,$this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter
858 
859  $pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26)));
860  $pdf->SetDrawColor(220, 26, 26);
861  $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite, $tab_top);
862  $pdf->SetLineStyle(array('dash'=>0));
863  $pdf->SetDrawColor(128, 128, 128);
864  $pdf->SetTextColor(0, 0, 120);
865 
866  //Ref mouv
867  if (empty($hidetop)) {
868  //$pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); // line takes a position y in 2nd parameter and 4th parameter
869  $pdf->SetXY($this->posxidref, $tab_top + 1);
870  $pdf->MultiCell($this->posxdatemouv - $this->posxdatemouv - 0.8, 3, $outputlangs->transnoentities("Ref"), '', 'L');
871  }
872 
873  //Date mouv
874  //$pdf->line($this->posxlabel-1, $tab_top, $this->posxlabel-1, $tab_top + $tab_height);
875  if (empty($hidetop)) {
876  $pdf->SetXY($this->posxdatemouv, $tab_top + 1);
877  $pdf->MultiCell($this->posxdesc - $this->posxdatemouv, 2, $outputlangs->transnoentities("Date"), '', 'C');
878  }
879 
880  //Ref Product
881  //$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
882  if (empty($hidetop)) {
883  $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
884  $pdf->MultiCell($this->posxlabel - $this->posxdesc, 2, $outputlangs->transnoentities("Ref. Product"), '', 'C');
885  }
886 
887  //Label Product
888  //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
889  if (empty($hidetop)) {
890  $pdf->SetXY($this->posxlabel - 1, $tab_top + 1);
891  $pdf->MultiCell($this->posxqty - $this->posxlabel, 2, $outputlangs->transnoentities("Label"), '', 'C');
892  }
893 
894  //Lot/serie Product
895  //$pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
896  if (empty($hidetop)) {
897  $pdf->SetXY($this->posxqty, $tab_top + 1);
898  $pdf->MultiCell($this->posxup - $this->posxqty, 2, $outputlangs->transnoentities("Lot/Série"), '', 'C');
899  }
900 
901  //Code Inv
902  //$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
903  if (empty($hidetop)) {
904  $pdf->SetXY($this->posxup - 1, $tab_top + 1);
905  $pdf->MultiCell($this->posxunit - $this->posxup, 2, $outputlangs->transnoentities("Inventory Code"), '', 'C');
906  }
907 
908  //Label mouvement
909  //$pdf->line($this->posxunit, $tab_top, $this->posxunit, $tab_top + $tab_height);
910  if (empty($hidetop)) {
911  $pdf->SetXY($this->posxunit, $tab_top + 1);
912  $pdf->MultiCell($this->posxdiscount - $this->posxunit, 2, $outputlangs->transnoentities("Label Mouvement"), '', 'C');
913  }
914 
915  //Origin
916  //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
917  if (empty($hidetop)) {
918  $pdf->SetXY($this->posxdiscount + 2, $tab_top + 1);
919  $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 2, $outputlangs->transnoentities("Origin"), '', 'C');
920  }
921 
922  //Qty
923  //$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
924  if (empty($hidetop)) {
925  $pdf->SetXY($this->postotalht + 2, $tab_top + 1);
926  $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities("Qty"), '', 'C');
927  }
928 
929  $pdf->SetDrawColor(220, 26, 26);
930  $pdf->SetLineStyle(array('dash'=>'0', 'color'=>array(220, 26, 26)));
931  $pdf->line($this->marge_gauche, $tab_top + 11, $this->page_largeur - $this->marge_droite, $tab_top + 11);
932  $pdf->SetLineStyle(array('dash'=>0));
933  }
934 
935  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
946  protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "")
947  {
948  global $conf, $langs, $db, $hookmanager;
949 
950  // Load traductions files required by page
951  $outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders", "stocks"));
952 
953  $default_font_size = pdf_getPDFFontSize($outputlangs);
954 
955  if ($object->type == 1) {
956  $titlekey = 'ServiceSheet';
957  } else {
958  $titlekey = 'StockSheet';
959  }
960 
961  pdf_pagehead($pdf, $outputlangs, $this->page_hauteur);
962 
963  // Show Draft Watermark
964  if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) {
965  pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
966  }
967 
968  $pdf->SetTextColor(0, 0, 60);
969  $pdf->SetFont('', 'B', $default_font_size + 3);
970 
971  $posy = $this->marge_haute;
972  $posx = $this->page_largeur - $this->marge_droite - 100;
973 
974  $pdf->SetXY($this->marge_gauche, $posy);
975 
976  // Logo
977  $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo;
978  if ($this->emetteur->logo) {
979  if (is_readable($logo)) {
980  $height = pdf_getHeightForLogo($logo);
981  $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto)
982  } else {
983  $pdf->SetTextColor(200, 0, 0);
984  $pdf->SetFont('', 'B', $default_font_size - 2);
985  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
986  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
987  }
988  } else {
989  $text = $this->emetteur->name;
990  $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
991  }
992 
993  $pdf->SetFont('', 'B', $default_font_size + 3);
994  $pdf->SetXY($posx, $posy);
995  $pdf->SetTextColor(0, 0, 60);
996  $title = $outputlangs->transnoentities("Warehouse");
997  $pdf->MultiCell(100, 3, $title, '', 'R');
998 
999  $pdf->SetFont('', 'B', $default_font_size);
1000 
1001  $posy += 5;
1002  $pdf->SetXY($posx, $posy);
1003  $pdf->SetTextColor(0, 0, 60);
1004 
1005  $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->label), '', 'R');
1006 
1007  $posy += 5;
1008  $pdf->SetFont('', '', $default_font_size - 1);
1009  $pdf->SetXY($posx, $posy);
1010  $pdf->SetTextColor(0, 0, 60);
1011  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("LocationSummary").' :', '', 'R');
1012 
1013  $posy += 4;
1014  $pdf->SetXY($posx - 50, $posy);
1015  $pdf->MultiCell(150, 3, $object->lieu, '', 'R');
1016 
1017 
1018  // Parent MouvementStock
1019  $posy += 4;
1020  $pdf->SetXY($posx, $posy);
1021  $pdf->SetTextColor(0, 0, 60);
1022  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ParentWarehouse").' :', '', 'R');
1023 
1024  $posy += 4;
1025  $pdf->SetXY($posx - 50, $posy);
1026  $e = new MouvementStock($this->db);
1027  if (!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0) {
1028  $pdf->MultiCell(150, 3, $e->label, '', 'R');
1029  } else {
1030  $pdf->MultiCell(150, 3, $outputlangs->transnoentities("None"), '', 'R');
1031  }
1032 
1033  // Description
1034  $nexY = $pdf->GetY();
1035  $nexY += 5;
1036  $pdf->SetXY($posx, $posy);
1037  $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("Description").' : </b>'.nl2br($object->description), 0, 1);
1038  $nexY = $pdf->GetY();
1039 
1040  $calcproductsunique = $object->nb_different_products();
1041  $calcproducts = $object->nb_products();
1042 
1043  // Total nb of different products
1044  $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfDifferentProducts").' : </b>'.(empty($calcproductsunique['nb']) ? '0' : $calcproductsunique['nb']), 0, 1);
1045  $nexY = $pdf->GetY();
1046 
1047  // Nb of products
1048  $valtoshow = price2num($calcproducts['nb'], 'MS');
1049  $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("NumberOfProducts").' : </b>'.(empty($valtoshow) ? '0' : $valtoshow), 0, 1);
1050  $nexY = $pdf->GetY();
1051 
1052  // Value
1053  $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("EstimatedStockValueShort").' : </b>'.price((empty($calcproducts['value']) ? '0' : price2num($calcproducts['value'], 'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1);
1054  $nexY = $pdf->GetY();
1055 
1056 
1057  // Last movement
1058  $sql = "SELECT max(m.datem) as datem";
1059  $sql .= " FROM ".MAIN_DB_PREFIX."stock_mouvement as m";
1060  $sql .= " WHERE m.fk_entrepot = ".((int) $object->id);
1061  $resqlbis = $this->db->query($sql);
1062  if ($resqlbis) {
1063  $obj = $this->db->fetch_object($resqlbis);
1064  $lastmovementdate = $this->db->jdate($obj->datem);
1065  } else {
1066  dol_print_error($this->db);
1067  }
1068 
1069  if ($lastmovementdate) {
1070  $toWrite = dol_print_date($lastmovementdate, 'dayhour').' ';
1071  } else {
1072  $toWrite = $outputlangs->transnoentities("None");
1073  }
1074 
1075  $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY, '<b>'.$outputlangs->transnoentities("LastMovement").' : </b>'.$toWrite, 0, 1);
1076  $nexY = $pdf->GetY();
1077 
1078 
1079  /*if ($object->ref_client)
1080  {
1081  $posy+=5;
1082  $pdf->SetXY($posx,$posy);
1083  $pdf->SetTextColor(0,0,60);
1084  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R');
1085  }*/
1086 
1087  /*$posy+=4;
1088  $pdf->SetXY($posx,$posy);
1089  $pdf->SetTextColor(0,0,60);
1090  $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R');
1091  */
1092 
1093  // Get contact
1094  /*
1095  if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1096  {
1097  $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL');
1098  if (count($arrayidcontact) > 0)
1099  {
1100  $usertmp=new User($this->db);
1101  $usertmp->fetch($arrayidcontact[0]);
1102  $posy+=4;
1103  $pdf->SetXY($posx,$posy);
1104  $pdf->SetTextColor(0,0,60);
1105  $pdf->MultiCell(100, 3, $langs->trans("SalesRepresentative")." : ".$usertmp->getFullName($langs), '', 'R');
1106  }
1107  }*/
1108 
1109  $posy += 2;
1110 
1111  // Show list of linked objects
1112  //$posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size);
1113 
1114  if ($showaddress) {
1115  /*
1116  // Sender properties
1117  $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
1118 
1119  // Show sender
1120  $posy=42;
1121  $posx=$this->marge_gauche;
1122  if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80;
1123  $hautcadre=40;
1124 
1125  // Show sender frame
1126  $pdf->SetTextColor(0,0,0);
1127  $pdf->SetFont('','', $default_font_size - 2);
1128  $pdf->SetXY($posx,$posy-5);
1129  $pdf->MultiCell(80, 5, $outputlangs->transnoentities("BillFrom"), 0, 'L');
1130  $pdf->SetXY($posx,$posy);
1131  $pdf->SetFillColor(230,230,230);
1132  $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
1133  $pdf->SetTextColor(0,0,60);
1134 
1135  // Show sender name
1136  $pdf->SetXY($posx+2,$posy+3);
1137  $pdf->SetFont('','B', $default_font_size);
1138  $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, 'L');
1139  $posy=$pdf->getY();
1140 
1141  // Show sender information
1142  $pdf->SetXY($posx+2,$posy);
1143  $pdf->SetFont('','', $default_font_size - 1);
1144  $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L');
1145  */
1146  }
1147 
1148  $pdf->SetTextColor(0, 0, 0);
1149  }
1150 
1151  // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore
1161  protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1162  {
1163  global $conf;
1164  $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1165  return pdf_pagefoot($pdf, $outputlangs, 'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1166  }
1167 }
make_substitutions
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
Definition: functions.lib.php:7839
db
$conf db
API class for accounts.
Definition: inc.php:41
pdf_writelinedesc
pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0)
Output line description into PDF.
Definition: pdf.lib.php:1345
dol_sanitizeFileName
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
Definition: functions.lib.php:1226
description
print *****$script_file(".$version.") pid cd cd cd description as description
Definition: email_expire_services_to_customers.php:83
pdf_getFormat
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
Definition: pdf.lib.php:84
ProductFournisseur
Class to manage predefined suppliers products.
Definition: fournisseur.product.class.php:41
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
pdf_getInstance
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
Definition: pdf.lib.php:126
dol_print_error
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
Definition: functions.lib.php:4844
pdf_getPDFFont
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
Definition: pdf.lib.php:265
pdf_standard\_pagefoot
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
Definition: pdf_standard.modules.php:1130
pdf_standard\_pagehead
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
Definition: pdf_standard.modules.php:654
name
$conf db name
Definition: repair.php:122
price2num
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
Definition: functions.lib.php:5661
dol_print_date
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
Definition: functions.lib.php:2514
pdf_pagehead
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Definition: pdf.lib.php:711
MouvementStock
Class to manage stock movements.
Definition: mouvementstock.class.php:31
pdf_standard\_pagehead
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="")
Show top header of page.
Definition: pdf_standard.modules.php:946
pdf_watermark
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
Definition: pdf.lib.php:757
pdf_getHeightForLogo
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
Definition: pdf.lib.php:313
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
dol_get_first_day
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
Definition: date.lib.php:551
convertBackOfficeMediasLinksToPublicLinks
if(!function_exists('dolEscapeXML')) convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
Definition: functions2.lib.php:2711
dol_get_last_day
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
Definition: date.lib.php:570
User
Class to manage Dolibarr users.
Definition: user.class.php:44
GETPOSTISSET
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
Definition: functions.lib.php:386
pdf_standard\__construct
__construct($db)
Constructor.
Definition: pdf_standard.modules.php:102
natural_search
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
Definition: functions.lib.php:9420
ExtraFields
Class to manage standard extra fields.
Definition: extrafields.class.php:39
Product
Class to manage products or services.
Definition: product.class.php:46
ModelePDFMovement
Parent class to manage warehouse mouvement document templates.
Definition: modules_movement.php:31
dol_htmlentitiesbr
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
Definition: functions.lib.php:6991
pdf_standard\write_file
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build a document on disk using the generic odt module.
Definition: pdf_standard.modules.php:176
pdf_standard\_tableau
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
Show table for lines.
Definition: pdf_standard.modules.php:901
Entrepot
Class to manage warehouses.
Definition: entrepot.class.php:35
$resql
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->rights->fournisseur->facture->lire)||(isModEnabled('supplier_invoice') && $user->rights->supplier_invoice->lire)) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
Definition: index.php:742
pdf_getPDFFontSize
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Definition: pdf.lib.php:288
pdf_getSubstitutionArray
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
Definition: pdf.lib.php:737
price
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.
Definition: functions.lib.php:5541
dol_mkdir
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
Definition: functions.lib.php:6603
type
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Definition: repair.php:119
pdf_standard
Class to generate expense report based on standard model.
Definition: pdf_standard.modules.php:45
HookManager
Class to manage hooks.
Definition: hookmanager.class.php:30
complete_substitutions_array
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
Definition: functions.lib.php:7961
pdf_pagefoot
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
Definition: pdf.lib.php:989