33 require_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
34 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
63 public $update_main_doc_field;
74 public $phpmin = array(5, 6);
80 public $version =
'dolibarr';
100 public $marge_gauche;
105 public $marge_droite;
136 global $conf, $langs, $mysoc;
139 $langs->loadLangs(array(
"main",
"bills",
"products"));
142 $this->
name =
"eratosthene";
143 $this->
description = $langs->trans(
'PDFEratostheneDescription');
144 $this->update_main_doc_field = 1;
149 $this->page_largeur = $formatarray[
'width'];
150 $this->page_hauteur = $formatarray[
'height'];
151 $this->format = array($this->page_largeur, $this->page_hauteur);
152 $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
153 $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
154 $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
155 $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
157 $this->option_logo = 1;
158 $this->option_tva = 1;
159 $this->option_modereg = 1;
160 $this->option_condreg = 1;
161 $this->option_codeproduitservice = 1;
162 $this->option_multilang = 1;
163 $this->option_escompte = 0;
164 $this->option_credit_note = 0;
165 $this->option_freetext = 1;
166 $this->option_draft_watermark = 1;
169 $this->emetteur = $mysoc;
170 if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2);
173 $this->posxdesc = $this->marge_gauche + 1;
176 $this->tabTitleHeight = 5;
180 $this->tva = array();
181 $this->localtax1 = array();
182 $this->localtax2 = array();
183 $this->atleastoneratenotnull = 0;
184 $this->atleastonediscount = 0;
199 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
202 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
204 if (!is_object($outputlangs)) $outputlangs = $langs;
206 if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output =
'ISO-8859-1';
209 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries"));
211 global $outputlangsbis;
212 $outputlangsbis = null;
213 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
214 $outputlangsbis =
new Translate(
'', $conf);
215 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
216 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries"));
219 $nblines = count($object->lines);
222 if (!empty($conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE)) {
223 $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
227 $realpatharray = array();
228 $this->atleastonephoto =
false;
229 if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE))
233 for ($i = 0; $i < $nblines; $i++)
235 if (empty($object->lines[$i]->fk_product))
continue;
237 $objphoto->fetch($object->lines[$i]->fk_product);
239 if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
241 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
242 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
244 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
245 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
249 foreach ($pdir as $midir)
253 if ($conf->product->entity != $objphoto->entity) {
254 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
256 $dir = $conf->product->dir_output.
'/'.$midir;
259 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
261 if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))
263 if ($obj[
'photo_vignette'])
265 $filename = $obj[
'photo_vignette'];
267 $filename = $obj[
'photo'];
270 $filename = $obj[
'photo'];
273 $realpath = $dir.$filename;
275 $this->atleastonephoto =
true;
280 if ($realpath && $arephoto) $realpatharray[$i] = $realpath;
286 if ($conf->commande->multidir_output[$conf->entity])
288 $object->fetch_thirdparty();
293 if ($object->specimen)
295 $dir = $conf->commande->multidir_output[$conf->entity];
296 $file = $dir.
"/SPECIMEN.pdf";
299 $dir = $conf->commande->multidir_output[$object->entity].
"/".$objectref;
300 $file = $dir.
"/".$objectref.
".pdf";
303 if (!file_exists($dir))
307 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
312 if (file_exists($dir))
315 if (!is_object($hookmanager))
317 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
320 $hookmanager->initHooks(array(
'pdfgeneration'));
321 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
323 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
328 $pdf->SetAutoPageBreak(1, 0);
330 $heightforinfotot = 40;
331 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
332 $heightforfooter = $this->marge_basse + (empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 12 : 22);
334 if (class_exists(
'TCPDF'))
336 $pdf->setPrintHeader(
false);
337 $pdf->setPrintFooter(
false);
341 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
343 $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
344 $tplidx = $pdf->importPage(1);
349 $pdf->SetDrawColor(128, 128, 128);
351 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
352 $pdf->SetSubject($outputlangs->transnoentities(
"PdfOrderTitle"));
353 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
354 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
355 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfOrderTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
356 if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(
false);
358 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
361 for ($i = 0; $i < $nblines; $i++)
363 if ($object->lines[$i]->remise_percent)
365 $this->atleastonediscount++;
372 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
374 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
375 $pdf->SetFont(
'',
'', $default_font_size - 1);
376 $pdf->MultiCell(0, 3,
'');
377 $pdf->SetTextColor(0, 0, 0);
380 $tab_top = 90 + $top_shift;
381 $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
384 $height_incoterms = 0;
385 if (!empty($conf->incoterm->enabled))
387 $desc_incoterms = $object->getIncotermsForPDF();
392 $pdf->SetFont(
'',
'', $default_font_size - 1);
393 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
394 $nexY = max($pdf->GetY(), $nexY);
395 $height_incoterms = $nexY - $tab_top;
398 $pdf->SetDrawColor(192, 192, 192);
399 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
401 $tab_top = $nexY + 6;
406 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
407 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
410 if (is_object($object->thirdparty))
412 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
413 $salerepobj =
new User($this->
db);
414 $salerepobj->fetch($salereparray[0][
'id']);
415 if (!empty($salerepobj->signature)) $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
420 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
421 if (!empty($extranote)) {
425 $pagenb = $pdf->getPage();
430 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
431 $pageposbeforenote = $pagenb;
438 $pdf->startTransaction();
440 $pdf->SetFont(
'',
'', $default_font_size - 1);
441 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
443 $pageposafternote = $pdf->getPage();
444 $posyafter = $pdf->GetY();
446 if ($pageposafternote > $pageposbeforenote)
448 $pdf->rollbackTransaction(
true);
451 while ($pagenb < $pageposafternote) {
454 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
455 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
457 $pdf->setTopMargin($tab_top_newpage);
459 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
463 $pdf->setPage($pageposbeforenote);
464 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
465 $pdf->SetFont(
'',
'', $default_font_size - 1);
466 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
467 $pageposafternote = $pdf->getPage();
469 $posyafter = $pdf->GetY();
471 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))
473 $pdf->AddPage(
'',
'',
true);
476 $pdf->setPage($pageposafternote);
477 $pdf->setTopMargin($tab_top_newpage);
479 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
485 $i = $pageposbeforenote;
486 while ($i < $pageposafternote) {
490 $pdf->SetDrawColor(128, 128, 128);
492 if ($i > $pageposbeforenote) {
493 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
494 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
496 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
497 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
501 $pdf->setPageOrientation(
'', 1, 0);
502 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
508 $pdf->setPage($pageposafternote);
509 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
510 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
511 $height_note = $posyafter - $tab_top_newpage;
512 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
515 $pdf->commitTransaction();
516 $posyafter = $pdf->GetY();
517 $height_note = $posyafter - $tab_top;
518 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
521 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20)))
524 $pdf->AddPage(
'',
'',
true);
527 $pdf->setPage($pageposafternote);
528 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
529 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
531 $posyafter = $tab_top_newpage;
535 $tab_height = $tab_height - $height_note;
536 $tab_top = $posyafter + 6;
546 $pdf->startTransaction();
547 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
548 $pdf->rollbackTransaction(
true);
550 $nexY = $tab_top + $this->tabTitleHeight;
553 $pageposbeforeprintlines = $pdf->getPage();
554 $pagenb = $pageposbeforeprintlines;
555 for ($i = 0; $i < $nblines; $i++)
558 $pdf->SetFont(
'',
'', $default_font_size - 1);
559 $pdf->SetTextColor(0, 0, 0);
562 $imglinesize = array();
565 $pdf->setTopMargin($tab_top_newpage);
566 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
567 $pageposbefore = $pdf->getPage();
570 $showpricebeforepagebreak = 1;
572 $posYAfterDescription = 0;
577 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))
579 $pdf->AddPage(
'',
'',
true);
580 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
581 $pdf->setPage($pageposbefore + 1);
583 $curY = $tab_top_newpage;
586 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
587 $showpricebeforepagebreak = 1;
588 else $showpricebeforepagebreak = 0;
591 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height']))
593 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
595 $posYAfterImage = $curY + $imglinesize[
'height'];
602 $pdf->startTransaction();
604 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
605 $pageposafter = $pdf->getPage();
607 if ($pageposafter > $pageposbefore)
609 $pdf->rollbackTransaction(
true);
610 $pageposafter = $pageposbefore;
612 $pdf->setPageOrientation(
'', 1, $heightforfooter);
614 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc);
615 $pageposafter = $pdf->getPage();
616 $posyafter = $pdf->GetY();
617 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))
619 if ($i == ($nblines - 1))
621 $pdf->AddPage(
'',
'',
true);
622 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
624 $pdf->setPage($pageposafter + 1);
629 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
630 $showpricebeforepagebreak = 1;
631 else $showpricebeforepagebreak = 0;
635 $pdf->commitTransaction();
637 $posYAfterDescription = $pdf->GetY();
641 $nexY = max($pdf->GetY(), $posYAfterImage);
644 $pageposafter = $pdf->getPage();
646 $pdf->setPage($pageposbefore);
647 $pdf->setTopMargin($this->marge_haute);
648 $pdf->setPageOrientation(
'', 1, 0);
651 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
652 $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
655 $pdf->SetFont(
'',
'', $default_font_size - 1);
662 $nexY = max($pdf->GetY(), $nexY);
670 $nexY = max($pdf->GetY(), $nexY);
679 $nexY = max($pdf->GetY(), $nexY);
686 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
688 $nexY = max($pdf->GetY(), $nexY);
692 if ($this->
getColumnStatus(
'discount') && $object->lines[$i]->remise_percent)
696 $nexY = max($pdf->GetY(), $nexY);
704 $nexY = max($pdf->GetY(), $nexY);
712 $nexY = max($pdf->GetY(), $nexY);
716 if (!empty($object->lines[$i]->array_options)) {
717 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
722 $nexY = max($pdf->GetY(), $nexY);
733 'outputlangs' => $outputlangs,
734 'hidedetails' => $hidedetails
736 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
740 if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
741 else $tvaligne = $object->lines[$i]->total_tva;
743 $localtax1ligne = $object->lines[$i]->total_localtax1;
744 $localtax2ligne = $object->lines[$i]->total_localtax2;
745 $localtax1_rate = $object->lines[$i]->localtax1_tx;
746 $localtax2_rate = $object->lines[$i]->localtax2_tx;
747 $localtax1_type = $object->lines[$i]->localtax1_type;
748 $localtax2_type = $object->lines[$i]->localtax2_type;
750 if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
751 if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
752 if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
754 $vatrate = (string) $object->lines[$i]->tva_tx;
757 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
758 && (!empty($localtax1_rate) || !empty($localtax2_rate)))
761 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
762 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
766 if ($localtax1_type && $localtax1ligne != 0)
767 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
768 if ($localtax2_type && $localtax2ligne != 0)
769 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
771 if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .=
'*';
772 if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
773 $this->tva[$vatrate] += $tvaligne;
776 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
778 $pdf->setPage($pageposafter);
779 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
781 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
782 $pdf->SetLineStyle(array(
'dash'=>0));
787 while ($pagenb < $pageposafter)
789 $pdf->setPage($pagenb);
790 if ($pagenb == $pageposbeforeprintlines)
792 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
794 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
796 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
798 $pdf->setPage($pagenb);
799 $pdf->setPageOrientation(
'', 1, 0);
800 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
802 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
804 if ($pagenb == $pageposafter)
806 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
808 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
810 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
813 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
815 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
820 if ($pagenb == $pageposbeforeprintlines)
822 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
824 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
826 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
829 $posy = $this->
drawInfoTable($pdf, $object, $bottomlasttab, $outputlangs);
832 $posy = $this->
drawTotalTable($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
843 $this->
_pagefoot($pdf, $object, $outputlangs);
844 if (method_exists($pdf,
'AliasNbPages')) $pdf->AliasNbPages();
848 $pdf->Output($file,
'F');
851 $hookmanager->initHooks(array(
'pdfgeneration'));
852 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
854 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
857 $this->error = $hookmanager->error;
858 $this->errors = $hookmanager->errors;
861 if (!empty($conf->global->MAIN_UMASK))
862 @chmod($file, octdec($conf->global->MAIN_UMASK));
864 $this->result = array(
'fullpath'=>$file);
868 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
872 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"COMMANDE_OUTPUTDIR");
901 global $conf, $mysoc;
904 $pdf->SetFont(
'',
'', $default_font_size - 1);
907 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj))
909 $pdf->SetFont(
'',
'B', $default_font_size - 2);
910 $pdf->SetXY($this->marge_gauche, $posy);
911 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
913 $posy = $pdf->GetY() + 4;
919 if ($object->cond_reglement_code || $object->cond_reglement)
921 $pdf->SetFont(
'',
'B', $default_font_size - 2);
922 $pdf->SetXY($this->marge_gauche, $posy);
923 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
924 $pdf->MultiCell(43, 4, $titre, 0,
'L');
926 $pdf->SetFont(
'',
'', $default_font_size - 2);
927 $pdf->SetXY($posxval, $posy);
928 $lib_condition_paiement = $outputlangs->transnoentities(
"PaymentCondition".$object->cond_reglement_code) != (
'PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities(
"PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
929 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
930 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
932 $posy = $pdf->GetY() + 3;
963 if (!empty($object->delivery_date))
965 $outputlangs->load(
"sendings");
966 $pdf->SetFont(
'',
'B', $default_font_size - 2);
967 $pdf->SetXY($this->marge_gauche, $posy);
968 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
969 $pdf->MultiCell(80, 4, $titre, 0,
'L');
970 $pdf->SetFont(
'',
'', $default_font_size - 2);
971 $pdf->SetXY($posxval, $posy);
972 $dlp =
dol_print_date($object->delivery_date,
"daytext",
false, $outputlangs,
true);
973 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
975 $posy = $pdf->GetY() + 1;
976 } elseif ($object->availability_code || $object->availability)
978 $pdf->SetFont(
'',
'B', $default_font_size - 2);
979 $pdf->SetXY($this->marge_gauche, $posy);
980 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
981 $pdf->MultiCell(80, 4, $titre, 0,
'L');
982 $pdf->SetTextColor(0, 0, 0);
983 $pdf->SetFont(
'',
'', $default_font_size - 2);
984 $pdf->SetXY($posxval, $posy);
985 $lib_availability = $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) != (
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability :
'');
986 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
987 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
989 $posy = $pdf->GetY() + 1;
993 if ($object->mode_reglement_code
994 && $object->mode_reglement_code !=
'CHQ'
995 && $object->mode_reglement_code !=
'VIR') {
996 $pdf->SetFont(
'',
'B', $default_font_size - 2);
997 $pdf->SetXY($this->marge_gauche, $posy);
998 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
999 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1001 $pdf->SetFont(
'',
'', $default_font_size - 2);
1002 $pdf->SetXY($posxval, $posy);
1003 $lib_mode_reg = $outputlangs->transnoentities(
"PaymentType".$object->mode_reglement_code) != (
'PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities(
"PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
1004 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1006 $posy = $pdf->GetY() + 2;
1010 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ')
1013 if (!empty($conf->global->FACTURE_CHQ_NUMBER))
1015 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1017 if ($conf->global->FACTURE_CHQ_NUMBER > 0)
1020 $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
1022 $pdf->SetXY($this->marge_gauche, $posy);
1023 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1024 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
1025 $posy = $pdf->GetY() + 1;
1027 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
1029 $pdf->SetXY($this->marge_gauche, $posy);
1030 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1031 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1032 $posy = $pdf->GetY() + 2;
1035 if ($conf->global->FACTURE_CHQ_NUMBER == -1)
1037 $pdf->SetXY($this->marge_gauche, $posy);
1038 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1039 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1040 $posy = $pdf->GetY() + 1;
1042 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
1044 $pdf->SetXY($this->marge_gauche, $posy);
1045 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1046 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1047 $posy = $pdf->GetY() + 2;
1054 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR')
1056 if ($object->fk_account > 0 || $object->fk_bank > 0 || !empty($conf->global->FACTURE_RIB_NUMBER))
1058 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1059 if ($object->fk_bank > 0) $bankid = $object->fk_bank;
1061 $account->fetch($bankid);
1063 $curx = $this->marge_gauche;
1066 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1088 global $conf, $mysoc, $hookmanager;
1092 $outputlangsbis = null;
1093 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
1094 $outputlangsbis =
new Translate(
'', $conf);
1095 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
1096 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1097 $default_font_size--;
1102 $pdf->SetFont(
'',
'', $default_font_size - 1);
1105 $col1x = 120; $col2x = 170;
1106 if ($this->page_largeur < 210)
1110 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1116 $pdf->SetFillColor(255, 255, 255);
1117 $pdf->SetXY($col1x, $tab2_top + 0);
1118 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
1119 $total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1120 $pdf->SetXY($col2x, $tab2_top + 0);
1121 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1124 $pdf->SetFillColor(248, 248, 248);
1126 $total_ttc = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1128 $this->atleastoneratenotnull = 0;
1129 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1131 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1132 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1139 foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1141 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5')))
continue;
1142 foreach ($localtax_rate as $tvakey => $tvaval)
1148 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1151 if (preg_match(
'/\*/', $tvakey))
1153 $tvakey = str_replace(
'*',
'', $tvakey);
1154 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1156 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1158 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1159 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1161 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1162 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1170 foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1172 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5')))
continue;
1173 foreach ($localtax_rate as $tvakey => $tvaval)
1180 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1183 if (preg_match(
'/\*/', $tvakey))
1185 $tvakey = str_replace(
'*',
'', $tvakey);
1186 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1188 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1190 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1191 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1193 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1194 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1200 foreach ($this->tva as $tvakey => $tvaval)
1204 $this->atleastoneratenotnull++;
1207 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1210 if (preg_match(
'/\*/', $tvakey))
1212 $tvakey = str_replace(
'*',
'', $tvakey);
1213 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1215 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1217 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
1218 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1220 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1221 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1228 foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1230 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6')))
continue;
1232 foreach ($localtax_rate as $tvakey => $tvaval)
1239 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1242 if (preg_match(
'/\*/', $tvakey))
1244 $tvakey = str_replace(
'*',
'', $tvakey);
1245 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1247 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1249 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1251 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1252 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1253 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1261 foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1263 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6')))
continue;
1265 foreach ($localtax_rate as $tvakey => $tvaval)
1273 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1276 if (preg_match(
'/\*/', $tvakey))
1278 $tvakey = str_replace(
'*',
'', $tvakey);
1279 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1281 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1284 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1285 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1287 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1288 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1296 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1297 $pdf->SetTextColor(0, 0, 60);
1298 $pdf->SetFillColor(224, 224, 224);
1299 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalTTC", $mysoc->country_code) :
''), $useborder,
'L', 1);
1301 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1302 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1306 $pdf->SetTextColor(0, 0, 0);
1308 $creditnoteamount = 0;
1309 $depositsamount = 0;
1313 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1314 if (!empty($object->paye)) $resteapayer = 0;
1316 if ($deja_regle > 0)
1321 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1322 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1323 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1324 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1327 $pdf->SetTextColor(0, 0, 60);
1328 $pdf->SetFillColor(224, 224, 224);
1329 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1330 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"RemainderToPay") :
''), $useborder,
'L', 1);
1332 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1333 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1335 $pdf->SetFont(
'',
'', $default_font_size - 1);
1336 $pdf->SetTextColor(0, 0, 0);
1340 return ($tab2_top + ($tab2_hl * $index));
1358 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'', $outputlangsbis = null)
1364 if ($hidetop) $hidetop = -1;
1366 $currency = !empty($currency) ? $currency : $conf->currency;
1370 $pdf->SetTextColor(0, 0, 0);
1371 $pdf->SetFont(
'',
'', $default_font_size - 2);
1373 if (empty($hidetop))
1375 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1376 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1377 $titre .=
' - '.$outputlangsbis->transnoentities(
"AmountInCurrency", $outputlangsbis->transnoentitiesnoconv(
"Currency".$currency));
1380 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1381 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1384 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1385 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, $this->tabTitleHeight,
'F', null, explode(
',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1389 $pdf->SetDrawColor(128, 128, 128);
1390 $pdf->SetFont(
'',
'', $default_font_size - 1);
1393 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1396 $this->
pdfTabTitles($pdf, $tab_top, $tab_height, $outputlangs, $hidetop);
1398 if (empty($hidetop)) {
1399 $pdf->line($this->marge_gauche, $tab_top + $this->tabTitleHeight, $this->page_largeur - $this->marge_droite, $tab_top + $this->tabTitleHeight);
1416 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null, $titlekey =
"PdfOrderTitle")
1419 global $conf, $langs, $hookmanager;
1422 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1429 if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)))
1431 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
1434 $pdf->SetTextColor(0, 0, 60);
1435 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1439 $posy = $this->marge_haute;
1440 $posx = $this->page_largeur - $this->marge_droite - $w;
1442 $pdf->SetXY($this->marge_gauche, $posy);
1445 if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1447 if ($this->emetteur->logo)
1449 $logodir = $conf->mycompany->dir_output;
1450 if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
1451 if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
1453 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1455 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1457 if (is_readable($logo)) {
1459 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1461 $pdf->SetTextColor(200, 0, 0);
1462 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1463 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1464 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1467 $text = $this->emetteur->name;
1468 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1472 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1473 $pdf->SetXY($posx, $posy);
1474 $pdf->SetTextColor(0, 0, 60);
1475 $title = $outputlangs->transnoentities($titlekey);
1476 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1478 $title .= $outputlangsbis->transnoentities($titlekey);
1481 $pdf->MultiCell($w, 3, $title,
'',
'R');
1483 $pdf->SetFont(
'',
'B', $default_font_size);
1486 $pdf->SetXY($posx, $posy);
1487 $pdf->SetTextColor(0, 0, 60);
1488 $textref = $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset($object->ref);
1489 if ($object->statut == $object::STATUS_DRAFT)
1491 $pdf->SetTextColor(128, 0, 0);
1492 $textref .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1494 $pdf->MultiCell($w, 4, $textref,
'',
'R');
1497 $pdf->SetFont(
'',
'', $default_font_size - 2);
1499 if ($object->ref_client)
1502 $pdf->SetXY($posx, $posy);
1503 $pdf->SetTextColor(0, 0, 60);
1504 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
1507 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
1509 $object->fetch_projet();
1510 if (!empty($object->project->ref))
1513 $pdf->SetXY($posx, $posy);
1514 $pdf->SetTextColor(0, 0, 60);
1515 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->projet->title),
'',
'R');
1519 if (!empty($conf->global->PDF_SHOW_PROJECT))
1521 $object->fetch_projet();
1522 if (!empty($object->project->ref))
1525 $pdf->SetXY($posx, $posy);
1526 $pdf->SetTextColor(0, 0, 60);
1527 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->projet->ref),
'',
'R');
1533 $pdf->SetXY($posx, $posy);
1534 $pdf->SetTextColor(0, 0, 60);
1535 $title = $outputlangs->transnoentities(
"OrderDate");
1536 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1537 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
1539 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1541 if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && !empty($object->thirdparty->code_client))
1544 $pdf->SetXY($posx, $posy);
1545 $pdf->SetTextColor(0, 0, 60);
1546 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1550 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1552 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1553 if (count($arrayidcontact) > 0)
1555 $usertmp =
new User($this->
db);
1556 $usertmp->fetch($arrayidcontact[0]);
1558 $pdf->SetXY($posx, $posy);
1559 $pdf->SetTextColor(0, 0, 60);
1560 $pdf->MultiCell($w, 3, $langs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1568 $current_y = $pdf->getY();
1569 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
1570 if ($current_y < $pdf->getY())
1572 $top_shift = $pdf->getY() - $current_y;
1578 $carac_emetteur =
'';
1580 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1581 if (count($arrayidcontact) > 0)
1583 $object->fetch_user($arrayidcontact[0]);
1584 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1585 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)).
"\n";
1588 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1591 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1592 $posy += $top_shift;
1593 $posx = $this->marge_gauche;
1594 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1596 $hautcadre = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 38 : 40;
1597 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 82;
1601 $pdf->SetTextColor(0, 0, 0);
1602 $pdf->SetFont(
'',
'', $default_font_size - 2);
1603 $pdf->SetXY($posx, $posy - 5);
1604 $pdf->MultiCell(66, 5, $outputlangs->transnoentities(
"BillFrom").
":", 0,
'L');
1605 $pdf->SetXY($posx, $posy);
1606 $pdf->SetFillColor(230, 230, 230);
1607 $pdf->MultiCell($widthrecbox, $hautcadre,
"", 0,
'R', 1);
1608 $pdf->SetTextColor(0, 0, 60);
1611 $pdf->SetXY($posx + 2, $posy + 3);
1612 $pdf->SetFont(
'',
'B', $default_font_size);
1613 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1614 $posy = $pdf->getY();
1617 $pdf->SetXY($posx + 2, $posy);
1618 $pdf->SetFont(
'',
'', $default_font_size - 1);
1619 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0,
'L');
1622 $usecontact =
false;
1623 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1624 if (count($arrayidcontact) > 0)
1627 $result = $object->fetch_contact($arrayidcontact[0]);
1631 if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
1632 $thirdparty = $object->contact;
1634 $thirdparty = $object->thirdparty;
1639 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact,
'target', $object);
1642 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1643 if ($this->page_largeur < 210) $widthrecbox = 84;
1644 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1645 $posy += $top_shift;
1646 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1647 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1650 $pdf->SetTextColor(0, 0, 0);
1651 $pdf->SetFont(
'',
'', $default_font_size - 2);
1652 $pdf->SetXY($posx + 2, $posy - 5);
1653 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo").
":", 0,
'L');
1654 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1657 $pdf->SetXY($posx + 2, $posy + 3);
1658 $pdf->SetFont(
'',
'B', $default_font_size);
1659 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1661 $posy = $pdf->getY();
1664 $pdf->SetFont(
'',
'', $default_font_size - 1);
1665 $pdf->SetXY($posx + 2, $posy);
1666 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1669 $pdf->SetTextColor(0, 0, 0);
1684 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1688 $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1689 return pdf_pagefoot($pdf, $outputlangs,
'ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1704 public function defineColumnField($object, $outputlangs, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
1706 global $conf, $hookmanager;
1709 $this->defaultContentsFieldsStyle = array(
1711 'padding' => array(1, 0.5, 1, 0.5),
1715 $this->defaultTitlesFieldsStyle = array(
1717 'padding' => array(0.5, 0, 0.5, 0),
1739 $this->cols[
'desc'] = array(
1744 'textkey' =>
'Designation',
1748 'padding' => array(0.5, 0.5, 0.5, 0.5),
1752 'padding' => array(1, 0.5, 1, 1.5),
1758 $this->cols[
'photo'] = array(
1760 'width' => (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH),
1763 'textkey' =>
'Photo',
1767 'padding' => array(0, 0, 0, 0),
1769 'border-left' =>
false,
1772 if (!empty($conf->global->MAIN_GENERATE_ORDERS_WITH_PICTURE) && !empty($this->atleastonephoto))
1774 $this->cols[
'photo'][
'status'] =
true;
1778 $this->cols[
'vat'] = array(
1785 'border-left' =>
true,
1788 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1790 $this->cols[
'vat'][
'status'] =
true;
1794 $this->cols[
'subprice'] = array(
1799 'textkey' =>
'PriceUHT'
1801 'border-left' =>
true,
1806 $nblines = count($object->lines);
1807 for ($i = 0; $i < $nblines; $i++) {
1809 $tmpwidth = max($tmpwidth, $tmpwidth2);
1811 if ($tmpwidth > 10) {
1812 $this->cols[
'subprice'][
'width'] += (2 * ($tmpwidth - 10));
1816 $this->cols[
'qty'] = array(
1823 'border-left' =>
true,
1827 $this->cols[
'unit'] = array(
1834 'border-left' =>
true,
1836 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1837 $this->cols[
'unit'][
'status'] =
true;
1841 $this->cols[
'discount'] = array(
1846 'textkey' =>
'ReductionShort'
1848 'border-left' =>
true,
1850 if ($this->atleastonediscount) {
1851 $this->cols[
'discount'][
'status'] =
true;
1854 $rank = $rank + 1000;
1855 $this->cols[
'totalexcltax'] = array(
1858 'status' => empty($conf->global->PDF_PROPAL_HIDE_PRICE_EXCL_TAX) ?
true :
false,
1860 'textkey' =>
'TotalHT'
1862 'border-left' =>
true,
1865 $rank = $rank + 1010;
1866 $this->cols[
'totalincltax'] = array(
1869 'status' => empty($conf->global->PDF_PROPAL_SHOW_PRICE_INCL_TAX) ?
false :
true,
1871 'textkey' =>
'TotalTTC'
1873 'border-left' =>
true,
1877 if (!empty($object->lines)) {
1878 $line = reset($object->lines);
1882 $parameters = array(
1883 'object' => $object,
1884 'outputlangs' => $outputlangs,
1885 'hidedetails' => $hidedetails,
1886 'hidedesc' => $hidedesc,
1887 'hideref' => $hideref
1890 $reshook = $hookmanager->executeHooks(
'defineColumnField', $parameters, $this);
1894 } elseif (empty($reshook))
1896 $this->cols = array_replace($this->cols, $hookmanager->resArray);
1898 $this->cols = $hookmanager->resArray;
pdf_getFormat(Translate $outputlangs=null, $mode= 'setup')
Return array with format properties of default PDF format.
pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank informations for PDF generation.
getExtrafieldContent($object, $extrafieldKey)
get extrafield content for pdf writeHtmlCell compatibility usage for PDF line columns and object note...
dol_string_nohtmltag($stringtoclean, $removelinefeed=1, $pagecodeto= 'UTF-8', $strip_tags=0, $removedoublespaces=1)
Clean a string from all HTML tags and entities.
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency= '', $outputlangsbis=null)
Show table for lines.
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
prepareArrayColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Prepare Array Column Field.
__construct($db)
Constructor.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
write_file($object, $outputlangs, $srctemplatepath= '', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Class to manage products or services.
printColDescContent($pdf, &$curY, $colKey, $object, $i, $outputlangs, $hideref=0, $hidedesc=0, $issupplierline=0)
print description column content
Class to manage Dolibarr users.
drawTotalTable(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.
defineColumnExtrafield($object, $outputlangs, $hidedetails=0)
Define Array Column Field for extrafields.
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...
printStdColumnContent($pdf, &$curY, $colKey, $columnText= '')
print standard column content
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0, $hookmanager=false)
Return line unit.
$conf db name
Only used if Module[ID]Name translation string is not found.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
drawInfoTable(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
$conf db
API class for accounts.
Class to manage bank accounts.
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...
getColumnStatus($colKey)
get column status from column key
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
drawPaymentsTable(&$pdf, $object, $posy, $outputlangs)
Show payments table.
pdfTabTitles(&$pdf, $tab_top, $tab_height, $outputlangs, $hidetop=0)
Print standard column content.
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0)
Show footer of page for PDF generation.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
getColumnContentXStart($colKey)
get column content X (abscissa) left position from column key
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
Class to manage translations.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis=null, $titlekey="PdfOrderTitle")
Show top header of page.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
defineColumnField($object, $outputlangs, $hidedetails=0, $hidedesc=0, $hideref=0)
Define Array Column Field.
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages...
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
pdf_getInstance($format= '', $metric= 'mm', $pagetype= 'P')
Return a PDF instance object.
pdf_build_address($outputlangs, $sourcecompany, $targetcompany= '', $targetcontact= '', $usecontact=0, $mode= 'source', $object=null)
Return a string with full address formated for output on documents.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
Class to generate PDF orders with template Eratosthene.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Parent class for orders models.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
pdf_getlinetotalwithtax($object, $i, $outputlangs, $hidedetails=0)
Return line total including tax.