--- /tmp/dsg/dolibarr/htdocs/core/modules/fichinter/doc/github_pdf_soleil.modules.php +++ /tmp/dsg/dolibarr/htdocs/core/modules/fichinter/doc/client_pdf_soleil.modules.php @@ -40,70 +40,70 @@ class pdf_soleil extends ModelePDFFicheinter { /** - * @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; /** @@ -152,11 +152,11 @@ $this->posxdesc = $this->marge_gauche + 1; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Function to build pdf onto disk * - * @param Fichinter $object Object to generate + * @param Object $object Object to generate * @param Translate $outputlangs Lang output object * @param string $srctemplatepath Full path of source filename for generator using a template file * @param int $hidedetails Do not show line details @@ -166,7 +166,7 @@ */ public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) { - // phpcs:enable + // phpcs:enable global $user, $langs, $conf, $mysoc, $db, $hookmanager; if (!is_object($outputlangs)) $outputlangs = $langs; @@ -180,12 +180,14 @@ { $object->fetch_thirdparty(); - // Definition of $dir and $file + // Definition of $dir and $file if ($object->specimen) { $dir = $conf->ficheinter->dir_output; $file = $dir."/SPECIMEN.pdf"; - } else { + } + else + { $objectref = dol_sanitizeFileName($object->ref); $dir = $conf->ficheinter->dir_output."/".$objectref; $file = $dir."/".$objectref.".pdf"; @@ -222,7 +224,7 @@ $heightforinfotot = 50; // 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 ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS > 0) $heightforfooter += 6; $pdf->SetAutoPageBreak(1, 0); if (class_exists('TCPDF')) @@ -286,7 +288,9 @@ $tab_height = $tab_height - $height_note; $tab_top = $nexY + 6; - } else { + } + else + { $height_note = 0; } @@ -304,8 +308,8 @@ $text = $object->description; if ($object->duration > 0) { - $totaltime = convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); - $text .= ($text ? ' - ' : '').$langs->trans("Total").": ".$totaltime; + $totaltime = convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); + $text .= ($text ? ' - ' : '').$langs->trans("Total").": ".$totaltime; } $desc = dol_htmlentitiesbr($text, 1); //print $outputlangs->convToOutputCharset($desc); exit; @@ -336,12 +340,12 @@ // Description of product line $curX = $this->posxdesc - 1; - // Description of product line - if (empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR)) { - $txt = $outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'dayhour', false, $outputlangs, true); - } else { - $txt = $outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'day', false, $outputlangs, true); - } + // Description of product line + if (empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR)) { + $txt = $outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'dayhour', false, $outputlangs, true); + } else { + $txt = $outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'day', false, $outputlangs, true); + } if ($objectligne->duration > 0) { @@ -373,7 +377,8 @@ $pdf->setPage($pageposafter + 1); } } - } else // No pagebreak + } + else // No pagebreak { $pdf->commitTransaction(); } @@ -398,7 +403,9 @@ if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); - } else { + } + else + { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); } $this->_pagefoot($pdf, $object, $outputlangs, 1); @@ -412,7 +419,9 @@ if ($pagenb == 1) { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); - } else { + } + else + { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); } $this->_pagefoot($pdf, $object, $outputlangs, 1); @@ -430,7 +439,9 @@ { $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; - } else { + } + else + { $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); $bottomlasttab = $this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; } @@ -448,8 +459,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)) @@ -458,11 +469,15 @@ $this->result = array('fullpath'=>$file); return 1; - } else { + } + else + { $this->error = $langs->trans("ErrorCanNotCreateDir", $dir); return 0; } - } else { + } + else + { $this->error = $langs->trans("ErrorConstantNotDefined", "FICHEINTER_OUTPUTDIR"); return 0; } @@ -472,7 +487,7 @@ /** * Show table for lines * - * @param TCPDF $pdf Object PDF + * @param PDF $pdf Object PDF * @param string $tab_top Top position of table * @param string $tab_height Height of table (rectangle) * @param int $nexY Y @@ -487,7 +502,7 @@ $default_font_size = pdf_getPDFFontSize($outputlangs); - /* + /* $pdf->SetXY($this->marge_gauche, $tab_top); $pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0); $pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8); @@ -536,8 +551,8 @@ /** * Show top header of page. * - * @param TCPDF $pdf Object PDF - * @param Fichinter $object Object to show + * @param PDF $pdf Object PDF + * @param Object $object Object to show * @param int $showaddress 0=no, 1=yes * @param Translate $outputlangs Object lang for output * @return void @@ -573,15 +588,19 @@ { if (is_readable($logo)) { - $height = pdf_getHeightForLogo($logo); - $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) - } else { + $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 { + } + else + { $text = $this->emetteur->name; $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); } @@ -665,8 +684,9 @@ $result = $object->fetch_contact($arrayidcontact[0]); } - // Recipient name - 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)))) { + //Recipient name + // On peut utiliser le nom de la societe du contact + if ($usecontact && !empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { $thirdparty = $object->contact; } else { $thirdparty = $object->thirdparty; @@ -708,8 +728,8 @@ /** * Show footer of page. Need this->emetteur object * - * @param TCPDF $pdf PDF - * @param Fichinter $object Object to show + * @param PDF $pdf PDF + * @param Object $object Object to show * @param Translate $outputlangs Object lang for output * @param int $hidefreetext 1=Hide free text * @return integer @@ -717,7 +737,7 @@ 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; + $showdetails = $conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS; return pdf_pagefoot($pdf, $outputlangs, 'FICHINTER_FREE_TEXT', $this->emetteur, $this->marge_basse, $this->marge_gauche, $this->page_hauteur, $object, $showdetails, $hidefreetext); } }