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(5, 5);
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);
134 $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
135 $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
136 $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
137 $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
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);
222 if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
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) {
233 if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
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"));
322 if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(
false);
324 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
328 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
330 $this->
_pagehead($pdf, $object, 1, $outputlangs);
331 $pdf->SetFont(
'',
'', $default_font_size - 1);
332 $pdf->MultiCell(0, 3,
'');
333 $pdf->SetTextColor(0, 0, 0);
336 $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
338 $tab_height_newpage = 150;
341 $height_incoterms = 0;
342 if ($conf->incoterm->enabled) {
343 $desc_incoterms = $object->getIncotermsForPDF();
344 if ($desc_incoterms) {
347 $pdf->SetFont(
'',
'', $default_font_size - 1);
348 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
349 $nexY = $pdf->GetY();
350 $height_incoterms = $nexY - $tab_top;
353 $pdf->SetDrawColor(192, 192, 192);
354 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
356 $tab_top = $nexY + 6;
357 $height_incoterms += 4;
361 if (!empty($object->note_public) || !empty($object->tracking_number)) {
362 $tab_top = 88 + $height_incoterms;
363 $tab_top_alt = $tab_top;
365 $pdf->SetFont(
'',
'B', $default_font_size - 2);
370 if (!empty($object->tracking_number)) {
371 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities(
"TrackingNumber").
" : ".$object->tracking_number, 0, 1,
false,
true,
'L');
372 $tab_top_alt = $pdf->GetY();
374 $object->getUrlTrackingStatus($object->tracking_number);
375 if (!empty($object->tracking_url)) {
376 if ($object->shipping_method_id > 0) {
378 $code = $outputlangs->getLabelFromKey($this->
db, $object->shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
380 if ($object->tracking_url != $object->tracking_number) $label .= $outputlangs->trans(
"LinkToTrackYourPackage").
"<br>";
381 $label .= $outputlangs->trans(
"SendingMethod").
": ".$outputlangs->trans(
"SendingMethod".strtoupper($code));
383 if ($object->tracking_url != $object->tracking_number) {
385 $label .= $object->tracking_url;
387 $pdf->SetFont(
'',
'B', $default_font_size - 2);
388 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1,
false,
true,
'L');
390 $tab_top_alt = $pdf->GetY();
396 if (!empty($object->note_public)) {
397 $pdf->SetFont(
'',
'', $default_font_size - 1);
398 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt,
dol_htmlentitiesbr($object->note_public), 0, 1);
401 $nexY = $pdf->GetY();
402 $height_note = $nexY - $tab_top;
405 $pdf->SetDrawColor(192, 192, 192);
406 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
408 $tab_height = $tab_height - $height_note;
409 $tab_top = $nexY + 6;
414 $iniY = $tab_top + 7;
415 $curY = $tab_top + 7;
416 $nexY = $tab_top + 7;
418 $TCacheEntrepots=array();
420 for ($i = 0; $i < $nblines; $i++) {
422 $pdf->SetFont(
'',
'', $default_font_size - 1);
423 $pdf->SetTextColor(0, 0, 0);
426 $imglinesize = array();
429 $pdf->setTopMargin($tab_top_newpage);
430 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
431 $pageposbefore = $pdf->getPage();
433 $showpricebeforepagebreak = 1;
435 $posYAfterDescription = 0;
438 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
439 $pdf->AddPage(
'',
'',
true);
440 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
441 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
442 $pdf->setPage($pageposbefore + 1);
444 $curY = $tab_top_newpage;
447 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
448 $showpricebeforepagebreak = 1;
449 else $showpricebeforepagebreak = 0;
452 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
453 $curX = $this->posxpicture - 1;
454 $pdf->Image($realpatharray[$i], $curX + (($this->posxqty - $this->posxweightvol - $imglinesize[
'width']
455 + (!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);
457 $posYAfterImage = $curY + $imglinesize[
'height'];
461 $curX = $this->posxdesc - 1;
463 $pdf->startTransaction();
464 if (method_exists($object->lines[$i],
'fetch_product')) {
465 $object->lines[$i]->fetch_product();
466 $object->lines[$i]->label = $object->lines[$i]->product->label;
467 $object->lines[$i]->description = $object->lines[$i]->product->description;
468 $object->lines[$i]->weight = $object->lines[$i]->product->weight;
469 $object->lines[$i]->weight_units = $object->lines[$i]->product->weight_units;
470 $object->lines[$i]->length = $object->lines[$i]->product->length;
471 $object->lines[$i]->length_units = $object->lines[$i]->product->length_units;
472 $object->lines[$i]->surface = $object->lines[$i]->product->surface;
473 $object->lines[$i]->surface_units = $object->lines[$i]->product->surface_units;
474 $object->lines[$i]->volume = $object->lines[$i]->product->volume;
475 $object->lines[$i]->volume_units = $object->lines[$i]->product->volume_units;
476 $object->lines[$i]->fk_unit = $object->lines[$i]->product->fk_unit;
480 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
482 $pageposafter = $pdf->getPage();
483 if ($pageposafter > $pageposbefore) {
484 $pdf->rollbackTransaction(
true);
485 $pageposafter = $pageposbefore;
487 $pdf->setPageOrientation(
'', 1, $heightforfooter);
488 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
490 $pageposafter = $pdf->getPage();
491 $posyafter = $pdf->GetY();
493 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
494 if ($i == ($nblines - 1)) {
495 $pdf->AddPage(
'',
'',
true);
496 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
497 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
498 $pdf->setPage($pageposafter + 1);
504 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
505 $showpricebeforepagebreak = 1;
506 else $showpricebeforepagebreak = 0;
510 $pdf->commitTransaction();
512 $posYAfterDescription = $pdf->GetY();
514 $nexY = $pdf->GetY();
515 $pageposafter = $pdf->getPage();
517 $pdf->setPage($pageposbefore);
518 $pdf->setTopMargin($this->marge_haute);
519 $pdf->setPageOrientation(
'', 1, 0);
522 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
523 $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
527 if ($pageposafter > $pageposbefore) {
528 $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
531 $pdf->SetFont(
'',
'', $default_font_size - 1);
534 if (!empty($conf->productbatch->enabled)) {
535 $pdf->SetXY($this->posxlot, $curY);
536 $pdf->MultiCell(($this->posxweightvol - $this->posxlot), 3, $object->lines[$i]->batch,
'',
'C');
540 $pdf->SetXY($this->posxweightvol, $curY);
542 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->weight) {
543 $weighttxt = round($object->lines[$i]->weight * $object->lines[$i]->qty, 5).
' '.
measuringUnitString(0,
"weight", $object->lines[$i]->weight_units, 1);
546 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->volume) {
547 $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);
551 if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME)) {
552 $pdf->writeHTMLCell($this->posxqty - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ?
'<br>' :
'').$voltxt, 0, 0,
false,
true,
'C');
557 $pdf->SetXY($this->posxqty, $curY);
558 $pdf->writeHTMLCell($this->posxwarehousesource - $this->posxqty + 2, 3, $this->posxqty - 1, $curY, $object->lines[$i]->qty, 0, 0,
false,
true,
'C');
563 if (!empty($TCacheEntrepots[$object->lines[$i]->fk_warehouse_source])) $wh_source = $TCacheEntrepots[$object->lines[$i]->fk_warehouse_source];
565 $wh_source->fetch($object->lines[$i]->fk_warehouse_source);
566 $TCacheEntrepots[$object->lines[$i]->fk_warehouse_source] = $wh_source;
568 $pdf->SetXY($this->posxwarehousesource, $curY);
569 $pdf->MultiCell(($this->posxwarehousedestination - $this->posxwarehousesource), 3, $wh_source->ref.(!empty($wh_source->lieu) ?
' - '.$wh_source->lieu :
''),
'',
'C');
572 $wh_destination =
new Entrepot($db);
573 if (!empty($TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination])) $wh_destination = $TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination];
575 $wh_destination->fetch($object->lines[$i]->fk_warehouse_destination);
576 $TCacheEntrepots[$object->lines[$i]->fk_warehouse_destination] = $wh_destination;
578 $pdf->SetXY($this->posxwarehousedestination, $curY);
579 $pdf->MultiCell(($this->posxpuht - $this->posxwarehousedestination), 3, $wh_destination->ref.(!empty($wh_destination->lieu) ?
' - '.$wh_destination->lieu :
''),
'',
'C');
581 if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT)) {
582 $pdf->SetXY($this->posxpuht, $curY);
583 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3,
price($object->lines[$i]->subprice, 0, $outputlangs),
'',
'R');
585 $pdf->SetXY($this->posxtotalht, $curY);
586 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3,
price($object->lines[$i]->total_ht, 0, $outputlangs),
'',
'R');
590 if ($weighttxt && $voltxt) $nexY += 2;
593 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
594 $pdf->setPage($pageposafter);
595 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
597 $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1);
598 $pdf->SetLineStyle(array(
'dash'=>0));
602 while ($pagenb < $pageposafter) {
603 $pdf->setPage($pagenb);
605 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
607 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
609 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
611 $pdf->setPage($pagenb);
612 $pdf->setPageOrientation(
'', 1, 0);
613 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
615 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
617 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
619 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
621 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
624 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
626 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
632 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
633 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
635 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
636 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
640 $posy = $this->
_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
643 $this->
_pagefoot($pdf, $object, $outputlangs);
644 if (method_exists($pdf,
'AliasNbPages')) $pdf->AliasNbPages();
648 $pdf->Output($file,
'F');
651 $hookmanager->initHooks(array(
'pdfgeneration'));
652 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
654 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
656 $this->error = $hookmanager->error;
657 $this->errors = $hookmanager->errors;
660 if (!empty($conf->global->MAIN_UMASK))
661 @chmod($file, octdec($conf->global->MAIN_UMASK));
663 $this->result = array(
'fullpath'=>$file);
667 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
671 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"EXP_OUTPUTDIR");
688 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
691 global $conf, $mysoc;
699 $pdf->SetFont(
'',
'B', $default_font_size - 1);
702 $col1x = $this->posxqty - 50; $col2x = $this->posxqty;
707 if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_ORDERED)) $largcol2 = ($this->posxwarehousesource - $this->posxqty);
708 else $largcol2 = ($this->posxwarehousedestination - $this->posxqty);
713 $totalWeighttoshow =
'';
714 $totalVolumetoshow =
'';
717 $tmparray = $object->getTotalWeightVolume();
718 $totalWeight = $tmparray[
'weight'];
719 $totalVolume = $tmparray[
'volume'];
721 if (!empty($object->lines))
722 foreach ($object->lines as $line) {
723 $totalQty+=$line->qty;
726 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
727 $object->trueVolume =
price(($object->trueWidth * $object->trueHeight * $object->trueDepth), 0, $outputlangs, 0, 0);
728 $object->volume_units = $object->size_units * 3;
733 if ($object->trueWeight) $totalWeighttoshow =
showDimensionInBestUnit($object->trueWeight, $object->weight_units,
"weight", $outputlangs);
734 if ($object->trueVolume) $totalVolumetoshow =
showDimensionInBestUnit($object->trueVolume, $object->volume_units,
"volume", $outputlangs);
736 $pdf->SetFillColor(255, 255, 255);
737 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
738 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Total"), 0,
'L', 1);
740 if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_ORDERED)) {
741 $pdf->SetXY($this->posxqty, $tab2_top + $tab2_hl * $index);
742 $pdf->MultiCell($this->posxwarehousesource - $this->posxqty, $tab2_hl, $totalQty, 0,
'C', 1);
745 if (!empty($conf->global->STOCKTRANSFER_PDF_DISPLAY_AMOUNT_HT)) {
746 $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
747 $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl,
'', 0,
'C', 1);
749 $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
750 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl,
price($object->total_ht, 0, $outputlangs), 0,
'C', 1);
753 if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME)) {
755 if ($totalWeighttoshow) {
756 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
757 $pdf->MultiCell(($this->posxqty - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0,
'C', 1);
761 if ($totalVolumetoshow) {
762 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
763 $pdf->MultiCell(($this->posxqty - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0,
'C', 1);
767 if (!$totalWeighttoshow && !$totalVolumetoshow) $index++;
770 $pdf->SetTextColor(0, 0, 0);
772 return ($tab2_top + ($tab2_hl * $index));
788 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0)
795 if ($hidetop) $hidetop = -1;
800 $pdf->SetTextColor(0, 0, 0);
801 $pdf->SetFont(
'',
'', $default_font_size - 2);
804 $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
806 $pdf->SetDrawColor(128, 128, 128);
807 $pdf->SetFont(
'',
'', $default_font_size - 1);
809 if (empty($hidetop)) {
810 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
812 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
813 $pdf->MultiCell($this->posxlot - $this->posxdesc, 2, $outputlangs->transnoentities(
"Description"),
'',
'L');
816 if (!empty($conf->productbatch->enabled) && $this->atLeastOneBatch) {
817 $pdf->line($this->posxlot - 1, $tab_top, $this->posxlot - 1, $tab_top + $tab_height);
818 if (empty($hidetop)) {
819 $pdf->SetXY($this->posxlot, $tab_top + 1);
820 $pdf->MultiCell(($this->posxweightvol - $this->posxlot), 2, $outputlangs->transnoentities(
"Batch"),
'',
'C');
824 if (empty($conf->global->STOCKTRANSFER_PDF_HIDE_WEIGHT_AND_VOLUME)) {
825 $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height);
826 if (empty($hidetop)) {
827 $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1);
828 $pdf->MultiCell(($this->posxqty - $this->posxweightvol), 2, $outputlangs->transnoentities(
"WeightVolShort"),
'',
'C');
832 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
833 if (empty($hidetop)) {
834 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
835 $pdf->MultiCell(($this->posxwarehousesource - $this->posxqty), 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
838 $pdf->line($this->posxwarehousesource - 1, $tab_top, $this->posxwarehousesource - 1, $tab_top + $tab_height);
839 if (empty($hidetop)) {
840 $pdf->SetXY($this->posxwarehousesource - 1, $tab_top + 1);
841 $pdf->MultiCell(($this->posxwarehousedestination - $this->posxwarehousesource), 2, $outputlangs->transnoentities(
"WarehouseSource"),
'',
'C');
845 $pdf->line($this->posxwarehousedestination - 1, $tab_top, $this->posxwarehousedestination - 1, $tab_top + $tab_height);
846 if (empty($hidetop)) {
847 $pdf->SetXY($this->posxwarehousedestination-2.5, $tab_top + 1);
848 $pdf->MultiCell(($this->posxpuht - $this->posxwarehousedestination+4), 2, $outputlangs->transnoentities(
"WarehouseTarget"),
'',
'C');
879 $atLeastOneBatch =
false;
881 if (empty($conf->productbatch->enabled))
return false;
883 foreach ($object->lines as $line) {
884 if (!empty($line->batch)) {
902 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
905 global $conf, $langs, $mysoc;
907 $langs->load(
"orders");
914 if ($object->statut == 0 && (!empty($conf->global->SHIPPING_DRAFT_WATERMARK))) {
915 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->SHIPPING_DRAFT_WATERMARK);
919 $pdf->SetTextColor(0, 0, 60);
920 $pdf->SetFont(
'',
'B', $default_font_size + 3);
924 $posy = $this->marge_haute;
925 $posx = $this->page_largeur - $this->marge_droite - $w;
927 $pdf->SetXY($this->marge_gauche, $posy);
930 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
931 if ($this->emetteur->logo) {
932 if (is_readable($logo)) {
934 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
936 $pdf->SetTextColor(200, 0, 0);
937 $pdf->SetFont(
'',
'B', $default_font_size - 2);
938 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
939 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
942 $text = $this->emetteur->name;
943 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
947 if (!empty($conf->barcode->enabled)) {
950 $posx = $this->marge_gauche + 3;
953 if (!empty($conf->barcode->enabled)) {
959 $pdf->SetDrawColor(128, 128, 128);
960 if (!empty($conf->barcode->enabled)) {
967 $posx = $this->page_largeur - $w - $this->marge_droite;
968 $posy = $this->marge_haute;
970 $pdf->SetFont(
'',
'B', $default_font_size + 2);
971 $pdf->SetXY($posx, $posy);
972 $pdf->SetTextColor(0, 0, 60);
973 $title = $outputlangs->transnoentities(
"StockTransferSheet");
974 $pdf->MultiCell($w, 4, $title,
'',
'R');
976 $pdf->SetFont(
'',
'', $default_font_size + 1);
980 $pdf->SetXY($posx, $posy);
981 $pdf->SetTextColor(0, 0, 60);
982 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"Ref").
" : ".$object->ref,
'',
'R');
985 if (!empty($object->date_prevue_depart)) {
987 $pdf->SetXY($posx, $posy);
988 $pdf->SetTextColor(0, 0, 60);
989 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueDepart").
" : ".
dol_print_date($object->date_prevue_depart,
"day",
false, $outputlangs,
true),
'',
'R');
993 if (!empty($object->date_prevue_arrivee)) {
995 $pdf->SetXY($posx, $posy);
996 $pdf->SetTextColor(0, 0, 60);
997 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DatePrevueArrivee").
" : ".
dol_print_date($object->date_prevue_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1001 if (!empty($object->date_reelle_depart)) {
1003 $pdf->SetXY($posx, $posy);
1004 $pdf->SetTextColor(0, 0, 60);
1005 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleDepart").
" : ".
dol_print_date($object->date_reelle_depart,
"day",
false, $outputlangs,
true),
'',
'R');
1009 if (!empty($object->date_reelle_arrivee)) {
1011 $pdf->SetXY($posx, $posy);
1012 $pdf->SetTextColor(0, 0, 60);
1013 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateReelleArrivee").
" : ".
dol_print_date($object->date_reelle_arrivee,
"day",
false, $outputlangs,
true),
'',
'R');
1016 if (!empty($object->thirdparty->code_client)) {
1018 $pdf->SetXY($posx, $posy);
1019 $pdf->SetTextColor(0, 0, 60);
1020 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1024 $pdf->SetFont(
'',
'', $default_font_size + 3);
1028 $origin = $object->origin;
1029 $origin_id = $object->origin_id;
1032 if (!empty($conf->$origin->enabled)) {
1033 $outputlangs->load(
'orders');
1035 $classname = ucfirst($origin);
1036 $linkedobject =
new $classname($this->
db);
1037 $result = $linkedobject->fetch($origin_id);
1041 $pdf->SetFont(
'',
'', $default_font_size - 2);
1042 $text = $linkedobject->ref;
1043 if ($linkedobject->ref_client) $text .=
' ('.$linkedobject->ref_client.
')';
1045 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1046 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"RefOrder").
" : ".$outputlangs->transnoentities($text), 0,
'R');
1048 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
1049 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($linkedobject->date,
"day",
false, $outputlangs,
true), 0,
'R');
1055 $carac_emetteur =
'';
1057 $arrayidcontact = array();
1058 $arrayidcontact = $object->getIdContact(
'external',
'STFROM');
1060 $usecontact =
false;
1061 if (count($arrayidcontact) > 0) {
1065 $result = $object->fetch_contact($arrayidcontact[0]);
1068 if ($usecontact) $thirdparty = $object->contact;
1069 else $thirdparty = $this->emetteur;
1073 if ($usecontact) $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, $object->contact, 1,
'targetwithdetails', $object);
1074 else $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1077 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1078 $posx = $this->marge_gauche;
1079 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1081 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1082 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1085 $pdf->SetTextColor(0, 0, 0);
1086 $pdf->SetFont(
'',
'', $default_font_size - 2);
1087 $pdf->SetXY($posx, $posy - 5);
1088 $pdf->MultiCell(66, 5, $outputlangs->transnoentities(
"Sender").
":", 0,
'L');
1089 $pdf->SetXY($posx, $posy);
1090 $pdf->SetFillColor(230, 230, 230);
1091 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1092 $pdf->SetTextColor(0, 0, 60);
1093 $pdf->SetFillColor(255, 255, 255);
1096 $pdf->SetXY($posx + 2, $posy + 3);
1097 $pdf->SetFont(
'',
'B', $default_font_size);
1098 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($carac_emetteur_name), 0,
'L');
1099 $posy = $pdf->getY();
1102 $pdf->SetXY($posx + 2, $posy);
1103 $pdf->SetFont(
'',
'', $default_font_size - 1);
1104 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1108 $usecontact =
false;
1109 $arrayidcontact = $object->getIdContact(
'external',
'STDEST');
1110 if (count($arrayidcontact) > 0) {
1112 $result = $object->fetch_contact($arrayidcontact[0]);
1118 $thirdparty = $object->contact;
1120 $thirdparty = $object->thirdparty;
1125 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact :
null), $usecontact,
'targetwithdetails', $object);
1128 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1129 if ($this->page_largeur < 210) $widthrecbox = 84;
1130 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1131 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1132 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1135 $pdf->SetTextColor(0, 0, 0);
1136 $pdf->SetFont(
'',
'', $default_font_size - 2);
1137 $pdf->SetXY($posx + 2, $posy - 5);
1138 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient").
":", 0,
'L');
1139 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1142 $pdf->SetXY($posx + 2, $posy + 3);
1143 $pdf->SetFont(
'',
'B', $default_font_size);
1144 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1146 $posy = $pdf->getY();
1149 $pdf->SetFont(
'',
'', $default_font_size - 1);
1150 $pdf->SetXY($posx + 2, $posy);
1151 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1154 $pdf->SetTextColor(0, 0, 0);
1167 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1171 $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1172 return pdf_pagefoot($pdf, $outputlangs,
'SHIPPING_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);