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