173 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
176 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
178 if (!is_object($outputlangs)) {
179 $outputlangs = $langs;
183 $outputlangs->charset_output =
'ISO-8859-1';
187 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"supplier_proposal"));
194 $nblines = count(
$object->lines);
197 $realpatharray = array();
199 for ($i = 0; $i < $nblines; $i++) {
200 if (empty(
$object->lines[$i]->fk_product)) {
204 $objphoto =
new Product($this->db);
205 $objphoto->fetch(
$object->lines[$i]->fk_product);
208 $pdir =
get_exdir(
$object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
209 $dir = $conf->product->dir_output.
'/'.$pdir;
211 $pdir =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
212 $dir = $conf->product->dir_output.
'/'.$pdir;
216 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
218 if ($obj[
'photo_vignette']) {
219 $filename = $obj[
'photo_vignette'];
221 $filename = $obj[
'photo'];
224 $filename = $obj[
'photo'];
226 $realpath = $dir.$filename;
231 $realpatharray[$i] = $realpath;
235 if (count($realpatharray) == 0) {
236 $this->posxpicture = $this->posxup;
239 if ($conf->supplier_proposal->dir_output) {
246 $dir = $conf->supplier_proposal->dir_output;
247 $file = $dir.
"/SPECIMEN.pdf";
250 $dir = $conf->supplier_proposal->dir_output.
"/".$objectref;
251 $file = $dir.
"/".$objectref.
".pdf";
254 if (!file_exists($dir)) {
256 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
261 if (file_exists($dir)) {
263 if (!is_object($hookmanager)) {
264 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
267 $hookmanager->initHooks(array(
'pdfgeneration'));
268 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
270 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
275 $heightforinfotot = 50;
277 $heightforfooter = $this->marge_basse + 8;
279 $heightforfooter += 6;
281 $pdf->SetAutoPageBreak(1, 0);
283 if (class_exists(
'TCPDF')) {
284 $pdf->setPrintHeader(
false);
285 $pdf->setPrintFooter(
false);
290 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
291 $tplidx = $pdf->importPage(1);
296 $pdf->SetDrawColor(128, 128, 128);
298 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
299 $pdf->SetSubject($outputlangs->transnoentities(
"CommercialAsk"));
300 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
301 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
302 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"CommercialAsk").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
304 $pdf->SetCompression(
false);
308 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
311 for ($i = 0; $i < $nblines; $i++) {
312 if (
$object->lines[$i]->remise_percent) {
313 $this->atleastonediscount++;
316 if (empty($this->atleastonediscount)) {
317 $delta = ($this->postotalht - $this->posxdiscount);
318 $this->posxpicture += $delta;
319 $this->posxup += $delta;
320 $this->posxqty += $delta;
321 $this->posxunit += $delta;
322 $this->posxdiscount += $delta;
328 if (!empty($tplidx)) {
329 $pdf->useTemplate($tplidx);
333 $pdf->SetFont(
'',
'', $default_font_size - 1);
334 $pdf->MultiCell(0, 3,
'');
335 $pdf->SetTextColor(0, 0, 0);
337 $tab_top = 90 + $top_shift;
338 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
341 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
344 if (is_object(
$object->thirdparty)) {
345 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
346 $salerepobj =
new User($this->db);
347 $salerepobj->fetch($salereparray[0][
'id']);
348 if (!empty($salerepobj->signature)) {
349 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
355 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
356 if (!empty($extranote)) {
368 $pdf->SetFont(
'',
'', $default_font_size - 1);
369 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
370 $nexY = $pdf->GetY();
371 $height_note = $nexY - $tab_top;
374 $pdf->SetDrawColor(192, 192, 192);
375 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius,
'1234',
'D');
377 $tab_top = $nexY + 6;
380 $iniY = $tab_top + 7;
381 $curY = $tab_top + 7;
382 $nexY = $tab_top + 7;
385 for ($i = 0; $i < $nblines; $i++) {
387 $pdf->SetFont(
'',
'', $default_font_size - 1);
388 $pdf->SetTextColor(0, 0, 0);
391 $imglinesize = array();
392 if (!empty($realpatharray[$i])) {
396 $pdf->setTopMargin($tab_top_newpage);
397 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
398 $pageposbefore = $pdf->getPage();
400 $showpricebeforepagebreak = 1;
402 $posYAfterDescription = 0;
405 if (!empty($imglinesize[
'width']) && !empty($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
406 $pdf->AddPage(
'',
'',
true);
407 if (!empty($tplidx)) {
408 $pdf->useTemplate($tplidx);
413 $pdf->setPage($pageposbefore + 1);
415 $curY = $tab_top_newpage;
419 $showpricebeforepagebreak = 1;
421 $showpricebeforepagebreak = 0;
425 if (!empty($imglinesize[
'width']) && !empty($imglinesize[
'height'])) {
426 $curX = $this->posxpicture - 1;
427 $pdf->Image($realpatharray[$i], $curX + (($this->posxup - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
429 $posYAfterImage = $curY + $imglinesize[
'height'];
433 $curX = $this->posxdesc - 1;
435 $pdf->startTransaction();
436 if ($posYAfterImage > 0) {
437 $descWidth = $this->posxpicture - $curX;
439 $descWidth = $this->posxup - $curX;
441 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
443 $pageposafter = $pdf->getPage();
444 if ($pageposafter > $pageposbefore) {
445 $pdf->rollbackTransaction(
true);
446 $pageposafter = $pageposbefore;
448 $pdf->setPageOrientation(
'', 1, $heightforfooter);
449 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
451 $pageposafter = $pdf->getPage();
452 $posyafter = $pdf->GetY();
454 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
455 if ($i == ($nblines - 1)) {
456 $pdf->AddPage(
'',
'',
true);
457 if (!empty($tplidx)) {
458 $pdf->useTemplate($tplidx);
463 $pdf->setPage($pageposafter + 1);
469 $showpricebeforepagebreak = 1;
471 $showpricebeforepagebreak = 0;
475 $pdf->commitTransaction();
477 $posYAfterDescription = $pdf->GetY();
479 $nexY = $pdf->GetY();
480 $pageposafter = $pdf->getPage();
482 $pdf->setPage($pageposbefore);
483 $pdf->setTopMargin($this->marge_haute);
484 $pdf->setPageOrientation(
'', 1, 0);
487 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
488 $pdf->setPage($pageposafter);
489 $curY = $tab_top_newpage;
492 $pdf->SetFont(
'',
'', $default_font_size - 1);
496 $pdf->SetXY($this->posxqty, $curY);
497 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
502 $pdf->SetXY($this->posxunit, $curY);
503 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
523 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
524 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
526 $tvaligne =
$object->lines[$i]->total_tva;
529 $localtax1ligne =
$object->lines[$i]->total_localtax1;
530 $localtax2ligne =
$object->lines[$i]->total_localtax2;
531 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
532 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
533 $localtax1_type =
$object->lines[$i]->localtax1_type;
534 $localtax2_type =
$object->lines[$i]->localtax2_type;
547 $vatrate = (string)
$object->lines[$i]->tva_tx;
550 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
551 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
553 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
554 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
558 if ($localtax1_type && $localtax1ligne != 0) {
559 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
560 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
562 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
565 if ($localtax2_type && $localtax2ligne != 0) {
566 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
567 $this->localtax2[$localtax2_type][$localtax2_rate] = (float) $localtax2ligne;
569 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
573 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
578 if (!isset($this->tva[$vatrate])) {
579 $this->tva[$vatrate] = 0;
581 $this->tva[$vatrate] += $tvaligne;
582 $vatcode =
$object->lines[$i]->vat_src_code;
583 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
584 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
586 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
588 if ($posYAfterImage > $posYAfterDescription) {
589 $nexY = $posYAfterImage;
594 $pdf->setPage($pageposafter);
595 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
597 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
598 $pdf->SetLineStyle(array(
'dash' => 0));
604 while ($pagenb < $pageposafter) {
605 $pdf->setPage($pagenb);
607 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
609 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
613 $pdf->setPage($pagenb);
614 $pdf->setPageOrientation(
'', 1, 0);
618 if (!empty($tplidx)) {
619 $pdf->useTemplate($tplidx);
622 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
624 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
626 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
631 if (!empty($tplidx)) {
632 $pdf->useTemplate($tplidx);
643 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
644 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
646 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
647 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
666 if (method_exists($pdf,
'AliasNbPages')) {
667 $pdf->AliasNbPages();
672 $pdf->Output($file,
'F');
675 $hookmanager->initHooks(array(
'pdfgeneration'));
676 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
678 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
680 $this->error = $hookmanager->error;
681 $this->errors = $hookmanager->errors;
686 $this->result = array(
'fullpath' => $file);
690 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
694 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_PROPOSAL_OUTPUTDIR");
733 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
735 $pdf->SetFont(
'',
'', $default_font_size - 1);
740 if (!empty(
$object->delivery_date)) {
741 $outputlangs->load(
"sendings");
742 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
743 $pdf->SetXY($this->marge_gauche, $posy);
744 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
745 $pdf->MultiCell(80, 4, $titre, 0,
'L');
746 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
747 $pdf->SetXY($posxval, $posy);
749 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
751 $posy = $pdf->GetY() + 1;
753 $outputlangs->load(
"sendings");
754 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
755 $pdf->SetXY($this->marge_gauche, $posy);
756 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
757 $pdf->MultiCell(80, 4, $titre, 0,
'L');
758 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
759 $pdf->SetXY($posxval, $posy);
761 $pdf->MultiCell(80, 4,
'', 0,
'L');
763 $posy = $pdf->GetY() + 1;
784 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
785 $pdf->SetXY($this->marge_gauche, $posy);
786 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
787 $pdf->MultiCell(80, 4, $titre, 0,
'L');
789 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
790 $pdf->SetXY($posxval, $posy);
791 $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);
792 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
793 $pdf->MultiCell(80, 4, $lib_condition_paiement, 0,
'L');
795 $posy = $pdf->GetY() + 3;
800 if (
$object->mode_reglement_code
801 &&
$object->mode_reglement_code !=
'CHQ'
802 &&
$object->mode_reglement_code !=
'VIR') {
803 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
804 $pdf->SetXY($this->marge_gauche, $posy - 2);
805 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
806 $pdf->MultiCell(80, 5, $titre, 0,
'L');
807 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
808 $pdf->SetXY($posxval, $posy - 2);
809 $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);
810 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
812 $posy = $pdf->GetY() + 2;
816 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
820 $account =
new Account($this->db);
823 $pdf->SetXY($this->marge_gauche, $posy);
824 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
825 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
826 $posy = $pdf->GetY() + 1;
829 $pdf->SetXY($this->marge_gauche, $posy);
830 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
831 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
832 $posy = $pdf->GetY() + 2;
836 $pdf->SetXY($this->marge_gauche, $posy);
837 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
838 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
839 $posy = $pdf->GetY() + 1;
842 $pdf->SetXY($this->marge_gauche, $posy);
843 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
844 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
845 $posy = $pdf->GetY() + 2;
852 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
854 $bankid = (empty(
$object->fk_bank) ? $conf->global->FACTURE_RIB_NUMBER :
$object->fk_bank);
855 $account =
new Account($this->db);
856 $account->fetch($bankid);
858 $curx = $this->marge_gauche;
861 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
886 global $conf, $mysoc;
891 $pdf->SetFont(
'',
'', $default_font_size - 1);
896 if ($this->page_largeur < 210) {
899 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
905 $pdf->SetFillColor(255, 255, 255);
906 $pdf->SetXY($col1x, $tab2_top);
907 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
909 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
910 $pdf->SetXY($col2x, $tab2_top);
911 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R', 1);
914 $pdf->SetFillColor(248, 248, 248);
916 $this->atleastoneratenotnull = 0;
918 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
925 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
926 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
930 foreach ($localtax_rate as $tvakey => $tvaval) {
935 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
938 if (preg_match(
'/\*/', $tvakey)) {
939 $tvakey = str_replace(
'*',
'', $tvakey);
940 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
942 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
943 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
944 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
946 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
947 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
955 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
956 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
960 foreach ($localtax_rate as $tvakey => $tvaval) {
967 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
970 if (preg_match(
'/\*/', $tvakey)) {
971 $tvakey = str_replace(
'*',
'', $tvakey);
972 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
974 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
975 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
976 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
978 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
979 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
985 foreach ($this->tva as $tvakey => $tvaval) {
987 $this->atleastoneratenotnull++;
990 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
993 if (preg_match(
'/\*/', $tvakey)) {
994 $tvakey = str_replace(
'*',
'', $tvakey);
995 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
997 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
998 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
999 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1001 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1002 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1009 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1010 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1014 foreach ($localtax_rate as $tvakey => $tvaval) {
1019 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1022 if (preg_match(
'/\*/', $tvakey)) {
1023 $tvakey = str_replace(
'*',
'', $tvakey);
1024 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1026 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1028 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1029 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1030 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1031 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1039 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1040 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1044 foreach ($localtax_rate as $tvakey => $tvaval) {
1050 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1053 if (preg_match(
'/\*/', $tvakey)) {
1054 $tvakey = str_replace(
'*',
'', $tvakey);
1055 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1057 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1059 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1060 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1062 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1063 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1071 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1072 $pdf->SetTextColor(0, 0, 60);
1073 $pdf->SetFillColor(224, 224, 224);
1074 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1076 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1077 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1081 $pdf->SetTextColor(0, 0, 0);
1083 $resteapayer =
$object->total_ttc - $deja_regle;
1088 if ($deja_regle > 0) {
1091 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1092 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1094 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1095 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1098 $pdf->SetTextColor(0, 0, 60);
1099 $pdf->SetFillColor(224, 224, 224);
1100 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1101 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1103 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1104 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1106 $pdf->SetFont(
'',
'', $default_font_size - 1);
1107 $pdf->SetTextColor(0, 0, 0);
1111 return ($tab2_top + ($tab2_hl * $index));
1128 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1138 $currency = !empty($currency) ? $currency : $conf->currency;
1142 $pdf->SetTextColor(0, 0, 0);
1143 $pdf->SetFont(
'',
'', $default_font_size - 2);
1145 if (empty($hidetop)) {
1146 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1147 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1148 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1152 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius,
'1001',
'F', array(), explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
1156 $pdf->SetDrawColor(128, 128, 128);
1157 $pdf->SetFont(
'',
'', $default_font_size - 1);
1160 $this->
printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom,
'D');
1162 if (empty($hidetop)) {
1163 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1165 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1166 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1169 $pdf->line($this->posxup + 1, $tab_top, $this->posxup + 1, $tab_top + $tab_height);
1170 if (empty($hidetop)) {
1171 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1172 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1175 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1176 if (empty($hidetop)) {
1177 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1178 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1182 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1183 if (empty($hidetop)) {
1184 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1185 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1189 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1190 if (empty($hidetop)) {
1191 if ($this->atleastonediscount) {
1192 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1193 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1196 if ($this->atleastonediscount) {
1197 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1199 if (empty($hidetop)) {
1200 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1201 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1217 global $conf, $langs;
1218 '@phan-var-force SupplierProposal $object';
1221 $outputlangs->loadLangs(array(
"main",
"bills",
"supplier_proposal",
"companies"));
1227 $pdf->SetTextColor(0, 0, 60);
1228 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1230 $posy = $this->marge_haute;
1231 $posx = $this->page_largeur - $this->marge_droite - 100;
1233 $pdf->SetXY($this->marge_gauche, $posy);
1237 if ($this->emetteur->logo) {
1238 $logodir = $conf->mycompany->dir_output;
1239 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
1240 $logodir = $conf->mycompany->multidir_output[
$object->entity];
1243 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1245 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1247 if (is_readable($logo)) {
1249 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1251 $pdf->SetTextColor(200, 0, 0);
1252 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1253 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1254 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1257 $text = $this->emetteur->name;
1258 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0);
1262 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1263 $pdf->SetXY($posx, $posy);
1264 $pdf->SetTextColor(0, 0, 60);
1265 $title = $outputlangs->transnoentities(
"CommercialAsk");
1266 $pdf->MultiCell(100, 4, $title,
'',
'R');
1268 $pdf->SetFont(
'',
'B', $default_font_size);
1271 $pdf->SetXY($posx, $posy);
1272 $pdf->SetTextColor(0, 0, 60);
1273 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset(
$object->ref),
'',
'R');
1276 $pdf->SetFont(
'',
'', $default_font_size - 2);
1280 $pdf->SetXY($posx, $posy);
1281 $pdf->SetTextColor(0, 0, 60);
1282 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_fourn), 65),
'',
'R');
1285 if (
$object->thirdparty->code_fournisseur) {
1287 $pdf->SetXY($posx, $posy);
1288 $pdf->SetTextColor(0, 0, 60);
1289 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_fournisseur),
'',
'R');
1294 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1295 if (count($arrayidcontact) > 0) {
1296 $usertmp =
new User($this->db);
1297 $usertmp->fetch($arrayidcontact[0]);
1299 $pdf->SetXY($posx, $posy);
1300 $pdf->SetTextColor(0, 0, 60);
1301 $pdf->MultiCell(100, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1309 $current_y = $pdf->getY();
1311 if ($current_y < $pdf->getY()) {
1312 $top_shift = $pdf->getY() - $current_y;
1317 $carac_emetteur =
'';
1319 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1320 if (count($arrayidcontact) > 0) {
1321 $object->fetch_user($arrayidcontact[0]);
1322 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1323 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1325 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1329 $carac_emetteur .=
"\n";
1335 $posy = 42 + $top_shift;
1336 $posx = $this->marge_gauche;
1338 $posx = $this->page_largeur - $this->marge_droite - 80;
1343 $pdf->SetTextColor(0, 0, 0);
1344 $pdf->SetFont(
'',
'', $default_font_size - 2);
1345 $pdf->SetXY($posx, $posy - 5);
1346 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0,
'L');
1347 $pdf->SetXY($posx, $posy);
1348 $pdf->SetFillColor(230, 230, 230);
1349 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1350 $pdf->SetTextColor(0, 0, 60);
1353 $pdf->SetXY($posx + 2, $posy + 3);
1354 $pdf->SetFont(
'',
'B', $default_font_size);
1355 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1356 $posy = $pdf->getY();
1359 $pdf->SetXY($posx + 2, $posy);
1360 $pdf->SetFont(
'',
'', $default_font_size - 1);
1361 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
1365 $usecontact =
false;
1367 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1369 $arrayidcontact = array_merge(
$object->getIdContact(
'external',
'CUSTOMER'),
$object->getIdContact(
'external',
'BILLING'));
1371 if (is_array($arrayidcontact) && count($arrayidcontact) > 0) {
1373 $result =
$object->fetch_contact($arrayidcontact[0]);
1377 if (!empty($usecontact)) {
1378 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1381 $socname =
$object->thirdparty;
1384 $socname =
$object->thirdparty;
1393 if ($this->page_largeur < 210) {
1396 $posy = 42 + $top_shift;
1397 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1399 $posx = $this->marge_gauche;
1403 $pdf->SetTextColor(0, 0, 0);
1404 $pdf->SetFont(
'',
'', $default_font_size - 2);
1405 $pdf->SetXY($posx + 2, $posy - 5);
1406 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0,
'L');
1407 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1410 $pdf->SetXY($posx + 2, $posy + 3);
1411 $pdf->SetFont(
'',
'B', $default_font_size);
1412 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0,
'L');
1415 $pdf->SetFont(
'',
'', $default_font_size - 1);
1416 $pdf->SetXY($posx + 2, $posy + 4 + (
dol_nboflines_bis($carac_client_name, 50) * 4));
1417 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1420 $pdf->SetTextColor(0, 0, 0);