184 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
187 global $user, $langs,
$conf, $mysoc, $db, $hookmanager, $nblines;
189 if (!is_object($outputlangs)) {
190 $outputlangs = $langs;
194 $outputlangs->charset_output =
'ISO-8859-1';
198 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries",
"compta"));
205 global $outputlangsbis;
206 $outputlangsbis =
null;
210 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries",
"compta"));
213 $nblines = count(
$object->lines);
215 if (
$conf->commande->multidir_output[
$conf->entity]) {
222 $dir =
$conf->commande->multidir_output[
$conf->entity];
223 $file = $dir.
"/SPECIMEN.pdf";
233 $dir =
$conf->commande->multidir_output[
$object->entity].
"/".$objectref;
234 $file = $dir.
"/".$objectref.$suffix.
".pdf";
237 if (!file_exists($dir)) {
239 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
244 if (file_exists($dir)) {
246 if (!is_object($hookmanager)) {
247 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
250 $hookmanager->initHooks(array(
'pdfgeneration'));
251 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
253 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
256 $nblines = count(
$object->lines);
261 $pdf->SetAutoPageBreak(1, 0);
263 $heightforinfotot = 40;
265 $heightforfooter = $this->marge_basse + 8;
267 $heightforfooter += 6;
270 if (class_exists(
'TCPDF')) {
271 $pdf->setPrintHeader(
false);
272 $pdf->setPrintFooter(
false);
277 $logodir =
$conf->mycompany->dir_output;
278 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
279 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
281 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
282 $tplidx = $pdf->importPage(1);
287 $pdf->SetDrawColor(128, 128, 128);
289 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
290 $pdf->SetSubject($outputlangs->transnoentities(
"PdfOrderTitle"));
291 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
292 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
293 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfOrderTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
295 $pdf->SetCompression(
false);
299 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
302 for ($i = 0; $i < $nblines; $i++) {
303 if (
$object->lines[$i]->remise_percent) {
304 $this->atleastonediscount++;
307 if (empty($this->atleastonediscount)) {
308 $delta = ($this->postotalht - $this->posxdiscount);
309 $this->posxpicture += $delta;
310 $this->posxtva += $delta;
311 $this->posxup += $delta;
312 $this->posxqty += $delta;
313 $this->posxunit += $delta;
314 $this->posxdiscount += $delta;
320 if (!empty($tplidx)) {
321 $pdf->useTemplate($tplidx);
324 $pagehead = $this->
_pagehead($pdf,
$object, 1, $outputlangs, (is_object($outputlangsbis) ? $outputlangsbis :
null));
325 $top_shift = $pagehead[
'top_shift'];
326 $shipp_shift = $pagehead[
'shipp_shift'];
327 $pdf->SetFont(
'',
'', $default_font_size - 1);
328 $pdf->MultiCell(0, 3,
'');
329 $pdf->SetTextColor(0, 0, 0);
331 $tab_top = 90 + $top_shift + $shipp_shift;
332 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
335 $height_incoterms = 0;
336 if (isModEnabled(
'incoterm')) {
337 $desc_incoterms =
$object->getIncotermsForPDF();
338 if ($desc_incoterms) {
341 $pdf->SetFont(
'',
'', $default_font_size - 1);
342 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
343 $nexY = $pdf->GetY();
344 $height_incoterms = $nexY - $tab_top;
347 $pdf->SetDrawColor(192, 192, 192);
348 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 3, $this->corner_radius,
'1234',
'D');
350 $tab_top = $nexY + 6;
355 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
358 if (is_object(
$object->thirdparty)) {
359 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
360 $salerepobj =
new User($this->db);
361 $salerepobj->fetch($salereparray[0][
'id']);
362 if (!empty($salerepobj->signature)) {
363 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
368 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
369 if (!empty($extranote)) {
381 $pdf->SetFont(
'',
'', $default_font_size - 1);
382 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
383 $nexY = $pdf->GetY();
384 $height_note = $nexY - $tab_top;
387 $pdf->SetDrawColor(192, 192, 192);
388 $pdf->RoundedRect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1, $this->corner_radius,
'1234',
'D');
390 $tab_top = $nexY + 6;
393 $iniY = $tab_top + 7;
394 $curY = $tab_top + 7;
395 $nexY = $tab_top + 7;
398 for ($i = 0; $i < $nblines; $i++) {
400 $pdf->SetFont(
'',
'', $default_font_size - 1);
401 $pdf->SetTextColor(0, 0, 0);
403 $pdf->setTopMargin($tab_top_newpage);
404 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
405 $pageposbefore = $pdf->getPage();
408 $curX = $this->posxdesc - 1;
410 $showpricebeforepagebreak = 1;
412 $pdf->startTransaction();
414 $pageposafter = $pdf->getPage();
415 if ($pageposafter > $pageposbefore) {
416 $pdf->rollbackTransaction(
true);
417 $pageposafter = $pageposbefore;
419 $pdf->setPageOrientation(
'', 1, $heightforfooter);
421 $pageposafter = $pdf->getPage();
422 $posyafter = $pdf->GetY();
423 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
424 if ($i == ($nblines - 1)) {
425 $pdf->AddPage(
'',
'',
true);
426 if (!empty($tplidx)) {
427 $pdf->useTemplate($tplidx);
432 $pdf->setPage($pageposafter + 1);
438 $showpricebeforepagebreak = 1;
440 $showpricebeforepagebreak = 0;
444 $pdf->commitTransaction();
446 $posYAfterDescription = $pdf->GetY();
448 $nexY = $pdf->GetY();
449 $pageposafter = $pdf->getPage();
451 $pdf->setPage($pageposbefore);
452 $pdf->setTopMargin($this->marge_haute);
453 $pdf->setPageOrientation(
'', 1, 0);
456 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
457 $pdf->setPage($pageposafter);
458 $curY = $tab_top_newpage;
461 $pdf->SetFont(
'',
'', $default_font_size - 1);
466 $pdf->SetXY($this->posxtva - 5, $curY);
467 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
472 $pdf->SetXY($this->posxup, $curY);
473 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
477 $pdf->SetXY($this->posxqty, $curY);
478 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
483 $pdf->SetXY($this->posxunit, $curY);
484 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
488 $pdf->SetXY($this->posxdiscount, $curY);
489 if (
$object->lines[$i]->remise_percent) {
490 $pdf->SetXY($this->posxdiscount - 2, $curY);
492 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
497 $pdf->SetXY($this->postotalht, $curY);
498 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
501 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
502 $tvaligne =
$object->lines[$i]->multicurrency_total_tva;
504 $tvaligne =
$object->lines[$i]->total_tva;
507 $localtax1ligne =
$object->lines[$i]->total_localtax1;
508 $localtax2ligne =
$object->lines[$i]->total_localtax2;
509 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
510 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
511 $localtax1_type =
$object->lines[$i]->localtax1_type;
512 $localtax2_type =
$object->lines[$i]->localtax2_type;
525 $vatrate = (string)
$object->lines[$i]->tva_tx;
528 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
529 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
531 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
532 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
536 if ($localtax1_type && $localtax1ligne != 0) {
537 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
538 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
540 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
543 if ($localtax2_type && $localtax2ligne != 0) {
544 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
545 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
547 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
551 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
556 if (!isset($this->tva[$vatrate])) {
557 $this->tva[$vatrate] = 0;
559 $this->tva[$vatrate] += $tvaligne;
560 $vatcode =
$object->lines[$i]->vat_src_code;
561 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
562 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
564 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
568 $pdf->setPage($pageposafter);
569 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
571 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
572 $pdf->SetLineStyle(array(
'dash' => 0));
578 while ($pagenb < $pageposafter) {
579 $pdf->setPage($pagenb);
581 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
583 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
587 $pdf->setPage($pagenb);
588 $pdf->setPageOrientation(
'', 1, 0);
592 if (!empty($tplidx)) {
593 $pdf->useTemplate($tplidx);
596 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
598 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
600 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
605 if (!empty($tplidx)) {
606 $pdf->useTemplate($tplidx);
617 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
619 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
621 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
639 if (method_exists($pdf,
'AliasNbPages')) {
640 $pdf->AliasNbPages();
644 if (!empty($mysoc->termsofsale) &&
getDolGlobalInt(
'MAIN_PDF_ADD_TERMSOFSALE_ORDER')) {
645 $termsofsale =
$conf->mycompany->dir_output.
'/'.$mysoc->termsofsale;
646 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
647 $termsofsale =
$conf->mycompany->multidir_output[
$object->entity].
'/'.$mysoc->termsofsale;
649 if (file_exists($termsofsale) && is_readable($termsofsale)) {
650 $pagecount = $pdf->setSourceFile($termsofsale);
651 for ($i = 1; $i <= $pagecount; $i++) {
652 $tplIdx = $pdf->importPage($i);
653 if ($tplIdx!==
false) {
654 $s = $pdf->getTemplatesize($tplIdx);
655 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
656 $pdf->useTemplate($tplIdx);
658 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
666 $pdf->Output($file,
'F');
669 $hookmanager->initHooks(array(
'pdfgeneration'));
670 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
672 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
674 $this->error = $hookmanager->error;
675 $this->errors = $hookmanager->errors;
680 $this->result = array(
'fullpath' => $file);
684 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
688 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"COMMANDE_OUTPUTDIR");
724 global
$conf, $mysoc;
727 $pdf->SetFont(
'',
'', $default_font_size - 1);
732 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
733 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
734 $pdf->SetXY($this->marge_gauche, $posy);
735 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
737 $posy = $pdf->GetY() + 4;
746 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
747 $pdf->SetXY($this->marge_gauche, $posy);
748 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
749 $pdf->MultiCell(43, 4, $titre, 0,
'L');
751 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
752 $pdf->SetXY($posxval, $posy);
753 $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);
754 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
755 if (
$object->deposit_percent > 0) {
756 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__', (
string)
$object->deposit_percent, $lib_condition_paiement);
758 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
760 $posy = $pdf->GetY() + 3;
791 if (!empty(
$object->delivery_date)) {
792 $outputlangs->load(
"sendings");
793 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
794 $pdf->SetXY($this->marge_gauche, $posy);
795 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
796 $pdf->MultiCell(80, 4, $titre, 0,
'L');
797 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
798 $pdf->SetXY($posxval, $posy);
800 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
802 $posy = $pdf->GetY() + 1;
805 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
806 $pdf->SetXY($this->marge_gauche, $posy);
807 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
808 $pdf->MultiCell(80, 4, $titre, 0,
'L');
809 $pdf->SetTextColor(0, 0, 0);
810 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
811 $pdf->SetXY($posxval, $posy);
812 $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 :
'');
813 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
814 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
816 $posy = $pdf->GetY() + 1;
820 if (
$object->mode_reglement_code
821 &&
$object->mode_reglement_code !=
'CHQ'
822 &&
$object->mode_reglement_code !=
'VIR') {
823 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
824 $pdf->SetXY($this->marge_gauche, $posy);
825 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
826 $pdf->MultiCell(80, 5, $titre, 0,
'L');
828 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
829 $pdf->SetXY($posxval, $posy);
830 $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);
831 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
833 $posy = $pdf->GetY() + 2;
837 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
841 $account =
new Account($this->db);
844 $pdf->SetXY($this->marge_gauche, $posy);
845 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
846 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L', 0);
847 $posy = $pdf->GetY() + 1;
850 $pdf->SetXY($this->marge_gauche, $posy);
851 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
852 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
853 $posy = $pdf->GetY() + 2;
856 if (
$conf->global->FACTURE_CHQ_NUMBER == -1) {
857 $pdf->SetXY($this->marge_gauche, $posy);
858 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
859 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
860 $posy = $pdf->GetY() + 1;
863 $pdf->SetXY($this->marge_gauche, $posy);
864 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
865 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
866 $posy = $pdf->GetY() + 2;
873 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
875 $bankid = (
$object->fk_account <= 0 ?
$conf->global->FACTURE_RIB_NUMBER :
$object->fk_account);
879 $account =
new Account($this->db);
880 $account->fetch($bankid);
882 $curx = $this->marge_gauche;
885 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
910 global
$conf, $mysoc, $hookmanager;
917 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
918 $default_font_size--;
923 $pdf->SetFont(
'',
'', $default_font_size - 1);
928 if ($this->page_largeur < 210) {
931 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
937 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
940 $total_line_remise = 0;
941 foreach (
$object->lines as $i => $line) {
943 $total_line_remise += (is_numeric($resdiscount) ? $resdiscount : 0);
945 if ($line->total_ht < 0) {
946 $total_line_remise += -$line->total_ht;
949 if ($total_line_remise > 0) {
950 $pdf->SetFillColor(255, 255, 255);
951 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
952 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L', 1);
953 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
954 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise, 0, $outputlangs), 0,
'R', 1);
959 $pdf->SetFillColor(255, 255, 255);
960 $pdf->SetXY($col1x, $tab2_top);
961 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L', 1);
962 $pdf->SetXY($col2x, $tab2_top);
963 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_line_remise + $total_ht, 0, $outputlangs), 0,
'R', 1);
969 $pdf->SetFillColor(255, 255, 255);
970 $pdf->SetXY($col1x, $tab2_top+ $tab2_hl * $index);
971 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
973 $total_ht = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
974 $pdf->SetXY($col2x, $tab2_top+ $tab2_hl * $index);
975 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R', 1);
978 $pdf->SetFillColor(248, 248, 248);
980 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
982 $this->atleastoneratenotnull = 0;
984 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
989 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
990 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
993 foreach ($localtax_rate as $tvakey => $tvaval) {
998 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1001 if (preg_match(
'/\*/', (
string) $tvakey)) {
1002 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1003 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1005 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1009 $totalvat .= $tvacompl;
1011 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1014 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1016 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1018 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1019 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1025 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1026 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1029 foreach ($localtax_rate as $tvakey => $tvaval) {
1034 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1037 if (preg_match(
'/\*/', (
string) $tvakey)) {
1038 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1039 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1041 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1045 $totalvat .= $tvacompl;
1047 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1050 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1052 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1054 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1055 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1061 foreach ($this->tva_array as $tvakey => $tvaval) {
1063 $this->atleastoneratenotnull++;
1066 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1069 if (preg_match(
'/\*/', $tvakey)) {
1070 $tvakey = str_replace(
'*',
'', $tvakey);
1071 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1073 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1076 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1078 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1080 $totalvat .= $tvacompl;
1082 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1084 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1086 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1087 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1094 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1095 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1099 foreach ($localtax_rate as $tvakey => $tvaval) {
1104 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1107 if (preg_match(
'/\*/', (
string) $tvakey)) {
1108 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1109 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1111 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1115 $totalvat .= $tvacompl;
1117 $totalvat .=
vatrate((
string) abs((
float) $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 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1134 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1138 foreach ($localtax_rate as $tvakey => $tvaval) {
1144 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1147 if (preg_match(
'/\*/', (
string) $tvakey)) {
1148 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1149 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1151 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1155 $totalvat .= $tvacompl;
1157 $totalvat .=
vatrate((
string) abs((
float) $tvakey), 1).$tvacompl;
1160 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1162 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1164 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1165 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R', 1);
1173 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1174 $pdf->SetTextColor(0, 0, 60);
1175 $pdf->SetFillColor(224, 224, 224);
1176 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalTTC", $mysoc->country_code) :
''), $useborder,
'L', 1);
1178 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1179 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1183 $pdf->SetTextColor(0, 0, 0);
1185 $creditnoteamount = 0;
1186 $depositsamount = 0;
1190 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1195 if ($deja_regle > 0) {
1199 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1200 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1201 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1202 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1205 $pdf->SetTextColor(0, 0, 60);
1206 $pdf->SetFillColor(224, 224, 224);
1207 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1208 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), $useborder,
'L', 1);
1210 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1211 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1213 $pdf->SetFont(
'',
'', $default_font_size - 1);
1214 $pdf->SetTextColor(0, 0, 0);
1218 return ($tab2_top + ($tab2_hl * $index));
1236 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'', $outputlangsbis =
null)
1246 $currency = !empty($currency) ? $currency :
$conf->currency;
1250 $pdf->SetTextColor(0, 0, 0);
1251 $pdf->SetFont(
'',
'', $default_font_size - 2);
1253 if (empty($hidetop)) {
1254 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1255 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1256 $titre .=
' - '.$outputlangsbis->transnoentities(
"AmountInCurrency", $outputlangsbis->transnoentitiesnoconv(
"Currency".$currency));
1259 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1260 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1264 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius,
'1001',
'F',
null, explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
1268 $pdf->SetDrawColor(128, 128, 128);
1269 $pdf->SetFont(
'',
'', $default_font_size - 1);
1272 $this->
printRoundedRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $this->corner_radius, $hidetop, $hidebottom,
'D');
1274 if (empty($hidetop)) {
1275 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1277 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1278 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1282 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1283 if (empty($hidetop)) {
1284 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1285 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1289 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1290 if (empty($hidetop)) {
1291 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1292 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1295 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1296 if (empty($hidetop)) {
1297 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1298 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1302 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1303 if (empty($hidetop)) {
1304 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1305 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1309 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1310 if (empty($hidetop)) {
1311 if ($this->atleastonediscount) {
1312 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1313 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1317 if ($this->atleastonediscount) {
1318 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1320 if (empty($hidetop)) {
1321 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1322 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1339 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null, $titlekey =
"PdfOrderTitle")
1342 global
$conf, $langs, $hookmanager;
1344 $ltrdirection =
'L';
1345 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1346 $ltrdirection =
'R';
1350 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1356 $pdf->SetTextColor(0, 0, 60);
1357 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1361 $posy = $this->marge_haute;
1362 $posx = $this->page_largeur - $this->marge_droite - $w;
1364 $pdf->SetXY($this->marge_gauche, $posy);
1368 if ($this->emetteur->logo) {
1369 $logodir =
$conf->mycompany->dir_output;
1370 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
1371 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
1374 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1376 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1378 if (is_readable($logo)) {
1380 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1382 $pdf->SetTextColor(200, 0, 0);
1383 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1384 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1385 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1388 $text = $this->emetteur->name;
1389 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1393 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1394 $pdf->SetXY($posx, $posy);
1395 $pdf->SetTextColor(0, 0, 60);
1396 $title = $outputlangs->transnoentities($titlekey);
1397 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1398 if (
$object->statut == $object::STATUS_DRAFT) {
1399 $pdf->SetTextColor(128, 0, 0);
1400 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1402 $pdf->MultiCell($w, 3, $title,
'',
'R');
1404 $pdf->SetFont(
'',
'B', $default_font_size);
1414 $pdf->SetFont(
'',
'', $default_font_size - 1);
1418 $pdf->SetXY($posx, $posy);
1419 $pdf->SetTextColor(0, 0, 60);
1420 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset(
$object->ref_client),
'',
'R');
1425 if (!empty(
$object->project->ref)) {
1427 $pdf->SetXY($posx, $posy);
1428 $pdf->SetTextColor(0, 0, 60);
1429 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1435 if (!empty(
$object->project->ref)) {
1436 $outputlangs->load(
"projects");
1438 $pdf->SetXY($posx, $posy);
1439 $pdf->SetTextColor(0, 0, 60);
1440 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1445 $pdf->SetXY($posx, $posy);
1446 $pdf->SetTextColor(0, 0, 60);
1447 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1451 $pdf->SetXY($posx, $posy);
1452 $pdf->SetTextColor(0, 0, 60);
1453 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1458 $pdf->SetXY($posx, $posy);
1459 $pdf->SetTextColor(0, 0, 60);
1460 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
1465 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1466 if (count($arrayidcontact) > 0) {
1467 $usertmp =
new User($this->db);
1468 $usertmp->fetch($arrayidcontact[0]);
1470 $pdf->SetXY($posx, $posy);
1471 $pdf->SetTextColor(0, 0, 60);
1472 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1481 $current_y = $pdf->getY();
1483 if ($current_y < $pdf->getY()) {
1484 $top_shift = $pdf->getY() - $current_y;
1489 $carac_emetteur =
'';
1491 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1492 if (count($arrayidcontact) > 0) {
1493 $object->fetch_user($arrayidcontact[0]);
1494 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1495 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1497 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1501 $carac_emetteur .=
"\n";
1507 $posy = 42 + $top_shift;
1508 $posx = $this->marge_gauche;
1510 $posx = $this->page_largeur - $this->marge_droite - 80;
1516 $pdf->SetTextColor(0, 0, 0);
1517 $pdf->SetFont(
'',
'', $default_font_size - 2);
1518 $pdf->SetXY($posx, $posy - 5);
1519 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1520 $pdf->SetXY($posx, $posy);
1521 $pdf->SetFillColor(230, 230, 230);
1522 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1523 $pdf->SetTextColor(0, 0, 60);
1528 $pdf->SetXY($posx + 2, $posy + 3);
1529 $pdf->SetFont(
'',
'B', $default_font_size);
1530 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1531 $posy = $pdf->getY();
1535 $pdf->SetXY($posx + 2, $posy);
1536 $pdf->SetFont(
'',
'', $default_font_size - 1);
1537 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
1541 $usecontact =
false;
1542 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1543 if (count($arrayidcontact) > 0) {
1545 $result =
$object->fetch_contact($arrayidcontact[0]);
1549 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1550 $thirdparty =
$object->contact;
1552 $thirdparty =
$object->thirdparty;
1562 if ($this->page_largeur < 210) {
1566 $posy += $top_shift;
1567 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1569 $posx = $this->marge_gauche;
1574 $pdf->SetTextColor(0, 0, 0);
1575 $pdf->SetFont(
'',
'', $default_font_size - 2);
1576 $pdf->SetXY($posx + 2, $posy - 5);
1577 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1578 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1582 $pdf->SetXY($posx + 2, $posy + 3);
1583 $pdf->SetFont(
'',
'B', $default_font_size);
1585 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1587 $posy = $pdf->getY();
1590 $pdf->SetFont(
'',
'', $default_font_size - 1);
1591 $pdf->SetXY($posx + 2, $posy);
1593 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1597 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
1599 if (!empty($idaddressshipping)) {
1600 $contactshipping =
$object->fetch_Contact($idaddressshipping[0]);
1601 $companystatic =
new Societe($this->db);
1602 $companystatic->fetch(
$object->contact->fk_soc);
1604 $carac_client_shipping =
pdf_build_address($outputlangs, $this->emetteur, $companystatic,
$object->contact, ($usecontact ? 1 : 0),
'target',
$object);
1609 if (!empty($carac_client_shipping)) {
1610 $posy += $hautcadre;
1615 $pdf->SetXY($posx + 2, $posy - 5);
1616 $pdf->SetFont(
'',
'', $default_font_size - 2);
1617 $pdf->MultiCell($widthrecbox,
'', $outputlangs->transnoentities(
'ShippingTo'), 0,
'L', 0);
1618 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1621 $pdf->SetXY($posx + 2, $posy + 1);
1622 $pdf->SetFont(
'',
'B', $default_font_size);
1623 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
1625 $posy = $pdf->getY();
1628 $pdf->SetXY($posx + 2, $posy);
1629 $pdf->SetFont(
'',
'', $default_font_size - 1);
1630 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
1632 $shipp_shift += $hautcadre + 10;
1637 $pdf->SetTextColor(0, 0, 0);
1639 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);