147 public function write_file(
$object, $outputlangs =
null, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
150 global $user, $langs, $conf, $hookmanager, $mysoc, $nblines;
152 if (!is_object($outputlangs)) {
153 $outputlangs = $langs;
157 $outputlangs->charset_output =
'ISO-8859-1';
161 $outputlangs->loadLangs(array(
"main",
"supplier_proposal",
"companies",
"bills",
"dict",
"products"));
163 global $outputlangsbis;
164 $outputlangsbis =
null;
166 $outputlangsbis =
new Translate(
'', $conf);
168 $outputlangsbis->loadLangs(array(
"main",
"supplier_proposal",
"companies",
"bills",
"dict",
"products"));
171 $nblines = count(
$object->lines);
179 $realpatharray = array();
181 for ($i = 0; $i < $nblines; $i++) {
182 if (empty(
$object->lines[$i]->fk_product)) {
186 $objphoto =
new Product($this->db);
187 $objphoto->fetch(
$object->lines[$i]->fk_product);
190 $pdir =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
191 $dir = $conf->product->dir_output.
'/'.$pdir;
193 $pdir =
get_exdir($objphoto->id, 0, 0, 0, $objphoto,
'product');
194 $dir = $conf->product->dir_output.
'/'.$pdir;
198 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
200 if ($obj[
'photo_vignette']) {
201 $filename = $obj[
'photo_vignette'];
203 $filename = $obj[
'photo'];
206 $filename = $obj[
'photo'];
208 $realpath = $dir.$filename;
213 $realpatharray[$i] = $realpath;
217 if (count($realpatharray) == 0) {
218 $this->posxpicture = $this->posxtva;
221 if ($conf->supplier_proposal->dir_output) {
225 $amount_credit_notes_included = 0;
226 $amount_deposits_included = 0;
232 $dir = $conf->supplier_proposal->dir_output;
233 $file = $dir.
"/SPECIMEN.pdf";
237 $dir = $conf->supplier_proposal->dir_output.
'/'.$objectref;
238 $file = $dir.
"/".$objectref.
".pdf";
240 $file = $dir.
"/".$objectref.($objectrefsupplier ?
"_".$objectrefsupplier :
"").
".pdf";
244 if (!file_exists($dir)) {
246 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
251 if (file_exists($dir)) {
253 if (!is_object($hookmanager)) {
254 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
257 $hookmanager->initHooks(array(
'pdfgeneration'));
258 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
260 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
262 $nblines = count(
$object->lines);
266 $heightforinfotot = 50;
267 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
268 $heightforfooter = $this->marge_basse + 8;
270 $heightforfooter += 6;
272 $pdf->SetAutoPageBreak(1, 0);
274 if (class_exists(
'TCPDF')) {
275 $pdf->setPrintHeader(
false);
276 $pdf->setPrintFooter(
false);
281 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
282 $tplidx = $pdf->importPage(1);
287 $pdf->SetDrawColor(128, 128, 128);
289 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
290 $pdf->SetSubject($outputlangs->transnoentities(
"SupplierProposal"));
291 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
292 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
293 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"SupplierProposal").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
295 $pdf->SetCompression(
false);
299 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
302 foreach (
$object->lines as $line) {
303 if ($line->remise_percent) {
304 $this->atleastonediscount =
true;
311 if (!empty($tplidx)) {
312 $pdf->useTemplate($tplidx);
316 $pdf->SetFont(
'',
'', $default_font_size - 1);
317 $pdf->MultiCell(0, 3,
'');
318 $pdf->SetTextColor(0, 0, 0);
320 $tab_top = 90 + $top_shift;
321 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
323 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
326 if (isModEnabled(
'incoterm')) {
327 $desc_incoterms =
$object->getIncotermsForPDF();
328 if ($desc_incoterms) {
331 $pdf->SetFont(
'',
'', $default_font_size - 1);
332 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
333 $nexY = $pdf->GetY();
334 $height_incoterms = $nexY - $tab_top;
337 $pdf->SetDrawColor(192, 192, 192);
338 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
340 $tab_top = $nexY + 6;
345 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
348 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
349 if (!empty($extranote)) {
353 $pagenb = $pdf->getPage();
355 $tab_width = $this->page_largeur - $this->marge_gauche - $this->marge_droite;
356 $pageposbeforenote = $pagenb;
365 $pdf->startTransaction();
367 $pdf->SetFont(
'',
'', $default_font_size - 1);
368 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
370 $pageposafternote = $pdf->getPage();
371 $posyafter = $pdf->GetY();
373 if ($pageposafternote > $pageposbeforenote) {
374 $pdf->rollbackTransaction(
true);
377 while ($pagenb < $pageposafternote) {
380 if (!empty($tplidx)) {
381 $pdf->useTemplate($tplidx);
387 $pdf->setTopMargin($tab_top_newpage);
389 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
393 $pdf->setPage($pageposbeforenote);
394 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
395 $pdf->SetFont(
'',
'', $default_font_size - 1);
396 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
397 $pageposafternote = $pdf->getPage();
399 $posyafter = $pdf->GetY();
401 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
402 $pdf->AddPage(
'',
'',
true);
405 $pdf->setPage($pageposafternote);
406 $pdf->setTopMargin($tab_top_newpage);
408 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext);
414 $i = $pageposbeforenote;
415 while ($i < $pageposafternote) {
419 $pdf->SetDrawColor(128, 128, 128);
421 if ($i > $pageposbeforenote) {
422 $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter);
423 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
425 $height_note = $this->page_hauteur - ($tab_top + $heightforfooter);
426 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
430 $pdf->setPageOrientation(
'', 1, 0);
437 $pdf->setPage($pageposafternote);
438 if (!empty($tplidx)) {
439 $pdf->useTemplate($tplidx);
444 $height_note = $posyafter - $tab_top_newpage;
445 $pdf->Rect($this->marge_gauche, $tab_top_newpage - 1, $tab_width, $height_note + 1);
448 $pdf->commitTransaction();
449 $posyafter = $pdf->GetY();
450 $height_note = $posyafter - $tab_top;
451 $pdf->Rect($this->marge_gauche, $tab_top - 1, $tab_width, $height_note + 1);
454 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + 20))) {
456 $pdf->AddPage(
'',
'',
true);
459 $pdf->setPage($pageposafternote);
460 if (!empty($tplidx)) {
461 $pdf->useTemplate($tplidx);
467 $posyafter = $tab_top_newpage;
471 $tab_height = $tab_height - $height_note;
472 $tab_top = $posyafter + 6;
480 $nexY = $tab_top + $this->tabTitleHeight;
483 $pageposbeforeprintlines = $pdf->getPage();
484 $pagenb = $pageposbeforeprintlines;
485 for ($i = 0; $i < $nblines; $i++) {
487 $pdf->SetFont(
'',
'', $default_font_size - 1);
488 $pdf->SetTextColor(0, 0, 0);
491 $imglinesize = array();
492 if (!empty($realpatharray[$i])) {
496 $pdf->setTopMargin($tab_top_newpage);
497 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
498 $pageposbefore = $pdf->getPage();
500 $showpricebeforepagebreak = 1;
502 $posYAfterDescription = 0;
507 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
508 $pdf->AddPage(
'',
'',
true);
509 if (!empty($tplidx)) {
510 $pdf->useTemplate($tplidx);
512 $pdf->setPage($pageposbefore + 1);
514 $curY = $tab_top_newpage;
518 $showpricebeforepagebreak = 1;
520 $showpricebeforepagebreak = 0;
524 if (!empty($this->cols[
'photo']) && isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
525 $pdf->Image($realpatharray[$i], $this->
getColumnContentXStart(
'photo'), $curY + 1, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
527 $posYAfterImage = $curY + $imglinesize[
'height'];
531 $curX = $this->posxdesc - 1;
532 $showpricebeforepagebreak = 1;
535 $pdf->startTransaction();
538 $pageposafter = $pdf->getPage();
539 if ($pageposafter > $pageposbefore) {
540 $pdf->rollbackTransaction(
true);
544 $pageposafter = $pdf->getPage();
545 $posyafter = $pdf->GetY();
546 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
547 if ($i == ($nblines - 1)) {
548 $pdf->AddPage(
'',
'',
true);
549 if (!empty($tplidx)) {
550 $pdf->useTemplate($tplidx);
553 $pdf->setPage($pageposafter + 1);
559 $showpricebeforepagebreak = 1;
561 $showpricebeforepagebreak = 0;
565 $pdf->commitTransaction();
567 $posYAfterDescription = $pdf->GetY();
570 $nexY = $pdf->GetY();
571 $pageposafter = $pdf->getPage();
572 $pdf->setPage($pageposbefore);
573 $pdf->setTopMargin($this->marge_haute);
574 $pdf->setPageOrientation(
'', 1, 0);
577 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
578 $pdf->setPage($pageposafter);
579 $curY = $tab_top_newpage;
582 $pdf->SetFont(
'',
'', $default_font_size - 1);
588 $nexY = max($pdf->GetY(), $nexY);
595 $nexY = max($pdf->GetY(), $nexY);
603 $nexY = max($pdf->GetY(), $nexY);
611 $nexY = max($pdf->GetY(), $nexY);
618 $nexY = max($pdf->GetY(), $nexY);
625 $nexY = max($pdf->GetY(), $nexY);
629 if (!empty(
$object->lines[$i]->array_options)) {
630 foreach (
$object->lines[$i]->array_options as $extrafieldColKey => $extrafieldValue) {
634 $nexY = max($pdf->GetY(), $nexY);
645 'outputlangs' => $outputlangs,
646 'hidedetails' => $hidedetails
648 $reshook = $hookmanager->executeHooks(
'printPDFline', $parameters, $this);
652 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
653 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
655 $tvaligne =
$object->lines[$i]->total_tva;
658 $localtax1ligne =
$object->lines[$i]->total_localtax1;
659 $localtax2ligne =
$object->lines[$i]->total_localtax2;
660 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
661 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
662 $localtax1_type =
$object->lines[$i]->localtax1_type;
663 $localtax2_type =
$object->lines[$i]->localtax2_type;
676 $vatrate = (string)
$object->lines[$i]->tva_tx;
679 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
680 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
682 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
683 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
687 if ($localtax1_type && $localtax1ligne != 0) {
688 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
689 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
691 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
694 if ($localtax2_type && $localtax2ligne != 0) {
695 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
696 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
698 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
702 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
707 if (!isset($this->tva[$vatrate])) {
708 $this->tva[$vatrate] = 0;
710 $this->tva[$vatrate] += $tvaligne;
711 $vatcode =
$object->lines[$i]->vat_src_code;
712 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
713 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
715 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
717 if ($posYAfterImage > $posYAfterDescription) {
718 $nexY = $posYAfterImage;
723 $pdf->setPage($pageposafter);
724 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
726 $pdf->line($this->marge_gauche, $nexY, $this->page_largeur - $this->marge_droite, $nexY);
727 $pdf->SetLineStyle(array(
'dash' => 0));
731 while ($pagenb < $pageposafter) {
732 $pdf->setPage($pagenb);
733 if ($pagenb == $pageposbeforeprintlines) {
734 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
736 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
740 $pdf->setPage($pagenb);
741 $pdf->setPageOrientation(
'', 1, 0);
745 if (!empty($tplidx)) {
746 $pdf->useTemplate($tplidx);
749 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
750 if ($pagenb == $pageposafter) {
751 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, $hidetop, 1,
$object->multicurrency_code);
753 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
758 if (!empty($tplidx)) {
759 $pdf->useTemplate($tplidx);
769 if ($pagenb == $pageposbeforeprintlines) {
770 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, $hidetop, 0,
$object->multicurrency_code);
771 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
773 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
774 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
784 if ($deja_regle || $amount_credit_notes_included || $amount_deposits_included) {
790 if (method_exists($pdf,
'AliasNbPages')) {
791 $pdf->AliasNbPages();
796 $pdf->Output($file,
'F');
799 $hookmanager->initHooks(array(
'pdfgeneration'));
800 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
802 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
804 $this->error = $hookmanager->error;
805 $this->errors = $hookmanager->errors;
810 $this->result = array(
'fullpath' => $file);
814 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
818 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_OUTPUTDIR");
920 global $conf, $mysoc;
926 $pdf->SetFont(
'',
'', $default_font_size - 1);
931 if ($this->page_largeur < 210) {
934 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
940 $pdf->SetFillColor(255, 255, 255);
941 $pdf->SetXY($col1x, $tab2_top);
942 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
944 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
945 $pdf->SetXY($col2x, $tab2_top);
946 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0)), 0,
'R', 1);
949 $pdf->SetFillColor(248, 248, 248);
951 $this->atleastoneratenotnull = 0;
952 foreach ($this->tva as $tvakey => $tvaval) {
954 $this->atleastoneratenotnull++;
957 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
961 if (preg_match(
'/\*/', $tvakey)) {
962 $tvakey = str_replace(
'*',
'', $tvakey);
963 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
966 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
967 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
968 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
970 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
971 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
974 if (!$this->atleastoneratenotnull) {
976 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
977 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code), 0,
'L', 1);
979 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
980 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_tva), 0,
'R', 1);
985 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
986 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code), 0,
'L', 1);
987 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
988 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax1), $useborder,
'R', 1);
994 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
995 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code), 0,
'L', 1);
996 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
997 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_localtax2), $useborder,
'R', 1);
1003 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1004 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1008 foreach ($localtax_rate as $tvakey => $tvaval) {
1013 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1016 if (preg_match(
'/\*/', $tvakey)) {
1017 $tvakey = str_replace(
'*',
'', $tvakey);
1018 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1020 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1021 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1022 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1024 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1025 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1033 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1034 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1038 foreach ($localtax_rate as $tvakey => $tvaval) {
1043 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1046 if (preg_match(
'/\*/', $tvakey)) {
1047 $tvakey = str_replace(
'*',
'', $tvakey);
1048 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1050 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1051 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1052 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1054 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1055 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval), 0,
'R', 1);
1063 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1064 $pdf->SetTextColor(0, 0, 60);
1065 $pdf->SetFillColor(224, 224, 224);
1066 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1068 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1069 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1070 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc), $useborder,
'R', 1);
1071 $pdf->SetFont(
'',
'', $default_font_size - 1);
1072 $pdf->SetTextColor(0, 0, 0);
1074 $creditnoteamount = 0;
1075 $depositsamount = 0;
1079 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1084 if ($deja_regle > 0) {
1088 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1089 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1090 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1091 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle), 0,
'R', 0);
1094 $pdf->SetTextColor(0, 0, 60);
1095 $pdf->SetFillColor(224, 224, 224);
1096 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1097 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1099 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1100 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer), $useborder,
'R', 1);
1102 $pdf->SetFont(
'',
'', $default_font_size - 1);
1103 $pdf->SetTextColor(0, 0, 0);
1107 return ($tab2_top + ($tab2_hl * $index));
1177 global $langs, $conf, $mysoc;
1179 $ltrdirection =
'L';
1180 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1181 $ltrdirection =
'R';
1185 $outputlangs->loadLangs(array(
"main",
"supplier_proposal",
"companies",
"bills",
"sendings"));
1199 $pdf->SetTextColor(0, 0, 60);
1200 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1202 $posx = $this->page_largeur - $this->marge_droite - 100;
1203 $posy = $this->marge_haute;
1205 $pdf->SetXY($this->marge_gauche, $posy);
1209 if ($this->emetteur->logo) {
1210 $logodir = $conf->mycompany->dir_output;
1211 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
1212 $logodir = $conf->mycompany->multidir_output[
$object->entity];
1215 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1217 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1219 if (is_readable($logo)) {
1221 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1223 $pdf->SetTextColor(200, 0, 0);
1224 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1225 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1226 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1229 $text = $this->emetteur->name;
1230 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1234 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1235 $pdf->SetXY($posx, $posy);
1236 $pdf->SetTextColor(0, 0, 60);
1237 $title = $outputlangs->transnoentities(
"SupplierProposal").
" ".$outputlangs->convToOutputCharset(
$object->ref);
1238 $pdf->MultiCell(100, 3, $title,
'',
'R');
1243 $pdf->SetFont(
'',
'B', $default_font_size);
1244 $pdf->SetXY($posx, $posy);
1245 $pdf->SetTextColor(0, 0, 60);
1246 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".$outputlangs->convToOutputCharset(
$object->ref_supplier),
'',
'R');
1250 $pdf->SetFont(
'',
'', $default_font_size - 1);
1254 if (!empty(
$object->project->ref)) {
1256 $pdf->SetXY($posx, $posy);
1257 $pdf->SetTextColor(0, 0, 60);
1258 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1264 if (!empty(
$object->project->ref)) {
1265 $outputlangs->load(
"projects");
1267 $pdf->SetXY($posx, $posy);
1268 $langs->load(
"projects");
1269 $pdf->SetTextColor(0, 0, 60);
1270 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1276 $pdf->SetXY($posx, $posy);
1277 $pdf->SetTextColor(0, 0, 60);
1278 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1281 $pdf->SetXY($posx, $posy);
1282 $pdf->SetTextColor(255, 0, 0);
1283 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Draft"),
'',
'R');
1286 $pdf->SetTextColor(0, 0, 60);
1287 $usehourmin =
'day';
1289 $usehourmin =
'dayhour';
1291 if (!empty(
$object->delivery_date)) {
1293 $pdf->SetXY($posx - 90, $posy);
1294 $pdf->MultiCell(190, 3, $outputlangs->transnoentities(
"DateDeliveryPlanned").
" : ".
dol_print_date(
$object->delivery_date, $usehourmin,
false, $outputlangs,
true),
'',
'R');
1297 if (
$object->thirdparty->code_fournisseur) {
1299 $pdf->SetXY($posx, $posy);
1300 $pdf->SetTextColor(0, 0, 60);
1301 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_fournisseur),
'',
'R');
1306 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1307 if (count($arrayidcontact) > 0) {
1308 $usertmp =
new User($this->db);
1309 $usertmp->fetch($arrayidcontact[0]);
1311 $pdf->SetXY($posx, $posy);
1312 $pdf->SetTextColor(0, 0, 60);
1313 $pdf->MultiCell(100, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1318 $pdf->SetTextColor(0, 0, 60);
1322 $current_y = $pdf->getY();
1324 if ($current_y < $pdf->getY()) {
1325 $top_shift = $pdf->getY() - $current_y;
1330 $carac_emetteur =
'';
1332 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1333 if (count($arrayidcontact) > 0) {
1334 $object->fetch_user($arrayidcontact[0]);
1335 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1336 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1338 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1342 $carac_emetteur .=
"\n";
1348 $posy = 42 + $top_shift;
1349 $posx = $this->marge_gauche;
1351 $posx = $this->page_largeur - $this->marge_droite - 80;
1356 $pdf->SetTextColor(0, 0, 0);
1357 $pdf->SetFont(
'',
'', $default_font_size - 2);
1358 $pdf->SetXY($posx, $posy - 5);
1359 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1360 $pdf->SetXY($posx, $posy);
1361 $pdf->SetFillColor(230, 230, 230);
1362 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1363 $pdf->SetTextColor(0, 0, 60);
1366 $pdf->SetXY($posx + 2, $posy + 3);
1367 $pdf->SetFont(
'',
'B', $default_font_size);
1368 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1369 $posy = $pdf->getY();
1372 $pdf->SetXY($posx + 2, $posy);
1373 $pdf->SetFont(
'',
'', $default_font_size - 1);
1374 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1379 $usecontact =
false;
1381 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1383 $arrayidcontact = array_merge(
$object->getIdContact(
'external',
'CUSTOMER'),
$object->getIdContact(
'external',
'BILLING'));
1385 if (is_array($arrayidcontact) && count($arrayidcontact) > 0) {
1387 $result =
$object->fetch_contact($arrayidcontact[0]);
1391 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1392 $thirdparty =
$object->contact;
1394 $thirdparty =
$object->thirdparty;
1403 if ($this->page_largeur < 210) {
1406 $posy = 42 + $top_shift;
1407 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1409 $posx = $this->marge_gauche;
1413 $pdf->SetTextColor(0, 0, 0);
1414 $pdf->SetFont(
'',
'', $default_font_size - 2);
1415 $pdf->SetXY($posx + 2, $posy - 5);
1416 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1417 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1420 $pdf->SetXY($posx + 2, $posy + 3);
1421 $pdf->SetFont(
'',
'B', $default_font_size);
1423 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1425 $posy = $pdf->getY();
1428 $pdf->SetFont(
'',
'', $default_font_size - 1);
1429 $pdf->SetXY($posx + 2, $posy);
1431 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);