217 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
220 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
222 if (!is_object($outputlangs)) {
223 $outputlangs = $langs;
226 if (!empty($conf->global->MAIN_USE_FPDF)) {
227 $outputlangs->charset_output =
'ISO-8859-1';
231 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries"));
234 if ($object->statut == $object::STATUS_DRAFT &&
getDolGlobalString(
'COMMANDE_DRAFT_WATERMARK')) {
238 global $outputlangsbis;
239 $outputlangsbis =
null;
240 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
241 $outputlangsbis =
new Translate(
'', $conf);
242 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
243 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries"));
246 $nblines = count($object->lines);
248 if ($conf->commande->multidir_output[$conf->entity]) {
249 $object->fetch_thirdparty();
254 if ($object->specimen) {
255 $dir = $conf->commande->multidir_output[$conf->entity];
256 $file = $dir.
"/SPECIMEN.pdf";
260 if (!empty($conf->global->PROFORMA_PDF_WITH_SUFFIX)) {
261 $suffix = (
GETPOST(
'model', 2)==
'proforma') ? $conf->global->PROFORMA_PDF_WITH_SUFFIX :
'';
266 $dir = $conf->commande->multidir_output[$object->entity].
"/".$objectref;
267 $file = $dir.
"/".$objectref.$suffix.
".pdf";
270 if (!file_exists($dir)) {
272 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
277 if (file_exists($dir)) {
279 if (!is_object($hookmanager)) {
280 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
283 $hookmanager->initHooks(array(
'pdfgeneration'));
284 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
286 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
289 $nblines = count($object->lines);
294 $pdf->SetAutoPageBreak(1, 0);
296 $heightforinfotot = 40;
297 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
298 $heightforfooter = $this->marge_basse + 8;
299 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
300 $heightforfooter += 6;
303 if (class_exists(
'TCPDF')) {
304 $pdf->setPrintHeader(
false);
305 $pdf->setPrintFooter(
false);
309 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
310 $logodir = $conf->mycompany->dir_output;
311 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
312 $logodir = $conf->mycompany->multidir_output[$object->entity];
314 $pagecount = $pdf->setSourceFile($logodir.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
315 $tplidx = $pdf->importPage(1);
320 $pdf->SetDrawColor(128, 128, 128);
322 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
323 $pdf->SetSubject($outputlangs->transnoentities(
"PdfOrderTitle"));
324 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
325 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
326 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfOrderTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
328 $pdf->SetCompression(
false);
331 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
334 for ($i = 0; $i < $nblines; $i++) {
335 if ($object->lines[$i]->remise_percent) {
336 $this->atleastonediscount++;
339 if (empty($this->atleastonediscount)) {
340 $delta = ($this->postotalht - $this->posxdiscount);
341 $this->posxpicture += $delta;
342 $this->posxtva += $delta;
343 $this->posxup += $delta;
344 $this->posxqty += $delta;
345 $this->posxunit += $delta;
346 $this->posxdiscount += $delta;
352 if (!empty($tplidx)) {
353 $pdf->useTemplate($tplidx);
356 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs, (is_object($outputlangsbis) ? $outputlangsbis :
null));
357 $pdf->SetFont(
'',
'', $default_font_size - 1);
358 $pdf->MultiCell(0, 3,
'');
359 $pdf->SetTextColor(0, 0, 0);
362 $tab_top = 90 + $top_shift;
363 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
366 $height_incoterms = 0;
367 if (isModEnabled(
'incoterm')) {
368 $desc_incoterms = $object->getIncotermsForPDF();
369 if ($desc_incoterms) {
372 $pdf->SetFont(
'',
'', $default_font_size - 1);
373 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
374 $nexY = $pdf->GetY();
375 $height_incoterms = $nexY - $tab_top;
378 $pdf->SetDrawColor(192, 192, 192);
379 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
381 $tab_top = $nexY + 6;
386 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
387 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
389 if (is_object($object->thirdparty)) {
390 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
391 $salerepobj =
new User($this->db);
392 $salerepobj->fetch($salereparray[0][
'id']);
393 if (!empty($salerepobj->signature)) {
394 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
399 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
400 if (!empty($extranote)) {
412 $pdf->SetFont(
'',
'', $default_font_size - 1);
413 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
414 $nexY = $pdf->GetY();
415 $height_note = $nexY - $tab_top;
418 $pdf->SetDrawColor(192, 192, 192);
419 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
421 $tab_top = $nexY + 6;
424 $iniY = $tab_top + 7;
425 $curY = $tab_top + 7;
426 $nexY = $tab_top + 7;
429 for ($i = 0; $i < $nblines; $i++) {
431 $pdf->SetFont(
'',
'', $default_font_size - 1);
432 $pdf->SetTextColor(0, 0, 0);
434 $pdf->setTopMargin($tab_top_newpage);
435 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
436 $pageposbefore = $pdf->getPage();
439 $curX = $this->posxdesc - 1;
441 $showpricebeforepagebreak = 1;
443 $pdf->startTransaction();
444 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc);
445 $pageposafter = $pdf->getPage();
446 if ($pageposafter > $pageposbefore) {
447 $pdf->rollbackTransaction(
true);
448 $pageposafter = $pageposbefore;
450 $pdf->setPageOrientation(
'', 1, $heightforfooter);
451 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc);
452 $pageposafter = $pdf->getPage();
453 $posyafter = $pdf->GetY();
454 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
455 if ($i == ($nblines - 1)) {
456 $pdf->AddPage(
'',
'',
true);
457 if (!empty($tplidx)) {
458 $pdf->useTemplate($tplidx);
461 $this->
_pagehead($pdf, $object, 0, $outputlangs);
463 $pdf->setPage($pageposafter + 1);
468 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
469 $showpricebeforepagebreak = 1;
471 $showpricebeforepagebreak = 0;
476 $pdf->commitTransaction();
478 $posYAfterDescription = $pdf->GetY();
480 $nexY = $pdf->GetY();
481 $pageposafter = $pdf->getPage();
483 $pdf->setPage($pageposbefore);
484 $pdf->setTopMargin($this->marge_haute);
485 $pdf->setPageOrientation(
'', 1, 0);
488 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
489 $pdf->setPage($pageposafter);
490 $curY = $tab_top_newpage;
493 $pdf->SetFont(
'',
'', $default_font_size - 1);
496 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
498 $pdf->SetXY($this->posxtva - 5, $curY);
499 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
504 $pdf->SetXY($this->posxup, $curY);
505 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
509 $pdf->SetXY($this->posxqty, $curY);
510 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
514 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
515 $pdf->SetXY($this->posxunit, $curY);
516 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
520 $pdf->SetXY($this->posxdiscount, $curY);
521 if ($object->lines[$i]->remise_percent) {
522 $pdf->SetXY($this->posxdiscount - 2, $curY);
524 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
529 $pdf->SetXY($this->postotalht, $curY);
530 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
533 if (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
534 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
536 $tvaligne = $object->lines[$i]->total_tva;
539 $localtax1ligne = $object->lines[$i]->total_localtax1;
540 $localtax2ligne = $object->lines[$i]->total_localtax2;
541 $localtax1_rate = $object->lines[$i]->localtax1_tx;
542 $localtax2_rate = $object->lines[$i]->localtax2_tx;
543 $localtax1_type = $object->lines[$i]->localtax1_type;
544 $localtax2_type = $object->lines[$i]->localtax2_type;
557 $vatrate = (string) $object->lines[$i]->tva_tx;
560 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
561 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
563 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
564 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
568 if ($localtax1_type && $localtax1ligne != 0) {
569 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
570 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
572 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
575 if ($localtax2_type && $localtax2ligne != 0) {
576 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
577 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
579 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
583 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
588 if (!isset($this->tva[$vatrate])) {
589 $this->tva[$vatrate] = 0;
591 $this->tva[$vatrate] += $tvaligne;
592 $vatcode = $object->lines[$i]->vat_src_code;
593 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
594 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
596 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
599 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
600 $pdf->setPage($pageposafter);
601 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
603 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
604 $pdf->SetLineStyle(array(
'dash'=>0));
610 while ($pagenb < $pageposafter) {
611 $pdf->setPage($pagenb);
613 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
615 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
617 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
619 $pdf->setPage($pagenb);
620 $pdf->setPageOrientation(
'', 1, 0);
622 $this->
_pagehead($pdf, $object, 0, $outputlangs);
624 if (!empty($tplidx)) {
625 $pdf->useTemplate($tplidx);
628 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
630 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
632 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
634 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
637 if (!empty($tplidx)) {
638 $pdf->useTemplate($tplidx);
642 $this->
_pagehead($pdf, $object, 0, $outputlangs);
649 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
651 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
653 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
656 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
659 $posy = $this->
_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
670 $this->
_pagefoot($pdf, $object, $outputlangs);
671 if (method_exists($pdf,
'AliasNbPages')) {
672 $pdf->AliasNbPages();
677 $pdf->Output($file,
'F');
680 $hookmanager->initHooks(array(
'pdfgeneration'));
681 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
683 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
685 $this->error = $hookmanager->error;
686 $this->errors = $hookmanager->errors;
691 $this->result = array(
'fullpath'=>$file);
695 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
699 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"COMMANDE_OUTPUTDIR");
735 global $conf, $mysoc;
738 $pdf->SetFont(
'',
'', $default_font_size - 1);
740 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
743 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
744 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
745 $pdf->SetXY($this->marge_gauche, $posy);
746 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
748 $posy = $pdf->GetY() + 4;
753 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
756 if ($object->cond_reglement_code || $object->cond_reglement) {
757 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
758 $pdf->SetXY($this->marge_gauche, $posy);
759 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
760 $pdf->MultiCell(43, 4, $titre, 0,
'L');
762 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
763 $pdf->SetXY($posxval, $posy);
764 $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);
765 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
766 if ($object->deposit_percent > 0) {
767 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement);
769 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
771 $posy = $pdf->GetY() + 3;
802 if (!empty($object->delivery_date)) {
803 $outputlangs->load(
"sendings");
804 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
805 $pdf->SetXY($this->marge_gauche, $posy);
806 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
807 $pdf->MultiCell(80, 4, $titre, 0,
'L');
808 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
809 $pdf->SetXY($posxval, $posy);
810 $dlp =
dol_print_date($object->delivery_date,
"daytext",
false, $outputlangs,
true);
811 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
813 $posy = $pdf->GetY() + 1;
814 } elseif ($object->availability_code || $object->availability) {
816 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
817 $pdf->SetXY($this->marge_gauche, $posy);
818 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
819 $pdf->MultiCell(80, 4, $titre, 0,
'L');
820 $pdf->SetTextColor(0, 0, 0);
821 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
822 $pdf->SetXY($posxval, $posy);
823 $lib_availability = $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) != (
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability :
'');
824 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
825 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
827 $posy = $pdf->GetY() + 1;
831 if ($object->mode_reglement_code
832 && $object->mode_reglement_code !=
'CHQ'
833 && $object->mode_reglement_code !=
'VIR') {
834 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
835 $pdf->SetXY($this->marge_gauche, $posy);
836 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
837 $pdf->MultiCell(80, 5, $titre, 0,
'L');
839 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
840 $pdf->SetXY($posxval, $posy);
841 $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);
842 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
844 $posy = $pdf->GetY() + 2;
848 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
850 if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
851 if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
852 $account =
new Account($this->db);
853 $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
855 $pdf->SetXY($this->marge_gauche, $posy);
856 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
857 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
858 $posy = $pdf->GetY() + 1;
860 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
861 $pdf->SetXY($this->marge_gauche, $posy);
862 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
863 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
864 $posy = $pdf->GetY() + 2;
867 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
868 $pdf->SetXY($this->marge_gauche, $posy);
869 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
870 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
871 $posy = $pdf->GetY() + 1;
873 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
874 $pdf->SetXY($this->marge_gauche, $posy);
875 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
876 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
877 $posy = $pdf->GetY() + 2;
884 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
885 if ($object->fk_account > 0 || $object->fk_bank > 0 ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
886 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
887 if ($object->fk_bank > 0) {
888 $bankid = $object->fk_bank;
890 $account =
new Account($this->db);
891 $account->fetch($bankid);
893 $curx = $this->marge_gauche;
896 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
918 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis =
null)
921 global $conf, $mysoc, $hookmanager;
925 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
926 $outputlangsbis =
new Translate(
'', $conf);
927 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
928 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
929 $default_font_size--;
934 $pdf->SetFont(
'',
'', $default_font_size - 1);
939 if ($this->page_largeur < 210) {
942 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
948 $pdf->SetFillColor(255, 255, 255);
949 $pdf->SetXY($col1x, $tab2_top);
950 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
952 $total_ht = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
953 $pdf->SetXY($col2x, $tab2_top);
954 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0,
'R', 1);
957 $pdf->SetFillColor(248, 248, 248);
959 $total_ttc = (isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
961 $this->atleastoneratenotnull = 0;
962 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
963 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
964 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) {
970 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
971 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
974 foreach ($localtax_rate as $tvakey => $tvaval) {
979 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
982 if (preg_match(
'/\*/', $tvakey)) {
983 $tvakey = str_replace(
'*',
'', $tvakey);
984 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
986 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
988 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
989 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
991 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
993 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
994 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1002 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1003 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1006 foreach ($localtax_rate as $tvakey => $tvaval) {
1011 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1014 if (preg_match(
'/\*/', $tvakey)) {
1015 $tvakey = str_replace(
'*',
'', $tvakey);
1016 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1018 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1020 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1021 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1023 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1025 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1026 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1033 foreach ($this->tva_array as $tvakey => $tvaval) {
1035 $this->atleastoneratenotnull++;
1038 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1041 if (preg_match(
'/\*/', $tvakey)) {
1042 $tvakey = str_replace(
'*',
'', $tvakey);
1043 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1045 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1048 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1050 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1052 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1054 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1056 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1057 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1064 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1065 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1069 foreach ($localtax_rate as $tvakey => $tvaval) {
1074 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1077 if (preg_match(
'/\*/', $tvakey)) {
1078 $tvakey = str_replace(
'*',
'', $tvakey);
1079 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1081 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1084 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1085 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1087 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1089 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1090 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1098 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1099 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1103 foreach ($localtax_rate as $tvakey => $tvaval) {
1109 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1112 if (preg_match(
'/\*/', $tvakey)) {
1113 $tvakey = str_replace(
'*',
'', $tvakey);
1114 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1116 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1119 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1120 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1122 $total_localtax = ((isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ?
price2num($tvaval * $object->multicurrency_tx,
'MT') : $tvaval);
1124 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1125 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1133 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1134 $pdf->SetTextColor(0, 0, 60);
1135 $pdf->SetFillColor(224, 224, 224);
1136 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalTTC", $mysoc->country_code) :
''), $useborder,
'L', 1);
1138 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1139 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1143 $pdf->SetTextColor(0, 0, 0);
1145 $creditnoteamount = 0;
1146 $depositsamount = 0;
1150 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1151 if (!empty($object->paye)) {
1155 if ($deja_regle > 0) {
1159 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1160 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1161 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1162 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1165 $pdf->SetTextColor(0, 0, 60);
1166 $pdf->SetFillColor(224, 224, 224);
1167 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1168 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), $useborder,
'L', 1);
1170 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1171 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1173 $pdf->SetFont(
'',
'', $default_font_size - 1);
1174 $pdf->SetTextColor(0, 0, 0);
1178 return ($tab2_top + ($tab2_hl * $index));
1196 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'', $outputlangsbis =
null)
1206 $currency = !empty($currency) ? $currency : $conf->currency;
1210 $pdf->SetTextColor(0, 0, 0);
1211 $pdf->SetFont(
'',
'', $default_font_size - 2);
1213 if (empty($hidetop)) {
1214 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1215 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1216 $titre .=
' - '.$outputlangsbis->transnoentities(
"AmountInCurrency", $outputlangsbis->transnoentitiesnoconv(
"Currency".$currency));
1219 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1220 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1223 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1224 $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));
1228 $pdf->SetDrawColor(128, 128, 128);
1229 $pdf->SetFont(
'',
'', $default_font_size - 1);
1232 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1234 if (empty($hidetop)) {
1235 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1237 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1238 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1241 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
1242 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1243 if (empty($hidetop)) {
1244 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1245 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1249 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1250 if (empty($hidetop)) {
1251 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1252 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1255 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1256 if (empty($hidetop)) {
1257 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1258 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1262 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1263 if (empty($hidetop)) {
1264 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1265 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1269 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1270 if (empty($hidetop)) {
1271 if ($this->atleastonediscount) {
1272 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1273 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1277 if ($this->atleastonediscount) {
1278 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1280 if (empty($hidetop)) {
1281 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1282 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1299 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null, $titlekey =
"PdfOrderTitle")
1302 global $conf, $langs, $hookmanager;
1304 $ltrdirection =
'L';
1305 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1306 $ltrdirection =
'R';
1310 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1316 $pdf->SetTextColor(0, 0, 60);
1317 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1321 $posy = $this->marge_haute;
1322 $posx = $this->page_largeur - $this->marge_droite - $w;
1324 $pdf->SetXY($this->marge_gauche, $posy);
1328 if ($this->emetteur->logo) {
1329 $logodir = $conf->mycompany->dir_output;
1330 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1331 $logodir = $conf->mycompany->multidir_output[$object->entity];
1334 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1336 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1338 if (is_readable($logo)) {
1340 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1342 $pdf->SetTextColor(200, 0, 0);
1343 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1344 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1345 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1348 $text = $this->emetteur->name;
1349 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1353 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1354 $pdf->SetXY($posx, $posy);
1355 $pdf->SetTextColor(0, 0, 60);
1356 $title = $outputlangs->transnoentities($titlekey);
1357 $title .=
' '.$outputlangs->convToOutputCharset($object->ref);
1358 if ($object->statut == $object::STATUS_DRAFT) {
1359 $pdf->SetTextColor(128, 0, 0);
1360 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1362 $pdf->MultiCell($w, 3, $title,
'',
'R');
1364 $pdf->SetFont(
'',
'B', $default_font_size);
1374 $pdf->SetFont(
'',
'', $default_font_size - 1);
1376 if ($object->ref_client) {
1378 $pdf->SetXY($posx, $posy);
1379 $pdf->SetTextColor(0, 0, 60);
1380 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
1383 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
1384 $object->fetch_projet();
1385 if (!empty($object->project->ref)) {
1387 $pdf->SetXY($posx, $posy);
1388 $pdf->SetTextColor(0, 0, 60);
1389 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1393 if (!empty($conf->global->PDF_SHOW_PROJECT)) {
1394 $object->fetch_projet();
1395 if (!empty($object->project->ref)) {
1396 $outputlangs->load(
"projects");
1398 $pdf->SetXY($posx, $posy);
1399 $pdf->SetTextColor(0, 0, 60);
1400 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1405 $pdf->SetXY($posx, $posy);
1406 $pdf->SetTextColor(0, 0, 60);
1407 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1409 if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) {
1411 $pdf->SetXY($posx, $posy);
1412 $pdf->SetTextColor(0, 0, 60);
1413 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1417 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1418 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1419 if (count($arrayidcontact) > 0) {
1420 $usertmp =
new User($this->db);
1421 $usertmp->fetch($arrayidcontact[0]);
1423 $pdf->SetXY($posx, $posy);
1424 $pdf->SetTextColor(0, 0, 60);
1425 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1433 $current_y = $pdf->getY();
1434 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
1435 if ($current_y < $pdf->getY()) {
1436 $top_shift = $pdf->getY() - $current_y;
1441 $carac_emetteur =
'';
1443 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1444 if (count($arrayidcontact) > 0) {
1445 $object->fetch_user($arrayidcontact[0]);
1446 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1447 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1449 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone :
'';
1451 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email :
'';
1453 $carac_emetteur .=
"\n";
1456 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1459 $posy = 42 + $top_shift;
1460 $posx = $this->marge_gauche;
1461 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1462 $posx = $this->page_largeur - $this->marge_droite - 80;
1467 if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
1468 $pdf->SetTextColor(0, 0, 0);
1469 $pdf->SetFont(
'',
'', $default_font_size - 2);
1470 $pdf->SetXY($posx, $posy - 5);
1471 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1472 $pdf->SetXY($posx, $posy);
1473 $pdf->SetFillColor(230, 230, 230);
1474 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1475 $pdf->SetTextColor(0, 0, 60);
1479 if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
1480 $pdf->SetXY($posx + 2, $posy + 3);
1481 $pdf->SetFont(
'',
'B', $default_font_size);
1482 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1483 $posy = $pdf->getY();
1487 $pdf->SetXY($posx + 2, $posy);
1488 $pdf->SetFont(
'',
'', $default_font_size - 1);
1489 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
1493 $usecontact =
false;
1494 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1495 if (count($arrayidcontact) > 0) {
1497 $result = $object->fetch_contact($arrayidcontact[0]);
1501 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)))) {
1502 $thirdparty = $object->contact;
1504 $thirdparty = $object->thirdparty;
1510 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact, $mode, $object);
1513 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1514 if ($this->page_largeur < 210) {
1517 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1518 $posy += $top_shift;
1519 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1520 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1521 $posx = $this->marge_gauche;
1525 if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
1526 $pdf->SetTextColor(0, 0, 0);
1527 $pdf->SetFont(
'',
'', $default_font_size - 2);
1528 $pdf->SetXY($posx + 2, $posy - 5);
1529 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1530 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1534 $pdf->SetXY($posx + 2, $posy + 3);
1535 $pdf->SetFont(
'',
'B', $default_font_size);
1536 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1538 $posy = $pdf->getY();
1541 $pdf->SetFont(
'',
'', $default_font_size - 1);
1542 $pdf->SetXY($posx + 2, $posy);
1543 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1546 $pdf->SetTextColor(0, 0, 0);