25 require_once DOL_DOCUMENT_ROOT.
'/core/modules/stock/modules_movement.php';
26 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/mouvementstock.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
64 public $phpmin = array(5, 6);
70 public $version =
'dolibarr';
120 global $conf, $langs, $mysoc;
123 $langs->loadLangs(array(
"main",
"companies"));
126 $this->
name =
"stdmouvement";
127 $this->
description = $langs->trans(
"DocumentModelStandardPDF");
132 $this->page_largeur = $formatarray[
'width'];
133 $this->page_hauteur = $formatarray[
'height'];
134 $this->format = array($this->page_largeur, $this->page_hauteur);
135 $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
136 $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
137 $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
138 $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
140 $this->option_logo = 1;
141 $this->option_codestockservice = 0;
142 $this->option_multilang = 1;
143 $this->option_freetext = 0;
146 $this->emetteur = $mysoc;
147 if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2);
151 $this->posxidref = $this->marge_gauche;
152 $this->posxdatemouv = $this->marge_gauche + 8;
153 $this->posxdesc = 37;
154 $this->posxlabel = 50;
156 $this->posxqty = 105;
158 $this->posxunit = 136;
159 $this->posxdiscount = 167;
160 $this->postotalht = 180;
162 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva = $this->posxup;
163 $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
164 if ($this->page_largeur < 210)
166 $this->posxpicture -= 20;
167 $this->posxtva -= 20;
169 $this->posxqty -= 20;
170 $this->posxunit -= 20;
171 $this->posxdiscount -= 20;
172 $this->postotalht -= 20;
174 $this->tva = array();
175 $this->localtax1 = array();
176 $this->localtax2 = array();
177 $this->atleastoneratenotnull = 0;
178 $this->atleastonediscount = 0;
194 public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
197 global $user, $langs, $conf, $mysoc, $db, $hookmanager;
199 if (!is_object($outputlangs)) $outputlangs = $langs;
201 if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output =
'ISO-8859-1';
204 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"stocks",
"orders",
"deliveries"));
211 $ref =
GETPOST(
'ref',
'alpha');
212 $msid =
GETPOST(
'msid',
'int');
213 $product_id =
GETPOST(
"product_id");
214 $action =
GETPOST(
'action',
'aZ09');
215 $cancel =
GETPOST(
'cancel',
'alpha');
216 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'movementlist';
218 $idproduct =
GETPOST(
'idproduct',
'int');
221 $search_ref =
GETPOST(
'search_ref',
'alpha');
222 $search_movement =
GETPOST(
"search_movement");
223 $search_product_ref = trim(
GETPOST(
"search_product_ref"));
224 $search_product = trim(
GETPOST(
"search_product"));
225 $search_warehouse = trim(
GETPOST(
"search_warehouse"));
226 $search_inventorycode = trim(
GETPOST(
"search_inventorycode"));
227 $search_user = trim(
GETPOST(
"search_user"));
228 $search_batch = trim(
GETPOST(
"search_batch"));
229 $search_qty = trim(
GETPOST(
"search_qty"));
230 $search_type_mouvement =
GETPOST(
'search_type_mouvement',
'int');
232 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
234 $sortfield =
GETPOST(
"sortfield",
'alpha');
235 $sortorder =
GETPOST(
"sortorder",
'alpha');
236 if (empty($page) || $page == -1) { $page = 0; }
237 $offset = $limit * $page;
238 if (!$sortfield) $sortfield =
"m.datem";
239 if (!$sortorder) $sortorder =
"DESC";
241 $pdluoid =
GETPOST(
'pdluoid',
'int');
244 $hookmanager->initHooks(array(
'movementlist'));
248 $extrafields->fetch_name_optionals_label(
'movement');
249 $search_array_options = $extrafields->getOptionalsFromPost(
'movement',
'',
'search_');
251 $productlot =
new ProductLot($this->
db);
255 $userstatic =
new User($this->
db);
256 $element =
'movement';
258 $sql =
"SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
259 $sql .=
" e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,";
260 $sql .=
" m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
261 $sql .=
" m.batch, m.price,";
262 $sql .=
" m.type_mouvement,";
263 $sql .=
" pl.rowid as lotid, pl.eatby, pl.sellby,";
264 $sql .=
" u.login, u.photo, u.lastname, u.firstname";
266 if (!empty($extrafields->attributes[$element][
'label'])) {
267 foreach ($extrafields->attributes[$element][
'label'] as $key => $val) $sql .= ($extrafields->attributes[$element][
'type'][$key] !=
'separate' ?
", ef.".$key.
' as options_'.$key :
'');
270 $parameters = array();
271 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
272 $sql .= $hookmanager->resPrint;
273 $sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e,";
274 $sql .=
" ".MAIN_DB_PREFIX.
"product as p,";
275 $sql .=
" ".MAIN_DB_PREFIX.
"stock_mouvement as m";
276 if (is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (m.rowid = ef.fk_object)";
277 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON m.fk_user_author = u.rowid";
278 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
279 $sql .=
" WHERE m.fk_product = p.rowid";
280 if ($msid > 0) $sql .=
" AND m.rowid = ".$msid;
281 $sql .=
" AND m.fk_entrepot = e.rowid";
282 $sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
283 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) $sql .=
" AND p.fk_product_type = 0";
284 if ($id > 0) $sql .=
" AND e.rowid ='".$id.
"'";
289 else $sql .=
" AND date_format(m.datem, '%m') = '$month'";
294 if ($idproduct > 0) $sql .=
" AND p.rowid = ".((int) $idproduct);
295 if (!empty($search_ref)) $sql .=
natural_search(
'm.rowid', $search_ref, 1);
296 if (!empty($search_movement)) $sql .=
natural_search(
'm.label', $search_movement);
297 if (!empty($search_inventorycode)) $sql .=
natural_search(
'm.inventorycode', $search_inventorycode);
298 if (!empty($search_product_ref)) $sql .=
natural_search(
'p.ref', $search_product_ref);
299 if (!empty($search_product)) $sql .=
natural_search(
'p.label', $search_product);
300 if ($search_warehouse > 0) $sql .=
" AND e.rowid = ".((int) $this->
db->escape($search_warehouse));
301 if (!empty($search_user)) $sql .=
natural_search(
'u.login', $search_user);
302 if (!empty($search_batch)) $sql .=
natural_search(
'm.batch', $search_batch);
303 if ($search_qty !=
'') $sql .=
natural_search(
'm.value', $search_qty, 1);
304 if ($search_type_mouvement > 0) $sql .=
" AND m.type_mouvement = '".$this->db->escape($search_type_mouvement).
"'";
306 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
308 $parameters = array();
309 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
310 $sql .= $hookmanager->resPrint;
311 $sql .= $this->
db->order($sortfield, $sortorder);
313 $nbtotalofrecords =
'';
314 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
316 $result = $this->
db->query($sql);
317 $nbtotalofrecords = $this->
db->num_rows($result);
318 if (($page * $limit) > $nbtotalofrecords)
325 if (empty($search_inventorycode)) $sql .= $this->
db->plimit($limit + 1, $offset);
329 $nbtotalofrecords = $this->
db->num_rows($result);
337 if ($conf->stock->dir_output)
346 $product->fetch($idproduct);
350 $result = $object->fetch($id, $ref);
359 $arrayofselected = is_array($toselect) ? $toselect : array();
362 $help_url =
'EN:Module_Stocks_En|FR:Module_Stock|ES:Módulo_Stocks';
363 if ($msid) $texte = $langs->trans(
'StockMovementForId', $msid);
365 $texte = $langs->trans(
"ListOfStockMovements");
366 if ($id) $texte .=
' ('.$langs->trans(
"ForThisWarehouse").
')';
371 if ($object->specimen)
373 $dir = $conf->stock->dir_output.
"/movement";
374 $file = $dir.
"/SPECIMEN.pdf";
377 if (!empty($search_inventorycode)) $objectref .=
"_".$id.
"_".$search_inventorycode;
378 if ($search_type_mouvement) $objectref .=
"_".$search_type_mouvement;
379 $dir = $conf->stock->dir_output.
"/movement/".$objectref;
380 $file = $dir.
"/".$objectref.
".pdf";
384 $supplierprices = $stockFournisseur->list_product_fournisseur_price($object->id);
385 $object->supplierprices = $supplierprices;
389 if (!file_exists($dir))
393 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
398 if (file_exists($dir))
401 if (!is_object($hookmanager))
403 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
406 $hookmanager->initHooks(array(
'pdfgeneration'));
407 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
409 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
414 $pdf->SetAutoPageBreak(1, 0);
416 $heightforinfotot = 40;
417 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
418 $heightforfooter = $this->marge_basse + 8;
420 if (class_exists(
'TCPDF'))
422 $pdf->setPrintHeader(
false);
423 $pdf->setPrintFooter(
false);
427 if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
429 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
430 $tplidx = $pdf->importPage(1);
435 $pdf->SetDrawColor(128, 128, 128);
437 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
438 $pdf->SetSubject($outputlangs->transnoentities(
"Stock"));
439 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
440 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
441 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Stock").
" ".$outputlangs->convToOutputCharset($object->label));
442 if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(
false);
444 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
449 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
451 $this->
_pagehead($pdf, $object, 1, $outputlangs);
452 $pdf->SetFont(
'',
'', $default_font_size - 1);
453 $pdf->MultiCell(0, 3,
'');
454 $pdf->SetTextColor(0, 0, 0);
457 $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
459 $tab_height_newpage = 150;
468 $nexY = $pdf->GetY();
472 $totalvalue = $totalvaluesell = 0;
473 $arrayofuniqueproduct = array();
482 for ($i = 0; $i < $nblines; $i++)
484 $objp = $this->
db->fetch_object(
$resql);
487 if (!empty($conf->global->MAIN_MULTILANGS))
489 $sql =
"SELECT label";
490 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
491 $sql .=
" WHERE fk_product=".$objp->rowid;
492 $sql .=
" AND lang='".$this->db->escape($langs->getDefaultLang()).
"'";
495 $result = $this->
db->query($sql);
498 $objtp = $this->
db->fetch_object($result);
499 if ($objtp->label !=
'') $objp->produit = $objtp->label;
504 $pdf->SetFont(
'',
'', $default_font_size - 1);
505 $pdf->SetTextColor(0, 0, 0);
507 $pdf->setTopMargin($tab_top_newpage);
508 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
509 $pageposbefore = $pdf->getPage();
512 $curX = $this->posxdesc - 1;
514 $showpricebeforepagebreak = 1;
516 $pdf->startTransaction();
517 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc);
518 $pageposafter = $pdf->getPage();
519 if ($pageposafter > $pageposbefore)
521 $pdf->rollbackTransaction(
true);
522 $pageposafter = $pageposbefore;
524 $pdf->setPageOrientation(
'', 1, $heightforfooter);
525 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc);
526 $pageposafter = $pdf->getPage();
527 $posyafter = $pdf->GetY();
528 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))
530 if ($i == ($nblines - 1))
532 $pdf->AddPage(
'',
'',
true);
533 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
534 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
535 $pdf->setPage($pageposafter + 1);
541 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
542 $showpricebeforepagebreak = 1;
543 else $showpricebeforepagebreak = 0;
547 $pdf->commitTransaction();
549 $posYAfterDescription = $pdf->GetY();
551 $nexY = $pdf->GetY();
552 $pageposafter = $pdf->getPage();
554 $pdf->setPage($pageposbefore);
555 $pdf->setTopMargin($this->marge_haute);
556 $pdf->setPageOrientation(
'', 1, 0);
559 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
560 $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
563 $pdf->SetFont(
'',
'', $default_font_size - 1);
567 $userstatic->id = $objp->fk_user_author;
568 $userstatic->login = $objp->login;
569 $userstatic->lastname = $objp->lastname;
570 $userstatic->firstname = $objp->firstname;
571 $userstatic->photo = $objp->photo;
573 $productstatic->id = $objp->rowid;
574 $productstatic->ref = $objp->product_ref;
575 $productstatic->label = $objp->produit;
576 $productstatic->type = $objp->type;
577 $productstatic->entity = $objp->entity;
578 $productstatic->status_batch = $objp->tobatch;
580 $productlot->id = $objp->lotid;
581 $productlot->batch = $objp->batch;
582 $productlot->eatby = $objp->eatby;
583 $productlot->sellby = $objp->sellby;
585 $warehousestatic->id = $objp->entrepot_id;
586 $warehousestatic->label = $objp->warehouse_ref;
587 $warehousestatic->lieu = $objp->lieu;
589 $arrayofuniqueproduct[$objp->rowid] = $objp->produit;
590 if (!empty($objp->fk_origin)) {
591 $origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
597 $pdf->SetXY($this->posxidref, $curY);
598 $pdf->MultiCell($this->posxdesc - $this->posxidref - 0.8, 3, $objp->mid, 0,
'L');
601 $pdf->SetXY($this->posxdatemouv, $curY);
602 $pdf->MultiCell($this->posxdesc - $this->posxdatemouv - 0.8, 6,
dol_print_date($this->
db->jdate($objp->datem),
'dayhour'), 0,
'L');
605 $pdf->SetXY($this->posxdesc, $curY);
606 $pdf->MultiCell($this->posxlabel - $this->posxdesc - 0.8, 3, $productstatic->ref, 0,
'L');
609 $pdf->SetXY($this->posxlabel + 0.8, $curY);
610 $pdf->MultiCell($this->posxqty - $this->posxlabel - 0.8, 6, $productstatic->label, 0,
'L');
613 $pdf->SetXY($this->posxqty, $curY);
614 $pdf->MultiCell($this->posxup - $this->posxqty - 0.8, 3, $productlot->batch, 0,
'R');
617 $pdf->SetXY($this->posxup, $curY);
618 $pdf->MultiCell($this->posxunit - $this->posxup - 0.8, 3, $objp->inventorycode, 0,
'R');
621 $pdf->SetXY($this->posxunit, $curY);
622 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 3, $objp->label, 0,
'R');
623 $totalvalue +=
price2num($objp->ppmp * $objp->value,
'MT');
626 $pricemin = $objp->price;
627 $pdf->SetXY($this->posxdiscount, $curY);
628 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 3, $origin, 0,
'R', 0);
631 $valtoshow =
price2num($objp->qty,
'MS');
632 $towrite = (empty($valtoshow) ?
'0' : $valtoshow);
633 $totalunit += $objp->qty;
635 $pdf->SetXY($this->postotalht, $curY);
636 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $objp->qty, 0,
'R', 0);
638 $totalvaluesell +=
price2num($pricemin * $objp->value,
'MT');
642 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
644 $pdf->setPage($pageposafter);
645 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
647 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
648 $pdf->SetLineStyle(array(
'dash'=>0));
654 while ($pagenb < $pageposafter)
656 $pdf->setPage($pagenb);
659 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
661 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
663 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
665 $pdf->setPage($pagenb);
666 $pdf->setPageOrientation(
'', 1, 0);
667 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
669 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
673 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
675 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
677 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
680 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
682 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
691 $nexY = $pdf->GetY();
695 $pdf->SetLineStyle(array(
'dash'=>
'0',
'color'=>array(220, 26, 26)));
696 $pdf->line($this->marge_gauche, $curY - 1, $this->page_largeur - $this->marge_droite, $curY - 1);
697 $pdf->SetLineStyle(array(
'dash'=>0));
699 $pdf->SetFont(
'',
'B', $default_font_size - 1);
700 $pdf->SetTextColor(0, 0, 120);
703 $pdf->SetXY($this->posxidref, $curY);
704 $pdf->MultiCell($this->posxdesc - $this->posxidref, 3, $langs->trans(
"Total"), 0,
'L');
707 $pdf->SetXY($this->postotalht, $curY);
708 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $totalunit, 0,
'R', 0);
722 $pdf->SetFont(
'',
'', $default_font_size - 1);
723 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
724 $nexY = $pdf->GetY();
725 $height_note = $nexY - $tab_top;
728 $pdf->SetDrawColor(192, 192, 192);
729 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
731 $tab_height = $tab_height - $height_note;
732 $tab_top = $nexY + 6;
737 $iniY = $tab_top + 7;
738 $curY = $tab_top + 7;
739 $nexY = $tab_top + 7;
741 $tab_top = $tab_top_newpage + 21;
746 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
747 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
749 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
750 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
753 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
762 $this->
_pagefoot($pdf, $object, $outputlangs);
763 if (method_exists($pdf,
'AliasNbPages')) $pdf->AliasNbPages();
767 $pdf->Output($file,
'F');
770 $hookmanager->initHooks(array(
'pdfgeneration'));
771 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
773 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
776 $this->error = $hookmanager->error;
777 $this->errors = $hookmanager->errors;
780 if (!empty($conf->global->MAIN_UMASK))
781 @chmod($file, octdec($conf->global->MAIN_UMASK));
783 $this->result = array(
'fullpath'=>$file);
787 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
791 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PRODUCT_OUTPUTDIR");
810 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
816 if ($hidetop) $hidetop = -1;
818 $currency = !empty($currency) ? $currency : $conf->currency;
822 $pdf->SetTextColor(0, 0, 0);
823 $pdf->SetFont(
'',
'', $default_font_size - 2);
827 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
828 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
829 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
832 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5,
'F', null, explode(
',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
835 $pdf->SetDrawColor(128, 128, 128);
836 $pdf->SetFont(
'',
'B', $default_font_size - 3);
841 $pdf->SetLineStyle(array(
'dash'=>
'0',
'color'=>array(220, 26, 26)));
842 $pdf->SetDrawColor(220, 26, 26);
843 $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite, $tab_top);
844 $pdf->SetLineStyle(array(
'dash'=>0));
845 $pdf->SetDrawColor(128, 128, 128);
846 $pdf->SetTextColor(0, 0, 120);
852 $pdf->SetXY($this->posxidref, $tab_top + 1);
853 $pdf->MultiCell($this->posxdatemouv - $this->posxdatemouv - 0.8, 3, $outputlangs->transnoentities(
"Ref"),
'',
'L');
860 $pdf->SetXY($this->posxdatemouv, $tab_top + 1);
861 $pdf->MultiCell($this->posxdesc - $this->posxdatemouv, 2, $outputlangs->transnoentities(
"Date"),
'',
'C');
868 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
869 $pdf->MultiCell($this->posxlabel - $this->posxdesc, 2, $outputlangs->transnoentities(
"Ref. Product"),
'',
'C');
876 $pdf->SetXY($this->posxlabel - 1, $tab_top + 1);
877 $pdf->MultiCell($this->posxqty - $this->posxlabel, 2, $outputlangs->transnoentities(
"Label"),
'',
'C');
884 $pdf->SetXY($this->posxqty, $tab_top + 1);
885 $pdf->MultiCell($this->posxup - $this->posxqty, 2, $outputlangs->transnoentities(
"Lot/Série"),
'',
'C');
892 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
893 $pdf->MultiCell($this->posxunit - $this->posxup, 2, $outputlangs->transnoentities(
"Inventory Code"),
'',
'C');
900 $pdf->SetXY($this->posxunit, $tab_top + 1);
901 $pdf->MultiCell($this->posxdiscount - $this->posxunit, 2, $outputlangs->transnoentities(
"Label Mouvement"),
'',
'C');
908 $pdf->SetXY($this->posxdiscount + 2, $tab_top + 1);
909 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 2, $outputlangs->transnoentities(
"Origin"),
'',
'C');
916 $pdf->SetXY($this->postotalht + 2, $tab_top + 1);
917 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
920 $pdf->SetDrawColor(220, 26, 26);
921 $pdf->SetLineStyle(array(
'dash'=>
'0',
'color'=>array(220, 26, 26)));
922 $pdf->line($this->marge_gauche, $tab_top + 11, $this->page_largeur - $this->marge_droite, $tab_top + 11);
923 $pdf->SetLineStyle(array(
'dash'=>0));
937 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey =
"")
939 global $conf, $langs, $db, $hookmanager;
942 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills",
"orders",
"stocks"));
946 if ($object->type == 1) $titlekey =
'ServiceSheet';
947 else $titlekey =
'StockSheet';
952 if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)))
954 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
957 $pdf->SetTextColor(0, 0, 60);
958 $pdf->SetFont(
'',
'B', $default_font_size + 3);
960 $posy = $this->marge_haute;
961 $posx = $this->page_largeur - $this->marge_droite - 100;
963 $pdf->SetXY($this->marge_gauche, $posy);
966 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
967 if ($this->emetteur->logo)
969 if (is_readable($logo))
972 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
974 $pdf->SetTextColor(200, 0, 0);
975 $pdf->SetFont(
'',
'B', $default_font_size - 2);
976 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
977 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
980 $text = $this->emetteur->name;
981 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
984 $pdf->SetFont(
'',
'B', $default_font_size + 3);
985 $pdf->SetXY($posx, $posy);
986 $pdf->SetTextColor(0, 0, 60);
987 $title = $outputlangs->transnoentities(
"Warehouse");
988 $pdf->MultiCell(100, 3, $title,
'',
'R');
990 $pdf->SetFont(
'',
'B', $default_font_size);
993 $pdf->SetXY($posx, $posy);
994 $pdf->SetTextColor(0, 0, 60);
996 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset($object->label),
'',
'R');
999 $pdf->SetFont(
'',
'', $default_font_size - 1);
1000 $pdf->SetXY($posx, $posy);
1001 $pdf->SetTextColor(0, 0, 60);
1002 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"LocationSummary").
' :',
'',
'R');
1005 $pdf->SetXY($posx - 50, $posy);
1006 $pdf->MultiCell(150, 3, $object->lieu,
'',
'R');
1011 $pdf->SetXY($posx, $posy);
1012 $pdf->SetTextColor(0, 0, 60);
1013 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ParentWarehouse").
' :',
'',
'R');
1016 $pdf->SetXY($posx - 50, $posy);
1018 if (!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0)
1020 $pdf->MultiCell(150, 3, $e->label,
'',
'R');
1022 $pdf->MultiCell(150, 3, $outputlangs->transnoentities(
"None"),
'',
'R');
1026 $nexY = $pdf->GetY();
1028 $pdf->SetXY($posx, $posy);
1029 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"Description").
' : </b>'.nl2br($object->description), 0, 1);
1030 $nexY = $pdf->GetY();
1032 $calcproductsunique = $object->nb_different_products();
1033 $calcproducts = $object->nb_products();
1036 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"NumberOfDifferentProducts").
' : </b>'.(empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb']), 0, 1);
1037 $nexY = $pdf->GetY();
1040 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
1041 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"NumberOfProducts").
' : </b>'.(empty($valtoshow) ?
'0' : $valtoshow), 0, 1);
1042 $nexY = $pdf->GetY();
1045 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"EstimatedStockValueShort").
' : </b>'.
price((empty($calcproducts[
'value']) ?
'0' :
price2num($calcproducts[
'value'],
'MT')), 0, $langs, 0, -1, -1, $conf->currency), 0, 1);
1046 $nexY = $pdf->GetY();
1050 $sql =
"SELECT max(m.datem) as datem";
1051 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
1052 $sql .=
" WHERE m.fk_entrepot = ".((int) $object->id);
1053 $resqlbis = $this->
db->query($sql);
1056 $obj = $this->
db->fetch_object($resqlbis);
1057 $lastmovementdate = $this->
db->jdate($obj->datem);
1062 if ($lastmovementdate)
1066 $toWrite = $outputlangs->transnoentities(
"None");
1069 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"LastMovement").
' : </b>'.$toWrite, 0, 1);
1070 $nexY = $pdf->GetY();
1143 $pdf->SetTextColor(0, 0, 0);
1156 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1159 $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1160 return pdf_pagefoot($pdf, $outputlangs,
'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
pdf_getFormat(Translate $outputlangs=null, $mode= 'setup')
Return array with format properties of default PDF format.
Parent class to manage warehouse mouvement document templates.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage stock movements.
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
Class to build documents using ODF templates generator.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
write_file($object, $outputlangs, $srctemplatepath, $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build a document on disk using the generic odt module.
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Class to manage products or services.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency= '')
Show table for lines.
Class to manage Dolibarr users.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom= 'UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
__construct($db)
Constructor.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0)
Show footer of page for PDF generation.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
natural_search($fields, $value, $mode=0, $nofirstand=0)
Generate natural SQL search string for a criteria (this criteria can be tested on one or several fiel...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
pdf_getInstance($format= '', $metric= 'mm', $pagetype= 'P')
Return a PDF instance object.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0)
Output line description into PDF.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Class to manage predefined suppliers products.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="")
Show top header of page.
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
Class to manage warehouses.