29 require_once DOL_DOCUMENT_ROOT.
'/core/modules/supplier_proposal/modules_supplier_proposal.php';
30 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
59 public $update_main_doc_field;
70 public $phpmin = array(7, 0);
76 public $version =
'dolibarr';
101 public $marge_droite;
127 global $conf, $langs, $mysoc;
130 $langs->loadLangs(array(
"main",
"bills"));
133 $this->
name =
"aurore";
134 $this->
description = $langs->trans(
'DocModelAuroreDescription');
135 $this->update_main_doc_field = 1;
140 $this->page_largeur = $formatarray[
'width'];
141 $this->page_hauteur = $formatarray[
'height'];
142 $this->format = array($this->page_largeur, $this->page_hauteur);
148 $this->option_logo = 1;
149 $this->option_tva = 1;
150 $this->option_modereg = 1;
151 $this->option_condreg = 1;
152 $this->option_multilang = 1;
153 $this->option_escompte = 1;
154 $this->option_credit_note = 1;
155 $this->option_freetext = 1;
156 $this->option_draft_watermark = 1;
157 $this->watermark =
'';
160 $this->emetteur = $mysoc;
161 if (empty($this->emetteur->country_code)) {
162 $this->emetteur->country_code = substr($langs->defaultlang, -2);
166 $this->posxdesc = $this->marge_gauche + 1;
167 $this->posxdiscount = 162;
168 $this->postotalht = 174;
172 $this->posxqty = 135;
173 $this->posxunit = 151;
176 $this->posxqty = 145;
177 $this->posxunit = 162;
180 $this->posxpicture = $this->posxup - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
181 if ($this->page_largeur < 210) {
182 $this->posxpicture -= 20;
184 $this->posxqty -= 20;
185 $this->posxunit -= 20;
186 $this->posxdiscount -= 20;
187 $this->postotalht -= 20;
190 $this->tva = array();
191 $this->tva_array = array();
192 $this->localtax1 = array();
193 $this->localtax2 = array();
194 $this->atleastoneratenotnull = 0;
195 $this->atleastonediscount = 0;
210 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
213 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
215 if (!is_object($outputlangs)) {
216 $outputlangs = $langs;
219 if (!empty($conf->global->MAIN_USE_FPDF)) {
220 $outputlangs->charset_output =
'ISO-8859-1';
224 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"supplier_proposal"));
227 if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK))) {
228 $this->watermark = $conf->global->SUPPLIER_PROPOSAL_DRAFT_WATERMARK;
231 $nblines = count($object->lines);
234 $realpatharray = array();
235 if (!empty($conf->global->MAIN_GENERATE_SUPPLIER_PROPOSAL_WITH_PICTURE)) {
236 for ($i = 0; $i < $nblines; $i++) {
237 if (empty($object->lines[$i]->fk_product)) {
242 $objphoto->fetch($object->lines[$i]->fk_product);
245 $pdir =
get_exdir($object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
246 $dir = $conf->product->dir_output.
'/'.$pdir;
248 $pdir =
get_exdir(0, 0, 0, 0, $objphoto,
'product');
249 $dir = $conf->product->dir_output.
'/'.$pdir;
253 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
255 if ($obj[
'photo_vignette']) {
256 $filename = $obj[
'photo_vignette'];
258 $filename = $obj[
'photo'];
261 $filename = $obj[
'photo'];
263 $realpath = $dir.$filename;
268 $realpatharray[$i] = $realpath;
272 if (count($realpatharray) == 0) {
273 $this->posxpicture = $this->posxup;
276 if ($conf->supplier_proposal->dir_output) {
277 $object->fetch_thirdparty();
282 if ($object->specimen) {
283 $dir = $conf->supplier_proposal->dir_output;
284 $file = $dir.
"/SPECIMEN.pdf";
287 $dir = $conf->supplier_proposal->dir_output.
"/".$objectref;
288 $file = $dir.
"/".$objectref.
".pdf";
291 if (!file_exists($dir)) {
293 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
298 if (file_exists($dir)) {
300 if (!is_object($hookmanager)) {
301 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
304 $hookmanager->initHooks(array(
'pdfgeneration'));
305 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
307 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
312 $heightforinfotot = 50;
313 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
314 $heightforfooter = $this->marge_basse + 8;
315 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
316 $heightforfooter += 6;
318 $pdf->SetAutoPageBreak(1, 0);
320 if (class_exists(
'TCPDF')) {
321 $pdf->setPrintHeader(
false);
322 $pdf->setPrintFooter(
false);
326 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
327 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
328 $tplidx = $pdf->importPage(1);
333 $pdf->SetDrawColor(128, 128, 128);
335 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
336 $pdf->SetSubject($outputlangs->transnoentities(
"CommercialAsk"));
337 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
338 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
339 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"CommercialAsk").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
341 $pdf->SetCompression(
false);
344 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
347 for ($i = 0; $i < $nblines; $i++) {
348 if ($object->lines[$i]->remise_percent) {
349 $this->atleastonediscount++;
352 if (empty($this->atleastonediscount)) {
353 $delta = ($this->postotalht - $this->posxdiscount);
354 $this->posxpicture += $delta;
355 $this->posxup += $delta;
356 $this->posxqty += $delta;
357 $this->posxunit += $delta;
358 $this->posxdiscount += $delta;
364 if (!empty($tplidx)) {
365 $pdf->useTemplate($tplidx);
368 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs);
369 $pdf->SetFont(
'',
'', $default_font_size - 1);
370 $pdf->MultiCell(0, 3,
'');
371 $pdf->SetTextColor(0, 0, 0);
373 $tab_top = 90 + $top_shift;
374 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
377 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
378 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
380 if (is_object($object->thirdparty)) {
381 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
382 $salerepobj =
new User($this->
db);
383 $salerepobj->fetch($salereparray[0][
'id']);
384 if (!empty($salerepobj->signature)) {
385 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
391 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
392 if (!empty($extranote)) {
404 $pdf->SetFont(
'',
'', $default_font_size - 1);
405 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
406 $nexY = $pdf->GetY();
407 $height_note = $nexY - $tab_top;
410 $pdf->SetDrawColor(192, 192, 192);
411 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
413 $tab_top = $nexY + 6;
416 $iniY = $tab_top + 7;
417 $curY = $tab_top + 7;
418 $nexY = $tab_top + 7;
421 for ($i = 0; $i < $nblines; $i++) {
423 $pdf->SetFont(
'',
'', $default_font_size - 1);
424 $pdf->SetTextColor(0, 0, 0);
427 $imglinesize = array();
428 if (!empty($realpatharray[$i])) {
432 $pdf->setTopMargin($tab_top_newpage);
433 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
434 $pageposbefore = $pdf->getPage();
436 $showpricebeforepagebreak = 1;
438 $posYAfterDescription = 0;
441 if (!empty($imglinesize[
'width']) && !empty($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
442 $pdf->AddPage(
'',
'',
true);
443 if (!empty($tplidx)) {
444 $pdf->useTemplate($tplidx);
447 $this->
_pagehead($pdf, $object, 0, $outputlangs);
449 $pdf->setPage($pageposbefore + 1);
451 $curY = $tab_top_newpage;
454 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
455 $showpricebeforepagebreak = 1;
457 $showpricebeforepagebreak = 0;
461 if (!empty($imglinesize[
'width']) && !empty($imglinesize[
'height'])) {
462 $curX = $this->posxpicture - 1;
463 $pdf->Image($realpatharray[$i], $curX + (($this->posxup - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
465 $posYAfterImage = $curY + $imglinesize[
'height'];
469 $curX = $this->posxdesc - 1;
471 $pdf->startTransaction();
472 if ($posYAfterImage > 0) {
473 $descWidth = $this->posxpicture - $curX;
475 $descWidth = $this->posxup - $curX;
477 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
479 $pageposafter = $pdf->getPage();
480 if ($pageposafter > $pageposbefore) {
481 $pdf->rollbackTransaction(
true);
482 $pageposafter = $pageposbefore;
484 $pdf->setPageOrientation(
'', 1, $heightforfooter);
485 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $descWidth, 3, $curX, $curY, $hideref, $hidedesc, 1);
487 $pageposafter = $pdf->getPage();
488 $posyafter = $pdf->GetY();
490 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
491 if ($i == ($nblines - 1)) {
492 $pdf->AddPage(
'',
'',
true);
493 if (!empty($tplidx)) {
494 $pdf->useTemplate($tplidx);
497 $this->
_pagehead($pdf, $object, 0, $outputlangs);
499 $pdf->setPage($pageposafter + 1);
504 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
505 $showpricebeforepagebreak = 1;
507 $showpricebeforepagebreak = 0;
512 $pdf->commitTransaction();
514 $posYAfterDescription = $pdf->GetY();
516 $nexY = $pdf->GetY();
517 $pageposafter = $pdf->getPage();
519 $pdf->setPage($pageposbefore);
520 $pdf->setTopMargin($this->marge_haute);
521 $pdf->setPageOrientation(
'', 1, 0);
524 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
525 $pdf->setPage($pageposafter);
526 $curY = $tab_top_newpage;
529 $pdf->SetFont(
'',
'', $default_font_size - 1);
533 $pdf->SetXY($this->posxqty, $curY);
534 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
538 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
539 $pdf->SetXY($this->posxunit, $curY);
540 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
560 if (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
561 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
563 $tvaligne = $object->lines[$i]->total_tva;
566 $localtax1ligne = $object->lines[$i]->total_localtax1;
567 $localtax2ligne = $object->lines[$i]->total_localtax2;
568 $localtax1_rate = $object->lines[$i]->localtax1_tx;
569 $localtax2_rate = $object->lines[$i]->localtax2_tx;
570 $localtax1_type = $object->lines[$i]->localtax1_type;
571 $localtax2_type = $object->lines[$i]->localtax2_type;
584 $vatrate = (string) $object->lines[$i]->tva_tx;
587 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
588 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
590 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
591 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
595 if ($localtax1_type && $localtax1ligne != 0) {
596 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
598 if ($localtax2_type && $localtax2ligne != 0) {
599 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
602 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
607 if (!isset($this->tva[$vatrate])) {
608 $this->tva[$vatrate] = 0;
610 $this->tva[$vatrate] += $tvaligne;
611 $vatcode = $object->lines[$i]->vat_src_code;
612 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
613 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
615 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
617 if ($posYAfterImage > $posYAfterDescription) {
618 $nexY = $posYAfterImage;
622 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
623 $pdf->setPage($pageposafter);
624 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
626 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
627 $pdf->SetLineStyle(array(
'dash'=>0));
633 while ($pagenb < $pageposafter) {
634 $pdf->setPage($pagenb);
636 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
638 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
640 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
642 $pdf->setPage($pagenb);
643 $pdf->setPageOrientation(
'', 1, 0);
645 $this->
_pagehead($pdf, $object, 0, $outputlangs);
647 if (!empty($tplidx)) {
648 $pdf->useTemplate($tplidx);
651 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
653 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1);
655 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1);
657 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
660 if (!empty($tplidx)) {
661 $pdf->useTemplate($tplidx);
665 $this->
_pagehead($pdf, $object, 0, $outputlangs);
672 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0);
673 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
675 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0);
676 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
680 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
694 $this->
_pagefoot($pdf, $object, $outputlangs);
695 if (method_exists($pdf,
'AliasNbPages')) {
696 $pdf->AliasNbPages();
701 $pdf->Output($file,
'F');
704 $hookmanager->initHooks(array(
'pdfgeneration'));
705 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
707 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
709 $this->error = $hookmanager->error;
710 $this->errors = $hookmanager->errors;
715 $this->result = array(
'fullpath'=>$file);
719 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
723 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"SUPPLIER_PROPOSAL_OUTPUTDIR");
761 $pdf->SetFont(
'',
'', $default_font_size - 1);
766 if (!empty($object->delivery_date)) {
767 $outputlangs->load(
"sendings");
768 $pdf->SetFont(
'',
'B', $default_font_size - 2);
769 $pdf->SetXY($this->marge_gauche, $posy);
770 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
771 $pdf->MultiCell(80, 4, $titre, 0,
'L');
772 $pdf->SetFont(
'',
'', $default_font_size - 2);
773 $pdf->SetXY($posxval, $posy);
774 $dlp =
dol_print_date($object->delivery_date,
"daytext",
false, $outputlangs,
true);
775 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
777 $posy = $pdf->GetY() + 1;
779 $outputlangs->load(
"sendings");
780 $pdf->SetFont(
'',
'B', $default_font_size - 2);
781 $pdf->SetXY($this->marge_gauche, $posy);
782 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
783 $pdf->MultiCell(80, 4, $titre, 0,
'L');
784 $pdf->SetFont(
'',
'', $default_font_size - 2);
785 $pdf->SetXY($posxval, $posy);
787 $pdf->MultiCell(80, 4,
'', 0,
'L');
789 $posy = $pdf->GetY() + 1;
809 if (empty($conf->global->SUPPLIER_PROPOSAL_PDF_HIDE_PAYMENTTERMCOND) && ($object->cond_reglement_code || $object->cond_reglement)) {
810 $pdf->SetFont(
'',
'B', $default_font_size - 2);
811 $pdf->SetXY($this->marge_gauche, $posy);
812 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
813 $pdf->MultiCell(80, 4, $titre, 0,
'L');
815 $pdf->SetFont(
'',
'', $default_font_size - 2);
816 $pdf->SetXY($posxval, $posy);
817 $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);
818 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
819 $pdf->MultiCell(80, 4, $lib_condition_paiement, 0,
'L');
821 $posy = $pdf->GetY() + 3;
824 if (!empty($conf->global->SUPPLIER_PROPOSAL_PDF_SHOW_PAYMENTTERMMODE)) {
826 if ($object->mode_reglement_code
827 && $object->mode_reglement_code !=
'CHQ'
828 && $object->mode_reglement_code !=
'VIR') {
829 $pdf->SetFont(
'',
'B', $default_font_size - 2);
830 $pdf->SetXY($this->marge_gauche, $posy - 2);
831 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
832 $pdf->MultiCell(80, 5, $titre, 0,
'L');
833 $pdf->SetFont(
'',
'', $default_font_size - 2);
834 $pdf->SetXY($posxval, $posy - 2);
835 $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);
836 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
838 $posy = $pdf->GetY() + 2;
842 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
844 if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
845 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
847 if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
849 $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
851 $pdf->SetXY($this->marge_gauche, $posy);
852 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
853 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
854 $posy = $pdf->GetY() + 1;
856 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
857 $pdf->SetXY($this->marge_gauche, $posy);
858 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
859 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
860 $posy = $pdf->GetY() + 2;
863 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
864 $pdf->SetXY($this->marge_gauche, $posy);
865 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
866 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
867 $posy = $pdf->GetY() + 1;
869 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
870 $pdf->SetXY($this->marge_gauche, $posy);
871 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
872 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
873 $posy = $pdf->GetY() + 2;
880 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
881 if (!empty($object->fk_bank) ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
882 $bankid = (empty($object->fk_bank) ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_bank);
884 $account->fetch($bankid);
886 $curx = $this->marge_gauche;
889 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
911 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
914 global $conf, $mysoc;
919 $pdf->SetFont(
'',
'', $default_font_size - 1);
924 if ($this->page_largeur < 210) {
927 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
933 $pdf->SetFillColor(255, 255, 255);
934 $pdf->SetXY($col1x, $tab2_top);
935 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT"), 0,
'L', 1);
937 $total_ht = ((
isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
938 $pdf->SetXY($col2x, $tab2_top);
939 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0,
'R', 1);
942 $pdf->SetFillColor(248, 248, 248);
944 $this->atleastoneratenotnull = 0;
945 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
946 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
947 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) {
953 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
954 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
958 foreach ($localtax_rate as $tvakey => $tvaval) {
963 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
966 if (preg_match(
'/\*/', $tvakey)) {
967 $tvakey = str_replace(
'*',
'', $tvakey);
968 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
970 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
971 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
972 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
974 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
975 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
983 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
984 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
988 foreach ($localtax_rate as $tvakey => $tvaval) {
995 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
998 if (preg_match(
'/\*/', $tvakey)) {
999 $tvakey = str_replace(
'*',
'', $tvakey);
1000 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1002 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1003 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1004 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1006 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1007 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1013 foreach ($this->tva as $tvakey => $tvaval) {
1015 $this->atleastoneratenotnull++;
1018 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1021 if (preg_match(
'/\*/', $tvakey)) {
1022 $tvakey = str_replace(
'*',
'', $tvakey);
1023 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1025 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).
' ';
1026 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
1027 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1029 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1030 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1037 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1038 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1042 foreach ($localtax_rate as $tvakey => $tvaval) {
1047 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1050 if (preg_match(
'/\*/', $tvakey)) {
1051 $tvakey = str_replace(
'*',
'', $tvakey);
1052 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1054 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1056 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1057 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1058 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1059 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1067 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1068 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1072 foreach ($localtax_rate as $tvakey => $tvaval) {
1078 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1081 if (preg_match(
'/\*/', $tvakey)) {
1082 $tvakey = str_replace(
'*',
'', $tvakey);
1083 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1085 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1087 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1088 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1090 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1091 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1099 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1100 $pdf->SetTextColor(0, 0, 60);
1101 $pdf->SetFillColor(224, 224, 224);
1102 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L', 1);
1104 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1105 $pdf->MultiCell($largcol2, $tab2_hl,
price($object->total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1109 $pdf->SetTextColor(0, 0, 0);
1111 $resteapayer = $object->total_ttc - $deja_regle;
1112 if (!empty($object->paye)) {
1116 if ($deja_regle > 0) {
1119 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1120 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid"), 0,
'L', 0);
1122 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1123 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1126 $pdf->SetTextColor(0, 0, 60);
1127 $pdf->SetFillColor(224, 224, 224);
1128 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1129 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L', 1);
1131 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1132 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1134 $pdf->SetFont(
'',
'', $default_font_size - 1);
1135 $pdf->SetTextColor(0, 0, 0);
1139 return ($tab2_top + ($tab2_hl * $index));
1156 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1166 $currency = !empty($currency) ? $currency : $conf->currency;
1170 $pdf->SetTextColor(0, 0, 0);
1171 $pdf->SetFont(
'',
'', $default_font_size - 2);
1173 if (empty($hidetop)) {
1174 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1175 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1176 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1179 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1180 $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));
1184 $pdf->SetDrawColor(128, 128, 128);
1185 $pdf->SetFont(
'',
'', $default_font_size - 1);
1188 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1190 if (empty($hidetop)) {
1191 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1193 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1194 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1197 $pdf->line($this->posxup + 1, $tab_top, $this->posxup + 1, $tab_top + $tab_height);
1198 if (empty($hidetop)) {
1199 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1200 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1203 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1204 if (empty($hidetop)) {
1205 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1206 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1210 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1211 if (empty($hidetop)) {
1212 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1213 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1217 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1218 if (empty($hidetop)) {
1219 if ($this->atleastonediscount) {
1220 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1221 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1224 if ($this->atleastonediscount) {
1225 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1227 if (empty($hidetop)) {
1228 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1229 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
1243 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs)
1245 global $conf, $langs;
1248 $outputlangs->loadLangs(array(
"main",
"bills",
"supplier_proposal",
"companies"));
1254 $pdf->SetTextColor(0, 0, 60);
1255 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1257 $posy = $this->marge_haute;
1258 $posx = $this->page_largeur - $this->marge_droite - 100;
1260 $pdf->SetXY($this->marge_gauche, $posy);
1264 if ($this->emetteur->logo) {
1265 $logodir = $conf->mycompany->dir_output;
1266 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1267 $logodir = $conf->mycompany->multidir_output[$object->entity];
1270 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1272 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1274 if (is_readable($logo)) {
1276 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1278 $pdf->SetTextColor(200, 0, 0);
1279 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1280 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1281 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1284 $text = $this->emetteur->name;
1285 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0);
1289 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1290 $pdf->SetXY($posx, $posy);
1291 $pdf->SetTextColor(0, 0, 60);
1292 $title = $outputlangs->transnoentities(
"CommercialAsk");
1293 $pdf->MultiCell(100, 4, $title,
'',
'R');
1295 $pdf->SetFont(
'',
'B', $default_font_size);
1298 $pdf->SetXY($posx, $posy);
1299 $pdf->SetTextColor(0, 0, 60);
1300 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset($object->ref),
'',
'R');
1303 $pdf->SetFont(
'',
'', $default_font_size - 2);
1305 if ($object->ref_fourn) {
1307 $pdf->SetXY($posx, $posy);
1308 $pdf->SetTextColor(0, 0, 60);
1309 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"RefSupplier").
" : ".
dol_trunc($outputlangs->convToOutputCharset($object->ref_fourn), 65),
'',
'R');
1312 if ($object->thirdparty->code_fournisseur) {
1314 $pdf->SetXY($posx, $posy);
1315 $pdf->SetTextColor(0, 0, 60);
1316 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"SupplierCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_fournisseur),
'',
'R');
1320 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1321 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1322 if (count($arrayidcontact) > 0) {
1323 $usertmp =
new User($this->
db);
1324 $usertmp->fetch($arrayidcontact[0]);
1326 $pdf->SetXY($posx, $posy);
1327 $pdf->SetTextColor(0, 0, 60);
1328 $pdf->MultiCell(100, 3, $langs->trans(
"BuyerName").
" : ".$usertmp->getFullName($langs),
'',
'R');
1336 $current_y = $pdf->getY();
1337 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3,
'R', $default_font_size);
1338 if ($current_y < $pdf->getY()) {
1339 $top_shift = $pdf->getY() - $current_y;
1344 $carac_emetteur =
'';
1346 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1347 if (count($arrayidcontact) > 0) {
1348 $object->fetch_user($arrayidcontact[0]);
1349 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1350 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
": ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)).
"\n";
1353 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1356 $posy = 42 + $top_shift;
1357 $posx = $this->marge_gauche;
1358 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1359 $posx = $this->page_largeur - $this->marge_droite - 80;
1364 $pdf->SetTextColor(0, 0, 0);
1365 $pdf->SetFont(
'',
'', $default_font_size - 2);
1366 $pdf->SetXY($posx, $posy - 5);
1367 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0,
'L');
1368 $pdf->SetXY($posx, $posy);
1369 $pdf->SetFillColor(230, 230, 230);
1370 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1371 $pdf->SetTextColor(0, 0, 60);
1374 $pdf->SetXY($posx + 2, $posy + 3);
1375 $pdf->SetFont(
'',
'B', $default_font_size);
1376 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1377 $posy = $pdf->getY();
1380 $pdf->SetXY($posx + 2, $posy);
1381 $pdf->SetFont(
'',
'', $default_font_size - 1);
1382 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
1386 $usecontact =
false;
1387 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1388 if (count($arrayidcontact) > 0) {
1390 $result = $object->fetch_contact($arrayidcontact[0]);
1394 if (!empty($usecontact)) {
1395 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)))) {
1396 $socname = $object->contact;
1398 $socname = $object->thirdparty;
1401 $socname = $object->thirdparty;
1406 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact,
'target', $object);
1410 if ($this->page_largeur < 210) {
1413 $posy = 42 + $top_shift;
1414 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1415 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1416 $posx = $this->marge_gauche;
1420 $pdf->SetTextColor(0, 0, 0);
1421 $pdf->SetFont(
'',
'', $default_font_size - 2);
1422 $pdf->SetXY($posx + 2, $posy - 5);
1423 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0,
'L');
1424 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1427 $pdf->SetXY($posx + 2, $posy + 3);
1428 $pdf->SetFont(
'',
'B', $default_font_size);
1429 $pdf->MultiCell($widthrecbox, 4, $carac_client_name, 0,
'L');
1432 $pdf->SetFont(
'',
'', $default_font_size - 1);
1433 $pdf->SetXY($posx + 2, $posy + 4 + (
dol_nboflines_bis($carac_client_name, 50) * 4));
1434 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1437 $pdf->SetTextColor(0, 0, 0);
1451 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1453 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1454 return pdf_pagefoot($pdf, $outputlangs,
'SUPPLIER_PROPOSAL_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);