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