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