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';
58 public $update_main_doc_field;
69 public $version =
'dolibarr';
98 global $conf, $langs, $mysoc;
101 $langs->loadLangs(array(
"main",
"companies"));
104 $this->
name =
"stdmouvement";
105 $this->
description = $langs->trans(
"DocumentModelStandardPDF");
110 $this->page_largeur = $formatarray[
'width'];
111 $this->page_hauteur = $formatarray[
'height'];
112 $this->format = array($this->page_largeur, $this->page_hauteur);
118 $this->option_logo = 1;
119 $this->option_codestockservice = 0;
120 $this->option_multilang = 1;
121 $this->option_freetext = 0;
124 $this->emetteur = $mysoc;
125 if (empty($this->emetteur->country_code)) {
126 $this->emetteur->country_code = substr($langs->defaultlang, -2);
131 $this->posxidref = $this->marge_gauche;
132 $this->posxdatemouv = $this->marge_gauche + 8;
133 $this->posxdesc = 37;
134 $this->posxlabel = 50;
136 $this->posxqty = 105;
138 $this->posxunit = 136;
139 $this->posxdiscount = 167;
140 $this->postotalht = 180;
142 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
143 $this->posxtva = $this->posxup;
145 $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
146 if ($this->page_largeur < 210) {
147 $this->posxpicture -= 20;
148 $this->posxtva -= 20;
150 $this->posxqty -= 20;
151 $this->posxunit -= 20;
152 $this->posxdiscount -= 20;
153 $this->postotalht -= 20;
170 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
173 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
175 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
177 if (!is_object($outputlangs)) {
178 $outputlangs = $langs;
181 if (!empty($conf->global->MAIN_USE_FPDF)) {
182 $outputlangs->charset_output =
'ISO-8859-1';
186 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"stocks",
"orders",
"deliveries"));
193 $ref =
GETPOST(
'ref',
'alpha');
194 $msid =
GETPOST(
'msid',
'int');
195 $product_id =
GETPOST(
"product_id");
196 $action =
GETPOST(
'action',
'aZ09');
197 $cancel =
GETPOST(
'cancel',
'alpha');
198 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'movementlist';
200 $idproduct =
GETPOST(
'idproduct',
'int');
203 $search_ref =
GETPOST(
'search_ref',
'alpha');
204 $search_movement =
GETPOST(
"search_movement");
205 $search_product_ref = trim(
GETPOST(
"search_product_ref"));
206 $search_product = trim(
GETPOST(
"search_product"));
207 $search_warehouse = trim(
GETPOST(
"search_warehouse"));
208 $search_inventorycode = trim(
GETPOST(
"search_inventorycode"));
209 $search_user = trim(
GETPOST(
"search_user"));
210 $search_batch = trim(
GETPOST(
"search_batch"));
211 $search_qty = trim(
GETPOST(
"search_qty"));
212 $search_type_mouvement =
GETPOST(
'search_type_mouvement',
'int');
214 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
216 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
217 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
218 if (empty($page) || $page == -1) {
221 $offset = $limit * $page;
223 $sortfield =
"m.datem";
229 $pdluoid =
GETPOST(
'pdluoid',
'int');
232 $hookmanager->initHooks(array(
'movementlist'));
236 $extrafields->fetch_name_optionals_label(
'movement');
237 $search_array_options = $extrafields->getOptionalsFromPost(
'movement',
'',
'search_');
240 $productstatic =
new Product($this->db);
241 $warehousestatic =
new Entrepot($this->db);
243 $userstatic =
new User($this->db);
244 $element =
'movement';
246 $sql =
"SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
247 $sql .=
" e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,";
248 $sql .=
" m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
249 $sql .=
" m.batch, m.price,";
250 $sql .=
" m.type_mouvement,";
251 $sql .=
" pl.rowid as lotid, pl.eatby, pl.sellby,";
252 $sql .=
" u.login, u.photo, u.lastname, u.firstname";
254 if (!empty($extrafields->attributes[$element][
'label'])) {
255 foreach ($extrafields->attributes[$element][
'label'] as $key => $val) {
256 $sql .= ($extrafields->attributes[$element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
260 $parameters = array();
261 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
262 $sql .= $hookmanager->resPrint;
263 $sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e,";
264 $sql .=
" ".MAIN_DB_PREFIX.
"product as p,";
265 $sql .=
" ".MAIN_DB_PREFIX.
"stock_mouvement as m";
266 if (is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
267 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (m.rowid = ef.fk_object)";
269 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON m.fk_user_author = u.rowid";
270 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
271 $sql .=
" WHERE m.fk_product = p.rowid";
273 $sql .=
" AND m.rowid = ".((int) $msid);
275 $sql .=
" AND m.fk_entrepot = e.rowid";
276 $sql .=
" AND e.entity IN (".getEntity(
'stock').
")";
277 if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
278 $sql .=
" AND p.fk_product_type = 0";
281 $sql .=
" AND e.rowid = ".((int) $id);
287 $sql .=
" AND date_format(m.datem, '%m') = '".((int) $month).
"'";
289 } elseif ($year > 0) {
292 if ($idproduct > 0) {
293 $sql .=
" AND p.rowid = ".((int) $idproduct);
295 if (!empty($search_ref)) {
298 if (!empty($search_movement)) {
301 if (!empty($search_inventorycode)) {
304 if (!empty($search_product_ref)) {
307 if (!empty($search_product)) {
310 if ($search_warehouse > 0) {
311 $sql .=
" AND e.rowid = ".((int) $search_warehouse);
313 if (!empty($search_user)) {
316 if (!empty($search_batch)) {
319 if ($search_qty !=
'') {
322 if ($search_type_mouvement > 0) {
323 $sql .=
" AND m.type_mouvement = '".$this->db->escape($search_type_mouvement).
"'";
326 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
328 $parameters = array();
329 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
330 $sql .= $hookmanager->resPrint;
331 $sql .= $this->db->order($sortfield, $sortorder);
333 $nbtotalofrecords =
'';
335 $result = $this->db->query(
$sql);
336 $nbtotalofrecords = $this->db->num_rows($result);
337 if (($page * $limit) > $nbtotalofrecords) {
343 if (empty($search_inventorycode)) {
344 $sql .= $this->db->plimit($limit + 1, $offset);
348 $resql = $this->db->query(
$sql);
349 $nbtotalofrecords = $this->db->num_rows($result);
357 if ($conf->stock->dir_output) {
359 $product =
new Product($this->db);
362 if ($idproduct > 0) {
363 $product->fetch($idproduct);
365 if ($id > 0 || $ref) {
366 $result = $object->fetch($id, $ref);
372 $num = $this->db->num_rows($resql);
376 if ($object->specimen) {
377 $dir = $conf->stock->dir_output.
"/movement";
378 $file = $dir.
"/SPECIMEN.pdf";
381 if (!empty($search_inventorycode)) {
382 $objectref .=
"_".$id.
"_".$search_inventorycode;
384 if ($search_type_mouvement) {
385 $objectref .=
"_".$search_type_mouvement;
387 $dir = $conf->stock->dir_output.
"/movement/".$objectref;
388 $file = $dir.
"/".$objectref.
".pdf";
392 $supplierprices = $stockFournisseur->list_product_fournisseur_price($object->id);
393 $object->supplierprices = $supplierprices;
395 $productstatic =
new Product($this->db);
397 if (!file_exists($dir)) {
399 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
404 if (file_exists($dir)) {
406 if (!is_object($hookmanager)) {
407 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
410 $hookmanager->initHooks(array(
'pdfgeneration'));
411 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
413 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
418 $pdf->SetAutoPageBreak(1, 0);
420 $heightforinfotot = 40;
421 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
422 $heightforfooter = $this->marge_basse + 8;
424 if (class_exists(
'TCPDF')) {
425 $pdf->setPrintHeader(
false);
426 $pdf->setPrintFooter(
false);
430 if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
431 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
432 $tplidx = $pdf->importPage(1);
437 $pdf->SetDrawColor(128, 128, 128);
439 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
440 $pdf->SetSubject($outputlangs->transnoentities(
"Stock"));
441 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
442 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
443 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Stock").
" ".$outputlangs->convToOutputCharset($object->label));
445 $pdf->SetCompression(
false);
448 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
453 if (!empty($tplidx)) {
454 $pdf->useTemplate($tplidx);
457 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
458 $pdf->SetFont(
'',
'', $default_font_size - 1);
459 $pdf->MultiCell(0, 3,
'');
460 $pdf->SetTextColor(0, 0, 0);
463 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
465 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
469 $nexY = $tab_top - 1;
471 $nexY = $pdf->GetY();
475 $totalvalue = $totalvaluesell = 0;
476 $arrayofuniqueproduct = array();
479 $resql = $this->db->query(
$sql);
481 $num = $this->db->num_rows($resql);
484 for ($i = 0; $i < $nblines; $i++) {
485 $objp = $this->db->fetch_object($resql);
489 $sql =
"SELECT label";
490 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
491 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
492 $sql .=
" AND lang = '".$this->db->escape($langs->getDefaultLang()).
"'";
495 $result = $this->db->query(
$sql);
497 $objtp = $this->db->fetch_object($result);
498 if ($objtp->label !=
'') {
499 $objp->produit = $objtp->label;
505 $pdf->SetFont(
'',
'', $default_font_size - 1);
506 $pdf->SetTextColor(0, 0, 0);
508 $pdf->setTopMargin($tab_top_newpage);
509 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
510 $pageposbefore = $pdf->getPage();
513 $curX = $this->posxdesc - 1;
515 $showpricebeforepagebreak = 1;
517 $pdf->startTransaction();
518 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc);
519 $pageposafter = $pdf->getPage();
520 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))) {
529 if ($i == ($nblines - 1)) {
530 $pdf->AddPage(
'',
'',
true);
531 if (!empty($tplidx)) {
532 $pdf->useTemplate($tplidx);
535 $this->
_pagehead($pdf, $object, 0, $outputlangs);
537 $pdf->setPage($pageposafter + 1);
543 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
544 $showpricebeforepagebreak = 1;
546 $showpricebeforepagebreak = 0;
551 $pdf->commitTransaction();
553 $posYAfterDescription = $pdf->GetY();
555 $nexY = $pdf->GetY();
556 $pageposafter = $pdf->getPage();
558 $pdf->setPage($pageposbefore);
559 $pdf->setTopMargin($this->marge_haute);
560 $pdf->setPageOrientation(
'', 1, 0);
563 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
564 $pdf->setPage($pageposafter);
565 $curY = $tab_top_newpage;
568 $pdf->SetFont(
'',
'', $default_font_size - 1);
572 $userstatic->id = $objp->fk_user_author;
573 $userstatic->login = $objp->login;
574 $userstatic->lastname = $objp->lastname;
575 $userstatic->firstname = $objp->firstname;
576 $userstatic->photo = $objp->photo;
578 $productstatic->id = $objp->rowid;
579 $productstatic->ref = $objp->product_ref;
580 $productstatic->label = $objp->produit;
581 $productstatic->type = $objp->type;
582 $productstatic->entity = $objp->entity;
583 $productstatic->status_batch = $objp->tobatch;
585 $productlot->id = $objp->lotid;
586 $productlot->batch = $objp->batch;
587 $productlot->eatby = $objp->eatby;
588 $productlot->sellby = $objp->sellby;
590 $warehousestatic->id = $objp->entrepot_id;
591 $warehousestatic->label = $objp->warehouse_ref;
592 $warehousestatic->lieu = $objp->lieu;
594 $arrayofuniqueproduct[$objp->rowid] = $objp->produit;
595 if (!empty($objp->fk_origin)) {
596 $origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
602 $pdf->SetXY($this->posxidref, $curY);
603 $pdf->MultiCell($this->posxdesc - $this->posxidref - 0.8, 3, $objp->mid, 0,
'L');
606 $pdf->SetXY($this->posxdatemouv, $curY);
607 $pdf->MultiCell($this->posxdesc - $this->posxdatemouv - 0.8, 6,
dol_print_date($this->db->jdate($objp->datem),
'dayhour'), 0,
'L');
610 $pdf->SetXY($this->posxdesc, $curY);
611 $pdf->MultiCell($this->posxlabel - $this->posxdesc - 0.8, 3, $productstatic->ref, 0,
'L');
614 $pdf->SetXY($this->posxlabel + 0.8, $curY);
615 $pdf->MultiCell($this->posxqty - $this->posxlabel - 0.8, 6, $productstatic->label, 0,
'L');
618 $pdf->SetXY($this->posxqty, $curY);
619 $pdf->MultiCell($this->posxup - $this->posxqty - 0.8, 3, $productlot->batch, 0,
'R');
622 $pdf->SetXY($this->posxup, $curY);
623 $pdf->MultiCell($this->posxunit - $this->posxup - 0.8, 3, $objp->inventorycode, 0,
'R');
626 $pdf->SetXY($this->posxunit, $curY);
627 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 3, $objp->label, 0,
'R');
628 $totalvalue +=
price2num($objp->ppmp * $objp->value,
'MT');
631 $pricemin = $objp->price;
632 $pdf->SetXY($this->posxdiscount, $curY);
633 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 3, $origin, 0,
'R', 0);
636 $valtoshow =
price2num($objp->qty,
'MS');
637 $towrite = (empty($valtoshow) ?
'0' : $valtoshow);
638 $totalunit += $objp->qty;
640 $pdf->SetXY($this->postotalht, $curY);
641 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $objp->qty, 0,
'R', 0);
643 $totalvaluesell +=
price2num($pricemin * $objp->value,
'MT');
647 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
648 $pdf->setPage($pageposafter);
649 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
651 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
652 $pdf->SetLineStyle(array(
'dash'=>0));
658 while ($pagenb < $pageposafter) {
659 $pdf->setPage($pagenb);
661 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
663 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
665 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
667 $pdf->setPage($pagenb);
668 $pdf->setPageOrientation(
'', 1, 0);
670 $this->
_pagehead($pdf, $object, 0, $outputlangs);
672 if (!empty($tplidx)) {
673 $pdf->useTemplate($tplidx);
676 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
678 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
680 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
682 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
685 if (!empty($tplidx)) {
686 $pdf->useTemplate($tplidx);
690 $this->
_pagehead($pdf, $object, 0, $outputlangs);
695 $this->db->free($resql);
700 $nexY = $pdf->GetY();
704 $pdf->SetLineStyle(array(
'dash'=>
'0',
'color'=>array(220, 26, 26)));
705 $pdf->line($this->marge_gauche, $curY - 1, $this->page_largeur - $this->marge_droite, $curY - 1);
706 $pdf->SetLineStyle(array(
'dash'=>0));
708 $pdf->SetFont(
'',
'B', $default_font_size - 1);
709 $pdf->SetTextColor(0, 0, 120);
712 $pdf->SetXY($this->posxidref, $curY);
713 $pdf->MultiCell($this->posxdesc - $this->posxidref, 3, $langs->trans(
"Total"), 0,
'L');
716 $pdf->SetXY($this->postotalht, $curY);
717 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $totalunit, 0,
'R', 0);
730 $pdf->SetFont(
'',
'', $default_font_size - 1);
731 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
732 $nexY = $pdf->GetY();
733 $height_note = $nexY - $tab_top;
736 $pdf->SetDrawColor(192, 192, 192);
737 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
739 $tab_height = $tab_height - $height_note;
740 $tab_top = $nexY + 6;
745 $iniY = $tab_top + 7;
746 $curY = $tab_top + 7;
747 $nexY = $tab_top + 7;
749 $tab_top = $tab_top_newpage + 21;
753 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
754 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
756 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
757 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
760 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
769 $this->
_pagefoot($pdf, $object, $outputlangs);
770 if (method_exists($pdf,
'AliasNbPages')) {
771 $pdf->AliasNbPages();
776 $pdf->Output($file,
'F');
779 $hookmanager->initHooks(array(
'pdfgeneration'));
780 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
782 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
784 $this->error = $hookmanager->error;
785 $this->errors = $hookmanager->errors;
790 $this->result = array(
'fullpath'=>$file);
794 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
798 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PRODUCT_OUTPUTDIR");
817 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
827 $currency = !empty($currency) ? $currency : $conf->currency;
831 $pdf->SetTextColor(0, 0, 0);
832 $pdf->SetFont(
'',
'', $default_font_size - 2);
834 if (empty($hidetop)) {
835 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
836 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
837 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
840 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
841 $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));
845 $pdf->SetDrawColor(128, 128, 128);
846 $pdf->SetFont(
'',
'B', $default_font_size - 3);
851 $pdf->SetLineStyle(array(
'dash'=>
'0',
'color'=>array(220, 26, 26)));
852 $pdf->SetDrawColor(220, 26, 26);
853 $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite, $tab_top);
854 $pdf->SetLineStyle(array(
'dash'=>0));
855 $pdf->SetDrawColor(128, 128, 128);
856 $pdf->SetTextColor(0, 0, 120);
859 if (empty($hidetop)) {
861 $pdf->SetXY($this->posxidref, $tab_top + 1);
862 $pdf->MultiCell($this->posxdatemouv - $this->posxdatemouv - 0.8, 3, $outputlangs->transnoentities(
"Ref"),
'',
'L');
867 if (empty($hidetop)) {
868 $pdf->SetXY($this->posxdatemouv, $tab_top + 1);
869 $pdf->MultiCell($this->posxdesc - $this->posxdatemouv, 2, $outputlangs->transnoentities(
"Date"),
'',
'C');
874 if (empty($hidetop)) {
875 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
876 $pdf->MultiCell($this->posxlabel - $this->posxdesc, 2, $outputlangs->transnoentities(
"Ref. Product"),
'',
'C');
881 if (empty($hidetop)) {
882 $pdf->SetXY($this->posxlabel - 1, $tab_top + 1);
883 $pdf->MultiCell($this->posxqty - $this->posxlabel, 2, $outputlangs->transnoentities(
"Label"),
'',
'C');
888 if (empty($hidetop)) {
889 $pdf->SetXY($this->posxqty, $tab_top + 1);
890 $pdf->MultiCell($this->posxup - $this->posxqty, 2, $outputlangs->transnoentities(
"Lot/Série"),
'',
'C');
895 if (empty($hidetop)) {
896 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
897 $pdf->MultiCell($this->posxunit - $this->posxup, 2, $outputlangs->transnoentities(
"Inventory Code"),
'',
'C');
902 if (empty($hidetop)) {
903 $pdf->SetXY($this->posxunit, $tab_top + 1);
904 $pdf->MultiCell($this->posxdiscount - $this->posxunit, 2, $outputlangs->transnoentities(
"Label Mouvement"),
'',
'C');
909 if (empty($hidetop)) {
910 $pdf->SetXY($this->posxdiscount + 2, $tab_top + 1);
911 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 2, $outputlangs->transnoentities(
"Origin"),
'',
'C');
916 if (empty($hidetop)) {
917 $pdf->SetXY($this->postotalht + 2, $tab_top + 1);
918 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
921 $pdf->SetDrawColor(220, 26, 26);
922 $pdf->SetLineStyle(array(
'dash'=>
'0',
'color'=>array(220, 26, 26)));
923 $pdf->line($this->marge_gauche, $tab_top + 11, $this->page_largeur - $this->marge_droite, $tab_top + 11);
924 $pdf->SetLineStyle(array(
'dash'=>0));
938 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey =
"")
940 global $conf, $langs, $db, $hookmanager;
943 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills",
"orders",
"stocks"));
947 if ($object->type == 1) {
948 $titlekey =
'ServiceSheet';
950 $titlekey =
'StockSheet';
960 $pdf->SetTextColor(0, 0, 60);
961 $pdf->SetFont(
'',
'B', $default_font_size + 3);
963 $posy = $this->marge_haute;
964 $posx = $this->page_largeur - $this->marge_droite - 100;
966 $pdf->SetXY($this->marge_gauche, $posy);
969 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
970 if ($this->emetteur->logo) {
971 if (is_readable($logo)) {
973 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
975 $pdf->SetTextColor(200, 0, 0);
976 $pdf->SetFont(
'',
'B', $default_font_size - 2);
977 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
978 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
981 $text = $this->emetteur->name;
982 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
985 $pdf->SetFont(
'',
'B', $default_font_size + 3);
986 $pdf->SetXY($posx, $posy);
987 $pdf->SetTextColor(0, 0, 60);
988 $title = $outputlangs->transnoentities(
"Warehouse");
989 $pdf->MultiCell(100, 3, $title,
'',
'R');
991 $pdf->SetFont(
'',
'B', $default_font_size);
994 $pdf->SetXY($posx, $posy);
995 $pdf->SetTextColor(0, 0, 60);
997 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset($object->label),
'',
'R');
1000 $pdf->SetFont(
'',
'', $default_font_size - 1);
1001 $pdf->SetXY($posx, $posy);
1002 $pdf->SetTextColor(0, 0, 60);
1003 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"LocationSummary").
' :',
'',
'R');
1006 $pdf->SetXY($posx - 50, $posy);
1007 $pdf->MultiCell(150, 3, $object->lieu,
'',
'R');
1012 $pdf->SetXY($posx, $posy);
1013 $pdf->SetTextColor(0, 0, 60);
1014 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ParentWarehouse").
' :',
'',
'R');
1017 $pdf->SetXY($posx - 50, $posy);
1019 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);
1055 $obj = $this->db->fetch_object($resqlbis);
1056 $lastmovementdate = $this->db->jdate($obj->datem);
1061 if ($lastmovementdate) {
1064 $toWrite = $outputlangs->transnoentities(
"None");
1067 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"LastMovement").
' : </b>'.$toWrite, 0, 1);
1068 $nexY = $pdf->GetY();
1105 $current_y = $pdf->getY();
1145 $pdf->SetTextColor(0, 0, 0);
1159 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1161 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1162 return pdf_pagefoot($pdf, $outputlangs,
'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
Class to manage warehouses.
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.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
dol_get_first_day($year, $month=1, $gm=false)
Return GMT time for first day of a month or year.
dol_get_last_day($year, $month=12, $gm=false)
Return GMT time for last day of a month or year.
print *****$script_file(".$version.") pid 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 dolibarr global constant int value.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
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.
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0)
Output line description into PDF.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
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.
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
Return array of possible substitutions for PDF content (without external module substitutions).
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.