--- /tmp/dsg/dolibarr/htdocs/core/modules/product/doc/github_doc_generic_product_odt.modules.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/product/doc/client_doc_generic_product_odt.modules.php @@ -44,15 +44,15 @@ public $emetteur; /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 5.6 = array(5, 6) - */ - public $phpmin = array(5, 6); + * @var array Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.5 = array(5, 5) + */ + public $phpmin = array(5, 5); /** - * Dolibarr version of the loaded document - * @var string - */ + * Dolibarr version of the loaded document + * @var string + */ public $version = 'dolibarr'; @@ -66,7 +66,7 @@ global $conf, $langs, $mysoc; // Load translation files required by the page - $langs->loadLangs(array("main", "companies")); + $langs->loadLangs(array("main", "companies")); $this->db = $db; $this->name = "ODT templates"; @@ -111,7 +111,7 @@ global $conf, $langs; // Load translation files required by the page - $langs->loadLangs(array("errors", "companies")); + $langs->loadLangs(array("errors", "companies")); $form = new Form($this->db); @@ -141,7 +141,8 @@ unset($listofdir[$key]); continue; } if (!is_dir($tmpdir)) $texttitle .= img_warning($langs->trans("ErrorDirNotFound", $tmpdir), 0); - else { + else + { $tmpfiles = dol_dir_list($tmpdir, 'files', 0, '\.(ods|odt)'); if (count($tmpfiles)) $listoffiles = array_merge($listoffiles, $tmpfiles); } @@ -204,7 +205,7 @@ return $texte; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -218,7 +219,7 @@ */ public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - // phpcs:enable + // phpcs:enable global $product, $langs, $conf, $mysoc, $hookmanager, $user; if (empty($srctemplatepath)) @@ -289,10 +290,12 @@ $newfileformat = substr($newfile, strrpos($newfile, '.') + 1); if (!empty($conf->global->MAIN_DOC_USE_TIMING)) { - $format = $conf->global->MAIN_DOC_USE_TIMING; - if ($format == '1') $format = '%Y%m%d%H%M%S'; + $format = $conf->global->MAIN_DOC_USE_TIMING; + if ($format == '1') $format = '%Y%m%d%H%M%S'; $filename = $newfiletmp.'-'.dol_print_date(dol_now(), $format).'.'.$newfileformat; - } else { + } + else + { $filename = $newfiletmp.'.'.$newfileformat; } $file = $dir.'/'.$filename; @@ -315,15 +318,19 @@ // Recipient name $contactobject = null; - if (!empty($usecontact)) { - 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)))) { - $socobject = $object->contact; - } else { - $socobject = $object->thirdparty; - // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use - $contactobject = $object->contact; - } - } else { + if (!empty($usecontact)) + { + // On peut utiliser le nom de la societe du contact + if (!empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { + $socobject = $object->contact; + } else { + $socobject = $object->thirdparty; + // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use + $contactobject = $object->contact; + } + } + else + { $socobject = $object->thirdparty; } // Make substitution @@ -350,7 +357,7 @@ // Open and load template require_once ODTPHP_PATH.'odf.php'; try { - $odfHandler = new odf( + $odfHandler = new odf( $srctemplatepath, array( 'PATH_TO_TMP' => $conf->product->dir_temp, @@ -359,7 +366,8 @@ 'DELIMITER_RIGHT' => '}' ) ); - } catch (Exception $e) + } + catch (Exception $e) { $this->error = $e->getMessage(); dol_syslog($e->getMessage(), LOG_INFO); @@ -376,7 +384,8 @@ // Make substitutions into odt of freetext try { $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); - } catch (OdfException $e) + } + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -407,17 +416,20 @@ { if (file_exists($value)) $odfHandler->setImage($key, $value); else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); - } else // Text + } + else // Text { $odfHandler->setVars($key, $value, true, 'UTF-8'); } - } catch (OdfException $e) + } + catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); + dol_syslog($e->getMessage(), LOG_INFO); } } // Replace tags of lines - try { + try + { $listlines = $odfHandler->setSegment('supplierprices'); if (!empty($object->supplierprices)) { foreach ($object->supplierprices as $supplierprice) @@ -429,12 +441,15 @@ $reshook = $hookmanager->executeHooks('ODTSubstitutionLine', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks foreach ($array_lines as $key => $val) { - try { + try + { $listlines->setVars($key, $val, true, 'UTF-8'); - } catch (OdfException $e) + } + catch (OdfException $e) { dol_syslog($e->getMessage(), LOG_INFO); - } catch (SegmentException $e) + } + catch (SegmentException $e) { dol_syslog($e->getMessage(), LOG_INFO); } @@ -443,7 +458,8 @@ } } $odfHandler->mergeSegment($listlines); - } catch (OdfException $e) + } + catch (OdfException $e) { $this->error = $e->getMessage(); dol_syslog($this->error, LOG_WARNING); @@ -456,9 +472,10 @@ { try { $odfHandler->setVars($key, $value, true, 'UTF-8'); - } catch (OdfException $e) + } + catch (OdfException $e) { - dol_syslog($e->getMessage(), LOG_INFO); + dol_syslog($e->getMessage(), LOG_INFO); } } @@ -472,15 +489,16 @@ $odfHandler->exportAsAttachedPDF($file); } catch (Exception $e) { $this->error = $e->getMessage(); - dol_syslog($e->getMessage(), LOG_INFO); + dol_syslog($e->getMessage(), LOG_INFO); return -1; } - } else { + } + else { try { $odfHandler->saveToDisk($file); } catch (Exception $e) { $this->error = $e->getMessage(); - dol_syslog($e->getMessage(), LOG_INFO); + dol_syslog($e->getMessage(), LOG_INFO); return -1; } } @@ -495,7 +513,9 @@ $this->result = array('fullpath'=>$file); return 1; // Success - } else { + } + else + { $this->error = $langs->transnoentities("ErrorCanNotCreateDir", $dir); return -1; } --- /tmp/dsg/dolibarr/htdocs/core/modules/product/doc/github_pdf_standard.modules.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/product/doc/client_pdf_standard.modules.php @@ -36,74 +36,74 @@ */ class pdf_standard extends ModelePDFProduct { - /** - * @var DoliDb Database handler - */ - public $db; - - /** - * @var string model name - */ - public $name; - - /** - * @var string model description (short text) - */ - public $description; - - /** - * @var string document type - */ - public $type; - - /** - * @var array Minimum version of PHP required by module. - * e.g.: PHP ≥ 5.6 = array(5, 6) - */ - public $phpmin = array(5, 6); - - /** - * Dolibarr version of the loaded document - * @var string - */ + /** + * @var DoliDb Database handler + */ + public $db; + + /** + * @var string model name + */ + public $name; + + /** + * @var string model description (short text) + */ + public $description; + + /** + * @var string document type + */ + public $type; + + /** + * @var array Minimum version of PHP required by module. + * e.g.: PHP ≥ 5.5 = array(5, 5) + */ + public $phpmin = array(5, 5); + + /** + * Dolibarr version of the loaded document + * @var string + */ public $version = 'dolibarr'; - /** - * @var int page_largeur - */ - public $page_largeur; - - /** - * @var int page_hauteur - */ - public $page_hauteur; - - /** - * @var array format - */ - public $format; - - /** - * @var int marge_gauche - */ + /** + * @var int page_largeur + */ + public $page_largeur; + + /** + * @var int page_hauteur + */ + public $page_hauteur; + + /** + * @var array format + */ + public $format; + + /** + * @var int marge_gauche + */ public $marge_gauche; /** - * @var int marge_droite - */ + * @var int marge_droite + */ public $marge_droite; /** - * @var int marge_haute - */ + * @var int marge_haute + */ public $marge_haute; /** - * @var int marge_basse - */ + * @var int marge_basse + */ public $marge_basse; - /** + /** * Issuer * @var Societe */ @@ -148,7 +148,7 @@ } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build a document on disk using the generic odt module. * @@ -160,9 +160,9 @@ * @param int $hideref Do not show ref * @return int 1 if OK, <=0 if KO */ - public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) - { - // phpcs:enable + public function write_file($object, $outputlangs, $srctemplatepath, $hidedetails = 0, $hidedesc = 0, $hideref = 0) + { + // phpcs:enable global $user, $langs, $conf, $mysoc, $db, $hookmanager; if (!is_object($outputlangs)) $outputlangs = $langs; @@ -176,12 +176,14 @@ if ($conf->product->dir_output) { - // Definition of $dir and $file + // Definition of $dir and $file if ($object->specimen) { $dir = $conf->product->dir_output; $file = $dir."/SPECIMEN.pdf"; - } else { + } + else + { $objectref = dol_sanitizeFileName($object->ref); $dir = $conf->product->dir_output."/".$objectref; $file = $dir."/".$objectref.".pdf"; @@ -219,22 +221,22 @@ $pdf->SetAutoPageBreak(1, 0); $heightforinfotot = 40; // Height reserved to output the info and total part - $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page - $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) - if (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS)) $heightforfooter += 6; - - if (class_exists('TCPDF')) - { - $pdf->setPrintHeader(false); - $pdf->setPrintFooter(false); - } - $pdf->SetFont(pdf_getPDFFont($outputlangs)); - // Set path to the background PDF File - if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) - { - $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); - $tplidx = $pdf->importPage(1); - } + $heightforfreetext = (isset($conf->global->MAIN_PDF_FREETEXT_HEIGHT) ? $conf->global->MAIN_PDF_FREETEXT_HEIGHT : 5); // Height reserved to output the free text on last page + $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; + + if (class_exists('TCPDF')) + { + $pdf->setPrintHeader(false); + $pdf->setPrintFooter(false); + } + $pdf->SetFont(pdf_getPDFFont($outputlangs)); + // Set path to the background PDF File + if (!empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) + { + $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); + $tplidx = $pdf->importPage(1); + } $pdf->Open(); $pagenb = 0; @@ -265,7 +267,7 @@ $tab_height = 130; $tab_height_newpage = 150; - // Label of product + // $pdf->SetFont('', 'B', $default_font_size); $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $tab_top, dol_htmlentitiesbr($object->label), 0, 1); $nexY = $pdf->GetY(); @@ -276,34 +278,29 @@ $nexY += 5; - $outputlangs->load("other"); if ($object->weight) { - $texttoshow = $langs->trans("Weight").': '.dol_htmlentitiesbr($object->weight); - if (isset($object->weight_units)) $texttoshow .= ' '.measuring_units_string($object->weight_units, 'weight', 0, 0, $outputlangs); - $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $texttoshow, 0, 1); - $nexY = $pdf->GetY(); + $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $langs->trans("Weight").': '.dol_htmlentitiesbr($object->weight), 0, 1); + $nexY = $pdf->GetY(); } if ($object->weight) { - $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 : '?'); - $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $texttoshow, 0, 1); - $nexY = $pdf->GetY(); + $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $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 : '?'), 0, 1); + $nexY = $pdf->GetY(); } if ($object->surface) { - $texttoshow = $langs->trans("Area").': '.dol_htmlentitiesbr($object->surface); - $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $texttoshow, 0, 1); - $nexY = $pdf->GetY(); + $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $langs->trans("Area").': '.dol_htmlentitiesbr($object->surface), 0, 1); + $nexY = $pdf->GetY(); } if ($object->volume) { - $texttoshow = $langs->trans("Volume").': '.dol_htmlentitiesbr($object->volume); - $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $texttoshow, 0, 1); - $nexY = $pdf->GetY(); - } - - // Show notes + $pdf->writeHTMLCell(190, 3, $this->marge_gauche, $nexY, $langs->trans("Volume").': '.dol_htmlentitiesbr($object->volume), 0, 1); + $nexY = $pdf->GetY(); + } + + + // Affiche notes // TODO There is no public note on product yet $notetoshow = empty($object->note_public) ? '' : $object->note_public; if (!empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) @@ -337,7 +334,9 @@ $tab_height = $tab_height - $height_note; $tab_top = $nexY + 6; - } else { + } + else + { $height_note = 0; } @@ -449,7 +448,7 @@ $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva - if (!empty($conf->multicurrency->enabled) && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; else $tvaligne=$object->lines[$i]->total_tva; $localtax1ligne=$object->lines[$i]->total_localtax1; @@ -470,8 +469,8 @@ && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax { $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc); - $localtax1_type = isset($localtaxtmp_array[0]) ? $localtaxtmp_array[0] : ''; - $localtax2_type = isset($localtaxtmp_array[2]) ? $localtaxtmp_array[2] : ''; + $localtax1_type = $localtaxtmp_array[0]; + $localtax2_type = $localtaxtmp_array[2]; } // retrieve global local tax @@ -564,8 +563,8 @@ $reshook = $hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks if ($reshook < 0) { - $this->error = $hookmanager->error; - $this->errors = $hookmanager->errors; + $this->error = $hookmanager->error; + $this->errors = $hookmanager->errors; } if (!empty($conf->global->MAIN_UMASK)) @@ -574,15 +573,19 @@ $this->result = array('fullpath'=>$file); return 1; // No error - } else { + } + else + { $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } - } else { + } + else + { $this->error = $langs->trans("ErrorConstantNotDefined", "PRODUCT_OUTPUTDIR"); return 0; } - } + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore /** @@ -600,94 +603,94 @@ */ protected function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') { - global $conf; - - // Force to disable hidetop and hidebottom - $hidebottom = 0; - if ($hidetop) $hidetop = -1; - - $currency = !empty($currency) ? $currency : $conf->currency; - $default_font_size = pdf_getPDFFontSize($outputlangs); - - // Amount in (at tab_top - 1) - $pdf->SetTextColor(0, 0, 0); - $pdf->SetFont('', '', $default_font_size - 2); - - if (empty($hidetop)) - { - $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); - $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); - $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); - - //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; - 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)); - } - - $pdf->SetDrawColor(128, 128, 128); - $pdf->SetFont('', '', $default_font_size - 1); - - // Output Rect - $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter - - if (empty($hidetop)) - { - $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter - - $pdf->SetXY($this->posxdesc - 1, $tab_top + 1); - $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L'); - } - - if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) - { - $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height); - if (empty($hidetop)) - { - $pdf->SetXY($this->posxtva - 3, $tab_top + 1); - $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C'); - } - } - - $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height); - if (empty($hidetop)) - { - $pdf->SetXY($this->posxup - 1, $tab_top + 1); - $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C'); - } - - $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height); - if (empty($hidetop)) - { - $pdf->SetXY($this->posxqty - 1, $tab_top + 1); - $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); - } - - if (!empty($conf->global->PRODUCT_USE_UNITS)) { - $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); - if (empty($hidetop)) { - $pdf->SetXY($this->posxunit - 1, $tab_top + 1); - $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', 'C'); - } - } - - $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height); - if (empty($hidetop)) - { - if ($this->atleastonediscount) - { - $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1); - $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C'); - } - } - - if ($this->atleastonediscount) - { - $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); - } - if (empty($hidetop)) - { - $pdf->SetXY($this->postotalht - 1, $tab_top + 1); - $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C'); - } + global $conf; + + // Force to disable hidetop and hidebottom + $hidebottom = 0; + if ($hidetop) $hidetop = -1; + + $currency = !empty($currency) ? $currency : $conf->currency; + $default_font_size = pdf_getPDFFontSize($outputlangs); + + // Amount in (at tab_top - 1) + $pdf->SetTextColor(0, 0, 0); + $pdf->SetFont('', '', $default_font_size - 2); + + if (empty($hidetop)) + { + $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); + $pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4); + $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); + + //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; + 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)); + } + + $pdf->SetDrawColor(128, 128, 128); + $pdf->SetFont('', '', $default_font_size - 1); + + // Output Rect + $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur - $this->marge_gauche - $this->marge_droite, $tab_height, $hidetop, $hidebottom); // Rect takes a length in 3rd parameter and 4th parameter + + if (empty($hidetop)) + { + $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur - $this->marge_droite, $tab_top + 5); // line takes a position y in 2nd parameter and 4th parameter + + $pdf->SetXY($this->posxdesc - 1, $tab_top + 1); + $pdf->MultiCell(108, 2, $outputlangs->transnoentities("Designation"), '', 'L'); + } + + if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) + { + $pdf->line($this->posxtva - 1, $tab_top, $this->posxtva - 1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxtva - 3, $tab_top + 1); + $pdf->MultiCell($this->posxup - $this->posxtva + 3, 2, $outputlangs->transnoentities("VAT"), '', 'C'); + } + } + + $pdf->line($this->posxup - 1, $tab_top, $this->posxup - 1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxup - 1, $tab_top + 1); + $pdf->MultiCell($this->posxqty - $this->posxup - 1, 2, $outputlangs->transnoentities("PriceUHT"), '', 'C'); + } + + $pdf->line($this->posxqty - 1, $tab_top, $this->posxqty - 1, $tab_top + $tab_height); + if (empty($hidetop)) + { + $pdf->SetXY($this->posxqty - 1, $tab_top + 1); + $pdf->MultiCell($this->posxunit - $this->posxqty - 1, 2, $outputlangs->transnoentities("Qty"), '', 'C'); + } + + if ($conf->global->PRODUCT_USE_UNITS) { + $pdf->line($this->posxunit - 1, $tab_top, $this->posxunit - 1, $tab_top + $tab_height); + if (empty($hidetop)) { + $pdf->SetXY($this->posxunit - 1, $tab_top + 1); + $pdf->MultiCell($this->posxdiscount - $this->posxunit - 1, 2, $outputlangs->transnoentities("Unit"), '', 'C'); + } + } + + $pdf->line($this->posxdiscount - 1, $tab_top, $this->posxdiscount - 1, $tab_top + $tab_height); + if (empty($hidetop)) + { + if ($this->atleastonediscount) + { + $pdf->SetXY($this->posxdiscount - 1, $tab_top + 1); + $pdf->MultiCell($this->postotalht - $this->posxdiscount + 1, 2, $outputlangs->transnoentities("ReductionShort"), '', 'C'); + } + } + + if ($this->atleastonediscount) + { + $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); + } + if (empty($hidetop)) + { + $pdf->SetXY($this->postotalht - 1, $tab_top + 1); + $pdf->MultiCell(30, 2, $outputlangs->transnoentities("TotalHT"), '', 'C'); + } } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore @@ -695,7 +698,7 @@ * Show top header of page. * * @param TCPDF $pdf Object PDF - * @param Product $object Object to show + * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output * @param string $titlekey Translation key to show as title of document @@ -703,68 +706,72 @@ */ protected function _pagehead(&$pdf, $object, $showaddress, $outputlangs, $titlekey = "") { - global $conf, $langs, $hookmanager; - - // Load traductions files required by page + global $conf, $langs, $hookmanager; + + // Load traductions files required by page $outputlangs->loadLangs(array("main", "propal", "companies", "bills", "orders")); - $default_font_size = pdf_getPDFFontSize($outputlangs); - - if ($object->type == 1) $titlekey = 'ServiceSheet'; - else $titlekey = 'ProductSheet'; - - pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); - - // Show Draft Watermark - if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) - { - pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK); - } - - $pdf->SetTextColor(0, 0, 60); - $pdf->SetFont('', 'B', $default_font_size + 3); - - $posy = $this->marge_haute; - $posx = $this->page_largeur - $this->marge_droite - 100; - - $pdf->SetXY($this->marge_gauche, $posy); - - // Logo - $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; - if ($this->emetteur->logo) - { - if (is_readable($logo)) - { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { - $pdf->SetTextColor(200, 0, 0); - $pdf->SetFont('', 'B', $default_font_size - 2); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); - } - } else { - $text = $this->emetteur->name; - $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); - } - - $pdf->SetFont('', 'B', $default_font_size + 3); - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $title = $outputlangs->transnoentities($titlekey); - $pdf->MultiCell(100, 3, $title, '', 'R'); - - $pdf->SetFont('', 'B', $default_font_size); - - $posy += 5; - $pdf->SetXY($posx, $posy); - $pdf->SetTextColor(0, 0, 60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); - - $posy += 1; - $pdf->SetFont('', '', $default_font_size - 1); - - /*if ($object->ref_client) + $default_font_size = pdf_getPDFFontSize($outputlangs); + + if ($object->type == 1) $titlekey = 'ServiceSheet'; + else $titlekey = 'ProductSheet'; + + pdf_pagehead($pdf, $outputlangs, $this->page_hauteur); + + // Show Draft Watermark + if ($object->statut == 0 && (!empty($conf->global->COMMANDE_DRAFT_WATERMARK))) + { + pdf_watermark($pdf, $outputlangs, $this->page_hauteur, $this->page_largeur, 'mm', $conf->global->COMMANDE_DRAFT_WATERMARK); + } + + $pdf->SetTextColor(0, 0, 60); + $pdf->SetFont('', 'B', $default_font_size + 3); + + $posy = $this->marge_haute; + $posx = $this->page_largeur - $this->marge_droite - 100; + + $pdf->SetXY($this->marge_gauche, $posy); + + // Logo + $logo = $conf->mycompany->dir_output.'/logos/'.$this->emetteur->logo; + if ($this->emetteur->logo) + { + if (is_readable($logo)) + { + $height = pdf_getHeightForLogo($logo); + $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) + } + else + { + $pdf->SetTextColor(200, 0, 0); + $pdf->SetFont('', 'B', $default_font_size - 2); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + } + } + else + { + $text = $this->emetteur->name; + $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); + } + + $pdf->SetFont('', 'B', $default_font_size + 3); + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $title = $outputlangs->transnoentities($titlekey); + $pdf->MultiCell(100, 3, $title, '', 'R'); + + $pdf->SetFont('', 'B', $default_font_size); + + $posy += 5; + $pdf->SetXY($posx, $posy); + $pdf->SetTextColor(0, 0, 60); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : ".$outputlangs->convToOutputCharset($object->ref), '', 'R'); + + $posy += 1; + $pdf->SetFont('', '', $default_font_size - 1); + + /*if ($object->ref_client) { $posy+=5; $pdf->SetXY($posx,$posy); @@ -772,14 +779,14 @@ $pdf->MultiCell(100, 3, $outputlangs->transnoentities("RefCustomer")." : " . $outputlangs->convToOutputCharset($object->ref_client), '', 'R'); }*/ - /*$posy+=4; + /*$posy+=4; $pdf->SetXY($posx,$posy); $pdf->SetTextColor(0,0,60); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dol_print_date($object->date,"%d %b %Y",false,$outputlangs,true), '', 'R'); */ - // Get contact - /* + // Get contact + /* if (!empty($conf->global->DOC_SHOW_FIRST_SALES_REP)) { $arrayidcontact=$object->getIdContact('internal','SALESREPFOLL'); @@ -794,14 +801,14 @@ } }*/ - $posy += 2; - - // Show list of linked objects - $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); - - if ($showaddress) - { - /* + $posy += 2; + + // Show list of linked objects + $posy = pdf_writeLinkedObjects($pdf, $object, $outputlangs, $posx, $posy, 100, 3, 'R', $default_font_size); + + if ($showaddress) + { + /* // Sender properties $carac_emetteur = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty); @@ -832,25 +839,25 @@ $pdf->SetFont('','', $default_font_size - 1); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); */ - } - - $pdf->SetTextColor(0, 0, 0); - } + } + + $pdf->SetTextColor(0, 0, 0); + } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore - /** - * Show footer of page. Need this->emetteur object - * - * @param TCPDF $pdf PDF - * @param Product $object Object to show - * @param Translate $outputlangs Object lang for output - * @param int $hidefreetext 1=Hide free text - * @return int Return height of bottom margin including footer text - */ + /** + * Show footer of page. Need this->emetteur object + * + * @param TCPDF $pdf PDF + * @param Object $object Object to show + * @param Translate $outputlangs Object lang for output + * @param int $hidefreetext 1=Hide free text + * @return int Return height of bottom margin including footer text + */ protected function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) - { - global $conf; - $showdetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS) ? 0 : $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; - return pdf_pagefoot($pdf, $outputlangs, 'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); - } + { + global $conf; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; + return pdf_pagefoot($pdf, $outputlangs, 'PRODUCT_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); + } }