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 $phpmin = array(7, 0);
75 public $version =
'dolibarr';
104 global $conf, $langs, $mysoc;
107 $langs->loadLangs(array(
"main",
"companies"));
110 $this->
name =
"stdmouvement";
111 $this->
description = $langs->trans(
"DocumentModelStandardPDF");
116 $this->page_largeur = $formatarray[
'width'];
117 $this->page_hauteur = $formatarray[
'height'];
118 $this->format = array($this->page_largeur, $this->page_hauteur);
124 $this->option_logo = 1;
125 $this->option_codestockservice = 0;
126 $this->option_multilang = 1;
127 $this->option_freetext = 0;
130 $this->emetteur = $mysoc;
131 if (empty($this->emetteur->country_code)) {
132 $this->emetteur->country_code = substr($langs->defaultlang, -2);
137 $this->posxidref = $this->marge_gauche;
138 $this->posxdatemouv = $this->marge_gauche + 8;
139 $this->posxdesc = 37;
140 $this->posxlabel = 50;
142 $this->posxqty = 105;
144 $this->posxunit = 136;
145 $this->posxdiscount = 167;
146 $this->postotalht = 180;
148 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
149 $this->posxtva = $this->posxup;
151 $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
152 if ($this->page_largeur < 210) {
153 $this->posxpicture -= 20;
154 $this->posxtva -= 20;
156 $this->posxqty -= 20;
157 $this->posxunit -= 20;
158 $this->posxdiscount -= 20;
159 $this->postotalht -= 20;
176 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
179 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
181 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
183 if (!is_object($outputlangs)) {
184 $outputlangs = $langs;
187 if (!empty($conf->global->MAIN_USE_FPDF)) {
188 $outputlangs->charset_output =
'ISO-8859-1';
192 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"stocks",
"orders",
"deliveries"));
199 $ref =
GETPOST(
'ref',
'alpha');
200 $msid =
GETPOST(
'msid',
'int');
201 $product_id =
GETPOST(
"product_id");
202 $action =
GETPOST(
'action',
'aZ09');
203 $cancel =
GETPOST(
'cancel',
'alpha');
204 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'movementlist';
206 $idproduct =
GETPOST(
'idproduct',
'int');
209 $search_ref =
GETPOST(
'search_ref',
'alpha');
210 $search_movement =
GETPOST(
"search_movement");
211 $search_product_ref = trim(
GETPOST(
"search_product_ref"));
212 $search_product = trim(
GETPOST(
"search_product"));
213 $search_warehouse = trim(
GETPOST(
"search_warehouse"));
214 $search_inventorycode = trim(
GETPOST(
"search_inventorycode"));
215 $search_user = trim(
GETPOST(
"search_user"));
216 $search_batch = trim(
GETPOST(
"search_batch"));
217 $search_qty = trim(
GETPOST(
"search_qty"));
218 $search_type_mouvement =
GETPOST(
'search_type_mouvement',
'int');
220 $limit =
GETPOST(
'limit',
'int') ?
GETPOST(
'limit',
'int') : $conf->liste_limit;
222 $sortfield =
GETPOST(
'sortfield',
'aZ09comma');
223 $sortorder =
GETPOST(
'sortorder',
'aZ09comma');
224 if (empty($page) || $page == -1) {
227 $offset = $limit * $page;
229 $sortfield =
"m.datem";
235 $pdluoid =
GETPOST(
'pdluoid',
'int');
238 $hookmanager->initHooks(array(
'movementlist'));
242 $extrafields->fetch_name_optionals_label(
'movement');
243 $search_array_options = $extrafields->getOptionalsFromPost(
'movement',
'',
'search_');
245 $productlot =
new ProductLot($this->
db);
249 $userstatic =
new User($this->
db);
250 $element =
'movement';
252 $sql =
"SELECT p.rowid, p.ref as product_ref, p.label as produit, p.tobatch, p.fk_product_type as type, p.entity,";
253 $sql .=
" e.ref as warehouse_ref, e.rowid as entrepot_id, e.lieu,";
254 $sql .=
" m.rowid as mid, m.value as qty, m.datem, m.fk_user_author, m.label, m.inventorycode, m.fk_origin, m.origintype,";
255 $sql .=
" m.batch, m.price,";
256 $sql .=
" m.type_mouvement,";
257 $sql .=
" pl.rowid as lotid, pl.eatby, pl.sellby,";
258 $sql .=
" u.login, u.photo, u.lastname, u.firstname";
260 if (!empty($extrafields->attributes[$element][
'label'])) {
261 foreach ($extrafields->attributes[$element][
'label'] as $key => $val) {
262 $sql .= ($extrafields->attributes[$element][
'type'][$key] !=
'separate' ?
", ef.".$key.
" as options_".$key :
'');
266 $parameters = array();
267 $reshook = $hookmanager->executeHooks(
'printFieldListSelect', $parameters);
268 $sql .= $hookmanager->resPrint;
269 $sql .=
" FROM ".MAIN_DB_PREFIX.
"entrepot as e,";
270 $sql .=
" ".MAIN_DB_PREFIX.
"product as p,";
271 $sql .=
" ".MAIN_DB_PREFIX.
"stock_mouvement as m";
272 if (is_array($extrafields->attributes[$object->table_element][
'label']) && count($extrafields->attributes[$object->table_element][
'label'])) {
273 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.$object->table_element.
"_extrafields as ef on (m.rowid = ef.fk_object)";
275 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"user as u ON m.fk_user_author = u.rowid";
276 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"product_lot as pl ON m.batch = pl.batch AND m.fk_product = pl.fk_product";
277 $sql .=
" WHERE m.fk_product = p.rowid";
279 $sql .=
" AND m.rowid = ".((int) $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)) {
284 $sql .=
" AND p.fk_product_type = 0";
287 $sql .=
" AND e.rowid = ".((int) $id);
293 $sql .=
" AND date_format(m.datem, '%m') = '".((int) $month).
"'";
295 } elseif ($year > 0) {
298 if ($idproduct > 0) {
299 $sql .=
" AND p.rowid = ".((int) $idproduct);
301 if (!empty($search_ref)) {
304 if (!empty($search_movement)) {
307 if (!empty($search_inventorycode)) {
310 if (!empty($search_product_ref)) {
313 if (!empty($search_product)) {
316 if ($search_warehouse > 0) {
317 $sql .=
" AND e.rowid = ".((int) $search_warehouse);
319 if (!empty($search_user)) {
322 if (!empty($search_batch)) {
325 if ($search_qty !=
'') {
328 if ($search_type_mouvement > 0) {
329 $sql .=
" AND m.type_mouvement = '".$this->db->escape($search_type_mouvement).
"'";
332 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_list_search_sql.tpl.php';
334 $parameters = array();
335 $reshook = $hookmanager->executeHooks(
'printFieldListWhere', $parameters);
336 $sql .= $hookmanager->resPrint;
337 $sql .= $this->
db->order($sortfield, $sortorder);
340 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
341 $result = $this->
db->query($sql);
349 if (empty($search_inventorycode)) {
350 $sql .= $this->
db->plimit($limit + 1, $offset);
363 if ($conf->stock->dir_output) {
368 if ($idproduct > 0) {
369 $product->fetch($idproduct);
371 if ($id > 0 || $ref) {
372 $result = $object->fetch($id, $ref);
382 if ($object->specimen) {
383 $dir = $conf->stock->dir_output.
"/movement";
384 $file = $dir.
"/SPECIMEN.pdf";
387 if (!empty($search_inventorycode)) {
388 $objectref .=
"_".$id.
"_".$search_inventorycode;
390 if ($search_type_mouvement) {
391 $objectref .=
"_".$search_type_mouvement;
393 $dir = $conf->stock->dir_output.
"/movement/".$objectref;
394 $file = $dir.
"/".$objectref.
".pdf";
398 $supplierprices = $stockFournisseur->list_product_fournisseur_price($object->id);
399 $object->supplierprices = $supplierprices;
403 if (!file_exists($dir)) {
405 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
410 if (file_exists($dir)) {
412 if (!is_object($hookmanager)) {
413 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
416 $hookmanager->initHooks(array(
'pdfgeneration'));
417 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
419 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
424 $pdf->SetAutoPageBreak(1, 0);
426 $heightforinfotot = 40;
427 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
428 $heightforfooter = $this->marge_basse + 8;
430 if (class_exists(
'TCPDF')) {
431 $pdf->setPrintHeader(
false);
432 $pdf->setPrintFooter(
false);
436 if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
437 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
438 $tplidx = $pdf->importPage(1);
443 $pdf->SetDrawColor(128, 128, 128);
445 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
446 $pdf->SetSubject($outputlangs->transnoentities(
"Stock"));
447 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
448 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
449 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Stock").
" ".$outputlangs->convToOutputCharset($object->label));
451 $pdf->SetCompression(
false);
454 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
459 if (!empty($tplidx)) {
460 $pdf->useTemplate($tplidx);
463 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
464 $pdf->SetFont(
'',
'', $default_font_size - 1);
465 $pdf->MultiCell(0, 3,
'');
466 $pdf->SetTextColor(0, 0, 0);
469 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
471 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
475 $nexY = $tab_top - 1;
477 $nexY = $pdf->GetY();
481 $totalvalue = $totalvaluesell = 0;
482 $arrayofuniqueproduct = array();
490 for ($i = 0; $i < $nblines; $i++) {
491 $objp = $this->
db->fetch_object(
$resql);
495 $sql =
"SELECT label";
496 $sql .=
" FROM ".MAIN_DB_PREFIX.
"product_lang";
497 $sql .=
" WHERE fk_product = ".((int) $objp->rowid);
498 $sql .=
" AND lang = '".$this->db->escape($langs->getDefaultLang()).
"'";
501 $result = $this->
db->query($sql);
503 $objtp = $this->
db->fetch_object($result);
504 if ($objtp->label !=
'') {
505 $objp->produit = $objtp->label;
511 $pdf->SetFont(
'',
'', $default_font_size - 1);
512 $pdf->SetTextColor(0, 0, 0);
514 $pdf->setTopMargin($tab_top_newpage);
515 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
516 $pageposbefore = $pdf->getPage();
519 $curX = $this->posxdesc - 1;
521 $showpricebeforepagebreak = 1;
523 $pdf->startTransaction();
524 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc);
525 $pageposafter = $pdf->getPage();
526 if ($pageposafter > $pageposbefore) {
527 $pdf->rollbackTransaction(
true);
528 $pageposafter = $pageposbefore;
530 $pdf->setPageOrientation(
'', 1, $heightforfooter);
531 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc);
532 $pageposafter = $pdf->getPage();
533 $posyafter = $pdf->GetY();
534 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
535 if ($i == ($nblines - 1)) {
536 $pdf->AddPage(
'',
'',
true);
537 if (!empty($tplidx)) {
538 $pdf->useTemplate($tplidx);
541 $this->
_pagehead($pdf, $object, 0, $outputlangs);
543 $pdf->setPage($pageposafter + 1);
549 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
550 $showpricebeforepagebreak = 1;
552 $showpricebeforepagebreak = 0;
557 $pdf->commitTransaction();
559 $posYAfterDescription = $pdf->GetY();
561 $nexY = $pdf->GetY();
562 $pageposafter = $pdf->getPage();
564 $pdf->setPage($pageposbefore);
565 $pdf->setTopMargin($this->marge_haute);
566 $pdf->setPageOrientation(
'', 1, 0);
569 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
570 $pdf->setPage($pageposafter);
571 $curY = $tab_top_newpage;
574 $pdf->SetFont(
'',
'', $default_font_size - 1);
578 $userstatic->id = $objp->fk_user_author;
579 $userstatic->login = $objp->login;
580 $userstatic->lastname = $objp->lastname;
581 $userstatic->firstname = $objp->firstname;
582 $userstatic->photo = $objp->photo;
584 $productstatic->id = $objp->rowid;
585 $productstatic->ref = $objp->product_ref;
586 $productstatic->label = $objp->produit;
587 $productstatic->type = $objp->type;
588 $productstatic->entity = $objp->entity;
589 $productstatic->status_batch = $objp->tobatch;
591 $productlot->id = $objp->lotid;
592 $productlot->batch = $objp->batch;
593 $productlot->eatby = $objp->eatby;
594 $productlot->sellby = $objp->sellby;
596 $warehousestatic->id = $objp->entrepot_id;
597 $warehousestatic->label = $objp->warehouse_ref;
598 $warehousestatic->lieu = $objp->lieu;
600 $arrayofuniqueproduct[$objp->rowid] = $objp->produit;
601 if (!empty($objp->fk_origin)) {
602 $origin = $movement->get_origin($objp->fk_origin, $objp->origintype);
608 $pdf->SetXY($this->posxidref, $curY);
609 $pdf->MultiCell($this->posxdesc - $this->posxidref - 0.8, 3, $objp->mid, 0,
'L');
612 $pdf->SetXY($this->posxdatemouv, $curY);
613 $pdf->MultiCell($this->posxdesc - $this->posxdatemouv - 0.8, 6,
dol_print_date($this->
db->jdate($objp->datem),
'dayhour'), 0,
'L');
616 $pdf->SetXY($this->posxdesc, $curY);
617 $pdf->MultiCell($this->posxlabel - $this->posxdesc - 0.8, 3, $productstatic->ref, 0,
'L');
620 $pdf->SetXY($this->posxlabel + 0.8, $curY);
621 $pdf->MultiCell($this->posxqty - $this->posxlabel - 0.8, 6, $productstatic->label, 0,
'L');
624 $pdf->SetXY($this->posxqty, $curY);
625 $pdf->MultiCell($this->posxup - $this->posxqty - 0.8, 3, $productlot->batch, 0,
'R');
628 $pdf->SetXY($this->posxup, $curY);
629 $pdf->MultiCell($this->posxunit - $this->posxup - 0.8, 3, $objp->inventorycode, 0,
'R');
632 $pdf->SetXY($this->posxunit, $curY);
633 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 3, $objp->label, 0,
'R');
634 $totalvalue +=
price2num($objp->ppmp * $objp->value,
'MT');
637 $pricemin = $objp->price;
638 $pdf->SetXY($this->posxdiscount, $curY);
639 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 3, $origin, 0,
'R', 0);
642 $valtoshow =
price2num($objp->qty,
'MS');
643 $towrite = (empty($valtoshow) ?
'0' : $valtoshow);
644 $totalunit += $objp->qty;
646 $pdf->SetXY($this->postotalht, $curY);
647 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $objp->qty, 0,
'R', 0);
649 $totalvaluesell +=
price2num($pricemin * $objp->value,
'MT');
653 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
654 $pdf->setPage($pageposafter);
655 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
657 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
658 $pdf->SetLineStyle(array(
'dash'=>0));
664 while ($pagenb < $pageposafter) {
665 $pdf->setPage($pagenb);
667 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
669 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
671 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
673 $pdf->setPage($pagenb);
674 $pdf->setPageOrientation(
'', 1, 0);
676 $this->
_pagehead($pdf, $object, 0, $outputlangs);
678 if (!empty($tplidx)) {
679 $pdf->useTemplate($tplidx);
682 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
684 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
686 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
688 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
691 if (!empty($tplidx)) {
692 $pdf->useTemplate($tplidx);
696 $this->
_pagehead($pdf, $object, 0, $outputlangs);
706 $nexY = $pdf->GetY();
710 $pdf->SetLineStyle(array(
'dash'=>
'0',
'color'=>array(220, 26, 26)));
711 $pdf->line($this->marge_gauche, $curY - 1, $this->page_largeur - $this->marge_droite, $curY - 1);
712 $pdf->SetLineStyle(array(
'dash'=>0));
714 $pdf->SetFont(
'',
'B', $default_font_size - 1);
715 $pdf->SetTextColor(0, 0, 120);
718 $pdf->SetXY($this->posxidref, $curY);
719 $pdf->MultiCell($this->posxdesc - $this->posxidref, 3, $langs->trans(
"Total"), 0,
'L');
722 $pdf->SetXY($this->postotalht, $curY);
723 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $totalunit, 0,
'R', 0);
736 $pdf->SetFont(
'',
'', $default_font_size - 1);
737 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
738 $nexY = $pdf->GetY();
739 $height_note = $nexY - $tab_top;
742 $pdf->SetDrawColor(192, 192, 192);
743 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
745 $tab_height = $tab_height - $height_note;
746 $tab_top = $nexY + 6;
751 $iniY = $tab_top + 7;
752 $curY = $tab_top + 7;
753 $nexY = $tab_top + 7;
755 $tab_top = $tab_top_newpage + 21;
759 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
760 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
762 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
763 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
766 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
775 $this->
_pagefoot($pdf, $object, $outputlangs);
776 if (method_exists($pdf,
'AliasNbPages')) {
777 $pdf->AliasNbPages();
782 $pdf->Output($file,
'F');
785 $hookmanager->initHooks(array(
'pdfgeneration'));
786 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
788 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
790 $this->error = $hookmanager->error;
791 $this->errors = $hookmanager->errors;
794 if (!empty($conf->global->MAIN_UMASK)) {
795 @chmod($file, octdec($conf->global->MAIN_UMASK));
798 $this->result = array(
'fullpath'=>$file);
802 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
806 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PRODUCT_OUTPUTDIR");
825 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
835 $currency = !empty($currency) ? $currency : $conf->currency;
839 $pdf->SetTextColor(0, 0, 0);
840 $pdf->SetFont(
'',
'', $default_font_size - 2);
842 if (empty($hidetop)) {
843 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
844 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
845 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
848 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
849 $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));
853 $pdf->SetDrawColor(128, 128, 128);
854 $pdf->SetFont(
'',
'B', $default_font_size - 3);
859 $pdf->SetLineStyle(array(
'dash'=>
'0',
'color'=>array(220, 26, 26)));
860 $pdf->SetDrawColor(220, 26, 26);
861 $pdf->line($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite, $tab_top);
862 $pdf->SetLineStyle(array(
'dash'=>0));
863 $pdf->SetDrawColor(128, 128, 128);
864 $pdf->SetTextColor(0, 0, 120);
867 if (empty($hidetop)) {
869 $pdf->SetXY($this->posxidref, $tab_top + 1);
870 $pdf->MultiCell($this->posxdatemouv - $this->posxdatemouv - 0.8, 3, $outputlangs->transnoentities(
"Ref"),
'',
'L');
875 if (empty($hidetop)) {
876 $pdf->SetXY($this->posxdatemouv, $tab_top + 1);
877 $pdf->MultiCell($this->posxdesc - $this->posxdatemouv, 2, $outputlangs->transnoentities(
"Date"),
'',
'C');
882 if (empty($hidetop)) {
883 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
884 $pdf->MultiCell($this->posxlabel - $this->posxdesc, 2, $outputlangs->transnoentities(
"Ref. Product"),
'',
'C');
889 if (empty($hidetop)) {
890 $pdf->SetXY($this->posxlabel - 1, $tab_top + 1);
891 $pdf->MultiCell($this->posxqty - $this->posxlabel, 2, $outputlangs->transnoentities(
"Label"),
'',
'C');
896 if (empty($hidetop)) {
897 $pdf->SetXY($this->posxqty, $tab_top + 1);
898 $pdf->MultiCell($this->posxup - $this->posxqty, 2, $outputlangs->transnoentities(
"Lot/Série"),
'',
'C');
903 if (empty($hidetop)) {
904 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
905 $pdf->MultiCell($this->posxunit - $this->posxup, 2, $outputlangs->transnoentities(
"Inventory Code"),
'',
'C');
910 if (empty($hidetop)) {
911 $pdf->SetXY($this->posxunit, $tab_top + 1);
912 $pdf->MultiCell($this->posxdiscount - $this->posxunit, 2, $outputlangs->transnoentities(
"Label Mouvement"),
'',
'C');
917 if (empty($hidetop)) {
918 $pdf->SetXY($this->posxdiscount + 2, $tab_top + 1);
919 $pdf->MultiCell($this->postotalht - $this->posxdiscount - 0.8, 2, $outputlangs->transnoentities(
"Origin"),
'',
'C');
924 if (empty($hidetop)) {
925 $pdf->SetXY($this->postotalht + 2, $tab_top + 1);
926 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
929 $pdf->SetDrawColor(220, 26, 26);
930 $pdf->SetLineStyle(array(
'dash'=>
'0',
'color'=>array(220, 26, 26)));
931 $pdf->line($this->marge_gauche, $tab_top + 11, $this->page_largeur - $this->marge_droite, $tab_top + 11);
932 $pdf->SetLineStyle(array(
'dash'=>0));
946 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey =
"")
948 global $conf, $langs, $db, $hookmanager;
951 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills",
"orders",
"stocks"));
955 if ($object->type == 1) {
956 $titlekey =
'ServiceSheet';
958 $titlekey =
'StockSheet';
964 if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) {
965 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
968 $pdf->SetTextColor(0, 0, 60);
969 $pdf->SetFont(
'',
'B', $default_font_size + 3);
971 $posy = $this->marge_haute;
972 $posx = $this->page_largeur - $this->marge_droite - 100;
974 $pdf->SetXY($this->marge_gauche, $posy);
977 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
978 if ($this->emetteur->logo) {
979 if (is_readable($logo)) {
981 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
983 $pdf->SetTextColor(200, 0, 0);
984 $pdf->SetFont(
'',
'B', $default_font_size - 2);
985 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
986 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
989 $text = $this->emetteur->name;
990 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
993 $pdf->SetFont(
'',
'B', $default_font_size + 3);
994 $pdf->SetXY($posx, $posy);
995 $pdf->SetTextColor(0, 0, 60);
996 $title = $outputlangs->transnoentities(
"Warehouse");
997 $pdf->MultiCell(100, 3, $title,
'',
'R');
999 $pdf->SetFont(
'',
'B', $default_font_size);
1002 $pdf->SetXY($posx, $posy);
1003 $pdf->SetTextColor(0, 0, 60);
1005 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset($object->label),
'',
'R');
1008 $pdf->SetFont(
'',
'', $default_font_size - 1);
1009 $pdf->SetXY($posx, $posy);
1010 $pdf->SetTextColor(0, 0, 60);
1011 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"LocationSummary").
' :',
'',
'R');
1014 $pdf->SetXY($posx - 50, $posy);
1015 $pdf->MultiCell(150, 3, $object->lieu,
'',
'R');
1020 $pdf->SetXY($posx, $posy);
1021 $pdf->SetTextColor(0, 0, 60);
1022 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ParentWarehouse").
' :',
'',
'R');
1025 $pdf->SetXY($posx - 50, $posy);
1027 if (!empty($object->fk_parent) && $e->fetch($object->fk_parent) > 0) {
1028 $pdf->MultiCell(150, 3, $e->label,
'',
'R');
1030 $pdf->MultiCell(150, 3, $outputlangs->transnoentities(
"None"),
'',
'R');
1034 $nexY = $pdf->GetY();
1036 $pdf->SetXY($posx, $posy);
1037 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"Description").
' : </b>'.nl2br($object->description), 0, 1);
1038 $nexY = $pdf->GetY();
1040 $calcproductsunique = $object->nb_different_products();
1041 $calcproducts = $object->nb_products();
1044 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"NumberOfDifferentProducts").
' : </b>'.(empty($calcproductsunique[
'nb']) ?
'0' : $calcproductsunique[
'nb']), 0, 1);
1045 $nexY = $pdf->GetY();
1048 $valtoshow =
price2num($calcproducts[
'nb'],
'MS');
1049 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"NumberOfProducts").
' : </b>'.(empty($valtoshow) ?
'0' : $valtoshow), 0, 1);
1050 $nexY = $pdf->GetY();
1053 $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);
1054 $nexY = $pdf->GetY();
1058 $sql =
"SELECT max(m.datem) as datem";
1059 $sql .=
" FROM ".MAIN_DB_PREFIX.
"stock_mouvement as m";
1060 $sql .=
" WHERE m.fk_entrepot = ".((int) $object->id);
1061 $resqlbis = $this->
db->query($sql);
1063 $obj = $this->
db->fetch_object($resqlbis);
1064 $lastmovementdate = $this->
db->jdate($obj->datem);
1069 if ($lastmovementdate) {
1072 $toWrite = $outputlangs->transnoentities(
"None");
1075 $pdf->writeHTMLCell(190, 2, $this->marge_gauche, $nexY,
'<b>'.$outputlangs->transnoentities(
"LastMovement").
' : </b>'.$toWrite, 0, 1);
1076 $nexY = $pdf->GetY();
1113 $current_y = $pdf->getY();
1153 $pdf->SetTextColor(0, 0, 0);
1167 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1169 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1170 return pdf_pagefoot($pdf, $outputlangs,
'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);