34 require_once DOL_DOCUMENT_ROOT.
'/core/modules/propale/modules_propale.php';
35 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
38 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
64 public $update_main_doc_field;
75 public $phpmin = array(5, 6);
81 public $version =
'dolibarr';
101 public $marge_gauche;
106 public $marge_droite;
132 global $conf, $langs, $mysoc;
135 $langs->loadLangs(array(
"main",
"bills"));
138 $this->
name =
"azur";
139 $this->
description = $langs->trans(
'DocModelAzurDescription');
140 $this->update_main_doc_field = 1;
145 $this->page_largeur = $formatarray[
'width'];
146 $this->page_hauteur = $formatarray[
'height'];
147 $this->format = array($this->page_largeur, $this->page_hauteur);
148 $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
149 $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
150 $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
151 $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
153 $this->option_logo = 1;
154 $this->option_tva = 1;
155 $this->option_modereg = 1;
156 $this->option_condreg = 1;
157 $this->option_multilang = 1;
158 $this->option_escompte = 0;
159 $this->option_credit_note = 0;
160 $this->option_freetext = 1;
161 $this->option_draft_watermark = 1;
162 $this->watermark =
'';
165 $this->emetteur = $mysoc;
166 if (empty($this->emetteur->country_code)) {
167 $this->emetteur->country_code = substr($langs->defaultlang, -2);
171 $this->posxdesc = $this->marge_gauche + 1;
172 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
173 $this->posxtva = 101;
175 $this->posxqty = 135;
176 $this->posxunit = 151;
178 $this->posxtva = 106;
180 $this->posxqty = 145;
181 $this->posxunit = 162;
183 $this->posxdiscount = 162;
184 $this->postotalht = 174;
185 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
186 $this->posxtva = $this->posxup;
188 $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
189 if ($this->page_largeur < 210) {
190 $this->posxpicture -= 20;
191 $this->posxtva -= 20;
193 $this->posxqty -= 20;
194 $this->posxunit -= 20;
195 $this->posxdiscount -= 20;
196 $this->postotalht -= 20;
199 $this->tva = array();
200 $this->tva_array = array();
201 $this->localtax1 = array();
202 $this->localtax2 = array();
203 $this->atleastoneratenotnull = 0;
204 $this->atleastonediscount = 0;
219 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
222 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
224 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
226 if (!is_object($outputlangs)) {
227 $outputlangs = $langs;
230 if (!empty($conf->global->MAIN_USE_FPDF)) {
231 $outputlangs->charset_output =
'ISO-8859-1';
235 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"propal",
"products"));
237 global $outputlangsbis;
238 $outputlangsbis =
null;
239 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
240 $outputlangsbis =
new Translate(
'', $conf);
241 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
242 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
246 if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->PROPALE_DRAFT_WATERMARK))) {
247 $this->watermark = $conf->global->PROPALE_DRAFT_WATERMARK;
250 $nblines = count($object->lines);
253 $realpatharray = array();
254 $this->atleastonephoto =
false;
255 if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE)) {
258 for ($i = 0; $i < $nblines; $i++) {
259 if (empty($object->lines[$i]->fk_product)) {
263 $objphoto->fetch($object->lines[$i]->fk_product);
265 if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
266 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
267 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
269 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
270 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
275 foreach ($pdir as $midir) {
277 if ($conf->entity != $objphoto->entity) {
278 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
280 $dir = $conf->product->dir_output.
'/'.$midir;
282 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
283 if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES)) {
284 if ($obj[
'photo_vignette']) {
285 $filename = $obj[
'photo_vignette'];
287 $filename = $obj[
'photo'];
290 $filename = $obj[
'photo'];
293 $realpath = $dir.$filename;
295 $this->atleastonephoto =
true;
300 if ($realpath && $arephoto) {
301 $realpatharray[$i] = $realpath;
306 if (count($realpatharray) == 0) {
307 $this->posxpicture = $this->posxtva;
310 if ($conf->propal->multidir_output[$conf->entity]) {
311 $object->fetch_thirdparty();
316 if ($object->specimen) {
317 $dir = $conf->propal->multidir_output[$conf->entity];
318 $file = $dir.
"/SPECIMEN.pdf";
321 $dir = $conf->propal->multidir_output[$object->entity].
"/".$objectref;
322 $file = $dir.
"/".$objectref.
".pdf";
325 if (!file_exists($dir)) {
327 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
332 if (file_exists($dir)) {
334 if (!is_object($hookmanager)) {
335 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
338 $hookmanager->initHooks(array(
'pdfgeneration'));
339 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
341 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
344 $nblines = count($object->lines);
350 $pdf->SetAutoPageBreak(1, 0);
352 if (class_exists(
'TCPDF')) {
353 $pdf->setPrintHeader(
false);
354 $pdf->setPrintFooter(
false);
358 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
359 $logodir = $conf->mycompany->dir_output;
360 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
361 $logodir = $conf->mycompany->multidir_output[$object->entity];
363 $pagecount = $pdf->setSourceFile($logodir.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
364 $tplidx = $pdf->importPage(1);
369 $pdf->SetDrawColor(128, 128, 128);
371 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
372 $pdf->SetSubject($outputlangs->transnoentities(
"PdfCommercialProposalTitle"));
373 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
374 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
375 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
376 if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
377 $pdf->SetCompression(
false);
380 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
383 for ($i = 0; $i < $nblines; $i++) {
384 if ($object->lines[$i]->remise_percent) {
385 $this->atleastonediscount++;
388 if (empty($this->atleastonediscount)) {
389 $delta = ($this->postotalht - $this->posxdiscount);
390 $this->posxpicture += $delta;
391 $this->posxtva += $delta;
392 $this->posxup += $delta;
393 $this->posxqty += $delta;
394 $this->posxunit += $delta;
395 $this->posxdiscount += $delta;
401 if (!empty($tplidx)) {
402 $pdf->useTemplate($tplidx);
406 $heightforinfotot = 40;
407 $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (
pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities(
"ProposalCustomerSignature")) + 10) : 0;
408 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
409 $heightforfooter = $this->marge_basse + 8;
410 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
411 $heightforfooter += 6;
415 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
416 $pdf->SetFont(
'',
'', $default_font_size - 1);
417 $pdf->MultiCell(0, 3,
'');
418 $pdf->SetTextColor(0, 0, 0);
421 $tab_top = 90 + $top_shift;
422 $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
425 $height_incoterms = 0;
426 if (!empty($conf->incoterm->enabled)) {
427 $desc_incoterms = $object->getIncotermsForPDF();
428 if ($desc_incoterms) {
431 $pdf->SetFont(
'',
'', $default_font_size - 1);
432 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
433 $nexY = $pdf->GetY();
434 $height_incoterms = $nexY - $tab_top;
437 $pdf->SetDrawColor(192, 192, 192);
438 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
440 $tab_top = $nexY + 6;
441 $height_incoterms += 4;
446 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
447 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
449 if (is_object($object->thirdparty)) {
450 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
451 $salerepobj =
new User($this->
db);
452 $salerepobj->fetch($salereparray[0][
'id']);
453 if (!empty($salerepobj->signature)) {
454 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
459 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
460 if (!empty($extranote)) {
463 if (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0) {
464 $tmpuser =
new User($this->
db);
465 $tmpuser->fetch($object->user_author_id);
468 $creator_info = $langs->trans(
"CaseFollowedBy").
' '.$tmpuser->getFullName($langs);
469 if ($tmpuser->email) $creator_info .=
', '.$langs->trans(
"EMail").
': '.$tmpuser->email;
470 if ($tmpuser->office_phone) $creator_info .=
', '.$langs->trans(
"Phone").
': '.$tmpuser->office_phone;
483 $pdf->SetFont(
'',
'', $default_font_size - 1);
484 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
485 $nexY = $pdf->GetY();
486 $height_note = $nexY - $tab_top;
489 $pdf->SetDrawColor(192, 192, 192);
490 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
492 $tab_top = $nexY + 6;
495 $iniY = $tab_top + 7;
496 $curY = $tab_top + 7;
497 $nexY = $tab_top + 7;
500 for ($i = 0; $i < $nblines; $i++) {
502 $pdf->SetFont(
'',
'', $default_font_size - 1);
503 $pdf->SetTextColor(0, 0, 0);
506 $imglinesize = array();
507 if (!empty($realpatharray[$i])) {
511 $pdf->setTopMargin($tab_top_newpage);
512 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot);
513 $pageposbefore = $pdf->getPage();
515 $showpricebeforepagebreak = 1;
517 $posYAfterDescription = 0;
520 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
521 $pdf->AddPage(
'',
'',
true);
522 if (!empty($tplidx)) {
523 $pdf->useTemplate($tplidx);
525 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
526 $this->
_pagehead($pdf, $object, 0, $outputlangs);
528 $pdf->setPage($pageposbefore + 1);
530 $curY = $tab_top_newpage;
533 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
534 $showpricebeforepagebreak = 1;
536 $showpricebeforepagebreak = 0;
540 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
541 $curX = $this->posxpicture - 1;
542 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
544 $posYAfterImage = $curY + $imglinesize[
'height'];
548 $curX = $this->posxdesc - 1;
550 $pdf->startTransaction();
551 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
552 $pageposafter = $pdf->getPage();
553 if ($pageposafter > $pageposbefore) {
554 $pdf->rollbackTransaction(
true);
555 $pageposafter = $pageposbefore;
557 $pdf->setPageOrientation(
'', 1, $heightforfooter);
558 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
560 $pageposafter = $pdf->getPage();
561 $posyafter = $pdf->GetY();
563 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
564 if ($i == ($nblines - 1)) {
565 $pdf->AddPage(
'',
'',
true);
566 if (!empty($tplidx)) {
567 $pdf->useTemplate($tplidx);
569 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
570 $this->
_pagehead($pdf, $object, 0, $outputlangs);
572 $pdf->setPage($pageposafter + 1);
578 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
579 $showpricebeforepagebreak = 1;
581 $showpricebeforepagebreak = 0;
586 $pdf->commitTransaction();
588 $posYAfterDescription = $pdf->GetY();
590 $nexY = $pdf->GetY();
591 $pageposafter = $pdf->getPage();
593 $pdf->setPage($pageposbefore);
594 $pdf->setTopMargin($this->marge_haute);
595 $pdf->setPageOrientation(
'', 1, 0);
598 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
599 $pdf->setPage($pageposafter);
600 $curY = $tab_top_newpage;
603 $pdf->SetFont(
'',
'', $default_font_size - 1);
606 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
608 $pdf->SetXY($this->posxtva - 5, $curY);
609 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
614 $pdf->SetXY($this->posxup, $curY);
615 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
619 $pdf->SetXY($this->posxqty, $curY);
620 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
623 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
624 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
625 $pdf->SetXY($this->posxunit, $curY);
626 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
630 $pdf->SetXY($this->posxdiscount, $curY);
631 if ($object->lines[$i]->remise_percent) {
632 $pdf->SetXY($this->posxdiscount - 2, $curY);
634 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
639 $pdf->SetXY($this->postotalht, $curY);
640 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
643 if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) {
644 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
646 $tvaligne = $object->lines[$i]->total_tva;
649 $localtax1ligne = $object->lines[$i]->total_localtax1;
650 $localtax2ligne = $object->lines[$i]->total_localtax2;
651 $localtax1_rate = $object->lines[$i]->localtax1_tx;
652 $localtax2_rate = $object->lines[$i]->localtax2_tx;
653 $localtax1_type = $object->lines[$i]->localtax1_type;
654 $localtax2_type = $object->lines[$i]->localtax2_type;
656 if ($object->remise_percent) {
657 $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
659 if ($object->remise_percent) {
660 $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
662 if ($object->remise_percent) {
663 $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
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 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
680 if ($localtax2_type && $localtax2ligne != 0) {
681 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
684 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
689 if (!isset($this->tva[$vatrate])) {
690 $this->tva[$vatrate] = 0;
692 $this->tva[$vatrate] += $tvaligne;
693 $vatcode = $object->lines[$i]->vat_src_code;
694 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
695 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
697 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
699 if ($posYAfterImage > $posYAfterDescription) {
700 $nexY = $posYAfterImage;
704 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
705 $pdf->setPage($pageposafter);
706 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
708 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
709 $pdf->SetLineStyle(array(
'dash'=>0));
715 while ($pagenb < $pageposafter) {
716 $pdf->setPage($pagenb);
718 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
720 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
722 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
724 $pdf->setPage($pagenb);
725 $pdf->setPageOrientation(
'', 1, 0);
726 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
727 $this->
_pagehead($pdf, $object, 0, $outputlangs);
729 if (!empty($tplidx)) {
730 $pdf->useTemplate($tplidx);
733 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
735 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
737 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
739 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
742 if (!empty($tplidx)) {
743 $pdf->useTemplate($tplidx);
746 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
747 $this->
_pagehead($pdf, $object, 0, $outputlangs);
754 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
755 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
757 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
758 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
762 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
765 $posy = $this->
_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
776 if (empty($conf->global->PROPAL_DISABLE_SIGNATURE)) {
781 $this->
_pagefoot($pdf, $object, $outputlangs);
782 if (method_exists($pdf,
'AliasNbPages')) {
783 $pdf->AliasNbPages();
787 if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) {
788 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
790 $already_merged = array();
791 foreach ($object->lines as $line) {
792 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
796 if ($conf->global->MAIN_MULTILANGS) {
797 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
799 $filetomerge->fetch_by_product($line->fk_product);
802 $already_merged[] = $line->fk_product;
805 $product->fetch($line->fk_product);
807 if ($product->entity != $conf->entity) {
808 $entity_product_file = $product->entity;
810 $entity_product_file = $conf->entity;
814 if (count($filetomerge->lines) > 0) {
815 foreach ($filetomerge->lines as $linefile) {
816 if (!empty($linefile->id) && !empty($linefile->file_name)) {
817 if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
818 if (!empty($conf->product->enabled)) {
819 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
820 } elseif (!empty($conf->service->enabled)) {
821 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
824 if (!empty($conf->product->enabled)) {
825 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
826 } elseif (!empty($conf->service->enabled)) {
827 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
831 dol_syslog(get_class($this).
':: upload_dir='.$filetomerge_dir, LOG_DEBUG);
833 $infile = $filetomerge_dir.
'/'.$linefile->file_name;
834 if (file_exists($infile) && is_readable($infile)) {
835 $pagecount = $pdf->setSourceFile($infile);
836 for ($i = 1; $i <= $pagecount; $i++) {
837 $tplIdx = $pdf->importPage($i);
838 if ($tplIdx !==
false) {
839 $s = $pdf->getTemplatesize($tplIdx);
840 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
841 $pdf->useTemplate($tplIdx);
843 setEventMessages(
null, array($infile.
' cannot be added, probably protected PDF'),
'warnings');
856 $pdf->Output($file,
'F');
859 $hookmanager->initHooks(array(
'pdfgeneration'));
860 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
862 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
864 $this->error = $hookmanager->error;
865 $this->errors = $hookmanager->errors;
868 if (!empty($conf->global->MAIN_UMASK)) {
869 @chmod($file, octdec($conf->global->MAIN_UMASK));
872 $this->result = array(
'fullpath'=>$file);
876 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
880 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PROP_OUTPUTDIR");
915 global $conf, $mysoc;
918 $pdf->SetFont(
'',
'', $default_font_size - 1);
921 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
922 $pdf->SetFont(
'',
'B', $default_font_size - 2);
923 $pdf->SetXY($this->marge_gauche, $posy);
924 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
926 $posy = $pdf->GetY() + 4;
930 if (!empty($conf->global->MAIN_PDF_DELIVERY_DATE_TEXT)) {
931 $displaydate =
"daytext";
933 $displaydate =
"day";
937 if (!empty($object->delivery_date)) {
938 $outputlangs->load(
"sendings");
939 $pdf->SetFont(
'',
'B', $default_font_size - 2);
940 $pdf->SetXY($this->marge_gauche, $posy);
941 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
942 $pdf->MultiCell(80, 4, $titre, 0,
'L');
943 $pdf->SetFont(
'',
'', $default_font_size - 2);
944 $pdf->SetXY($posxval, $posy);
945 $dlp =
dol_print_date($object->delivery_date, $displaydate,
false, $outputlangs,
true);
946 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
948 $posy = $pdf->GetY() + 1;
949 } elseif ($object->availability_code || $object->availability) {
950 $pdf->SetFont(
'',
'B', $default_font_size - 2);
951 $pdf->SetXY($this->marge_gauche, $posy);
952 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
953 $pdf->MultiCell(80, 4, $titre, 0,
'L');
954 $pdf->SetTextColor(0, 0, 0);
955 $pdf->SetFont(
'',
'', $default_font_size - 2);
956 $pdf->SetXY($posxval, $posy);
957 $lib_availability = $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) != (
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability);
958 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
959 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
961 $posy = $pdf->GetY() + 1;
965 if (empty($conf->global->PROPOSAL_PDF_HIDE_PAYMENTTERM) && ($object->cond_reglement_code || $object->cond_reglement)) {
966 $pdf->SetFont(
'',
'B', $default_font_size - 2);
967 $pdf->SetXY($this->marge_gauche, $posy);
968 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
969 $pdf->MultiCell(43, 4, $titre, 0,
'L');
971 $pdf->SetFont(
'',
'', $default_font_size - 2);
972 $pdf->SetXY($posxval, $posy);
973 $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);
974 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
975 if ($object->deposit_percent > 0) {
976 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement);
978 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
980 $posy = $pdf->GetY() + 3;
983 if (empty($conf->global->PROPOSAL_PDF_HIDE_PAYMENTMODE)) {
1001 if ($object->mode_reglement_code
1002 && $object->mode_reglement_code !=
'CHQ'
1003 && $object->mode_reglement_code !=
'VIR') {
1004 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1005 $pdf->SetXY($this->marge_gauche, $posy);
1006 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1007 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1008 $pdf->SetFont(
'',
'', $default_font_size - 2);
1009 $pdf->SetXY($posxval, $posy);
1010 $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);
1011 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1013 $posy = $pdf->GetY() + 2;
1017 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
1019 if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
1020 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
1022 if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
1024 $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
1026 $pdf->SetXY($this->marge_gauche, $posy);
1027 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1028 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
1029 $posy = $pdf->GetY() + 1;
1031 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
1032 $pdf->SetXY($this->marge_gauche, $posy);
1033 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1034 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1035 $posy = $pdf->GetY() + 2;
1038 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1039 $pdf->SetXY($this->marge_gauche, $posy);
1040 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1041 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1042 $posy = $pdf->GetY() + 1;
1044 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
1045 $pdf->SetXY($this->marge_gauche, $posy);
1046 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1047 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1048 $posy = $pdf->GetY() + 2;
1055 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
1056 if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER)) {
1057 $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1058 if (!empty($object->fk_bank)) {
1059 $bankid = $object->fk_bank;
1062 $account->fetch($bankid);
1064 $curx = $this->marge_gauche;
1067 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1090 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis =
null)
1093 global $conf, $mysoc;
1098 $pdf->SetFont(
'',
'', $default_font_size - 1);
1103 if ($this->page_largeur < 210) {
1106 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1112 $pdf->SetFillColor(255, 255, 255);
1113 $pdf->SetXY($col1x, $tab2_top + 0);
1114 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1116 $total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1117 $pdf->SetXY($col2x, $tab2_top + 0);
1118 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1121 $pdf->SetFillColor(248, 248, 248);
1123 $total_ttc = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1125 $this->atleastoneratenotnull = 0;
1126 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
1127 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1128 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) {
1134 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1135 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1139 foreach ($localtax_rate as $tvakey => $tvaval) {
1144 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1147 if (preg_match(
'/\*/', $tvakey)) {
1148 $tvakey = str_replace(
'*',
'', $tvakey);
1149 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1151 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1152 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1153 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1155 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1156 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1164 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1165 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1169 foreach ($localtax_rate as $tvakey => $tvaval) {
1176 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1179 if (preg_match(
'/\*/', $tvakey)) {
1180 $tvakey = str_replace(
'*',
'', $tvakey);
1181 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1183 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1184 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1185 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1187 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1188 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1195 foreach ($this->tva_array as $tvakey => $tvaval) {
1197 $this->atleastoneratenotnull++;
1200 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1203 if (preg_match(
'/\*/', $tvakey)) {
1204 $tvakey = str_replace(
'*',
'', $tvakey);
1205 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1207 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1210 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1212 $totalvat .= ($tvaval[
'vatcode'] ? $tvaval[
'vatcode'] :
vatrate($tvaval[
'vatrate'], 1)).$tvacompl;
1214 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1216 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1218 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1219 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1226 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1227 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1231 foreach ($localtax_rate as $tvakey => $tvaval) {
1236 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1239 if (preg_match(
'/\*/', $tvakey)) {
1240 $tvakey = str_replace(
'*',
'', $tvakey);
1241 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1243 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1245 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1246 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1247 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1248 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1256 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1257 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1261 foreach ($localtax_rate as $tvakey => $tvaval) {
1267 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1270 if (preg_match(
'/\*/', $tvakey)) {
1271 $tvakey = str_replace(
'*',
'', $tvakey);
1272 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1274 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1276 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1277 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1279 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1280 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1288 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1289 $pdf->SetTextColor(0, 0, 60);
1290 $pdf->SetFillColor(224, 224, 224);
1291 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1293 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1294 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1298 $pdf->SetTextColor(0, 0, 0);
1305 if ($deja_regle > 0) {
1308 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1309 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1311 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1312 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1331 $pdf->SetTextColor(0, 0, 60);
1332 $pdf->SetFillColor(224, 224, 224);
1333 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1334 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1336 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1337 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1339 $pdf->SetFont(
'',
'', $default_font_size - 1);
1340 $pdf->SetTextColor(0, 0, 0);
1344 return ($tab2_top + ($tab2_hl * $index));
1361 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1371 $currency = !empty($currency) ? $currency : $conf->currency;
1375 $pdf->SetTextColor(0, 0, 0);
1376 $pdf->SetFont(
'',
'', $default_font_size - 2);
1378 if (empty($hidetop)) {
1379 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1380 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1381 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1384 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1385 $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));
1389 $pdf->SetDrawColor(128, 128, 128);
1390 $pdf->SetFont(
'',
'', $default_font_size - 1);
1393 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1395 if (empty($hidetop)) {
1396 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1398 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1399 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1402 if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE)) {
1403 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1404 if (empty($hidetop)) {
1410 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
1411 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1412 if (empty($hidetop)) {
1414 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1415 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1419 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1420 if (empty($hidetop)) {
1421 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1422 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1425 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1426 if (empty($hidetop)) {
1427 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1428 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1431 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1432 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1433 if (empty($hidetop)) {
1434 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1436 $this->posxdiscount - $this->posxunit - 1,
1438 $outputlangs->transnoentities(
"Unit"),
1445 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1446 if (empty($hidetop)) {
1447 if ($this->atleastonediscount) {
1448 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1449 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1452 if ($this->atleastonediscount) {
1453 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1455 if (empty($hidetop)) {
1456 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1457 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
1472 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null)
1474 global $conf, $langs;
1476 $ltrdirection =
'L';
1477 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') $ltrdirection =
'R';
1480 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills"));
1486 $pdf->SetTextColor(0, 0, 60);
1487 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1489 $posy = $this->marge_haute;
1490 $posx = $this->page_largeur - $this->marge_droite - 100;
1492 $pdf->SetXY($this->marge_gauche, $posy);
1495 if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) {
1496 if ($this->emetteur->logo) {
1497 $logodir = $conf->mycompany->dir_output;
1498 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1499 $logodir = $conf->mycompany->multidir_output[$object->entity];
1501 if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) {
1502 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1504 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1506 if (is_readable($logo)) {
1508 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1510 $pdf->SetTextColor(200, 0, 0);
1511 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1512 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1513 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1516 $text = $this->emetteur->name;
1517 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1521 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1522 $pdf->SetXY($posx, $posy);
1523 $pdf->SetTextColor(0, 0, 60);
1524 $title = $outputlangs->transnoentities(
"PdfCommercialProposalTitle");
1525 $title .=
' '.$outputlangs->convToOutputCharset($object->ref);
1526 if ($object->statut == $object::STATUS_DRAFT) {
1527 $pdf->SetTextColor(128, 0, 0);
1528 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1530 $pdf->MultiCell(100, 4, $title,
'',
'R');
1532 $pdf->SetFont(
'',
'B', $default_font_size);
1542 $pdf->SetFont(
'',
'', $default_font_size - 2);
1544 if ($object->ref_client) {
1546 $pdf->SetXY($posx, $posy);
1547 $pdf->SetTextColor(0, 0, 60);
1548 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
1551 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
1552 $object->fetch_projet();
1553 if (!empty($object->project->ref)) {
1555 $pdf->SetXY($posx, $posy);
1556 $pdf->SetTextColor(0, 0, 60);
1557 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1561 if (!empty($conf->global->PDF_SHOW_PROJECT)) {
1562 $object->fetch_projet();
1563 if (!empty($object->project->ref)) {
1564 $outputlangs->load(
"projects");
1566 $pdf->SetXY($posx, $posy);
1567 $pdf->SetTextColor(0, 0, 60);
1568 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1572 if (!empty($conf->global->MAIN_PDF_DATE_TEXT)) {
1573 $displaydate =
"daytext";
1575 $displaydate =
"day";
1579 $pdf->SetXY($posx, $posy);
1580 $pdf->SetTextColor(0, 0, 60);
1581 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"DatePropal").
" : ".
dol_print_date($object->date, $displaydate,
false, $outputlangs,
true),
'',
'R');
1584 $pdf->SetXY($posx, $posy);
1585 $pdf->SetTextColor(0, 0, 60);
1586 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"DateEndPropal").
" : ".
dol_print_date($object->fin_validite, $displaydate,
false, $outputlangs,
true),
'',
'R');
1588 if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && $object->thirdparty->code_client) {
1590 $pdf->SetXY($posx, $posy);
1591 $pdf->SetTextColor(0, 0, 60);
1592 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1596 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1597 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1598 if (count($arrayidcontact) > 0) {
1599 $usertmp =
new User($this->
db);
1600 $usertmp->fetch($arrayidcontact[0]);
1602 $pdf->SetXY($posx, $posy);
1603 $pdf->SetTextColor(0, 0, 60);
1604 $pdf->MultiCell(100, 3, $langs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1612 $current_y = $pdf->getY();
1613 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3,
'R', $default_font_size);
1614 if ($current_y < $pdf->getY()) {
1615 $top_shift = $pdf->getY() - $current_y;
1620 $carac_emetteur =
'';
1622 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1623 if (count($arrayidcontact) > 0) {
1624 $object->fetch_user($arrayidcontact[0]);
1625 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1626 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)).
"\n";
1629 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1632 $posy = 42 + $top_shift;
1633 $posx = $this->marge_gauche;
1634 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1635 $posx = $this->page_largeur - $this->marge_droite - 80;
1640 if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
1641 $pdf->SetTextColor(0, 0, 0);
1642 $pdf->SetFont(
'',
'', $default_font_size - 2);
1643 $pdf->SetXY($posx, $posy - 5);
1644 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1645 $pdf->SetXY($posx, $posy);
1646 $pdf->SetFillColor(230, 230, 230);
1647 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1648 $pdf->SetTextColor(0, 0, 60);
1652 if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
1653 $pdf->SetXY($posx + 2, $posy + 3);
1654 $pdf->SetFont(
'',
'B', $default_font_size);
1655 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1656 $posy = $pdf->getY();
1660 $pdf->SetXY($posx + 2, $posy);
1661 $pdf->SetFont(
'',
'', $default_font_size - 1);
1662 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1666 $usecontact =
false;
1667 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1668 if (count($arrayidcontact) > 0) {
1670 $result = $object->fetch_contact($arrayidcontact[0]);
1674 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)))) {
1675 $thirdparty = $object->contact;
1677 $thirdparty = $object->thirdparty;
1683 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact, $mode, $object);
1687 if ($this->page_largeur < 210) {
1690 $posy = 42 + $top_shift;
1691 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1692 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1693 $posx = $this->marge_gauche;
1697 if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
1698 $pdf->SetTextColor(0, 0, 0);
1699 $pdf->SetFont(
'',
'', $default_font_size - 2);
1700 $pdf->SetXY($posx + 2, $posy - 5);
1701 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1702 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1706 $pdf->SetXY($posx + 2, $posy + 3);
1707 $pdf->SetFont(
'',
'B', $default_font_size);
1708 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1710 $posy = $pdf->getY();
1713 $pdf->SetFont(
'',
'', $default_font_size - 1);
1714 $pdf->SetXY($posx + 2, $posy);
1715 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1718 $pdf->SetTextColor(0, 0, 0);
1732 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1735 $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1736 return pdf_pagefoot($pdf, $outputlangs,
'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);
1755 $tab_top = $posy + 4;
1759 $largcol = ($this->page_largeur - $this->marge_droite - $posx);
1763 $pdf->SetFillColor(255, 255, 255);
1764 $pdf->SetXY($posx, $tab_top + 0);
1765 $pdf->SetFont(
'',
'', $default_font_size - 2);
1766 $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities(
"ProposalCustomerSignature"), 0,
'L', 1);
1768 $pdf->SetXY($posx, $tab_top + $tab_hl);
1769 $pdf->MultiCell($largcol, $tab_hl * 3,
'', 1,
'R');
1770 if (!empty($conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) {
1771 $pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl, $largcol, $tab_hl * 3);
1774 return ($tab_hl * 7);