138 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
141 global $user, $conf, $langs, $hookmanager;
143 $object->fetch_thirdparty();
145 if (!is_object($outputlangs)) {
146 $outputlangs = $langs;
150 $outputlangs->charset_output =
'ISO-8859-1';
153 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal",
"deliveries",
"receptions",
"productbatch",
"sendings"));
156 if ($object->statut == $object::STATUS_DRAFT && (
getDolGlobalString(
'RECEPTION_DRAFT_WATERMARK'))) {
157 $this->watermark = $conf->global->RECEPTION_DRAFT_WATERMARK;
160 $nblines = count($object->lines);
163 $realpatharray = array();
165 $objphoto =
new Product($this->db);
167 for ($i = 0; $i < $nblines; $i++) {
168 if (empty($object->lines[$i]->fk_product)) {
172 $objphoto =
new Product($this->db);
173 $objphoto->fetch($object->lines[$i]->fk_product);
176 $pdir =
get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
177 $dir = $conf->product->dir_output.
'/'.$pdir;
179 $pdir =
get_exdir(0, 2, 0, 0, $objphoto,
'product');
180 $dir = $conf->product->dir_output.
'/'.$pdir;
185 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
188 if ($obj[
'photo_vignette']) {
189 $filename = $obj[
'photo_vignette'];
191 $filename = $obj[
'photo'];
194 $filename = $obj[
'photo'];
197 $realpath = $dir.$filename;
202 $realpatharray[$i] = $realpath;
207 if (count($realpatharray) == 0) {
208 $this->posxpicture = $this->posxweightvol;
211 if ($conf->reception->dir_output) {
213 if ($object->specimen) {
214 $dir = $conf->reception->dir_output;
215 $file = $dir.
"/SPECIMEN.pdf";
218 $dir = $conf->reception->dir_output.
"/".$rcpref;
219 $file = $dir.
"/".$rcpref.
".pdf";
222 if (!file_exists($dir)) {
224 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
229 if (file_exists($dir)) {
231 if (!is_object($hookmanager)) {
232 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
235 $hookmanager->initHooks(array(
'pdfgeneration'));
236 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
238 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
241 $nblines = count($object->lines);
245 $heightforinfotot = 8;
246 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
247 $heightforfooter = $this->marge_basse + 8;
248 $pdf->SetAutoPageBreak(1, 0);
250 if (class_exists(
'TCPDF')) {
251 $pdf->setPrintHeader(
false);
252 $pdf->setPrintFooter(
false);
257 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
258 $tplidx = $pdf->importPage(1);
263 $pdf->SetDrawColor(128, 128, 128);
265 if (method_exists($pdf,
'AliasNbPages')) {
266 $pdf->AliasNbPages();
269 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
270 $pdf->SetSubject($outputlangs->transnoentities(
"Reception"));
271 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
272 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
273 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Reception"));
275 $pdf->SetCompression(
false);
278 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
282 if (!empty($tplidx)) {
283 $pdf->useTemplate($tplidx);
286 $this->
_pagehead($pdf, $object, 1, $outputlangs);
287 $pdf->SetFont(
'',
'', $default_font_size - 1);
288 $pdf->MultiCell(0, 3,
'');
289 $pdf->SetTextColor(0, 0, 0);
292 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
294 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
297 $height_incoterms = 0;
298 if (isModEnabled(
'incoterm')) {
299 $desc_incoterms = $object->getIncotermsForPDF();
300 if ($desc_incoterms) {
303 $pdf->SetFont(
'',
'', $default_font_size - 1);
304 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
305 $nexY = $pdf->GetY();
306 $height_incoterms = $nexY - $tab_top;
309 $pdf->SetDrawColor(192, 192, 192);
310 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
312 $tab_top = $nexY + 6;
313 $height_incoterms += 4;
317 if (!empty($object->note_public) || !empty($object->tracking_number)) {
318 $tab_top = 88 + $height_incoterms;
319 $tab_top_alt = $tab_top;
321 $pdf->SetFont(
'',
'B', $default_font_size - 2);
322 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top - 1, $outputlangs->transnoentities(
"TrackingNumber").
" : ".$object->tracking_number, 0, 1,
false,
true,
'L');
324 $tab_top_alt = $pdf->GetY();
328 if (!empty($object->tracking_number)) {
329 $object->getUrlTrackingStatus($object->tracking_number);
330 if (!empty($object->tracking_url)) {
331 if ($object->reception_method_id > 0) {
333 $code = $outputlangs->getLabelFromKey($this->db, $object->shipment_method_id,
'c_shipment_mode',
'rowid',
'code');
335 if ($object->tracking_url != $object->tracking_number) {
336 $label .= $outputlangs->trans(
"LinkToTrackYourPackage").
"<br>";
338 $label .= $outputlangs->trans(
"ReceptionMethod").
": ".$outputlangs->trans(
"ReceptionMethod".strtoupper($code));
340 if ($object->tracking_url != $object->tracking_number) {
342 $label .= $object->tracking_url;
344 $pdf->SetFont(
'',
'B', $default_font_size - 2);
345 $pdf->writeHTMLCell(60, 4, $this->posxdesc - 1, $tab_top_alt, $label, 0, 1,
false,
true,
'L');
347 $tab_top_alt = $pdf->GetY();
353 if (!empty($object->note_public)) {
354 $pdf->SetFont(
'',
'', $default_font_size - 1);
355 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top_alt,
dol_htmlentitiesbr($object->note_public), 0, 1);
358 $nexY = $pdf->GetY();
359 $height_note = $nexY - $tab_top;
362 $pdf->SetDrawColor(192, 192, 192);
363 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
365 $tab_height = $tab_height - $height_note;
366 $tab_top = $nexY + 6;
371 $iniY = $tab_top + 7;
372 $curY = $tab_top + 7;
373 $nexY = $tab_top + 7;
374 $fk_commandefourndet = 0;
379 for ($i = 0; $i < $nblines; $i++) {
381 $pdf->SetFont(
'',
'', $default_font_size - 1);
382 $pdf->SetTextColor(0, 0, 0);
385 $imglinesize = array();
386 if (!empty($realpatharray[$i])) {
390 $pdf->setTopMargin($tab_top_newpage);
391 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
392 $pageposbefore = $pdf->getPage();
394 $showpricebeforepagebreak = 1;
396 $posYAfterDescription = 0;
399 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
400 $pdf->AddPage(
'',
'',
true);
401 if (!empty($tplidx)) {
402 $pdf->useTemplate($tplidx);
405 $this->
_pagehead($pdf, $object, 0, $outputlangs);
407 $pdf->setPage($pageposbefore + 1);
409 $curY = $tab_top_newpage;
413 $showpricebeforepagebreak = 1;
415 $showpricebeforepagebreak = 0;
419 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
420 $curX = $this->posxpicture - 1;
421 $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
423 $posYAfterImage = $curY + $imglinesize[
'height'];
427 $curX = $this->posxdesc - 1;
441 $pdf->startTransaction();
442 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
444 $pageposafter = $pdf->getPage();
445 if ($pageposafter > $pageposbefore) {
446 $pdf->rollbackTransaction(
true);
447 $pageposafter = $pageposbefore;
449 $pdf->setPageOrientation(
'', 1, $heightforfooter);
451 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
453 $pageposafter = $pdf->getPage();
454 $posyafter = $pdf->GetY();
456 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
457 if ($i == ($nblines - 1)) {
458 $pdf->AddPage(
'',
'',
true);
459 if (!empty($tplidx)) {
460 $pdf->useTemplate($tplidx);
463 $this->
_pagehead($pdf, $object, 0, $outputlangs);
465 $pdf->setPage($pageposafter + 1);
472 $showpricebeforepagebreak = 1;
474 $showpricebeforepagebreak = 0;
478 $pdf->commitTransaction();
480 $posYAfterDescription = $pdf->GetY();
482 $nexY = max($pdf->GetY(), $posYAfterImage);
483 $pageposafter = $pdf->getPage();
485 $pdf->setPage($pageposbefore);
486 $pdf->setTopMargin($this->marge_haute);
487 $pdf->setPageOrientation(
'', 1, 0);
490 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
491 $pdf->setPage($pageposafter);
492 $curY = $tab_top_newpage;
496 if ($pageposafter > $pageposbefore) {
497 $pdf->setPage($pageposafter);
498 $curY = $tab_top_newpage;
501 $pdf->SetFont(
'',
'', $default_font_size - 1);
504 $pdf->SetXY($this->posxweightvol, $curY);
506 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->weight) {
507 $weighttxt = round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).
' '.
measuringUnitString(0,
"weight", $object->lines[$i]->product->weight_units, 1);
510 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->volume) {
511 $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);
514 $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ?
'<br>' :
'').$voltxt, 0, 0,
false,
true,
'C');
519 $pdf->SetXY($this->posxqtyordered, $curY);
520 if ($object->lines[$i]->fk_commandefourndet != $fk_commandefourndet) {
521 $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,
'',
'C');
522 $totalOrdered += $object->lines[$i]->qty_asked;
524 $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet;
528 $pdf->SetXY($this->posxqtytoship, $curY);
529 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty,
'',
'C');
533 $pdf->SetXY($this->posxpuht, $curY);
534 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3,
price($object->lines[$i]->subprice, 0, $outputlangs),
'',
'R');
536 $amountreceived =
price2num($object->lines[$i]->subprice * $object->lines[$i]->qty,
'MT');
537 $pdf->SetXY($this->posxtotalht, $curY);
538 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3,
price($amountreceived, 0, $outputlangs),
'',
'R');
540 $totalAmount += $amountreceived;
544 if ($weighttxt && $voltxt) {
550 $pdf->setPage($pageposafter);
551 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
553 $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1);
554 $pdf->SetLineStyle(array(
'dash'=>0));
558 while ($pagenb < $pageposafter) {
559 $pdf->setPage($pagenb);
561 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object);
563 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object);
565 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
567 $pdf->setPage($pagenb);
568 $pdf->setPageOrientation(
'', 1, 0);
569 if (!empty($tplidx)) {
570 $pdf->useTemplate($tplidx);
573 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
575 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object);
577 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object);
579 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
582 if (!empty($tplidx)) {
583 $pdf->useTemplate($tplidx);
591 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object);
592 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
594 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object);
595 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
599 $posy = $this->
_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered, $totalAmount);
602 $this->
_pagefoot($pdf, $object, $outputlangs);
603 if (method_exists($pdf,
'AliasNbPages')) {
604 $pdf->AliasNbPages();
609 $pdf->Output($file,
'F');
612 $hookmanager->initHooks(array(
'pdfgeneration'));
613 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
615 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
617 $this->error = $hookmanager->error;
618 $this->errors = $hookmanager->errors;
625 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
629 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"EXP_OUTPUTDIR");
648 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered, $totalAmount = 0)
651 global $conf, $mysoc;
659 $pdf->SetFont(
'',
'B', $default_font_size - 1);
662 $col1x = $this->posxweightvol - 50;
663 $col2x = $this->posxweightvol;
669 $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
671 $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
677 $totalWeighttoshow =
'';
678 $totalVolumetoshow =
'';
681 $tmparray = $object->getTotalWeightVolume();
682 $totalWeight = $tmparray[
'weight'];
683 $totalVolume = $tmparray[
'volume'];
684 $totalToShip = $tmparray[
'toship'];
688 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
689 $object->trueVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
690 $object->volume_units = $object->size_units * 3;
693 if ($totalWeight !=
'') {
696 if ($totalVolume !=
'') {
699 if (isset($object->trueWeight) && !empty($object->trueWeight)) {
700 $totalWeighttoshow =
showDimensionInBestUnit($object->trueWeight, $object->weight_units,
"weight", $outputlangs, -1,
'no', 1);
702 if (isset($object->trueVolume) && !empty($object->trueVolume)) {
703 $totalVolumetoshow =
showDimensionInBestUnit($object->trueVolume, $object->volume_units,
"volume", $outputlangs, -1,
'no', 1);
706 $pdf->SetFillColor(255, 255, 255);
707 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
708 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Total"), 0,
'L', 1);
713 if ($totalWeighttoshow) {
714 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * ($index + $index2));
715 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0,
'C', 1);
718 if ($totalVolumetoshow) {
719 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * ($index + $index2));
720 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0,
'C', 1);
726 $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
727 $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0,
'C', 1);
731 $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
732 $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0,
'C', 1);
736 $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
737 $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl,
'', 0,
'C', 1);
739 $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
740 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl,
price($totalAmount, 0, $outputlangs), 0,
'C', 1);
743 $pdf->SetTextColor(0, 0, 0);
750 return ($tab2_top + ($tab2_hl * $index));
767 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $object =
null)
780 $pdf->SetTextColor(0, 0, 0);
781 $pdf->SetFont(
'',
'', $default_font_size - 2);
784 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
786 $pdf->SetDrawColor(128, 128, 128);
787 $pdf->SetFont(
'',
'', $default_font_size - 1);
790 if (empty($hidetop)) {
791 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
793 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
794 $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities(
"Description"),
'',
'L');
798 $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height);
799 if (empty($hidetop)) {
800 $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1);
801 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities(
"WeightVolShort"),
'',
'C');
806 $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
807 if (empty($hidetop)) {
808 $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
809 $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities(
"QtyOrdered"),
'',
'C');
814 $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
815 if (empty($hidetop)) {
816 $pdf->SetXY($this->posxqtytoship, $tab_top + 1);
817 $statusreceived = Reception::STATUS_CLOSED;
819 $statusreceived = Reception::STATUS_VALIDATED;
822 $statusreceived = Reception::STATUS_CLOSED;
824 if ($object && $object->statut < $statusreceived) {
825 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities(
'QtyToReceive'),
'',
'C');
827 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities(
'QtyReceived'),
'',
'C');
833 $pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height);
834 if (empty($hidetop)) {
835 $pdf->SetXY($this->posxpuht - 1, $tab_top + 1);
836 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
839 $pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height);
840 if (empty($hidetop)) {
841 $pdf->SetXY($this->posxtotalht - 1, $tab_top + 1);
842 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
857 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
859 global $conf, $langs, $mysoc;
861 $langs->load(
"orders");
868 $pdf->SetTextColor(0, 0, 60);
869 $pdf->SetFont(
'',
'B', $default_font_size + 3);
873 $posy = $this->marge_haute;
874 $posx = $this->page_largeur - $this->marge_droite - $w;
876 $pdf->SetXY($this->marge_gauche, $posy);
879 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
880 if ($this->emetteur->logo) {
881 if (is_readable($logo)) {
883 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
885 $pdf->SetTextColor(200, 0, 0);
886 $pdf->SetFont(
'',
'B', $default_font_size - 2);
887 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
888 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
891 $text = $this->emetteur->name;
892 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
896 if (isModEnabled(
'barcode')) {
899 $posx = $this->marge_gauche + 3;
902 if (isModEnabled(
'barcode')) {
908 $pdf->SetDrawColor(128, 128, 128);
910 $posx = $this->page_largeur - $w - $this->marge_droite;
911 $posy = $this->marge_haute;
913 $pdf->SetFont(
'',
'B', $default_font_size + 2);
914 $pdf->SetXY($posx, $posy);
915 $pdf->SetTextColor(0, 0, 60);
916 $title = $outputlangs->transnoentities(
"ReceptionSheet");
917 $pdf->MultiCell($w, 4, $title,
'',
'R');
919 $pdf->SetFont(
'',
'', $default_font_size + 1);
923 $pdf->SetXY($posx, $posy);
924 $pdf->SetTextColor(0, 0, 60);
925 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"RefReception").
" : ".$object->ref,
'',
'R');
928 if (!empty($object->date_delivery)) {
930 $pdf->SetXY($posx, $posy);
931 $pdf->SetTextColor(0, 0, 60);
932 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date($object->date_delivery,
"day",
false, $outputlangs,
true),
'',
'R');
935 if (!empty($object->thirdparty->code_fournisseur)) {
937 $pdf->SetXY($posx, $posy);
938 $pdf->SetTextColor(0, 0, 60);
939 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur),
'',
'R');
943 $pdf->SetFont(
'',
'', $default_font_size + 3);
947 $origin = $object->origin;
948 $origin_id = $object->origin_id;
951 if (isModEnabled(
"supplier_order")) {
952 $outputlangs->load(
'orders');
954 $classname =
'CommandeFournisseur';
955 $linkedobject =
new $classname($this->db);
956 $result = $linkedobject->fetch($origin_id);
960 $pdf->SetFont(
'',
'', $default_font_size - 2);
961 $text = $linkedobject->ref;
962 if (isset($linkedobject->ref_client) && !empty($linkedobject->ref_client)) {
963 $text .=
' ('.$linkedobject->ref_client.
')';
966 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
967 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"RefOrder").
" : ".$outputlangs->transnoentities($text), 0,
'R');
969 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
970 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($linkedobject->date,
"day",
false, $outputlangs,
true), 0,
'R');
976 $carac_emetteur =
'';
978 $arrayidcontact = array();
979 if (!empty($origin) && is_object($object->$origin)) {
980 $arrayidcontact = $object->$origin->getIdContact(
'internal',
'SALESREPFOLL');
982 if (empty($arrayidcontact)) {
983 $arrayidcontact = $object->$origin->getIdContact(
'internal',
'SHIPPING');
985 if (count($arrayidcontact) > 0) {
986 $object->fetch_user(reset($arrayidcontact));
987 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
988 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
990 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone :
'';
992 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email :
'';
994 $carac_emetteur .=
"\n";
997 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
1001 $posx = $this->marge_gauche;
1003 $posx = $this->page_largeur - $this->marge_droite - 80;
1010 $pdf->SetTextColor(0, 0, 0);
1011 $pdf->SetFont(
'',
'', $default_font_size - 2);
1012 $pdf->SetXY($posx, $posy - 5);
1013 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Sender"), 0,
'L');
1014 $pdf->SetXY($posx, $posy);
1015 $pdf->SetFillColor(230, 230, 230);
1016 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1017 $pdf->SetTextColor(0, 0, 60);
1018 $pdf->SetFillColor(255, 255, 255);
1021 $usecontact =
false;
1022 $arrayidcontact = $object->$origin->getIdContact(
'external',
'SHIPPING');
1024 if (count($arrayidcontact) > 0) {
1026 $result = $object->fetch_contact($arrayidcontact[0]);
1030 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1031 $thirdparty = $object->contact;
1033 $thirdparty = $object->thirdparty;
1038 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact :
null), $usecontact,
'targetwithdetails', $object);
1041 $pdf->SetXY($posx + 2, $posy + 3);
1042 $pdf->SetFont(
'',
'B', $default_font_size);
1043 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client_name, 0,
'L');
1045 $posy = $pdf->getY();
1048 $pdf->SetFont(
'',
'', $default_font_size - 1);
1049 $pdf->SetXY($posx + 2, $posy);
1050 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0,
'L');
1054 if ($this->page_largeur < 210) {
1058 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1060 $posx = $this->marge_gauche;
1064 $pdf->SetTextColor(0, 0, 0);
1065 $pdf->SetFont(
'',
'', $default_font_size - 2);
1066 $pdf->SetXY($posx + 2, $posy - 5);
1067 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient"), 0,
'L');
1068 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1073 $pdf->SetXY($posx + 2, $posy + 3);
1074 $pdf->SetFont(
'',
'B', $default_font_size);
1075 $pdf->MultiCell($widthrecbox, 2, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1076 $posy = $pdf->getY();
1079 $pdf->SetXY($posx + 2, $posy);
1080 $pdf->SetFont(
'',
'', $default_font_size - 1);
1081 $pdf->MultiCell($widthrecbox, 4, $carac_emetteur, 0,
'L');
1084 $pdf->SetTextColor(0, 0, 0);