165 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
168 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
170 if (!is_object($outputlangs)) {
171 $outputlangs = $langs;
175 $outputlangs->charset_output =
'ISO-8859-1';
179 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"supplier_proposal"));
182 if ($object->statut == $object::STATUS_DRAFT && (
getDolGlobalString(
'SUPPLIER_PROPOSAL_DRAFT_WATERMARK'))) {
183 $this->watermark = $conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK;
186 $nblines = count($object->lines);
189 $realpatharray = array();
191 for ($i = 0; $i < $nblines; $i++) {
192 if (empty($object->lines[$i]->fk_product)) {
196 $objphoto =
new Product($this->db);
197 $objphoto->fetch($object->lines[$i]->fk_product);
200 $pdir =
get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
201 $dir = $conf->product->dir_output.
'/'.$pdir;
203 $pdir =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
204 $dir = $conf->product->dir_output.
'/'.$pdir;
208 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
210 if ($obj[
'photo_vignette']) {
211 $filename = $obj[
'photo_vignette'];
213 $filename = $obj[
'photo'];
216 $filename = $obj[
'photo'];
218 $realpath = $dir.$filename;
223 $realpatharray[$i] = $realpath;
227 if (count($realpatharray) == 0) {
228 $this->posxpicture = $this->posxup;
231 if ($conf->supplier_proposal->dir_output) {
232 $object->fetch_thirdparty();
237 if ($object->specimen) {
238 $dir = $conf->supplier_proposal->dir_output;
239 $file = $dir.
"/SPECIMEN.pdf";
242 $dir = $conf->supplier_proposal->dir_output.
"/".$objectref;
243 $file = $dir.
"/".$objectref.
".pdf";
246 if (!file_exists($dir)) {
248 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
253 if (file_exists($dir)) {
255 if (!is_object($hookmanager)) {
256 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
259 $hookmanager->initHooks(array(
'pdfgeneration'));
260 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
262 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
267 $heightforinfotot = 50;
268 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
269 $heightforfooter = $this->marge_basse + 8;
271 $heightforfooter += 6;
273 $pdf->SetAutoPageBreak(1, 0);
275 if (class_exists(
'TCPDF')) {
276 $pdf->setPrintHeader(
false);
277 $pdf->setPrintFooter(
false);
282 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
283 $tplidx = $pdf->importPage(1);
288 $pdf->SetDrawColor(128, 128, 128);
290 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
291 $pdf->SetSubject($outputlangs->transnoentities(
"CommercialAsk"));
292 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
293 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
294 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"CommercialAsk").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
296 $pdf->SetCompression(
false);
299 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
302 for ($i = 0; $i < $nblines; $i++) {
303 if ($object->lines[$i]->remise_percent) {
304 $this->atleastonediscount++;
307 if (empty($this->atleastonediscount)) {
308 $delta = ($this->postotalht - $this->posxdiscount);
309 $this->posxpicture += $delta;
310 $this->posxup += $delta;
311 $this->posxqty += $delta;
312 $this->posxunit += $delta;
313 $this->posxdiscount += $delta;
319 if (!empty($tplidx)) {
320 $pdf->useTemplate($tplidx);
323 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
324 $pdf->SetFont(
'',
'', $default_font_size - 1);
325 $pdf->MultiCell(0, 3,
'');
326 $pdf->SetTextColor(0, 0, 0);
328 $tab_top = 90 + $top_shift;
329 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
332 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
335 if (is_object($object->thirdparty)) {
336 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
337 $salerepobj =
new User($this->db);
338 $salerepobj->fetch($salereparray[0][
'id']);
339 if (!empty($salerepobj->signature)) {
340 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
346 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
347 if (!empty($extranote)) {
359 $pdf->SetFont(
'',
'', $default_font_size - 1);
360 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
361 $nexY = $pdf->GetY();
362 $height_note = $nexY - $tab_top;
365 $pdf->SetDrawColor(192, 192, 192);
366 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
368 $tab_top = $nexY + 6;
371 $iniY = $tab_top + 7;
372 $curY = $tab_top + 7;
373 $nexY = $tab_top + 7;
376 for ($i = 0; $i < $nblines; $i++) {
378 $pdf->SetFont(
'',
'', $default_font_size - 1);
379 $pdf->SetTextColor(0, 0, 0);
382 $imglinesize = array();
383 if (!empty($realpatharray[$i])) {
387 $pdf->setTopMargin($tab_top_newpage);
388 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
389 $pageposbefore = $pdf->getPage();
391 $showpricebeforepagebreak = 1;
393 $posYAfterDescription = 0;
396 if (!empty($imglinesize[
'width']) && !empty($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
397 $pdf->AddPage(
'',
'',
true);
398 if (!empty($tplidx)) {
399 $pdf->useTemplate($tplidx);
402 $this->
_pagehead($pdf, $object, 0, $outputlangs);
404 $pdf->setPage($pageposbefore + 1);
406 $curY = $tab_top_newpage;
410 $showpricebeforepagebreak = 1;
412 $showpricebeforepagebreak = 0;
416 if (!empty($imglinesize[
'width']) && !empty($imglinesize[
'height'])) {
417 $curX = $this->posxpicture - 1;
418 $pdf->Image($realpatharray[$i], $curX + (($this->posxup - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
420 $posYAfterImage = $curY + $imglinesize[
'height'];
424 $curX = $this->posxdesc - 1;
426 $pdf->startTransaction();
427 if ($posYAfterImage > 0) {
428 $descWidth = $this->posxpicture - $curX;
430 $descWidth = $this->posxup - $curX;
432 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
434 $pageposafter = $pdf->getPage();
435 if ($pageposafter > $pageposbefore) {
436 $pdf->rollbackTransaction(
true);
437 $pageposafter = $pageposbefore;
439 $pdf->setPageOrientation(
'', 1, $heightforfooter);
440 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
442 $pageposafter = $pdf->getPage();
443 $posyafter = $pdf->GetY();
445 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
446 if ($i == ($nblines - 1)) {
447 $pdf->AddPage(
'',
'',
true);
448 if (!empty($tplidx)) {
449 $pdf->useTemplate($tplidx);
452 $this->
_pagehead($pdf, $object, 0, $outputlangs);
454 $pdf->setPage($pageposafter + 1);
460 $showpricebeforepagebreak = 1;
462 $showpricebeforepagebreak = 0;
466 $pdf->commitTransaction();
468 $posYAfterDescription = $pdf->GetY();
470 $nexY = $pdf->GetY();
471 $pageposafter = $pdf->getPage();
473 $pdf->setPage($pageposbefore);
474 $pdf->setTopMargin($this->marge_haute);
475 $pdf->setPageOrientation(
'', 1, 0);
478 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
479 $pdf->setPage($pageposafter);
480 $curY = $tab_top_newpage;
483 $pdf->SetFont(
'',
'', $default_font_size - 1);
487 $pdf->SetXY($this->posxqty, $curY);
488 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
492 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
493 $pdf->SetXY($this->posxunit, $curY);
494 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
514 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
515 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
517 $tvaligne = $object->lines[$i]->total_tva;
520 $localtax1ligne = $object->lines[$i]->total_localtax1;
521 $localtax2ligne = $object->lines[$i]->total_localtax2;
522 $localtax1_rate = $object->lines[$i]->localtax1_tx;
523 $localtax2_rate = $object->lines[$i]->localtax2_tx;
524 $localtax1_type = $object->lines[$i]->localtax1_type;
525 $localtax2_type = $object->lines[$i]->localtax2_type;
538 $vatrate = (string) $object->lines[$i]->tva_tx;
541 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
542 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
544 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
545 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
549 if ($localtax1_type && $localtax1ligne != 0) {
550 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
551 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
553 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
556 if ($localtax2_type && $localtax2ligne != 0) {
557 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
558 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
560 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
564 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
569 if (!isset($this->tva[$vatrate])) {
570 $this->tva[$vatrate] = 0;
572 $this->tva[$vatrate] += $tvaligne;
573 $vatcode = $object->lines[$i]->vat_src_code;
574 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
575 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
577 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
579 if ($posYAfterImage > $posYAfterDescription) {
580 $nexY = $posYAfterImage;
585 $pdf->setPage($pageposafter);
586 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
588 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
589 $pdf->SetLineStyle(array(
'dash'=>0));
595 while ($pagenb < $pageposafter) {
596 $pdf->setPage($pagenb);
598 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
600 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
602 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
604 $pdf->setPage($pagenb);
605 $pdf->setPageOrientation(
'', 1, 0);
607 $this->
_pagehead($pdf, $object, 0, $outputlangs);
609 if (!empty($tplidx)) {
610 $pdf->useTemplate($tplidx);
613 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
615 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
617 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
619 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
622 if (!empty($tplidx)) {
623 $pdf->useTemplate($tplidx);
627 $this->
_pagehead($pdf, $object, 0, $outputlangs);
634 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
635 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
637 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
638 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
642 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
656 $this->
_pagefoot($pdf, $object, $outputlangs);
657 if (method_exists($pdf,
'AliasNbPages')) {
658 $pdf->AliasNbPages();
663 $pdf->Output($file,
'F');
666 $hookmanager->initHooks(array(
'pdfgeneration'));
667 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
669 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
671 $this->error = $hookmanager->error;
672 $this->errors = $hookmanager->errors;
677 $this->result = array(
'fullpath'=>$file);
681 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
685 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_PROPOSAL_OUTPUTDIR");
724 $diffsizetitle = (!
getDolGlobalString(
'PDF_DIFFSIZE_TITLE') ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
726 $pdf->SetFont(
'',
'', $default_font_size - 1);
731 if (!empty($object->delivery_date)) {
732 $outputlangs->load(
"sendings");
733 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
734 $pdf->SetXY($this->marge_gauche, $posy);
735 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
736 $pdf->MultiCell(80, 4, $titre, 0,
'L');
737 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
738 $pdf->SetXY($posxval, $posy);
739 $dlp =
dol_print_date($object->delivery_date,
"daytext",
false, $outputlangs,
true);
740 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
742 $posy = $pdf->GetY() + 1;
744 $outputlangs->load(
"sendings");
745 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
746 $pdf->SetXY($this->marge_gauche, $posy);
747 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
748 $pdf->MultiCell(80, 4, $titre, 0,
'L');
749 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
750 $pdf->SetXY($posxval, $posy);
752 $pdf->MultiCell(80, 4,
'', 0,
'L');
754 $posy = $pdf->GetY() + 1;
774 if (!
getDolGlobalString(
'SUPPLIER_PROPOSAL_PDF_HIDE_PAYMENTTERMCOND') && ($object->cond_reglement_code || $object->cond_reglement)) {
775 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
776 $pdf->SetXY($this->marge_gauche, $posy);
777 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
778 $pdf->MultiCell(80, 4, $titre, 0,
'L');
780 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
781 $pdf->SetXY($posxval, $posy);
782 $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);
783 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
784 $pdf->MultiCell(80, 4, $lib_condition_paiement, 0,
'L');
786 $posy = $pdf->GetY() + 3;
791 if ($object->mode_reglement_code
792 && $object->mode_reglement_code !=
'CHQ'
793 && $object->mode_reglement_code !=
'VIR') {
794 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
795 $pdf->SetXY($this->marge_gauche, $posy - 2);
796 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
797 $pdf->MultiCell(80, 5, $titre, 0,
'L');
798 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
799 $pdf->SetXY($posxval, $posy - 2);
800 $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);
801 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
803 $posy = $pdf->GetY() + 2;
807 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
811 $account =
new Account($this->db);
814 $pdf->SetXY($this->marge_gauche, $posy);
815 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
816 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
817 $posy = $pdf->GetY() + 1;
820 $pdf->SetXY($this->marge_gauche, $posy);
821 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
822 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
823 $posy = $pdf->GetY() + 2;
827 $pdf->SetXY($this->marge_gauche, $posy);
828 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
829 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
830 $posy = $pdf->GetY() + 1;
833 $pdf->SetXY($this->marge_gauche, $posy);
834 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
835 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
836 $posy = $pdf->GetY() + 2;
843 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
844 if (!empty($object->fk_bank) ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
845 $bankid = (empty($object->fk_bank) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_bank);
846 $account =
new Account($this->db);
847 $account->fetch($bankid);
849 $curx = $this->marge_gauche;
852 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
874 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
877 global $conf, $mysoc;
882 $pdf->SetFont(
'',
'', $default_font_size - 1);
887 if ($this->page_largeur < 210) {
890 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
896 $pdf->SetFillColor(255, 255, 255);
897 $pdf->SetXY($col1x, $tab2_top);
898 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
900 $total_ht = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
901 $pdf->SetXY($col2x, $tab2_top);
902 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0,
'R', 1);
905 $pdf->SetFillColor(248, 248, 248);
907 $this->atleastoneratenotnull = 0;
909 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
916 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
917 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
921 foreach ($localtax_rate as $tvakey => $tvaval) {
926 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
929 if (preg_match(
'/\*/', $tvakey)) {
930 $tvakey = str_replace(
'*',
'', $tvakey);
931 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
933 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
934 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
935 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
937 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
938 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
946 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
947 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
951 foreach ($localtax_rate as $tvakey => $tvaval) {
958 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
961 if (preg_match(
'/\*/', $tvakey)) {
962 $tvakey = str_replace(
'*',
'', $tvakey);
963 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
965 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
966 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
967 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
969 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
970 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
976 foreach ($this->tva as $tvakey => $tvaval) {
978 $this->atleastoneratenotnull++;
981 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
984 if (preg_match(
'/\*/', $tvakey)) {
985 $tvakey = str_replace(
'*',
'', $tvakey);
986 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
988 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
989 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
990 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
992 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
993 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1000 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1001 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1005 foreach ($localtax_rate as $tvakey => $tvaval) {
1010 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1013 if (preg_match(
'/\*/', $tvakey)) {
1014 $tvakey = str_replace(
'*',
'', $tvakey);
1015 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1017 $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);
1021 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1022 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1030 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1031 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1035 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).
' ';
1050 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1051 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1053 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1054 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1062 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1063 $pdf->SetTextColor(0, 0, 60);
1064 $pdf->SetFillColor(224, 224, 224);
1065 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1067 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1068 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1072 $pdf->SetTextColor(0, 0, 0);
1074 $resteapayer = $object->total_ttc - $deja_regle;
1075 if (!empty($object->paye)) {
1079 if ($deja_regle > 0) {
1082 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1083 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1085 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1086 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1089 $pdf->SetTextColor(0, 0, 60);
1090 $pdf->SetFillColor(224, 224, 224);
1091 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1092 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1094 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1095 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1097 $pdf->SetFont(
'',
'', $default_font_size - 1);
1098 $pdf->SetTextColor(0, 0, 0);
1102 return ($tab2_top + ($tab2_hl * $index));
1119 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1129 $currency = !empty($currency) ? $currency : $conf->currency;
1133 $pdf->SetTextColor(0, 0, 0);
1134 $pdf->SetFont(
'',
'', $default_font_size - 2);
1136 if (empty($hidetop)) {
1137 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1138 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1139 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1143 $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')));
1147 $pdf->SetDrawColor(128, 128, 128);
1148 $pdf->SetFont(
'',
'', $default_font_size - 1);
1151 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1153 if (empty($hidetop)) {
1154 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1156 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1157 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1160 $pdf->line($this->posxup + 1, $tab_top, $this->posxup + 1, $tab_top + $tab_height);
1161 if (empty($hidetop)) {
1162 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1163 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1166 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1167 if (empty($hidetop)) {
1168 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1169 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1173 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1174 if (empty($hidetop)) {
1175 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1176 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1180 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1181 if (empty($hidetop)) {
1182 if ($this->atleastonediscount) {
1183 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1184 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1187 if ($this->atleastonediscount) {
1188 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1190 if (empty($hidetop)) {
1191 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1192 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1206 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1208 global $conf, $langs;
1211 $outputlangs->loadLangs(array(
"main",
"bills",
"supplier_proposal",
"companies"));
1217 $pdf->SetTextColor(0, 0, 60);
1218 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1220 $posy = $this->marge_haute;
1221 $posx = $this->page_largeur - $this->marge_droite - 100;
1223 $pdf->SetXY($this->marge_gauche, $posy);
1227 if ($this->emetteur->logo) {
1228 $logodir = $conf->mycompany->dir_output;
1229 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1230 $logodir = $conf->mycompany->multidir_output[$object->entity];
1233 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1235 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1237 if (is_readable($logo)) {
1239 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1241 $pdf->SetTextColor(200, 0, 0);
1242 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1243 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1244 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1247 $text = $this->emetteur->name;
1248 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0);
1252 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1253 $pdf->SetXY($posx, $posy);
1254 $pdf->SetTextColor(0, 0, 60);
1255 $title = $outputlangs->transnoentities(
"CommercialAsk");
1256 $pdf->MultiCell(100, 4, $title,
'',
'R');
1258 $pdf->SetFont(
'',
'B', $default_font_size);
1261 $pdf->SetXY($posx, $posy);
1262 $pdf->SetTextColor(0, 0, 60);
1263 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset($object->ref),
'',
'R');
1266 $pdf->SetFont(
'',
'', $default_font_size - 2);
1268 if ($object->ref_fourn) {
1270 $pdf->SetXY($posx, $posy);
1271 $pdf->SetTextColor(0, 0, 60);
1272 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".
dol_trunc($outputlangs->convToOutputCharset($object->ref_fourn), 65),
'',
'R');
1275 if ($object->thirdparty->code_fournisseur) {
1277 $pdf->SetXY($posx, $posy);
1278 $pdf->SetTextColor(0, 0, 60);
1279 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur),
'',
'R');
1284 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1285 if (count($arrayidcontact) > 0) {
1286 $usertmp =
new User($this->db);
1287 $usertmp->fetch($arrayidcontact[0]);
1289 $pdf->SetXY($posx, $posy);
1290 $pdf->SetTextColor(0, 0, 60);
1291 $pdf->MultiCell(100, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1299 $current_y = $pdf->getY();
1300 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3,
'R', $default_font_size);
1301 if ($current_y < $pdf->getY()) {
1302 $top_shift = $pdf->getY() - $current_y;
1307 $carac_emetteur =
'';
1309 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1310 if (count($arrayidcontact) > 0) {
1311 $object->fetch_user($arrayidcontact[0]);
1312 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1313 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1315 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone :
'';
1317 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email :
'';
1319 $carac_emetteur .=
"\n";
1322 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1325 $posy = 42 + $top_shift;
1326 $posx = $this->marge_gauche;
1328 $posx = $this->page_largeur - $this->marge_droite - 80;
1333 $pdf->SetTextColor(0, 0, 0);
1334 $pdf->SetFont(
'',
'', $default_font_size - 2);
1335 $pdf->SetXY($posx, $posy - 5);
1336 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0,
'L');
1337 $pdf->SetXY($posx, $posy);
1338 $pdf->SetFillColor(230, 230, 230);
1339 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1340 $pdf->SetTextColor(0, 0, 60);
1343 $pdf->SetXY($posx + 2, $posy + 3);
1344 $pdf->SetFont(
'',
'B', $default_font_size);
1345 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1346 $posy = $pdf->getY();
1349 $pdf->SetXY($posx + 2, $posy);
1350 $pdf->SetFont(
'',
'', $default_font_size - 1);
1351 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
1355 $usecontact =
false;
1357 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1359 $arrayidcontact = array_merge($object->getIdContact(
'external',
'CUSTOMER'), $object->getIdContact(
'external',
'BILLING'));
1361 if (count($arrayidcontact) > 0) {
1363 $result = $object->fetch_contact($arrayidcontact[0]);
1367 if (!empty($usecontact)) {
1368 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1369 $socname = $object->contact;
1371 $socname = $object->thirdparty;
1374 $socname = $object->thirdparty;
1379 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact,
'target', $object);
1383 if ($this->page_largeur < 210) {
1386 $posy = 42 + $top_shift;
1387 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1389 $posx = $this->marge_gauche;
1393 $pdf->SetTextColor(0, 0, 0);
1394 $pdf->SetFont(
'',
'', $default_font_size - 2);
1395 $pdf->SetXY($posx + 2, $posy - 5);
1396 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0,
'L');
1397 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1400 $pdf->SetXY($posx + 2, $posy + 3);
1401 $pdf->SetFont(
'',
'B', $default_font_size);
1402 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0,
'L');
1405 $pdf->SetFont(
'',
'', $default_font_size - 1);
1406 $pdf->SetXY($posx + 2, $posy + 4 + (
dol_nboflines_bis($carac_client_name, 50) * 4));
1407 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1410 $pdf->SetTextColor(0, 0, 0);