118 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
121 global $user, $conf, $langs, $hookmanager;
123 $object->fetch_thirdparty();
125 if (!is_object($outputlangs)) {
126 $outputlangs = $langs;
129 if (!empty($conf->global->MAIN_USE_FPDF)) {
130 $outputlangs->charset_output =
'ISO-8859-1';
133 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal",
"deliveries",
"receptions",
"productbatch",
"sendings"));
136 if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->RECEPTION_DRAFT_WATERMARK))) {
137 $this->watermark = $conf->global->RECEPTION_DRAFT_WATERMARK;
140 $nblines = count($object->lines);
143 $realpatharray = array();
144 if (!empty($conf->global->MAIN_GENERATE_SHIPMENT_WITH_PICTURE)) {
145 $objphoto =
new Product($this->db);
147 for ($i = 0; $i < $nblines; $i++) {
148 if (empty($object->lines[$i]->fk_product)) {
152 $objphoto =
new Product($this->db);
153 $objphoto->fetch($object->lines[$i]->fk_product);
156 $pdir =
get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
157 $dir = $conf->product->dir_output.
'/'.$pdir;
159 $pdir =
get_exdir(0, 2, 0, 0, $objphoto,
'product');
160 $dir = $conf->product->dir_output.
'/'.$pdir;
165 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
168 if ($obj[
'photo_vignette']) {
169 $filename = $obj[
'photo_vignette'];
171 $filename = $obj[
'photo'];
174 $filename = $obj[
'photo'];
177 $realpath = $dir.$filename;
182 $realpatharray[$i] = $realpath;
187 if (count($realpatharray) == 0) {
188 $this->posxpicture = $this->posxweightvol;
191 if ($conf->reception->dir_output) {
193 if ($object->specimen) {
194 $dir = $conf->reception->dir_output;
195 $file = $dir.
"/SPECIMEN.pdf";
198 $dir = $conf->reception->dir_output.
"/".$rcpref;
199 $file = $dir.
"/".$rcpref.
".pdf";
202 if (!file_exists($dir)) {
204 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
209 if (file_exists($dir)) {
211 if (!is_object($hookmanager)) {
212 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
215 $hookmanager->initHooks(array(
'pdfgeneration'));
216 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
218 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
221 $nblines = count($object->lines);
225 $heightforinfotot = 8;
226 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
227 $heightforfooter = $this->marge_basse + 8;
228 $pdf->SetAutoPageBreak(1, 0);
230 if (class_exists(
'TCPDF')) {
231 $pdf->setPrintHeader(
false);
232 $pdf->setPrintFooter(
false);
236 if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
237 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
238 $tplidx = $pdf->importPage(1);
243 $pdf->SetDrawColor(128, 128, 128);
245 if (method_exists($pdf,
'AliasNbPages')) {
246 $pdf->AliasNbPages();
249 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
250 $pdf->SetSubject($outputlangs->transnoentities(
"Reception"));
251 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
252 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
253 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Reception"));
255 $pdf->SetCompression(
false);
258 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
262 if (!empty($tplidx)) {
263 $pdf->useTemplate($tplidx);
266 $this->
_pagehead($pdf, $object, 1, $outputlangs);
267 $pdf->SetFont(
'',
'', $default_font_size - 1);
268 $pdf->MultiCell(0, 3,
'');
269 $pdf->SetTextColor(0, 0, 0);
272 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
274 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
277 $height_incoterms = 0;
278 if (isModEnabled(
'incoterm')) {
279 $desc_incoterms = $object->getIncotermsForPDF();
280 if ($desc_incoterms) {
283 $pdf->SetFont(
'',
'', $default_font_size - 1);
284 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
285 $nexY = $pdf->GetY();
286 $height_incoterms = $nexY - $tab_top;
289 $pdf->SetDrawColor(192, 192, 192);
290 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
292 $tab_top = $nexY + 6;
293 $height_incoterms += 4;
297 if (!empty($object->note_public) || !empty($object->tracking_number)) {
298 $tab_top = 88 + $height_incoterms;
299 $tab_top_alt = $tab_top;
301 $pdf->SetFont(
'',
'B', $default_font_size - 2);
302 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities(
"TrackingNumber").
" : ".$object->tracking_number, 0, 1,
false,
true,
'L');
304 $tab_top_alt = $pdf->GetY();
308 if (!empty($object->tracking_number)) {
309 $object->getUrlTrackingStatus($object->tracking_number);
310 if (!empty($object->tracking_url)) {
311 if ($object->reception_method_id > 0) {
313 $code = $outputlangs->getLabelFromKey($this->db, $object->shipment_method_id,
'c_shipment_mode',
'rowid',
'code');
315 if ($object->tracking_url != $object->tracking_number) {
316 $label .= $outputlangs->trans(
"LinkToTrackYourPackage").
"<br>";
318 $label .= $outputlangs->trans(
"ReceptionMethod").
": ".$outputlangs->trans(
"ReceptionMethod".strtoupper($code));
320 if ($object->tracking_url != $object->tracking_number) {
322 $label .= $object->tracking_url;
324 $pdf->SetFont(
'',
'B', $default_font_size - 2);
325 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1,
false,
true,
'L');
327 $tab_top_alt = $pdf->GetY();
333 if (!empty($object->note_public)) {
334 $pdf->SetFont(
'',
'', $default_font_size - 1);
335 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt,
dol_htmlentitiesbr($object->note_public), 0, 1);
338 $nexY = $pdf->GetY();
339 $height_note = $nexY - $tab_top;
342 $pdf->SetDrawColor(192, 192, 192);
343 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
345 $tab_height = $tab_height - $height_note;
346 $tab_top = $nexY + 6;
351 $iniY = $tab_top + 7;
352 $curY = $tab_top + 7;
353 $nexY = $tab_top + 7;
354 $fk_commandefourndet = 0;
359 for ($i = 0; $i < $nblines; $i++) {
361 $pdf->SetFont(
'',
'', $default_font_size - 1);
362 $pdf->SetTextColor(0, 0, 0);
365 $imglinesize = array();
366 if (!empty($realpatharray[$i])) {
370 $pdf->setTopMargin($tab_top_newpage);
371 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
372 $pageposbefore = $pdf->getPage();
374 $showpricebeforepagebreak = 1;
376 $posYAfterDescription = 0;
379 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
380 $pdf->AddPage(
'',
'',
true);
381 if (!empty($tplidx)) {
382 $pdf->useTemplate($tplidx);
385 $this->
_pagehead($pdf, $object, 0, $outputlangs);
387 $pdf->setPage($pageposbefore + 1);
389 $curY = $tab_top_newpage;
392 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
393 $showpricebeforepagebreak = 1;
395 $showpricebeforepagebreak = 0;
399 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
400 $curX = $this->posxpicture - 1;
401 $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
403 $posYAfterImage = $curY + $imglinesize[
'height'];
407 $curX = $this->posxdesc - 1;
421 $pdf->startTransaction();
422 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
424 $pageposafter = $pdf->getPage();
425 if ($pageposafter > $pageposbefore) {
426 $pdf->rollbackTransaction(
true);
427 $pageposafter = $pageposbefore;
429 $pdf->setPageOrientation(
'', 1, $heightforfooter);
431 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
433 $pageposafter = $pdf->getPage();
434 $posyafter = $pdf->GetY();
436 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
437 if ($i == ($nblines - 1)) {
438 $pdf->AddPage(
'',
'',
true);
439 if (!empty($tplidx)) {
440 $pdf->useTemplate($tplidx);
443 $this->
_pagehead($pdf, $object, 0, $outputlangs);
445 $pdf->setPage($pageposafter + 1);
451 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
452 $showpricebeforepagebreak = 1;
454 $showpricebeforepagebreak = 0;
459 $pdf->commitTransaction();
461 $posYAfterDescription = $pdf->GetY();
463 $nexY = max($pdf->GetY(), $posYAfterImage);
464 $pageposafter = $pdf->getPage();
466 $pdf->setPage($pageposbefore);
467 $pdf->setTopMargin($this->marge_haute);
468 $pdf->setPageOrientation(
'', 1, 0);
471 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
472 $pdf->setPage($pageposafter);
473 $curY = $tab_top_newpage;
477 if ($pageposafter > $pageposbefore) {
478 $pdf->setPage($pageposafter);
479 $curY = $tab_top_newpage;
482 $pdf->SetFont(
'',
'', $default_font_size - 1);
485 $pdf->SetXY($this->posxweightvol, $curY);
487 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->weight) {
488 $weighttxt = round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).
' '.
measuringUnitString(0,
"weight", $object->lines[$i]->product->weight_units, 1);
491 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->volume) {
492 $voltxt = round($object->lines[$i]->product->volume * $object->lines[$i]->qty, 5).
' '.
measuringUnitString(0,
"volume", $object->lines[$i]->product->volume_units ? $object->lines[$i]->product->volume_units : 0, 1);
495 $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ?
'<br>' :
'').$voltxt, 0, 0,
false,
true,
'C');
499 if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
500 $pdf->SetXY($this->posxqtyordered, $curY);
501 if ($object->lines[$i]->fk_commandefourndet != $fk_commandefourndet) {
502 $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,
'',
'C');
503 $totalOrdered += $object->lines[$i]->qty_asked;
505 $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet;
509 $pdf->SetXY($this->posxqtytoship, $curY);
510 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty,
'',
'C');
513 if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
514 $pdf->SetXY($this->posxpuht, $curY);
515 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3,
price($object->lines[$i]->subprice, 0, $outputlangs),
'',
'R');
517 $amountreceived =
price2num($object->lines[$i]->subprice * $object->lines[$i]->qty,
'MT');
518 $pdf->SetXY($this->posxtotalht, $curY);
519 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3,
price($amountreceived, 0, $outputlangs),
'',
'R');
521 $totalAmount += $amountreceived;
525 if ($weighttxt && $voltxt) {
530 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
531 $pdf->setPage($pageposafter);
532 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
534 $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1);
535 $pdf->SetLineStyle(array(
'dash'=>0));
539 while ($pagenb < $pageposafter) {
540 $pdf->setPage($pagenb);
542 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object);
544 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object);
546 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
548 $pdf->setPage($pagenb);
549 $pdf->setPageOrientation(
'', 1, 0);
550 if (!empty($tplidx)) {
551 $pdf->useTemplate($tplidx);
554 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
556 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object);
558 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object);
560 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
563 if (!empty($tplidx)) {
564 $pdf->useTemplate($tplidx);
572 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object);
573 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
575 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object);
576 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
580 $posy = $this->
_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered, $totalAmount);
583 $this->
_pagefoot($pdf, $object, $outputlangs);
584 if (method_exists($pdf,
'AliasNbPages')) {
585 $pdf->AliasNbPages();
590 $pdf->Output($file,
'F');
593 $hookmanager->initHooks(array(
'pdfgeneration'));
594 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
596 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
598 $this->error = $hookmanager->error;
599 $this->errors = $hookmanager->errors;
606 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
610 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"EXP_OUTPUTDIR");
629 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered, $totalAmount = 0)
632 global $conf, $mysoc;
640 $pdf->SetFont(
'',
'B', $default_font_size - 1);
643 $col1x = $this->posxweightvol - 50;
644 $col2x = $this->posxweightvol;
649 if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
650 $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
652 $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
658 $totalWeighttoshow =
'';
659 $totalVolumetoshow =
'';
662 $tmparray = $object->getTotalWeightVolume();
663 $totalWeight = $tmparray[
'weight'];
664 $totalVolume = $tmparray[
'volume'];
665 $totalToShip = $tmparray[
'toship'];
669 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
670 $object->trueVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
671 $object->volume_units = $object->size_units * 3;
674 if ($totalWeight !=
'') {
677 if ($totalVolume !=
'') {
680 if (isset($object->trueWeight) && !empty($object->trueWeight)) {
681 $totalWeighttoshow =
showDimensionInBestUnit($object->trueWeight, $object->weight_units,
"weight", $outputlangs, -1,
'no', 1);
683 if (isset($object->trueVolume) && !empty($object->trueVolume)) {
684 $totalVolumetoshow =
showDimensionInBestUnit($object->trueVolume, $object->volume_units,
"volume", $outputlangs, -1,
'no', 1);
687 $pdf->SetFillColor(255, 255, 255);
688 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
689 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Total"), 0,
'L', 1);
694 if ($totalWeighttoshow) {
695 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * ($index + $index2));
696 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0,
'C', 1);
699 if ($totalVolumetoshow) {
700 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * ($index + $index2));
701 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0,
'C', 1);
706 if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
707 $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
708 $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0,
'C', 1);
712 $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
713 $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0,
'C', 1);
716 if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
717 $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
718 $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl,
'', 0,
'C', 1);
720 $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
721 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl,
price($totalAmount, 0, $outputlangs), 0,
'C', 1);
724 $pdf->SetTextColor(0, 0, 0);
731 return ($tab2_top + ($tab2_hl * $index));
748 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $object =
null)
761 $pdf->SetTextColor(0, 0, 0);
762 $pdf->SetFont(
'',
'', $default_font_size - 2);
765 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
767 $pdf->SetDrawColor(128, 128, 128);
768 $pdf->SetFont(
'',
'', $default_font_size - 1);
771 if (empty($hidetop)) {
772 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
774 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
775 $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities(
"Description"),
'',
'L');
779 $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height);
780 if (empty($hidetop)) {
781 $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1);
782 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities(
"WeightVolShort"),
'',
'C');
786 if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
787 $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
788 if (empty($hidetop)) {
789 $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
790 $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities(
"QtyOrdered"),
'',
'C');
795 $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
796 if (empty($hidetop)) {
797 $pdf->SetXY($this->posxqtytoship, $tab_top + 1);
798 $statusreceived = Reception::STATUS_CLOSED;
800 $statusreceived = Reception::STATUS_VALIDATED;
803 $statusreceived = Reception::STATUS_CLOSED;
805 if ($object && $object->statut < $statusreceived) {
806 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities(
'QtyToReceive'),
'',
'C');
808 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities(
'QtyReceived'),
'',
'C');
813 if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
814 $pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height);
815 if (empty($hidetop)) {
816 $pdf->SetXY($this->posxpuht - 1, $tab_top + 1);
817 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
820 $pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height);
821 if (empty($hidetop)) {
822 $pdf->SetXY($this->posxtotalht - 1, $tab_top + 1);
823 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
838 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
840 global $conf, $langs, $mysoc;
842 $langs->load(
"orders");
849 $pdf->SetTextColor(0, 0, 60);
850 $pdf->SetFont(
'',
'B', $default_font_size + 3);
854 $posy = $this->marge_haute;
855 $posx = $this->page_largeur - $this->marge_droite - $w;
857 $pdf->SetXY($this->marge_gauche, $posy);
860 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
861 if ($this->emetteur->logo) {
862 if (is_readable($logo)) {
864 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
866 $pdf->SetTextColor(200, 0, 0);
867 $pdf->SetFont(
'',
'B', $default_font_size - 2);
868 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
869 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
872 $text = $this->emetteur->name;
873 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
877 if (isModEnabled(
'barcode')) {
880 $posx = $this->marge_gauche + 3;
883 if (isModEnabled(
'barcode')) {
889 $pdf->SetDrawColor(128, 128, 128);
890 if (isModEnabled(
'barcode')) {
897 $posx = $this->page_largeur - $w - $this->marge_droite;
898 $posy = $this->marge_haute;
900 $pdf->SetFont(
'',
'B', $default_font_size + 2);
901 $pdf->SetXY($posx, $posy);
902 $pdf->SetTextColor(0, 0, 60);
903 $title = $outputlangs->transnoentities(
"ReceptionSheet");
904 $pdf->MultiCell($w, 4, $title,
'',
'R');
906 $pdf->SetFont(
'',
'', $default_font_size + 1);
910 $pdf->SetXY($posx, $posy);
911 $pdf->SetTextColor(0, 0, 60);
912 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"RefReception").
" : ".$object->ref,
'',
'R');
915 if (!empty($object->date_delivery)) {
917 $pdf->SetXY($posx, $posy);
918 $pdf->SetTextColor(0, 0, 60);
919 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date($object->date_delivery,
"day",
false, $outputlangs,
true),
'',
'R');
922 if (!empty($object->thirdparty->code_fournisseur)) {
924 $pdf->SetXY($posx, $posy);
925 $pdf->SetTextColor(0, 0, 60);
926 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur),
'',
'R');
930 $pdf->SetFont(
'',
'', $default_font_size + 3);
934 $origin = $object->origin;
935 $origin_id = $object->origin_id;
938 if (isModEnabled(
"supplier_order")) {
939 $outputlangs->load(
'orders');
941 $classname =
'CommandeFournisseur';
942 $linkedobject =
new $classname($this->db);
943 $result = $linkedobject->fetch($origin_id);
947 $pdf->SetFont(
'',
'', $default_font_size - 2);
948 $text = $linkedobject->ref;
949 if (isset($linkedobject->ref_client) && !empty($linkedobject->ref_client)) {
950 $text .=
' ('.$linkedobject->ref_client.
')';
953 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
954 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"RefOrder").
" : ".$outputlangs->transnoentities($text), 0,
'R');
956 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
957 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($linkedobject->date,
"day",
false, $outputlangs,
true), 0,
'R');
963 $carac_emetteur =
'';
965 $arrayidcontact = array();
966 if (!empty($origin) && is_object($object->$origin)) {
967 $arrayidcontact = $object->$origin->getIdContact(
'internal',
'SALESREPFOLL');
969 if (empty($arrayidcontact)) {
970 $arrayidcontact = $object->$origin->getIdContact(
'internal',
'SHIPPING');
972 if (count($arrayidcontact) > 0) {
973 $object->fetch_user(reset($arrayidcontact));
974 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
975 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
977 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone :
'';
979 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email :
'';
981 $carac_emetteur .=
"\n";
984 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
987 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
988 $posx = $this->marge_gauche;
989 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
990 $posx = $this->page_largeur - $this->marge_droite - 80;
993 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
994 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
997 $pdf->SetTextColor(0, 0, 0);
998 $pdf->SetFont(
'',
'', $default_font_size - 2);
999 $pdf->SetXY($posx, $posy - 5);
1000 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Sender"), 0,
'L');
1001 $pdf->SetXY($posx, $posy);
1002 $pdf->SetFillColor(230, 230, 230);
1003 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1004 $pdf->SetTextColor(0, 0, 60);
1005 $pdf->SetFillColor(255, 255, 255);
1008 $usecontact =
false;
1009 $arrayidcontact = $object->$origin->getIdContact(
'external',
'SHIPPING');
1011 if (count($arrayidcontact) > 0) {
1013 $result = $object->fetch_contact($arrayidcontact[0]);
1017 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
1018 $thirdparty = $object->contact;
1020 $thirdparty = $object->thirdparty;
1025 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact :
null), $usecontact,
'targetwithdetails', $object);
1028 $pdf->SetXY($posx + 2, $posy + 3);
1029 $pdf->SetFont(
'',
'B', $default_font_size);
1030 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client_name, 0,
'L');
1032 $posy = $pdf->getY();
1035 $pdf->SetFont(
'',
'', $default_font_size - 1);
1036 $pdf->SetXY($posx + 2, $posy);
1037 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0,
'L');
1040 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1041 if ($this->page_largeur < 210) {
1044 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1045 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1046 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1047 $posx = $this->marge_gauche;
1051 $pdf->SetTextColor(0, 0, 0);
1052 $pdf->SetFont(
'',
'', $default_font_size - 2);
1053 $pdf->SetXY($posx + 2, $posy - 5);
1054 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient"), 0,
'L');
1055 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1060 $pdf->SetXY($posx + 2, $posy + 3);
1061 $pdf->SetFont(
'',
'B', $default_font_size);
1062 $pdf->MultiCell($widthrecbox, 2, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1063 $posy = $pdf->getY();
1066 $pdf->SetXY($posx + 2, $posy);
1067 $pdf->SetFont(
'',
'', $default_font_size - 1);
1068 $pdf->MultiCell($widthrecbox, 4, $carac_emetteur, 0,
'L');
1071 $pdf->SetTextColor(0, 0, 0);