218 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
221 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
223 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
225 if (!is_object($outputlangs)) {
226 $outputlangs = $langs;
229 if (!empty($conf->global->MAIN_USE_FPDF)) {
230 $outputlangs->charset_output =
'ISO-8859-1';
234 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"propal",
"products"));
236 global $outputlangsbis;
237 $outputlangsbis =
null;
238 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
239 $outputlangsbis =
new Translate(
'', $conf);
240 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
241 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
245 if ($object->statut == $object::STATUS_DRAFT &&
getDolGlobalString(
'PROPALE_DRAFT_WATERMARK')) {
249 $nblines = count($object->lines);
252 $realpatharray = array();
253 $this->atleastonephoto =
false;
254 if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE)) {
255 $objphoto =
new Product($this->db);
257 for ($i = 0; $i < $nblines; $i++) {
258 if (empty($object->lines[$i]->fk_product)) {
262 $objphoto->fetch($object->lines[$i]->fk_product);
265 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
266 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
268 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
269 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
274 foreach ($pdir as $midir) {
276 if ($conf->entity != $objphoto->entity) {
277 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
279 $dir = $conf->product->dir_output.
'/'.$midir;
281 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
283 if ($obj[
'photo_vignette']) {
284 $filename = $obj[
'photo_vignette'];
286 $filename = $obj[
'photo'];
289 $filename = $obj[
'photo'];
292 $realpath = $dir.$filename;
294 $this->atleastonephoto =
true;
299 if ($realpath && $arephoto) {
300 $realpatharray[$i] = $realpath;
305 if (count($realpatharray) == 0) {
306 $this->posxpicture = $this->posxtva;
309 if ($conf->propal->multidir_output[$conf->entity]) {
310 $object->fetch_thirdparty();
315 if ($object->specimen) {
316 $dir = $conf->propal->multidir_output[$conf->entity];
317 $file = $dir.
"/SPECIMEN.pdf";
320 $dir = $conf->propal->multidir_output[$object->entity].
"/".$objectref;
321 $file = $dir.
"/".$objectref.
".pdf";
324 if (!file_exists($dir)) {
326 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
331 if (file_exists($dir)) {
333 if (!is_object($hookmanager)) {
334 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
337 $hookmanager->initHooks(array(
'pdfgeneration'));
338 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
340 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
343 $nblines = count($object->lines);
349 $pdf->SetAutoPageBreak(1, 0);
351 if (class_exists(
'TCPDF')) {
352 $pdf->setPrintHeader(
false);
353 $pdf->setPrintFooter(
false);
357 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
358 $logodir = $conf->mycompany->dir_output;
359 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
360 $logodir = $conf->mycompany->multidir_output[$object->entity];
362 $pagecount = $pdf->setSourceFile($logodir.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
363 $tplidx = $pdf->importPage(1);
368 $pdf->SetDrawColor(128, 128, 128);
370 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
371 $pdf->SetSubject($outputlangs->transnoentities(
"PdfCommercialProposalTitle"));
372 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
373 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
374 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
376 $pdf->SetCompression(
false);
379 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
382 for ($i = 0; $i < $nblines; $i++) {
383 if ($object->lines[$i]->remise_percent) {
384 $this->atleastonediscount++;
387 if (empty($this->atleastonediscount)) {
388 $delta = ($this->postotalht - $this->posxdiscount);
389 $this->posxpicture += $delta;
390 $this->posxtva += $delta;
391 $this->posxup += $delta;
392 $this->posxqty += $delta;
393 $this->posxunit += $delta;
394 $this->posxdiscount += $delta;
400 if (!empty($tplidx)) {
401 $pdf->useTemplate($tplidx);
405 $heightforinfotot = 40;
406 $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (
pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities(
"ProposalCustomerSignature")) + 10) : 0;
407 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
408 $heightforfooter = $this->marge_basse + 8;
409 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
410 $heightforfooter += 6;
414 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
415 $pdf->SetFont(
'',
'', $default_font_size - 1);
416 $pdf->MultiCell(0, 3,
'');
417 $pdf->SetTextColor(0, 0, 0);
420 $tab_top = 90 + $top_shift;
421 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
424 $height_incoterms = 0;
425 if (isModEnabled(
'incoterm')) {
426 $desc_incoterms = $object->getIncotermsForPDF();
427 if ($desc_incoterms) {
430 $pdf->SetFont(
'',
'', $default_font_size - 1);
431 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
432 $nexY = $pdf->GetY();
433 $height_incoterms = $nexY - $tab_top;
436 $pdf->SetDrawColor(192, 192, 192);
437 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
439 $tab_top = $nexY + 6;
440 $height_incoterms += 4;
445 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
446 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
448 if (is_object($object->thirdparty)) {
449 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
450 $salerepobj =
new User($this->db);
451 $salerepobj->fetch($salereparray[0][
'id']);
452 if (!empty($salerepobj->signature)) {
453 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
458 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
459 if (!empty($extranote)) {
462 if (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0) {
463 $tmpuser =
new User($this->db);
464 $tmpuser->fetch($object->user_author_id);
467 $creator_info = $langs->trans(
"CaseFollowedBy").
' '.$tmpuser->getFullName($langs);
468 if ($tmpuser->email) $creator_info .=
', '.$langs->trans(
"EMail").
': '.$tmpuser->email;
469 if ($tmpuser->office_phone) $creator_info .=
', '.$langs->trans(
"Phone").
': '.$tmpuser->office_phone;
482 $pdf->SetFont(
'',
'', $default_font_size - 1);
483 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
484 $nexY = $pdf->GetY();
485 $height_note = $nexY - $tab_top;
488 $pdf->SetDrawColor(192, 192, 192);
489 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
491 $tab_top = $nexY + 6;
494 $iniY = $tab_top + 7;
495 $curY = $tab_top + 7;
496 $nexY = $tab_top + 7;
499 for ($i = 0; $i < $nblines; $i++) {
501 $pdf->SetFont(
'',
'', $default_font_size - 1);
502 $pdf->SetTextColor(0, 0, 0);
505 $imglinesize = array();
506 if (!empty($realpatharray[$i])) {
510 $pdf->setTopMargin($tab_top_newpage);
511 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot);
512 $pageposbefore = $pdf->getPage();
514 $showpricebeforepagebreak = 1;
516 $posYAfterDescription = 0;
519 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
520 $pdf->AddPage(
'',
'',
true);
521 if (!empty($tplidx)) {
522 $pdf->useTemplate($tplidx);
525 $this->
_pagehead($pdf, $object, 0, $outputlangs);
527 $pdf->setPage($pageposbefore + 1);
529 $curY = $tab_top_newpage;
532 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
533 $showpricebeforepagebreak = 1;
535 $showpricebeforepagebreak = 0;
539 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
540 $curX = $this->posxpicture - 1;
541 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
543 $posYAfterImage = $curY + $imglinesize[
'height'];
547 $curX = $this->posxdesc - 1;
549 $pdf->startTransaction();
550 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
551 $pageposafter = $pdf->getPage();
552 if ($pageposafter > $pageposbefore) {
553 $pdf->rollbackTransaction(
true);
554 $pageposafter = $pageposbefore;
556 $pdf->setPageOrientation(
'', 1, $heightforfooter);
557 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
559 $pageposafter = $pdf->getPage();
560 $posyafter = $pdf->GetY();
562 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
563 if ($i == ($nblines - 1)) {
564 $pdf->AddPage(
'',
'',
true);
565 if (!empty($tplidx)) {
566 $pdf->useTemplate($tplidx);
569 $this->
_pagehead($pdf, $object, 0, $outputlangs);
571 $pdf->setPage($pageposafter + 1);
577 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
578 $showpricebeforepagebreak = 1;
580 $showpricebeforepagebreak = 0;
585 $pdf->commitTransaction();
587 $posYAfterDescription = $pdf->GetY();
589 $nexY = $pdf->GetY();
590 $pageposafter = $pdf->getPage();
592 $pdf->setPage($pageposbefore);
593 $pdf->setTopMargin($this->marge_haute);
594 $pdf->setPageOrientation(
'', 1, 0);
597 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
598 $pdf->setPage($pageposafter);
599 $curY = $tab_top_newpage;
602 $pdf->SetFont(
'',
'', $default_font_size - 1);
605 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
607 $pdf->SetXY($this->posxtva - 5, $curY);
608 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
613 $pdf->SetXY($this->posxup, $curY);
614 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
618 $pdf->SetXY($this->posxqty, $curY);
619 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
623 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
624 $pdf->SetXY($this->posxunit, $curY);
625 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
629 $pdf->SetXY($this->posxdiscount, $curY);
630 if ($object->lines[$i]->remise_percent) {
631 $pdf->SetXY($this->posxdiscount - 2, $curY);
633 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
638 $pdf->SetXY($this->postotalht, $curY);
639 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
642 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
643 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
645 $tvaligne = $object->lines[$i]->total_tva;
648 $localtax1ligne = $object->lines[$i]->total_localtax1;
649 $localtax2ligne = $object->lines[$i]->total_localtax2;
650 $localtax1_rate = $object->lines[$i]->localtax1_tx;
651 $localtax2_rate = $object->lines[$i]->localtax2_tx;
652 $localtax1_type = $object->lines[$i]->localtax1_type;
653 $localtax2_type = $object->lines[$i]->localtax2_type;
666 $vatrate = (string) $object->lines[$i]->tva_tx;
669 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
670 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
672 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
673 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
677 if ($localtax1_type && $localtax1ligne != 0) {
678 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
679 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
681 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
684 if ($localtax2_type && $localtax2ligne != 0) {
685 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
686 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
688 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
692 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
697 if (!isset($this->tva[$vatrate])) {
698 $this->tva[$vatrate] = 0;
700 $this->tva[$vatrate] += $tvaligne;
701 $vatcode = $object->lines[$i]->vat_src_code;
702 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
703 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
705 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
707 if ($posYAfterImage > $posYAfterDescription) {
708 $nexY = $posYAfterImage;
712 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
713 $pdf->setPage($pageposafter);
714 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
716 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
717 $pdf->SetLineStyle(array(
'dash'=>0));
723 while ($pagenb < $pageposafter) {
724 $pdf->setPage($pagenb);
726 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
728 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
730 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
732 $pdf->setPage($pagenb);
733 $pdf->setPageOrientation(
'', 1, 0);
735 $this->
_pagehead($pdf, $object, 0, $outputlangs);
737 if (!empty($tplidx)) {
738 $pdf->useTemplate($tplidx);
741 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
743 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
745 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
747 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
750 if (!empty($tplidx)) {
751 $pdf->useTemplate($tplidx);
755 $this->
_pagehead($pdf, $object, 0, $outputlangs);
762 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
763 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
765 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
766 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
770 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
773 $posy = $this->
_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
784 if (empty($conf->global->PROPAL_DISABLE_SIGNATURE)) {
789 $this->
_pagefoot($pdf, $object, $outputlangs);
790 if (method_exists($pdf,
'AliasNbPages')) {
791 $pdf->AliasNbPages();
795 if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) {
796 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
798 $already_merged = array();
799 foreach ($object->lines as $line) {
800 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
805 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
807 $filetomerge->fetch_by_product($line->fk_product);
810 $already_merged[] = $line->fk_product;
812 $product =
new Product($this->db);
813 $product->fetch($line->fk_product);
815 if ($product->entity != $conf->entity) {
816 $entity_product_file = $product->entity;
818 $entity_product_file = $conf->entity;
822 if (count($filetomerge->lines) > 0) {
823 foreach ($filetomerge->lines as $linefile) {
824 if (!empty($linefile->id) && !empty($linefile->file_name)) {
826 if (isModEnabled(
"product")) {
827 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
828 } elseif (isModEnabled(
"service")) {
829 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
832 if (isModEnabled(
"product")) {
833 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
834 } elseif (isModEnabled(
"service")) {
835 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
839 dol_syslog(get_class($this).
':: upload_dir='.$filetomerge_dir, LOG_DEBUG);
841 $infile = $filetomerge_dir.
'/'.$linefile->file_name;
842 if (file_exists($infile) && is_readable($infile)) {
843 $pagecount = $pdf->setSourceFile($infile);
844 for ($i = 1; $i <= $pagecount; $i++) {
845 $tplIdx = $pdf->importPage($i);
846 if ($tplIdx !==
false) {
847 $s = $pdf->getTemplatesize($tplIdx);
848 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
849 $pdf->useTemplate($tplIdx);
851 setEventMessages(
null, array($infile.
' cannot be added, probably protected PDF'),
'warnings');
864 $pdf->Output($file,
'F');
867 $hookmanager->initHooks(array(
'pdfgeneration'));
868 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
870 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
872 $this->error = $hookmanager->error;
873 $this->errors = $hookmanager->errors;
878 $this->result = array(
'fullpath'=>$file);
882 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
886 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PROP_OUTPUTDIR");
922 global $conf, $mysoc;
925 $pdf->SetFont(
'',
'', $default_font_size - 1);
927 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
930 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
931 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
932 $pdf->SetXY($this->marge_gauche, $posy);
933 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
935 $posy = $pdf->GetY() + 4;
939 if (!empty($conf->global->MAIN_PDF_DELIVERY_DATE_TEXT)) {
940 $displaydate =
"daytext";
942 $displaydate =
"day";
946 if (!empty($object->delivery_date)) {
947 $outputlangs->load(
"sendings");
948 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
949 $pdf->SetXY($this->marge_gauche, $posy);
950 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
951 $pdf->MultiCell(80, 4, $titre, 0,
'L');
952 $pdf->SetFont(
'',
'', $default_font_size -$diffsizetitle);
953 $pdf->SetXY($posxval, $posy);
954 $dlp =
dol_print_date($object->delivery_date, $displaydate,
false, $outputlangs,
true);
955 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
957 $posy = $pdf->GetY() + 1;
958 } elseif ($object->availability_code || $object->availability) {
959 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
960 $pdf->SetXY($this->marge_gauche, $posy);
961 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
962 $pdf->MultiCell(80, 4, $titre, 0,
'L');
963 $pdf->SetTextColor(0, 0, 0);
964 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
965 $pdf->SetXY($posxval, $posy);
966 $lib_availability = $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) != (
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability);
967 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
968 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
970 $posy = $pdf->GetY() + 1;
974 if (empty($conf->global->PROPOSAL_PDF_HIDE_DELIVERYMODE) && $object->shipping_method_id > 0) {
975 $outputlangs->load(
"sendings");
977 $shipping_method_id = $object->shipping_method_id;
978 if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && !empty($this->emetteur->shipping_method_id)) {
979 $shipping_method_id = $this->emetteur->shipping_method_id;
981 $shipping_method_code =
dol_getIdFromCode($this->db, $shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
982 $shipping_method_label =
dol_getIdFromCode($this->db, $shipping_method_id,
'c_shipment_mode',
'rowid',
'libelle');
984 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
985 $pdf->SetXY($this->marge_gauche, $posy);
986 $titre = $outputlangs->transnoentities(
"SendingMethod").
':';
987 $pdf->MultiCell(43, 4, $titre, 0,
'L');
989 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
990 $pdf->SetXY($posxval, $posy);
991 $lib_condition_paiement = ($outputlangs->transnoentities(
"SendingMethod".strtoupper($shipping_method_code)) !=
"SendingMethod".strtoupper($shipping_method_code)) ? $outputlangs->trans(
"SendingMethod".strtoupper($shipping_method_code)) : $shipping_method_label;
992 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
993 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
995 $posy = $pdf->GetY() + 1;
999 if (empty($conf->global->PROPOSAL_PDF_HIDE_PAYMENTTERM) && $object->cond_reglement_code) {
1000 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1001 $pdf->SetXY($this->marge_gauche, $posy);
1002 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1003 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1005 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1006 $pdf->SetXY($posxval, $posy);
1007 $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);
1008 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1009 if ($object->deposit_percent > 0) {
1010 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement);
1012 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1014 $posy = $pdf->GetY() + 3;
1017 if (empty($conf->global->PROPOSAL_PDF_HIDE_PAYMENTMODE)) {
1019 if ($object->mode_reglement_code
1020 && $object->mode_reglement_code !=
'CHQ'
1021 && $object->mode_reglement_code !=
'VIR') {
1022 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1023 $pdf->SetXY($this->marge_gauche, $posy);
1024 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1025 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1026 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1027 $pdf->SetXY($posxval, $posy);
1028 $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);
1029 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1031 $posy = $pdf->GetY() + 2;
1035 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
1038 if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
1039 $account =
new Account($this->db);
1042 $pdf->SetXY($this->marge_gauche, $posy);
1043 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1044 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
1045 $posy = $pdf->GetY() + 1;
1047 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
1048 $pdf->SetXY($this->marge_gauche, $posy);
1049 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1050 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1051 $posy = $pdf->GetY() + 2;
1054 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1055 $pdf->SetXY($this->marge_gauche, $posy);
1056 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1057 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1058 $posy = $pdf->GetY() + 1;
1060 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
1061 $pdf->SetXY($this->marge_gauche, $posy);
1062 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1063 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1064 $posy = $pdf->GetY() + 2;
1071 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
1072 if (!empty($object->fk_account) || !empty($object->fk_bank) ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
1073 $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1074 if (!empty($object->fk_bank)) {
1075 $bankid = $object->fk_bank;
1077 $account =
new Account($this->db);
1078 $account->fetch($bankid);
1080 $curx = $this->marge_gauche;
1083 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1106 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis =
null)
1109 global $conf, $mysoc;
1114 $pdf->SetFont(
'',
'', $default_font_size - 1);
1119 if ($this->page_largeur < 210) {
1122 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1128 $pdf->SetFillColor(255, 255, 255);
1129 $pdf->SetXY($col1x, $tab2_top);
1130 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1132 $total_ht = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1133 $pdf->SetXY($col2x, $tab2_top);
1134 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1137 $pdf->SetFillColor(248, 248, 248);
1139 $total_ttc = (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1141 $this->atleastoneratenotnull = 0;
1142 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
1143 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1144 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) {
1150 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1151 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1155 foreach ($localtax_rate as $tvakey => $tvaval) {
1160 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1163 if (preg_match(
'/\*/', $tvakey)) {
1164 $tvakey = str_replace(
'*',
'', $tvakey);
1165 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1167 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1168 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1169 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1171 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1173 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1174 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1182 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1183 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1187 foreach ($localtax_rate as $tvakey => $tvaval) {
1192 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1195 if (preg_match(
'/\*/', $tvakey)) {
1196 $tvakey = str_replace(
'*',
'', $tvakey);
1197 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1199 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1200 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1201 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1203 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1205 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1206 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1213 foreach ($this->tva_array as $tvakey => $tvaval) {
1215 $this->atleastoneratenotnull++;
1218 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1221 if (preg_match(
'/\*/', $tvakey)) {
1222 $tvakey = str_replace(
'*',
'', $tvakey);
1223 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1225 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1228 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1230 $totalvat .= ($tvaval[
'vatcode'] ? $tvaval[
'vatcode'] :
vatrate($tvaval[
'vatrate'], 1)).$tvacompl;
1232 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1234 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1236 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1237 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1244 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1245 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1249 foreach ($localtax_rate as $tvakey => $tvaval) {
1254 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1257 if (preg_match(
'/\*/', $tvakey)) {
1258 $tvakey = str_replace(
'*',
'', $tvakey);
1259 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1261 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1263 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1264 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1266 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1268 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1269 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1277 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1278 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1282 foreach ($localtax_rate as $tvakey => $tvaval) {
1288 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1291 if (preg_match(
'/\*/', $tvakey)) {
1292 $tvakey = str_replace(
'*',
'', $tvakey);
1293 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1295 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1297 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1298 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1300 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1302 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1303 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1311 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1312 $pdf->SetTextColor(0, 0, 60);
1313 $pdf->SetFillColor(224, 224, 224);
1314 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1316 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1317 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1321 $pdf->SetTextColor(0, 0, 0);
1328 if ($deja_regle > 0) {
1331 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1332 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1334 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1335 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1354 $pdf->SetTextColor(0, 0, 60);
1355 $pdf->SetFillColor(224, 224, 224);
1356 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1357 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1359 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1360 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1362 $pdf->SetFont(
'',
'', $default_font_size - 1);
1363 $pdf->SetTextColor(0, 0, 0);
1367 return ($tab2_top + ($tab2_hl * $index));
1384 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1394 $currency = !empty($currency) ? $currency : $conf->currency;
1398 $pdf->SetTextColor(0, 0, 0);
1399 $pdf->SetFont(
'',
'', $default_font_size - 2);
1401 if (empty($hidetop)) {
1402 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1403 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1404 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1407 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1408 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5,
'F',
null, explode(
',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1412 $pdf->SetDrawColor(128, 128, 128);
1413 $pdf->SetFont(
'',
'', $default_font_size - 1);
1416 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1418 if (empty($hidetop)) {
1419 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1421 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1422 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1425 if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE)) {
1426 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1427 if (empty($hidetop)) {
1433 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
1434 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1435 if (empty($hidetop)) {
1437 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1438 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1442 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1443 if (empty($hidetop)) {
1444 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1445 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1448 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1449 if (empty($hidetop)) {
1450 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1451 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1455 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1456 if (empty($hidetop)) {
1457 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1459 $this->posxdiscount - $this->posxunit - 1,
1461 $outputlangs->transnoentities(
"Unit"),
1468 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1469 if (empty($hidetop)) {
1470 if ($this->atleastonediscount) {
1471 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1472 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1475 if ($this->atleastonediscount) {
1476 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1478 if (empty($hidetop)) {
1479 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1480 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1495 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null)
1497 global $conf, $langs;
1499 $ltrdirection =
'L';
1500 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') $ltrdirection =
'R';
1503 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills"));
1509 $pdf->SetTextColor(0, 0, 60);
1510 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1514 $posy = $this->marge_haute;
1515 $posx = $this->page_largeur - $this->marge_droite - $w;
1517 $pdf->SetXY($this->marge_gauche, $posy);
1521 if ($this->emetteur->logo) {
1522 $logodir = $conf->mycompany->dir_output;
1523 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1524 $logodir = $conf->mycompany->multidir_output[$object->entity];
1527 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1529 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1531 if (is_readable($logo)) {
1533 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1535 $pdf->SetTextColor(200, 0, 0);
1536 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1537 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1538 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1541 $text = $this->emetteur->name;
1542 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1546 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1547 $pdf->SetXY($posx, $posy);
1548 $pdf->SetTextColor(0, 0, 60);
1549 $title = $outputlangs->transnoentities(
"PdfCommercialProposalTitle");
1550 $title .=
' '.$outputlangs->convToOutputCharset($object->ref);
1551 if ($object->statut == $object::STATUS_DRAFT) {
1552 $pdf->SetTextColor(128, 0, 0);
1553 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1555 $pdf->MultiCell(100, 4, $title,
'',
'R');
1557 $pdf->SetFont(
'',
'B', $default_font_size);
1567 $pdf->SetFont(
'',
'', $default_font_size - 2);
1569 if ($object->ref_client) {
1571 $pdf->SetXY($posx, $posy);
1572 $pdf->SetTextColor(0, 0, 60);
1573 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
1576 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
1577 $object->fetch_projet();
1578 if (!empty($object->project->ref)) {
1580 $pdf->SetXY($posx, $posy);
1581 $pdf->SetTextColor(0, 0, 60);
1582 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1586 if (!empty($conf->global->PDF_SHOW_PROJECT)) {
1587 $object->fetch_projet();
1588 if (!empty($object->project->ref)) {
1589 $outputlangs->load(
"projects");
1591 $pdf->SetXY($posx, $posy);
1592 $pdf->SetTextColor(0, 0, 60);
1593 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1597 if (!empty($conf->global->MAIN_PDF_DATE_TEXT)) {
1598 $displaydate =
"daytext";
1600 $displaydate =
"day";
1604 $posy = $pdf->getY();
1605 $pdf->SetXY($posx, $posy);
1606 $pdf->SetTextColor(0, 0, 60);
1607 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"DatePropal").
" : ".
dol_print_date($object->date, $displaydate,
false, $outputlangs,
true),
'',
'R');
1610 $pdf->SetXY($posx, $posy);
1611 $pdf->SetTextColor(0, 0, 60);
1612 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"DateEndPropal").
" : ".
dol_print_date($object->fin_validite, $displaydate,
false, $outputlangs,
true),
'',
'R');
1614 if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && $object->thirdparty->code_client) {
1616 $pdf->SetXY($posx, $posy);
1617 $pdf->SetTextColor(0, 0, 60);
1618 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1622 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1623 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1624 if (count($arrayidcontact) > 0) {
1625 $usertmp =
new User($this->db);
1626 $usertmp->fetch($arrayidcontact[0]);
1628 $pdf->SetXY($posx, $posy);
1629 $pdf->SetTextColor(0, 0, 60);
1630 $pdf->MultiCell(100, 3, $outputlangs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1638 $current_y = $pdf->getY();
1639 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3,
'R', $default_font_size);
1640 if ($current_y < $pdf->getY()) {
1641 $top_shift = $pdf->getY() - $current_y;
1646 $carac_emetteur =
'';
1648 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1649 if (count($arrayidcontact) > 0) {
1650 $object->fetch_user($arrayidcontact[0]);
1651 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1652 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1654 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone :
'';
1656 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email :
'';
1658 $carac_emetteur .=
"\n";
1661 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1664 $posy = 42 + $top_shift;
1665 $posx = $this->marge_gauche;
1666 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1667 $posx = $this->page_largeur - $this->marge_droite - 80;
1672 if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
1673 $pdf->SetTextColor(0, 0, 0);
1674 $pdf->SetFont(
'',
'', $default_font_size - 2);
1675 $pdf->SetXY($posx, $posy - 5);
1676 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1677 $pdf->SetXY($posx, $posy);
1678 $pdf->SetFillColor(230, 230, 230);
1679 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1680 $pdf->SetTextColor(0, 0, 60);
1684 if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
1685 $pdf->SetXY($posx + 2, $posy + 3);
1686 $pdf->SetFont(
'',
'B', $default_font_size);
1687 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1688 $posy = $pdf->getY();
1692 $pdf->SetXY($posx + 2, $posy);
1693 $pdf->SetFont(
'',
'', $default_font_size - 1);
1694 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1698 $usecontact =
false;
1699 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1700 if (count($arrayidcontact) > 0) {
1702 $result = $object->fetch_contact($arrayidcontact[0]);
1706 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
1707 $thirdparty = $object->contact;
1709 $thirdparty = $object->thirdparty;
1715 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact, $mode, $object);
1719 if ($this->page_largeur < 210) {
1722 $posy = 42 + $top_shift;
1723 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1724 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1725 $posx = $this->marge_gauche;
1729 if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
1730 $pdf->SetTextColor(0, 0, 0);
1731 $pdf->SetFont(
'',
'', $default_font_size - 2);
1732 $pdf->SetXY($posx + 2, $posy - 5);
1733 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1734 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1738 $pdf->SetXY($posx + 2, $posy + 3);
1739 $pdf->SetFont(
'',
'B', $default_font_size);
1740 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1742 $posy = $pdf->getY();
1745 $pdf->SetFont(
'',
'', $default_font_size - 1);
1746 $pdf->SetXY($posx + 2, $posy);
1747 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1750 $pdf->SetTextColor(0, 0, 0);