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';
63 public $update_main_doc_field;
74 public $phpmin = array(5, 6);
80 public $version =
'dolibarr';
100 public $marge_gauche;
105 public $marge_droite;
131 global $conf, $langs, $mysoc;
134 $langs->loadLangs(array(
"main",
"bills",
"products"));
137 $this->
name =
"einstein";
138 $this->
description = $langs->trans(
'PDFEinsteinDescription');
139 $this->update_main_doc_field = 1;
144 $this->page_largeur = $formatarray[
'width'];
145 $this->page_hauteur = $formatarray[
'height'];
146 $this->format = array($this->page_largeur, $this->page_hauteur);
147 $this->marge_gauche = isset($conf->global->MAIN_PDF_MARGIN_LEFT) ? $conf->global->MAIN_PDF_MARGIN_LEFT : 10;
148 $this->marge_droite = isset($conf->global->MAIN_PDF_MARGIN_RIGHT) ? $conf->global->MAIN_PDF_MARGIN_RIGHT : 10;
149 $this->marge_haute = isset($conf->global->MAIN_PDF_MARGIN_TOP) ? $conf->global->MAIN_PDF_MARGIN_TOP : 10;
150 $this->marge_basse = isset($conf->global->MAIN_PDF_MARGIN_BOTTOM) ? $conf->global->MAIN_PDF_MARGIN_BOTTOM : 10;
152 $this->option_logo = 1;
153 $this->option_tva = 1;
154 $this->option_modereg = 1;
155 $this->option_condreg = 1;
156 $this->option_codeproduitservice = 1;
157 $this->option_multilang = 1;
158 $this->option_escompte = 0;
159 $this->option_credit_note = 0;
160 $this->option_freetext = 1;
161 $this->option_draft_watermark = 1;
164 $this->emetteur = $mysoc;
165 if (empty($this->emetteur->country_code)) $this->emetteur->country_code = substr($langs->defaultlang, -2);
168 $this->posxdesc = $this->marge_gauche + 1;
169 if (!empty($conf->global->PRODUCT_USE_UNITS))
171 $this->posxtva = 101;
173 $this->posxqty = 135;
174 $this->posxunit = 151;
176 $this->posxtva = 110;
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)) $this->posxtva = $this->posxup;
184 $this->posxpicture = $this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH) ? 20 : $conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH);
185 if ($this->page_largeur < 210)
187 $this->posxpicture -= 20;
188 $this->posxtva -= 20;
190 $this->posxqty -= 20;
191 $this->posxunit -= 20;
192 $this->posxdiscount -= 20;
193 $this->postotalht -= 20;
196 $this->tva = array();
197 $this->localtax1 = array();
198 $this->localtax2 = array();
199 $this->atleastoneratenotnull = 0;
200 $this->atleastonediscount = 0;
215 public function write_file($object, $outputlangs, $srctemplatepath =
'', $hidedetails = 0, $hidedesc = 0, $hideref = 0)
218 global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblines;
220 if (!is_object($outputlangs)) $outputlangs = $langs;
222 if (!empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output =
'ISO-8859-1';
225 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries"));
227 global $outputlangsbis;
228 $outputlangsbis = null;
229 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
230 $outputlangsbis =
new Translate(
'', $conf);
231 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
232 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries"));
235 $nblines = count($object->lines);
237 if ($conf->commande->multidir_output[$conf->entity])
239 $object->fetch_thirdparty();
244 if ($object->specimen)
246 $dir = $conf->commande->multidir_output[$conf->entity];
247 $file = $dir.
"/SPECIMEN.pdf";
250 $dir = $conf->commande->multidir_output[$object->entity].
"/".$objectref;
251 $file = $dir.
"/".$objectref.
".pdf";
254 if (!file_exists($dir))
258 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
263 if (file_exists($dir))
266 if (!is_object($hookmanager))
268 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
271 $hookmanager->initHooks(array(
'pdfgeneration'));
272 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
274 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
279 $pdf->SetAutoPageBreak(1, 0);
281 $heightforinfotot = 40;
282 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
283 $heightforfooter = $this->marge_basse + 8;
284 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) $heightforfooter += 6;
286 if (class_exists(
'TCPDF'))
288 $pdf->setPrintHeader(
false);
289 $pdf->setPrintFooter(
false);
293 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
295 $pagecount = $pdf->setSourceFile($conf->mycompany->multidir_output[$object->entity].
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
296 $tplidx = $pdf->importPage(1);
301 $pdf->SetDrawColor(128, 128, 128);
303 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
304 $pdf->SetSubject($outputlangs->transnoentities(
"PdfOrderTitle"));
305 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
306 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
307 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"PdfOrderTitle").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
308 if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(
false);
310 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
313 for ($i = 0; $i < $nblines; $i++)
315 if ($object->lines[$i]->remise_percent)
317 $this->atleastonediscount++;
320 if (empty($this->atleastonediscount))
322 $delta = ($this->postotalht - $this->posxdiscount);
323 $this->posxpicture += $delta;
324 $this->posxtva += $delta;
325 $this->posxup += $delta;
326 $this->posxqty += $delta;
327 $this->posxunit += $delta;
328 $this->posxdiscount += $delta;
334 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
336 $top_shift = $this->
_pagehead($pdf, $object, 1, $outputlangs, (is_object($outputlangsbis) ? $outputlangsbis : null));
337 $pdf->SetFont(
'',
'', $default_font_size - 1);
338 $pdf->MultiCell(0, 3,
'');
339 $pdf->SetTextColor(0, 0, 0);
342 $tab_top = 90 + $top_shift;
343 $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 42 + $top_shift : 10);
346 $height_incoterms = 0;
347 if (!empty($conf->incoterm->enabled))
349 $desc_incoterms = $object->getIncotermsForPDF();
354 $pdf->SetFont(
'',
'', $default_font_size - 1);
355 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($desc_incoterms), 0, 1);
356 $nexY = $pdf->GetY();
357 $height_incoterms = $nexY - $tab_top;
360 $pdf->SetDrawColor(192, 192, 192);
361 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_incoterms + 1);
363 $tab_top = $nexY + 6;
368 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
369 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE))
372 if (is_object($object->thirdparty))
374 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
375 $salerepobj =
new User($this->
db);
376 $salerepobj->fetch($salereparray[0][
'id']);
377 if (!empty($salerepobj->signature)) $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
381 $extranote = $this->getExtrafieldsInHtml($object, $outputlangs);
382 if (!empty($extranote)) {
395 $pdf->SetFont(
'',
'', $default_font_size - 1);
396 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top - 1,
dol_htmlentitiesbr($notetoshow), 0, 1);
397 $nexY = $pdf->GetY();
398 $height_note = $nexY - $tab_top;
401 $pdf->SetDrawColor(192, 192, 192);
402 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
404 $tab_top = $nexY + 6;
407 $iniY = $tab_top + 7;
408 $curY = $tab_top + 7;
409 $nexY = $tab_top + 7;
412 for ($i = 0; $i < $nblines; $i++)
415 $pdf->SetFont(
'',
'', $default_font_size - 1);
416 $pdf->SetTextColor(0, 0, 0);
418 $pdf->setTopMargin($tab_top_newpage);
419 $pdf->setPageOrientation(
'', 1, $heightforfooter + $heightforfreetext + $heightforinfotot);
420 $pageposbefore = $pdf->getPage();
423 $curX = $this->posxdesc - 1;
425 $showpricebeforepagebreak = 1;
427 $pdf->startTransaction();
428 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 3, $curX, $curY, $hideref, $hidedesc);
429 $pageposafter = $pdf->getPage();
430 if ($pageposafter > $pageposbefore)
432 $pdf->rollbackTransaction(
true);
433 $pageposafter = $pageposbefore;
435 $pdf->setPageOrientation(
'', 1, $heightforfooter);
436 pdf_writelinedesc($pdf, $object, $i, $outputlangs, $this->posxtva - $curX, 4, $curX, $curY, $hideref, $hidedesc);
437 $pageposafter = $pdf->getPage();
438 $posyafter = $pdf->GetY();
439 if ($posyafter > ($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)))
441 if ($i == ($nblines - 1))
443 $pdf->AddPage(
'',
'',
true);
444 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
445 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
446 $pdf->setPage($pageposafter + 1);
451 if (!empty($conf->global->MAIN_PDF_DATA_ON_FIRST_PAGE))
452 $showpricebeforepagebreak = 1;
453 else $showpricebeforepagebreak = 0;
457 $pdf->commitTransaction();
459 $posYAfterDescription = $pdf->GetY();
461 $nexY = $pdf->GetY();
462 $pageposafter = $pdf->getPage();
464 $pdf->setPage($pageposbefore);
465 $pdf->setTopMargin($this->marge_haute);
466 $pdf->setPageOrientation(
'', 1, 0);
469 if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
470 $pdf->setPage($pageposafter); $curY = $tab_top_newpage;
473 $pdf->SetFont(
'',
'', $default_font_size - 1);
476 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
479 $pdf->SetXY($this->posxtva - 5, $curY);
480 $pdf->MultiCell($this->posxup - $this->posxtva + 4, 3, $vat_rate, 0,
'R');
485 $pdf->SetXY($this->posxup, $curY);
486 $pdf->MultiCell($this->posxqty - $this->posxup - 0.8, 3, $up_excl_tax, 0,
'R', 0);
490 $pdf->SetXY($this->posxqty, $curY);
491 $pdf->MultiCell($this->posxunit - $this->posxqty - 0.8, 4, $qty, 0,
'R');
494 if (!empty($conf->global->PRODUCT_USE_UNITS))
496 $unit =
pdf_getlineunit($object, $i, $outputlangs, $hidedetails, $hookmanager);
497 $pdf->SetXY($this->posxunit, $curY);
498 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 0.8, 4, $unit, 0,
'L');
502 $pdf->SetXY($this->posxdiscount, $curY);
503 if ($object->lines[$i]->remise_percent)
505 $pdf->SetXY($this->posxdiscount - 2, $curY);
507 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 2, 3, $remise_percent, 0,
'R');
512 $pdf->SetXY($this->postotalht, $curY);
513 $pdf->MultiCell($this->page_largeur - $this->marge_droite - $this->postotalht, 3, $total_excl_tax, 0,
'R', 0);
516 if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) $tvaligne = $object->lines[$i]->multicurrency_total_tva;
517 else $tvaligne = $object->lines[$i]->total_tva;
519 $localtax1ligne = $object->lines[$i]->total_localtax1;
520 $localtax2ligne = $object->lines[$i]->total_localtax2;
521 $localtax1_rate = $object->lines[$i]->localtax1_tx;
522 $localtax2_rate = $object->lines[$i]->localtax2_tx;
523 $localtax1_type = $object->lines[$i]->localtax1_type;
524 $localtax2_type = $object->lines[$i]->localtax2_type;
526 if ($object->remise_percent) $tvaligne -= ($tvaligne * $object->remise_percent) / 100;
527 if ($object->remise_percent) $localtax1ligne -= ($localtax1ligne * $object->remise_percent) / 100;
528 if ($object->remise_percent) $localtax2ligne -= ($localtax2ligne * $object->remise_percent) / 100;
530 $vatrate = (string) $object->lines[$i]->tva_tx;
533 if ((!isset($localtax1_type) || $localtax1_type ==
'' || !isset($localtax2_type) || $localtax2_type ==
'')
534 && (!empty($localtax1_rate) || !empty($localtax2_rate)))
537 $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] :
'';
538 $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] :
'';
542 if ($localtax1_type && $localtax1ligne != 0)
543 $this->localtax1[$localtax1_type][$localtax1_rate] += $localtax1ligne;
544 if ($localtax2_type && $localtax2ligne != 0)
545 $this->localtax2[$localtax2_type][$localtax2_rate] += $localtax2ligne;
547 if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate .=
'*';
548 if (!isset($this->tva[$vatrate])) $this->tva[$vatrate] = 0;
549 $this->tva[$vatrate] += $tvaligne;
552 if (!empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblines - 1))
554 $pdf->setPage($pageposafter);
555 $pdf->SetLineStyle(array(
'dash'=>
'1,1',
'color'=>array(80, 80, 80)));
557 $pdf->line($this->marge_gauche, $nexY + 1, $this->page_largeur - $this->marge_droite, $nexY + 1);
558 $pdf->SetLineStyle(array(
'dash'=>0));
564 while ($pagenb < $pageposafter)
566 $pdf->setPage($pagenb);
569 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
571 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
573 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
575 $pdf->setPage($pagenb);
576 $pdf->setPageOrientation(
'', 1, 0);
577 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
579 if (isset($object->lines[$i + 1]->pagebreak) && $object->lines[$i + 1]->pagebreak)
583 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
585 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code);
587 $this->
_pagefoot($pdf, $object, $outputlangs, 1);
590 if (!empty($tplidx)) $pdf->useTemplate($tplidx);
592 if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->
_pagehead($pdf, $object, 0, $outputlangs);
598 $this->
_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
600 $this->
_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code);
602 $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1;
605 $posy = $this->
_tableau_info($pdf, $object, $bottomlasttab, $outputlangs);
608 $posy = $this->
_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs);
619 $this->
_pagefoot($pdf, $object, $outputlangs);
620 if (method_exists($pdf,
'AliasNbPages')) $pdf->AliasNbPages();
624 $pdf->Output($file,
'F');
627 $hookmanager->initHooks(array(
'pdfgeneration'));
628 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
630 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
633 $this->error = $hookmanager->error;
634 $this->errors = $hookmanager->errors;
637 if (!empty($conf->global->MAIN_UMASK))
638 @chmod($file, octdec($conf->global->MAIN_UMASK));
640 $this->result = array(
'fullpath'=>$file);
644 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
648 $this->error = $langs->transnoentities(
"ErrorConstantNotDefined",
"COMMANDE_OUTPUTDIR");
683 global $conf, $mysoc;
686 $pdf->SetFont(
'',
'', $default_font_size - 1);
689 if ($this->emetteur->country_code ==
'FR' && empty($mysoc->tva_assuj))
691 $pdf->SetFont(
'',
'B', $default_font_size - 2);
692 $pdf->SetXY($this->marge_gauche, $posy);
693 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"VATIsNotUsedForInvoice"), 0,
'L', 0);
695 $posy = $pdf->GetY() + 4;
701 if ($object->cond_reglement_code || $object->cond_reglement)
703 $pdf->SetFont(
'',
'B', $default_font_size - 2);
704 $pdf->SetXY($this->marge_gauche, $posy);
705 $titre = $outputlangs->transnoentities(
"PaymentConditions").
':';
706 $pdf->MultiCell(43, 4, $titre, 0,
'L');
708 $pdf->SetFont(
'',
'', $default_font_size - 2);
709 $pdf->SetXY($posxval, $posy);
710 $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);
711 $lib_condition_paiement = str_replace(
'\n',
"\n", $lib_condition_paiement);
712 $pdf->MultiCell(67, 4, $lib_condition_paiement, 0,
'L');
714 $posy = $pdf->GetY() + 3;
745 if (!empty($object->delivery_date))
747 $outputlangs->load(
"sendings");
748 $pdf->SetFont(
'',
'B', $default_font_size - 2);
749 $pdf->SetXY($this->marge_gauche, $posy);
750 $titre = $outputlangs->transnoentities(
"DateDeliveryPlanned").
':';
751 $pdf->MultiCell(80, 4, $titre, 0,
'L');
752 $pdf->SetFont(
'',
'', $default_font_size - 2);
753 $pdf->SetXY($posxval, $posy);
754 $dlp =
dol_print_date($object->delivery_date,
"daytext",
false, $outputlangs,
true);
755 $pdf->MultiCell(80, 4, $dlp, 0,
'L');
757 $posy = $pdf->GetY() + 1;
758 } elseif ($object->availability_code || $object->availability) {
760 $pdf->SetFont(
'',
'B', $default_font_size - 2);
761 $pdf->SetXY($this->marge_gauche, $posy);
762 $titre = $outputlangs->transnoentities(
"AvailabilityPeriod").
':';
763 $pdf->MultiCell(80, 4, $titre, 0,
'L');
764 $pdf->SetTextColor(0, 0, 0);
765 $pdf->SetFont(
'',
'', $default_font_size - 2);
766 $pdf->SetXY($posxval, $posy);
767 $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 :
'');
768 $lib_availability = str_replace(
'\n',
"\n", $lib_availability);
769 $pdf->MultiCell(80, 4, $lib_availability, 0,
'L');
771 $posy = $pdf->GetY() + 1;
775 if ($object->mode_reglement_code
776 && $object->mode_reglement_code !=
'CHQ'
777 && $object->mode_reglement_code !=
'VIR') {
778 $pdf->SetFont(
'',
'B', $default_font_size - 2);
779 $pdf->SetXY($this->marge_gauche, $posy);
780 $titre = $outputlangs->transnoentities(
"PaymentMode").
':';
781 $pdf->MultiCell(80, 5, $titre, 0,
'L');
783 $pdf->SetFont(
'',
'', $default_font_size - 2);
784 $pdf->SetXY($posxval, $posy);
785 $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);
786 $pdf->MultiCell(80, 5, $lib_mode_reg, 0,
'L');
788 $posy = $pdf->GetY() + 2;
792 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'CHQ')
795 if (!empty($conf->global->FACTURE_CHQ_NUMBER))
797 $diffsizetitle = (empty($conf->global->PDF_DIFFSIZE_TITLE) ? 3 : $conf->global->PDF_DIFFSIZE_TITLE);
799 if ($conf->global->FACTURE_CHQ_NUMBER > 0)
802 $account->fetch($conf->global->FACTURE_CHQ_NUMBER);
804 $pdf->SetXY($this->marge_gauche, $posy);
805 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
806 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $account->proprio), 0,
'L', 0);
807 $posy = $pdf->GetY() + 1;
809 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
811 $pdf->SetXY($this->marge_gauche, $posy);
812 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
813 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($account->owner_address), 0,
'L', 0);
814 $posy = $pdf->GetY() + 2;
817 if ($conf->global->FACTURE_CHQ_NUMBER == -1)
819 $pdf->SetXY($this->marge_gauche, $posy);
820 $pdf->SetFont(
'',
'B', $default_font_size - $diffsizetitle);
821 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
'PaymentByChequeOrderedTo', $this->emetteur->name), 0,
'L', 0);
822 $posy = $pdf->GetY() + 1;
824 if (empty($conf->global->MAIN_PDF_HIDE_CHQ_ADDRESS))
826 $pdf->SetXY($this->marge_gauche, $posy);
827 $pdf->SetFont(
'',
'', $default_font_size - $diffsizetitle);
828 $pdf->MultiCell(100, 3, $outputlangs->convToOutputCharset($this->emetteur->getFullAddress()), 0,
'L', 0);
829 $posy = $pdf->GetY() + 2;
836 if (empty($object->mode_reglement_code) || $object->mode_reglement_code ==
'VIR')
838 if ($object->fk_account > 0 || $object->fk_bank > 0 || !empty($conf->global->FACTURE_RIB_NUMBER))
840 $bankid = ($object->fk_account <= 0 ? $conf->global->FACTURE_RIB_NUMBER : $object->fk_account);
841 if ($object->fk_bank > 0) $bankid = $object->fk_bank;
843 $account->fetch($bankid);
845 $curx = $this->marge_gauche;
848 $posy =
pdf_bank($pdf, $outputlangs, $curx, $cury, $account, 0, $default_font_size);
869 protected function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
872 global $conf, $mysoc, $hookmanager;
876 $outputlangsbis = null;
877 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && $outputlangs->defaultlang != $conf->global->PDF_USE_ALSO_LANGUAGE_CODE) {
878 $outputlangsbis =
new Translate(
'', $conf);
879 $outputlangsbis->setDefaultLang($conf->global->PDF_USE_ALSO_LANGUAGE_CODE);
880 $outputlangsbis->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"propal"));
881 $default_font_size--;
886 $pdf->SetFont(
'',
'', $default_font_size - 1);
889 $col1x = 120; $col2x = 170;
890 if ($this->page_largeur < 210)
894 $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x);
900 $pdf->SetFillColor(255, 255, 255);
901 $pdf->SetXY($col1x, $tab2_top + 0);
902 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalHT").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"TotalHT") :
''), 0,
'L', 1);
904 $total_ht = ((!empty($conf->multicurrency->enabled) && isset($object->multicurrency_tx) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ht : $object->total_ht);
905 $pdf->SetXY($col2x, $tab2_top + 0);
906 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ht + (!empty($object->remise) ? $object->remise : 0), 0, $outputlangs), 0,
'R', 1);
909 $pdf->SetFillColor(248, 248, 248);
911 $total_ttc = (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) ? $object->multicurrency_total_ttc : $object->total_ttc;
913 $this->atleastoneratenotnull = 0;
914 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))
916 $tvaisnull = ((!empty($this->tva) && count($this->tva) == 1 && isset($this->tva[
'0.000']) && is_float($this->tva[
'0.000'])) ?
true :
false);
917 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull)
924 foreach ($this->localtax1 as $localtax_type => $localtax_rate)
926 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5')))
continue;
927 foreach ($localtax_rate as $tvakey => $tvaval)
934 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
937 if (preg_match(
'/\*/', $tvakey))
939 $tvakey = str_replace(
'*',
'', $tvakey);
940 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
942 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
944 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
945 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
947 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
948 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
956 foreach ($this->localtax2 as $localtax_type => $localtax_rate)
958 if (in_array((
string) $localtax_type, array(
'1',
'3',
'5')))
continue;
959 foreach ($localtax_rate as $tvakey => $tvaval)
966 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
969 if (preg_match(
'/\*/', $tvakey))
971 $tvakey = str_replace(
'*',
'', $tvakey);
972 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
974 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
976 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
977 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
979 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
980 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
986 foreach ($this->tva as $tvakey => $tvaval)
990 $this->atleastoneratenotnull++;
993 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
996 if (preg_match(
'/\*/', $tvakey))
998 $tvakey = str_replace(
'*',
'', $tvakey);
999 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1001 $totalvat = $outputlangs->transcountrynoentities(
"TotalVAT", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalVAT", $mysoc->country_code) :
'');
1003 $totalvat .=
vatrate($tvakey, 1).$tvacompl;
1004 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1006 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1007 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1014 foreach ($this->localtax1 as $localtax_type => $localtax_rate)
1016 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6')))
continue;
1018 foreach ($localtax_rate as $tvakey => $tvaval)
1025 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1028 if (preg_match(
'/\*/', $tvakey))
1030 $tvakey = str_replace(
'*',
'', $tvakey);
1031 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1033 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT1", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT1", $mysoc->country_code) :
'');
1036 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1037 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0,
'L', 1);
1038 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1039 $pdf->MultiCell($largcol2, $tab2_hl,
price($tvaval, 0, $outputlangs), 0,
'R', 1);
1047 foreach ($this->localtax2 as $localtax_type => $localtax_rate)
1049 if (in_array((
string) $localtax_type, array(
'2',
'4',
'6')))
continue;
1051 foreach ($localtax_rate as $tvakey => $tvaval)
1059 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1062 if (preg_match(
'/\*/', $tvakey))
1064 $tvakey = str_replace(
'*',
'', $tvakey);
1065 $tvacompl =
" (".$outputlangs->transnoentities(
"NonPercuRecuperable").
")";
1067 $totalvat = $outputlangs->transcountrynoentities(
"TotalLT2", $mysoc->country_code).(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalLT2", $mysoc->country_code) :
'');
1070 $totalvat .=
vatrate(abs($tvakey), 1).$tvacompl;
1071 $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 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1083 $pdf->SetTextColor(0, 0, 60);
1084 $pdf->SetFillColor(224, 224, 224);
1085 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"TotalTTC").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transcountrynoentities(
"TotalTTC", $mysoc->country_code) :
''), $useborder,
'L', 1);
1087 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1088 $pdf->MultiCell($largcol2, $tab2_hl,
price($total_ttc, 0, $outputlangs), $useborder,
'R', 1);
1092 $pdf->SetTextColor(0, 0, 0);
1094 $creditnoteamount = 0;
1095 $depositsamount = 0;
1099 $resteapayer =
price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount,
'MT');
1100 if (!empty($object->paye)) $resteapayer = 0;
1102 if ($deja_regle > 0)
1107 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1108 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"AlreadyPaid").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), 0,
'L', 0);
1109 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1110 $pdf->MultiCell($largcol2, $tab2_hl,
price($deja_regle, 0, $outputlangs), 0,
'R', 0);
1113 $pdf->SetTextColor(0, 0, 60);
1114 $pdf->SetFillColor(224, 224, 224);
1115 $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1116 $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities(
"RemainderToPay").(is_object($outputlangsbis) ?
' / '.$outputlangsbis->transnoentities(
"AlreadyPaid") :
''), $useborder,
'L', 1);
1118 $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1119 $pdf->MultiCell($largcol2, $tab2_hl,
price($resteapayer, 0, $outputlangs), $useborder,
'R', 1);
1121 $pdf->SetFont(
'',
'', $default_font_size - 1);
1122 $pdf->SetTextColor(0, 0, 0);
1126 return ($tab2_top + ($tab2_hl * $index));
1144 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'', $outputlangsbis = null)
1150 if ($hidetop) $hidetop = -1;
1152 $currency = !empty($currency) ? $currency : $conf->currency;
1156 $pdf->SetTextColor(0, 0, 0);
1157 $pdf->SetFont(
'',
'', $default_font_size - 2);
1159 if (empty($hidetop))
1161 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
1162 if (!empty($conf->global->PDF_USE_ALSO_LANGUAGE_CODE) && is_object($outputlangsbis)) {
1163 $titre .=
' - '.$outputlangsbis->transnoentities(
"AmountInCurrency", $outputlangsbis->transnoentitiesnoconv(
"Currency".$currency));
1166 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
1167 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1170 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $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));
1173 $pdf->SetDrawColor(128, 128, 128);
1174 $pdf->SetFont(
'',
'', $default_font_size - 1);
1177 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
1179 if (empty($hidetop))
1181 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
1183 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
1184 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
1187 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
1189 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
1190 if (empty($hidetop))
1192 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
1193 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
1197 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
1198 if (empty($hidetop))
1200 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
1201 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
1204 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
1205 if (empty($hidetop))
1207 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
1208 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
1211 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1212 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
1213 if (empty($hidetop)) {
1214 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
1215 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
1219 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
1220 if (empty($hidetop))
1222 if ($this->atleastonediscount)
1224 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
1225 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
1229 if ($this->atleastonediscount)
1231 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
1233 if (empty($hidetop))
1235 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
1236 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
1253 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis = null, $titlekey =
"PdfOrderTitle")
1256 global $conf, $langs, $hookmanager;
1259 $outputlangs->loadLangs(array(
"main",
"bills",
"propal",
"orders",
"companies"));
1266 if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK)))
1268 pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur,
'mm', $conf->global->COMMANDE_DRAFT_WATERMARK);
1271 $pdf->SetTextColor(0, 0, 60);
1272 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1276 $posy = $this->marge_haute;
1277 $posx = $this->page_largeur - $this->marge_droite - $w;
1279 $pdf->SetXY($this->marge_gauche, $posy);
1282 if (empty($conf->global->PDF_DISABLE_MYCOMPANY_LOGO))
1284 if ($this->emetteur->logo)
1286 $logodir = $conf->mycompany->dir_output;
1287 if (!empty($conf->mycompany->multidir_output[$object->entity])) $logodir = $conf->mycompany->multidir_output[$object->entity];
1288 if (empty($conf->global->MAIN_PDF_USE_LARGE_LOGO))
1290 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
1292 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
1294 if (is_readable($logo))
1297 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
1299 $pdf->SetTextColor(200, 0, 0);
1300 $pdf->SetFont(
'',
'B', $default_font_size - 2);
1301 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
1302 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
1305 $text = $this->emetteur->name;
1306 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
1310 $pdf->SetFont(
'',
'B', $default_font_size + 3);
1311 $pdf->SetXY($posx, $posy);
1312 $pdf->SetTextColor(0, 0, 60);
1313 $title = $outputlangs->transnoentities($titlekey);
1314 $pdf->MultiCell($w, 3, $title,
'',
'R');
1316 $pdf->SetFont(
'',
'B', $default_font_size);
1319 $pdf->SetXY($posx, $posy);
1320 $pdf->SetTextColor(0, 0, 60);
1321 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset($object->ref),
'',
'R');
1324 $pdf->SetFont(
'',
'', $default_font_size - 1);
1326 if ($object->ref_client)
1329 $pdf->SetXY($posx, $posy);
1330 $pdf->SetTextColor(0, 0, 60);
1331 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefCustomer").
" : ".$outputlangs->convToOutputCharset($object->ref_client),
'',
'R');
1334 if (!empty($conf->global->PDF_SHOW_PROJECT_TITLE))
1336 $object->fetch_projet();
1337 if (!empty($object->project->ref))
1340 $pdf->SetXY($posx, $posy);
1341 $pdf->SetTextColor(0, 0, 60);
1342 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"Project").
" : ".(empty($object->project->title) ?
'' : $object->projet->title),
'',
'R');
1346 if (!empty($conf->global->PDF_SHOW_PROJECT))
1348 $object->fetch_projet();
1349 if (!empty($object->project->ref))
1352 $pdf->SetXY($posx, $posy);
1353 $pdf->SetTextColor(0, 0, 60);
1354 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"RefProject").
" : ".(empty($object->project->ref) ?
'' : $object->projet->ref),
'',
'R');
1359 $pdf->SetXY($posx, $posy);
1360 $pdf->SetTextColor(0, 0, 60);
1361 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"OrderDate").
" : ".
dol_print_date($object->date,
"day",
false, $outputlangs,
true),
'',
'R');
1363 if (!empty($conf->global->DOC_SHOW_CUSTOMER_CODE) && !empty($object->thirdparty->code_client))
1366 $pdf->SetXY($posx, $posy);
1367 $pdf->SetTextColor(0, 0, 60);
1368 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"CustomerCode").
" : ".$outputlangs->transnoentities($object->thirdparty->code_client),
'',
'R');
1372 if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP))
1374 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1375 if (count($arrayidcontact) > 0)
1377 $usertmp =
new User($this->
db);
1378 $usertmp->fetch($arrayidcontact[0]);
1380 $pdf->SetXY($posx, $posy);
1381 $pdf->SetTextColor(0, 0, 60);
1382 $pdf->MultiCell($w, 3, $langs->transnoentities(
"SalesRepresentative").
" : ".$usertmp->getFullName($langs),
'',
'R');
1390 $current_y = $pdf->getY();
1391 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, $w, 3,
'R', $default_font_size);
1392 if ($current_y < $pdf->getY())
1394 $top_shift = $pdf->getY() - $current_y;
1400 $carac_emetteur =
'';
1402 $arrayidcontact = $object->getIdContact(
'internal',
'SALESREPFOLL');
1403 if (count($arrayidcontact) > 0)
1405 $object->fetch_user($arrayidcontact[0]);
1406 $labelbeforecontactname = ($outputlangs->transnoentities(
"FromContactName") !=
'FromContactName' ? $outputlangs->transnoentities(
"FromContactName") : $outputlangs->transnoentities(
"Name"));
1407 $carac_emetteur .= ($carac_emetteur ?
"\n" :
'').$labelbeforecontactname.
" ".$outputlangs->convToOutputCharset($object->user->getFullName($outputlangs)).
"\n";
1410 $carac_emetteur .=
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty,
'', 0,
'source', $object);
1413 $posy = 42 + $top_shift;
1414 $posx = $this->marge_gauche;
1415 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->page_largeur - $this->marge_droite - 80;
1419 $pdf->SetTextColor(0, 0, 0);
1420 $pdf->SetFont(
'',
'', $default_font_size - 2);
1421 $pdf->SetXY($posx, $posy - 5);
1422 $pdf->MultiCell(66, 5, $outputlangs->transnoentities(
"BillFrom").
":", 0,
'L');
1423 $pdf->SetXY($posx, $posy);
1424 $pdf->SetFillColor(230, 230, 230);
1425 $pdf->MultiCell(82, $hautcadre,
"", 0,
'R', 1);
1426 $pdf->SetTextColor(0, 0, 60);
1429 $pdf->SetXY($posx + 2, $posy + 3);
1430 $pdf->SetFont(
'',
'B', $default_font_size);
1431 $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->name), 0,
'L');
1432 $posy = $pdf->getY();
1435 $pdf->SetXY($posx + 2, $posy);
1436 $pdf->SetFont(
'',
'', $default_font_size - 1);
1437 $pdf->MultiCell(80, 4, $carac_emetteur, 0,
'L');
1441 $usecontact =
false;
1442 $arrayidcontact = $object->getIdContact(
'external',
'CUSTOMER');
1443 if (count($arrayidcontact) > 0)
1446 $result = $object->fetch_contact($arrayidcontact[0]);
1450 if ($usecontact && ($object->contact->fk_soc != $object->thirdparty->id && (!isset($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT) || !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)))) {
1451 $thirdparty = $object->contact;
1453 $thirdparty = $object->thirdparty;
1458 $carac_client =
pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ($usecontact ? $object->contact :
''), $usecontact,
'target', $object);
1461 $widthrecbox = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 92 : 100;
1462 if ($this->page_largeur < 210) $widthrecbox = 84;
1463 $posy = !empty($conf->global->MAIN_PDF_USE_ISO_LOCATION) ? 40 : 42;
1464 $posy += $top_shift;
1465 $posx = $this->page_largeur - $this->marge_droite - $widthrecbox;
1466 if (!empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx = $this->marge_gauche;
1469 $pdf->SetTextColor(0, 0, 0);
1470 $pdf->SetFont(
'',
'', $default_font_size - 2);
1471 $pdf->SetXY($posx + 2, $posy - 5);
1472 $pdf->MultiCell($widthrecbox, 5, $outputlangs->transnoentities(
"BillTo").
":", 0,
'L');
1473 $pdf->Rect($posx, $posy, $widthrecbox, $hautcadre);
1476 $pdf->SetXY($posx + 2, $posy + 3);
1477 $pdf->SetFont(
'',
'B', $default_font_size);
1478 $pdf->MultiCell($widthrecbox, 2, $carac_client_name, 0,
'L');
1480 $posy = $pdf->getY();
1483 $pdf->SetFont(
'',
'', $default_font_size - 1);
1484 $pdf->SetXY($posx + 2, $posy);
1485 $pdf->MultiCell($widthrecbox, 4, $carac_client, 0,
'L');
1488 $pdf->SetTextColor(0, 0, 0);
1503 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
1507 $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS;
1508 return pdf_pagefoot($pdf, $outputlangs,
'ORDER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
pdf_getFormat(Translate $outputlangs=null, $mode= 'setup')
Return array with format properties of default PDF format.
pdf_bank(&$pdf, $outputlangs, $curx, $cury, $account, $onlynumber=0, $default_font_size=10)
Show bank informations for PDF generation.
pdfBuildThirdpartyName($thirdparty, Translate $outputlangs, $includealias=0)
Returns the name of the thirdparty.
pdf_pagehead(&$pdf, $outputlangs, $page_height)
Show header of page for PDF generation.
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
</td > param sortfield sortorder printFieldListOption< tdclass="liste_titremaxwidthsearchright"></td ></tr >< trclass="liste_titre">< inputtype="checkbox"onClick="toggle(this)"/> Ref p ref Label p label Duration p duration center DesiredStock p desiredstock right StockLimitShort p seuil_stock_alerte right stock_physique right stock_real_warehouse right Ordered right StockToBuy right SupplierRef right param sortfield sortorder printFieldListTitle warehouseinternal SELECT description FROM product_lang WHERE qty< br > qty qty qty StockTooLow StockTooLow help help help< trclass="oddeven">< td >< inputtype="checkbox"class="check"name="choose'.$i.'"></td >< tdclass="nowrap"> stock</td >< td >< inputtype="hidden"name="desc'.$i.'"value="'.dol_escape_htmltag($objp-> description
Only used if Module[ID]Desc translation string is not found.
pdf_getPDFFontSize($outputlangs)
Return font size to use for PDF generation.
Class to manage Dolibarr users.
_tableau_info(&$pdf, $object, $posy, $outputlangs)
Show miscellaneous information (payment mode, payment term, ...)
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...
Class to generate PDF orders with template Einstein.
pdf_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_getlineunit($object, $i, $outputlangs, $hidedetails=0, $hookmanager=false)
Return line unit.
$conf db name
Only used if Module[ID]Name translation string is not found.
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...
$conf db
API class for accounts.
Class to manage bank accounts.
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...
pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line total excluding tax.
pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails=0)
Return line vat rate.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency= '', $outputlangsbis=null)
Show table for lines.
pdf_getlineqty($object, $i, $outputlangs, $hidedetails=0)
Return line quantity.
__construct($db)
Constructor.
pdf_pagefoot(&$pdf, $outputlangs, $paramfreetext, $fromcompany, $marge_basse, $marge_gauche, $page_hauteur, $object, $showdetails=0, $hidefreetext=0)
Show footer of page for PDF generation.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails=0)
Return line unit price excluding tax.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $outputlangsbis=null, $titlekey="PdfOrderTitle")
Show top header of page.
Class to manage translations.
dol_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails=0)
Return line remise percent.
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
pdf_getHeightForLogo($logo, $url=false)
Return height to use for Logo onto PDF.
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)
Return a string with VAT rate label formated for view output Used into pdf and HTML pages...
pdf_writeLinkedObjects(&$pdf, $object, $outputlangs, $posx, $posy, $w, $h, $align, $default_font_size)
Show linked objects for PDF generation.
pdf_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0)
Return array of possible substitutions for PDF content (without external module substitutions).
pdf_getInstance($format= '', $metric= 'mm', $pagetype= 'P')
Return a PDF instance object.
pdf_build_address($outputlangs, $sourcecompany, $targetcompany= '', $targetcontact= '', $usecontact=0, $mode= 'source', $object=null)
Return a string with full address formated for output on documents.
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
pdf_writelinedesc(&$pdf, $object, $i, $outputlangs, $w, $h, $posx, $posy, $hideref=0, $hidedesc=0, $issupplierline=0)
Output line description into PDF.
write_file($object, $outputlangs, $srctemplatepath= '', $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build pdf onto disk.
make_substitutions($text, $substitutionarray, $outputlangs=null)
Make substitution into a text string, replacing keys with vals from $substitutionarray (oldval=>newva...
_tableau_versements(&$pdf, $object, $posy, $outputlangs)
Show payments table.
getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
Get type and rate of localtaxes for a particular vat rate/country of a thirdparty.
_tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs)
Show total to pay.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type
Parent class for orders models.
dol_mkdir($dir, $dataroot= '', $newmask=null)
Creation of a directory (this can create recursive subdir)
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...