27require_once DOL_DOCUMENT_ROOT.
'/core/modules/product/modules_product.class.php';
28require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
29require_once DOL_DOCUMENT_ROOT.
'/fourn/class/fournisseur.product.class.php';
30require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/files.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/core/lib/pdf.lib.php';
65 public $version =
'dolibarr';
75 global $langs, $mysoc;
78 $langs->loadLangs(array(
"main",
"companies"));
81 $this->
name =
"standard";
82 $this->
description = $langs->trans(
"DocumentModelStandardPDF");
87 $this->page_largeur = $formatarray[
'width'];
88 $this->page_hauteur = $formatarray[
'height'];
89 $this->format = array($this->page_largeur, $this->page_hauteur);
95 $this->option_logo = 1;
96 $this->option_multilang = 1;
97 $this->option_freetext = 0;
100 $this->emetteur = $mysoc;
101 if (!$this->emetteur->country_code) {
102 $this->emetteur->country_code = substr($langs->defaultlang, -2);
119 public function write_file(
$object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0)
122 global $user, $langs, $conf, $mysoc, $db, $hookmanager;
124 if (!is_object($outputlangs)) {
125 $outputlangs = $langs;
129 $outputlangs->charset_output =
'ISO-8859-1';
133 $outputlangs->loadLangs(array(
"main",
"dict",
"companies",
"bills",
"products",
"orders",
"deliveries"));
135 if (is_array(
$object->lines)) {
136 $nblines = count(
$object->lines);
141 if ($conf->product->dir_output) {
144 $dir = $conf->product->dir_output;
145 $file = $dir.
"/SPECIMEN.pdf";
148 $dir = $conf->product->dir_output.
"/".$objectref;
149 $file = $dir.
"/".$objectref.
".pdf";
153 $supplierprices = $productFournisseur->list_product_fournisseur_price(
$object->id);
154 $object->supplierprices = $supplierprices;
156 if (!file_exists($dir)) {
158 $this->error = $langs->transnoentities(
"ErrorCanNotCreateDir", $dir);
163 if (file_exists($dir)) {
165 if (!is_object($hookmanager)) {
166 include_once DOL_DOCUMENT_ROOT.
'/core/class/hookmanager.class.php';
169 $hookmanager->initHooks(array(
'pdfgeneration'));
170 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
172 $reshook = $hookmanager->executeHooks(
'beforePDFCreation', $parameters,
$object, $action);
177 $pdf->SetAutoPageBreak(1, 0);
179 $heightforinfotot = 40;
180 $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5);
181 $heightforfooter = $this->marge_basse + 8;
183 $heightforfooter += 6;
186 if (class_exists(
'TCPDF')) {
187 $pdf->setPrintHeader(
false);
188 $pdf->setPrintFooter(
false);
193 $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.
'/' .
getDolGlobalString(
'MAIN_ADD_PDF_BACKGROUND'));
194 $tplidx = $pdf->importPage(1);
199 $pdf->SetDrawColor(128, 128, 128);
201 $pdf->SetTitle($outputlangs->convToOutputCharset(
$object->ref));
202 $pdf->SetSubject($outputlangs->transnoentities(
"Product"));
203 $pdf->SetCreator(
"Dolibarr ".DOL_VERSION);
204 $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
205 $pdf->SetKeyWords($outputlangs->convToOutputCharset(
$object->ref).
" ".$outputlangs->transnoentities(
"Product"));
207 $pdf->SetCompression(
false);
211 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite);
216 if (!empty($tplidx)) {
217 $pdf->useTemplate($tplidx);
221 $pdf->SetFont(
'',
'', $default_font_size - 1);
222 $pdf->MultiCell(0, 3,
'');
223 $pdf->SetTextColor(0, 0, 0);
227 $tab_top_newpage = (!
getDolGlobalInt(
'MAIN_PDF_DONOTREPEAT_HEAD') ? 42 : 10);
229 $tab_height = $this->page_hauteur - $tab_top - $heightforfooter - $heightforfreetext;
232 $pdf->SetFont(
'',
'B', $default_font_size);
234 $nexY = $pdf->GetY();
247 foreach ($pdir as $midir) {
249 if ($conf->entity !=
$object->entity) {
250 $dir = $conf->product->multidir_output[
$object->entity].
'/'.$midir;
252 $dir = $conf->product->dir_output.
'/'.$midir;
254 foreach (
$object->liste_photos($dir, 1) as $key => $obj) {
256 if ($obj[
'photo_vignette']) {
257 $filename = $obj[
'photo_vignette'];
259 $filename = $obj[
'photo'];
262 $filename = $obj[
'photo'];
264 $realpath = $dir.$filename;
270 $imglinesize = array();
271 if (!empty($realpath) && $arephoto) {
273 $imgsizewidth = $imgsize[
'width'] + 20;
274 $imgsizeheight = $imgsize[
'height'] + 20;
276 $midelpage = ($this->page_largeur - $this->marge_gauche - $this->marge_droite) / 2;
277 $posxphoto = $midelpage + ($midelpage / 2) - ($imgsizewidth / 2);
278 $posyphoto = $tab_top - 1;
279 $pdf->Image($realpath, $posxphoto, $posyphoto, $imgsizewidth, $imgsizeheight,
'',
'',
'', 2, 300);
280 $nexyafterphoto = $tab_top + $imgsizeheight;
284 $pdf->SetFont(
'',
'', $default_font_size);
286 $nexY = $pdf->GetY();
290 $outputlangs->load(
"other");
293 if (isset(
$object->weight_units)) {
294 $texttoshow .=
' '.measuring_units_string(
$object->weight_units,
'weight', 0, 0, $outputlangs);
296 $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $texttoshow, 0, 1);
297 $nexY = $pdf->GetY();
300 $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 :
'?');
302 $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $texttoshow, 0, 1);
303 $nexY = $pdf->GetY();
308 $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $texttoshow, 0, 1);
309 $nexY = $pdf->GetY();
314 $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $texttoshow, 0, 1);
315 $nexY = $pdf->GetY();
319 if (!empty($nexyafterphoto) && $nexyafterphoto > $tab_top) {
320 $tab_top = $nexyafterphoto;
325 $notetoshow = empty(
$object->note_public) ?
'' :
$object->note_public;
332 $pdf->SetFont(
'',
'', $default_font_size - 1);
333 $pdf->writeHTMLCell(190, 3, $this->marge_gauche - 1, $tab_top,
dol_htmlentitiesbr($notetoshow), 0, 1);
334 $nexY = $pdf->GetY();
335 $height_note = $nexY - $tab_top;
338 $pdf->SetDrawColor(192, 192, 192);
339 $pdf->Rect($this->marge_gauche, $tab_top - 1, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $height_note + 1);
341 $tab_height = $tab_height - $height_note;
342 $tab_top = $nexY + 6;
347 $iniY = $tab_top + 7;
348 $curY = $tab_top + 7;
349 $nexY = $tab_top + 7;
567 if (method_exists($pdf,
'AliasNbPages')) {
568 $pdf->AliasNbPages();
573 $pdf->Output($file,
'F');
576 $hookmanager->initHooks(array(
'pdfgeneration'));
577 $parameters = array(
'file' => $file,
'object' =>
$object,
'outputlangs' => $outputlangs);
579 $reshook = $hookmanager->executeHooks(
'afterPDFCreation', $parameters, $this, $action);
581 $this->error = $hookmanager->error;
582 $this->errors = $hookmanager->errors;
587 $this->result = array(
'fullpath' => $file);
591 $this->error = $langs->trans(
"ErrorCanNotCreateDir", $dir);
595 $this->error = $langs->trans(
"ErrorConstantNotDefined",
"PRODUCT_OUTPUTDIR");
614 protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency =
'')
624 $currency = !empty($currency) ? $currency : $conf->currency;
628 $pdf->SetTextColor(0, 0, 0);
629 $pdf->SetFont(
'',
'', $default_font_size - 2);
631 if (empty($hidetop)) {
632 $titre = $outputlangs->transnoentities(
"AmountInCurrency", $outputlangs->transnoentitiesnoconv(
"Currency".$currency));
633 $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4);
634 $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
638 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_droite - $this->marge_gauche, 5,
'F',
null, explode(
',',
getDolGlobalString(
'MAIN_PDF_TITLE_BACKGROUND_COLOR')));
642 $pdf->SetDrawColor(128, 128, 128);
643 $pdf->SetFont(
'',
'', $default_font_size - 1);
646 $this->
printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom);
648 if (empty($hidetop)) {
649 $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5);
651 $pdf->SetXY($this->posxdesc - 1, $tab_top + 1);
652 $pdf->MultiCell(108, 2, $outputlangs->transnoentities(
"Designation"),
'',
'L');
656 $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height);
657 if (empty($hidetop)) {
658 $pdf->SetXY($this->posxtva - 3, $tab_top + 1);
659 $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities(
"VAT"),
'',
'C');
663 $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height);
664 if (empty($hidetop)) {
665 $pdf->SetXY($this->posxup - 1, $tab_top + 1);
666 $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities(
"PriceUHT"),
'',
'C');
669 $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height);
670 if (empty($hidetop)) {
671 $pdf->SetXY($this->posxqty - 1, $tab_top + 1);
672 $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities(
"Qty"),
'',
'C');
676 $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height);
677 if (empty($hidetop)) {
678 $pdf->SetXY($this->posxunit - 1, $tab_top + 1);
679 $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities(
"Unit"),
'',
'C');
683 $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height);
684 if (empty($hidetop)) {
685 if ($this->atleastonediscount) {
686 $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1);
687 $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities(
"ReductionShort"),
'',
'C');
691 if ($this->atleastonediscount) {
692 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
694 if (empty($hidetop)) {
695 $pdf->SetXY($this->postotalht - 1, $tab_top + 1);
696 $pdf->MultiCell(30, 2, $outputlangs->transnoentities(
"TotalHT"),
'',
'C');
716 if ($outputlangs->trans(
"DIRECTION") ==
'rtl') {
721 $outputlangs->loadLangs(array(
"main",
"propal",
"companies",
"bills",
"orders"));
726 $titlekey =
'ServiceSheet';
728 $titlekey =
'ProductSheet';
738 $pdf->SetTextColor(0, 0, 60);
739 $pdf->SetFont(
'',
'B', $default_font_size + 3);
743 $posy = $this->marge_haute;
744 $posx = $this->page_largeur - $this->marge_droite - 100;
746 $pdf->SetXY($this->marge_gauche, $posy);
750 if ($this->emetteur->logo) {
751 $logodir = $conf->mycompany->dir_output;
752 if (!empty($conf->mycompany->multidir_output[
$object->entity])) {
753 $logodir = $conf->mycompany->multidir_output[
$object->entity];
756 $logo = $logodir.
'/logos/thumbs/'.$this->emetteur->logo_small;
758 $logo = $logodir.
'/logos/'.$this->emetteur->logo;
760 if (is_readable($logo)) {
762 $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height);
764 $pdf->SetTextColor(200, 0, 0);
765 $pdf->SetFont(
'',
'B', $default_font_size - 2);
766 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorLogoFileNotFound", $logo), 0,
'L');
767 $pdf->MultiCell($w, 3, $outputlangs->transnoentities(
"ErrorGoToGlobalSetup"), 0,
'L');
770 $text = $this->emetteur->name;
771 $pdf->MultiCell($w, 4, $outputlangs->convToOutputCharset($text), 0, $ltrdirection);
776 $pdf->SetFont(
'',
'B', $default_font_size + 3);
777 $pdf->SetXY($posx, $posy);
778 $pdf->SetTextColor(0, 0, 60);
779 $title = $outputlangs->transnoentities($titlekey);
780 $pdf->MultiCell(100, 3, $title,
'',
'R');
782 $pdf->SetFont(
'',
'B', $default_font_size);
785 $pdf->SetXY($posx, $posy);
786 $pdf->SetTextColor(0, 0, 60);
787 $pdf->MultiCell(100, 4, $outputlangs->transnoentities(
"Ref").
" : ".$outputlangs->convToOutputCharset(
$object->ref),
'',
'R');
790 $pdf->SetFont(
'',
'', $default_font_size - 1);
861 $pdf->SetTextColor(0, 0, 0);
878 $showdetails =
getDolGlobalInt(
'MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS', 0);
879 return pdf_pagefoot($pdf, $outputlangs,
'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur,
$object, $showdetails, $hidefreetext);
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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 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 $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after 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...
dolChmod($filepath, $newmask='')
Change mod of a file.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
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...
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...
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_mkdir($dir, $dataroot='', $newmask='')
Creation of a directory (this can create recursive subdir)
pdf_getSizeForImage($realpath)
Return dimensions to use for images onto PDF checking that width and height are not higher than maxim...
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_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_getSubstitutionArray($outputlangs, $exclude=null, $object=null, $onlykey=0, $include=null)
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_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.