25 require_once DOL_DOCUMENT_ROOT.
'/core/modules/reception/modules_reception.php';
26 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
27 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
49 global $conf, $langs, $mysoc;
52 $this->
name =
"squille";
53 $this->
description = $langs->trans(
"DocumentModelStandardPDF");
57 $this->page_largeur = $formatarray[
'width'];
58 $this->page_hauteur = $formatarray[
'height'];
59 $this->format = array($this->page_largeur, $this->page_hauteur);
60 $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
61 $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
62 $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
63 $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
65 $this->option_logo = 1;
66 $this->option_draft_watermark = 1;
67 $this->watermark =
'';
70 $this->emetteur = $mysoc;
71 if (!$this->emetteur->country_code) {
72 $this->emetteur->country_code = substr($langs->defaultlang, -2);
76 $this->posxdesc = $this->marge_gauche + 1;
77 $this->posxweightvol = $this->page_largeur - $this->marge_droite - 78;
78 $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 56;
79 $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 28;
80 $this->posxpuht = $this->page_largeur - $this->marge_droite;
82 if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
83 $this->posxweightvol = $this->page_largeur - $this->marge_droite - 118;
84 $this->posxqtyordered = $this->page_largeur - $this->marge_droite - 96;
85 $this->posxqtytoship = $this->page_largeur - $this->marge_droite - 68;
86 $this->posxpuht = $this->page_largeur - $this->marge_droite - 40;
87 $this->posxtotalht = $this->page_largeur - $this->marge_droite - 20;
90 $this->posxpicture = $this->posxweightvol - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
92 if ($this->page_largeur < 210) {
93 $this->posxweightvol -= 20;
94 $this->posxpicture -= 20;
95 $this->posxqtyordered -= 20;
96 $this->posxqtytoship -= 20;
99 if (!empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
100 $this->posxweightvol += ($this->posxqtytoship - $this->posxqtyordered);
101 $this->posxpicture += ($this->posxqtytoship - $this->posxqtyordered);
102 $this->posxqtyordered = $this->posxqtytoship;
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)) {
147 for ($i = 0; $i < $nblines; $i++) {
148 if (empty($object->lines[$i]->fk_product)) {
153 $objphoto->fetch($object->lines[$i]->fk_product);
155 if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
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) {
166 if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
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"));
254 if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
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 = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 : 10);
274 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
277 $height_incoterms = 0;
278 if (!empty($conf->incoterm->enabled)) {
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;
357 for ($i = 0; $i < $nblines; $i++) {
359 $pdf->SetFont(
'',
'', $default_font_size - 1);
360 $pdf->SetTextColor(0, 0, 0);
363 $imglinesize = array();
364 if (!empty($realpatharray[$i])) {
368 $pdf->setTopMargin($tab_top_newpage);
369 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
370 $pageposbefore = $pdf->getPage();
372 $showpricebeforepagebreak = 1;
374 $posYAfterDescription = 0;
377 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
378 $pdf->AddPage(
'',
'',
true);
379 if (!empty($tplidx)) {
380 $pdf->useTemplate($tplidx);
382 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
383 $this->
_pagehead($pdf, $object, 0, $outputlangs);
385 $pdf->setPage($pageposbefore + 1);
387 $curY = $tab_top_newpage;
390 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
391 $showpricebeforepagebreak = 1;
393 $showpricebeforepagebreak = 0;
397 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
398 $curX = $this->posxpicture - 1;
399 $pdf->Image($realpatharray[$i], $curX + (($this->posxweightvol - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
401 $posYAfterImage = $curY + $imglinesize[
'height'];
405 $curX = $this->posxdesc - 1;
419 $pdf->startTransaction();
420 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
422 $pageposafter = $pdf->getPage();
423 if ($pageposafter > $pageposbefore) {
424 $pdf->rollbackTransaction(
true);
425 $pageposafter = $pageposbefore;
427 $pdf->setPageOrientation(
'', 1, $heightforfooter);
429 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
431 $pageposafter = $pdf->getPage();
432 $posyafter = $pdf->GetY();
434 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
435 if ($i == ($nblines - 1)) {
436 $pdf->AddPage(
'',
'',
true);
437 if (!empty($tplidx)) {
438 $pdf->useTemplate($tplidx);
440 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
441 $this->
_pagehead($pdf, $object, 0, $outputlangs);
443 $pdf->setPage($pageposafter + 1);
449 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
450 $showpricebeforepagebreak = 1;
452 $showpricebeforepagebreak = 0;
457 $pdf->commitTransaction();
459 $posYAfterDescription = $pdf->GetY();
461 $nexY = max($pdf->GetY(), $posYAfterImage);
462 $pageposafter = $pdf->getPage();
464 $pdf->setPage($pageposbefore);
465 $pdf->setTopMargin($this->marge_haute);
466 $pdf->setPageOrientation(
'', 1, 0);
469 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
470 $pdf->setPage($pageposafter);
471 $curY = $tab_top_newpage;
475 if ($pageposafter > $pageposbefore) {
476 $pdf->setPage($pageposafter);
477 $curY = $tab_top_newpage;
480 $pdf->SetFont(
'',
'', $default_font_size - 1);
482 $pdf->SetXY($this->posxweightvol, $curY);
484 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->weight) {
485 $weighttxt = round($object->lines[$i]->product->weight * $object->lines[$i]->qty, 5).
' '.
measuringUnitString(0,
"weight", $object->lines[$i]->product->weight_units);
488 if ($object->lines[$i]->fk_product_type == 0 && $object->lines[$i]->product->volume) {
489 $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);
492 $pdf->writeHTMLCell($this->posxqtyordered - $this->posxweightvol + 2, 3, $this->posxweightvol - 1, $curY, $weighttxt.(($weighttxt && $voltxt) ?
'<br>' :
'').$voltxt, 0, 0,
false,
true,
'C');
495 if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
496 $pdf->SetXY($this->posxqtyordered, $curY);
497 if ($object->lines[$i]->fk_commandefourndet != $fk_commandefourndet) {
498 $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 3, $object->lines[$i]->qty_asked,
'',
'C');
499 $totalOrdered += $object->lines[$i]->qty_asked;
501 $fk_commandefourndet = $object->lines[$i]->fk_commandefourndet;
504 $pdf->SetXY($this->posxqtytoship, $curY);
505 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 3, $object->lines[$i]->qty,
'',
'C');
507 if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
508 $pdf->SetXY($this->posxpuht, $curY);
509 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht - 1), 3,
price($object->lines[$i]->subprice, 0, $outputlangs),
'',
'R');
511 $pdf->SetXY($this->posxtotalht, $curY);
512 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 3,
price($object->lines[$i]->total_ht, 0, $outputlangs),
'',
'R');
516 if ($weighttxt && $voltxt) {
521 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
522 $pdf->setPage($pageposafter);
523 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
525 $pdf->line($this->marge_gauche, $nexY - 1, $this->page_largeur - $this->marge_droite, $nexY - 1);
526 $pdf->SetLineStyle(array(
'dash'=>0));
530 while ($pagenb < $pageposafter) {
531 $pdf->setPage($pagenb);
533 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object);
535 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object);
537 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
539 $pdf->setPage($pagenb);
540 $pdf->setPageOrientation(
'', 1, 0);
541 if (!empty($tplidx)) {
542 $pdf->useTemplate($tplidx);
545 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
547 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object);
549 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object);
551 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
554 if (!empty($tplidx)) {
555 $pdf->useTemplate($tplidx);
563 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object);
564 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
566 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object);
567 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
571 $posy = $this->
_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs, $totalOrdered);
574 $this->
_pagefoot($pdf, $object, $outputlangs);
575 if (method_exists($pdf,
'AliasNbPages')) {
576 $pdf->AliasNbPages();
581 $pdf->Output($file,
'F');
584 $hookmanager->initHooks(array(
'pdfgeneration'));
585 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
587 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
589 $this->error = $hookmanager->error;
590 $this->errors = $hookmanager->errors;
593 if (!empty($conf->global->MAIN_UMASK)) {
594 @chmod($file, octdec($conf->global->MAIN_UMASK));
599 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
603 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"EXP_OUTPUTDIR");
621 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered)
624 global $conf, $mysoc;
632 $pdf->SetFont(
'',
'B', $default_font_size - 1);
635 $col1x = $this->posxweightvol - 50;
636 $col2x = $this->posxweightvol;
641 if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
642 $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
644 $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
650 $totalWeighttoshow =
'';
651 $totalVolumetoshow =
'';
654 $tmparray = $object->getTotalWeightVolume();
655 $totalWeight = $tmparray[
'weight'];
656 $totalVolume = $tmparray[
'volume'];
657 $totalToShip = $tmparray[
'toship'];
661 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
662 $object->trueVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
663 $object->volume_units = $object->size_units * 3;
666 if ($totalWeight !=
'') {
669 if ($totalVolume !=
'') {
672 if ($object->trueWeight) {
673 $totalWeighttoshow =
showDimensionInBestUnit($object->trueWeight, $object->weight_units,
"weight", $outputlangs);
675 if ($object->trueVolume) {
676 $totalVolumetoshow =
showDimensionInBestUnit($object->trueVolume, $object->volume_units,
"volume", $outputlangs);
679 $pdf->SetFillColor(255, 255, 255);
680 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
681 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Total"), 0,
'L', 1);
683 if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
684 $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
685 $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0,
'C', 1);
688 $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
689 $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0,
'C', 1);
691 if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
692 $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
693 $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl,
'', 0,
'C', 1);
695 $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
696 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl,
price($object->total_ht, 0, $outputlangs), 0,
'C', 1);
700 if ($totalWeighttoshow) {
701 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
702 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0,
'C', 1);
706 if ($totalVolumetoshow) {
707 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * $index);
708 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0,
'C', 1);
712 if (!$totalWeighttoshow && !$totalVolumetoshow) {
716 $pdf->SetTextColor(0, 0, 0);
718 return ($tab2_top + ($tab2_hl * $index));
735 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $object =
null)
748 $pdf->SetTextColor(0, 0, 0);
749 $pdf->SetFont(
'',
'', $default_font_size - 2);
752 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
754 $pdf->SetDrawColor(128, 128, 128);
755 $pdf->SetFont(
'',
'', $default_font_size - 1);
757 if (empty($hidetop)) {
758 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
760 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
761 $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities(
"Description"),
'',
'L');
764 $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height);
765 if (empty($hidetop)) {
766 $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1);
767 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities(
"WeightVolShort"),
'',
'C');
770 if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
771 $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
772 if (empty($hidetop)) {
773 $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
774 $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities(
"QtyOrdered"),
'',
'C');
778 $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
779 if (empty($hidetop)) {
780 $pdf->SetXY($this->posxqtytoship, $tab_top + 1);
781 $statusreceived = Reception::STATUS_CLOSED;
783 $statusreceived = Reception::STATUS_VALIDATED;
786 $statusreceived = Reception::STATUS_CLOSED;
788 if ($object && $object->statut < $statusreceived) {
789 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities(
'QtyToReceive'),
'',
'C');
791 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities(
'QtyReceived'),
'',
'C');
795 if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
796 $pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height);
797 if (empty($hidetop)) {
798 $pdf->SetXY($this->posxpuht - 1, $tab_top + 1);
799 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
802 $pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height);
803 if (empty($hidetop)) {
804 $pdf->SetXY($this->posxtotalht - 1, $tab_top + 1);
805 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
820 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
822 global $conf, $langs, $mysoc;
824 $langs->load(
"orders");
831 $pdf->SetTextColor(0, 0, 60);
832 $pdf->SetFont(
'',
'B', $default_font_size + 3);
836 $posy = $this->marge_haute;
837 $posx = $this->page_largeur - $this->marge_droite - $w;
839 $pdf->SetXY($this->marge_gauche, $posy);
842 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
843 if ($this->emetteur->logo) {
844 if (is_readable($logo)) {
846 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
848 $pdf->SetTextColor(200, 0, 0);
849 $pdf->SetFont(
'',
'B', $default_font_size - 2);
850 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
851 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
854 $text = $this->emetteur->name;
855 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
859 if (!empty($conf->barcode->enabled)) {
862 $posx = $this->marge_gauche + 3;
865 if (!empty($conf->barcode->enabled)) {
871 $pdf->SetDrawColor(128, 128, 128);
872 if (!empty($conf->barcode->enabled)) {
879 $posx = $this->page_largeur - $w - $this->marge_droite;
880 $posy = $this->marge_haute;
882 $pdf->SetFont(
'',
'B', $default_font_size + 2);
883 $pdf->SetXY($posx, $posy);
884 $pdf->SetTextColor(0, 0, 60);
885 $title = $outputlangs->transnoentities(
"ReceptionSheet");
886 $pdf->MultiCell($w, 4, $title,
'',
'R');
888 $pdf->SetFont(
'',
'', $default_font_size + 1);
892 $pdf->SetXY($posx, $posy);
893 $pdf->SetTextColor(0, 0, 60);
894 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"RefReception").
" : ".$object->ref,
'',
'R');
897 if (!empty($object->date_delivery)) {
899 $pdf->SetXY($posx, $posy);
900 $pdf->SetTextColor(0, 0, 60);
901 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date($object->date_delivery,
"day",
false, $outputlangs,
true),
'',
'R');
904 if (!empty($object->thirdparty->code_fournisseur)) {
906 $pdf->SetXY($posx, $posy);
907 $pdf->SetTextColor(0, 0, 60);
908 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur),
'',
'R');
912 $pdf->SetFont(
'',
'', $default_font_size + 3);
916 $origin = $object->origin;
917 $origin_id = $object->origin_id;
920 if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) || !empty($conf->supplier_order->enabled)) {
921 $outputlangs->load(
'orders');
923 $classname =
'CommandeFournisseur';
924 $linkedobject =
new $classname($this->
db);
925 $result = $linkedobject->fetch($origin_id);
929 $pdf->SetFont(
'',
'', $default_font_size - 2);
930 $text = $linkedobject->ref;
931 if ($linkedobject->ref_client) {
932 $text .=
' ('.$linkedobject->ref_client.
')';
935 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
936 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"RefOrder").
" : ".$outputlangs->transnoentities($text), 0,
'R');
938 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
939 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($linkedobject->date,
"day",
false, $outputlangs,
true), 0,
'R');
945 $carac_emetteur =
'';
947 $arrayidcontact = array();
948 if (!empty($origin) && is_object($object->$origin)) {
949 $arrayidcontact = $object->$origin->getIdContact(
'internal',
'SALESREPFOLL');
951 if (empty($arrayidcontact)) {
952 $arrayidcontact = $object->$origin->getIdContact(
'internal',
'SHIPPING');
954 if (count($arrayidcontact) > 0) {
955 $object->fetch_user(reset($arrayidcontact));
956 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Name").
": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)).
"\n";
959 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
962 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
963 $posx = $this->marge_gauche;
964 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
965 $posx = $this->page_largeur - $this->marge_droite - 80;
968 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
969 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
972 $pdf->SetTextColor(0, 0, 0);
973 $pdf->SetFont(
'',
'', $default_font_size - 2);
974 $pdf->SetXY($posx, $posy - 5);
975 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Sender"), 0,
'L');
976 $pdf->SetXY($posx, $posy);
977 $pdf->SetFillColor(230, 230, 230);
978 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
979 $pdf->SetTextColor(0, 0, 60);
980 $pdf->SetFillColor(255, 255, 255);
984 $arrayidcontact = $object->$origin->getIdContact(
'external',
'SHIPPING');
986 if (count($arrayidcontact) > 0) {
988 $result = $object->fetch_contact($arrayidcontact[0]);
992 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)))) {
993 $thirdparty = $object->contact;
995 $thirdparty = $object->thirdparty;
1000 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact :
null), $usecontact,
'targetwithdetails', $object);
1003 $pdf->SetXY($posx + 2, $posy + 3);
1004 $pdf->SetFont(
'',
'B', $default_font_size);
1005 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client_name, 0,
'L');
1007 $posy = $pdf->getY();
1010 $pdf->SetFont(
'',
'', $default_font_size - 1);
1011 $pdf->SetXY($posx + 2, $posy);
1012 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0,
'L');
1015 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1016 if ($this->page_largeur < 210) {
1019 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1020 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1021 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1022 $posx = $this->marge_gauche;
1026 $pdf->SetTextColor(0, 0, 0);
1027 $pdf->SetFont(
'',
'', $default_font_size - 2);
1028 $pdf->SetXY($posx + 2, $posy - 5);
1029 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient"), 0,
'L');
1030 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1035 $pdf->SetXY($posx + 2, $posy + 3);
1036 $pdf->SetFont(
'',
'B', $default_font_size);
1037 $pdf->MultiCell($widthrecbox, 2, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1038 $posy = $pdf->getY();
1041 $pdf->SetXY($posx + 2, $posy);
1042 $pdf->SetFont(
'',
'', $default_font_size - 1);
1043 $pdf->MultiCell($widthrecbox, 4, $carac_emetteur, 0,
'L');
1046 $pdf->SetTextColor(0, 0, 0);
1059 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1062 $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1063 return pdf_pagefoot($pdf, $outputlangs,
'RECEPTION_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);