202 public function write_file(
$object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
205 global $user, $langs,
$conf, $mysoc, $hookmanager, $nblines;
207 dol_syslog(
"write_file outputlangs->defaultlang=".(is_object($outputlangs) ? $outputlangs->defaultlang :
'null'));
209 if (!is_object($outputlangs)) {
210 $outputlangs = $langs;
214 $outputlangs->charset_output =
'ISO-8859-1';
218 $outputlangs->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"compta"));
225 global $outputlangsbis;
226 $outputlangsbis =
null;
230 $outputlangsbis->loadLangs(array(
"main",
"bills",
"products",
"dict",
"companies",
"compta"));
233 $nblines = count(
$object->lines);
236 $realpatharray = array();
238 for ($i = 0; $i < $nblines; $i++) {
239 if (empty(
$object->lines[$i]->fk_product)) {
243 $objphoto =
new Product($this->db);
244 $objphoto->fetch(
$object->lines[$i]->fk_product);
246 $pdir =
get_exdir(
$object->lines[$i]->fk_product, 2, 0, 0, $objphoto,
'product').$object->lines[$i]->fk_product.
"/photos/";
247 $dir =
$conf->product->dir_output.
'/'.$pdir;
250 foreach ($objphoto->liste_photos($dir, 1) as $key => $obj) {
251 $filename = $obj[
'photo'];
253 $realpath = $dir.$filename;
258 $realpatharray[$i] = $realpath;
262 if (count($realpatharray) == 0) {
263 $this->posxpicture = $this->posxtva;
266 if (
$conf->facture->dir_output) {
269 $deja_regle =
$object->getSommePaiement((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
270 $amount_credit_notes_included =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
271 $amount_deposits_included =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
275 $dir = empty(
$conf->facture->multidir_output[
$object->entity]) ?
$conf->facture->dir_output :
$conf->facture->multidir_output[
$object->entity];
276 $file = $dir.
"/SPECIMEN.pdf";
279 $dir = (empty(
$conf->facture->multidir_output[
$object->entity]) ?
$conf->facture->dir_output :
$conf->facture->multidir_output[
$object->entity]).
"/".$objectref;
280 $file = $dir.
"/".$objectref.
".pdf";
282 if (!file_exists($dir)) {
284 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
289 if (file_exists($dir)) {
291 if (!is_object($hookmanager)) {
292 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
295 $hookmanager->initHooks(array(
'pdfgeneration'));
296 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
298 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
301 $nblines = count(
$object->lines);
302 $nbpayments = count(
$object->getListOfPayments());
307 $pdf->setAutoPageBreak(
true, 0);
309 $heightforinfotot = 50 + (4 * $nbpayments);
310 if ($heightforinfotot > 220) {
311 $heightforinfotot = 220;
314 $heightforfooter = $this->marge_basse + 8;
316 $heightforfooter += 6;
319 $heightforqrinvoice_firstpage = 0;
322 if ($heightforqrinvoice_firstpage > 0) {
324 $heightforinfotot = 30 + (4 * $nbpayments);
328 if (class_exists(
'TCPDF')) {
329 $pdf->setPrintHeader(
false);
330 $pdf->setPrintFooter(
false);
336 $logodir =
$conf->mycompany->dir_output;
337 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
338 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
340 $pagecount = $pdf->setSourceFile($logodir.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
341 $tplidx = $pdf->importPage(1);
346 $pdf->SetDrawColor(128, 128, 128);
348 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
349 $pdf->SetSubject($outputlangs->transnoentities(
"PdfInvoiceTitle"));
350 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
351 $pdf->SetAuthor($mysoc->name.($user->id > 0 ?
' - '.$outputlangs->convToOutputCharset($user->getFullName($outputlangs)) :
''));
352 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"PdfInvoiceTitle").
" ".$outputlangs->convToOutputCharset(
$object->thirdparty->name));
354 $pdf->SetCompression(
false);
358 $cert = empty($user->conf->CERTIFICATE_CRT) ?
'' : $user->conf->CERTIFICATE_CRT;
359 $certprivate = empty($user->conf->CERTIFICATE_CRT_PRIVATE) ?
'' : $user->conf->CERTIFICATE_CRT_PRIVATE;
370 'Name' => $this->emetteur->name,
371 'Location' =>
getCountry($this->emetteur->country_code,
''),
372 'Reason' =>
'INVOICE',
373 'ContactInfo' => $this->emetteur->email
375 $pdf->setSignature($cert, $certprivate, $this->emetteur->name,
'', 2, $info);
379 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
383 $categoryOfOperation = 0;
386 for ($i = 0; $i < $nblines; $i++) {
387 if (
$object->lines[$i]->remise_percent) {
388 $this->atleastonediscount++;
393 if (preg_match(
'/^\((.*)\)$/',
$object->lines[$i]->desc, $reg)) {
394 if ($reg[1] ==
'DEPOSIT') {
405 if ($categoryOfOperation < 2) {
406 $lineProductType =
$object->lines[$i]->product_type;
412 if ($nbProduct > 0 && $nbService > 0) {
414 $categoryOfOperation = 2;
419 if ($categoryOfOperation <= 0) {
421 if ($nbProduct == 0 && $nbService > 0) {
422 $categoryOfOperation = 1;
425 $this->categoryOfOperation = $categoryOfOperation;
426 if (empty($this->atleastonediscount)) {
427 $delta = ($this->posxprogress - $this->posxdiscount);
428 $this->posxpicture += $delta;
429 $this->posxtva += $delta;
430 $this->posxup += $delta;
431 $this->posxqty += $delta;
432 $this->posxunit += $delta;
433 $this->posxdiscount += $delta;
440 $this->situationinvoice =
true;
441 $progress_width = 10;
442 $this->posxpicture -= $progress_width;
443 $this->posxtva -= $progress_width;
444 $this->posxup -= $progress_width;
445 $this->posxqty -= $progress_width;
446 $this->posxunit -= $progress_width;
447 $this->posxdiscount -= $progress_width;
448 $this->posxprogress -= $progress_width;
453 if (!empty($tplidx)) {
454 $pdf->useTemplate($tplidx);
460 $pdf->SetFont(
'',
'', $default_font_size - 1);
461 $pdf->MultiCell(0, 3,
'');
462 $pdf->SetTextColor(0, 0, 0);
467 $tab_top = 90 + $top_shift;
468 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
471 $extra_under_address_shift = 0;
474 $qrcodestring =
$object->buildZATCAQRString();
477 $qrcodestring =
$object->buildSwitzerlandQRString();
481 $qrcodestring =
$object->buildEPCQrCodeString();
486 $qrcodecolor = array(
'25',
'25',
'25');
491 'fgcolor' => $qrcodecolor,
496 $pdf->write2DBarcode($qrcodestring,
'QRCODE,M', $this->marge_gauche, $tab_top - 5, 25, 25, $styleQr,
'N');
500 $pdf->SetXY($this->marge_gauche + 30, $pdf->GetY() - 15);
501 $pdf->SetFont(
'',
'', $default_font_size - 4);
502 $pdf->MultiCell(40, 3, $langs->transnoentitiesnoconv(
"INVOICE_ADD_EPC_QR_CODEPay"), 0,
'L',
false);
506 $extra_under_address_shift += 25;
514 'outputlangs' => $outputlangs,
515 'hidedetails' => $hidedetails
517 $reshook = $hookmanager->executeHooks(
'printUnderHeaderPDFline', $parameters, $this);
518 if (!empty($hookmanager->resArray[
'extra_under_address_shift'])) {
519 $extra_under_address_shift += $hookmanager->resArray[
'extra_under_address_shift'];
522 $tab_top += $extra_under_address_shift;
523 $tab_top_newpage += 0;
526 $height_incoterms = 0;
527 if (isModEnabled(
'incoterm')) {
528 $desc_incoterms =
$object->getIncotermsForPDF();
529 if ($desc_incoterms) {
532 $pdf->SetFont(
'',
'', $default_font_size - 1);
533 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
534 $nexY = $pdf->GetY();
535 $height_incoterms = $nexY - $tab_top;
538 $pdf->SetDrawColor(192, 192, 192);
539 $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');
541 $tab_top = $nexY + 6;
546 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
549 if (is_object(
$object->thirdparty)) {
550 $salereparray =
$object->thirdparty->getSalesRepresentatives($user);
551 $salerepobj =
new User($this->db);
552 $salerepobj->fetch($salereparray[0][
'id']);
553 if (!empty($salerepobj->signature)) {
554 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
559 $extranote = $this->getExtrafieldsInHtml(
$object, $outputlangs);
560 if (!empty($extranote)) {
572 $pdf->SetFont(
'',
'', $default_font_size - 1);
573 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
574 $nexY = $pdf->GetY();
575 $height_note = $nexY - $tab_top;
578 $pdf->SetDrawColor(192, 192, 192);
579 $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');
581 $tab_top = $nexY + 6;
584 $iniY = $tab_top + 7;
585 $curY = $tab_top + 7;
586 $nexY = $tab_top + 7;
589 for ($i = 0; $i < $nblines; $i++) {
591 $pdf->SetFont(
'',
'', $default_font_size - 1);
592 $pdf->SetTextColor(0, 0, 0);
595 $imglinesize = array();
596 if (!empty($realpatharray[$i])) {
600 $pdf->setTopMargin($tab_top_newpage);
601 $page_bottom_margin = $heightforfooter + $heightforfreetext + $heightforinfotot + $this->
getHeightForQRInvoice($pdf->getPage(),
$object, $langs);
602 $pdf->setPageOrientation(
'',
true, $page_bottom_margin);
603 $pageposbefore = $pdf->getPage();
605 $showpricebeforepagebreak = 1;
607 $posYAfterDescription = 0;
610 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height']) && ($curY + $imglinesize[
'height']) > ($this->page_hauteur - $page_bottom_margin)) {
611 $pdf->AddPage(
'',
'',
true);
612 if (!empty($tplidx)) {
613 $pdf->useTemplate($tplidx);
617 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
619 $pdf->setPage($pageposbefore + 1);
621 $curY = $tab_top_newpage;
625 $showpricebeforepagebreak = 1;
627 $showpricebeforepagebreak = 0;
631 if (isset($imglinesize[
'width']) && isset($imglinesize[
'height'])) {
632 $curX = $this->posxpicture - 1;
633 $pdf->Image($realpatharray[$i], $curX + (($this->posxtva - $this->posxpicture - $imglinesize[
'width']) / 2), $curY, $imglinesize[
'width'], $imglinesize[
'height'],
'',
'',
'', 2, 300);
635 $posYAfterImage = $curY + $imglinesize[
'height'];
639 $curX = $this->posxdesc - 1;
641 $pdf->startTransaction();
642 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
643 $pageposafter = $pdf->getPage();
644 if ($pageposafter > $pageposbefore) {
645 $pdf->rollbackTransaction(
true);
646 $pageposafter = $pageposbefore;
648 $pdf->setPageOrientation(
'',
true, $heightforfooter);
649 pdf_writelinedesc($pdf,
$object, $i, $outputlangs, $this->posxpicture - $curX - $progress_width, 3, $curX, $curY, $hideref, $hidedesc);
650 $pageposafter = $pdf->getPage();
651 $posyafter = $pdf->GetY();
653 if ($posyafter > ($this->page_hauteur - $page_bottom_margin)) {
654 if ($i == ($nblines - 1)) {
655 $pdf->AddPage(
'',
'',
true);
656 if (!empty($tplidx)) {
657 $pdf->useTemplate($tplidx);
661 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
663 $pdf->setPage($pageposafter + 1);
670 $showpricebeforepagebreak = 1;
672 $showpricebeforepagebreak = 0;
676 $pdf->commitTransaction();
678 $posYAfterDescription = $pdf->GetY();
680 $nexY = $pdf->GetY();
681 $pageposafter = $pdf->getPage();
682 $pdf->setPage($pageposbefore);
683 $pdf->setTopMargin($this->marge_haute);
684 $pdf->setPageOrientation(
'',
true, 0);
687 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
688 $pdf->setPage($pageposafter);
689 $curY = $tab_top_newpage;
692 $pdf->SetFont(
'',
'', $default_font_size - 1);
697 $pdf->SetXY($this->posxtva - 5, $curY);
698 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
703 $pdf->SetXY($this->posxup, $curY);
704 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R',
false);
708 $pdf->SetXY($this->posxqty, $curY);
709 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
714 $pdf->SetXY($this->posxunit, $curY);
715 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
719 if (
$object->lines[$i]->remise_percent) {
720 $pdf->SetXY($this->posxdiscount - 2, $curY);
722 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
726 if ($this->situationinvoice) {
728 $pdf->SetXY($this->posxprogress, $curY);
729 $pdf->MultiCell($this->postotalht - $this->posxprogress + 1, 3, $progress, 0,
'R');
734 $pdf->SetXY($this->postotalht, $curY);
735 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R',
false);
743 $prev_progress =
$object->lines[$i]->get_prev_progress(
$object->id);
744 if ($prev_progress > 0 && !empty(
$object->lines[$i]->situation_percent)) {
745 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
746 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
748 $tvaligne = $sign *
$object->lines[$i]->total_tva * (
$object->lines[$i]->situation_percent - $prev_progress) /
$object->lines[$i]->situation_percent;
751 if (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) {
752 $tvaligne = $sign *
$object->lines[$i]->multicurrency_total_tva;
754 $tvaligne = $sign *
$object->lines[$i]->total_tva;
758 $localtax1ligne =
$object->lines[$i]->total_localtax1;
759 $localtax2ligne =
$object->lines[$i]->total_localtax2;
760 $localtax1_rate =
$object->lines[$i]->localtax1_tx;
761 $localtax2_rate =
$object->lines[$i]->localtax2_tx;
762 $localtax1_type =
$object->lines[$i]->localtax1_type;
763 $localtax2_type =
$object->lines[$i]->localtax2_type;
765 $vatrate = (string)
$object->lines[$i]->tva_tx;
768 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
769 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
771 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
772 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
776 if ($localtax1_type && $localtax1ligne != 0) {
777 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
778 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
780 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
783 if ($localtax2_type && $localtax2ligne != 0) {
784 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
785 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
787 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
791 if ((
$object->lines[$i]->info_bits & 0x01) == 0x01) {
796 if (!isset($this->tva[$vatrate])) {
797 $this->tva[$vatrate] = 0;
799 $this->tva[$vatrate] += $tvaligne;
800 $vatcode =
$object->lines[$i]->vat_src_code;
802 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'tot_ht'])) {
803 $this->tva_array[$vatrate . ($vatcode ?
' (' . $vatcode .
')' :
'')][
'tot_ht'] = 0;
805 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne,
'tot_ht' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'tot_ht'] +
$object->lines[$i]->total_ht);
807 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
808 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
810 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate' => $vatrate,
'vatcode' => $vatcode,
'amount' => $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
813 if ($posYAfterImage > $posYAfterDescription) {
814 $nexY = $posYAfterImage;
819 $pdf->setPage($pageposafter);
820 $pdf->SetLineStyle(array(
'dash' =>
'1,1',
'color' => array(80, 80, 80)));
822 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
823 $pdf->SetLineStyle(array(
'dash' => 0));
829 while ($pagenb < $pageposafter) {
830 $pdf->setPage($pagenb);
832 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
834 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
838 $pdf->setPage($pagenb);
839 $pdf->setPageOrientation(
'',
true, 0);
842 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
844 if (!empty($tplidx)) {
845 $pdf->useTemplate($tplidx);
848 if (isset(
$object->lines[$i + 1]->pagebreak) &&
$object->lines[$i + 1]->pagebreak) {
850 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 1,
$object->multicurrency_code);
852 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1,
$object->multicurrency_code);
857 if (!empty($tplidx)) {
858 $pdf->useTemplate($tplidx);
863 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
870 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter - $heightforqrinvoice_firstpage, 0, $outputlangs, 0, 0,
$object->multicurrency_code);
871 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter - $heightforqrinvoice_firstpage + 1;
873 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0,
$object->multicurrency_code);
874 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
876 dol_syslog(
"bottomlasttab=".$bottomlasttab.
" this->page_hauteur=".$this->page_hauteur.
" heightforinfotot=".$heightforinfotot.
" heightforfreetext=".$heightforfreetext.
" heightforfooter=".$heightforfooter);
882 $posy = $this->
_tableau_tot($pdf,
$object, $deja_regle, $bottomlasttab, $outputlangs, $outputlangsbis);
885 $listofpayments =
$object->getListOfPayments(
'', 0, 1);
886 if ((count($listofpayments) || $amount_credit_notes_included || $amount_deposits_included) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
892 if (method_exists($pdf,
'AliasNbPages')) {
893 $pdf->AliasNbPages();
906 if (
getDolGlobalInt(
'MAIN_PDF_ADD_TERMSOFSALE_INVOICE') && $termsofsalefilename) {
907 $termsofsale =
$conf->invoice->dir_output.
'/'.$termsofsalefilename;
909 $termsofsale =
$conf->invoice->multidir_output[
$object->entity ??
$conf->entity].
'/'.$termsofsalefilename;
911 if (file_exists($termsofsale) && is_readable($termsofsale)) {
912 $pagecount = $pdf->setSourceFile($termsofsale);
913 for ($i = 1; $i <= $pagecount; $i++) {
914 $tplIdx = $pdf->importPage($i);
915 if ($tplIdx !==
false) {
916 $s = $pdf->getTemplatesize($tplIdx);
917 $pdf->AddPage($s[
'h'] > $s[
'w'] ?
'P' :
'L');
918 $pdf->useTemplate($tplIdx);
920 setEventMessages(
null, array($termsofsale.
' cannot be added, probably protected PDF'),
'warnings');
928 $pdf->Output($file,
'F');
931 $hookmanager->initHooks(array(
'pdfgeneration'));
932 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
934 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
936 $this->error = $hookmanager->error;
937 $this->errors = $hookmanager->errors;
942 $this->result = array(
'fullpath' => $file);
946 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
950 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"FAC_OUTPUTDIR");
977 $current_page = $pdf->getPage();
979 $tab3_top = $posy + 8;
982 if ($this->page_largeur < 210) {
992 $pdf->SetFont(
'',
'', $default_font_size - 4);
996 $sql =
"SELECT re.rowid, re.amount_ht, re.multicurrency_amount_ht, re.amount_tva, re.multicurrency_amount_tva, re.amount_ttc, re.multicurrency_amount_ttc,";
997 $sql .=
" re.description, re.fk_facture_source,";
998 $sql .=
" f.type, f.datef";
999 $sql .=
" FROM ".MAIN_DB_PREFIX.
"societe_remise_except as re, ".MAIN_DB_PREFIX.
"facture as f";
1000 $sql .=
" WHERE re.fk_facture_source = f.rowid AND re.fk_facture = ".((int)
$object->id);
1001 $resql = $this->db->query($sql);
1003 $num = $this->db->num_rows($resql);
1005 $invoice =
new Facture($this->db);
1008 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
1011 $pdf->AddPage(
'',
'',
true);
1017 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
1019 $pdf->setPage($current_page);
1023 $obj = $this->db->fetch_object($resql);
1025 if ($obj->type == 2) {
1026 $text = $outputlangs->transnoentities(
"CreditNote");
1027 } elseif ($obj->type == 3) {
1028 $text = $outputlangs->transnoentities(
"Deposit");
1029 } elseif ($obj->type == 0) {
1030 $text = $outputlangs->transnoentities(
"ExcessReceived");
1032 $text = $outputlangs->transnoentities(
"UnknownType");
1035 $invoice->fetch($obj->fk_facture_source);
1037 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1038 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($obj->datef),
'day',
false, $outputlangs,
true), 0,
'L',
false);
1039 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1040 $pdf->MultiCell(20, 3,
price((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $obj->multicurrency_amount_ttc : $obj->amount_ttc, 0, $outputlangs), 0,
'L',
false);
1041 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1042 $pdf->MultiCell(20, 3, $text, 0,
'L',
false);
1043 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1044 $pdf->MultiCell(20, 3, $invoice->ref, 0,
'L',
false);
1046 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1051 $this->error = $this->db->lasterror();
1057 $sql =
"SELECT p.datep as date, p.fk_paiement, p.num_paiement as num, pf.amount as amount, pf.multicurrency_amount,";
1059 $sql .=
" FROM ".MAIN_DB_PREFIX.
"paiement_facture as pf, ".MAIN_DB_PREFIX.
"paiement as p";
1060 $sql .=
" LEFT JOIN ".MAIN_DB_PREFIX.
"c_paiement as cp ON p.fk_paiement = cp.id";
1061 $sql .=
" WHERE pf.fk_paiement = p.rowid AND pf.fk_facture = ".((int)
$object->id);
1063 $sql .=
" ORDER BY p.datep";
1065 $resql = $this->db->query($sql);
1067 $num = $this->db->num_rows($resql);
1072 if ($tab3_top + $y >= ($this->page_hauteur - $heightforfooter)) {
1075 $pdf->AddPage(
'',
'',
true);
1081 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
1083 $pdf->setPage($current_page);
1087 $row = $this->db->fetch_object($resql);
1089 $pdf->SetXY($tab3_posx, $tab3_top + $y);
1090 $pdf->MultiCell(20, 3,
dol_print_date($this->db->jdate($row->date),
'day',
false, $outputlangs,
true), 0,
'L',
false);
1091 $pdf->SetXY($tab3_posx + 21, $tab3_top + $y);
1092 $pdf->MultiCell(20, 3,
price($sign * ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $row->multicurrency_amount : $row->amount), 0, $outputlangs), 0,
'L',
false);
1093 $pdf->SetXY($tab3_posx + 40, $tab3_top + $y);
1094 $oper = $outputlangs->transnoentitiesnoconv(
"PaymentTypeShort".$row->code);
1096 $pdf->MultiCell(20, 3, $oper, 0,
'L',
false);
1097 $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1098 $pdf->SetXY($tab3_posx + 58, $tab3_top + $y);
1099 $pdf->MultiCell(30, 3, $row->num, 0,
'L',
false);
1100 $y = $maxY = max($pdf->GetY() - $tab3_top - 3, $maxY);
1101 $pdf->line($tab3_posx, $tab3_top + $y + 3, $tab3_posx + $tab3_width, $tab3_top + $y + 3);
1106 return $tab3_top + $y + 3;
1108 $this->error = $this->db->lasterror();
1170 global $mysoc, $hookmanager;
1174 $pdf->SetFont(
'',
'', $default_font_size - 1);
1176 krsort($this->tva_array);
1183 $pdf->SetFillColor(224, 224, 224);
1185 $pdf->SetFont(
'',
'', $default_font_size - 2);
1186 $pdf->SetXY($this->marge_gauche, $posy);
1187 $titre = $outputlangs->transnoentities(
"VAT");
1188 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1190 $pdf->SetFont(
'',
'', $default_font_size - 2);
1191 $pdf->SetXY($this->marge_gauche + 25, $posy);
1192 $titre = $outputlangs->transnoentities(
"NetTotal");
1193 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1195 $pdf->SetFont(
'',
'', $default_font_size - 2);
1196 $pdf->SetXY($this->marge_gauche + 50, $posy);
1197 $titre = $outputlangs->transnoentities(
"VATAmount");
1198 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1200 $pdf->SetFont(
'',
'', $default_font_size - 2);
1201 $pdf->SetXY($this->marge_gauche + 75, $posy);
1202 $titre = $outputlangs->transnoentities(
"AmountTotal");
1203 $pdf->MultiCell(25, 4, $titre, 0,
'L',
true);
1205 $posy = $pdf->GetY();
1210 foreach ($this->tva_array as $tvakey => $tvaval) {
1211 $pdf->SetFont(
'',
'', $default_font_size - 2);
1212 $pdf->SetXY($this->marge_gauche, $posy);
1213 $titre = round((
float) $tvakey, 2) .
"%";
1214 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1216 $pdf->SetFont(
'',
'', $default_font_size - 2);
1217 $pdf->SetXY($this->marge_gauche + 25, $posy);
1218 $titre =
price($tvaval[
'tot_ht']);
1219 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1220 $tot_ht += $tvaval[
'tot_ht'];
1222 $pdf->SetFont(
'',
'', $default_font_size - 2);
1223 $pdf->SetXY($this->marge_gauche + 50, $posy);
1224 $titre =
price($tvaval[
'amount']);
1225 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1226 $tot_tva += $tvaval[
'amount'];
1228 $pdf->SetFont(
'',
'', $default_font_size - 2);
1229 $pdf->SetXY($this->marge_gauche + 75, $posy);
1230 $titre =
price($tvaval[
'tot_ht'] + $tvaval[
'amount']);
1231 $pdf->MultiCell(25, 4, $titre, 0,
'L');
1232 $tot_ttc += ($tvaval[
'tot_ht'] + $tvaval[
'amount']);
1234 $posy = $pdf->GetY();
1239 if (in_array($this->emetteur->country_code, array(
'FR')) && empty(
$object->total_tva)) {
1240 $pdf->SetFont(
'',
'', $default_font_size - 2);
1241 $pdf->SetXY($this->marge_gauche, $posy);
1242 if (empty($mysoc->tva_assuj)) {
1243 if ($mysoc->forme_juridique_code == 92) {
1244 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoiceAsso"), 0,
'L',
false);
1246 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L',
false);
1248 } elseif (
getDolGlobalString(
"INVOICE_VAT_SHOW_REVERSE_CHARGE_MENTION") && $this->emetteur->country_code !=
$object->thirdparty->country_code && $this->emetteur->isInEEC() &&
$object->thirdparty->isInEEC()) {
1249 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedReverseChargeProcedure"), 0,
'L',
false);
1251 $posy = $pdf->GetY() + 4;
1256 if ($this->page_largeur < 210) {
1262 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1263 $pdf->SetXY($this->marge_gauche, $posy);
1264 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
1265 $pdf->MultiCell(43, 4, $titre, 0,
'L');
1267 $pdf->SetFont(
'',
'', $default_font_size - 2);
1268 $pdf->SetXY($posxval, $posy);
1269 $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);
1270 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
1271 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
1273 $posy = $pdf->GetY() + 3;
1277 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 2 && $this->categoryOfOperation >= 0) {
1278 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1279 $pdf->SetXY($this->marge_gauche, $posy);
1280 $categoryOfOperationTitle = $outputlangs->transnoentities(
"MentionCategoryOfOperations").
' : ';
1281 $pdf->MultiCell($posxval - $this->marge_gauche, 4, $categoryOfOperationTitle, 0,
'L');
1283 $pdf->SetFont(
'',
'', $default_font_size - 2);
1284 $pdf->SetXY($posxval, $posy);
1285 $categoryOfOperationLabel = $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1286 $pdf->MultiCell($posxend - $posxval, 4, $categoryOfOperationLabel, 0,
'L');
1288 $posy = $pdf->GetY() + 3;
1293 if (empty(
$object->mode_reglement_code)
1296 $this->error = $outputlangs->transnoentities(
"ErrorNoPaiementModeConfigured");
1300 $outputlangs->load(
"errors");
1302 $pdf->SetXY($this->marge_gauche, $posy);
1303 $pdf->SetTextColor(200, 0, 0);
1304 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1305 $this->error = $outputlangs->transnoentities(
"ErrorPaymentModeDefinedToWithoutSetup",
$object->mode_reglement_code);
1306 $pdf->MultiCell(80, 3, $this->error, 0,
'L',
false);
1307 $pdf->SetTextColor(0, 0, 0);
1309 $posy = $pdf->GetY() + 1;
1313 if (!empty(
$object->mode_reglement_code)
1314 &&
$object->mode_reglement_code !=
'CHQ'
1315 &&
$object->mode_reglement_code !=
'VIR') {
1316 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1317 $pdf->SetXY($this->marge_gauche, $posy);
1318 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
1319 $pdf->MultiCell(80, 5, $titre, 0,
'L');
1321 $pdf->SetFont(
'',
'', $default_font_size - 2);
1322 $pdf->SetXY($posxval, $posy);
1323 $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);
1325 if (
$object->mode_reglement_code ==
"PRE") {
1326 require_once DOL_DOCUMENT_ROOT.
'/societe/class/companybankaccount.class.php';
1329 $bac->fetch(0,
'',
$object->thirdparty->id);
1330 $iban = $bac->iban.(($bac->iban && $bac->bic) ?
' / ' :
'').$bac->bic;
1331 $lib_mode_reg .=
' '.$outputlangs->trans(
"PaymentTypePREdetails",
dol_trunc($iban, 6,
'right',
'UTF-8', 1));
1333 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
1335 $posy = $pdf->GetY();
1341 if ($this->emetteur->country_code ==
'FR') {
1343 $pdf->SetXY($this->marge_gauche, $posy);
1344 $pdf->writeHTMLCell(80, 5,
null,
null, $outputlangs->transnoentities(
"MentionVATDebitOptionIsOn"), 0, 1);
1346 $posy = $pdf->GetY() + 1;
1351 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CB' ||
$object->mode_reglement_code ==
'VAD') {
1352 $useonlinepayment = 0;
1356 include_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1357 $validpaymentmethod = getValidOnlinePaymentMethods(
'');
1358 $useonlinepayment = count($validpaymentmethod);
1362 require_once DOL_DOCUMENT_ROOT.
'/core/lib/payments.lib.php';
1365 $langs->loadLangs(array(
'payment',
'paybox',
'stripe'));
1366 $servicename = $langs->transnoentities(
'Online');
1368 $paiement_url = getOnlinePaymentUrl(0,
'invoice',
$object->ref, 0,
'', 0);
1369 $linktopay = $langs->trans(
"ToOfferALinkForOnlinePayment", $servicename).
' <a href="'.$paiement_url.
'">'.$outputlangs->transnoentities(
"ClickHere").
'</a>';
1371 $pdf->SetXY($this->marge_gauche, $posy);
1374 $posy = $pdf->GetY() + 1;
1379 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'CHQ') {
1385 $account =
new Account($this->db);
1388 $pdf->SetXY($this->marge_gauche, $posy);
1389 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1390 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->owner_name), 0,
'L',
false);
1391 $posy = $pdf->GetY() + 1;
1394 $pdf->SetXY($this->marge_gauche, $posy);
1395 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1396 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L',
false);
1397 $posy = $pdf->GetY() + 2;
1401 $pdf->SetXY($this->marge_gauche, $posy);
1402 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
1403 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L',
false);
1404 $posy = $pdf->GetY() + 1;
1407 $pdf->SetXY($this->marge_gauche, $posy);
1408 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
1409 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L',
false);
1410 $posy = $pdf->GetY() + 2;
1417 if (empty(
$object->mode_reglement_code) ||
$object->mode_reglement_code ==
'VIR') {
1423 $account =
new Account($this->db);
1424 $account->fetch($bankid);
1426 $curx = $this->marge_gauche;
1429 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
1434 include_once DOL_DOCUMENT_ROOT.
'/core/lib/functions_be.lib.php';
1437 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'StructuredCommunication').
": " . $outputlangs->convToOutputCharset($invoicePaymentKey), 0,
'L',
false);
1463 global
$conf, $mysoc, $hookmanager;
1472 $outputlangsbis =
null;
1476 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
1477 $default_font_size--;
1482 $pdf->SetFont(
'',
'', $default_font_size - 1);
1487 if ($this->page_largeur < 210) {
1491 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
1497 $total_ht = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1 ?
$object->multicurrency_total_ht :
$object->total_ht);
1500 $total_discount_on_lines = 0;
1501 $multicurrency_total_discount_on_lines = 0;
1502 foreach (
$object->lines as $i => $line) {
1506 $total_discount_on_lines += (is_numeric($resdiscount) ? $resdiscount : 0);
1507 $multicurrency_total_discount_on_lines += (is_numeric($multicurrency_resdiscount) ? $multicurrency_resdiscount : 0);
1509 if ($line->total_ht < 0) {
1510 $total_discount_on_lines += -$line->total_ht;
1511 $multicurrency_total_discount_on_lines += -$line->multicurrency_total_ht;
1515 if ($total_discount_on_lines > 0) {
1517 $pdf->SetFillColor(255, 255, 255);
1518 $pdf->SetXY($col1x, $tab2_top);
1519 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHTBeforeDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHTBeforeDiscount") :
''), 0,
'L',
true);
1520 $pdf->SetXY($col2x, $tab2_top);
1522 $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));
1523 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_before_discount_to_show, 0, $outputlangs), 0,
'R',
true);
1527 $pdf->SetFillColor(255, 255, 255);
1528 $pdf->SetXY($col1x, $tab2_top + $tab2_hl);
1529 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalDiscount").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalDiscount") :
''), 0,
'L',
true);
1530 $pdf->SetXY($col2x, $tab2_top + $tab2_hl);
1532 $total_discount_to_show = ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? $multicurrency_total_discount_on_lines : $total_discount_on_lines);
1533 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_discount_to_show, 0, $outputlangs), 0,
'R',
true);
1539 $pdf->SetFillColor(255, 255, 255);
1540 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1541 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') ?
"TotalHT" :
"Total").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(!
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT') ?
"TotalHT" :
"Total") :
''), 0,
'L',
true);
1543 $total_ht = ((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ht :
$object->total_ht);
1544 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1545 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ht, 0, $outputlangs), 0,
'R',
true);
1549 $pdf->SetFillColor(255, 255, 255);
1550 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1551 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalVAT"), 0,
'L',
true);
1553 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1554 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->total_tva), 0,
'R',
true);
1558 $pdf->SetFillColor(248, 248, 248);
1560 $total_ttc = (isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ?
$object->multicurrency_total_ttc :
$object->total_ttc;
1562 $this->atleastoneratenotnull = 0;
1564 $tvaisnull = (!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000']));
1565 if (
getDolGlobalString(
'MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL') && $tvaisnull) {
1569 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1570 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1574 foreach ($localtax_rate as $tvakey => $tvaval) {
1579 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1582 if (preg_match(
'/\*/', (
string) $tvakey)) {
1583 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1584 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1587 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1591 $totalvat .= $tvacompl;
1593 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1596 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1598 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1600 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1601 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1607 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1608 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
1612 foreach ($localtax_rate as $tvakey => $tvaval) {
1617 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1620 if (preg_match(
'/\*/', (
string) $tvakey)) {
1621 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1622 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1624 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1628 $totalvat .= $tvacompl;
1630 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1633 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1635 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1637 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1638 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1645 foreach ($this->tva_array as $tvakey => $tvaval) {
1647 $this->atleastoneratenotnull++;
1650 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1653 if (preg_match(
'/\*/', $tvakey)) {
1654 $tvakey = str_replace(
'*',
'', $tvakey);
1655 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1657 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1660 $totalvat .=
vatrate((
string) $tvaval[
'vatrate'],
true).$tvacompl;
1662 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1664 $totalvat .= $tvacompl;
1666 $totalvat .=
vatrate((
string) $tvaval[
'vatrate'],
true).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1668 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1669 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1670 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R',
true);
1676 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1677 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1681 foreach ($localtax_rate as $tvakey => $tvaval) {
1686 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1689 if (preg_match(
'/\*/', (
string) $tvakey)) {
1690 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1691 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1693 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).
' ';
1696 $totalvat .= $tvacompl;
1698 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1701 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1703 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1705 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1706 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1712 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1713 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1717 foreach ($localtax_rate as $tvakey => $tvaval) {
1721 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1724 if (preg_match(
'/\*/', (
string) $tvakey)) {
1725 $tvakey = str_replace(
'*',
'', (
string) $tvakey);
1726 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1728 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).
' ';
1731 $totalvat .= $tvacompl;
1733 $totalvat .=
vatrate((
string) abs((
float) $tvakey),
true).$tvacompl;
1736 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L',
true);
1738 $total_localtax = ((isModEnabled(
"multicurrency") && isset(
$object->multicurrency_tx) &&
$object->multicurrency_tx != 1) ?
price2num($tvaval *
$object->multicurrency_tx,
'MT') : $tvaval);
1740 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1741 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_localtax, 0, $outputlangs), 0,
'R',
true);
1748 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1749 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RevenueStamp"), $useborder,
'L',
true);
1751 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1752 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign *
$object->revenuestamp), $useborder,
'R',
true);
1757 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1758 $pdf->SetTextColor(0, 0, 60);
1759 $pdf->SetFillColor(224, 224, 224);
1760 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC"), $useborder,
'L',
true);
1762 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1763 $pdf->MultiCell($largcol2, $tab2_hl,
price($sign * $total_ttc, 0, $outputlangs), $useborder,
'R',
true);
1766 if (
$object->displayRetainedWarranty()) {
1767 $pdf->SetTextColor(40, 40, 40);
1768 $pdf->SetFillColor(255, 255, 255);
1770 $retainedWarranty =
$object->getRetainedWarrantyAmount();
1771 $billedWithRetainedWarranty =
$object->total_ttc - $retainedWarranty;
1775 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1776 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"ToPayOn",
dol_print_date(
$object->date_lim_reglement,
'day')), $useborder,
'L',
true);
1778 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1779 $pdf->MultiCell($largcol2, $tab2_hl,
price($billedWithRetainedWarranty), $useborder,
'R',
true);
1783 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1785 $retainedWarrantyToPayOn = $outputlangs->transnoentities(
"RetainedWarranty").
' ('.
$object->retained_warranty.
'%)';
1786 $retainedWarrantyToPayOn .= !empty(
$object->retained_warranty_date_limit) ?
' '.$outputlangs->transnoentities(
"toPayOn",
dol_print_date(
$object->retained_warranty_date_limit,
'day')) :
'';
1788 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $retainedWarrantyToPayOn, $useborder,
'L',
true);
1789 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1790 $pdf->MultiCell($largcol2, $tab2_hl,
price($retainedWarranty), $useborder,
'R',
true);
1795 $pdf->SetTextColor(0, 0, 0);
1796 $creditnoteamount =
$object->getSumCreditNotesUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1797 $depositsamount =
$object->getSumDepositsUsed((isModEnabled(
"multicurrency") &&
$object->multicurrency_tx != 1) ? 1 : 0);
1799 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1804 if (($deja_regle > 0 || $creditnoteamount > 0 || $depositsamount > 0) && !
getDolGlobalString(
'INVOICE_NO_PAYMENT_DETAILS')) {
1807 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1808 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"Paid"), 0,
'L',
false);
1809 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1810 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle + $depositsamount, 0, $outputlangs), 0,
'R',
false);
1813 if ($creditnoteamount) {
1814 $labeltouse = ($outputlangs->transnoentities(
"CreditNotesOrExcessReceived") !=
"CreditNotesOrExcessReceived") ? $outputlangs->transnoentities(
"CreditNotesOrExcessReceived") : $outputlangs->transnoentities(
"CreditNotes");
1816 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1817 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $labeltouse, 0,
'L',
false);
1818 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1819 $pdf->MultiCell($largcol2, $tab2_hl,
price($creditnoteamount, 0, $outputlangs), 0,
'R',
false);
1823 if (
$object->close_code == Facture::CLOSECODE_DISCOUNTVAT) {
1825 $pdf->SetFillColor(255, 255, 255);
1827 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1828 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"EscompteOfferedShort"), $useborder,
'L',
true);
1829 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1830 $pdf->MultiCell($largcol2, $tab2_hl,
price(
$object->total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 0, $outputlangs), $useborder,
'R',
true);
1836 $pdf->SetTextColor(0, 0, 60);
1837 $pdf->SetFillColor(224, 224, 224);
1838 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1839 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay"), $useborder,
'L',
true);
1840 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1841 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R',
true);
1843 $pdf->SetFont(
'',
'', $default_font_size - 1);
1844 $pdf->SetTextColor(0, 0, 0);
1852 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1853 $pdf->MultiCell($col2x - $col1x, $tab2_hl,
getDolGlobalString(
'BILL_TEXT_TOTAL_FOOTER'), 0,
'L',
false);
1856 return ($tab2_top + ($tab2_hl * $index));
1873 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
1883 $currency = !empty($currency) ? $currency :
$conf->currency;
1887 $pdf->SetTextColor(0, 0, 0);
1888 $pdf->SetFont(
'',
'', $default_font_size - 2);
1890 if (empty($hidetop)) {
1892 if (
getDolGlobalInt(
'INVOICE_CATEGORY_OF_OPERATION') == 1 && $this->categoryOfOperation >= 0) {
1893 $categoryOfOperations = $outputlangs->transnoentities(
"MentionCategoryOfOperations") .
' : ' . $outputlangs->transnoentities(
"MentionCategoryOfOperations" . $this->categoryOfOperation);
1894 $pdf->SetXY($this->marge_gauche, $tab_top - 4);
1895 $pdf->MultiCell(($pdf->GetStringWidth($categoryOfOperations)) + 4, 2, $categoryOfOperations);
1898 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1899 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1900 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1903 $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')));
1907 $pdf->SetDrawColor(128, 128, 128);
1908 $pdf->SetFont(
'',
'', $default_font_size - 1);
1911 $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');
1913 if (empty($hidetop)) {
1914 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1916 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1917 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1921 $pdf->line($this->posxpicture - 1, $tab_top, $this->posxpicture - 1, $tab_top + $tab_height);
1929 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1930 if (empty($hidetop)) {
1931 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1932 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1936 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1937 if (empty($hidetop)) {
1938 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1939 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1942 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1943 if (empty($hidetop)) {
1944 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1945 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1949 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1950 if (empty($hidetop)) {
1951 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1952 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1956 if ($this->atleastonediscount) {
1957 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1958 if (empty($hidetop)) {
1959 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1960 $pdf->MultiCell($this->posxprogress - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1964 if ($this->situationinvoice) {
1965 $pdf->line($this->posxprogress - 1, $tab_top, $this->posxprogress - 1, $tab_top + $tab_height);
1966 if (empty($hidetop)) {
1967 $pdf->SetXY($this->posxprogress, $tab_top + 1);
1968 $pdf->MultiCell($this->postotalht - $this->posxprogress, 2, $outputlangs->transnoentities(
"ProgressShort"),
'',
'C');
1972 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1973 if (empty($hidetop)) {
1974 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1975 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1990 protected function _pagehead(&$pdf,
$object, $showaddress, $outputlangs, $outputlangsbis =
null)
1993 global
$conf, $langs;
1995 $ltrdirection =
'L';
1996 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1997 $ltrdirection =
'R';
2001 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"companies"));
2007 $pdf->SetTextColor(0, 0, 60);
2008 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2012 $posy = $this->marge_haute;
2013 $posx = $this->page_largeur - $this->marge_droite - $w;
2015 $pdf->SetXY($this->marge_gauche, $posy);
2019 if ($this->emetteur->logo) {
2020 $logodir =
$conf->mycompany->dir_output;
2021 if (!empty(
$conf->mycompany->multidir_output[
$object->entity])) {
2022 $logodir =
$conf->mycompany->multidir_output[
$object->entity];
2025 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
2027 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
2029 if (is_readable($logo)) {
2031 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
2033 $pdf->SetTextColor(200, 0, 0);
2034 $pdf->SetFont(
'',
'B', $default_font_size - 2);
2035 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
2036 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
2039 $text = $this->emetteur->name;
2040 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
2044 $pdf->SetFont(
'',
'B', $default_font_size + 3);
2045 $pdf->SetXY($posx, $posy);
2046 $pdf->SetTextColor(0, 0, 60);
2047 $title = $outputlangs->transnoentities(
"PdfInvoiceTitle");
2049 $title = $outputlangs->transnoentities(
"InvoiceReplacement");
2052 $title = $outputlangs->transnoentities(
"InvoiceAvoir");
2055 $title = $outputlangs->transnoentities(
"InvoiceDeposit");
2058 $title = $outputlangs->transnoentities(
"InvoiceProForma");
2060 if ($this->situationinvoice) {
2061 $outputlangs->loadLangs(array(
"other"));
2062 $title = $outputlangs->transnoentities(
"PDFInvoiceSituation") .
" " . $outputlangs->transnoentities(
"NumberingShort") .
$object->situation_counter .
" -";
2064 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2067 if ($this->situationinvoice) {
2068 $title .= $outputlangsbis->transnoentities(
"PDFInvoiceSituation");
2070 $title .= $outputlangsbis->transnoentities(
"PdfInvoiceTitle");
2071 } elseif (
$object->type == 1) {
2072 $title .= $outputlangsbis->transnoentities(
"InvoiceReplacement");
2073 } elseif (
$object->type == 2) {
2074 $title .= $outputlangsbis->transnoentities(
"InvoiceAvoir");
2075 } elseif (
$object->type == 3) {
2076 $title .= $outputlangsbis->transnoentities(
"InvoiceDeposit");
2077 } elseif (
$object->type == 4) {
2078 $title .= $outputlangsbis->transnoentities(
"InvoiceProForma");
2081 $title .=
' '.$outputlangs->convToOutputCharset(
$object->ref);
2082 if (
$object->status == $object::STATUS_DRAFT) {
2083 $pdf->SetTextColor(128, 0, 0);
2084 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
2087 $pdf->MultiCell($w, 3, $title,
'',
'R');
2089 $pdf->SetFont(
'',
'B', $default_font_size);
2103 $pdf->SetFont(
'',
'', $default_font_size - 2);
2107 $pdf->SetXY($posx, $posy);
2108 $pdf->SetTextColor(0, 0, 60);
2109 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset(
$object->ref_customer),
'',
'R');
2114 if (!empty(
$object->project->ref)) {
2116 $pdf->SetXY($posx, $posy);
2117 $pdf->SetTextColor(0, 0, 60);
2118 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty(
$object->project->title) ?
'' :
$object->project->title),
'',
'R');
2124 if (!empty(
$object->project->ref)) {
2125 $outputlangs->load(
"projects");
2127 $pdf->SetXY($posx, $posy);
2128 $pdf->SetTextColor(0, 0, 60);
2129 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty(
$object->project->ref) ?
'' :
$object->project->ref),
'',
'R');
2133 $objectidnext =
$object->getIdReplacingInvoice(
'validated');
2134 if (
$object->type == 0 && $objectidnext) {
2135 $objectreplacing =
new Facture($this->db);
2136 $objectreplacing->fetch($objectidnext);
2139 $pdf->SetXY($posx, $posy);
2140 $pdf->SetTextColor(0, 0, 60);
2141 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementByInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplacing->ref),
'',
'R');
2144 $objectreplaced =
new Facture($this->db);
2145 $objectreplaced->fetch(
$object->fk_facture_source);
2148 $pdf->SetXY($posx, $posy);
2149 $pdf->SetTextColor(0, 0, 60);
2150 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ReplacementInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2153 $objectreplaced =
new Facture($this->db);
2154 $objectreplaced->fetch(
$object->fk_facture_source);
2157 $pdf->SetXY($posx, $posy);
2158 $pdf->SetTextColor(0, 0, 60);
2159 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CorrectionInvoice").
' : '.$outputlangs->convToOutputCharset($objectreplaced->ref),
'',
'R');
2163 $pdf->SetXY($posx, $posy);
2164 $pdf->SetTextColor(0, 0, 60);
2165 $title = $outputlangs->transnoentities(
"DateInvoice");
2166 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2167 $title .=
' - '.$outputlangsbis->transnoentities(
"DateInvoice");
2169 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date,
"day",
false, $outputlangs,
true),
'',
'R');
2173 $pdf->SetXY($posx, $posy);
2174 $pdf->SetTextColor(0, 0, 60);
2175 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"DatePointOfTax").
" : ".
dol_print_date(
$object->date_pointoftax,
"day",
false, $outputlangs),
'',
'R');
2180 $pdf->SetXY($posx, $posy);
2181 $pdf->SetTextColor(0, 0, 60);
2182 $title = $outputlangs->transnoentities(
"DateDue");
2183 if (
getDolGlobalString(
'PDF_USE_ALSO_LANGUAGE_CODE') && is_object($outputlangsbis)) {
2184 $title .=
' - '.$outputlangsbis->transnoentities(
"DateDue");
2186 $pdf->MultiCell($w, 3, $title.
" : ".
dol_print_date(
$object->date_lim_reglement,
"day",
false, $outputlangs,
true),
'',
'R');
2191 $pdf->SetXY($posx, $posy);
2192 $pdf->SetTextColor(0, 0, 60);
2193 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_client),
'',
'R');
2198 $pdf->SetXY($posx, $posy);
2199 $pdf->SetTextColor(0, 0, 60);
2200 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerAccountancyCode").
" : ".$outputlangs->transnoentities(
$object->thirdparty->code_compta_client),
'',
'R');
2205 $arrayidcontact =
$object->getIdContact(
'internal',
'SALESREPFOLL');
2206 if (count($arrayidcontact) > 0) {
2207 $usertmp =
new User($this->db);
2208 $usertmp->fetch($arrayidcontact[0]);
2210 $pdf->SetXY($posx, $posy);
2211 $pdf->SetTextColor(0, 0, 60);
2212 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
2221 $current_y = $pdf->getY();
2223 if ($current_y < $pdf->getY()) {
2224 $top_shift = $pdf->getY() - $current_y;
2230 $carac_emetteur =
'';
2232 $arrayidcontact =
$object->getIdContact(
'internal',
'BILLING');
2233 if (count($arrayidcontact) > 0) {
2234 $object->fetch_user($arrayidcontact[0]);
2235 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
2236 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset(
$object->user->getFullName($outputlangs));
2237 $carac_emetteur .=
"\n";
2244 $posy += $top_shift;
2245 $posx = $this->marge_gauche;
2247 $posx = $this->page_largeur - $this->marge_droite - 80;
2256 $pdf->SetTextColor(0, 0, 0);
2257 $pdf->SetFont(
'',
'', $default_font_size - 2);
2258 $pdf->SetXY($posx, $posy - 5);
2259 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
2260 $pdf->SetXY($posx, $posy);
2261 $pdf->SetFillColor(230, 230, 230);
2262 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'F');
2263 $pdf->SetTextColor(0, 0, 60);
2268 $pdf->SetXY($posx + 2, $posy + 3);
2269 $pdf->SetFont(
'',
'B', $default_font_size);
2270 $pdf->MultiCell($widthrecbox - 2, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
2271 $posy = $pdf->getY();
2275 $pdf->SetXY($posx + 2, $posy);
2276 $pdf->SetFont(
'',
'', $default_font_size - 1);
2277 $pdf->MultiCell($widthrecbox - 2, 4, $carac_emetteur, 0, $ltrdirection);
2281 $usecontact =
false;
2282 $arrayidcontact =
$object->getIdContact(
'external',
'BILLING');
2283 if (count($arrayidcontact) > 0) {
2285 $result =
$object->fetch_contact($arrayidcontact[0]);
2289 if ($usecontact && (
$object->contact->socid !=
$object->thirdparty->id && (!isset(
$conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) ||
getDolGlobalString(
'MAIN_USE_COMPANY_NAME_OF_CONTACT')))) {
2290 $thirdparty =
$object->contact;
2292 $thirdparty =
$object->thirdparty;
2302 if ($this->page_largeur < 210) {
2306 $posy += $top_shift;
2307 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
2309 $posx = $this->marge_gauche;
2314 $pdf->SetTextColor(0, 0, 0);
2315 $pdf->SetFont(
'',
'', $default_font_size - 2);
2316 $pdf->SetXY($posx + 2, $posy - 5);
2317 $pdf->MultiCell($widthrecbox - 2, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
2318 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2322 $pdf->SetXY($posx + 2, $posy + 3);
2323 $pdf->SetFont(
'',
'B', $default_font_size);
2325 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name, 0, $ltrdirection);
2327 $posy = $pdf->getY();
2330 $pdf->SetFont(
'',
'', $default_font_size - 1);
2331 $pdf->SetXY($posx + 2, $posy);
2333 $pdf->MultiCell($widthrecbox - 2, 4, $carac_client, 0, $ltrdirection);
2337 $idaddressshipping =
$object->getIdContact(
'external',
'SHIPPING');
2339 if (!empty($idaddressshipping)) {
2340 $contactshipping =
$object->fetch_Contact($idaddressshipping[0]);
2341 $companystatic =
new Societe($this->db);
2342 $companystatic->fetch(
$object->contact->fk_soc);
2349 if (!empty($carac_client_shipping)) {
2350 $posy += $hautcadre;
2355 $pdf->SetXY($posx + 2, $posy - 5);
2356 $pdf->SetFont(
'',
'', $default_font_size - 2);
2357 $pdf->MultiCell($widthrecbox, 0, $outputlangs->transnoentities(
'ShippingTo'), 0,
'L',
false);
2358 $pdf->RoundedRect($posx, $posy, $widthrecbox, $hautcadre, $this->corner_radius,
'1234',
'D');
2361 $pdf->SetXY($posx + 2, $posy + 3);
2362 $pdf->SetFont(
'',
'B', $default_font_size);
2363 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_name_shipping,
'',
'L');
2365 $posy = $pdf->getY();
2368 $pdf->SetXY($posx + 2, $posy);
2369 $pdf->SetFont(
'',
'', $default_font_size - 1);
2370 $pdf->MultiCell($widthrecbox - 2, 2, $carac_client_shipping,
'',
'L');
2372 $top_shift += $hautcadre + 10;
2377 $pdf->SetTextColor(0, 0, 0);