25 require_once DOL_DOCUMENT_ROOT.
'/core/modules/product/modules_product.class.php';
26 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
27 require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
28 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
63 public $phpmin = array(7, 0);
69 public $version =
'dolibarr';
85 global $conf, $langs, $mysoc;
88 $langs->loadLangs(array(
"main",
"companies"));
91 $this->
name =
"standard";
92 $this->
description = $langs->trans(
"DocumentModelStandardPDF");
97 $this->page_largeur = $formatarray[
'width'];
98 $this->page_hauteur = $formatarray[
'height'];
99 $this->format = array($this->page_largeur, $this->page_hauteur);
105 $this->option_logo = 1;
106 $this->option_multilang = 1;
107 $this->option_freetext = 0;
110 $this->emetteur = $mysoc;
111 if (!$this->emetteur->country_code) {
112 $this->emetteur->country_code = substr($langs->defaultlang, -2);
129 public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
132 global $user, $langs, $conf, $mysoc, $db, $hookmanager;
134 if (!is_object($outputlangs)) {
135 $outputlangs = $langs;
138 if (!empty($conf->global->MAIN_USE_FPDF)) {
139 $outputlangs->charset_output =
'ISO-8859-1';
143 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries"));
145 if (is_array($object->lines)) {
146 $nblines = count($object->lines);
151 if ($conf->product->dir_output) {
153 if ($object->specimen) {
154 $dir = $conf->product->dir_output;
155 $file = $dir.
"/SPECIMEN.pdf";
158 $dir = $conf->product->dir_output.
"/".$objectref;
159 $file = $dir.
"/".$objectref.
".pdf";
163 $supplierprices = $productFournisseur->list_product_fournisseur_price($object->id);
164 $object->supplierprices = $supplierprices;
166 if (!file_exists($dir)) {
168 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
173 if (file_exists($dir)) {
175 if (!is_object($hookmanager)) {
176 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
179 $hookmanager->initHooks(array(
'pdfgeneration'));
180 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
182 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters, $object, $action);
187 $pdf->SetAutoPageBreak(1, 0);
189 $heightforinfotot = 40;
190 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
191 $heightforfooter = $this->marge_basse + 8;
192 if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) {
193 $heightforfooter += 6;
196 if (class_exists(
'TCPDF')) {
197 $pdf->setPrintHeader(
false);
198 $pdf->setPrintFooter(
false);
202 if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) {
203 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
204 $tplidx = $pdf->importPage(1);
209 $pdf->SetDrawColor(128, 128, 128);
211 $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
212 $pdf->SetSubject($outputlangs->transnoentities(
"Order"));
213 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
214 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
215 $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref).
" ".$outputlangs->transnoentities(
"Order").
" ".$outputlangs->convToOutputCharset($object->thirdparty->name));
217 $pdf->SetCompression(
false);
220 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
225 if (!empty($tplidx)) {
226 $pdf->useTemplate($tplidx);
229 $this->
_pagehead($pdf, $object, 1, $outputlangs);
230 $pdf->SetFont(
'',
'', $default_font_size - 1);
231 $pdf->MultiCell(0, 3,
'');
232 $pdf->SetTextColor(0, 0, 0);
236 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
238 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
241 $pdf->SetFont(
'',
'B', $default_font_size);
242 $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $tab_top,
dol_htmlentitiesbr($object->label), 0, 1);
243 $nexY = $pdf->GetY();
245 $pdf->SetFont(
'',
'', $default_font_size);
246 $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY,
dol_htmlentitiesbr($object->description), 0, 1);
247 $nexY = $pdf->GetY();
251 $outputlangs->load(
"other");
252 if ($object->weight) {
254 if (isset($object->weight_units)) {
255 $texttoshow .=
' '.measuring_units_string($object->weight_units,
'weight', 0, 0, $outputlangs);
257 $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $texttoshow, 0, 1);
258 $nexY = $pdf->GetY();
260 if ($object->length) {
261 $texttoshow = $langs->trans(
"Length") .
' x ' . $langs->trans(
"Width") .
' x ' . $langs->trans(
"Height") .
': ' . ($object->length !=
'' ? $object->length :
'?') .
' x ' . ($object->width !=
'' ? $object->width :
'?') .
' x ' . ($object->height !=
'' ? $object->height :
'?');
263 $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $texttoshow, 0, 1);
264 $nexY = $pdf->GetY();
266 if ($object->surface) {
269 $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $texttoshow, 0, 1);
270 $nexY = $pdf->GetY();
272 if ($object->volume) {
275 $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $texttoshow, 0, 1);
276 $nexY = $pdf->GetY();
281 $notetoshow = empty($object->note_public) ?
'' : $object->note_public;
282 if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) {
284 if (is_object($object->thirdparty)) {
285 $salereparray = $object->thirdparty->getSalesRepresentatives($user);
286 $salerepobj =
new User($this->
db);
287 $salerepobj->fetch($salereparray[0][
'id']);
288 if (!empty($salerepobj->signature)) {
289 $notetoshow =
dol_concatdesc($notetoshow, $salerepobj->signature);
301 $pdf->SetFont(
'',
'', $default_font_size - 1);
302 $pdf->writeHTMLCell(190, 3, $this->posxdesc - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
303 $nexY = $pdf->GetY();
304 $height_note = $nexY - $tab_top;
307 $pdf->SetDrawColor(192, 192, 192);
308 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
310 $tab_height = $tab_height - $height_note;
311 $tab_top = $nexY + 6;
316 $iniY = $tab_top + 7;
317 $curY = $tab_top + 7;
318 $nexY = $tab_top + 7;
525 $this->
_pagefoot($pdf, $object, $outputlangs);
526 if (method_exists($pdf,
'AliasNbPages')) {
527 $pdf->AliasNbPages();
532 $pdf->Output($file,
'F');
535 $hookmanager->initHooks(array(
'pdfgeneration'));
536 $parameters = array(
'file'=>$file,
'object'=>$object,
'outputlangs'=>$outputlangs);
538 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
540 $this->error = $hookmanager->error;
541 $this->errors = $hookmanager->errors;
544 if (!empty($conf->global->MAIN_UMASK)) {
545 @chmod($file, octdec($conf->global->MAIN_UMASK));
548 $this->result = array(
'fullpath'=>$file);
552 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
556 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PRODUCT_OUTPUTDIR");
575 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
585 $currency = !empty($currency) ? $currency : $conf->currency;
589 $pdf->SetTextColor(0, 0, 0);
590 $pdf->SetFont(
'',
'', $default_font_size - 2);
592 if (empty($hidetop)) {
593 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
594 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
595 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
598 if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
599 $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));
603 $pdf->SetDrawColor(128, 128, 128);
604 $pdf->SetFont(
'',
'', $default_font_size - 1);
607 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
609 if (empty($hidetop)) {
610 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
612 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
613 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
616 if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) {
617 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
618 if (empty($hidetop)) {
619 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
620 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
624 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
625 if (empty($hidetop)) {
626 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
627 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
630 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
631 if (empty($hidetop)) {
632 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
633 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
636 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
637 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
638 if (empty($hidetop)) {
639 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
640 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
644 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
645 if (empty($hidetop)) {
646 if ($this->atleastonediscount) {
647 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
648 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
652 if ($this->atleastonediscount) {
653 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
655 if (empty($hidetop)) {
656 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
657 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
672 protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey =
"")
674 global $conf, $langs, $hookmanager;
677 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills",
"orders"));
681 if ($object->type == 1) {
682 $titlekey =
'ServiceSheet';
684 $titlekey =
'ProductSheet';
694 $pdf->SetTextColor(0, 0, 60);
695 $pdf->SetFont(
'',
'B', $default_font_size + 3);
697 $posy = $this->marge_haute;
698 $posx = $this->page_largeur - $this->marge_droite - 100;
700 $pdf->SetXY($this->marge_gauche, $posy);
703 $logo = $conf->mycompany->dir_output.
'/logos/'.$this->emetteur->logo;
704 if ($this->emetteur->logo) {
705 if (is_readable($logo)) {
707 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
709 $pdf->SetTextColor(200, 0, 0);
710 $pdf->SetFont(
'',
'B', $default_font_size - 2);
711 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
712 $pdf->MultiCell(100, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
715 $text = $this->emetteur->name;
716 $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0,
'L');
719 $pdf->SetFont(
'',
'B', $default_font_size + 3);
720 $pdf->SetXY($posx, $posy);
721 $pdf->SetTextColor(0, 0, 60);
722 $title = $outputlangs->transnoentities($titlekey);
723 $pdf->MultiCell(100, 3, $title,
'',
'R');
725 $pdf->SetFont(
'',
'B', $default_font_size);
728 $pdf->SetXY($posx, $posy);
729 $pdf->SetTextColor(0, 0, 60);
730 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset($object->ref),
'',
'R');
733 $pdf->SetFont(
'',
'', $default_font_size - 1);
768 $posy =
pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3,
'R', $default_font_size);
804 $pdf->SetTextColor(0, 0, 0);
817 protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0)
819 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
820 return pdf_pagefoot($pdf, $outputlangs,
'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext);
printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
Rect pdf.
Parent class to manage intervention document templates.
Class to manage predefined suppliers products.
Class to manage Dolibarr users.
Class to generate expense report based on standard model.
__construct($db)
Constructor.
_tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
Show table for lines.
write_file($object, $outputlangs, $srctemplatepath, $hidedetails=0, $hidedesc=0, $hideref=0)
Function to build a document on disk using the generic odt module.
_pagehead(&$pdf, $object, $showaddress, $outputlangs)
Show top header of page.
_pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey="")
Show top header of page.
_pagefoot(&$pdf, $object, $outputlangs, $hidefreetext=0)
Show footer of page.
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...
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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...
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
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_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_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_getPDFFont($outputlangs)
Return font name to use for PDF generation.
pdf_getInstance($format='', $metric='mm', $pagetype='P')
Return a PDF instance object.
pdf_watermark(&$pdf, $outputlangs, $h, $w, $unit, $text)
Add a draft watermark on PDF files.
measuringUnitString($unit, $measuring_style='', $scale='', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
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.