30 require_once DOL_DOCUMENT_ROOT .
'/core/modules/stocktransfer/modules_stocktransfer.php';
31 require_once DOL_DOCUMENT_ROOT.
'/product/stock/class/entrepot.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
34 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
66 public $phpmin = array(7, 0);
72 public $version =
'dolibarr';
123 global $conf, $langs, $mysoc;
126 $this->
name = $langs->trans(
"StockTransferSheet");
127 $this->
description = $langs->trans(
"DocumentModelStandardPDF");
131 $this->page_largeur = $formatarray[
'width'];
132 $this->page_hauteur = $formatarray[
'height'];
133 $this->format = array($this->page_largeur, $this->page_hauteur);
139 $this->option_logo = 1;
142 $this->emetteur = $mysoc;
143 if (!$this->emetteur->country_code) $this->emetteur->country_code = substr($langs->defaultlang, -2);
146 $this->posxdesc = $this->marge_gauche + 1;
147 $this->posxlot = $this->page_largeur - $this->marge_droite - 135;
148 $this->posxweightvol = $this->page_largeur - $this->marge_droite - 115;
149 $this->posxqty = $this->page_largeur - $this->marge_droite - 95;
150 $this->posxwarehousesource = $this->page_largeur - $this->marge_droite - 70;
151 $this->posxwarehousedestination = $this->page_largeur - $this->marge_droite - 35;
152 $this->posxpuht = $this->page_largeur - $this->marge_droite;
162 if (!empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME)) $this->posxweightvol = $this->posxqty;
164 $this->posxpicture = $this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
168 if ($this->page_largeur < 210) {
169 $this->posxqty -= 20;
170 $this->posxpicture -= 20;
171 $this->posxwarehousesource -= 20;
172 $this->posxwarehousedestination -= 20;
194 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
197 global $db, $user, $conf, $langs, $hookmanager;
199 $object->fetch_thirdparty();
203 if (!is_object($outputlangs)) $outputlangs = $langs;
205 if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output =
'ISO-8859-1';
208 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"propal",
"deliveries",
"sendings",
"productbatch",
"stocks",
"stocktransfer@stocktransfer"));
210 $nblines = count($object->lines);
213 $realpatharray = array();
214 if (!empty($conf->global->MAIN_GENERATE_STOCKTRANSFER_WITH_PICTURE)) {
217 for ($i = 0; $i < $nblines; $i++) {
218 if (empty($object->lines[$i]->fk_product))
continue;
221 $objphoto->fetch($object->lines[$i]->fk_product);
223 $pdir =
get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
224 $dir = $conf->product->dir_output.
'/'.$pdir;
226 $pdir =
get_exdir(0, 2, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
227 $dir = $conf->product->dir_output.
'/'.$pdir;
232 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
235 if ($obj[
'photo_vignette']) {
236 $filename = $obj[
'photo_vignette'];
238 $filename = $obj[
'photo'];
241 $filename = $obj[
'photo'];
244 $realpath = $dir.$filename;
248 if ($realpath) $realpatharray[$i] = $realpath;
252 if (count($realpatharray) == 0) $this->posxpicture = $this->posxweightvol;
256 $this->posxpicture = $this->posxlot;
257 if (!empty($conf->global->MAIN_GENERATE_STOCKTRANSFER_WITH_PICTURE)) $this->posxpicture -= (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
260 if ($conf->stocktransfer->dir_output) {
262 if ($object->specimen) {
263 $dir = $conf->stocktransfer->dir_output;
264 $file = $dir.
"/SPECIMEN.pdf";
267 $dir = $conf->stocktransfer->dir_output.
'/'.$object->element.
"/".$stocktransferref;
268 $file = $dir.
"/".$stocktransferref.
".pdf";
271 if (!file_exists($dir)) {
273 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
278 if (file_exists($dir)) {
280 if (!is_object($hookmanager)) {
281 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
284 $hookmanager->initHooks(array(
'pdfgeneration'));
285 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
287 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
290 $nblines = count($object->lines);
294 $heightforinfotot = 8;
295 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
296 $heightforfooter = $this->marge_basse + 8;
297 if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6;
298 $pdf->SetAutoPageBreak(1, 0);
300 if (class_exists(
'TCPDF')) {
301 $pdf->setPrintHeader(
false);
302 $pdf->setPrintFooter(
false);
306 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
307 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
308 $tplidx = $pdf->importPage(1);
313 $pdf->SetDrawColor(128, 128, 128);
315 if (method_exists($pdf,
'AliasNbPages')) $pdf->AliasNbPages();
317 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
318 $pdf->SetSubject($outputlangs->transnoentities(
"Shipment"));
319 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
320 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
321 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Shipment"));
323 $pdf->SetCompression(
false);
326 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
330 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
332 $this->
_pagehead($pdf, $object, 1, $outputlangs);
333 $pdf->SetFont(
'',
'', $default_font_size - 1);
334 $pdf->MultiCell(0, 3,
'');
335 $pdf->SetTextColor(0, 0, 0);
338 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
340 $tab_height_newpage = 150;
343 $height_incoterms = 0;
344 if ($conf->incoterm->enabled) {
345 $desc_incoterms = $object->getIncotermsForPDF();
346 if ($desc_incoterms) {
349 $pdf->SetFont(
'',
'', $default_font_size - 1);
350 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
351 $nexY = $pdf->GetY();
352 $height_incoterms = $nexY - $tab_top;
355 $pdf->SetDrawColor(192, 192, 192);
356 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
358 $tab_top = $nexY + 6;
359 $height_incoterms += 4;
363 if (!empty($object->note_public) || !empty($object->tracking_number)) {
364 $tab_top = 88 + $height_incoterms;
365 $tab_top_alt = $tab_top;
367 $pdf->SetFont(
'',
'B', $default_font_size - 2);
372 if (!empty($object->tracking_number)) {
373 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities(
"TrackingNumber").
" : ".$object->tracking_number, 0, 1,
false,
true,
'L');
374 $tab_top_alt = $pdf->GetY();
376 $object->getUrlTrackingStatus($object->tracking_number);
377 if (!empty($object->tracking_url)) {
378 if ($object->shipping_method_id > 0) {
380 $code = $outputlangs->getLabelFromKey($this->
db, $object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
382 if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans(
"LinkToTrackYourPackage").
"<br>";
383 $label .= $outputlangs->trans(
"SendingMethod").
": ".$outputlangs->trans(
"SendingMethod".strtoupper($code));
385 if ($object->tracking_url != $object->tracking_number) {
387 $label .= $object->tracking_url;
389 $pdf->SetFont(
'',
'B', $default_font_size - 2);
390 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1,
false,
true,
'L');
392 $tab_top_alt = $pdf->GetY();
398 if (!empty($object->note_public)) {
399 $pdf->SetFont(
'',
'', $default_font_size - 1);
400 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt,
dol_htmlentitiesbr($object->note_public), 0, 1);
403 $nexY = $pdf->GetY();
404 $height_note = $nexY - $tab_top;
407 $pdf->SetDrawColor(192, 192, 192);
408 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
410 $tab_height = $tab_height - $height_note;
411 $tab_top = $nexY + 6;
416 $iniY = $tab_top + 7;
417 $curY = $tab_top + 7;
418 $nexY = $tab_top + 7;
420 $TCacheEntrepots=array();
422 for ($i = 0; $i < $nblines; $i++) {
424 $pdf->SetFont(
'',
'', $default_font_size - 1);
425 $pdf->SetTextColor(0, 0, 0);
428 $imglinesize = array();
431 $pdf->setTopMargin($tab_top_newpage);
432 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
433 $pageposbefore = $pdf->getPage();
435 $showpricebeforepagebreak = 1;
437 $posYAfterDescription = 0;
440 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
441 $pdf->AddPage(
'',
'',
true);
442 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
444 $pdf->setPage($pageposbefore + 1);
446 $curY = $tab_top_newpage;
449 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
450 $showpricebeforepagebreak = 1;
451 else $showpricebeforepagebreak = 0;
454 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
455 $curX = $this->posxpicture - 1;
456 $pdf->Image($realpatharray[$i], $curX + (($this->posxqty - $this->posxweightvol - $imglinesize[
'width']
457 + (!empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME) ? (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) : 0)) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
459 $posYAfterImage = $curY + $imglinesize[
'height'];
463 $curX = $this->posxdesc - 1;
465 $pdf->startTransaction();
466 if (method_exists($object->lines[$i],
'fetch_product')) {
467 $object->lines[$i]->fetch_product();
468 $object->lines[$i]->label = $object->lines[$i]->product->label;
469 $object->lines[$i]->description = $object->lines[$i]->product->description;
470 $object->lines[$i]->weight = $object->lines[$i]->product->weight;
471 $object->lines[$i]->weight_units = $object->lines[$i]->product->weight_units;
472 $object->lines[$i]->length = $object->lines[$i]->product->length;
473 $object->lines[$i]->length_units = $object->lines[$i]->product->length_units;
474 $object->lines[$i]->surface = $object->lines[$i]->product->surface;
475 $object->lines[$i]->surface_units = $object->lines[$i]->product->surface_units;
476 $object->lines[$i]->volume = $object->lines[$i]->product->volume;
477 $object->lines[$i]->volume_units = $object->lines[$i]->product->volume_units;
478 $object->lines[$i]->fk_unit = $object->lines[$i]->product->fk_unit;
482 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
484 $pageposafter = $pdf->getPage();
485 if ($pageposafter > $pageposbefore) {
486 $pdf->rollbackTransaction(
true);
487 $pageposafter = $pageposbefore;
489 $pdf->setPageOrientation(
'', 1, $heightforfooter);
490 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
492 $pageposafter = $pdf->getPage();
493 $posyafter = $pdf->GetY();
495 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
496 if ($i == ($nblines - 1)) {
497 $pdf->AddPage(
'',
'',
true);
498 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
500 $pdf->setPage($pageposafter + 1);
506 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
507 $showpricebeforepagebreak = 1;
508 else $showpricebeforepagebreak = 0;
512 $pdf->commitTransaction();
514 $posYAfterDescription = $pdf->GetY();
516 $nexY = $pdf->GetY();
517 $pageposafter = $pdf->getPage();
519 $pdf->setPage($pageposbefore);
520 $pdf->setTopMargin($this->marge_haute);
521 $pdf->setPageOrientation(
'', 1, 0);
524 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
525 $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
529 if ($pageposafter > $pageposbefore) {
530 $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
533 $pdf->SetFont(
'',
'', $default_font_size - 1);
537 $pdf->SetXY($this->posxlot, $curY);
538 $pdf->MultiCell(($this->posxweightvol - $this->posxlot), 3, $object->lines[$i]->batch,
'',
'C');
542 $pdf->SetXY($this->posxweightvol, $curY);
544 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) {
545 $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty, 5).
' '.
measuringUnitString(0,
"weight", $object->lines[$i]->weight_units, 1);
548 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) {
549 $voltxt = round($object->lines[$i]->volume * $object->lines[$i]->qty, 5).
' '.
measuringUnitString(0,
"volume", $object->lines[$i]->volume_units ? $object->lines[$i]->volume_units : 0, 1);
553 if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME)) {
554 $pdf->writeHTMLCell($this->posxqty - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ?
'<br>' :
'').$voltxt, 0, 0,
false,
true,
'C');
559 $pdf->SetXY($this->posxqty, $curY);
560 $pdf->writeHTMLCell($this->posxwarehousesource - $this->posxqty + 2, 3, $this->posxqty - 1, $curY, $object->lines[$i]->qty, 0, 0,
false,
true,
'C');
565 if (!empty($TCacheEntrepots[$object->lines[$i]->fk_warehouse_source])) $wh_source = $TCacheEntrepots[$object->lines[$i]->fk_warehouse_source];
567 $wh_source->fetch($object->lines[$i]->fk_warehouse_source);
568 $TCacheEntrepots[$object->lines[$i]->fk_warehouse_source] = $wh_source;
570 $pdf->SetXY($this->posxwarehousesource, $curY);
571 $pdf->MultiCell(($this->posxwarehousedestination - $this->posxwarehousesource), 3, $wh_source->ref.(!empty($wh_source->lieu) ?
' - '.$wh_source->lieu :
''),
'',
'C');
574 $wh_destination =
new Entrepot($db);
575 if (!empty($TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination])) $wh_destination = $TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination];
577 $wh_destination->fetch($object->lines[$i]->fk_warehouse_destination);
578 $TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination] = $wh_destination;
580 $pdf->SetXY($this->posxwarehousedestination, $curY);
581 $pdf->MultiCell(($this->posxpuht - $this->posxwarehousedestination), 3, $wh_destination->ref.(!empty($wh_destination->lieu) ?
' - '.$wh_destination->lieu :
''),
'',
'C');
583 if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT)) {
584 $pdf->SetXY($this->posxpuht, $curY);
585 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3,
price($object->lines[$i]->subprice, 0, $outputlangs),
'',
'R');
587 $pdf->SetXY($this->posxtotalht, $curY);
588 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3,
price($object->lines[$i]->total_ht, 0, $outputlangs),
'',
'R');
592 if ($weighttxt && $voltxt) $nexY += 2;
595 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
596 $pdf->setPage($pageposafter);
597 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
599 $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1);
600 $pdf->SetLineStyle(array(
'dash'=>0));
604 while ($pagenb < $pageposafter) {
605 $pdf->setPage($pagenb);
607 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
609 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
611 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
613 $pdf->setPage($pagenb);
614 $pdf->setPageOrientation(
'', 1, 0);
617 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
619 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
621 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
623 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
626 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
634 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
635 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
637 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
638 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
642 $posy = $this->
_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
645 $this->
_pagefoot($pdf, $object, $outputlangs);
646 if (method_exists($pdf,
'AliasNbPages')) $pdf->AliasNbPages();
650 $pdf->Output($file,
'F');
653 $hookmanager->initHooks(array(
'pdfgeneration'));
654 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
656 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
658 $this->error = $hookmanager->error;
659 $this->errors = $hookmanager->errors;
662 if (!empty($conf->global->MAIN_UMASK))
663 @chmod($file, octdec($conf->global->MAIN_UMASK));
665 $this->result = array(
'fullpath'=>$file);
669 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
673 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"EXP_OUTPUTDIR");
690 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
693 global $conf, $mysoc;
701 $pdf->SetFont(
'',
'B', $default_font_size - 1);
704 $col1x = $this->posxqty - 50; $col2x = $this->posxqty;
709 if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxwarehousesource - $this->posxqty);
710 else $largcol2 = ($this->posxwarehousedestination - $this->posxqty);
715 $totalWeighttoshow =
'';
716 $totalVolumetoshow =
'';
719 $tmparray = $object->getTotalWeightVolume();
720 $totalWeight = $tmparray[
'weight'];
721 $totalVolume = $tmparray[
'volume'];
723 if (!empty($object->lines))
724 foreach ($object->lines as $line) {
725 $totalQty+=$line->qty;
728 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
729 $object->trueVolume =
price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
730 $object->volume_units = $object->size_units * 3;
735 if ($object->trueWeight) $totalWeighttoshow =
showDimensionInBestUnit($object->trueWeight, $object->weight_units,
"weight", $outputlangs);
736 if ($object->trueVolume) $totalVolumetoshow =
showDimensionInBestUnit($object->trueVolume, $object->volume_units,
"volume", $outputlangs);
738 $pdf->SetFillColor(255, 255, 255);
739 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
740 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Total"), 0,
'L', 1);
742 if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_ORDERED)) {
743 $pdf->SetXY($this->posxqty, $tab2_top + $tab2_hl * $index);
744 $pdf->MultiCell($this->posxwarehousesource - $this->posxqty, $tab2_hl, $totalQty, 0,
'C', 1);
747 if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT)) {
748 $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
749 $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl,
'', 0,
'C', 1);
751 $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
752 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl,
price($object->total_ht, 0, $outputlangs), 0,
'C', 1);
755 if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME)) {
757 if ($totalWeighttoshow) {
758 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
759 $pdf->MultiCell(($this->posxqty - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0,
'C', 1);
763 if ($totalVolumetoshow) {
764 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
765 $pdf->MultiCell(($this->posxqty - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0,
'C', 1);
769 if (!$totalWeighttoshow && !$totalVolumetoshow) $index++;
772 $pdf->SetTextColor(0, 0, 0);
774 return ($tab2_top + ($tab2_hl * $index));
790 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
797 if ($hidetop) $hidetop = -1;
802 $pdf->SetTextColor(0, 0, 0);
803 $pdf->SetFont(
'',
'', $default_font_size - 2);
806 $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
808 $pdf->SetDrawColor(128, 128, 128);
809 $pdf->SetFont(
'',
'', $default_font_size - 1);
811 if (empty($hidetop)) {
812 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
814 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
815 $pdf->MultiCell($this->posxlot - $this->posxdesc, 2, $outputlangs->transnoentities(
"Description"),
'',
'L');
819 $pdf->line($this->posxlot - 1, $tab_top, $this->posxlot - 1, $tab_top + $tab_height);
820 if (empty($hidetop)) {
821 $pdf->SetXY($this->posxlot, $tab_top + 1);
822 $pdf->MultiCell(($this->posxweightvol - $this->posxlot), 2, $outputlangs->transnoentities(
"Batch"),
'',
'C');
826 if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME)) {
827 $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height);
828 if (empty($hidetop)) {
829 $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1);
830 $pdf->MultiCell(($this->posxqty - $this->posxweightvol), 2, $outputlangs->transnoentities(
"WeightVolShort"),
'',
'C');
834 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
835 if (empty($hidetop)) {
836 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
837 $pdf->MultiCell(($this->posxwarehousesource - $this->posxqty), 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
840 $pdf->line($this->posxwarehousesource - 1, $tab_top, $this->posxwarehousesource - 1, $tab_top + $tab_height);
841 if (empty($hidetop)) {
842 $pdf->SetXY($this->posxwarehousesource - 1, $tab_top + 1);
843 $pdf->MultiCell(($this->posxwarehousedestination - $this->posxwarehousesource), 2, $outputlangs->transnoentities(
"WarehouseSource"),
'',
'C');
847 $pdf->line($this->posxwarehousedestination - 1, $tab_top, $this->posxwarehousedestination - 1, $tab_top + $tab_height);
848 if (empty($hidetop)) {
849 $pdf->SetXY($this->posxwarehousedestination-2.5, $tab_top + 1);
850 $pdf->MultiCell(($this->posxpuht - $this->posxwarehousedestination+4), 2, $outputlangs->transnoentities(
"WarehouseTarget"),
'',
'C');
881 $atLeastOneBatch =
false;
883 if (empty($conf->productbatch->enabled))
return false;
885 foreach ($object->lines as $line) {
886 if (!empty($line->batch)) {
904 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
907 global $conf, $langs, $mysoc;
909 $langs->load(
"orders");
916 if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK))) {
917 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
921 $pdf->SetTextColor(0, 0, 60);
922 $pdf->SetFont(
'',
'B', $default_font_size + 3);
926 $posy = $this->marge_haute;
927 $posx = $this->page_largeur - $this->marge_droite - $w;
929 $pdf->SetXY($this->marge_gauche, $posy);
932 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
933 if ($this->emetteur->logo) {
934 if (is_readable($logo)) {
936 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
938 $pdf->SetTextColor(200, 0, 0);
939 $pdf->SetFont(
'',
'B', $default_font_size - 2);
940 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
941 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
944 $text = $this->emetteur->name;
945 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
952 $posx = $this->marge_gauche + 3;
961 $pdf->SetDrawColor(128, 128, 128);
969 $posx = $this->page_largeur - $w - $this->marge_droite;
970 $posy = $this->marge_haute;
972 $pdf->SetFont(
'',
'B', $default_font_size + 2);
973 $pdf->SetXY($posx, $posy);
974 $pdf->SetTextColor(0, 0, 60);
975 $title = $outputlangs->transnoentities(
"StockTransferSheet");
976 $pdf->MultiCell($w, 4, $title,
'',
'R');
978 $pdf->SetFont(
'',
'', $default_font_size + 1);
982 $pdf->SetXY($posx, $posy);
983 $pdf->SetTextColor(0, 0, 60);
984 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"Ref").
" : ".$object->ref,
'',
'R');
987 if (!empty($object->date_prevue_depart)) {
989 $pdf->SetXY($posx, $posy);
990 $pdf->SetTextColor(0, 0, 60);
991 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueDepart").
" : ".
dol_print_date($object->date_prevue_depart,
"day",
false, $outputlangs,
true),
'',
'R');
995 if (!empty($object->date_prevue_arrivee)) {
997 $pdf->SetXY($posx, $posy);
998 $pdf->SetTextColor(0, 0, 60);
999 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueArrivee").
" : ".
dol_print_date($object->date_prevue_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1003 if (!empty($object->date_reelle_depart)) {
1005 $pdf->SetXY($posx, $posy);
1006 $pdf->SetTextColor(0, 0, 60);
1007 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleDepart").
" : ".
dol_print_date($object->date_reelle_depart,
"day",
false, $outputlangs,
true),
'',
'R');
1011 if (!empty($object->date_reelle_arrivee)) {
1013 $pdf->SetXY($posx, $posy);
1014 $pdf->SetTextColor(0, 0, 60);
1015 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleArrivee").
" : ".
dol_print_date($object->date_reelle_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1018 if (!empty($object->thirdparty->code_client)) {
1020 $pdf->SetXY($posx, $posy);
1021 $pdf->SetTextColor(0, 0, 60);
1022 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1026 $pdf->SetFont(
'',
'', $default_font_size + 3);
1030 $origin = $object->origin;
1031 $origin_id = $object->origin_id;
1034 if (!empty($conf->$origin->enabled)) {
1035 $outputlangs->load(
'orders');
1037 $classname = ucfirst($origin);
1038 $linkedobject =
new $classname($this->
db);
1039 $result = $linkedobject->fetch($origin_id);
1043 $pdf->SetFont(
'',
'', $default_font_size - 2);
1044 $text = $linkedobject->ref;
1045 if ($linkedobject->ref_client) $text .=
' ('.$linkedobject->ref_client.
')';
1047 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1048 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"RefOrder").
" : ".$outputlangs->transnoentities($text), 0,
'R');
1050 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1051 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($linkedobject->date,
"day",
false, $outputlangs,
true), 0,
'R');
1057 $carac_emetteur =
'';
1059 $arrayidcontact = array();
1060 $arrayidcontact = $object->getIdContact(
'external',
'STFROM');
1062 $usecontact =
false;
1063 if (count($arrayidcontact) > 0) {
1067 $result = $object->fetch_contact($arrayidcontact[0]);
1070 if ($usecontact) $thirdparty = $object->contact;
1071 else $thirdparty = $this->emetteur;
1075 if ($usecontact) $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, 1,
'targetwithdetails', $object);
1076 else $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1079 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1080 $posx = $this->marge_gauche;
1081 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1083 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1084 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1087 $pdf->SetTextColor(0, 0, 0);
1088 $pdf->SetFont(
'',
'', $default_font_size - 2);
1089 $pdf->SetXY($posx, $posy - 5);
1090 $pdf->MultiCell(66, 5, $outputlangs->transnoentities(
"Sender").
":", 0,
'L');
1091 $pdf->SetXY($posx, $posy);
1092 $pdf->SetFillColor(230, 230, 230);
1093 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1094 $pdf->SetTextColor(0, 0, 60);
1095 $pdf->SetFillColor(255, 255, 255);
1098 $pdf->SetXY($posx + 2, $posy + 3);
1099 $pdf->SetFont(
'',
'B', $default_font_size);
1100 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($carac_emetteur_name), 0,
'L');
1101 $posy = $pdf->getY();
1104 $pdf->SetXY($posx + 2, $posy);
1105 $pdf->SetFont(
'',
'', $default_font_size - 1);
1106 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1110 $usecontact =
false;
1111 $arrayidcontact = $object->getIdContact(
'external',
'STDEST');
1112 if (count($arrayidcontact) > 0) {
1114 $result = $object->fetch_contact($arrayidcontact[0]);
1120 $thirdparty = $object->contact;
1122 $thirdparty = $object->thirdparty;
1127 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact :
null), $usecontact,
'targetwithdetails', $object);
1130 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1131 if ($this->page_largeur < 210) $widthrecbox = 84;
1132 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1133 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1134 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1137 $pdf->SetTextColor(0, 0, 0);
1138 $pdf->SetFont(
'',
'', $default_font_size - 2);
1139 $pdf->SetXY($posx + 2, $posy - 5);
1140 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient").
":", 0,
'L');
1141 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1144 $pdf->SetXY($posx + 2, $posy + 3);
1145 $pdf->SetFont(
'',
'B', $default_font_size);
1146 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1148 $posy = $pdf->getY();
1151 $pdf->SetFont(
'',
'', $default_font_size - 1);
1152 $pdf->SetXY($posx + 2, $posy);
1153 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1156 $pdf->SetTextColor(0, 0, 0);
1169 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1172 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1173 return pdf_pagefoot($pdf, $outputlangs,
'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
Class to manage warehouses.
Class to manage products or services.
Class to build sending documents with model Eagle.
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0)
Show table for lines.
atLeastOneBatch($object)
 * Used to know if at least one line of Stock Transfer object has a batch set  *
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
__construct($db=0)
Constructor.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
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).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
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_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formated for output on documents.
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
measuringUnitString($unit, $measuring_style='', $scale='', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
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.
$conf db
API class for accounts.