33 require_once DOL_DOCUMENT_ROOT.
'/core/modules/commande/modules_commande.php';
34 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
35 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
36 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
37 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
68 public $update_main_doc_field;
79 public $version =
'dolibarr';
104 public $marge_droite;
130 global $conf, $langs, $mysoc;
133 $langs->loadLangs(array(
"main",
"bills",
"products"));
136 $this->
name =
"einstein";
137 $this->
description = $langs->trans(
'PDFEinsteinDescription');
138 $this->update_main_doc_field = 1;
143 $this->page_largeur = $formatarray[
'width'];
144 $this->page_hauteur = $formatarray[
'height'];
145 $this->format = array($this->page_largeur, $this->page_hauteur);
151 $this->option_logo = 1;
152 $this->option_tva = 1;
153 $this->option_modereg = 1;
154 $this->option_condreg = 1;
155 $this->option_multilang = 1;
156 $this->option_escompte = 0;
157 $this->option_credit_note = 0;
158 $this->option_freetext = 1;
159 $this->option_draft_watermark = 1;
160 $this->watermark =
'';
163 $this->emetteur = $mysoc;
164 if (empty($this->emetteur->country_code)) {
165 $this->emetteur->country_code = substr($langs->defaultlang, -2);
169 $this->posxdesc = $this->marge_gauche + 1;
171 $this->posxtva = 101;
173 $this->posxqty = 135;
174 $this->posxunit = 151;
176 $this->posxtva = 106;
178 $this->posxqty = 145;
179 $this->posxunit = 162;
181 $this->posxdiscount = 162;
182 $this->postotalht = 174;
183 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
184 $this->posxtva = $this->posxup;
186 $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
187 if ($this->page_largeur < 210) {
188 $this->posxpicture -= 20;
189 $this->posxtva -= 20;
191 $this->posxqty -= 20;
192 $this->posxunit -= 20;
193 $this->posxdiscount -= 20;
194 $this->postotalht -= 20;
197 $this->tva = array();
198 $this->tva_array = array();
199 $this->localtax1 = array();
200 $this->localtax2 = array();
201 $this->atleastoneratenotnull = 0;
202 $this->atleastonediscount = 0;
217 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
220 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
222 if (!is_object($outputlangs)) {
223 $outputlangs = $langs;
226 if (!empty($conf->global->MAIN_USE_FPDF)) {
227 $outputlangs->charset_output =
'ISO-8859-1';
231 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries"));
234 if ($object->statut == $object::STATUS_DRAFT &&
getDolGlobalString(
'COMMANDE_DRAFT_WATERMARK')) {
238 global $outputlangsbis;
239 $outputlangsbis =
null;
240 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
241 $outputlangsbis =
new Translate(
'', $conf);
242 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
243 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries"));
246 $nblines = count($object->lines);
248 if ($conf->commande->multidir_output[$conf->entity]) {
249 $object->fetch_thirdparty();
254 if ($object->specimen) {
255 $dir = $conf->commande->multidir_output[$conf->entity];
256 $file = $dir.
"/SPECIMEN.pdf";
260 if (!empty($conf->global->PROFORMA_PDF_WITH_SUFFIX)) {
261 $suffix = (
GETPOST(
'model', 2)==
'proforma') ? $conf->global->PROFORMA_PDF_WITH_SUFFIX :
'';
266 $dir = $conf->commande->multidir_output[$object->entity].
"/".$objectref;
267 $file = $dir.
"/".$objectref.$suffix.
".pdf";
270 if (!file_exists($dir)) {
272 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
277 if (file_exists($dir)) {
279 if (!is_object($hookmanager)) {
280 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
283 $hookmanager->initHooks(array(
'pdfgeneration'));
284 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
286 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
289 $nblines = count($object->lines);
294 $pdf->SetAutoPageBreak(1, 0);
296 $heightforinfotot = 40;
297 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
298 $heightforfooter = $this->marge_basse + 8;
299 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
300 $heightforfooter += 6;
303 if (class_exists(
'TCPDF')) {
304 $pdf->setPrintHeader(
false);
305 $pdf->setPrintFooter(
false);
309 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
310 $logodir = $conf->mycompany->dir_output;
311 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
312 $logodir = $conf->mycompany->multidir_output[$object->entity];
314 $pagecount = $pdf->setSourceFile($logodir.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
315 $tplidx = $pdf->importPage(1);
320 $pdf->SetDrawColor(128, 128, 128);
322 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
323 $pdf->SetSubject($outputlangs->transnoentities(
"PdfOrderTitle"));
324 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
325 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
326 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfOrderTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
328 $pdf->SetCompression(
false);
331 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
334 for ($i = 0; $i < $nblines; $i++) {
335 if ($object->lines[$i]->remise_percent) {
336 $this->atleastonediscount++;
339 if (empty($this->atleastonediscount)) {
340 $delta = ($this->postotalht - $this->posxdiscount);
341 $this->posxpicture += $delta;
342 $this->posxtva += $delta;
343 $this->posxup += $delta;
344 $this->posxqty += $delta;
345 $this->posxunit += $delta;
346 $this->posxdiscount += $delta;
352 if (!empty($tplidx)) {
353 $pdf->useTemplate($tplidx);
356 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs, (is_object($outputlangsbis) ? $outputlangsbis :
null));
357 $pdf->SetFont(
'',
'', $default_font_size - 1);
358 $pdf->MultiCell(0, 3,
'');
359 $pdf->SetTextColor(0, 0, 0);
362 $tab_top = 90 + $top_shift;
363 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
366 $height_incoterms = 0;
368 $desc_incoterms = $object->getIncotermsForPDF();
369 if ($desc_incoterms) {
372 $pdf->SetFont(
'',
'', $default_font_size - 1);
373 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
374 $nexY = $pdf->GetY();
375 $height_incoterms = $nexY - $tab_top;
378 $pdf->SetDrawColor(192, 192, 192);
379 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
381 $tab_top = $nexY + 6;
386 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
387 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
389 if (is_object($object->thirdparty)) {
390 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
391 $salerepobj =
new User($this->db);
392 $salerepobj->fetch($salereparray[0][
'id']);
393 if (!empty($salerepobj->signature)) {
394 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
399 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
400 if (!empty($extranote)) {
412 $pdf->SetFont(
'',
'', $default_font_size - 1);
413 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
414 $nexY = $pdf->GetY();
415 $height_note = $nexY - $tab_top;
418 $pdf->SetDrawColor(192, 192, 192);
419 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
421 $tab_top = $nexY + 6;
424 $iniY = $tab_top + 7;
425 $curY = $tab_top + 7;
426 $nexY = $tab_top + 7;
429 for ($i = 0; $i < $nblines; $i++) {
431 $pdf->SetFont(
'',
'', $default_font_size - 1);
432 $pdf->SetTextColor(0, 0, 0);
434 $pdf->setTopMargin($tab_top_newpage);
435 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
436 $pageposbefore = $pdf->getPage();
439 $curX = $this->posxdesc - 1;
441 $showpricebeforepagebreak = 1;
443 $pdf->startTransaction();
444 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc);
445 $pageposafter = $pdf->getPage();
446 if ($pageposafter > $pageposbefore) {
447 $pdf->rollbackTransaction(
true);
448 $pageposafter = $pageposbefore;
450 $pdf->setPageOrientation(
'', 1, $heightforfooter);
451 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc);
452 $pageposafter = $pdf->getPage();
453 $posyafter = $pdf->GetY();
454 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
455 if ($i == ($nblines - 1)) {
456 $pdf->AddPage(
'',
'',
true);
457 if (!empty($tplidx)) {
458 $pdf->useTemplate($tplidx);
461 $this->
_pagehead($pdf, $object, 0, $outputlangs);
463 $pdf->setPage($pageposafter + 1);
468 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
469 $showpricebeforepagebreak = 1;
471 $showpricebeforepagebreak = 0;
476 $pdf->commitTransaction();
478 $posYAfterDescription = $pdf->GetY();
480 $nexY = $pdf->GetY();
481 $pageposafter = $pdf->getPage();
483 $pdf->setPage($pageposbefore);
484 $pdf->setTopMargin($this->marge_haute);
485 $pdf->setPageOrientation(
'', 1, 0);
488 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
489 $pdf->setPage($pageposafter);
490 $curY = $tab_top_newpage;
493 $pdf->SetFont(
'',
'', $default_font_size - 1);
496 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
498 $pdf->SetXY($this->posxtva - 5, $curY);
499 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
504 $pdf->SetXY($this->posxup, $curY);
505 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
509 $pdf->SetXY($this->posxqty, $curY);
510 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
514 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
515 $pdf->SetXY($this->posxunit, $curY);
516 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
520 $pdf->SetXY($this->posxdiscount, $curY);
521 if ($object->lines[$i]->remise_percent) {
522 $pdf->SetXY($this->posxdiscount - 2, $curY);
524 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
529 $pdf->SetXY($this->postotalht, $curY);
530 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
533 if (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
534 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
536 $tvaligne = $object->lines[$i]->total_tva;
539 $localtax1ligne = $object->lines[$i]->total_localtax1;
540 $localtax2ligne = $object->lines[$i]->total_localtax2;
541 $localtax1_rate = $object->lines[$i]->localtax1_tx;
542 $localtax2_rate = $object->lines[$i]->localtax2_tx;
543 $localtax1_type = $object->lines[$i]->localtax1_type;
544 $localtax2_type = $object->lines[$i]->localtax2_type;
557 $vatrate = (string) $object->lines[$i]->tva_tx;
560 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
561 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
563 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
564 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
568 if ($localtax1_type && $localtax1ligne != 0) {
569 if (empty($this->localtax1[$localtax1_type][$localtax1_rate])) {
570 $this->localtax1[$localtax1_type][$localtax1_rate] = $localtax1ligne;
572 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
575 if ($localtax2_type && $localtax2ligne != 0) {
576 if (empty($this->localtax2[$localtax2_type][$localtax2_rate])) {
577 $this->localtax2[$localtax2_type][$localtax2_rate] = $localtax2ligne;
579 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
583 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
588 if (!isset($this->tva[$vatrate])) {
589 $this->tva[$vatrate] = 0;
591 $this->tva[$vatrate] += $tvaligne;
592 $vatcode = $object->lines[$i]->vat_src_code;
593 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
594 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
596 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
599 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
600 $pdf->setPage($pageposafter);
601 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
603 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
604 $pdf->SetLineStyle(array(
'dash'=>0));
610 while ($pagenb < $pageposafter) {
611 $pdf->setPage($pagenb);
613 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
615 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
617 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
619 $pdf->setPage($pagenb);
620 $pdf->setPageOrientation(
'', 1, 0);
622 $this->
_pagehead($pdf, $object, 0, $outputlangs);
624 if (!empty($tplidx)) {
625 $pdf->useTemplate($tplidx);
628 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
630 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
632 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
634 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
637 if (!empty($tplidx)) {
638 $pdf->useTemplate($tplidx);
642 $this->
_pagehead($pdf, $object, 0, $outputlangs);
649 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
651 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
653 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
656 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
659 $posy = $this->
_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
670 $this->
_pagefoot($pdf, $object, $outputlangs);
671 if (method_exists($pdf,
'AliasNbPages')) {
672 $pdf->AliasNbPages();
677 $pdf->Output($file,
'F');
680 $hookmanager->initHooks(array(
'pdfgeneration'));
681 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
683 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
685 $this->error = $hookmanager->error;
686 $this->errors = $hookmanager->errors;
691 $this->result = array(
'fullpath'=>$file);
695 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
699 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"COMMANDE_OUTPUTDIR");
735 global $conf, $mysoc;
738 $pdf->SetFont(
'',
'', $default_font_size - 1);
740 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
743 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
744 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
745 $pdf->SetXY($this->marge_gauche, $posy);
746 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
748 $posy = $pdf->GetY() + 4;
753 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
756 if ($object->cond_reglement_code || $object->cond_reglement) {
757 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
758 $pdf->SetXY($this->marge_gauche, $posy);
759 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
760 $pdf->MultiCell(43, 4, $titre, 0,
'L');
762 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
763 $pdf->SetXY($posxval, $posy);
764 $lib_condition_paiement = $outputlangs->transnoentities(
"PaymentCondition".$object->cond_reglement_code) != (
'PaymentCondition'.$object->cond_reglement_code) ? $outputlangs->transnoentities(
"PaymentCondition".$object->cond_reglement_code) : $outputlangs->convToOutputCharset($object->cond_reglement_doc ? $object->cond_reglement_doc : $object->cond_reglement_label);
765 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
766 if ($object->deposit_percent > 0) {
767 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement);
769 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
771 $posy = $pdf->GetY() + 3;
802 if (!empty($object->delivery_date)) {
803 $outputlangs->load(
"sendings");
804 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
805 $pdf->SetXY($this->marge_gauche, $posy);
806 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
807 $pdf->MultiCell(80, 4, $titre, 0,
'L');
808 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
809 $pdf->SetXY($posxval, $posy);
810 $dlp =
dol_print_date($object->delivery_date,
"daytext",
false, $outputlangs,
true);
811 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
813 $posy = $pdf->GetY() + 1;
814 } elseif ($object->availability_code || $object->availability) {
816 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
817 $pdf->SetXY($this->marge_gauche, $posy);
818 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
819 $pdf->MultiCell(80, 4, $titre, 0,
'L');
820 $pdf->SetTextColor(0, 0, 0);
821 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
822 $pdf->SetXY($posxval, $posy);
823 $lib_availability = $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) != (
'AvailabilityType'.$object->availability_code) ? $outputlangs->transnoentities(
"AvailabilityType".$object->availability_code) : $outputlangs->convToOutputCharset(isset($object->availability) ? $object->availability :
'');
824 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
825 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
827 $posy = $pdf->GetY() + 1;
831 if ($object->mode_reglement_code
832 && $object->mode_reglement_code !=
'CHQ'
833 && $object->mode_reglement_code !=
'VIR') {
834 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
835 $pdf->SetXY($this->marge_gauche, $posy);
836 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
837 $pdf->MultiCell(80, 5, $titre, 0,
'L');
839 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
840 $pdf->SetXY($posxval, $posy);
841 $lib_mode_reg = $outputlangs->transnoentities(
"PaymentType".$object->mode_reglement_code) != (
'PaymentType'.$object->mode_reglement_code) ? $outputlangs->transnoentities(
"PaymentType".$object->mode_reglement_code) : $outputlangs->convToOutputCharset($object->mode_reglement);
842 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
844 $posy = $pdf->GetY() + 2;
848 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
850 if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
851 if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
852 $account =
new Account($this->db);
853 $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
855 $pdf->SetXY($this->marge_gauche, $posy);
856 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
857 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
858 $posy = $pdf->GetY() + 1;
860 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
861 $pdf->SetXY($this->marge_gauche, $posy);
862 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
863 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
864 $posy = $pdf->GetY() + 2;
867 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
868 $pdf->SetXY($this->marge_gauche, $posy);
869 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
870 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
871 $posy = $pdf->GetY() + 1;
873 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
874 $pdf->SetXY($this->marge_gauche, $posy);
875 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
876 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
877 $posy = $pdf->GetY() + 2;
884 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
885 if ($object->fk_account > 0 || $object->fk_bank > 0 ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
886 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
887 if ($object->fk_bank > 0) {
888 $bankid = $object->fk_bank;
890 $account =
new Account($this->db);
891 $account->fetch($bankid);
893 $curx = $this->marge_gauche;
896 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
918 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis =
null)
921 global $conf, $mysoc, $hookmanager;
925 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
926 $outputlangsbis =
new Translate(
'', $conf);
927 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
928 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
929 $default_font_size--;
934 $pdf->SetFont(
'',
'', $default_font_size - 1);
939 if ($this->page_largeur < 210) {
942 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
948 $pdf->SetFillColor(255, 255, 255);
949 $pdf->SetXY($col1x, $tab2_top);
950 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
952 $total_ht = ((
isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
953 $pdf->SetXY($col2x, $tab2_top);
954 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0,
'R', 1);
957 $pdf->SetFillColor(248, 248, 248);
959 $total_ttc = (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
961 $this->atleastoneratenotnull = 0;
962 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
963 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
964 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) {
970 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
971 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
974 foreach ($localtax_rate as $tvakey => $tvaval) {
979 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
982 if (preg_match(
'/\*/', $tvakey)) {
983 $tvakey = str_replace(
'*',
'', $tvakey);
984 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
986 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
988 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
989 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
991 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
992 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1000 foreach ($this->localtax2 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(
'/\*/', $tvakey)) {
1013 $tvakey = str_replace(
'*',
'', $tvakey);
1014 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1016 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1018 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1019 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1021 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1022 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1029 foreach ($this->tva_array as $tvakey => $tvaval) {
1031 $this->atleastoneratenotnull++;
1034 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1037 if (preg_match(
'/\*/', $tvakey)) {
1038 $tvakey = str_replace(
'*',
'', $tvakey);
1039 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1041 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1044 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1046 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1048 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1050 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1052 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1053 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1060 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1061 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1065 foreach ($localtax_rate as $tvakey => $tvaval) {
1070 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1073 if (preg_match(
'/\*/', $tvakey)) {
1074 $tvakey = str_replace(
'*',
'', $tvakey);
1075 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1077 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1080 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1081 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1082 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1083 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1091 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1092 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1096 foreach ($localtax_rate as $tvakey => $tvaval) {
1102 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1105 if (preg_match(
'/\*/', $tvakey)) {
1106 $tvakey = str_replace(
'*',
'', $tvakey);
1107 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1109 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1112 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1113 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1115 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1116 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1124 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1125 $pdf->SetTextColor(0, 0, 60);
1126 $pdf->SetFillColor(224, 224, 224);
1127 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalTTC", $mysoc->country_code) :
''), $useborder,
'L', 1);
1129 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1130 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1134 $pdf->SetTextColor(0, 0, 0);
1136 $creditnoteamount = 0;
1137 $depositsamount = 0;
1141 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1142 if (!empty($object->paye)) {
1146 if ($deja_regle > 0) {
1150 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1151 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1152 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1153 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1156 $pdf->SetTextColor(0, 0, 60);
1157 $pdf->SetFillColor(224, 224, 224);
1158 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1159 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), $useborder,
'L', 1);
1161 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1162 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1164 $pdf->SetFont(
'',
'', $default_font_size - 1);
1165 $pdf->SetTextColor(0, 0, 0);
1169 return ($tab2_top + ($tab2_hl * $index));
1187 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'', $outputlangsbis =
null)
1197 $currency = !empty($currency) ? $currency : $conf->currency;
1201 $pdf->SetTextColor(0, 0, 0);
1202 $pdf->SetFont(
'',
'', $default_font_size - 2);
1204 if (empty($hidetop)) {
1205 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1206 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1207 $titre .=
' - '.$outputlangsbis->transnoentities(
"AmountInCurrency", $outputlangsbis->transnoentitiesnoconv(
"Currency".$currency));
1210 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1211 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1214 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1215 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5,
'F',
null, explode(
',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1219 $pdf->SetDrawColor(128, 128, 128);
1220 $pdf->SetFont(
'',
'', $default_font_size - 1);
1223 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1225 if (empty($hidetop)) {
1226 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1228 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1229 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1232 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
1233 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1234 if (empty($hidetop)) {
1235 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1236 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1240 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1241 if (empty($hidetop)) {
1242 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1243 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1246 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1247 if (empty($hidetop)) {
1248 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1249 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1253 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1254 if (empty($hidetop)) {
1255 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1256 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1260 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1261 if (empty($hidetop)) {
1262 if ($this->atleastonediscount) {
1263 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1264 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1268 if ($this->atleastonediscount) {
1269 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1271 if (empty($hidetop)) {
1272 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1273 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1290 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null, $titlekey =
"PdfOrderTitle")
1293 global $conf, $langs, $hookmanager;
1295 $ltrdirection =
'L';
1296 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1297 $ltrdirection =
'R';
1301 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1307 $pdf->SetTextColor(0, 0, 60);
1308 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1312 $posy = $this->marge_haute;
1313 $posx = $this->page_largeur - $this->marge_droite - $w;
1315 $pdf->SetXY($this->marge_gauche, $posy);
1319 if ($this->emetteur->logo) {
1320 $logodir = $conf->mycompany->dir_output;
1321 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1322 $logodir = $conf->mycompany->multidir_output[$object->entity];
1325 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1327 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1329 if (is_readable($logo)) {
1331 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1333 $pdf->SetTextColor(200, 0, 0);
1334 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1335 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1336 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1339 $text = $this->emetteur->name;
1340 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1344 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1345 $pdf->SetXY($posx, $posy);
1346 $pdf->SetTextColor(0, 0, 60);
1347 $title = $outputlangs->transnoentities($titlekey);
1348 $title .=
' '.$outputlangs->convToOutputCharset($object->ref);
1349 if ($object->statut == $object::STATUS_DRAFT) {
1350 $pdf->SetTextColor(128, 0, 0);
1351 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1353 $pdf->MultiCell($w, 3, $title,
'',
'R');
1355 $pdf->SetFont(
'',
'B', $default_font_size);
1365 $pdf->SetFont(
'',
'', $default_font_size - 1);
1367 if ($object->ref_client) {
1369 $pdf->SetXY($posx, $posy);
1370 $pdf->SetTextColor(0, 0, 60);
1371 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
1374 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
1375 $object->fetch_projet();
1376 if (!empty($object->project->ref)) {
1378 $pdf->SetXY($posx, $posy);
1379 $pdf->SetTextColor(0, 0, 60);
1380 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1384 if (!empty($conf->global->PDF_SHOW_PROJECT)) {
1385 $object->fetch_projet();
1386 if (!empty($object->project->ref)) {
1387 $outputlangs->load(
"projects");
1389 $pdf->SetXY($posx, $posy);
1390 $pdf->SetTextColor(0, 0, 60);
1391 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1396 $pdf->SetXY($posx, $posy);
1397 $pdf->SetTextColor(0, 0, 60);
1398 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1400 if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) {
1402 $pdf->SetXY($posx, $posy);
1403 $pdf->SetTextColor(0, 0, 60);
1404 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1408 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1409 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1410 if (count($arrayidcontact) > 0) {
1411 $usertmp =
new User($this->db);
1412 $usertmp->fetch($arrayidcontact[0]);
1414 $pdf->SetXY($posx, $posy);
1415 $pdf->SetTextColor(0, 0, 60);
1416 $pdf->MultiCell($w, 3, $langs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1424 $current_y = $pdf->getY();
1425 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
1426 if ($current_y < $pdf->getY()) {
1427 $top_shift = $pdf->getY() - $current_y;
1432 $carac_emetteur =
'';
1434 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1435 if (count($arrayidcontact) > 0) {
1436 $object->fetch_user($arrayidcontact[0]);
1437 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1438 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs));
1440 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_PHONE_AFTER_USER_CONTACT') && !empty($object->user->office_phone)) ? $object->user->office_phone :
'';
1442 $carac_emetteur .= (
getDolGlobalInt(
'PDF_SHOW_EMAIL_AFTER_USER_CONTACT') && !empty($object->user->email)) ? $object->user->email :
'';
1444 $carac_emetteur .=
"\n";
1447 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1450 $posy = 42 + $top_shift;
1451 $posx = $this->marge_gauche;
1452 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1453 $posx = $this->page_largeur - $this->marge_droite - 80;
1458 if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
1459 $pdf->SetTextColor(0, 0, 0);
1460 $pdf->SetFont(
'',
'', $default_font_size - 2);
1461 $pdf->SetXY($posx, $posy - 5);
1462 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1463 $pdf->SetXY($posx, $posy);
1464 $pdf->SetFillColor(230, 230, 230);
1465 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1466 $pdf->SetTextColor(0, 0, 60);
1470 if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
1471 $pdf->SetXY($posx + 2, $posy + 3);
1472 $pdf->SetFont(
'',
'B', $default_font_size);
1473 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1474 $posy = $pdf->getY();
1478 $pdf->SetXY($posx + 2, $posy);
1479 $pdf->SetFont(
'',
'', $default_font_size - 1);
1480 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
1484 $usecontact =
false;
1485 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1486 if (count($arrayidcontact) > 0) {
1488 $result = $object->fetch_contact($arrayidcontact[0]);
1492 if ($usecontact && ($object->contact->socid != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
1493 $thirdparty = $object->contact;
1495 $thirdparty = $object->thirdparty;
1501 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact, $mode, $object);
1504 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1505 if ($this->page_largeur < 210) {
1508 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1509 $posy += $top_shift;
1510 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1511 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1512 $posx = $this->marge_gauche;
1516 if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
1517 $pdf->SetTextColor(0, 0, 0);
1518 $pdf->SetFont(
'',
'', $default_font_size - 2);
1519 $pdf->SetXY($posx + 2, $posy - 5);
1520 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1521 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1525 $pdf->SetXY($posx + 2, $posy + 3);
1526 $pdf->SetFont(
'',
'B', $default_font_size);
1527 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1529 $posy = $pdf->getY();
1532 $pdf->SetFont(
'',
'', $default_font_size - 1);
1533 $pdf->SetXY($posx + 2, $posy);
1534 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1537 $pdf->SetTextColor(0, 0, 0);
1552 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1555 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1556 return pdf_pagefoot($pdf, $outputlangs,
'ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext, $this->page_largeur, $this->watermark);