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;
177 $this->posxtva = 101;
179 $this->posxqty = 135;
180 $this->posxunit = 151;
182 $this->posxtva = 110;
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 &&
getDolGlobalString(
'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');
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);
732 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj)) {
733 $pdf->SetFont(
'',
'B', $default_font_size - 2);
734 $pdf->SetXY($this->marge_gauche, $posy);
735 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
737 $posy = $pdf->GetY() + 4;
743 if ($object->cond_reglement_code || $object->cond_reglement) {
744 $pdf->SetFont(
'',
'B', $default_font_size - 2);
745 $pdf->SetXY($this->marge_gauche, $posy);
746 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
747 $pdf->MultiCell(43, 4, $titre, 0,
'L');
749 $pdf->SetFont(
'',
'', $default_font_size - 2);
750 $pdf->SetXY($posxval, $posy);
751 $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);
752 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
753 if ($object->deposit_percent > 0) {
754 $lib_condition_paiement = str_replace(
'__DEPOSIT_PERCENT__', $object->deposit_percent, $lib_condition_paiement);
756 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
758 $posy = $pdf->GetY() + 3;
789 if (!empty($object->delivery_date)) {
790 $outputlangs->load(
"sendings");
791 $pdf->SetFont(
'',
'B', $default_font_size - 2);
792 $pdf->SetXY($this->marge_gauche, $posy);
793 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
794 $pdf->MultiCell(80, 4, $titre, 0,
'L');
795 $pdf->SetFont(
'',
'', $default_font_size - 2);
796 $pdf->SetXY($posxval, $posy);
797 $dlp =
dol_print_date($object->delivery_date,
"daytext",
false, $outputlangs,
true);
798 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
800 $posy = $pdf->GetY() + 1;
801 } elseif ($object->availability_code || $object->availability) {
803 $pdf->SetFont(
'',
'B', $default_font_size - 2);
804 $pdf->SetXY($this->marge_gauche, $posy);
805 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
806 $pdf->MultiCell(80, 4, $titre, 0,
'L');
807 $pdf->SetTextColor(0, 0, 0);
808 $pdf->SetFont(
'',
'', $default_font_size - 2);
809 $pdf->SetXY($posxval, $posy);
810 $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 :
'');
811 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
812 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
814 $posy = $pdf->GetY() + 1;
818 if ($object->mode_reglement_code
819 && $object->mode_reglement_code !=
'CHQ'
820 && $object->mode_reglement_code !=
'VIR') {
821 $pdf->SetFont(
'',
'B', $default_font_size - 2);
822 $pdf->SetXY($this->marge_gauche, $posy);
823 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
824 $pdf->MultiCell(80, 5, $titre, 0,
'L');
826 $pdf->SetFont(
'',
'', $default_font_size - 2);
827 $pdf->SetXY($posxval, $posy);
828 $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);
829 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
831 $posy = $pdf->GetY() + 2;
835 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ') {
837 if (!empty($conf->global->FACTURE_CHQ_NUMBER)) {
838 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
840 if ($conf->global->FACTURE_CHQ_NUMBER > 0) {
842 $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
844 $pdf->SetXY($this->marge_gauche, $posy);
845 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
846 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
847 $posy = $pdf->GetY() + 1;
849 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
850 $pdf->SetXY($this->marge_gauche, $posy);
851 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
852 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
853 $posy = $pdf->GetY() + 2;
856 if ($conf->global->FACTURE_CHQ_NUMBER == -1) {
857 $pdf->SetXY($this->marge_gauche, $posy);
858 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
859 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
860 $posy = $pdf->GetY() + 1;
862 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS)) {
863 $pdf->SetXY($this->marge_gauche, $posy);
864 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
865 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
866 $posy = $pdf->GetY() + 2;
873 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR') {
874 if ($object->fk_account > 0 || $object->fk_bank > 0 ||
getDolGlobalInt(
'FACTURE_RIB_NUMBER')) {
875 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
876 if ($object->fk_bank > 0) {
877 $bankid = $object->fk_bank;
880 $account->fetch($bankid);
882 $curx = $this->marge_gauche;
885 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
907 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis =
null)
910 global $conf, $mysoc, $hookmanager;
914 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
915 $outputlangsbis =
new Translate(
'', $conf);
916 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
917 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
918 $default_font_size--;
923 $pdf->SetFont(
'',
'', $default_font_size - 1);
928 if ($this->page_largeur < 210) {
931 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
937 $pdf->SetFillColor(255, 255, 255);
938 $pdf->SetXY($col1x, $tab2_top);
939 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
941 $total_ht = ((
isModEnabled(
"multicurrency") && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
942 $pdf->SetXY($col2x, $tab2_top);
943 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0,
'R', 1);
946 $pdf->SetFillColor(248, 248, 248);
948 $total_ttc = (
isModEnabled(
"multicurrency") && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
950 $this->atleastoneratenotnull = 0;
951 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) {
952 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
953 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) {
959 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
960 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
963 foreach ($localtax_rate as $tvakey => $tvaval) {
968 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
971 if (preg_match(
'/\*/', $tvakey)) {
972 $tvakey = str_replace(
'*',
'', $tvakey);
973 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
975 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
977 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
978 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
980 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
981 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
989 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
990 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5'))) {
993 foreach ($localtax_rate as $tvakey => $tvaval) {
998 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1001 if (preg_match(
'/\*/', $tvakey)) {
1002 $tvakey = str_replace(
'*',
'', $tvakey);
1003 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1005 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1007 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1008 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1010 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1011 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1018 foreach ($this->tva_array as $tvakey => $tvaval) {
1020 $this->atleastoneratenotnull++;
1023 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1026 if (preg_match(
'/\*/', $tvakey)) {
1027 $tvakey = str_replace(
'*',
'', $tvakey);
1028 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1030 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1033 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).$tvacompl;
1035 $totalvat .= $tvaval[
'vatcode'].$tvacompl;
1037 $totalvat .=
vatrate($tvaval[
'vatrate'], 1).($tvaval[
'vatcode'] ?
' ('.$tvaval[
'vatcode'].
')' :
'').$tvacompl;
1039 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1041 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1042 $pdf->MultiCell($largcol2, $tab2_hl,
price(
price2num($tvaval[
'amount'],
'MT'), 0, $outputlangs), 0,
'R', 1);
1049 foreach ($this->localtax1 as $localtax_type => $localtax_rate) {
1050 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1054 foreach ($localtax_rate as $tvakey => $tvaval) {
1059 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1062 if (preg_match(
'/\*/', $tvakey)) {
1063 $tvakey = str_replace(
'*',
'', $tvakey);
1064 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1066 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1069 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1070 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1071 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1072 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1080 foreach ($this->localtax2 as $localtax_type => $localtax_rate) {
1081 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6'))) {
1085 foreach ($localtax_rate as $tvakey => $tvaval) {
1091 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1094 if (preg_match(
'/\*/', $tvakey)) {
1095 $tvakey = str_replace(
'*',
'', $tvakey);
1096 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1098 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1101 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1102 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1104 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1105 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1113 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1114 $pdf->SetTextColor(0, 0, 60);
1115 $pdf->SetFillColor(224, 224, 224);
1116 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalTTC", $mysoc->country_code) :
''), $useborder,
'L', 1);
1118 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1119 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1123 $pdf->SetTextColor(0, 0, 0);
1125 $creditnoteamount = 0;
1126 $depositsamount = 0;
1130 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1131 if (!empty($object->paye)) {
1135 if ($deja_regle > 0) {
1139 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1140 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1141 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1142 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1145 $pdf->SetTextColor(0, 0, 60);
1146 $pdf->SetFillColor(224, 224, 224);
1147 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1148 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), $useborder,
'L', 1);
1150 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1151 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1153 $pdf->SetFont(
'',
'', $default_font_size - 1);
1154 $pdf->SetTextColor(0, 0, 0);
1158 return ($tab2_top + ($tab2_hl * $index));
1176 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'', $outputlangsbis =
null)
1186 $currency = !empty($currency) ? $currency : $conf->currency;
1190 $pdf->SetTextColor(0, 0, 0);
1191 $pdf->SetFont(
'',
'', $default_font_size - 2);
1193 if (empty($hidetop)) {
1194 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1195 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1196 $titre .=
' - '.$outputlangsbis->transnoentities(
"AmountInCurrency", $outputlangsbis->transnoentitiesnoconv(
"Currency".$currency));
1199 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1200 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1203 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1204 $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));
1208 $pdf->SetDrawColor(128, 128, 128);
1209 $pdf->SetFont(
'',
'', $default_font_size - 1);
1212 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1214 if (empty($hidetop)) {
1215 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1217 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1218 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1221 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
1222 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1223 if (empty($hidetop)) {
1224 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1225 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1229 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1230 if (empty($hidetop)) {
1231 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1232 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1235 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1236 if (empty($hidetop)) {
1237 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1238 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1242 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1243 if (empty($hidetop)) {
1244 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1245 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1249 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1250 if (empty($hidetop)) {
1251 if ($this->atleastonediscount) {
1252 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1253 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1257 if ($this->atleastonediscount) {
1258 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1260 if (empty($hidetop)) {
1261 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1262 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
1279 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis =
null, $titlekey =
"PdfOrderTitle")
1282 global $conf, $langs, $hookmanager;
1284 $ltrdirection =
'L';
1285 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
1286 $ltrdirection =
'R';
1290 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1296 $pdf->SetTextColor(0, 0, 60);
1297 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1301 $posy = $this->marge_haute;
1302 $posx = $this->page_largeur - $this->marge_droite - $w;
1304 $pdf->SetXY($this->marge_gauche, $posy);
1308 if ($this->emetteur->logo) {
1309 $logodir = $conf->mycompany->dir_output;
1310 if (!empty($conf->mycompany->multidir_output[$object->entity])) {
1311 $logodir = $conf->mycompany->multidir_output[$object->entity];
1314 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1316 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1318 if (is_readable($logo)) {
1320 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1322 $pdf->SetTextColor(200, 0, 0);
1323 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1324 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1325 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1328 $text = $this->emetteur->name;
1329 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
1333 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1334 $pdf->SetXY($posx, $posy);
1335 $pdf->SetTextColor(0, 0, 60);
1336 $title = $outputlangs->transnoentities($titlekey);
1337 $title .=
' '.$outputlangs->convToOutputCharset($object->ref);
1338 if ($object->statut == $object::STATUS_DRAFT) {
1339 $pdf->SetTextColor(128, 0, 0);
1340 $title .=
' - '.$outputlangs->transnoentities(
"NotValidated");
1342 $pdf->MultiCell($w, 3, $title,
'',
'R');
1344 $pdf->SetFont(
'',
'B', $default_font_size);
1354 $pdf->SetFont(
'',
'', $default_font_size - 1);
1356 if ($object->ref_client) {
1358 $pdf->SetXY($posx, $posy);
1359 $pdf->SetTextColor(0, 0, 60);
1360 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
1363 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE)) {
1364 $object->fetch_projet();
1365 if (!empty($object->project->ref)) {
1367 $pdf->SetXY($posx, $posy);
1368 $pdf->SetTextColor(0, 0, 60);
1369 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->project->title),
'',
'R');
1373 if (!empty($conf->global->PDF_SHOW_PROJECT)) {
1374 $object->fetch_projet();
1375 if (!empty($object->project->ref)) {
1376 $outputlangs->load(
"projects");
1378 $pdf->SetXY($posx, $posy);
1379 $pdf->SetTextColor(0, 0, 60);
1380 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->project->ref),
'',
'R');
1385 $pdf->SetXY($posx, $posy);
1386 $pdf->SetTextColor(0, 0, 60);
1387 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1389 if (empty($conf->global->MAIN_PDF_HIDE_CUSTOMER_CODE) && !empty($object->thirdparty->code_client)) {
1391 $pdf->SetXY($posx, $posy);
1392 $pdf->SetTextColor(0, 0, 60);
1393 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1397 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) {
1398 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1399 if (count($arrayidcontact) > 0) {
1400 $usertmp =
new User($this->
db);
1401 $usertmp->fetch($arrayidcontact[0]);
1403 $pdf->SetXY($posx, $posy);
1404 $pdf->SetTextColor(0, 0, 60);
1405 $pdf->MultiCell($w, 3, $langs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1413 $current_y = $pdf->getY();
1414 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
1415 if ($current_y < $pdf->getY()) {
1416 $top_shift = $pdf->getY() - $current_y;
1421 $carac_emetteur =
'';
1423 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1424 if (count($arrayidcontact) > 0) {
1425 $object->fetch_user($arrayidcontact[0]);
1426 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1427 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)).
"\n";
1430 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1433 $posy = 42 + $top_shift;
1434 $posx = $this->marge_gauche;
1435 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1436 $posx = $this->page_largeur - $this->marge_droite - 80;
1441 if (empty($conf->global->MAIN_PDF_NO_SENDER_FRAME)) {
1442 $pdf->SetTextColor(0, 0, 0);
1443 $pdf->SetFont(
'',
'', $default_font_size - 2);
1444 $pdf->SetXY($posx, $posy - 5);
1445 $pdf->MultiCell(80, 5, $outputlangs->transnoentities(
"BillFrom"), 0, $ltrdirection);
1446 $pdf->SetXY($posx, $posy);
1447 $pdf->SetFillColor(230, 230, 230);
1448 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1449 $pdf->SetTextColor(0, 0, 60);
1453 if (empty($conf->global->MAIN_PDF_HIDE_SENDER_NAME)) {
1454 $pdf->SetXY($posx + 2, $posy + 3);
1455 $pdf->SetFont(
'',
'B', $default_font_size);
1456 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0, $ltrdirection);
1457 $posy = $pdf->getY();
1461 $pdf->SetXY($posx + 2, $posy);
1462 $pdf->SetFont(
'',
'', $default_font_size - 1);
1463 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
1467 $usecontact =
false;
1468 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1469 if (count($arrayidcontact) > 0) {
1471 $result = $object->fetch_contact($arrayidcontact[0]);
1475 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)))) {
1476 $thirdparty = $object->contact;
1478 $thirdparty = $object->thirdparty;
1484 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact, $mode, $object);
1487 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1488 if ($this->page_largeur < 210) {
1491 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1492 $posy += $top_shift;
1493 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1494 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) {
1495 $posx = $this->marge_gauche;
1499 if (empty($conf->global->MAIN_PDF_NO_RECIPENT_FRAME)) {
1500 $pdf->SetTextColor(0, 0, 0);
1501 $pdf->SetFont(
'',
'', $default_font_size - 2);
1502 $pdf->SetXY($posx + 2, $posy - 5);
1503 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo"), 0, $ltrdirection);
1504 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1508 $pdf->SetXY($posx + 2, $posy + 3);
1509 $pdf->SetFont(
'',
'B', $default_font_size);
1510 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0, $ltrdirection);
1512 $posy = $pdf->getY();
1515 $pdf->SetFont(
'',
'', $default_font_size - 1);
1516 $pdf->SetXY($posx + 2, $posy);
1517 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0, $ltrdirection);
1520 $pdf->SetTextColor(0, 0, 0);
1535 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1538 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
1539 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);
Class to manage bank accounts.
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
Parent class for orders models.
Class to manage translations.
Class to manage Dolibarr users.
Class to generate PDF orders with template Einstein.
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis=null, $titlekey="PdfOrderTitle")
Show top header of page.
__construct($db)
Constructor.
_tableau_info(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs, $outputlangsbis=null)
Show total to pay.
_tableau_versements(&$pdf, $object, $posy, $outputlangs)
Show payments table.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='', $outputlangsbis=null)
Show table for lines.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
write_file($object, $outputlangs, $srctemplatepath='', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
print *****$script_file(".$version.") pid cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
if(!function_exists('dolEscapeXML')) convertBackOfficeMediasLinksToPublicLinks($notetoshow)
Convert links to local wrapper to medias files into a string into a public external URL readable on i...
vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0, $html=0)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
complete_substitutions_array(&$substitutionarray, $outputlangs, $object=null, $parameters=null, $callfunc="completesubstitutionarray")
Complete the $substitutionarray with more entries coming from external module that had set the "subst...
make_substitutions($text, $substitutionarray, $outputlangs=null, $converttextinhtmlifnecessary=0)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_htmlentitiesbr($stringtoencode, $nl2brmode=0, $pagecodefrom='UTF-8', $removelasteolbr=1)
This function is called to encode a string into a HTML string but differs from htmlentities because a...
isModEnabled($module)
Is Dolibarr module enabled.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
if(!defined( 'CSRFCHECK_WITH_TOKEN'))
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
pdf_getFormat(Translate $outputlangs=null, $mode='setup')
Return array with format properties of default PDF format.
pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0)
Output line description into PDF.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0, $page_largeur=0, $watermark='')
Show footer of page for PDF generation.
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0, $hookmanager=false)
Return line unit.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank informations for PDF generation.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_build_address($outputlangs, $sourcecompany, $targetcompany='', $targetcontact='', $usecontact=0, $mode='source', $object=null)
Return a string with full address formated for output on documents.
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
$conf db name
Only used if Module[ID]Name translation string is not found.
$conf db
API class for accounts.