167 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
170 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
172 if (!is_object($outputlangs)) {
173 $outputlangs = $langs;
177 $outputlangs->charset_output =
'ISO-8859-1';
181 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"supplier_proposal"));
188 $nblines = count(
$object->lines);
191 $realpatharray = array();
193 for ($i = 0; $i < $nblines; $i++) {
194 if (empty(
$object->lines[$i]->fk_product)) {
198 $objphoto =
new Product($this->db);
199 $objphoto->fetch(
$object->lines[$i]->fk_product);
202 $pdir =
get_exdir(
$object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
203 $dir = $conf->product->dir_output.
'/'.$pdir;
205 $pdir =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
206 $dir = $conf->product->dir_output.
'/'.$pdir;
210 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
212 if ($obj[
'photo_vignette']) {
213 $filename = $obj[
'photo_vignette'];
215 $filename = $obj[
'photo'];
218 $filename = $obj[
'photo'];
220 $realpath = $dir.$filename;
225 $realpatharray[$i] = $realpath;
229 if (count($realpatharray) == 0) {
230 $this->posxpicture = $this->posxup;
233 if ($conf->supplier_proposal->dir_output) {
240 $dir = $conf->supplier_proposal->dir_output;
241 $file = $dir.
"/SPECIMEN.pdf";
244 $dir = $conf->supplier_proposal->dir_output.
"/".$objectref;
245 $file = $dir.
"/".$objectref.
".pdf";
248 if (!file_exists($dir)) {
250 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
255 if (file_exists($dir)) {
257 if (!is_object($hookmanager)) {
258 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
261 $hookmanager->initHooks(array(
'pdfgeneration'));
262 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
264 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
269 $heightforinfotot = 50;
270 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
271 $heightforfooter = $this->marge_basse + 8;
273 $heightforfooter += 6;
275 $pdf->SetAutoPageBreak(1, 0);
277 if (class_exists(
'TCPDF')) {
278 $pdf->setPrintHeader(
false);
279 $pdf->setPrintFooter(
false);
284 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
285 $tplidx = $pdf->importPage(1);
290 $pdf->SetDrawColor(128, 128, 128);
292 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
293 $pdf->SetSubject($outputlangs->transnoentities(
"CommercialAsk"));
294 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
295 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
296 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"CommercialAsk").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
298 $pdf->SetCompression(
false);
302 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
305 for ($i = 0; $i < $nblines; $i++) {
306 if (
$object->lines[$i]->remise_percent) {
307 $this->atleastonediscount++;
310 if (empty($this->atleastonediscount)) {
311 $delta = ($this->postotalht - $this->posxdiscount);
312 $this->posxpicture += $delta;
313 $this->posxup += $delta;
314 $this->posxqty += $delta;
315 $this->posxunit += $delta;
316 $this->posxdiscount += $delta;
322 if (!empty($tplidx)) {
323 $pdf->useTemplate($tplidx);
327 $pdf->SetFont(
'',
'', $default_font_size - 1);
328 $pdf->MultiCell(0, 3,
'');
329 $pdf->SetTextColor(0, 0, 0);
331 $tab_top = 90 + $top_shift;
332 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
335 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
338 if (is_object(
$object->thirdparty)) {
339 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
340 $salerepobj =
new User($this->db);
341 $salerepobj->fetch($salereparray[0][
'id']);
342 if (!empty($salerepobj->signature)) {
343 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
349 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
350 if (!empty($extranote)) {
362 $pdf->SetFont(
'',
'', $default_font_size - 1);
363 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
364 $nexY = $pdf->GetY();
365 $height_note = $nexY - $tab_top;
368 $pdf->SetDrawColor(192, 192, 192);
369 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
371 $tab_top = $nexY + 6;
374 $iniY = $tab_top + 7;
375 $curY = $tab_top + 7;
376 $nexY = $tab_top + 7;
379 for ($i = 0; $i < $nblines; $i++) {
381 $pdf->SetFont(
'',
'', $default_font_size - 1);
382 $pdf->SetTextColor(0, 0, 0);
385 $imglinesize = array();
386 if (!empty($realpatharray[$i])) {
390 $pdf->setTopMargin($tab_top_newpage);
391 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
392 $pageposbefore = $pdf->getPage();
394 $showpricebeforepagebreak = 1;
396 $posYAfterDescription = 0;
399 if (!empty($imglinesize[
'width']) && !empty($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
400 $pdf->AddPage(
'',
'',
true);
401 if (!empty($tplidx)) {
402 $pdf->useTemplate($tplidx);
407 $pdf->setPage($pageposbefore + 1);
409 $curY = $tab_top_newpage;
413 $showpricebeforepagebreak = 1;
415 $showpricebeforepagebreak = 0;
419 if (!empty($imglinesize[
'width']) && !empty($imglinesize[
'height'])) {
420 $curX = $this->posxpicture - 1;
421 $pdf->Image($realpatharray[$i], $curX + (($this->posxup - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
423 $posYAfterImage = $curY + $imglinesize[
'height'];
427 $curX = $this->posxdesc - 1;
429 $pdf->startTransaction();
430 if ($posYAfterImage > 0) {
431 $descWidth = $this->posxpicture - $curX;
433 $descWidth = $this->posxup - $curX;
435 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
437 $pageposafter = $pdf->getPage();
438 if ($pageposafter > $pageposbefore) {
439 $pdf->rollbackTransaction(
true);
440 $pageposafter = $pageposbefore;
442 $pdf->setPageOrientation(
'', 1, $heightforfooter);
443 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
445 $pageposafter = $pdf->getPage();
446 $posyafter = $pdf->GetY();
448 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
449 if ($i == ($nblines - 1)) {
450 $pdf->AddPage(
'',
'',
true);
451 if (!empty($tplidx)) {
452 $pdf->useTemplate($tplidx);
457 $pdf->setPage($pageposafter + 1);
463 $showpricebeforepagebreak = 1;
465 $showpricebeforepagebreak = 0;
469 $pdf->commitTransaction();
471 $posYAfterDescription = $pdf->GetY();
473 $nexY = $pdf->GetY();
474 $pageposafter = $pdf->getPage();
476 $pdf->setPage($pageposbefore);
477 $pdf->setTopMargin($this->marge_haute);
478 $pdf->setPageOrientation(
'', 1, 0);
481 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
482 $pdf->setPage($pageposafter);
483 $curY = $tab_top_newpage;
486 $pdf->SetFont(
'',
'', $default_font_size - 1);
490 $pdf->SetXY($this->posxqty, $curY);
491 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
496 $pdf->SetXY($this->posxunit, $curY);
497 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
517 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
518 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
520 $tvaligne =
$object->lines[$i]->total_tva;
523 $localtax1ligne =
$object->lines[$i]->total_localtax1;
524 $localtax2ligne =
$object->lines[$i]->total_localtax2;
525 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
526 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
527 $localtax1_type =
$object->lines[$i]->localtax1_type;
528 $localtax2_type =
$object->lines[$i]->localtax2_type;
541 $vatrate = (string)
$object->lines[$i]->tva_tx;
544 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
545 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
547 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
548 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
552 if ($localtax1_type && $localtax1ligne != 0) {
553 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
554 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
556 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
559 if ($localtax2_type && $localtax2ligne != 0) {
560 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
561 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
563 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
567 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
572 if (!isset($this->tva[$vatrate])) {
573 $this->tva[$vatrate] = 0;
575 $this->tva[$vatrate] += $tvaligne;
576 $vatcode =
$object->lines[$i]->vat_src_code;
577 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
578 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
580 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
582 if ($posYAfterImage > $posYAfterDescription) {
583 $nexY = $posYAfterImage;
588 $pdf->setPage($pageposafter);
589 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
591 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
592 $pdf->SetLineStyle(array(
'dash' => 0));
598 while ($pagenb < $pageposafter) {
599 $pdf->setPage($pagenb);
601 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
603 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
607 $pdf->setPage($pagenb);
608 $pdf->setPageOrientation(
'', 1, 0);
612 if (!empty($tplidx)) {
613 $pdf->useTemplate($tplidx);
616 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
618 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
620 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
625 if (!empty($tplidx)) {
626 $pdf->useTemplate($tplidx);
637 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
638 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
640 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
641 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
660 if (method_exists($pdf,
'AliasNbPages')) {
661 $pdf->AliasNbPages();
666 $pdf->Output($file,
'F');
669 $hookmanager->initHooks(array(
'pdfgeneration'));
670 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
672 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
674 $this->error = $hookmanager->error;
675 $this->errors = $hookmanager->errors;
680 $this->result = array(
'fullpath' => $file);
684 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
688 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_PROPOSAL_OUTPUTDIR");
727 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
729 $pdf->SetFont(
'',
'', $default_font_size - 1);
734 if (!empty(
$object->delivery_date)) {
735 $outputlangs->load(
"sendings");
736 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
737 $pdf->SetXY($this->marge_gauche, $posy);
738 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
739 $pdf->MultiCell(80, 4, $titre, 0,
'L');
740 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
741 $pdf->SetXY($posxval, $posy);
743 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
745 $posy = $pdf->GetY() + 1;
747 $outputlangs->load(
"sendings");
748 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
749 $pdf->SetXY($this->marge_gauche, $posy);
750 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
751 $pdf->MultiCell(80, 4, $titre, 0,
'L');
752 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
753 $pdf->SetXY($posxval, $posy);
755 $pdf->MultiCell(80, 4,
'', 0,
'L');
757 $posy = $pdf->GetY() + 1;
778 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
779 $pdf->SetXY($this->marge_gauche, $posy);
780 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
781 $pdf->MultiCell(80, 4, $titre, 0,
'L');
783 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
784 $pdf->SetXY($posxval, $posy);
785 $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);
786 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
787 $pdf->MultiCell(80, 4, $lib_condition_paiement, 0,
'L');
789 $posy = $pdf->GetY() + 3;
794 if (
$object->mode_reglement_code
795 &&
$object->mode_reglement_code !=
'CHQ'
796 &&
$object->mode_reglement_code !=
'VIR') {
797 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
798 $pdf->SetXY($this->marge_gauche, $posy - 2);
799 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
800 $pdf->MultiCell(80, 5, $titre, 0,
'L');
801 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
802 $pdf->SetXY($posxval, $posy - 2);
803 $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);
804 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
806 $posy = $pdf->GetY() + 2;
810 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
814 $account =
new Account($this->db);
817 $pdf->SetXY($this->marge_gauche, $posy);
818 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
819 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
820 $posy = $pdf->GetY() + 1;
823 $pdf->SetXY($this->marge_gauche, $posy);
824 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
825 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
826 $posy = $pdf->GetY() + 2;
830 $pdf->SetXY($this->marge_gauche, $posy);
831 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
832 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
833 $posy = $pdf->GetY() + 1;
836 $pdf->SetXY($this->marge_gauche, $posy);
837 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
838 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
839 $posy = $pdf->GetY() + 2;
846 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
848 $bankid = (empty(
$object->fk_bank) ? $conf->global->FACTURE_RIB_NUMBER :
$object->fk_bank);
849 $account =
new Account($this->db);
850 $account->fetch($bankid);
852 $curx = $this->marge_gauche;
855 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
880 global $conf, $mysoc;
885 $pdf->SetFont(
'',
'', $default_font_size - 1);
890 if ($this->page_largeur < 210) {
893 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
899 $pdf->SetFillColor(255, 255, 255);
900 $pdf->SetXY($col1x, $tab2_top);
901 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
903 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
904 $pdf->SetXY($col2x, $tab2_top);
905 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R', 1);
908 $pdf->SetFillColor(248, 248, 248);
910 $this->atleastoneratenotnull = 0;
912 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
919 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
920 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
924 foreach ($localtax_rate as $tvakey => $tvaval) {
929 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
932 if (preg_match(
'/\*/', $tvakey)) {
933 $tvakey = str_replace(
'*',
'', $tvakey);
934 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
936 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
937 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
938 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
940 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
941 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
949 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
950 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
954 foreach ($localtax_rate as $tvakey => $tvaval) {
961 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
964 if (preg_match(
'/\*/', $tvakey)) {
965 $tvakey = str_replace(
'*',
'', $tvakey);
966 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
968 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
969 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
970 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
972 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
973 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
979 foreach ($this->tva as $tvakey => $tvaval) {
981 $this->atleastoneratenotnull++;
984 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
987 if (preg_match(
'/\*/', $tvakey)) {
988 $tvakey = str_replace(
'*',
'', $tvakey);
989 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
991 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
992 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
993 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
995 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
996 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'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).
' ';
1022 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1023 $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) {
1044 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1047 if (preg_match(
'/\*/', $tvakey)) {
1048 $tvakey = str_replace(
'*',
'', $tvakey);
1049 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1051 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1053 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1054 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1056 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1057 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1065 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1066 $pdf->SetTextColor(0, 0, 60);
1067 $pdf->SetFillColor(224, 224, 224);
1068 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1070 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1071 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1075 $pdf->SetTextColor(0, 0, 0);
1077 $resteapayer =
$object->total_ttc - $deja_regle;
1082 if ($deja_regle > 0) {
1085 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1086 $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, $outputlangs), 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, 0, $outputlangs), $useborder,
'R', 1);
1100 $pdf->SetFont(
'',
'', $default_font_size - 1);
1101 $pdf->SetTextColor(0, 0, 0);
1105 return ($tab2_top + ($tab2_hl * $index));
1122 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1132 $currency = !empty($currency) ? $currency : $conf->currency;
1136 $pdf->SetTextColor(0, 0, 0);
1137 $pdf->SetFont(
'',
'', $default_font_size - 2);
1139 if (empty($hidetop)) {
1140 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1141 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1142 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1146 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5,
'F',
null, explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
1150 $pdf->SetDrawColor(128, 128, 128);
1151 $pdf->SetFont(
'',
'', $default_font_size - 1);
1154 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1156 if (empty($hidetop)) {
1157 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1159 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1160 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1163 $pdf->line($this->posxup + 1, $tab_top, $this->posxup + 1, $tab_top + $tab_height);
1164 if (empty($hidetop)) {
1165 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1166 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1169 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1170 if (empty($hidetop)) {
1171 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1172 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1176 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1177 if (empty($hidetop)) {
1178 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1179 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1183 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1184 if (empty($hidetop)) {
1185 if ($this->atleastonediscount) {
1186 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1187 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1190 if ($this->atleastonediscount) {
1191 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1193 if (empty($hidetop)) {
1194 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1195 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1211 global $conf, $langs;
1214 $outputlangs->loadLangs(array(
"main",
"bills",
"supplier_proposal",
"companies"));
1220 $pdf->SetTextColor(0, 0, 60);
1221 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1223 $posy = $this->marge_haute;
1224 $posx = $this->page_largeur - $this->marge_droite - 100;
1226 $pdf->SetXY($this->marge_gauche, $posy);
1230 if ($this->emetteur->logo) {
1231 $logodir = $conf->mycompany->dir_output;
1232 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
1233 $logodir = $conf->mycompany->multidir_output[
$object->entity];
1236 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1238 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1240 if (is_readable($logo)) {
1242 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1244 $pdf->SetTextColor(200, 0, 0);
1245 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1246 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1247 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1250 $text = $this->emetteur->name;
1251 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0);
1255 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1256 $pdf->SetXY($posx, $posy);
1257 $pdf->SetTextColor(0, 0, 60);
1258 $title = $outputlangs->transnoentities(
"CommercialAsk");
1259 $pdf->MultiCell(100, 4, $title,
'',
'R');
1261 $pdf->SetFont(
'',
'B', $default_font_size);
1264 $pdf->SetXY($posx, $posy);
1265 $pdf->SetTextColor(0, 0, 60);
1266 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset(
$object->ref),
'',
'R');
1269 $pdf->SetFont(
'',
'', $default_font_size - 2);
1273 $pdf->SetXY($posx, $posy);
1274 $pdf->SetTextColor(0, 0, 60);
1275 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".
dol_trunc($outputlangs->convToOutputCharset(
$object->ref_fourn), 65),
'',
'R');
1278 if (
$object->thirdparty->code_fournisseur) {
1280 $pdf->SetXY($posx, $posy);
1281 $pdf->SetTextColor(0, 0, 60);
1282 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_fournisseur),
'',
'R');
1287 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1288 if (count($arrayidcontact) > 0) {
1289 $usertmp =
new User($this->db);
1290 $usertmp->fetch($arrayidcontact[0]);
1292 $pdf->SetXY($posx, $posy);
1293 $pdf->SetTextColor(0, 0, 60);
1294 $pdf->MultiCell(100, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1302 $current_y = $pdf->getY();
1304 if ($current_y < $pdf->getY()) {
1305 $top_shift = $pdf->getY() - $current_y;
1310 $carac_emetteur =
'';
1312 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1313 if (count($arrayidcontact) > 0) {
1314 $object->fetch_user($arrayidcontact[0]);
1315 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1316 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1318 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1322 $carac_emetteur .=
"\n";
1328 $posy = 42 + $top_shift;
1329 $posx = $this->marge_gauche;
1331 $posx = $this->page_largeur - $this->marge_droite - 80;
1336 $pdf->SetTextColor(0, 0, 0);
1337 $pdf->SetFont(
'',
'', $default_font_size - 2);
1338 $pdf->SetXY($posx, $posy - 5);
1339 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0,
'L');
1340 $pdf->SetXY($posx, $posy);
1341 $pdf->SetFillColor(230, 230, 230);
1342 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1343 $pdf->SetTextColor(0, 0, 60);
1346 $pdf->SetXY($posx + 2, $posy + 3);
1347 $pdf->SetFont(
'',
'B', $default_font_size);
1348 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1349 $posy = $pdf->getY();
1352 $pdf->SetXY($posx + 2, $posy);
1353 $pdf->SetFont(
'',
'', $default_font_size - 1);
1354 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
1358 $usecontact =
false;
1360 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1362 $arrayidcontact = array_merge(
$object->getIdContact(
'external',
'CUSTOMER'),
$object->getIdContact(
'external',
'BILLING'));
1364 if (count($arrayidcontact) > 0) {
1366 $result =
$object->fetch_contact($arrayidcontact[0]);
1370 if (!empty($usecontact)) {
1371 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1374 $socname =
$object->thirdparty;
1377 $socname =
$object->thirdparty;
1386 if ($this->page_largeur < 210) {
1389 $posy = 42 + $top_shift;
1390 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1392 $posx = $this->marge_gauche;
1396 $pdf->SetTextColor(0, 0, 0);
1397 $pdf->SetFont(
'',
'', $default_font_size - 2);
1398 $pdf->SetXY($posx + 2, $posy - 5);
1399 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0,
'L');
1400 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1403 $pdf->SetXY($posx + 2, $posy + 3);
1404 $pdf->SetFont(
'',
'B', $default_font_size);
1405 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0,
'L');
1408 $pdf->SetFont(
'',
'', $default_font_size - 1);
1409 $pdf->SetXY($posx + 2, $posy + 4 + (
dol_nboflines_bis($carac_client_name, 50) * 4));
1410 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1413 $pdf->SetTextColor(0, 0, 0);