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