33 require_once DOL_DOCUMENT_ROOT.
'/core/modules/propale/modules_propale.php';
34 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
63 public $update_main_doc_field;
74 public $phpmin = array(5, 6);
80 public $version =
'dolibarr';
100 public $marge_gauche;
105 public $marge_droite;
131 global $conf, $langs, $mysoc;
134 $langs->loadLangs(array(
"main",
"bills"));
137 $this->
name =
"azur";
138 $this->
description = $langs->trans(
'DocModelAzurDescription');
139 $this->update_main_doc_field = 1;
144 $this->page_largeur = $formatarray[
'width'];
145 $this->page_hauteur = $formatarray[
'height'];
146 $this->format = array($this->page_largeur, $this->page_hauteur);
147 $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
148 $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
149 $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
150 $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
152 $this->option_logo = 1;
153 $this->option_tva = 1;
154 $this->option_modereg = 1;
155 $this->option_condreg = 1;
156 $this->option_codeproduitservice = 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;
164 $this->emetteur = $mysoc;
165 if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2);
168 $this->posxdesc = $this->marge_gauche + 1;
169 if (!empty($conf->global->PRODUCT_USE_UNITS))
171 $this->posxtva = 101;
173 $this->posxqty = 135;
174 $this->posxunit = 151;
176 $this->posxtva = 106;
178 $this->posxqty = 145;
179 $this->posxunit = 162;
181 $this->posxdiscount = 162;
182 $this->postotalht = 174;
183 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva = $this->posxup;
184 $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
185 if ($this->page_largeur < 210)
187 $this->posxpicture -= 20;
188 $this->posxtva -= 20;
190 $this->posxqty -= 20;
191 $this->posxunit -= 20;
192 $this->posxdiscount -= 20;
193 $this->postotalht -= 20;
196 $this->tva = array();
197 $this->localtax1 = array();
198 $this->localtax2 = array();
199 $this->atleastoneratenotnull = 0;
200 $this->atleastonediscount = 0;
215 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
218 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
220 if (!is_object($outputlangs)) $outputlangs = $langs;
222 if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output =
'ISO-8859-1';
225 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"propal",
"products"));
227 $nblines = count($object->lines);
230 $realpatharray = array();
231 if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
235 for ($i = 0; $i < $nblines; $i++)
237 if (empty($object->lines[$i]->fk_product))
continue;
239 $objphoto->fetch($object->lines[$i]->fk_product);
241 if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
243 $pdir[0] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
244 $pdir[1] =
get_exdir(0, 0, 0, 0, $objphoto,
'product').dol_sanitizeFileName($objphoto->ref).
'/';
246 $pdir[0] =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
247 $pdir[1] =
get_exdir($objphoto->id, 2, 0, 0, $objphoto,
'product').$objphoto->id.
"/photos/";
251 foreach ($pdir as $midir)
255 if ($conf->product->entity != $objphoto->entity) {
256 $dir = $conf->product->multidir_output[$objphoto->entity].
'/'.$midir;
258 $dir = $conf->product->dir_output.
'/'.$midir;
261 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj)
263 if (empty($conf->global->CAT_HIGH_QUALITY_IMAGES))
265 if ($obj[
'photo_vignette'])
267 $filename = $obj[
'photo_vignette'];
269 $filename = $obj[
'photo'];
272 $filename = $obj[
'photo'];
275 $realpath = $dir.$filename;
281 if ($realpath && $arephoto) $realpatharray[$i] = $realpath;
285 if (count($realpatharray) == 0) $this->posxpicture = $this->posxtva;
287 if ($conf->propal->multidir_output[$conf->entity])
289 $object->fetch_thirdparty();
294 if ($object->specimen)
296 $dir = $conf->propal->multidir_output[$conf->entity];
297 $file = $dir.
"/SPECIMEN.pdf";
300 $dir = $conf->propal->multidir_output[$object->entity].
"/".$objectref;
301 $file = $dir.
"/".$objectref.
".pdf";
304 if (!file_exists($dir))
308 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
313 if (file_exists($dir))
316 if (!is_object($hookmanager))
318 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
321 $hookmanager->initHooks(array(
'pdfgeneration'));
322 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
324 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
329 $pdf->SetAutoPageBreak(1, 0);
331 if (class_exists(
'TCPDF'))
333 $pdf->setPrintHeader(
false);
334 $pdf->setPrintFooter(
false);
338 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
340 $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
341 $tplidx = $pdf->importPage(1);
346 $pdf->SetDrawColor(128, 128, 128);
348 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
349 $pdf->SetSubject($outputlangs->transnoentities(
"PdfCommercialProposalTitle"));
350 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
351 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
352 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfCommercialProposalTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
353 if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(
false);
355 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
358 for ($i = 0; $i < $nblines; $i++)
360 if ($object->lines[$i]->remise_percent)
362 $this->atleastonediscount++;
365 if (empty($this->atleastonediscount))
367 $delta = ($this->postotalht - $this->posxdiscount);
368 $this->posxpicture += $delta;
369 $this->posxtva += $delta;
370 $this->posxup += $delta;
371 $this->posxqty += $delta;
372 $this->posxunit += $delta;
373 $this->posxdiscount += $delta;
379 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
382 $heightforinfotot = 40;
383 $heightforsignature = empty($conf->global->PROPAL_DISABLE_SIGNATURE) ? (
pdfGetHeightForHtmlContent($pdf, $outputlangs->transnoentities(
"ProposalCustomerSignature")) + 10) : 0;
384 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
385 $heightforfooter = $this->marge_basse + 8;
386 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) $heightforfooter += 6;
389 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
390 $pdf->SetFont(
'',
'', $default_font_size - 1);
391 $pdf->MultiCell(0, 3,
'');
392 $pdf->SetTextColor(0, 0, 0);
395 $tab_top = 90 + $top_shift;
396 $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
399 if (!empty($conf->incoterm->enabled))
401 $desc_incoterms = $object->getIncotermsForPDF();
406 $pdf->SetFont(
'',
'', $default_font_size - 1);
407 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
408 $nexY = $pdf->GetY();
409 $height_incoterms = $nexY - $tab_top;
412 $pdf->SetDrawColor(192, 192, 192);
413 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
415 $tab_top = $nexY + 6;
420 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
421 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
424 if (is_object($object->thirdparty))
426 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
427 $salerepobj =
new User($this->
db);
428 $salerepobj->fetch($salereparray[0][
'id']);
429 if (!empty($salerepobj->signature)) $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
433 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
434 if (!empty($extranote)) {
437 if (!empty($conf->global->MAIN_ADD_CREATOR_IN_NOTE) && $object->user_author_id > 0)
439 $tmpuser =
new User($this->
db);
440 $tmpuser->fetch($object->user_author_id);
441 $notetoshow .= $langs->trans(
"CaseFollowedBy").
' '.$tmpuser->getFullName($langs);
442 if ($tmpuser->email) $notetoshow .=
', Mail: '.$tmpuser->email;
443 if ($tmpuser->office_phone) $notetoshow .=
', Tel: '.$tmpuser->office_phone;
454 $pdf->SetFont(
'',
'', $default_font_size - 1);
455 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
456 $nexY = $pdf->GetY();
457 $height_note = $nexY - $tab_top;
460 $pdf->SetDrawColor(192, 192, 192);
461 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
463 $tab_top = $nexY + 6;
466 $iniY = $tab_top + 7;
467 $curY = $tab_top + 7;
468 $nexY = $tab_top + 7;
471 for ($i = 0; $i < $nblines; $i++)
474 $pdf->SetFont(
'',
'', $default_font_size - 1);
475 $pdf->SetTextColor(0, 0, 0);
478 $imglinesize = array();
481 $pdf->setTopMargin($tab_top_newpage);
482 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot);
483 $pageposbefore = $pdf->getPage();
485 $showpricebeforepagebreak = 1;
487 $posYAfterDescription = 0;
490 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot)))
492 $pdf->AddPage(
'',
'',
true);
493 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
494 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
495 $pdf->setPage($pageposbefore + 1);
497 $curY = $tab_top_newpage;
500 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
501 $showpricebeforepagebreak = 1;
502 else $showpricebeforepagebreak = 0;
505 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']))
507 $curX = $this->posxpicture - 1;
508 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
510 $posYAfterImage = $curY + $imglinesize[
'height'];
514 $curX = $this->posxdesc - 1;
516 $pdf->startTransaction();
517 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
518 $pageposafter = $pdf->getPage();
519 if ($pageposafter > $pageposbefore)
521 $pdf->rollbackTransaction(
true);
522 $pageposafter = $pageposbefore;
524 $pdf->setPageOrientation(
'', 1, $heightforfooter);
525 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxpicture - $curX, 3, $curX, $curY, $hideref, $hidedesc);
527 $pageposafter = $pdf->getPage();
528 $posyafter = $pdf->GetY();
530 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforsignature + $heightforinfotot)))
532 if ($i == ($nblines - 1))
534 $pdf->AddPage(
'',
'',
true);
535 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
536 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
537 $pdf->setPage($pageposafter + 1);
543 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
544 $showpricebeforepagebreak = 1;
545 else $showpricebeforepagebreak = 0;
549 $pdf->commitTransaction();
551 $posYAfterDescription = $pdf->GetY();
553 $nexY = $pdf->GetY();
554 $pageposafter = $pdf->getPage();
556 $pdf->setPage($pageposbefore);
557 $pdf->setTopMargin($this->marge_haute);
558 $pdf->setPageOrientation(
'', 1, 0);
561 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
562 $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
565 $pdf->SetFont(
'',
'', $default_font_size - 1);
568 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
571 $pdf->SetXY($this->posxtva - 5, $curY);
572 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
577 $pdf->SetXY($this->posxup, $curY);
578 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
582 $pdf->SetXY($this->posxqty, $curY);
583 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
586 if (!empty($conf->global->PRODUCT_USE_UNITS))
588 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
589 $pdf->SetXY($this->posxunit, $curY);
590 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
594 $pdf->SetXY($this->posxdiscount, $curY);
595 if ($object->lines[$i]->remise_percent)
597 $pdf->SetXY($this->posxdiscount - 2, $curY);
599 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
604 $pdf->SetXY($this->postotalht, $curY);
605 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
608 if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
609 else $tvaligne = $object->lines[$i]->total_tva;
611 $localtax1ligne = $object->lines[$i]->total_localtax1;
612 $localtax2ligne = $object->lines[$i]->total_localtax2;
613 $localtax1_rate = $object->lines[$i]->localtax1_tx;
614 $localtax2_rate = $object->lines[$i]->localtax2_tx;
615 $localtax1_type = $object->lines[$i]->localtax1_type;
616 $localtax2_type = $object->lines[$i]->localtax2_type;
618 if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
619 if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
620 if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
622 $vatrate = (string) $object->lines[$i]->tva_tx;
625 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
626 && (!empty($localtax1_rate) || !empty($localtax2_rate)))
629 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
630 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
634 if ($localtax1_type && $localtax1ligne != 0)
635 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
636 if ($localtax2_type && $localtax2ligne != 0)
637 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
639 if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .=
'*';
640 if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
641 $this->tva[$vatrate] += $tvaligne;
643 if ($posYAfterImage > $posYAfterDescription) $nexY = $posYAfterImage;
646 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
648 $pdf->setPage($pageposafter);
649 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
651 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
652 $pdf->SetLineStyle(array(
'dash'=>0));
658 while ($pagenb < $pageposafter)
660 $pdf->setPage($pagenb);
663 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
665 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
667 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
669 $pdf->setPage($pagenb);
670 $pdf->setPageOrientation(
'', 1, 0);
671 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
673 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
677 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
679 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
681 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
684 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
686 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
693 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
694 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
696 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
697 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforsignature - $heightforfooter + 1;
701 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
704 $posy = $this->
_tableau_tot($pdf, $object, 0, $bottomlasttab, $outputlangs);
715 if (empty($conf->global->PROPAL_DISABLE_SIGNATURE))
721 $this->
_pagefoot($pdf, $object, $outputlangs);
722 if (method_exists($pdf,
'AliasNbPages')) $pdf->AliasNbPages();
725 if (!empty($conf->global->PRODUIT_PDF_MERGE_PROPAL))
727 require_once DOL_DOCUMENT_ROOT.
'/product/class/propalmergepdfproduct.class.php';
729 $already_merged = array();
730 foreach ($object->lines as $line) {
731 if (!empty($line->fk_product) && !(in_array($line->fk_product, $already_merged))) {
735 if ($conf->global->MAIN_MULTILANGS) {
736 $filetomerge->fetch_by_product($line->fk_product, $outputlangs->defaultlang);
738 $filetomerge->fetch_by_product($line->fk_product);
741 $already_merged[] = $line->fk_product;
744 $product->fetch($line->fk_product);
746 if ($product->entity != $conf->entity) {
747 $entity_product_file = $product->entity;
749 $entity_product_file = $conf->entity;
753 if (count($filetomerge->lines) > 0) {
754 foreach ($filetomerge->lines as $linefile) {
755 if (!empty($linefile->id) && !empty($linefile->file_name)) {
756 if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
758 if (!empty($conf->product->enabled)) {
759 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
760 } elseif (!empty($conf->service->enabled)) {
761 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir($product->id, 2, 0, 0, $product,
'product').$product->id.
"/photos";
764 if (!empty($conf->product->enabled)) {
765 $filetomerge_dir = $conf->product->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product').dol_sanitizeFileName($product->ref);
766 } elseif (!empty($conf->service->enabled)) {
767 $filetomerge_dir = $conf->service->multidir_output[$entity_product_file].
'/'.
get_exdir(0, 0, 0, 0, $product,
'product').dol_sanitizeFileName($product->ref);
771 dol_syslog(get_class($this).
':: upload_dir='.$filetomerge_dir, LOG_DEBUG);
773 $infile = $filetomerge_dir.
'/'.$linefile->file_name;
774 if (file_exists($infile) && is_readable($infile)) {
775 $pagecount = $pdf->setSourceFile($infile);
776 for ($i = 1; $i <= $pagecount; $i++) {
777 $tplIdx = $pdf->importPage($i);
778 if ($tplIdx !==
false) {
779 $s = $pdf->getTemplatesize($tplIdx);
780 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
781 $pdf->useTemplate($tplIdx);
783 setEventMessages(null, array($infile.
' cannot be added, probably protected PDF'),
'warnings');
796 $pdf->Output($file,
'F');
799 $hookmanager->initHooks(array(
'pdfgeneration'));
800 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
802 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
805 $this->error = $hookmanager->error;
806 $this->errors = $hookmanager->errors;
809 if (!empty($conf->global->MAIN_UMASK))
810 @chmod($file, octdec($conf->global->MAIN_UMASK));
812 $this->result = array(
'fullpath'=>$file);
816 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
820 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PROP_OUTPUTDIR");
855 global $conf, $mysoc;
858 $pdf->SetFont(
'',
'', $default_font_size - 1);
861 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj))
863 $pdf->SetFont(
'',
'B', $default_font_size - 2);
864 $pdf->SetXY($this->marge_gauche, $posy);
865 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
867 $posy = $pdf->GetY() + 4;
873 if (!empty($object->delivery_date))
875 $outputlangs->load(
"sendings");
876 $pdf->SetFont(
'',
'B', $default_font_size - 2);
877 $pdf->SetXY($this->marge_gauche, $posy);
878 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
879 $pdf->MultiCell(80, 4, $titre, 0,
'L');
880 $pdf->SetFont(
'',
'', $default_font_size - 2);
881 $pdf->SetXY($posxval, $posy);
882 $dlp =
dol_print_date($object->delivery_date,
"daytext",
false, $outputlangs,
true);
883 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
885 $posy = $pdf->GetY() + 1;
886 } elseif ($object->availability_code || $object->availability)
888 $pdf->SetFont(
'',
'B', $default_font_size - 2);
889 $pdf->SetXY($this->marge_gauche, $posy);
890 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
891 $pdf->MultiCell(80, 4, $titre, 0,
'L');
892 $pdf->SetTextColor(0, 0, 0);
893 $pdf->SetFont(
'',
'', $default_font_size - 2);
894 $pdf->SetXY($posxval, $posy);
895 $lib_availability = $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) != (
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset($object->availability);
896 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
897 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
899 $posy = $pdf->GetY() + 1;
903 if (empty($conf->global->PROPOSAL_PDF_HIDE_PAYMENTTERM) && ($object->cond_reglement_code || $object->cond_reglement))
905 $pdf->SetFont(
'',
'B', $default_font_size - 2);
906 $pdf->SetXY($this->marge_gauche, $posy);
907 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
908 $pdf->MultiCell(43, 4, $titre, 0,
'L');
910 $pdf->SetFont(
'',
'', $default_font_size - 2);
911 $pdf->SetXY($posxval, $posy);
912 $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);
913 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
914 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
916 $posy = $pdf->GetY() + 3;
919 if (empty($conf->global->PROPOSAL_PDF_HIDE_PAYMENTMODE))
938 if ($object->mode_reglement_code
939 && $object->mode_reglement_code !=
'CHQ'
940 && $object->mode_reglement_code !=
'VIR')
942 $pdf->SetFont(
'',
'B', $default_font_size - 2);
943 $pdf->SetXY($this->marge_gauche, $posy);
944 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
945 $pdf->MultiCell(80, 5, $titre, 0,
'L');
946 $pdf->SetFont(
'',
'', $default_font_size - 2);
947 $pdf->SetXY($posxval, $posy);
948 $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);
949 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
951 $posy = $pdf->GetY() + 2;
955 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ')
958 if (!empty($conf->global->FACTURE_CHQ_NUMBER))
960 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
962 if ($conf->global->FACTURE_CHQ_NUMBER > 0)
965 $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
967 $pdf->SetXY($this->marge_gauche, $posy);
968 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
969 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
970 $posy = $pdf->GetY() + 1;
972 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
974 $pdf->SetXY($this->marge_gauche, $posy);
975 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
976 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
977 $posy = $pdf->GetY() + 2;
980 if ($conf->global->FACTURE_CHQ_NUMBER == -1)
982 $pdf->SetXY($this->marge_gauche, $posy);
983 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
984 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
985 $posy = $pdf->GetY() + 1;
987 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
989 $pdf->SetXY($this->marge_gauche, $posy);
990 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
991 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
992 $posy = $pdf->GetY() + 2;
999 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR')
1001 if (!empty($object->fk_account) || !empty($object->fk_bank) || !empty($conf->global->FACTURE_RIB_NUMBER))
1003 $bankid = (empty($object->fk_account) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
1004 if (!empty($object->fk_bank)) $bankid = $object->fk_bank;
1006 $account->fetch($bankid);
1008 $curx = $this->marge_gauche;
1011 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1033 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
1036 global $conf, $mysoc;
1041 $pdf->SetFont(
'',
'', $default_font_size - 1);
1044 $col1x = 120; $col2x = 170;
1045 if ($this->page_largeur < 210)
1049 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1055 $pdf->SetFillColor(255, 255, 255);
1056 $pdf->SetXY($col1x, $tab2_top + 0);
1057 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
1059 $total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
1060 $pdf->SetXY($col2x, $tab2_top + 0);
1061 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0,
'R', 1);
1064 $pdf->SetFillColor(248, 248, 248);
1066 $total_ttc = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
1068 $this->atleastoneratenotnull = 0;
1069 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
1071 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
1072 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
1079 foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1081 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5')))
continue;
1083 foreach ($localtax_rate as $tvakey => $tvaval)
1090 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1093 if (preg_match(
'/\*/', $tvakey))
1095 $tvakey = str_replace(
'*',
'', $tvakey);
1096 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1098 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1099 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1100 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1102 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1103 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1111 foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1113 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5')))
continue;
1115 foreach ($localtax_rate as $tvakey => $tvaval)
1124 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1127 if (preg_match(
'/\*/', $tvakey))
1129 $tvakey = str_replace(
'*',
'', $tvakey);
1130 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1132 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1133 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1134 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1136 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1137 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1143 foreach ($this->tva as $tvakey => $tvaval)
1147 $this->atleastoneratenotnull++;
1150 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1153 if (preg_match(
'/\*/', $tvakey))
1155 $tvakey = str_replace(
'*',
'', $tvakey);
1156 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1158 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
1159 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
1160 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1162 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1163 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1170 foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1172 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6')))
continue;
1174 foreach ($localtax_rate as $tvakey => $tvaval)
1181 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1184 if (preg_match(
'/\*/', $tvakey))
1186 $tvakey = str_replace(
'*',
'', $tvakey);
1187 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1189 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1191 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1192 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1193 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1194 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1202 foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1204 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6')))
continue;
1206 foreach ($localtax_rate as $tvakey => $tvaval)
1214 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1217 if (preg_match(
'/\*/', $tvakey))
1219 $tvakey = str_replace(
'*',
'', $tvakey);
1220 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1222 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1224 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1225 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1227 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1228 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1236 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1237 $pdf->SetTextColor(0, 0, 60);
1238 $pdf->SetFillColor(224, 224, 224);
1239 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1241 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1242 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1246 $pdf->SetTextColor(0, 0, 0);
1253 if ($deja_regle > 0)
1257 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1258 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1260 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1261 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1280 $pdf->SetTextColor(0, 0, 60);
1281 $pdf->SetFillColor(224, 224, 224);
1282 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1283 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1285 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1286 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1288 $pdf->SetFont(
'',
'', $default_font_size - 1);
1289 $pdf->SetTextColor(0, 0, 0);
1293 return ($tab2_top + ($tab2_hl * $index));
1310 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1316 if ($hidetop) $hidetop = -1;
1318 $currency = !empty($currency) ? $currency : $conf->currency;
1322 $pdf->SetTextColor(0, 0, 0);
1323 $pdf->SetFont(
'',
'', $default_font_size - 2);
1325 if (empty($hidetop))
1327 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1328 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1329 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1332 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $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));
1335 $pdf->SetDrawColor(128, 128, 128);
1336 $pdf->SetFont(
'',
'', $default_font_size - 1);
1339 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1341 if (empty($hidetop))
1343 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1345 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1346 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1349 if (!empty($conf->global->MAIN_GENERATE_PROPOSALS_WITH_PICTURE))
1351 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1352 if (empty($hidetop))
1359 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1361 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1362 if (empty($hidetop))
1365 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1366 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1370 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1371 if (empty($hidetop))
1373 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1374 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1377 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1378 if (empty($hidetop))
1380 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1381 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1384 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1385 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1386 if (empty($hidetop)) {
1387 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1388 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
1393 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1394 if (empty($hidetop))
1396 if ($this->atleastonediscount)
1398 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1399 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1402 if ($this->atleastonediscount)
1404 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1406 if (empty($hidetop))
1408 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1409 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
1423 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1425 global $conf, $langs;
1428 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills"));
1435 if ($object->statut == 0 && (!empty($conf->global->PROPALE_DRAFT_WATERMARK)))
1437 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->PROPALE_DRAFT_WATERMARK);
1440 $pdf->SetTextColor(0, 0, 60);
1441 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1443 $posy = $this->marge_haute;
1444 $posx = $this->page_largeur - $this->marge_droite - 100;
1446 $pdf->SetXY($this->marge_gauche, $posy);
1449 if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1451 if ($this->emetteur->logo)
1453 $logodir = $conf->mycompany->dir_output;
1454 if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
1455 if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
1457 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1459 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1461 if (is_readable($logo))
1464 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1466 $pdf->SetTextColor(200, 0, 0);
1467 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1468 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1469 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1472 $text = $this->emetteur->name;
1473 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1477 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1478 $pdf->SetXY($posx, $posy);
1479 $pdf->SetTextColor(0, 0, 60);
1480 $title = $outputlangs->transnoentities(
"PdfCommercialProposalTitle");
1481 $pdf->MultiCell(100, 4, $title,
'',
'R');
1483 $pdf->SetFont(
'',
'B', $default_font_size);
1486 $pdf->SetXY($posx, $posy);
1487 $pdf->SetTextColor(0, 0, 60);
1488 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset($object->ref),
'',
'R');
1491 $pdf->SetFont(
'',
'', $default_font_size - 2);
1493 if ($object->ref_client)
1496 $pdf->SetXY($posx, $posy);
1497 $pdf->SetTextColor(0, 0, 60);
1498 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
1501 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
1503 $object->fetch_projet();
1504 if (!empty($object->project->ref))
1507 $pdf->SetXY($posx, $posy);
1508 $pdf->SetTextColor(0, 0, 60);
1509 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->projet->title),
'',
'R');
1513 if (!empty($conf->global->PDF_SHOW_PROJECT))
1515 $object->fetch_projet();
1516 if (!empty($object->project->ref))
1519 $pdf->SetXY($posx, $posy);
1520 $pdf->SetTextColor(0, 0, 60);
1521 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->projet->ref),
'',
'R');
1526 $pdf->SetXY($posx, $posy);
1527 $pdf->SetTextColor(0, 0, 60);
1528 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"Date").
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1531 $pdf->SetXY($posx, $posy);
1532 $pdf->SetTextColor(0, 0, 60);
1533 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"DateEndPropal").
" : ".
dol_print_date($object->fin_validite,
"day",
false, $outputlangs,
true),
'',
'R');
1535 if ($object->thirdparty->code_client)
1538 $pdf->SetXY($posx, $posy);
1539 $pdf->SetTextColor(0, 0, 60);
1540 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1544 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1546 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1547 if (count($arrayidcontact) > 0)
1549 $usertmp =
new User($this->
db);
1550 $usertmp->fetch($arrayidcontact[0]);
1552 $pdf->SetXY($posx, $posy);
1553 $pdf->SetTextColor(0, 0, 60);
1554 $pdf->MultiCell(100, 3, $langs->trans(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1562 $current_y = $pdf->getY();
1563 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3,
'R', $default_font_size);
1564 if ($current_y < $pdf->getY())
1566 $top_shift = $pdf->getY() - $current_y;
1572 $carac_emetteur =
'';
1574 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1575 if (count($arrayidcontact) > 0)
1577 $object->fetch_user($arrayidcontact[0]);
1578 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1579 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)).
"\n";
1582 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1585 $posy = 42 + $top_shift;
1586 $posx = $this->marge_gauche;
1587 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1591 $pdf->SetTextColor(0, 0, 0);
1592 $pdf->SetFont(
'',
'', $default_font_size - 2);
1593 $pdf->SetXY($posx, $posy - 5);
1594 $pdf->MultiCell(66, 5, $outputlangs->transnoentities(
"BillFrom").
":", 0,
'L');
1595 $pdf->SetXY($posx, $posy);
1596 $pdf->SetFillColor(230, 230, 230);
1597 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1598 $pdf->SetTextColor(0, 0, 60);
1601 $pdf->SetXY($posx + 2, $posy + 3);
1602 $pdf->SetFont(
'',
'B', $default_font_size);
1603 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1604 $posy = $pdf->getY();
1607 $pdf->SetXY($posx + 2, $posy);
1608 $pdf->SetFont(
'',
'', $default_font_size - 1);
1609 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
1613 $usecontact =
false;
1614 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1615 if (count($arrayidcontact) > 0)
1618 $result = $object->fetch_contact($arrayidcontact[0]);
1622 if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
1623 $thirdparty = $object->contact;
1625 $thirdparty = $object->thirdparty;
1630 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact,
'target', $object);
1634 if ($this->page_largeur < 210) $widthrecbox = 84;
1635 $posy = 42 + $top_shift;
1636 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1637 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1640 $pdf->SetTextColor(0, 0, 0);
1641 $pdf->SetFont(
'',
'', $default_font_size - 2);
1642 $pdf->SetXY($posx + 2, $posy - 5);
1643 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo").
":", 0,
'L');
1644 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1647 $pdf->SetXY($posx + 2, $posy + 3);
1648 $pdf->SetFont(
'',
'B', $default_font_size);
1649 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0,
'L');
1651 $posy = $pdf->getY();
1654 $pdf->SetFont(
'',
'', $default_font_size - 1);
1655 $pdf->SetXY($posx + 2, $posy);
1656 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1659 $pdf->SetTextColor(0, 0, 0);
1673 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1676 $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1677 return pdf_pagefoot($pdf, $outputlangs,
'PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
1696 $tab_top = $posy + 4;
1700 $largcol = ($this->page_largeur - $this->marge_droite - $posx);
1704 $pdf->SetFillColor(255, 255, 255);
1705 $pdf->SetXY($posx, $tab_top + 0);
1706 $pdf->SetFont(
'',
'', $default_font_size - 2);
1707 $pdf->MultiCell($largcol, $tab_hl, $outputlangs->transnoentities(
"ProposalCustomerSignature"), 0,
'L', 1);
1709 $pdf->SetXY($posx, $tab_top + $tab_hl);
1710 $pdf->MultiCell($largcol, $tab_hl * 3,
'', 1,
'R');
1711 if (!empty($conf->global->MAIN_PDF_PROPAL_USE_ELECTRONIC_SIGNING)) {
1712 $pdf->addEmptySignatureAppearance($posx, $tab_top + $tab_hl, $largcol, $tab_hl * 3);
1715 return ($tab_hl * 7);
pdf_getFormat(Translate $outputlangs=null, $mode= 'setup')
Return array with format properties of default PDF format.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency= '')
Show table for lines.
pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank informations for PDF generation.
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
write_file($object, $outputlangs, $srctemplatepath= '', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
Put here description of your class.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
Class to generate PDF proposal Azur.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Class to manage products or services.
_tableau_versements(&$pdf, $object, $posy, $outputlangs)
Show payments table.
Class to manage Dolibarr users.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom= 'UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0, $hookmanager=false)
Return line unit.
$conf db name
Only used if Module[ID]Name translation string is not found.
Classe mere des modeles de propale.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
$conf db
API class for accounts.
_tableau_info(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
Class to manage bank accounts.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
_signature_area(&$pdf, $object, $posy, $outputlangs)
Show area for the customer to sign.
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0)
Show footer of page for PDF generation.
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
pdfGetHeightForHtmlContent(&$pdf, $htmlcontent)
Function to try to calculate height of a HTML Content.
__construct($db)
Constructor.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages...
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
pdf_getInstance($format= '', $metric= 'mm', $pagetype= 'P')
Return a PDF instance object.
pdf_build_address($outputlangs, $sourcecompany, $targetcompany= '', $targetcontact= '', $usecontact=0, $mode= 'source', $object=null)
Return a string with full address formated for output on documents.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0)
Output line description into PDF.
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.