186 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
189 global $user, $langs,
$conf, $mysoc, $db, $hookmanager, $nblines;
191 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
193 if (!is_object($outputlangs)) {
194 $outputlangs = $langs;
198 $outputlangs->charset_output =
'ISO-8859-1';
202 $langfiles = array(
"main",
"dict",
"companies",
"bills",
"propal",
"products",
"compta");
203 $outputlangs->loadLangs($langfiles);
205 global $outputlangsbis;
206 $outputlangsbis =
null;
210 $outputlangsbis->loadLangs($langfiles);
218 $nblines = count(
$object->lines);
221 $realpatharray = array();
222 $this->atleastonephoto =
false;
224 $objphoto =
new Product($this->db);
226 for ($i = 0; $i < $nblines; $i++) {
227 if (empty(
$object->lines[$i]->fk_product)) {
231 $objphoto->fetch(
$object->lines[$i]->fk_product);
235 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
236 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
238 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
239 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
244 foreach ($pdir as $midir) {
246 if (
$conf->entity != $objphoto->entity) {
247 $dir =
$conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
249 $dir =
$conf->product->dir_output.
'/'.$midir;
251 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
253 if ($obj[
'photo_vignette']) {
254 $filename = $obj[
'photo_vignette'];
256 $filename = $obj[
'photo'];
259 $filename = $obj[
'photo'];
262 $realpath = $dir.$filename;
264 $this->atleastonephoto =
true;
269 if ($realpath && $arephoto) {
270 $realpatharray[$i] = $realpath;
275 if (count($realpatharray) == 0) {
276 $this->posxpicture = $this->posxtva;
279 if (
$conf->propal->multidir_output[
$conf->entity]) {
286 $dir =
$conf->propal->multidir_output[
$conf->entity];
287 $file = $dir.
"/SPECIMEN.pdf";
290 $dir =
$conf->propal->multidir_output[
$object->entity].
"/".$objectref;
291 $file = $dir.
"/".$objectref.
".pdf";
294 if (!file_exists($dir)) {
296 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
301 if (file_exists($dir)) {
303 if (!is_object($hookmanager)) {
304 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
307 $hookmanager->initHooks(array(
'pdfgeneration'));
308 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
310 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
313 $nblines = count(
$object->lines);
319 $pdf->SetAutoPageBreak(1, 0);
321 if (class_exists(
'TCPDF')) {
322 $pdf->setPrintHeader(
false);
323 $pdf->setPrintFooter(
false);
328 $logodir =
$conf->mycompany->dir_output;
329 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
330 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
332 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
333 $tplidx = $pdf->importPage(1);
338 $pdf->SetDrawColor(128, 128, 128);
340 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
341 $pdf->SetSubject($outputlangs->transnoentities(
"PdfCommercialProposalTitle"));
342 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
343 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
344 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
346 $pdf->SetCompression(
false);
350 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
353 for ($i = 0; $i < $nblines; $i++) {
354 if (
$object->lines[$i]->remise_percent) {
355 $this->atleastonediscount++;
358 if (empty($this->atleastonediscount)) {
359 $delta = ($this->postotalht - $this->posxdiscount);
360 $this->posxpicture += $delta;
361 $this->posxtva += $delta;
362 $this->posxup += $delta;
363 $this->posxqty += $delta;
364 $this->posxunit += $delta;
365 $this->posxdiscount += $delta;
371 if (!empty($tplidx)) {
372 $pdf->useTemplate($tplidx);
376 $heightforinfotot = 40;
379 $heightforfooter = $this->marge_basse + 8;
381 $heightforfooter += 6;
385 $top_shift = $this->
_pagehead($pdf,
$object, 1, $outputlangs, $outputlangsbis);
386 $pdf->SetFont(
'',
'', $default_font_size - 1);
387 $pdf->MultiCell(0, 3,
'');
388 $pdf->SetTextColor(0, 0, 0);
391 $tab_top = 90 + $top_shift;
392 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
395 $height_incoterms = 0;
396 if (isModEnabled(
'incoterm')) {
397 $desc_incoterms =
$object->getIncotermsForPDF();
398 if ($desc_incoterms) {
401 $pdf->SetFont(
'',
'', $default_font_size - 1);
402 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
403 $nexY = $pdf->GetY();
404 $height_incoterms = $nexY - $tab_top;
407 $pdf->SetDrawColor(192, 192, 192);
408 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius,
'1234',
'D');
410 $tab_top = $nexY + 6;
411 $height_incoterms += 4;
416 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
419 if (is_object(
$object->thirdparty)) {
420 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
421 $salerepobj =
new User($this->db);
422 $salerepobj->fetch($salereparray[0][
'id']);
423 if (!empty($salerepobj->signature)) {
424 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
429 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
430 if (!empty($extranote)) {
434 $tmpuser =
new User($this->db);
435 $tmpuser->fetch(
$object->user_author_id);
438 $creator_info = $langs->trans(
"CaseFollowedBy").
' '.$tmpuser->getFullName($langs);
439 if ($tmpuser->email) {
440 $creator_info .=
', '.$langs->trans(
"EMail").
': '.$tmpuser->email;
442 if ($tmpuser->office_phone) {
443 $creator_info .=
', '.$langs->trans(
"Phone").
': '.$tmpuser->office_phone;
457 $pdf->SetFont(
'',
'', $default_font_size - 1);
458 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
459 $nexY = $pdf->GetY();
460 $height_note = $nexY - $tab_top;
463 $pdf->SetDrawColor(192, 192, 192);
464 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 2, $this->corner_radius,
'1234',
'D');
466 $tab_top = $nexY + 6;
469 $iniY = $tab_top + 7;
470 $curY = $tab_top + 7;
471 $nexY = $tab_top + 7;
474 for ($i = 0; $i < $nblines; $i++) {
476 $pdf->SetFont(
'',
'', $default_font_size - 1);
477 $pdf->SetTextColor(0, 0, 0);
480 $imglinesize = array();
481 if (!empty($realpatharray[$i])) {
485 $pdf->setTopMargin($tab_top_newpage);
486 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot);
487 $pageposbefore = $pdf->getPage();
489 $showpricebeforepagebreak = 1;
491 $posYAfterDescription = 0;
494 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
495 $pdf->AddPage(
'',
'',
true);
496 if (!empty($tplidx)) {
497 $pdf->useTemplate($tplidx);
502 $pdf->setPage($pageposbefore + 1);
504 $curY = $tab_top_newpage;
508 $showpricebeforepagebreak = 1;
510 $showpricebeforepagebreak = 0;
514 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
515 $curX = $this->posxpicture - 1;
516 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
518 $posYAfterImage = $curY + $imglinesize[
'height'];
522 $curX = $this->posxdesc - 1;
524 $pdf->startTransaction();
525 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
526 $pageposafter = $pdf->getPage();
527 if ($pageposafter > $pageposbefore) {
528 $pdf->rollbackTransaction(
true);
529 $pageposafter = $pageposbefore;
531 $pdf->setPageOrientation(
'', 1, $heightforfooter);
532 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
534 $pageposafter = $pdf->getPage();
535 $posyafter = $pdf->GetY();
537 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
538 if ($i == ($nblines - 1)) {
539 $pdf->AddPage(
'',
'',
true);
540 if (!empty($tplidx)) {
541 $pdf->useTemplate($tplidx);
546 $pdf->setPage($pageposafter + 1);
553 $showpricebeforepagebreak = 1;
555 $showpricebeforepagebreak = 0;
559 $pdf->commitTransaction();
561 $posYAfterDescription = $pdf->GetY();
563 $nexY = $pdf->GetY();
564 $pageposafter = $pdf->getPage();
566 $pdf->setPage($pageposbefore);
567 $pdf->setTopMargin($this->marge_haute);
568 $pdf->setPageOrientation(
'', 1, 0);
571 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
572 $pdf->setPage($pageposafter);
573 $curY = $tab_top_newpage;
576 $pdf->SetFont(
'',
'', $default_font_size - 1);
581 $pdf->SetXY($this->posxtva - 5, $curY);
582 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
587 $pdf->SetXY($this->posxup, $curY);
588 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
592 $pdf->SetXY($this->posxqty, $curY);
593 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
598 $pdf->SetXY($this->posxunit, $curY);
599 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
603 $pdf->SetXY($this->posxdiscount, $curY);
604 if (
$object->lines[$i]->remise_percent) {
605 $pdf->SetXY($this->posxdiscount - 2, $curY);
607 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
612 $pdf->SetXY($this->postotalht, $curY);
613 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
616 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
617 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
619 $tvaligne =
$object->lines[$i]->total_tva;
622 $localtax1ligne =
$object->lines[$i]->total_localtax1;
623 $localtax2ligne =
$object->lines[$i]->total_localtax2;
624 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
625 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
626 $localtax1_type =
$object->lines[$i]->localtax1_type;
627 $localtax2_type =
$object->lines[$i]->localtax2_type;
640 $vatrate = (string)
$object->lines[$i]->tva_tx;
643 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
644 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
646 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
647 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
651 if ($localtax1_type && $localtax1ligne != 0) {
652 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
653 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
655 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
658 if ($localtax2_type && $localtax2ligne != 0) {
659 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
660 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
662 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
666 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
671 if (!isset($this->tva[$vatrate])) {
672 $this->tva[$vatrate] = 0;
674 $this->tva[$vatrate] += $tvaligne;
675 $vatcode =
$object->lines[$i]->vat_src_code;
676 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
677 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
679 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
681 if ($posYAfterImage > $posYAfterDescription) {
682 $nexY = $posYAfterImage;
687 $pdf->setPage($pageposafter);
688 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
690 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
691 $pdf->SetLineStyle(array(
'dash' => 0));
697 while ($pagenb < $pageposafter) {
698 $pdf->setPage($pagenb);
700 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
702 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
706 $pdf->setPage($pagenb);
707 $pdf->setPageOrientation(
'', 1, 0);
711 if (!empty($tplidx)) {
712 $pdf->useTemplate($tplidx);
715 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
717 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
719 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
724 if (!empty($tplidx)) {
725 $pdf->useTemplate($tplidx);
736 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
737 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
739 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
740 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
764 if (method_exists($pdf,
'AliasNbPages')) {
765 $pdf->AliasNbPages();
769 if (!empty($mysoc->termsofsale) &&
getDolGlobalInt(
'MAIN_PDF_ADD_TERMSOFSALE_PROPAL')) {
770 $termsofsale =
$conf->mycompany->dir_output.
'/'.$mysoc->termsofsale;
771 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
772 $termsofsale =
$conf->mycompany->multidir_output[
$object->entity].
'/'.$mysoc->termsofsale;
774 if (file_exists($termsofsale) && is_readable($termsofsale)) {
775 $pagecount = $pdf->setSourceFile($termsofsale);
776 for ($i = 1; $i <= $pagecount; $i++) {
777 $tplIdx = $pdf->importPage($i);
778 if ($tplIdx!==
false) {
779 $s = $pdf->getTemplatesize($tplIdx);
780 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
781 $pdf->useTemplate($tplIdx);
783 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
791 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
793 $already_merged = array();
794 foreach (
$object->lines as $line) {
795 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
800 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
802 $filetomerge->fetch_by_product($line->fk_product);
805 $already_merged[] = $line->fk_product;
807 $product =
new Product($this->db);
808 $product->fetch($line->fk_product);
810 if ($product->entity !=
$conf->entity) {
811 $entity_product_file = $product->entity;
813 $entity_product_file =
$conf->entity;
817 if (count($filetomerge->lines) > 0) {
818 foreach ($filetomerge->lines as $linefile) {
819 if (!empty($linefile->id) && !empty($linefile->file_name)) {
821 if (isModEnabled(
"product")) {
822 $filetomerge_dir =
$conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
823 } elseif (isModEnabled(
"service")) {
824 $filetomerge_dir =
$conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
827 if (isModEnabled(
"product")) {
828 $filetomerge_dir =
$conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
829 } elseif (isModEnabled(
"service")) {
830 $filetomerge_dir =
$conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
834 dol_syslog(get_class($this).
':: upload_dir='.$filetomerge_dir, LOG_DEBUG);
836 $infile = $filetomerge_dir.
'/'.$linefile->file_name;
837 if (file_exists($infile) && is_readable($infile)) {
838 $pagecount = $pdf->setSourceFile($infile);
839 for ($i = 1; $i <= $pagecount; $i++) {
840 $tplIdx = $pdf->importPage($i);
841 if ($tplIdx !==
false) {
842 $s = $pdf->getTemplatesize($tplIdx);
843 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
844 $pdf->useTemplate($tplIdx);
846 setEventMessages(
null, array($infile.
' cannot be added, probably protected PDF'),
'warnings');
859 $pdf->Output($file,
'F');
862 $hookmanager->initHooks(array(
'pdfgeneration'));
863 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
865 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
867 $this->error = $hookmanager->error;
868 $this->errors = $hookmanager->errors;
873 $this->result = array(
'fullpath' => $file);
877 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
881 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PROP_OUTPUTDIR");
917 global
$conf, $mysoc;
920 $pdf->SetFont(
'',
'', $default_font_size - 1);
925 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
926 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
927 $pdf->SetXY($this->marge_gauche, $posy);
928 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
930 $posy = $pdf->GetY() + 4;
935 $displaydate =
"daytext";
937 $displaydate =
"day";
941 if (!empty(
$object->delivery_date)) {
942 $outputlangs->load(
"sendings");
943 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
944 $pdf->SetXY($this->marge_gauche, $posy);
945 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
946 $pdf->MultiCell(80, 4, $titre, 0,
'L');
947 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
948 $pdf->SetXY($posxval, $posy);
950 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
952 $posy = $pdf->GetY() + 1;
954 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
955 $pdf->SetXY($this->marge_gauche, $posy);
956 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
957 $pdf->MultiCell(80, 4, $titre, 0,
'L');
958 $pdf->SetTextColor(0, 0, 0);
959 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
960 $pdf->SetXY($posxval, $posy);
961 $lib_availability = ($outputlangs->transnoentities(
"AvailabilityType".
$object->availability_code) !=
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(
$object->availability);
962 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
963 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
965 $posy = $pdf->GetY() + 1;
970 $outputlangs->load(
"sendings");
972 $shipping_method_id =
$object->shipping_method_id;
973 if (
getDolGlobalString(
'SOCIETE_ASK_FOR_SHIPPING_METHOD') && !empty($this->emetteur->shipping_method_id)) {
974 $shipping_method_id = $this->emetteur->shipping_method_id;
976 $shipping_method_code =
dol_getIdFromCode($this->db, (
string) $shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
977 $shipping_method_label =
dol_getIdFromCode($this->db, (
string) $shipping_method_id,
'c_shipment_mode',
'rowid',
'libelle');
979 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
980 $pdf->SetXY($this->marge_gauche, $posy);
981 $titre = $outputlangs->transnoentities(
"SendingMethod").
':';
982 $pdf->MultiCell(43, 4, $titre, 0,
'L');
984 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
985 $pdf->SetXY($posxval, $posy);
986 $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;
987 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
988 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
990 $posy = $pdf->GetY() + 1;
995 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
996 $pdf->SetXY($this->marge_gauche, $posy);
997 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
998 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1000 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1001 $pdf->SetXY($posxval, $posy);
1002 $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);
1003 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1004 if (
$object->deposit_percent > 0) {
1005 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__',
$object->deposit_percent, $lib_condition_paiement);
1007 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1009 $posy = $pdf->GetY() + 3;
1014 if (
$object->mode_reglement_code
1015 &&
$object->mode_reglement_code !=
'CHQ'
1016 &&
$object->mode_reglement_code !=
'VIR') {
1017 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1018 $pdf->SetXY($this->marge_gauche, $posy);
1019 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1020 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1021 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1022 $pdf->SetXY($posxval, $posy);
1023 $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);
1024 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1026 $posy = $pdf->GetY() + 2;
1030 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1034 $account =
new Account($this->db);
1037 $pdf->SetXY($this->marge_gauche, $posy);
1038 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1039 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
1040 $posy = $pdf->GetY() + 1;
1043 $pdf->SetXY($this->marge_gauche, $posy);
1044 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1045 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1046 $posy = $pdf->GetY() + 2;
1050 $pdf->SetXY($this->marge_gauche, $posy);
1051 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1052 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1053 $posy = $pdf->GetY() + 1;
1056 $pdf->SetXY($this->marge_gauche, $posy);
1057 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1058 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1059 $posy = $pdf->GetY() + 2;
1066 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1072 $account =
new Account($this->db);
1073 $account->fetch($bankid);
1075 $curx = $this->marge_gauche;
1078 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1104 global
$conf, $mysoc;
1109 $pdf->SetFont(
'',
'', $default_font_size - 1);
1114 if ($this->page_largeur < 210) {
1117 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1123 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
1126 $total_line_remise = 0;
1127 foreach (
$object->lines as $i => $line) {
1129 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
1131 if ($line->total_ht < 0) {
1132 $total_line_remise += -$line->total_ht;
1135 if ($total_line_remise > 0) {
1136 $pdf->SetFillColor(255, 255, 255);
1137 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1138 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
1139 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1140 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
1145 $pdf->SetFillColor(255, 255, 255);
1146 $pdf->SetXY($col1x, $tab2_top);
1147 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
1148 $pdf->SetXY($col2x, $tab2_top);
1149 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
1155 $pdf->SetFillColor(255, 255, 255);
1156 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1157 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1159 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1160 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1161 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1164 $pdf->SetFillColor(248, 248, 248);
1166 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1168 $this->atleastoneratenotnull = 0;
1170 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1171 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1175 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1176 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1180 foreach ($localtax_rate as $tvakey => $tvaval) {
1185 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1188 if (preg_match(
'/\*/', $tvakey)) {
1189 $tvakey = str_replace(
'*',
'', $tvakey);
1190 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1192 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1195 $totalvat .= $tvacompl;
1197 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1200 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1202 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1204 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1205 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1211 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1212 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1216 foreach ($localtax_rate as $tvakey => $tvaval) {
1221 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1224 if (preg_match(
'/\*/', $tvakey)) {
1225 $tvakey = str_replace(
'*',
'', $tvakey);
1226 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1228 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1231 $totalvat .= $tvacompl;
1233 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1236 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1238 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1240 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1241 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1247 foreach ($this->tva_array as $tvakey => $tvaval) {
1249 $this->atleastoneratenotnull++;
1252 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1255 if (preg_match(
'/\*/', $tvakey)) {
1256 $tvakey = str_replace(
'*',
'', $tvakey);
1257 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1259 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1262 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1264 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1266 $totalvat .= $tvacompl;
1268 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1270 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1272 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1273 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1278 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1279 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1283 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(
"TotalLT1", $mysoc->country_code).
' ';
1298 $totalvat .= $tvacompl;
1300 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1303 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1305 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1307 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1308 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1314 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1315 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1319 foreach ($localtax_rate as $tvakey => $tvaval) {
1325 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1328 if (preg_match(
'/\*/', $tvakey)) {
1329 $tvakey = str_replace(
'*',
'', $tvakey);
1330 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1332 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1335 $totalvat .= $tvacompl;
1337 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1340 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1342 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1344 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1345 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1353 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1354 $pdf->SetTextColor(0, 0, 60);
1355 $pdf->SetFillColor(224, 224, 224);
1356 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1358 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1359 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1363 $pdf->SetTextColor(0, 0, 0);
1371 if ($deja_regle > 0) {
1374 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1375 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1377 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1378 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1396 $pdf->SetTextColor(0, 0, 60);
1397 $pdf->SetFillColor(224, 224, 224);
1398 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1399 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1401 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1402 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1404 $pdf->SetFont(
'',
'', $default_font_size - 1);
1405 $pdf->SetTextColor(0, 0, 0);
1409 return ($tab2_top + ($tab2_hl * $index));
1426 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1436 $currency = !empty($currency) ? $currency :
$conf->currency;
1440 $pdf->SetTextColor(0, 0, 0);
1441 $pdf->SetFont(
'',
'', $default_font_size - 2);
1443 if (empty($hidetop)) {
1444 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1445 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1446 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1450 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius,
'1001',
'F',
null, explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
1454 $pdf->SetDrawColor(128, 128, 128);
1455 $pdf->SetFont(
'',
'', $default_font_size - 1);
1458 $this->
printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom,
'D');
1460 if (empty($hidetop)) {
1461 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1463 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1464 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1468 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1469 if (empty($hidetop)) {
1476 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1477 if (empty($hidetop)) {
1479 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1480 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1484 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1485 if (empty($hidetop)) {
1486 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1487 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1490 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1491 if (empty($hidetop)) {
1492 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1493 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1497 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1498 if (empty($hidetop)) {
1499 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1501 $this->posxdiscount - $this->posxunit - 1,
1503 $outputlangs->transnoentities(
"Unit"),
1510 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1511 if (empty($hidetop)) {
1512 if ($this->atleastonediscount) {
1513 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1514 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1517 if ($this->atleastonediscount) {
1518 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1520 if (empty($hidetop)) {
1521 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1522 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1537 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
1539 global
$conf, $langs;
1541 $ltrdirection =
'L';
1542 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1543 $ltrdirection =
'R';
1547 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills"));
1553 $pdf->SetTextColor(0, 0, 60);
1554 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1558 $posy = $this->marge_haute;
1559 $posx = $this->page_largeur - $this->marge_droite - $w;
1561 $pdf->SetXY($this->marge_gauche, $posy);
1565 if ($this->emetteur->logo) {
1566 $logodir =
$conf->mycompany->dir_output;
1567 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
1568 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
1571 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1573 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1575 if (is_readable($logo)) {
1577 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1579 $pdf->SetTextColor(200, 0, 0);
1580 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1581 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1582 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1585 $text = $this->emetteur->name;
1586 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1590 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1591 $pdf->SetXY($posx, $posy);
1592 $pdf->SetTextColor(0, 0, 60);
1593 $title = $outputlangs->transnoentities(
"PdfCommercialProposalTitle");
1594 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1595 if (
$object->statut == $object::STATUS_DRAFT) {
1596 $pdf->SetTextColor(128, 0, 0);
1597 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1599 $pdf->MultiCell($w, 4, $title,
'',
'R');
1601 $pdf->SetFont(
'',
'B', $default_font_size);
1611 $pdf->SetFont(
'',
'', $default_font_size - 2);
1615 $pdf->SetXY($posx, $posy);
1616 $pdf->SetTextColor(0, 0, 60);
1617 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset(
$object->ref_client),
'',
'R');
1622 if (!empty(
$object->project->ref)) {
1624 $pdf->SetXY($posx, $posy);
1625 $pdf->SetTextColor(0, 0, 60);
1626 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1632 if (!empty(
$object->project->ref)) {
1633 $outputlangs->load(
"projects");
1635 $pdf->SetXY($posx, $posy);
1636 $pdf->SetTextColor(0, 0, 60);
1637 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1642 $displaydate =
"daytext";
1644 $displaydate =
"day";
1648 $posy = $pdf->getY();
1649 $pdf->SetXY($posx, $posy);
1650 $pdf->SetTextColor(0, 0, 60);
1651 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePropal").
" : ".
dol_print_date(
$object->date, $displaydate,
false, $outputlangs,
true),
'',
'R');
1654 $pdf->SetXY($posx, $posy);
1655 $pdf->SetTextColor(0, 0, 60);
1656 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DateEndPropal").
" : ".
dol_print_date(
$object->fin_validite, $displaydate,
false, $outputlangs,
true),
'',
'R');
1660 $pdf->SetXY($posx, $posy);
1661 $pdf->SetTextColor(0, 0, 60);
1662 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1667 $pdf->SetXY($posx, $posy);
1668 $pdf->SetTextColor(0, 0, 60);
1669 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
1674 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1675 if (count($arrayidcontact) > 0) {
1676 $usertmp =
new User($this->db);
1677 $usertmp->fetch($arrayidcontact[0]);
1679 $pdf->SetXY($posx, $posy);
1680 $pdf->SetTextColor(0, 0, 60);
1681 $pdf->MultiCell($w, 3, $outputlangs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1689 $current_y = $pdf->getY();
1691 if ($current_y < $pdf->getY()) {
1692 $top_shift = $pdf->getY() - $current_y;
1697 $carac_emetteur =
'';
1699 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1700 if (count($arrayidcontact) > 0) {
1701 $object->fetch_user($arrayidcontact[0]);
1702 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1703 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1705 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1709 $carac_emetteur .=
"\n";
1715 $posy = 42 + $top_shift;
1716 $posx = $this->marge_gauche;
1718 $posx = $this->page_largeur - $this->marge_droite - 80;
1724 $pdf->SetTextColor(0, 0, 0);
1725 $pdf->SetFont(
'',
'', $default_font_size - 2);
1726 $pdf->SetXY($posx, $posy - 5);
1727 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1728 $pdf->SetXY($posx, $posy);
1729 $pdf->SetFillColor(230, 230, 230);
1730 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1731 $pdf->SetTextColor(0, 0, 60);
1736 $pdf->SetXY($posx + 2, $posy + 3);
1737 $pdf->SetFont(
'',
'B', $default_font_size);
1738 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1739 $posy = $pdf->getY();
1743 $pdf->SetXY($posx + 2, $posy);
1744 $pdf->SetFont(
'',
'', $default_font_size - 1);
1745 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1749 $usecontact =
false;
1750 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1751 if (count($arrayidcontact) > 0) {
1753 $result =
$object->fetch_contact($arrayidcontact[0]);
1757 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1758 $thirdparty =
$object->contact;
1760 $thirdparty =
$object->thirdparty;
1770 if ($this->page_largeur < 210) {
1773 $posy = 42 + $top_shift;
1774 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1776 $posx = $this->marge_gauche;
1781 $pdf->SetTextColor(0, 0, 0);
1782 $pdf->SetFont(
'',
'', $default_font_size - 2);
1783 $pdf->SetXY($posx + 2, $posy - 5);
1784 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1785 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1789 $pdf->SetXY($posx + 2, $posy + 3);
1790 $pdf->SetFont(
'',
'B', $default_font_size);
1792 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1794 $posy = $pdf->getY();
1797 $pdf->SetFont(
'',
'', $default_font_size - 1);
1798 $pdf->SetXY($posx + 2, $posy);
1800 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1803 $pdf->SetTextColor(0, 0, 0);