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';
69 public $update_main_doc_field;
80 public $phpmin = array(7, 0);
86 public $version =
'dolibarr';
106 public $marge_gauche;
111 public $marge_droite;
137 global $conf, $langs, $mysoc;
140 $langs->loadLangs(array(
"main",
"bills"));
143 $this->
name =
"azur";
144 $this->
description = $langs->trans(
'DocModelAzurDescription');
145 $this->update_main_doc_field = 1;
150 $this->page_largeur = $formatarray[
'width'];
151 $this->page_hauteur = $formatarray[
'height'];
152 $this->format = array($this->page_largeur, $this->page_hauteur);
158 $this->option_logo = 1;
159 $this->option_tva = 1;
160 $this->option_modereg = 1;
161 $this->option_condreg = 1;
162 $this->option_multilang = 1;
163 $this->option_escompte = 0;
164 $this->option_credit_note = 0;
165 $this->option_freetext = 1;
166 $this->option_draft_watermark = 1;
167 $this->watermark =
'';
170 $this->emetteur = $mysoc;
171 if (empty($this->emetteur->country_code)) {
172 $this->emetteur->country_code = substr($langs->defaultlang, -2);
176 $this->posxdesc = $this->marge_gauche + 1;
177 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
178 $this->posxtva = 101;
180 $this->posxqty = 135;
181 $this->posxunit = 151;
183 $this->posxtva = 106;
185 $this->posxqty = 145;
186 $this->posxunit = 162;
188 $this->posxdiscount = 162;
189 $this->postotalht = 174;
190 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
191 $this->posxtva = $this->posxup;
193 $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
194 if ($this->page_largeur < 210) {
195 $this->posxpicture -= 20;
196 $this->posxtva -= 20;
198 $this->posxqty -= 20;
199 $this->posxunit -= 20;
200 $this->posxdiscount -= 20;
201 $this->postotalht -= 20;
204 $this->tva = array();
205 $this->tva_array = array();
206 $this->localtax1 = array();
207 $this->localtax2 = array();
208 $this->atleastoneratenotnull = 0;
209 $this->atleastonediscount = 0;
224 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
227 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
229 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
231 if (!is_object($outputlangs)) {
232 $outputlangs = $langs;
235 if (!empty($conf->global->MAIN_USE_FPDF)) {
236 $outputlangs->charset_output =
'ISO-8859-1';
240 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"propal",
"products"));
242 global $outputlangsbis;
243 $outputlangsbis =
null;
244 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
245 $outputlangsbis =
new Translate(
'', $conf);
246 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
247 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
251 if ($object->statut == $object::STATUS_DRAFT &&
getDolGlobalString(
'PROPALE_DRAFT_WATERMARK')) {
255 $nblines = count($object->lines);
258 $realpatharray = array();
259 $this->atleastonephoto =
false;
260 if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE)) {
263 for ($i = 0; $i < $nblines; $i++) {
264 if (empty($object->lines[$i]->fk_product)) {
268 $objphoto->fetch($object->lines[$i]->fk_product);
271 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
272 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
274 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
275 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
280 foreach ($pdir as $midir) {
282 if ($conf->entity != $objphoto->entity) {
283 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
285 $dir = $conf->product->dir_output.
'/'.$midir;
287 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
289 if ($obj[
'photo_vignette']) {
290 $filename = $obj[
'photo_vignette'];
292 $filename = $obj[
'photo'];
295 $filename = $obj[
'photo'];
298 $realpath = $dir.$filename;
300 $this->atleastonephoto =
true;
305 if ($realpath && $arephoto) {
306 $realpatharray[$i] = $realpath;
311 if (count($realpatharray) == 0) {
312 $this->posxpicture = $this->posxtva;
315 if ($conf->propal->multidir_output[$conf->entity]) {
316 $object->fetch_thirdparty();
321 if ($object->specimen) {
322 $dir = $conf->propal->multidir_output[$conf->entity];
323 $file = $dir.
"/SPECIMEN.pdf";
326 $dir = $conf->propal->multidir_output[$object->entity].
"/".$objectref;
327 $file = $dir.
"/".$objectref.
".pdf";
330 if (!file_exists($dir)) {
332 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
337 if (file_exists($dir)) {
339 if (!is_object($hookmanager)) {
340 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
343 $hookmanager->initHooks(array(
'pdfgeneration'));
344 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
346 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
349 $nblines = count($object->lines);
355 $pdf->SetAutoPageBreak(1, 0);
357 if (class_exists(
'TCPDF')) {
358 $pdf->setPrintHeader(
false);
359 $pdf->setPrintFooter(
false);
363 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
364 $logodir = $conf->mycompany->dir_output;
365 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
366 $logodir = $conf->mycompany->multidir_output[$object->entity];
368 $pagecount = $pdf->setSourceFile($logodir.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
369 $tplidx = $pdf->importPage(1);
374 $pdf->SetDrawColor(128, 128, 128);
376 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
377 $pdf->SetSubject($outputlangs->transnoentities(
"PdfCommercialProposalTitle"));
378 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
379 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
380 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
382 $pdf->SetCompression(
false);
385 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
388 for ($i = 0; $i < $nblines; $i++) {
389 if ($object->lines[$i]->remise_percent) {
390 $this->atleastonediscount++;
393 if (empty($this->atleastonediscount)) {
394 $delta = ($this->postotalht - $this->posxdiscount);
395 $this->posxpicture += $delta;
396 $this->posxtva += $delta;
397 $this->posxup += $delta;
398 $this->posxqty += $delta;
399 $this->posxunit += $delta;
400 $this->posxdiscount += $delta;
406 if (!empty($tplidx)) {
407 $pdf->useTemplate($tplidx);
411 $heightforinfotot = 40;
412 $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (
pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities(
"ProposalCustomerSignature")) + 10) : 0;
413 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
414 $heightforfooter = $this->marge_basse + 8;
415 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
416 $heightforfooter += 6;
420 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs, $outputlangsbis);
421 $pdf->SetFont(
'',
'', $default_font_size - 1);
422 $pdf->MultiCell(0, 3,
'');
423 $pdf->SetTextColor(0, 0, 0);
426 $tab_top = 90 + $top_shift;
427 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
430 $height_incoterms = 0;
432 $desc_incoterms = $object->getIncotermsForPDF();
433 if ($desc_incoterms) {
436 $pdf->SetFont(
'',
'', $default_font_size - 1);
437 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
438 $nexY = $pdf->GetY();
439 $height_incoterms = $nexY - $tab_top;
442 $pdf->SetDrawColor(192, 192, 192);
443 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
445 $tab_top = $nexY + 6;
446 $height_incoterms += 4;
451 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
452 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
454 if (is_object($object->thirdparty)) {
455 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
456 $salerepobj =
new User($this->
db);
457 $salerepobj->fetch($salereparray[0][
'id']);
458 if (!empty($salerepobj->signature)) {
459 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
464 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
465 if (!empty($extranote)) {
468 if (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0) {
469 $tmpuser =
new User($this->
db);
470 $tmpuser->fetch($object->user_author_id);
473 $creator_info = $langs->trans(
"CaseFollowedBy").
' '.$tmpuser->getFullName($langs);
474 if ($tmpuser->email) $creator_info .=
', '.$langs->trans(
"EMail").
': '.$tmpuser->email;
475 if ($tmpuser->office_phone) $creator_info .=
', '.$langs->trans(
"Phone").
': '.$tmpuser->office_phone;
488 $pdf->SetFont(
'',
'', $default_font_size - 1);
489 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
490 $nexY = $pdf->GetY();
491 $height_note = $nexY - $tab_top;
494 $pdf->SetDrawColor(192, 192, 192);
495 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
497 $tab_top = $nexY + 6;
500 $iniY = $tab_top + 7;
501 $curY = $tab_top + 7;
502 $nexY = $tab_top + 7;
505 for ($i = 0; $i < $nblines; $i++) {
507 $pdf->SetFont(
'',
'', $default_font_size - 1);
508 $pdf->SetTextColor(0, 0, 0);
511 $imglinesize = array();
512 if (!empty($realpatharray[$i])) {
516 $pdf->setTopMargin($tab_top_newpage);
517 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot);
518 $pageposbefore = $pdf->getPage();
520 $showpricebeforepagebreak = 1;
522 $posYAfterDescription = 0;
525 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
526 $pdf->AddPage(
'',
'',
true);
527 if (!empty($tplidx)) {
528 $pdf->useTemplate($tplidx);
531 $this->
_pagehead($pdf, $object, 0, $outputlangs);
533 $pdf->setPage($pageposbefore + 1);
535 $curY = $tab_top_newpage;
538 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
539 $showpricebeforepagebreak = 1;
541 $showpricebeforepagebreak = 0;
545 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
546 $curX = $this->posxpicture - 1;
547 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
549 $posYAfterImage = $curY + $imglinesize[
'height'];
553 $curX = $this->posxdesc - 1;
555 $pdf->startTransaction();
556 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
557 $pageposafter = $pdf->getPage();
558 if ($pageposafter > $pageposbefore) {
559 $pdf->rollbackTransaction(
true);
560 $pageposafter = $pageposbefore;
562 $pdf->setPageOrientation(
'', 1, $heightforfooter);
563 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
565 $pageposafter = $pdf->getPage();
566 $posyafter = $pdf->GetY();
568 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot))) {
569 if ($i == ($nblines - 1)) {
570 $pdf->AddPage(
'',
'',
true);
571 if (!empty($tplidx)) {
572 $pdf->useTemplate($tplidx);
575 $this->
_pagehead($pdf, $object, 0, $outputlangs);
577 $pdf->setPage($pageposafter + 1);
583 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
584 $showpricebeforepagebreak = 1;
586 $showpricebeforepagebreak = 0;
591 $pdf->commitTransaction();
593 $posYAfterDescription = $pdf->GetY();
595 $nexY = $pdf->GetY();
596 $pageposafter = $pdf->getPage();
598 $pdf->setPage($pageposbefore);
599 $pdf->setTopMargin($this->marge_haute);
600 $pdf->setPageOrientation(
'', 1, 0);
603 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
604 $pdf->setPage($pageposafter);
605 $curY = $tab_top_newpage;
608 $pdf->SetFont(
'',
'', $default_font_size - 1);
611 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
613 $pdf->SetXY($this->posxtva - 5, $curY);
614 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
619 $pdf->SetXY($this->posxup, $curY);
620 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
624 $pdf->SetXY($this->posxqty, $curY);
625 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
628 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
629 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
630 $pdf->SetXY($this->posxunit, $curY);
631 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
635 $pdf->SetXY($this->posxdiscount, $curY);
636 if ($object->lines[$i]->remise_percent) {
637 $pdf->SetXY($this->posxdiscount - 2, $curY);
639 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
644 $pdf->SetXY($this->postotalht, $curY);
645 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
648 if (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
649 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
651 $tvaligne = $object->lines[$i]->total_tva;
654 $localtax1ligne = $object->lines[$i]->total_localtax1;
655 $localtax2ligne = $object->lines[$i]->total_localtax2;
656 $localtax1_rate = $object->lines[$i]->localtax1_tx;
657 $localtax2_rate = $object->lines[$i]->localtax2_tx;
658 $localtax1_type = $object->lines[$i]->localtax1_type;
659 $localtax2_type = $object->lines[$i]->localtax2_type;
661 if ($object->remise_percent) {
662 $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
664 if ($object->remise_percent) {
665 $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
667 if ($object->remise_percent) {
668 $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
671 $vatrate = (string) $object->lines[$i]->tva_tx;
674 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
675 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
677 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
678 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
682 if ($localtax1_type && $localtax1ligne != 0) {
683 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
684 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
686 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
689 if ($localtax2_type && $localtax2ligne != 0) {
690 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
691 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
693 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
697 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
702 if (!isset($this->tva[$vatrate])) {
703 $this->tva[$vatrate] = 0;
705 $this->tva[$vatrate] += $tvaligne;
706 $vatcode = $object->lines[$i]->vat_src_code;
707 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
708 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
710 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
712 if ($posYAfterImage > $posYAfterDescription) {
713 $nexY = $posYAfterImage;
717 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
718 $pdf->setPage($pageposafter);
719 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
721 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
722 $pdf->SetLineStyle(array(
'dash'=>0));
728 while ($pagenb < $pageposafter) {
729 $pdf->setPage($pagenb);
731 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
733 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
735 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
737 $pdf->setPage($pagenb);
738 $pdf->setPageOrientation(
'', 1, 0);
740 $this->
_pagehead($pdf, $object, 0, $outputlangs);
742 if (!empty($tplidx)) {
743 $pdf->useTemplate($tplidx);
746 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
748 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
750 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
752 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
755 if (!empty($tplidx)) {
756 $pdf->useTemplate($tplidx);
760 $this->
_pagehead($pdf, $object, 0, $outputlangs);
767 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
768 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
770 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
771 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
775 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
778 $posy = $this->
_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
789 if (empty($conf->global->PROPAL_DISABLE_SIGNATURE)) {
794 $this->
_pagefoot($pdf, $object, $outputlangs);
795 if (method_exists($pdf,
'AliasNbPages')) {
796 $pdf->AliasNbPages();
800 if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL)) {
801 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
803 $already_merged = array();
804 foreach ($object->lines as $line) {
805 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
810 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
812 $filetomerge->fetch_by_product($line->fk_product);
815 $already_merged[] = $line->fk_product;
818 $product->fetch($line->fk_product);
820 if ($product->entity != $conf->entity) {
821 $entity_product_file = $product->entity;
823 $entity_product_file = $conf->entity;
827 if (count($filetomerge->lines) > 0) {
828 foreach ($filetomerge->lines as $linefile) {
829 if (!empty($linefile->id) && !empty($linefile->file_name)) {
832 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
834 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
838 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
840 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product');
844 dol_syslog(get_class($this).
':: upload_dir='.$filetomerge_dir, LOG_DEBUG);
846 $infile = $filetomerge_dir.
'/'.$linefile->file_name;
847 if (file_exists($infile) && is_readable($infile)) {
848 $pagecount = $pdf->setSourceFile($infile);
849 for ($i = 1; $i <= $pagecount; $i++) {
850 $tplIdx = $pdf->importPage($i);
851 if ($tplIdx !==
false) {
852 $s = $pdf->getTemplatesize($tplIdx);
853 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
854 $pdf->useTemplate($tplIdx);
856 setEventMessages(
null, array($infile.
' cannot be added, probably protected PDF'),
'warnings');
869 $pdf->Output($file,
'F');
872 $hookmanager->initHooks(array(
'pdfgeneration'));
873 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
875 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
877 $this->error = $hookmanager->error;
878 $this->errors = $hookmanager->errors;
881 if (!empty($conf->global->MAIN_UMASK)) {
882 @chmod($file, octdec($conf->global->MAIN_UMASK));
885 $this->result = array(
'fullpath'=>$file);
889 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
893 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PROP_OUTPUTDIR");
928 global $conf, $mysoc;
931 $pdf->SetFont(
'',
'', $default_font_size - 1);
933 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
936 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
937 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
938 $pdf->SetXY($this->marge_gauche, $posy);
939 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
941 $posy = $pdf->GetY() + 4;
945 if (!empty($conf->global->MAIN_PDF_DELIVERY_DATE_TEXT)) {
946 $displaydate =
"daytext";
948 $displaydate =
"day";
952 if (!empty($object->delivery_date)) {
953 $outputlangs->load(
"sendings");
954 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
955 $pdf->SetXY($this->marge_gauche, $posy);
956 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
957 $pdf->MultiCell(80, 4, $titre, 0,
'L');
958 $pdf->SetFont(
'',
'', $default_font_size -$diffsizetitle);
959 $pdf->SetXY($posxval, $posy);
960 $dlp =
dol_print_date($object->delivery_date, $displaydate,
false, $outputlangs,
true);
961 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
963 $posy = $pdf->GetY() + 1;
964 } elseif ($object->availability_code || $object->availability) {
965 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
966 $pdf->SetXY($this->marge_gauche, $posy);
967 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
968 $pdf->MultiCell(80, 4, $titre, 0,
'L');
969 $pdf->SetTextColor(0, 0, 0);
970 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
971 $pdf->SetXY($posxval, $posy);
972 $lib_availability = $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) != (
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability);
973 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
974 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
976 $posy = $pdf->GetY() + 1;
980 if (empty($conf->global->PROPOSAL_PDF_HIDE_DELIVERYMODE) && $object->shipping_method_id > 0) {
981 $outputlangs->load(
"sendings");
983 $shipping_method_id = $object->shipping_method_id;
984 if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && !empty($this->emetteur->shipping_method_id)) {
985 $shipping_method_id = $this->emetteur->shipping_method_id;
987 $shipping_method_code =
dol_getIdFromCode($this->
db, $shipping_method_id,
'c_shipment_mode',
'rowid',
'code');
988 $shipping_method_label =
dol_getIdFromCode($this->
db, $shipping_method_id,
'c_shipment_mode',
'rowid',
'libelle');
990 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
991 $pdf->SetXY($this->marge_gauche, $posy);
992 $titre = $outputlangs->transnoentities(
"SendingMethod").
':';
993 $pdf->MultiCell(43, 4, $titre, 0,
'L');
995 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
996 $pdf->SetXY($posxval, $posy);
997 $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;
998 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
999 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1001 $posy = $pdf->GetY() + 1;
1005 if (empty($conf->global->PROPOSAL_PDF_HIDE_PAYMENTTERM) && $object->cond_reglement_code) {
1006 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1007 $pdf->SetXY($this->marge_gauche, $posy);
1008 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1009 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1011 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1012 $pdf->SetXY($posxval, $posy);
1013 $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);
1014 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1015 if ($object->deposit_percent > 0) {
1016 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement);
1018 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1020 $posy = $pdf->GetY() + 3;
1023 if (empty($conf->global->PROPOSAL_PDF_HIDE_PAYMENTMODE)) {
1025 if ($object->mode_reglement_code
1026 && $object->mode_reglement_code !=
'CHQ'
1027 && $object->mode_reglement_code !=
'VIR') {
1028 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1029 $pdf->SetXY($this->marge_gauche, $posy);
1030 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1031 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1032 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1033 $pdf->SetXY($posxval, $posy);
1034 $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);
1035 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1037 $posy = $pdf->GetY() + 2;
1041 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
1043 if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
1044 if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
1046 $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
1048 $pdf->SetXY($this->marge_gauche, $posy);
1049 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1050 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
1051 $posy = $pdf->GetY() + 1;
1053 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
1054 $pdf->SetXY($this->marge_gauche, $posy);
1055 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1056 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
1057 $posy = $pdf->GetY() + 2;
1060 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
1061 $pdf->SetXY($this->marge_gauche, $posy);
1062 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1063 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
1064 $posy = $pdf->GetY() + 1;
1066 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
1067 $pdf->SetXY($this->marge_gauche, $posy);
1068 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1069 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
1070 $posy = $pdf->GetY() + 2;
1077 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
1078 if (!empty($object->fk_account) || !empty($object->fk_bank) ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
1079 $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1080 if (!empty($object->fk_bank)) {
1081 $bankid = $object->fk_bank;
1084 $account->fetch($bankid);
1086 $curx = $this->marge_gauche;
1089 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1112 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis =
null)
1115 global $conf, $mysoc;
1120 $pdf->SetFont(
'',
'', $default_font_size - 1);
1125 if ($this->page_largeur < 210) {
1128 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1134 $pdf->SetFillColor(255, 255, 255);
1135 $pdf->SetXY($col1x, $tab2_top + 0);
1136 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1138 $total_ht = ((
isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1139 $pdf->SetXY($col2x, $tab2_top + 0);
1140 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1143 $pdf->SetFillColor(248, 248, 248);
1145 $total_ttc = (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1147 $this->atleastoneratenotnull = 0;
1148 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
1149 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1150 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) {
1156 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1157 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1161 foreach ($localtax_rate as $tvakey => $tvaval) {
1166 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1169 if (preg_match(
'/\*/', $tvakey)) {
1170 $tvakey = str_replace(
'*',
'', $tvakey);
1171 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1173 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1174 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1175 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1177 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1178 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1186 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1187 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1191 foreach ($localtax_rate as $tvakey => $tvaval) {
1198 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1201 if (preg_match(
'/\*/', $tvakey)) {
1202 $tvakey = str_replace(
'*',
'', $tvakey);
1203 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1205 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1206 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1207 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1209 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1210 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1217 foreach ($this->tva_array as $tvakey => $tvaval) {
1219 $this->atleastoneratenotnull++;
1222 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1225 if (preg_match(
'/\*/', $tvakey)) {
1226 $tvakey = str_replace(
'*',
'', $tvakey);
1227 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1229 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1232 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1234 $totalvat .= ($tvaval[
'vatcode'] ? $tvaval[
'vatcode'] :
vatrate($tvaval[
'vatrate'], 1)).$tvacompl;
1236 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1238 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1240 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1241 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1248 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1249 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1253 foreach ($localtax_rate as $tvakey => $tvaval) {
1258 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1261 if (preg_match(
'/\*/', $tvakey)) {
1262 $tvakey = str_replace(
'*',
'', $tvakey);
1263 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1265 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1267 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1268 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1269 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1270 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1278 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1279 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1283 foreach ($localtax_rate as $tvakey => $tvaval) {
1289 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1292 if (preg_match(
'/\*/', $tvakey)) {
1293 $tvakey = str_replace(
'*',
'', $tvakey);
1294 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1296 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1298 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1299 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1301 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1302 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1310 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1311 $pdf->SetTextColor(0, 0, 60);
1312 $pdf->SetFillColor(224, 224, 224);
1313 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1315 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1316 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1320 $pdf->SetTextColor(0, 0, 0);
1327 if ($deja_regle > 0) {
1330 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1331 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1333 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1334 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1353 $pdf->SetTextColor(0, 0, 60);
1354 $pdf->SetFillColor(224, 224, 224);
1355 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1356 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1358 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1359 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1361 $pdf->SetFont(
'',
'', $default_font_size - 1);
1362 $pdf->SetTextColor(0, 0, 0);
1366 return ($tab2_top + ($tab2_hl * $index));
1383 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1393 $currency = !empty($currency) ? $currency : $conf->currency;
1397 $pdf->SetTextColor(0, 0, 0);
1398 $pdf->SetFont(
'',
'', $default_font_size - 2);
1400 if (empty($hidetop)) {
1401 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1402 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1403 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1406 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1407 $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));
1411 $pdf->SetDrawColor(128, 128, 128);
1412 $pdf->SetFont(
'',
'', $default_font_size - 1);
1415 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1417 if (empty($hidetop)) {
1418 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1420 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1421 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1424 if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE)) {
1425 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1426 if (empty($hidetop)) {
1432 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
1433 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1434 if (empty($hidetop)) {
1436 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1437 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1441 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1442 if (empty($hidetop)) {
1443 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1444 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1447 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1448 if (empty($hidetop)) {
1449 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1450 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1453 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1454 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1455 if (empty($hidetop)) {
1456 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1458 $this->posxdiscount - $this->posxunit - 1,
1460 $outputlangs->transnoentities(
"Unit"),
1467 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1468 if (empty($hidetop)) {
1469 if ($this->atleastonediscount) {
1470 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1471 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1474 if ($this->atleastonediscount) {
1475 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1477 if (empty($hidetop)) {
1478 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1479 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1494 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null)
1496 global $conf, $langs;
1498 $ltrdirection =
'L';
1499 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') $ltrdirection =
'R';
1502 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills"));
1508 $pdf->SetTextColor(0, 0, 60);
1509 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1511 $posy = $this->marge_haute;
1512 $posx = $this->page_largeur - $this->marge_droite - 100;
1514 $pdf->SetXY($this->marge_gauche, $posy);
1517 if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) {
1518 if ($this->emetteur->logo) {
1519 $logodir = $conf->mycompany->dir_output;
1520 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1521 $logodir = $conf->mycompany->multidir_output[$object->entity];
1523 if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) {
1524 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1526 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1528 if (is_readable($logo)) {
1530 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1532 $pdf->SetTextColor(200, 0, 0);
1533 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1534 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1535 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1538 $text = $this->emetteur->name;
1539 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1543 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1544 $pdf->SetXY($posx, $posy);
1545 $pdf->SetTextColor(0, 0, 60);
1546 $title = $outputlangs->transnoentities(
"PdfCommercialProposalTitle");
1547 $title .=
' '.$outputlangs->convToOutputCharset($object->ref);
1548 if ($object->statut == $object::STATUS_DRAFT) {
1549 $pdf->SetTextColor(128, 0, 0);
1550 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1552 $pdf->MultiCell(100, 4, $title,
'',
'R');
1554 $pdf->SetFont(
'',
'B', $default_font_size);
1564 $pdf->SetFont(
'',
'', $default_font_size - 2);
1566 if ($object->ref_client) {
1568 $pdf->SetXY($posx, $posy);
1569 $pdf->SetTextColor(0, 0, 60);
1570 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
1573 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
1574 $object->fetch_projet();
1575 if (!empty($object->project->ref)) {
1577 $pdf->SetXY($posx, $posy);
1578 $pdf->SetTextColor(0, 0, 60);
1579 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1583 if (!empty($conf->global->PDF_SHOW_PROJECT)) {
1584 $object->fetch_projet();
1585 if (!empty($object->project->ref)) {
1586 $outputlangs->load(
"projects");
1588 $pdf->SetXY($posx, $posy);
1589 $pdf->SetTextColor(0, 0, 60);
1590 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1594 if (!empty($conf->global->MAIN_PDF_DATE_TEXT)) {
1595 $displaydate =
"daytext";
1597 $displaydate =
"day";
1601 $pdf->SetXY($posx, $posy);
1602 $pdf->SetTextColor(0, 0, 60);
1603 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"DatePropal").
" : ".
dol_print_date($object->date, $displaydate,
false, $outputlangs,
true),
'',
'R');
1606 $pdf->SetXY($posx, $posy);
1607 $pdf->SetTextColor(0, 0, 60);
1608 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"DateEndPropal").
" : ".
dol_print_date($object->fin_validite, $displaydate,
false, $outputlangs,
true),
'',
'R');
1610 if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && $object->thirdparty->code_client) {
1612 $pdf->SetXY($posx, $posy);
1613 $pdf->SetTextColor(0, 0, 60);
1614 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1618 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1619 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1620 if (count($arrayidcontact) > 0) {
1621 $usertmp =
new User($this->
db);
1622 $usertmp->fetch($arrayidcontact[0]);
1624 $pdf->SetXY($posx, $posy);
1625 $pdf->SetTextColor(0, 0, 60);
1626 $pdf->MultiCell(100, 3, $langs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1634 $current_y = $pdf->getY();
1635 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3,
'R', $default_font_size);
1636 if ($current_y < $pdf->getY()) {
1637 $top_shift = $pdf->getY() - $current_y;
1642 $carac_emetteur =
'';
1644 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1645 if (count($arrayidcontact) > 0) {
1646 $object->fetch_user($arrayidcontact[0]);
1647 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1648 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)).
"\n";
1651 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1654 $posy = 42 + $top_shift;
1655 $posx = $this->marge_gauche;
1656 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1657 $posx = $this->page_largeur - $this->marge_droite - 80;
1662 if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
1663 $pdf->SetTextColor(0, 0, 0);
1664 $pdf->SetFont(
'',
'', $default_font_size - 2);
1665 $pdf->SetXY($posx, $posy - 5);
1666 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1667 $pdf->SetXY($posx, $posy);
1668 $pdf->SetFillColor(230, 230, 230);
1669 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1670 $pdf->SetTextColor(0, 0, 60);
1674 if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
1675 $pdf->SetXY($posx + 2, $posy + 3);
1676 $pdf->SetFont(
'',
'B', $default_font_size);
1677 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1678 $posy = $pdf->getY();
1682 $pdf->SetXY($posx + 2, $posy);
1683 $pdf->SetFont(
'',
'', $default_font_size - 1);
1684 $pdf->MultiCell(80, 4, $carac_emetteur, 0, $ltrdirection);
1688 $usecontact =
false;
1689 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1690 if (count($arrayidcontact) > 0) {
1692 $result = $object->fetch_contact($arrayidcontact[0]);
1696 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)))) {
1697 $thirdparty = $object->contact;
1699 $thirdparty = $object->thirdparty;
1705 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact, $mode, $object);
1709 if ($this->page_largeur < 210) {
1712 $posy = 42 + $top_shift;
1713 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1714 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1715 $posx = $this->marge_gauche;
1719 if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
1720 $pdf->SetTextColor(0, 0, 0);
1721 $pdf->SetFont(
'',
'', $default_font_size - 2);
1722 $pdf->SetXY($posx + 2, $posy - 5);
1723 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1724 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1728 $pdf->SetXY($posx + 2, $posy + 3);
1729 $pdf->SetFont(
'',
'B', $default_font_size);
1730 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0, $ltrdirection);
1732 $posy = $pdf->getY();
1735 $pdf->SetFont(
'',
'', $default_font_size - 1);
1736 $pdf->SetXY($posx + 2, $posy);
1737 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1740 $pdf->SetTextColor(0, 0, 0);
1754 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1756 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1757 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);
1776 $tab_top = $posy + 4;
1780 $largcol = ($this->page_largeur - $this->marge_droite - $posx);
1784 $pdf->SetFillColor(255, 255, 255);
1785 $pdf->SetXY($posx, $tab_top + 0);
1786 $pdf->SetFont(
'',
'', $default_font_size - 2);
1787 $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities(
"ProposalCustomerSignature"), 0,
'L', 1);
1789 $pdf->SetXY($posx, $tab_top + $tab_hl);
1790 $pdf->MultiCell($largcol, $tab_hl * 3,
'', 1,
'R');
1791 if (!empty($conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) {
1792 $pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl, $largcol, $tab_hl * 3);
1795 return ($tab_hl * 7);