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(
true, 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(
'',
true, $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(
'',
true, $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(
'',
true, 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',
false);
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',
false);
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(
'',
true, 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();
646 $termsofsale =
$conf->order->dir_output.
'/'.$termsofsalefilename;
647 if (!empty(
$conf->order->multidir_output[
$conf->entity])) {
648 $termsofsale =
$conf->order->multidir_output[
$conf->entity].
'/'.$termsofsalefilename;
650 if (file_exists($termsofsale) && is_readable($termsofsale)) {
651 $pagecount = $pdf->setSourceFile($termsofsale);
652 for ($i = 1; $i <= $pagecount; $i++) {
653 $tplIdx = $pdf->importPage($i);
654 if ($tplIdx !==
false) {
655 $s = $pdf->getTemplatesize($tplIdx);
656 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
657 $pdf->useTemplate($tplIdx);
659 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
667 $pdf->Output($file,
'F');
670 $hookmanager->initHooks(array(
'pdfgeneration'));
671 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
673 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
675 $this->error = $hookmanager->error;
676 $this->errors = $hookmanager->errors;
681 $this->result = array(
'fullpath' => $file);
685 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
689 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"COMMANDE_OUTPUTDIR");
725 global
$conf, $mysoc;
728 $pdf->SetFont(
'',
'', $default_font_size - 1);
733 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
734 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
735 $pdf->SetXY($this->marge_gauche, $posy);
736 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L',
false);
738 $posy = $pdf->GetY() + 4;
747 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
748 $pdf->SetXY($this->marge_gauche, $posy);
749 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
750 $pdf->MultiCell(43, 4, $titre, 0,
'L');
752 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
753 $pdf->SetXY($posxval, $posy);
754 $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);
755 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
756 if (
$object->deposit_percent > 0) {
757 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__', (
string)
$object->deposit_percent, $lib_condition_paiement);
759 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
761 $posy = $pdf->GetY() + 3;
792 if (!empty(
$object->delivery_date)) {
793 $outputlangs->load(
"sendings");
794 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
795 $pdf->SetXY($this->marge_gauche, $posy);
796 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
797 $pdf->MultiCell(80, 4, $titre, 0,
'L');
798 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
799 $pdf->SetXY($posxval, $posy);
801 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
803 $posy = $pdf->GetY() + 1;
806 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
807 $pdf->SetXY($this->marge_gauche, $posy);
808 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
809 $pdf->MultiCell(80, 4, $titre, 0,
'L');
810 $pdf->SetTextColor(0, 0, 0);
811 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
812 $pdf->SetXY($posxval, $posy);
813 $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 :
'');
814 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
815 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
817 $posy = $pdf->GetY() + 1;
821 if (
$object->mode_reglement_code
822 &&
$object->mode_reglement_code !=
'CHQ'
823 &&
$object->mode_reglement_code !=
'VIR') {
824 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
825 $pdf->SetXY($this->marge_gauche, $posy);
826 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
827 $pdf->MultiCell(80, 5, $titre, 0,
'L');
829 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
830 $pdf->SetXY($posxval, $posy);
831 $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);
832 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
834 $posy = $pdf->GetY() + 2;
838 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
842 $account =
new Account($this->db);
845 $pdf->SetXY($this->marge_gauche, $posy);
846 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
847 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L',
false);
848 $posy = $pdf->GetY() + 1;
851 $pdf->SetXY($this->marge_gauche, $posy);
852 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
853 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L',
false);
854 $posy = $pdf->GetY() + 2;
857 if (
$conf->global->FACTURE_CHQ_NUMBER == -1) {
858 $pdf->SetXY($this->marge_gauche, $posy);
859 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
860 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L',
false);
861 $posy = $pdf->GetY() + 1;
864 $pdf->SetXY($this->marge_gauche, $posy);
865 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
866 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L',
false);
867 $posy = $pdf->GetY() + 2;
874 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
876 $bankid = (
$object->fk_account <= 0 ?
$conf->global->FACTURE_RIB_NUMBER :
$object->fk_account);
880 $account =
new Account($this->db);
881 $account->fetch($bankid);
883 $curx = $this->marge_gauche;
886 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
911 global
$conf, $mysoc, $hookmanager;
918 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
919 $default_font_size--;
924 $pdf->SetFont(
'',
'', $default_font_size - 1);
929 if ($this->page_largeur < 210) {
932 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
938 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
941 $total_discount_on_lines = 0;
942 $multicurrency_total_discount_on_lines = 0;
943 foreach (
$object->lines as $i => $line) {
947 $total_discount_on_lines += (is_numeric($resdiscount) ? $resdiscount : 0);
948 $multicurrency_total_discount_on_lines += (is_numeric($multicurrency_resdiscount) ? $multicurrency_resdiscount : 0);
950 if ($line->total_ht < 0) {
951 $total_discount_on_lines += -$line->total_ht;
952 $multicurrency_total_discount_on_lines += -$line->multicurrency_total_ht;
956 if ($total_discount_on_lines > 0) {
958 $pdf->SetFillColor(255, 255, 255);
959 $pdf->SetXY($col1x, $tab2_top);
960 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L',
true);
961 $pdf->SetXY($col2x, $tab2_top);
963 $total_before_discount_to_show = ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? (
$object->multicurrency_total_ht + $multicurrency_total_discount_on_lines) : (
$object->total_ht + $total_discount_on_lines));
964 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_before_discount_to_show, 0, $outputlangs), 0,
'R',
true);
968 $pdf->SetFillColor(255, 255, 255);
969 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
970 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L',
true);
971 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
973 $total_discount_to_show = ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $multicurrency_total_discount_on_lines : $total_discount_on_lines);
974 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_discount_to_show, 0, $outputlangs), 0,
'R',
true);
980 $pdf->SetFillColor(255, 255, 255);
981 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
982 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L',
true);
984 $total_ht = ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
985 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
986 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty(
$object->remise) ?
$object->remise : 0), 0, $outputlangs), 0,
'R',
true);
989 $pdf->SetFillColor(248, 248, 248);
991 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
993 $this->atleastoneratenotnull = 0;
995 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1000 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1001 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1004 foreach ($localtax_rate as $tvakey => $tvaval) {
1009 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1012 if (preg_match(
'/\*/', (
string) $tvakey)) {
1013 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1014 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1016 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1020 $totalvat .= $tvacompl;
1022 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1025 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1027 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1029 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1030 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1036 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1037 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1040 foreach ($localtax_rate as $tvakey => $tvaval) {
1045 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1048 if (preg_match(
'/\*/', (
string) $tvakey)) {
1049 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1050 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1052 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1056 $totalvat .= $tvacompl;
1058 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1061 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1063 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1065 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1066 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1072 foreach ($this->tva_array as $tvakey => $tvaval) {
1074 $this->atleastoneratenotnull++;
1077 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1080 if (preg_match(
'/\*/', $tvakey)) {
1081 $tvakey = str_replace(
'*',
'', $tvakey);
1082 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1084 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1087 $totalvat .=
vatrate((
string) $tvaval[
'vatrate'],
true).$tvacompl;
1089 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1091 $totalvat .= $tvacompl;
1093 $totalvat .=
vatrate((
string) $tvaval[
'vatrate'],
true).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1095 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1097 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1098 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R',
true);
1105 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1106 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1110 foreach ($localtax_rate as $tvakey => $tvaval) {
1115 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1118 if (preg_match(
'/\*/', (
string) $tvakey)) {
1119 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1120 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1122 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1126 $totalvat .= $tvacompl;
1128 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1131 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1133 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1135 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1136 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1144 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1145 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1149 foreach ($localtax_rate as $tvakey => $tvaval) {
1155 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1158 if (preg_match(
'/\*/', (
string) $tvakey)) {
1159 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1160 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1162 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1166 $totalvat .= $tvacompl;
1168 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1171 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1173 $total_localtax = ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1175 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1176 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1184 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1185 $pdf->SetTextColor(0, 0, 60);
1186 $pdf->SetFillColor(224, 224, 224);
1187 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalTTC", $mysoc->country_code) :
''), $useborder,
'L',
true);
1189 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1190 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R',
true);
1194 $pdf->SetTextColor(0, 0, 0);
1196 $creditnoteamount = 0;
1197 $depositsamount = 0;
1201 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1206 if ($deja_regle > 0) {
1210 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1211 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L',
false);
1212 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1213 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R',
false);
1216 $pdf->SetTextColor(0, 0, 60);
1217 $pdf->SetFillColor(224, 224, 224);
1218 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1219 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), $useborder,
'L',
true);
1221 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1222 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R',
true);
1224 $pdf->SetFont(
'',
'', $default_font_size - 1);
1225 $pdf->SetTextColor(0, 0, 0);
1229 return ($tab2_top + ($tab2_hl * $index));
1247 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'', $outputlangsbis =
null)
1257 $currency = !empty($currency) ? $currency :
$conf->currency;
1261 $pdf->SetTextColor(0, 0, 0);
1262 $pdf->SetFont(
'',
'', $default_font_size - 2);
1264 if (empty($hidetop)) {
1265 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1266 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
1267 $titre .=
' - '.$outputlangsbis->transnoentities(
"AmountInCurrency", $outputlangsbis->transnoentitiesnoconv(
"Currency".$currency));
1270 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1271 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1275 $pdf->RoundedRect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5, $this->corner_radius,
'1001',
'F', array(), explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
1279 $pdf->SetDrawColor(128, 128, 128);
1280 $pdf->SetFont(
'',
'', $default_font_size - 1);
1283 $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');
1285 if (empty($hidetop)) {
1286 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1288 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1289 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1293 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1294 if (empty($hidetop)) {
1295 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1296 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1300 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1301 if (empty($hidetop)) {
1302 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1303 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1306 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1307 if (empty($hidetop)) {
1308 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1309 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1313 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1314 if (empty($hidetop)) {
1315 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1316 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1320 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1321 if (empty($hidetop)) {
1322 if ($this->atleastonediscount) {
1323 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1324 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1328 if ($this->atleastonediscount) {
1329 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1331 if (empty($hidetop)) {
1332 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1333 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1350 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null, $titlekey =
"PdfOrderTitle")
1353 global
$conf, $langs, $hookmanager;
1355 $ltrdirection =
'L';
1356 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1357 $ltrdirection =
'R';
1361 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1367 $pdf->SetTextColor(0, 0, 60);
1368 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1372 $posy = $this->marge_haute;
1373 $posx = $this->page_largeur - $this->marge_droite - $w;
1375 $pdf->SetXY($this->marge_gauche, $posy);
1379 if ($this->emetteur->logo) {
1380 $logodir =
$conf->mycompany->dir_output;
1381 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
1382 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
1385 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1387 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1389 if (is_readable($logo)) {
1391 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1393 $pdf->SetTextColor(200, 0, 0);
1394 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1395 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1396 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1399 $text = $this->emetteur->name;
1400 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1404 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1405 $pdf->SetXY($posx, $posy);
1406 $pdf->SetTextColor(0, 0, 60);
1407 $title = $outputlangs->transnoentities($titlekey);
1408 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
1409 if (
$object->statut == $object::STATUS_DRAFT) {
1410 $pdf->SetTextColor(128, 0, 0);
1411 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1413 $pdf->MultiCell($w, 3, $title,
'',
'R');
1415 $pdf->SetFont(
'',
'B', $default_font_size);
1425 $pdf->SetFont(
'',
'', $default_font_size - 1);
1429 $pdf->SetXY($posx, $posy);
1430 $pdf->SetTextColor(0, 0, 60);
1431 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset(
$object->ref_client),
'',
'R');
1436 if (!empty(
$object->project->ref)) {
1437 $posy = $pdf->GetY();
1438 $pdf->SetXY($posx, $posy);
1439 $pdf->SetTextColor(0, 0, 60);
1440 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
1446 if (!empty(
$object->project->ref)) {
1447 $outputlangs->load(
"projects");
1448 $posy = $pdf->GetY();
1449 $pdf->SetXY($posx, $posy);
1450 $pdf->SetTextColor(0, 0, 60);
1451 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
1455 $posy = $pdf->GetY();
1456 $pdf->SetXY($posx, $posy);
1457 $pdf->SetTextColor(0, 0, 60);
1458 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1461 $posy = $pdf->GetY();
1462 $pdf->SetXY($posx, $posy);
1463 $pdf->SetTextColor(0, 0, 60);
1464 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
1469 $pdf->SetXY($posx, $posy);
1470 $pdf->SetTextColor(0, 0, 60);
1471 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
1476 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1477 if (count($arrayidcontact) > 0) {
1478 $usertmp =
new User($this->db);
1479 $usertmp->fetch($arrayidcontact[0]);
1481 $pdf->SetXY($posx, $posy);
1482 $pdf->SetTextColor(0, 0, 60);
1483 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1492 $current_y = $pdf->getY();
1494 if ($current_y < $pdf->getY()) {
1495 $top_shift = $pdf->getY() - $current_y;
1500 $carac_emetteur =
'';
1502 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
1503 if (count($arrayidcontact) > 0) {
1504 $object->fetch_user($arrayidcontact[0]);
1505 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1506 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
1508 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty(
$object->user->office_phone)) ?
$object->user->office_phone :
'';
1512 $carac_emetteur .=
"\n";
1518 $posy = 42 + $top_shift;
1519 $posx = $this->marge_gauche;
1521 $posx = $this->page_largeur - $this->marge_droite - 80;
1527 $pdf->SetTextColor(0, 0, 0);
1528 $pdf->SetFont(
'',
'', $default_font_size - 2);
1529 $pdf->SetXY($posx, $posy - 5);
1530 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1531 $pdf->SetXY($posx, $posy);
1532 $pdf->SetFillColor(230, 230, 230);
1533 $pdf->RoundedRect($posx, $posy, 82, $hautcadre, $this->corner_radius,
'1234',
'F');
1534 $pdf->SetTextColor(0, 0, 60);
1539 $pdf->SetXY($posx + 2, $posy + 3);
1540 $pdf->SetFont(
'',
'B', $default_font_size);
1541 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1542 $posy = $pdf->getY();
1546 $pdf->SetXY($posx + 2, $posy);
1547 $pdf->SetFont(
'',
'', $default_font_size - 1);
1548 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
1552 $usecontact =
false;
1553 $arrayidcontact =
$object->getIdContact(
'external',
'CUSTOMER');
1554 if (count($arrayidcontact) > 0) {
1556 $result =
$object->fetch_contact($arrayidcontact[0]);
1560 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
1561 $thirdparty =
$object->contact;
1563 $thirdparty =
$object->thirdparty;
1573 if ($this->page_largeur < 210) {
1577 $posy += $top_shift;
1578 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1580 $posx = $this->marge_gauche;
1585 $pdf->SetTextColor(0, 0, 0);
1586 $pdf->SetFont(
'',
'', $default_font_size - 2);
1587 $pdf->SetXY($posx + 2, $posy - 5);
1588 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1589 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1593 $pdf->SetXY($posx + 2, $posy + 3);
1594 $pdf->SetFont(
'',
'B', $default_font_size);
1596 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1598 $posy = $pdf->getY();
1601 $pdf->SetFont(
'',
'', $default_font_size - 1);
1602 $pdf->SetXY($posx + 2, $posy);
1604 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1608 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
1610 if (!empty($idaddressshipping)) {
1611 $contactshipping =
$object->fetch_Contact($idaddressshipping[0]);
1612 $companystatic =
new Societe($this->db);
1613 $companystatic->fetch(
$object->contact->fk_soc);
1620 if (!empty($carac_client_shipping)) {
1621 $posy += $hautcadre;
1626 $pdf->SetXY($posx + 2, $posy - 5);
1627 $pdf->SetFont(
'',
'', $default_font_size - 2);
1628 $pdf->MultiCell($widthrecbox, 0, $outputlangs->transnoentities(
'ShippingTo'), 0,
'L',
false);
1629 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
1632 $pdf->SetXY($posx + 2, $posy + 1);
1633 $pdf->SetFont(
'',
'B', $default_font_size);
1634 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
1636 $posy = $pdf->getY();
1639 $pdf->SetXY($posx + 2, $posy);
1640 $pdf->SetFont(
'',
'', $default_font_size - 1);
1641 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
1643 $shipp_shift += $hautcadre + 10;
1648 $pdf->SetTextColor(0, 0, 0);
1650 $pagehead = array(
'top_shift' => $top_shift,
'shipp_shift' => $shipp_shift);