146 public function write_file($object, $outputlangs =
'', $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
149 global $user, $langs, $conf, $hookmanager, $mysoc, $nblines;
151 if (!is_object($outputlangs)) {
152 $outputlangs = $langs;
156 $outputlangs->charset_output =
'ISO-8859-1';
160 $outputlangs->loadLangs(array(
"main",
"supplier_proposal",
"companies",
"bills",
"dict",
"products"));
162 global $outputlangsbis;
163 $outputlangsbis =
null;
164 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
165 $outputlangsbis =
new Translate(
'', $conf);
166 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
167 $outputlangsbis->loadLangs(array(
"main",
"supplier_proposal",
"companies",
"bills",
"dict",
"products"));
170 $nblines = count($object->lines);
174 $hidetop = $conf->global->MAIN_PDF_DISABLE_COL_HEAD_TITLE;
178 $realpatharray = array();
180 for ($i = 0; $i < $nblines; $i++) {
181 if (empty($object->lines[$i]->fk_product)) {
185 $objphoto =
new Product($this->db);
186 $objphoto->fetch($object->lines[$i]->fk_product);
189 $pdir =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
190 $dir = $conf->product->dir_output.
'/'.$pdir;
192 $pdir =
get_exdir($objphoto->id, 0, 0, 0, $objphoto,
'product');
193 $dir = $conf->product->dir_output.
'/'.$pdir;
197 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
199 if ($obj[
'photo_vignette']) {
200 $filename = $obj[
'photo_vignette'];
202 $filename = $obj[
'photo'];
205 $filename = $obj[
'photo'];
207 $realpath = $dir.$filename;
212 $realpatharray[$i] = $realpath;
216 if (count($realpatharray) == 0) {
217 $this->posxpicture = $this->posxtva;
220 if ($conf->supplier_proposal->dir_output) {
221 $object->fetch_thirdparty();
224 $amount_credit_notes_included = 0;
225 $amount_deposits_included = 0;
230 if ($object->specimen) {
231 $dir = $conf->supplier_proposal->dir_output;
232 $file = $dir.
"/SPECIMEN.pdf";
236 $dir = $conf->supplier_proposal->dir_output.
'/'.$objectref;
237 $file = $dir.
"/".$objectref.
".pdf";
239 $file = $dir.
"/".$objectref.($objectrefsupplier ?
"_".$objectrefsupplier :
"").
".pdf";
243 if (!file_exists($dir)) {
245 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
250 if (file_exists($dir)) {
252 if (!is_object($hookmanager)) {
253 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
256 $hookmanager->initHooks(array(
'pdfgeneration'));
257 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
259 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
261 $nblines = count($object->lines);
265 $heightforinfotot = 50;
266 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
267 $heightforfooter = $this->marge_basse + 8;
269 $heightforfooter += 6;
271 $pdf->SetAutoPageBreak(1, 0);
273 if (class_exists(
'TCPDF')) {
274 $pdf->setPrintHeader(
false);
275 $pdf->setPrintFooter(
false);
280 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
281 $tplidx = $pdf->importPage(1);
286 $pdf->SetDrawColor(128, 128, 128);
288 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
289 $pdf->SetSubject($outputlangs->transnoentities(
"SupplierProposal"));
290 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
291 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
292 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"SupplierProposal").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
294 $pdf->SetCompression(
false);
297 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
300 foreach ($object->lines as $line) {
301 if ($line->remise_percent) {
302 $this->atleastonediscount =
true;
309 if (!empty($tplidx)) {
310 $pdf->useTemplate($tplidx);
313 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
314 $pdf->SetFont(
'',
'', $default_font_size - 1);
315 $pdf->MultiCell(0, 3,
'');
316 $pdf->SetTextColor(0, 0, 0);
318 $tab_top = 90 + $top_shift;
319 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
321 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
324 if (isModEnabled(
'incoterm')) {
325 $desc_incoterms = $object->getIncotermsForPDF();
326 if ($desc_incoterms) {
329 $pdf->SetFont(
'',
'', $default_font_size - 1);
330 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
331 $nexY = $pdf->GetY();
332 $height_incoterms = $nexY - $tab_top;
335 $pdf->SetDrawColor(192, 192, 192);
336 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
338 $tab_top = $nexY + 6;
343 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
346 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
347 if (!empty($extranote)) {
351 $pagenb = $pdf->getPage();
353 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
354 $pageposbeforenote = $pagenb;
363 $pdf->startTransaction();
365 $pdf->SetFont(
'',
'', $default_font_size - 1);
366 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
368 $pageposafternote = $pdf->getPage();
369 $posyafter = $pdf->GetY();
371 if ($pageposafternote > $pageposbeforenote) {
372 $pdf->rollbackTransaction(
true);
375 while ($pagenb < $pageposafternote) {
378 if (!empty($tplidx)) {
379 $pdf->useTemplate($tplidx);
382 $this->
_pagehead($pdf, $object, 0, $outputlangs);
385 $pdf->setTopMargin($tab_top_newpage);
387 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
391 $pdf->setPage($pageposbeforenote);
392 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
393 $pdf->SetFont(
'',
'', $default_font_size - 1);
394 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
395 $pageposafternote = $pdf->getPage();
397 $posyafter = $pdf->GetY();
399 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
400 $pdf->AddPage(
'',
'',
true);
403 $pdf->setPage($pageposafternote);
404 $pdf->setTopMargin($tab_top_newpage);
406 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
412 $i = $pageposbeforenote;
413 while ($i < $pageposafternote) {
417 $pdf->SetDrawColor(128, 128, 128);
419 if ($i > $pageposbeforenote) {
420 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
421 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
423 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
424 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
428 $pdf->setPageOrientation(
'', 1, 0);
429 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
435 $pdf->setPage($pageposafternote);
436 if (!empty($tplidx)) {
437 $pdf->useTemplate($tplidx);
440 $this->
_pagehead($pdf, $object, 0, $outputlangs);
442 $height_note = $posyafter - $tab_top_newpage;
443 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
446 $pdf->commitTransaction();
447 $posyafter = $pdf->GetY();
448 $height_note = $posyafter - $tab_top;
449 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
452 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
454 $pdf->AddPage(
'',
'',
true);
457 $pdf->setPage($pageposafternote);
458 if (!empty($tplidx)) {
459 $pdf->useTemplate($tplidx);
462 $this->
_pagehead($pdf, $object, 0, $outputlangs);
465 $posyafter = $tab_top_newpage;
469 $tab_height = $tab_height - $height_note;
470 $tab_top = $posyafter + 6;
478 $nexY = $tab_top + $this->tabTitleHeight;
481 $pageposbeforeprintlines = $pdf->getPage();
482 $pagenb = $pageposbeforeprintlines;
483 for ($i = 0; $i < $nblines; $i++) {
485 $pdf->SetFont(
'',
'', $default_font_size - 1);
486 $pdf->SetTextColor(0, 0, 0);
489 $imglinesize = array();
490 if (!empty($realpatharray[$i])) {
494 $pdf->setTopMargin($tab_top_newpage);
495 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
496 $pageposbefore = $pdf->getPage();
498 $showpricebeforepagebreak = 1;
500 $posYAfterDescription = 0;
505 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
506 $pdf->AddPage(
'',
'',
true);
507 if (!empty($tplidx)) {
508 $pdf->useTemplate($tplidx);
510 $pdf->setPage($pageposbefore + 1);
512 $curY = $tab_top_newpage;
516 $showpricebeforepagebreak = 1;
518 $showpricebeforepagebreak = 0;
522 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
523 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
525 $posYAfterImage = $curY + $imglinesize[
'height'];
529 $curX = $this->posxdesc - 1;
530 $showpricebeforepagebreak = 1;
533 $pdf->startTransaction();
534 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1);
536 $pageposafter = $pdf->getPage();
537 if ($pageposafter > $pageposbefore) {
538 $pdf->rollbackTransaction(
true);
540 $this->
printColDescContent($pdf, $curY,
'desc', $object, $i, $outputlangs, $hideref, $hidedesc, 1);
542 $pageposafter = $pdf->getPage();
543 $posyafter = $pdf->GetY();
544 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
545 if ($i == ($nblines - 1)) {
546 $pdf->AddPage(
'',
'',
true);
547 if (!empty($tplidx)) {
548 $pdf->useTemplate($tplidx);
551 $pdf->setPage($pageposafter + 1);
557 $showpricebeforepagebreak = 1;
559 $showpricebeforepagebreak = 0;
563 $pdf->commitTransaction();
565 $posYAfterDescription = $pdf->GetY();
568 $nexY = $pdf->GetY();
569 $pageposafter = $pdf->getPage();
570 $pdf->setPage($pageposbefore);
571 $pdf->setTopMargin($this->marge_haute);
572 $pdf->setPageOrientation(
'', 1, 0);
575 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
576 $pdf->setPage($pageposafter);
577 $curY = $tab_top_newpage;
580 $pdf->SetFont(
'',
'', $default_font_size - 1);
586 $nexY = max($pdf->GetY(), $nexY);
593 $nexY = max($pdf->GetY(), $nexY);
601 $nexY = max($pdf->GetY(), $nexY);
607 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
609 $nexY = max($pdf->GetY(), $nexY);
613 if ($this->
getColumnStatus(
'discount') && $object->lines[$i]->remise_percent) {
616 $nexY = max($pdf->GetY(), $nexY);
623 $nexY = max($pdf->GetY(), $nexY);
627 if (!empty($object->lines[$i]->array_options)) {
628 foreach ($object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
630 $extrafieldValue = $this->
getExtrafieldContent($object->lines[$i], $extrafieldColKey, $outputlangs);
632 $nexY = max($pdf->GetY(), $nexY);
643 'outputlangs' => $outputlangs,
644 'hidedetails' => $hidedetails
646 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
650 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
651 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
653 $tvaligne = $object->lines[$i]->total_tva;
656 $localtax1ligne = $object->lines[$i]->total_localtax1;
657 $localtax2ligne = $object->lines[$i]->total_localtax2;
658 $localtax1_rate = $object->lines[$i]->localtax1_tx;
659 $localtax2_rate = $object->lines[$i]->localtax2_tx;
660 $localtax1_type = $object->lines[$i]->localtax1_type;
661 $localtax2_type = $object->lines[$i]->localtax2_type;
674 $vatrate = (string) $object->lines[$i]->tva_tx;
677 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
678 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
680 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
681 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
685 if ($localtax1_type && $localtax1ligne != 0) {
686 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
687 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
689 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
692 if ($localtax2_type && $localtax2ligne != 0) {
693 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
694 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
696 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
700 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
705 if (!isset($this->tva[$vatrate])) {
706 $this->tva[$vatrate] = 0;
708 $this->tva[$vatrate] += $tvaligne;
709 $vatcode = $object->lines[$i]->vat_src_code;
710 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
711 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
713 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
715 if ($posYAfterImage > $posYAfterDescription) {
716 $nexY = $posYAfterImage;
721 $pdf->setPage($pageposafter);
722 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
724 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
725 $pdf->SetLineStyle(array(
'dash'=>0));
729 while ($pagenb < $pageposafter) {
730 $pdf->setPage($pagenb);
731 if ($pagenb == $pageposbeforeprintlines) {
732 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
734 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
736 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
738 $pdf->setPage($pagenb);
739 $pdf->setPageOrientation(
'', 1, 0);
741 $this->
_pagehead($pdf, $object, 0, $outputlangs);
743 if (!empty($tplidx)) {
744 $pdf->useTemplate($tplidx);
747 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
748 if ($pagenb == $pageposafter) {
749 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
751 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
753 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
756 if (!empty($tplidx)) {
757 $pdf->useTemplate($tplidx);
761 $this->
_pagehead($pdf, $object, 0, $outputlangs);
767 if ($pagenb == $pageposbeforeprintlines) {
768 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
769 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
771 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
772 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
776 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
779 $posy = $this->
_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
782 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
787 $this->
_pagefoot($pdf, $object, $outputlangs);
788 if (method_exists($pdf,
'AliasNbPages')) {
789 $pdf->AliasNbPages();
794 $pdf->Output($file,
'F');
797 $hookmanager->initHooks(array(
'pdfgeneration'));
798 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
800 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
802 $this->error = $hookmanager->error;
803 $this->errors = $hookmanager->errors;
808 $this->result = array(
'fullpath'=>$file);
812 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
816 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
915 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
918 global $conf, $mysoc;
924 $pdf->SetFont(
'',
'', $default_font_size - 1);
929 if ($this->page_largeur < 210) {
932 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
938 $pdf->SetFillColor(255, 255, 255);
939 $pdf->SetXY($col1x, $tab2_top);
940 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
942 $total_ht = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
943 $pdf->SetXY($col2x, $tab2_top);
944 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0)), 0,
'R', 1);
947 $pdf->SetFillColor(248, 248, 248);
949 $this->atleastoneratenotnull = 0;
950 foreach ($this->tva as $tvakey => $tvaval) {
952 $this->atleastoneratenotnull++;
955 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
959 if (preg_match(
'/\*/', $tvakey)) {
960 $tvakey = str_replace(
'*',
'', $tvakey);
961 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
964 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
965 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
966 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
968 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
969 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
972 if (!$this->atleastoneratenotnull) {
974 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
975 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code), 0,
'L', 1);
977 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
978 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_tva), 0,
'R', 1);
981 if (
getDolGlobalString(
'FACTURE_LOCAL_TAX1_OPTION') ==
'localtax1on' && $object->total_localtax1 > 0) {
983 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
984 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code), 0,
'L', 1);
985 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
986 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_localtax1), $useborder,
'R', 1);
990 if (
getDolGlobalString(
'FACTURE_LOCAL_TAX2_OPTION') ==
'localtax2on' && $object->total_localtax2 > 0) {
992 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
993 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code), 0,
'L', 1);
994 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
995 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_localtax2), $useborder,
'R', 1);
1001 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1002 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1006 foreach ($localtax_rate as $tvakey => $tvaval) {
1011 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1014 if (preg_match(
'/\*/', $tvakey)) {
1015 $tvakey = str_replace(
'*',
'', $tvakey);
1016 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1018 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1019 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1020 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1022 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1023 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1031 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1032 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1036 foreach ($localtax_rate as $tvakey => $tvaval) {
1041 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1044 if (preg_match(
'/\*/', $tvakey)) {
1045 $tvakey = str_replace(
'*',
'', $tvakey);
1046 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1048 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1049 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1050 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1052 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1053 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
1061 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1062 $pdf->SetTextColor(0, 0, 60);
1063 $pdf->SetFillColor(224, 224, 224);
1064 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1066 $total_ttc = (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1067 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1068 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R', 1);
1069 $pdf->SetFont(
'',
'', $default_font_size - 1);
1070 $pdf->SetTextColor(0, 0, 0);
1072 $creditnoteamount = 0;
1073 $depositsamount = 0;
1077 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1078 if (!empty($object->paye)) {
1082 if ($deja_regle > 0) {
1086 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1087 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1088 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1089 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R', 0);
1092 $pdf->SetTextColor(0, 0, 60);
1093 $pdf->SetFillColor(224, 224, 224);
1094 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1095 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1097 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1098 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R', 1);
1100 $pdf->SetFont(
'',
'', $default_font_size - 1);
1101 $pdf->SetTextColor(0, 0, 0);
1105 return ($tab2_top + ($tab2_hl * $index));
1173 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1175 global $langs, $conf, $mysoc;
1177 $ltrdirection =
'L';
1178 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1179 $ltrdirection =
'R';
1183 $outputlangs->loadLangs(array(
"main",
"supplier_proposal",
"companies",
"bills",
"sendings"));
1197 $pdf->SetTextColor(0, 0, 60);
1198 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1200 $posx = $this->page_largeur - $this->marge_droite - 100;
1201 $posy = $this->marge_haute;
1203 $pdf->SetXY($this->marge_gauche, $posy);
1207 if ($this->emetteur->logo) {
1208 $logodir = $conf->mycompany->dir_output;
1209 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1210 $logodir = $conf->mycompany->multidir_output[$object->entity];
1213 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1215 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1217 if (is_readable($logo)) {
1219 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1221 $pdf->SetTextColor(200, 0, 0);
1222 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1223 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1224 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1227 $text = $this->emetteur->name;
1228 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1232 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1233 $pdf->SetXY($posx, $posy);
1234 $pdf->SetTextColor(0, 0, 60);
1235 $title = $outputlangs->transnoentities(
"SupplierProposal").
" ".$outputlangs->convToOutputCharset($object->ref);
1236 $pdf->MultiCell(100, 3, $title,
'',
'R');
1239 if ($object->ref_supplier) {
1241 $pdf->SetFont(
'',
'B', $default_font_size);
1242 $pdf->SetXY($posx, $posy);
1243 $pdf->SetTextColor(0, 0, 60);
1244 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset($object->ref_supplier),
'',
'R');
1248 $pdf->SetFont(
'',
'', $default_font_size - 1);
1251 $object->fetch_projet();
1252 if (!empty($object->project->ref)) {
1254 $pdf->SetXY($posx, $posy);
1255 $pdf->SetTextColor(0, 0, 60);
1256 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1261 $object->fetch_projet();
1262 if (!empty($object->project->ref)) {
1263 $outputlangs->load(
"projects");
1265 $pdf->SetXY($posx, $posy);
1266 $langs->load(
"projects");
1267 $pdf->SetTextColor(0, 0, 60);
1268 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1272 if (!empty($object->date)) {
1274 $pdf->SetXY($posx, $posy);
1275 $pdf->SetTextColor(0, 0, 60);
1276 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1279 $pdf->SetXY($posx, $posy);
1280 $pdf->SetTextColor(255, 0, 0);
1281 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Draft"),
'',
'R');
1284 $pdf->SetTextColor(0, 0, 60);
1285 $usehourmin =
'day';
1287 $usehourmin =
'dayhour';
1289 if (!empty($object->delivery_date)) {
1291 $pdf->SetXY($posx - 90, $posy);
1292 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date($object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1295 if ($object->thirdparty->code_fournisseur) {
1297 $pdf->SetXY($posx, $posy);
1298 $pdf->SetTextColor(0, 0, 60);
1299 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur),
'',
'R');
1304 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1305 if (count($arrayidcontact) > 0) {
1306 $usertmp =
new User($this->db);
1307 $usertmp->fetch($arrayidcontact[0]);
1309 $pdf->SetXY($posx, $posy);
1310 $pdf->SetTextColor(0, 0, 60);
1311 $pdf->MultiCell(100, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1316 $pdf->SetTextColor(0, 0, 60);
1320 $current_y = $pdf->getY();
1321 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3,
'R', $default_font_size);
1322 if ($current_y < $pdf->getY()) {
1323 $top_shift = $pdf->getY() - $current_y;
1328 $carac_emetteur =
'';
1330 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1331 if (count($arrayidcontact) > 0) {
1332 $object->fetch_user($arrayidcontact[0]);
1333 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1334 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1336 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone :
'';
1338 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email :
'';
1340 $carac_emetteur .=
"\n";
1343 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1346 $posy = 42 + $top_shift;
1347 $posx = $this->marge_gauche;
1349 $posx = $this->page_largeur - $this->marge_droite - 80;
1354 $pdf->SetTextColor(0, 0, 0);
1355 $pdf->SetFont(
'',
'', $default_font_size - 2);
1356 $pdf->SetXY($posx, $posy - 5);
1357 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1358 $pdf->SetXY($posx, $posy);
1359 $pdf->SetFillColor(230, 230, 230);
1360 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1361 $pdf->SetTextColor(0, 0, 60);
1364 $pdf->SetXY($posx + 2, $posy + 3);
1365 $pdf->SetFont(
'',
'B', $default_font_size);
1366 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1367 $posy = $pdf->getY();
1370 $pdf->SetXY($posx + 2, $posy);
1371 $pdf->SetFont(
'',
'', $default_font_size - 1);
1372 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1377 $usecontact =
false;
1379 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1381 $arrayidcontact = array_merge($object->getIdContact(
'external',
'CUSTOMER'), $object->getIdContact(
'external',
'BILLING'));
1383 if (count($arrayidcontact) > 0) {
1385 $result = $object->fetch_contact($arrayidcontact[0]);
1389 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1390 $thirdparty = $object->contact;
1392 $thirdparty = $object->thirdparty;
1397 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact,
'target', $object);
1401 if ($this->page_largeur < 210) {
1404 $posy = 42 + $top_shift;
1405 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1407 $posx = $this->marge_gauche;
1411 $pdf->SetTextColor(0, 0, 0);
1412 $pdf->SetFont(
'',
'', $default_font_size - 2);
1413 $pdf->SetXY($posx + 2, $posy - 5);
1414 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1415 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1418 $pdf->SetXY($posx + 2, $posy + 3);
1419 $pdf->SetFont(
'',
'B', $default_font_size);
1420 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1422 $posy = $pdf->getY();
1425 $pdf->SetFont(
'',
'', $default_font_size - 1);
1426 $pdf->SetXY($posx + 2, $posy);
1427 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);