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 $phpmin = array(7, 0);
85 public $version =
'dolibarr';
105 public $marge_gauche;
110 public $marge_droite;
136 global $conf, $langs, $mysoc;
139 $langs->loadLangs(array(
"main",
"bills",
"products"));
142 $this->
name =
"einstein";
143 $this->
description = $langs->trans(
'PDFEinsteinDescription');
144 $this->update_main_doc_field = 1;
149 $this->page_largeur = $formatarray[
'width'];
150 $this->page_hauteur = $formatarray[
'height'];
151 $this->format = array($this->page_largeur, $this->page_hauteur);
157 $this->option_logo = 1;
158 $this->option_tva = 1;
159 $this->option_modereg = 1;
160 $this->option_condreg = 1;
161 $this->option_multilang = 1;
162 $this->option_escompte = 0;
163 $this->option_credit_note = 0;
164 $this->option_freetext = 1;
165 $this->option_draft_watermark = 1;
166 $this->watermark =
'';
169 $this->emetteur = $mysoc;
170 if (empty($this->emetteur->country_code)) {
171 $this->emetteur->country_code = substr($langs->defaultlang, -2);
175 $this->posxdesc = $this->marge_gauche + 1;
176 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
177 $this->posxtva = 101;
179 $this->posxqty = 135;
180 $this->posxunit = 151;
182 $this->posxtva = 106;
184 $this->posxqty = 145;
185 $this->posxunit = 162;
187 $this->posxdiscount = 162;
188 $this->postotalht = 174;
189 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || !empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
190 $this->posxtva = $this->posxup;
192 $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
193 if ($this->page_largeur < 210) {
194 $this->posxpicture -= 20;
195 $this->posxtva -= 20;
197 $this->posxqty -= 20;
198 $this->posxunit -= 20;
199 $this->posxdiscount -= 20;
200 $this->postotalht -= 20;
203 $this->tva = array();
204 $this->tva_array = array();
205 $this->localtax1 = array();
206 $this->localtax2 = array();
207 $this->atleastoneratenotnull = 0;
208 $this->atleastonediscount = 0;
223 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
226 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
228 if (!is_object($outputlangs)) {
229 $outputlangs = $langs;
232 if (!empty($conf->global->MAIN_USE_FPDF)) {
233 $outputlangs->charset_output =
'ISO-8859-1';
237 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries"));
240 if ($object->statut == $object::STATUS_DRAFT && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) {
241 $this->watermark = $conf->global->COMMANDE_DRAFT_WATERMARK;
244 global $outputlangsbis;
245 $outputlangsbis =
null;
246 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
247 $outputlangsbis =
new Translate(
'', $conf);
248 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
249 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries"));
252 $nblines = count($object->lines);
254 if ($conf->commande->multidir_output[$conf->entity]) {
255 $object->fetch_thirdparty();
260 if ($object->specimen) {
261 $dir = $conf->commande->multidir_output[$conf->entity];
262 $file = $dir.
"/SPECIMEN.pdf";
265 $dir = $conf->commande->multidir_output[$object->entity].
"/".$objectref;
266 $file = $dir.
"/".$objectref.
".pdf";
269 if (!file_exists($dir)) {
271 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
276 if (file_exists($dir)) {
278 if (!is_object($hookmanager)) {
279 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
282 $hookmanager->initHooks(array(
'pdfgeneration'));
283 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
285 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
288 $nblines = count($object->lines);
293 $pdf->SetAutoPageBreak(1, 0);
295 $heightforinfotot = 40;
296 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
297 $heightforfooter = $this->marge_basse + 8;
298 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
299 $heightforfooter += 6;
302 if (class_exists(
'TCPDF')) {
303 $pdf->setPrintHeader(
false);
304 $pdf->setPrintFooter(
false);
308 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
309 $logodir = $conf->mycompany->dir_output;
310 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
311 $logodir = $conf->mycompany->multidir_output[$object->entity];
313 $pagecount = $pdf->setSourceFile($logodir.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
314 $tplidx = $pdf->importPage(1);
319 $pdf->SetDrawColor(128, 128, 128);
321 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
322 $pdf->SetSubject($outputlangs->transnoentities(
"PdfOrderTitle"));
323 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
324 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
325 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfOrderTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
327 $pdf->SetCompression(
false);
330 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
333 for ($i = 0; $i < $nblines; $i++) {
334 if ($object->lines[$i]->remise_percent) {
335 $this->atleastonediscount++;
338 if (empty($this->atleastonediscount)) {
339 $delta = ($this->postotalht - $this->posxdiscount);
340 $this->posxpicture += $delta;
341 $this->posxtva += $delta;
342 $this->posxup += $delta;
343 $this->posxqty += $delta;
344 $this->posxunit += $delta;
345 $this->posxdiscount += $delta;
351 if (!empty($tplidx)) {
352 $pdf->useTemplate($tplidx);
355 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs, (is_object($outputlangsbis) ? $outputlangsbis :
null));
356 $pdf->SetFont(
'',
'', $default_font_size - 1);
357 $pdf->MultiCell(0, 3,
'');
358 $pdf->SetTextColor(0, 0, 0);
361 $tab_top = 90 + $top_shift;
362 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 + $top_shift : 10);
365 $height_incoterms = 0;
367 $desc_incoterms = $object->getIncotermsForPDF();
368 if ($desc_incoterms) {
371 $pdf->SetFont(
'',
'', $default_font_size - 1);
372 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
373 $nexY = $pdf->GetY();
374 $height_incoterms = $nexY - $tab_top;
377 $pdf->SetDrawColor(192, 192, 192);
378 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
380 $tab_top = $nexY + 6;
385 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
386 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
388 if (is_object($object->thirdparty)) {
389 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
390 $salerepobj =
new User($this->
db);
391 $salerepobj->fetch($salereparray[0][
'id']);
392 if (!empty($salerepobj->signature)) {
393 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
398 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
399 if (!empty($extranote)) {
411 $pdf->SetFont(
'',
'', $default_font_size - 1);
412 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
413 $nexY = $pdf->GetY();
414 $height_note = $nexY - $tab_top;
417 $pdf->SetDrawColor(192, 192, 192);
418 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
420 $tab_top = $nexY + 6;
423 $iniY = $tab_top + 7;
424 $curY = $tab_top + 7;
425 $nexY = $tab_top + 7;
428 for ($i = 0; $i < $nblines; $i++) {
430 $pdf->SetFont(
'',
'', $default_font_size - 1);
431 $pdf->SetTextColor(0, 0, 0);
433 $pdf->setTopMargin($tab_top_newpage);
434 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
435 $pageposbefore = $pdf->getPage();
438 $curX = $this->posxdesc - 1;
440 $showpricebeforepagebreak = 1;
442 $pdf->startTransaction();
443 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc);
444 $pageposafter = $pdf->getPage();
445 if ($pageposafter > $pageposbefore) {
446 $pdf->rollbackTransaction(
true);
447 $pageposafter = $pageposbefore;
449 $pdf->setPageOrientation(
'', 1, $heightforfooter);
450 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc);
451 $pageposafter = $pdf->getPage();
452 $posyafter = $pdf->GetY();
453 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot))) {
454 if ($i == ($nblines - 1)) {
455 $pdf->AddPage(
'',
'',
true);
456 if (!empty($tplidx)) {
457 $pdf->useTemplate($tplidx);
460 $this->
_pagehead($pdf, $object, 0, $outputlangs);
462 $pdf->setPage($pageposafter + 1);
467 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE)) {
468 $showpricebeforepagebreak = 1;
470 $showpricebeforepagebreak = 0;
475 $pdf->commitTransaction();
477 $posYAfterDescription = $pdf->GetY();
479 $nexY = $pdf->GetY();
480 $pageposafter = $pdf->getPage();
482 $pdf->setPage($pageposbefore);
483 $pdf->setTopMargin($this->marge_haute);
484 $pdf->setPageOrientation(
'', 1, 0);
487 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
488 $pdf->setPage($pageposafter);
489 $curY = $tab_top_newpage;
492 $pdf->SetFont(
'',
'', $default_font_size - 1);
495 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
497 $pdf->SetXY($this->posxtva - 5, $curY);
498 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
503 $pdf->SetXY($this->posxup, $curY);
504 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
508 $pdf->SetXY($this->posxqty, $curY);
509 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
512 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
513 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
514 $pdf->SetXY($this->posxunit, $curY);
515 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
519 $pdf->SetXY($this->posxdiscount, $curY);
520 if ($object->lines[$i]->remise_percent) {
521 $pdf->SetXY($this->posxdiscount - 2, $curY);
523 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
528 $pdf->SetXY($this->postotalht, $curY);
529 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
532 if (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) {
533 $tvaligne = $object->lines[$i]->multicurrency_total_tva;
535 $tvaligne = $object->lines[$i]->total_tva;
538 $localtax1ligne = $object->lines[$i]->total_localtax1;
539 $localtax2ligne = $object->lines[$i]->total_localtax2;
540 $localtax1_rate = $object->lines[$i]->localtax1_tx;
541 $localtax2_rate = $object->lines[$i]->localtax2_tx;
542 $localtax1_type = $object->lines[$i]->localtax1_type;
543 $localtax2_type = $object->lines[$i]->localtax2_type;
545 if ($object->remise_percent) {
546 $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
548 if ($object->remise_percent) {
549 $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
551 if ($object->remise_percent) {
552 $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
555 $vatrate = (string) $object->lines[$i]->tva_tx;
558 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
559 && (!empty($localtax1_rate) || !empty($localtax2_rate))) {
561 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
562 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
566 if ($localtax1_type && $localtax1ligne != 0) {
567 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
569 if ($localtax2_type && $localtax2ligne != 0) {
570 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
573 if (($object->lines[$i]->info_bits & 0x01) == 0x01) {
578 if (!isset($this->tva[$vatrate])) {
579 $this->tva[$vatrate] = 0;
581 $this->tva[$vatrate] += $tvaligne;
582 $vatcode = $object->lines[$i]->vat_src_code;
583 if (empty($this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'])) {
584 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] = 0;
586 $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')] = array(
'vatrate'=>$vatrate,
'vatcode'=>$vatcode,
'amount'=> $this->tva_array[$vatrate.($vatcode ?
' ('.$vatcode.
')' :
'')][
'amount'] + $tvaligne);
589 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1)) {
590 $pdf->setPage($pageposafter);
591 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
593 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
594 $pdf->SetLineStyle(array(
'dash'=>0));
600 while ($pagenb < $pageposafter) {
601 $pdf->setPage($pagenb);
603 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
605 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
607 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
609 $pdf->setPage($pagenb);
610 $pdf->setPageOrientation(
'', 1, 0);
612 $this->
_pagehead($pdf, $object, 0, $outputlangs);
614 if (!empty($tplidx)) {
615 $pdf->useTemplate($tplidx);
618 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak) {
620 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
622 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
624 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
627 if (!empty($tplidx)) {
628 $pdf->useTemplate($tplidx);
632 $this->
_pagehead($pdf, $object, 0, $outputlangs);
639 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
641 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
643 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
646 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
649 $posy = $this->
_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
660 $this->
_pagefoot($pdf, $object, $outputlangs);
661 if (method_exists($pdf,
'AliasNbPages')) {
662 $pdf->AliasNbPages();
667 $pdf->Output($file,
'F');
670 $hookmanager->initHooks(array(
'pdfgeneration'));
671 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
673 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
675 $this->error = $hookmanager->error;
676 $this->errors = $hookmanager->errors;
679 if (!empty($conf->global->MAIN_UMASK)) {
680 @chmod($file, octdec($conf->global->MAIN_UMASK));
683 $this->result = array(
'fullpath'=>$file);
687 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
691 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"COMMANDE_OUTPUTDIR");
726 global $conf, $mysoc;
729 $pdf->SetFont(
'',
'', $default_font_size - 1);
731 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
734 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
735 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
736 $pdf->SetXY($this->marge_gauche, $posy);
737 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
739 $posy = $pdf->GetY() + 4;
744 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
747 if ($object->cond_reglement_code || $object->cond_reglement) {
748 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
749 $pdf->SetXY($this->marge_gauche, $posy);
750 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
751 $pdf->MultiCell(43, 4, $titre, 0,
'L');
753 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
754 $pdf->SetXY($posxval, $posy);
755 $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);
756 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
757 if ($object->deposit_percent > 0) {
758 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement);
760 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
762 $posy = $pdf->GetY() + 3;
793 if (!empty($object->delivery_date)) {
794 $outputlangs->load(
"sendings");
795 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
796 $pdf->SetXY($this->marge_gauche, $posy);
797 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
798 $pdf->MultiCell(80, 4, $titre, 0,
'L');
799 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
800 $pdf->SetXY($posxval, $posy);
801 $dlp =
dol_print_date($object->delivery_date,
"daytext",
false, $outputlangs,
true);
802 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
804 $posy = $pdf->GetY() + 1;
805 } elseif ($object->availability_code || $object->availability) {
807 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
808 $pdf->SetXY($this->marge_gauche, $posy);
809 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
810 $pdf->MultiCell(80, 4, $titre, 0,
'L');
811 $pdf->SetTextColor(0, 0, 0);
812 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
813 $pdf->SetXY($posxval, $posy);
814 $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 :
'');
815 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
816 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
818 $posy = $pdf->GetY() + 1;
822 if ($object->mode_reglement_code
823 && $object->mode_reglement_code !=
'CHQ'
824 && $object->mode_reglement_code !=
'VIR') {
825 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
826 $pdf->SetXY($this->marge_gauche, $posy);
827 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
828 $pdf->MultiCell(80, 5, $titre, 0,
'L');
830 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
831 $pdf->SetXY($posxval, $posy);
832 $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);
833 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
835 $posy = $pdf->GetY() + 2;
839 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
841 if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
842 if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
844 $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
846 $pdf->SetXY($this->marge_gauche, $posy);
847 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
848 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
849 $posy = $pdf->GetY() + 1;
851 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
852 $pdf->SetXY($this->marge_gauche, $posy);
853 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
854 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
855 $posy = $pdf->GetY() + 2;
858 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
859 $pdf->SetXY($this->marge_gauche, $posy);
860 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
861 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
862 $posy = $pdf->GetY() + 1;
864 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
865 $pdf->SetXY($this->marge_gauche, $posy);
866 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
867 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
868 $posy = $pdf->GetY() + 2;
875 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
876 if ($object->fk_account > 0 || $object->fk_bank > 0 ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
877 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
878 if ($object->fk_bank > 0) {
879 $bankid = $object->fk_bank;
882 $account->fetch($bankid);
884 $curx = $this->marge_gauche;
887 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
909 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis =
null)
912 global $conf, $mysoc, $hookmanager;
916 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
917 $outputlangsbis =
new Translate(
'', $conf);
918 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
919 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
920 $default_font_size--;
925 $pdf->SetFont(
'',
'', $default_font_size - 1);
930 if ($this->page_largeur < 210) {
933 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
939 $pdf->SetFillColor(255, 255, 255);
940 $pdf->SetXY($col1x, $tab2_top + 0);
941 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
943 $total_ht = ((
isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
944 $pdf->SetXY($col2x, $tab2_top + 0);
945 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0,
'R', 1);
948 $pdf->SetFillColor(248, 248, 248);
950 $total_ttc = (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
952 $this->atleastoneratenotnull = 0;
953 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
954 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
955 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) {
961 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
962 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
965 foreach ($localtax_rate as $tvakey => $tvaval) {
970 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
973 if (preg_match(
'/\*/', $tvakey)) {
974 $tvakey = str_replace(
'*',
'', $tvakey);
975 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
977 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
979 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
980 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
982 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
983 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
991 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
992 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
995 foreach ($localtax_rate as $tvakey => $tvaval) {
1000 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1003 if (preg_match(
'/\*/', $tvakey)) {
1004 $tvakey = str_replace(
'*',
'', $tvakey);
1005 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1007 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1009 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1010 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1012 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1013 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1020 foreach ($this->tva_array as $tvakey => $tvaval) {
1022 $this->atleastoneratenotnull++;
1025 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1028 if (preg_match(
'/\*/', $tvakey)) {
1029 $tvakey = str_replace(
'*',
'', $tvakey);
1030 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1032 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1035 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1037 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1039 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1041 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1043 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1044 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1051 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1052 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1056 foreach ($localtax_rate as $tvakey => $tvaval) {
1061 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1064 if (preg_match(
'/\*/', $tvakey)) {
1065 $tvakey = str_replace(
'*',
'', $tvakey);
1066 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1068 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1071 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1072 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1073 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1074 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1082 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1083 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1087 foreach ($localtax_rate as $tvakey => $tvaval) {
1093 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1096 if (preg_match(
'/\*/', $tvakey)) {
1097 $tvakey = str_replace(
'*',
'', $tvakey);
1098 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1100 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1103 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1104 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1106 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1107 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1115 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1116 $pdf->SetTextColor(0, 0, 60);
1117 $pdf->SetFillColor(224, 224, 224);
1118 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalTTC", $mysoc->country_code) :
''), $useborder,
'L', 1);
1120 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1121 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1125 $pdf->SetTextColor(0, 0, 0);
1127 $creditnoteamount = 0;
1128 $depositsamount = 0;
1132 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1133 if (!empty($object->paye)) {
1137 if ($deja_regle > 0) {
1141 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1142 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1143 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1144 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1147 $pdf->SetTextColor(0, 0, 60);
1148 $pdf->SetFillColor(224, 224, 224);
1149 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1150 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), $useborder,
'L', 1);
1152 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1153 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1155 $pdf->SetFont(
'',
'', $default_font_size - 1);
1156 $pdf->SetTextColor(0, 0, 0);
1160 return ($tab2_top + ($tab2_hl * $index));
1178 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'', $outputlangsbis =
null)
1188 $currency = !empty($currency) ? $currency : $conf->currency;
1192 $pdf->SetTextColor(0, 0, 0);
1193 $pdf->SetFont(
'',
'', $default_font_size - 2);
1195 if (empty($hidetop)) {
1196 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1197 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1198 $titre .=
' - '.$outputlangsbis->transnoentities(
"AmountInCurrency", $outputlangsbis->transnoentitiesnoconv(
"Currency".$currency));
1201 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1202 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1205 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1206 $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));
1210 $pdf->SetDrawColor(128, 128, 128);
1211 $pdf->SetFont(
'',
'', $default_font_size - 1);
1214 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1216 if (empty($hidetop)) {
1217 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1219 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1220 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1223 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
1224 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1225 if (empty($hidetop)) {
1226 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1227 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1231 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1232 if (empty($hidetop)) {
1233 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1234 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1237 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1238 if (empty($hidetop)) {
1239 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1240 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1243 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1244 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1245 if (empty($hidetop)) {
1246 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1247 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1251 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1252 if (empty($hidetop)) {
1253 if ($this->atleastonediscount) {
1254 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1255 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1259 if ($this->atleastonediscount) {
1260 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1262 if (empty($hidetop)) {
1263 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1264 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHTShort"),
'',
'C');
1281 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null, $titlekey =
"PdfOrderTitle")
1284 global $conf, $langs, $hookmanager;
1286 $ltrdirection =
'L';
1287 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1288 $ltrdirection =
'R';
1292 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1298 $pdf->SetTextColor(0, 0, 60);
1299 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1303 $posy = $this->marge_haute;
1304 $posx = $this->page_largeur - $this->marge_droite - $w;
1306 $pdf->SetXY($this->marge_gauche, $posy);
1309 if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO)) {
1310 if ($this->emetteur->logo) {
1311 $logodir = $conf->mycompany->dir_output;
1312 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1313 $logodir = $conf->mycompany->multidir_output[$object->entity];
1315 if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO)) {
1316 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1318 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1320 if (is_readable($logo)) {
1322 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1324 $pdf->SetTextColor(200, 0, 0);
1325 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1326 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1327 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1330 $text = $this->emetteur->name;
1331 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1335 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1336 $pdf->SetXY($posx, $posy);
1337 $pdf->SetTextColor(0, 0, 60);
1338 $title = $outputlangs->transnoentities($titlekey);
1339 $title .=
' '.$outputlangs->convToOutputCharset($object->ref);
1340 if ($object->statut == $object::STATUS_DRAFT) {
1341 $pdf->SetTextColor(128, 0, 0);
1342 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1344 $pdf->MultiCell($w, 3, $title,
'',
'R');
1346 $pdf->SetFont(
'',
'B', $default_font_size);
1356 $pdf->SetFont(
'',
'', $default_font_size - 1);
1358 if ($object->ref_client) {
1360 $pdf->SetXY($posx, $posy);
1361 $pdf->SetTextColor(0, 0, 60);
1362 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
1365 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
1366 $object->fetch_projet();
1367 if (!empty($object->project->ref)) {
1369 $pdf->SetXY($posx, $posy);
1370 $pdf->SetTextColor(0, 0, 60);
1371 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1375 if (!empty($conf->global->PDF_SHOW_PROJECT)) {
1376 $object->fetch_projet();
1377 if (!empty($object->project->ref)) {
1378 $outputlangs->load(
"projects");
1380 $pdf->SetXY($posx, $posy);
1381 $pdf->SetTextColor(0, 0, 60);
1382 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1387 $pdf->SetXY($posx, $posy);
1388 $pdf->SetTextColor(0, 0, 60);
1389 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1391 if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) {
1393 $pdf->SetXY($posx, $posy);
1394 $pdf->SetTextColor(0, 0, 60);
1395 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1399 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1400 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1401 if (count($arrayidcontact) > 0) {
1402 $usertmp =
new User($this->
db);
1403 $usertmp->fetch($arrayidcontact[0]);
1405 $pdf->SetXY($posx, $posy);
1406 $pdf->SetTextColor(0, 0, 60);
1407 $pdf->MultiCell($w, 3, $langs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1415 $current_y = $pdf->getY();
1416 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
1417 if ($current_y < $pdf->getY()) {
1418 $top_shift = $pdf->getY() - $current_y;
1423 $carac_emetteur =
'';
1425 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1426 if (count($arrayidcontact) > 0) {
1427 $object->fetch_user($arrayidcontact[0]);
1428 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1429 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)).
"\n";
1432 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1435 $posy = 42 + $top_shift;
1436 $posx = $this->marge_gauche;
1437 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1438 $posx = $this->page_largeur - $this->marge_droite - 80;
1443 if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
1444 $pdf->SetTextColor(0, 0, 0);
1445 $pdf->SetFont(
'',
'', $default_font_size - 2);
1446 $pdf->SetXY($posx, $posy - 5);
1447 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1448 $pdf->SetXY($posx, $posy);
1449 $pdf->SetFillColor(230, 230, 230);
1450 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1451 $pdf->SetTextColor(0, 0, 60);
1455 if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
1456 $pdf->SetXY($posx + 2, $posy + 3);
1457 $pdf->SetFont(
'',
'B', $default_font_size);
1458 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1459 $posy = $pdf->getY();
1463 $pdf->SetXY($posx + 2, $posy);
1464 $pdf->SetFont(
'',
'', $default_font_size - 1);
1465 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
1469 $usecontact =
false;
1470 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1471 if (count($arrayidcontact) > 0) {
1473 $result = $object->fetch_contact($arrayidcontact[0]);
1477 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)))) {
1478 $thirdparty = $object->contact;
1480 $thirdparty = $object->thirdparty;
1486 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact, $mode, $object);
1489 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1490 if ($this->page_largeur < 210) {
1493 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1494 $posy += $top_shift;
1495 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1496 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1497 $posx = $this->marge_gauche;
1501 if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
1502 $pdf->SetTextColor(0, 0, 0);
1503 $pdf->SetFont(
'',
'', $default_font_size - 2);
1504 $pdf->SetXY($posx + 2, $posy - 5);
1505 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1506 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1510 $pdf->SetXY($posx + 2, $posy + 3);
1511 $pdf->SetFont(
'',
'B', $default_font_size);
1512 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1514 $posy = $pdf->getY();
1517 $pdf->SetFont(
'',
'', $default_font_size - 1);
1518 $pdf->SetXY($posx + 2, $posy);
1519 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1522 $pdf->SetTextColor(0, 0, 0);
1537 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1540 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1541 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);