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);
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);
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;
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;
602 if (!empty($conf->global->MAIN_UMASK)) {
603 @chmod($file, octdec($conf->global->MAIN_UMASK));
608 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
612 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"EXP_OUTPUTDIR");
631 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered, $totalAmount = 0)
634 global $conf, $mysoc;
642 $pdf->SetFont(
'',
'B', $default_font_size - 1);
645 $col1x = $this->posxweightvol - 50;
646 $col2x = $this->posxweightvol;
651 if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
652 $largcol2 = ($this->posxqtyordered - $this->posxweightvol);
654 $largcol2 = ($this->posxqtytoship - $this->posxweightvol);
660 $totalWeighttoshow =
'';
661 $totalVolumetoshow =
'';
664 $tmparray = $object->getTotalWeightVolume();
665 $totalWeight = $tmparray[
'weight'];
666 $totalVolume = $tmparray[
'volume'];
667 $totalToShip = $tmparray[
'toship'];
671 if ($object->trueWidth && $object->trueHeight && $object->trueDepth) {
672 $object->trueVolume = ($object->trueWidth * $object->trueHeight * $object->trueDepth);
673 $object->volume_units = $object->size_units * 3;
676 if ($totalWeight !=
'') {
679 if ($totalVolume !=
'') {
682 if ($object->trueWeight) {
683 $totalWeighttoshow =
showDimensionInBestUnit($object->trueWeight, $object->weight_units,
"weight", $outputlangs, -1,
'no', 1);
685 if ($object->trueVolume) {
686 $totalVolumetoshow =
showDimensionInBestUnit($object->trueVolume, $object->volume_units,
"volume", $outputlangs, -1,
'no', 1);
689 $pdf->SetFillColor(255, 255, 255);
690 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
691 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Total"), 0,
'L', 1);
696 if ($totalWeighttoshow) {
697 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * ($index + $index2));
698 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalWeighttoshow, 0,
'C', 1);
701 if ($totalVolumetoshow) {
702 $pdf->SetXY($this->posxweightvol, $tab2_top + $tab2_hl * ($index + $index2));
703 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), $tab2_hl, $totalVolumetoshow, 0,
'C', 1);
708 if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
709 $pdf->SetXY($this->posxqtyordered, $tab2_top + $tab2_hl * $index);
710 $pdf->MultiCell($this->posxqtytoship - $this->posxqtyordered, $tab2_hl, $totalOrdered, 0,
'C', 1);
714 $pdf->SetXY($this->posxqtytoship, $tab2_top + $tab2_hl * $index);
715 $pdf->MultiCell($this->posxpuht - $this->posxqtytoship, $tab2_hl, $totalToShip, 0,
'C', 1);
718 if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
719 $pdf->SetXY($this->posxpuht, $tab2_top + $tab2_hl * $index);
720 $pdf->MultiCell($this->posxtotalht - $this->posxpuht, $tab2_hl,
'', 0,
'C', 1);
722 $pdf->SetXY($this->posxtotalht, $tab2_top + $tab2_hl * $index);
723 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->posxtotalht, $tab2_hl,
price($totalAmount, 0, $outputlangs), 0,
'C', 1);
726 $pdf->SetTextColor(0, 0, 0);
733 return ($tab2_top + ($tab2_hl * $index));
750 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $object =
null)
763 $pdf->SetTextColor(0, 0, 0);
764 $pdf->SetFont(
'',
'', $default_font_size - 2);
767 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
769 $pdf->SetDrawColor(128, 128, 128);
770 $pdf->SetFont(
'',
'', $default_font_size - 1);
773 if (empty($hidetop)) {
774 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
776 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
777 $pdf->MultiCell($this->posxqtyordered - $this->posxdesc, 2, $outputlangs->transnoentities(
"Description"),
'',
'L');
781 $pdf->line($this->posxweightvol - 1, $tab_top, $this->posxweightvol - 1, $tab_top + $tab_height);
782 if (empty($hidetop)) {
783 $pdf->SetXY($this->posxweightvol - 1, $tab_top + 1);
784 $pdf->MultiCell(($this->posxqtyordered - $this->posxweightvol), 2, $outputlangs->transnoentities(
"WeightVolShort"),
'',
'C');
788 if (empty($conf->global->RECEPTION_PDF_HIDE_ORDERED)) {
789 $pdf->line($this->posxqtyordered - 1, $tab_top, $this->posxqtyordered - 1, $tab_top + $tab_height);
790 if (empty($hidetop)) {
791 $pdf->SetXY($this->posxqtyordered - 1, $tab_top + 1);
792 $pdf->MultiCell(($this->posxqtytoship - $this->posxqtyordered), 2, $outputlangs->transnoentities(
"QtyOrdered"),
'',
'C');
797 $pdf->line($this->posxqtytoship - 1, $tab_top, $this->posxqtytoship - 1, $tab_top + $tab_height);
798 if (empty($hidetop)) {
799 $pdf->SetXY($this->posxqtytoship, $tab_top + 1);
800 $statusreceived = Reception::STATUS_CLOSED;
802 $statusreceived = Reception::STATUS_VALIDATED;
805 $statusreceived = Reception::STATUS_CLOSED;
807 if ($object && $object->statut < $statusreceived) {
808 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities(
'QtyToReceive'),
'',
'C');
810 $pdf->MultiCell(($this->posxpuht - $this->posxqtytoship), 2, $outputlangs->transnoentities(
'QtyReceived'),
'',
'C');
815 if (!empty($conf->global->MAIN_PDF_RECEPTION_DISPLAY_AMOUNT_HT)) {
816 $pdf->line($this->posxpuht - 1, $tab_top, $this->posxpuht - 1, $tab_top + $tab_height);
817 if (empty($hidetop)) {
818 $pdf->SetXY($this->posxpuht - 1, $tab_top + 1);
819 $pdf->MultiCell(($this->posxtotalht - $this->posxpuht), 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
822 $pdf->line($this->posxtotalht - 1, $tab_top, $this->posxtotalht - 1, $tab_top + $tab_height);
823 if (empty($hidetop)) {
824 $pdf->SetXY($this->posxtotalht - 1, $tab_top + 1);
825 $pdf->MultiCell(($this->page_largeur - $this->marge_droite - $this->posxtotalht), 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
840 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
842 global $conf, $langs, $mysoc;
844 $langs->load(
"orders");
851 $pdf->SetTextColor(0, 0, 60);
852 $pdf->SetFont(
'',
'B', $default_font_size + 3);
856 $posy = $this->marge_haute;
857 $posx = $this->page_largeur - $this->marge_droite - $w;
859 $pdf->SetXY($this->marge_gauche, $posy);
862 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
863 if ($this->emetteur->logo) {
864 if (is_readable($logo)) {
866 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
868 $pdf->SetTextColor(200, 0, 0);
869 $pdf->SetFont(
'',
'B', $default_font_size - 2);
870 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
871 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
874 $text = $this->emetteur->name;
875 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
882 $posx = $this->marge_gauche + 3;
891 $pdf->SetDrawColor(128, 128, 128);
899 $posx = $this->page_largeur - $w - $this->marge_droite;
900 $posy = $this->marge_haute;
902 $pdf->SetFont(
'',
'B', $default_font_size + 2);
903 $pdf->SetXY($posx, $posy);
904 $pdf->SetTextColor(0, 0, 60);
905 $title = $outputlangs->transnoentities(
"ReceptionSheet");
906 $pdf->MultiCell($w, 4, $title,
'',
'R');
908 $pdf->SetFont(
'',
'', $default_font_size + 1);
912 $pdf->SetXY($posx, $posy);
913 $pdf->SetTextColor(0, 0, 60);
914 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"RefReception").
" : ".$object->ref,
'',
'R');
917 if (!empty($object->date_delivery)) {
919 $pdf->SetXY($posx, $posy);
920 $pdf->SetTextColor(0, 0, 60);
921 $pdf->MultiCell($w, 4, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date($object->date_delivery,
"day",
false, $outputlangs,
true),
'',
'R');
924 if (!empty($object->thirdparty->code_fournisseur)) {
926 $pdf->SetXY($posx, $posy);
927 $pdf->SetTextColor(0, 0, 60);
928 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur),
'',
'R');
932 $pdf->SetFont(
'',
'', $default_font_size + 3);
936 $origin = $object->origin;
937 $origin_id = $object->origin_id;
940 if ((
isModEnabled(
"fournisseur") && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)) ||
isModEnabled(
"supplier_order")) {
941 $outputlangs->load(
'orders');
943 $classname =
'CommandeFournisseur';
944 $linkedobject =
new $classname($this->
db);
945 $result = $linkedobject->fetch($origin_id);
949 $pdf->SetFont(
'',
'', $default_font_size - 2);
950 $text = $linkedobject->ref;
951 if ($linkedobject->ref_client) {
952 $text .=
' ('.$linkedobject->ref_client.
')';
955 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
956 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"RefOrder").
" : ".$outputlangs->transnoentities($text), 0,
'R');
958 $pdf->SetXY($this->page_largeur - $this->marge_droite - $w, $Yoff);
959 $pdf->MultiCell($w, 2, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($linkedobject->date,
"day",
false, $outputlangs,
true), 0,
'R');
965 $carac_emetteur =
'';
967 $arrayidcontact = array();
968 if (!empty($origin) && is_object($object->$origin)) {
969 $arrayidcontact = $object->$origin->getIdContact(
'internal',
'SALESREPFOLL');
971 if (empty($arrayidcontact)) {
972 $arrayidcontact = $object->$origin->getIdContact(
'internal',
'SHIPPING');
974 if (count($arrayidcontact) > 0) {
975 $object->fetch_user(reset($arrayidcontact));
976 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$outputlangs->transnoentities(
"Name").
": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)).
"\n";
979 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty);
982 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
983 $posx = $this->marge_gauche;
984 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
985 $posx = $this->page_largeur - $this->marge_droite - 80;
988 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
989 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
992 $pdf->SetTextColor(0, 0, 0);
993 $pdf->SetFont(
'',
'', $default_font_size - 2);
994 $pdf->SetXY($posx, $posy - 5);
995 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Sender"), 0,
'L');
996 $pdf->SetXY($posx, $posy);
997 $pdf->SetFillColor(230, 230, 230);
998 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
999 $pdf->SetTextColor(0, 0, 60);
1000 $pdf->SetFillColor(255, 255, 255);
1003 $usecontact =
false;
1004 $arrayidcontact = $object->$origin->getIdContact(
'external',
'SHIPPING');
1006 if (count($arrayidcontact) > 0) {
1008 $result = $object->fetch_contact($arrayidcontact[0]);
1012 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)))) {
1013 $thirdparty = $object->contact;
1015 $thirdparty = $object->thirdparty;
1020 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, (!empty($object->contact) ? $object->contact :
null), $usecontact,
'targetwithdetails', $object);
1023 $pdf->SetXY($posx + 2, $posy + 3);
1024 $pdf->SetFont(
'',
'B', $default_font_size);
1025 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client_name, 0,
'L');
1027 $posy = $pdf->getY();
1030 $pdf->SetFont(
'',
'', $default_font_size - 1);
1031 $pdf->SetXY($posx + 2, $posy);
1032 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0,
'L');
1035 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1036 if ($this->page_largeur < 210) {
1039 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1040 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1041 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1042 $posx = $this->marge_gauche;
1046 $pdf->SetTextColor(0, 0, 0);
1047 $pdf->SetFont(
'',
'', $default_font_size - 2);
1048 $pdf->SetXY($posx + 2, $posy - 5);
1049 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"Recipient"), 0,
'L');
1050 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1055 $pdf->SetXY($posx + 2, $posy + 3);
1056 $pdf->SetFont(
'',
'B', $default_font_size);
1057 $pdf->MultiCell($widthrecbox, 2, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1058 $posy = $pdf->getY();
1061 $pdf->SetXY($posx + 2, $posy);
1062 $pdf->SetFont(
'',
'', $default_font_size - 1);
1063 $pdf->MultiCell($widthrecbox, 4, $carac_emetteur, 0,
'L');
1066 $pdf->SetTextColor(0, 0, 0);
1079 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1081 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1082 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);
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
Class to manage Dolibarr database access.
Parent class of sending receipts models.
Class to manage products or services.
Classe permettant de generer les borderaux envoi au modele Squille.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
__construct(DoliDB $db)
Constructor.
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $totalOrdered, $totalAmount=0)
Show total to pay.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $object=null)
Show table for lines.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no', $use_short_label=0)
Output a dimension with best unit.
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
isModEnabled($module)
Is Dolibarr module enabled.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0)
Output line description into PDF.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formated for output on documents.
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
measuringUnitString($unit, $measuring_style='', $scale='', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.