| Total Complexity | 69 |
| Total Lines | 699 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like pdf_soleil often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use pdf_soleil, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 40 | class pdf_soleil extends ModelePDFFicheinter |
||
| 41 | { |
||
| 42 | /** |
||
| 43 | * @var DoliDb Database handler |
||
| 44 | */ |
||
| 45 | public $db; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @var string model name |
||
| 49 | */ |
||
| 50 | public $name; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @var string model description (short text) |
||
| 54 | */ |
||
| 55 | public $description; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @var string document type |
||
| 59 | */ |
||
| 60 | public $type; |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @var array Minimum version of PHP required by module. |
||
| 64 | * e.g.: PHP ≥ 5.5 = array(5, 5) |
||
| 65 | */ |
||
| 66 | public $phpmin = array(5, 5); |
||
| 67 | |||
| 68 | /** |
||
| 69 | * Dolibarr version of the loaded document |
||
| 70 | * @var string |
||
| 71 | */ |
||
| 72 | public $version = 'dolibarr'; |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @var int page_largeur |
||
| 76 | */ |
||
| 77 | public $page_largeur; |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @var int page_hauteur |
||
| 81 | */ |
||
| 82 | public $page_hauteur; |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @var array format |
||
| 86 | */ |
||
| 87 | public $format; |
||
| 88 | |||
| 89 | /** |
||
| 90 | * @var int marge_gauche |
||
| 91 | */ |
||
| 92 | public $marge_gauche; |
||
| 93 | |||
| 94 | /** |
||
| 95 | * @var int marge_droite |
||
| 96 | */ |
||
| 97 | public $marge_droite; |
||
| 98 | |||
| 99 | /** |
||
| 100 | * @var int marge_haute |
||
| 101 | */ |
||
| 102 | public $marge_haute; |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @var int marge_basse |
||
| 106 | */ |
||
| 107 | public $marge_basse; |
||
| 108 | |||
| 109 | /** |
||
| 110 | * Issuer |
||
| 111 | * @var Company object that emits |
||
| 112 | */ |
||
| 113 | public $emetteur; |
||
| 114 | |||
| 115 | /** |
||
| 116 | * Constructor |
||
| 117 | * |
||
| 118 | * @param DoliDB $db Database handler |
||
| 119 | */ |
||
| 120 | public function __construct($db) |
||
| 121 | { |
||
| 122 | global $conf,$langs,$mysoc; |
||
| 123 | |||
| 124 | $this->db = $db; |
||
| 125 | $this->name = 'soleil'; |
||
| 126 | $this->description = $langs->trans("DocumentModelStandardPDF"); |
||
| 127 | |||
| 128 | // Dimension page pour format A4 |
||
| 129 | $this->type = 'pdf'; |
||
| 130 | $formatarray=pdf_getFormat(); |
||
| 131 | $this->page_largeur = $formatarray['width']; |
||
| 132 | $this->page_hauteur = $formatarray['height']; |
||
| 133 | $this->format = array($this->page_largeur,$this->page_hauteur); |
||
| 134 | $this->marge_gauche=isset($conf->global->MAIN_PDF_MARGIN_LEFT)?$conf->global->MAIN_PDF_MARGIN_LEFT:10; |
||
| 135 | $this->marge_droite=isset($conf->global->MAIN_PDF_MARGIN_RIGHT)?$conf->global->MAIN_PDF_MARGIN_RIGHT:10; |
||
| 136 | $this->marge_haute =isset($conf->global->MAIN_PDF_MARGIN_TOP)?$conf->global->MAIN_PDF_MARGIN_TOP:10; |
||
| 137 | $this->marge_basse =isset($conf->global->MAIN_PDF_MARGIN_BOTTOM)?$conf->global->MAIN_PDF_MARGIN_BOTTOM:10; |
||
| 138 | |||
| 139 | $this->option_logo = 1; // Affiche logo |
||
| 140 | $this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION |
||
| 141 | $this->option_modereg = 0; // Affiche mode reglement |
||
| 142 | $this->option_condreg = 0; // Affiche conditions reglement |
||
| 143 | $this->option_codeproduitservice = 0; // Affiche code produit-service |
||
| 144 | $this->option_multilang = 1; // Dispo en plusieurs langues |
||
| 145 | $this->option_draft_watermark = 1; //Support add of a watermark on drafts |
||
| 146 | |||
| 147 | // Get source company |
||
| 148 | $this->emetteur=$mysoc; |
||
| 149 | if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang, -2); // By default, if not defined |
||
| 150 | |||
| 151 | // Define position of columns |
||
| 152 | $this->posxdesc=$this->marge_gauche+1; |
||
| 153 | } |
||
| 154 | |||
| 155 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
||
| 156 | /** |
||
| 157 | * Function to build pdf onto disk |
||
| 158 | * |
||
| 159 | * @param Object $object Object to generate |
||
| 160 | * @param Translate $outputlangs Lang output object |
||
| 161 | * @param string $srctemplatepath Full path of source filename for generator using a template file |
||
| 162 | * @param int $hidedetails Do not show line details |
||
| 163 | * @param int $hidedesc Do not show desc |
||
| 164 | * @param int $hideref Do not show ref |
||
| 165 | * @return int 1=OK, 0=KO |
||
| 166 | */ |
||
| 167 | public function write_file($object, $outputlangs, $srctemplatepath = '', $hidedetails = 0, $hidedesc = 0, $hideref = 0) |
||
| 168 | { |
||
| 169 | // phpcs:enable |
||
| 170 | global $user,$langs,$conf,$mysoc,$db,$hookmanager; |
||
| 171 | |||
| 172 | if (! is_object($outputlangs)) $outputlangs=$langs; |
||
| 173 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
||
| 174 | if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
||
| 175 | |||
| 176 | // Load traductions files requiredby by page |
||
| 177 | $outputlangs->loadLangs(array("main", "interventions", "dict", "companies")); |
||
| 178 | |||
| 179 | if ($conf->ficheinter->dir_output) |
||
| 180 | { |
||
| 181 | $object->fetch_thirdparty(); |
||
| 182 | |||
| 183 | // Definition of $dir and $file |
||
| 184 | if ($object->specimen) |
||
| 185 | { |
||
| 186 | $dir = $conf->ficheinter->dir_output; |
||
| 187 | $file = $dir . "/SPECIMEN.pdf"; |
||
| 188 | } |
||
| 189 | else |
||
| 190 | { |
||
| 191 | $objectref = dol_sanitizeFileName($object->ref); |
||
| 192 | $dir = $conf->ficheinter->dir_output . "/" . $objectref; |
||
| 193 | $file = $dir . "/" . $objectref . ".pdf"; |
||
| 194 | } |
||
| 195 | |||
| 196 | if (! file_exists($dir)) |
||
| 197 | { |
||
| 198 | if (dol_mkdir($dir) < 0) |
||
| 199 | { |
||
| 200 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir", $dir); |
||
| 201 | return 0; |
||
| 202 | } |
||
| 203 | } |
||
| 204 | |||
| 205 | if (file_exists($dir)) |
||
| 206 | { |
||
| 207 | // Add pdfgeneration hook |
||
| 208 | if (! is_object($hookmanager)) |
||
| 209 | { |
||
| 210 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
||
| 211 | $hookmanager=new HookManager($this->db); |
||
| 212 | } |
||
| 213 | |||
| 214 | $hookmanager->initHooks(array('pdfgeneration')); |
||
| 215 | $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
||
| 216 | global $action; |
||
| 217 | $reshook=$hookmanager->executeHooks('beforePDFCreation', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks |
||
| 218 | |||
| 219 | $nblines = count($object->lines); |
||
| 220 | |||
| 221 | // Create pdf instance |
||
| 222 | $pdf=pdf_getInstance($this->format); |
||
| 223 | $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
||
| 224 | $heightforinfotot = 50; // Height reserved to output the info and total part |
||
| 225 | $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 |
||
| 226 | $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
||
| 227 | if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
||
| 228 | $pdf->SetAutoPageBreak(1, 0); |
||
| 229 | |||
| 230 | if (class_exists('TCPDF')) |
||
| 231 | { |
||
| 232 | $pdf->setPrintHeader(false); |
||
| 233 | $pdf->setPrintFooter(false); |
||
| 234 | } |
||
| 235 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
||
| 236 | // Set path to the background PDF File |
||
| 237 | if (! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
||
| 238 | { |
||
| 239 | $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); |
||
| 240 | $tplidx = $pdf->importPage(1); |
||
| 241 | } |
||
| 242 | |||
| 243 | $pdf->Open(); |
||
| 244 | $pagenb=0; |
||
| 245 | $pdf->SetDrawColor(128, 128, 128); |
||
| 246 | |||
| 247 | $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
||
| 248 | $pdf->SetSubject($outputlangs->transnoentities("InterventionCard")); |
||
| 249 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
||
| 250 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
||
| 251 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("InterventionCard")); |
||
| 252 | if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
||
| 253 | |||
| 254 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
||
| 255 | |||
| 256 | // New page |
||
| 257 | $pdf->AddPage(); |
||
| 258 | if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
||
| 259 | $pagenb++; |
||
| 260 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
||
| 261 | $pdf->SetFont('', '', $default_font_size - 1); |
||
| 262 | $pdf->SetTextColor(0, 0, 0); |
||
| 263 | |||
| 264 | $tab_top = 90; |
||
| 265 | $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); |
||
| 266 | $tab_height = 130; |
||
| 267 | $tab_height_newpage = 150; |
||
| 268 | |||
| 269 | // Affiche notes |
||
| 270 | $notetoshow=empty($object->note_public)?'':$object->note_public; |
||
| 271 | if ($notetoshow) |
||
| 272 | { |
||
| 273 | $substitutionarray=pdf_getSubstitutionArray($outputlangs, null, $object); |
||
| 274 | complete_substitutions_array($substitutionarray, $outputlangs, $object); |
||
| 275 | $notetoshow = make_substitutions($notetoshow, $substitutionarray, $outputlangs); |
||
| 276 | $notetoshow = convertBackOfficeMediasLinksToPublicLinks($notetoshow); |
||
| 277 | |||
| 278 | $tab_top = 88; |
||
| 279 | |||
| 280 | $pdf->SetFont('', '', $default_font_size - 1); |
||
| 281 | $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); |
||
| 282 | $nexY = $pdf->GetY(); |
||
| 283 | $height_note=$nexY-$tab_top; |
||
| 284 | |||
| 285 | // Rect prend une longueur en 3eme param |
||
| 286 | $pdf->SetDrawColor(192, 192, 192); |
||
| 287 | $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
||
| 288 | |||
| 289 | $tab_height = $tab_height - $height_note; |
||
| 290 | $tab_top = $nexY+6; |
||
| 291 | } |
||
| 292 | else |
||
| 293 | { |
||
| 294 | $height_note=0; |
||
| 295 | } |
||
| 296 | |||
| 297 | $iniY = $tab_top + 7; |
||
| 298 | $curY = $tab_top + 7; |
||
| 299 | $nexY = $tab_top + 7; |
||
| 300 | |||
| 301 | $pdf->SetXY($this->marge_gauche, $tab_top); |
||
| 302 | $pdf->MultiCell(190, 5, $outputlangs->transnoentities("Description"), 0, 'L', 0); |
||
| 303 | $pdf->line($this->marge_gauche, $tab_top + 5, $this->page_largeur-$this->marge_droite, $tab_top + 5); |
||
| 304 | |||
| 305 | $pdf->SetFont('', '', $default_font_size - 1); |
||
| 306 | |||
| 307 | $pdf->SetXY($this->marge_gauche, $tab_top + 5); |
||
| 308 | $text=$object->description; |
||
| 309 | if ($object->duration > 0) |
||
| 310 | { |
||
| 311 | $totaltime=convertSecondToTime($object->duration, 'all', $conf->global->MAIN_DURATION_OF_WORKDAY); |
||
| 312 | $text.=($text?' - ':'').$langs->trans("Total").": ".$totaltime; |
||
| 313 | } |
||
| 314 | $desc=dol_htmlentitiesbr($text, 1); |
||
| 315 | //print $outputlangs->convToOutputCharset($desc); exit; |
||
| 316 | |||
| 317 | $pdf->writeHTMLCell(180, 3, 10, $tab_top + 5, $outputlangs->convToOutputCharset($desc), 0, 1); |
||
| 318 | $nexY = $pdf->GetY(); |
||
| 319 | |||
| 320 | $pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY); |
||
| 321 | |||
| 322 | $nblines = count($object->lines); |
||
| 323 | |||
| 324 | // Loop on each lines |
||
| 325 | for ($i = 0; $i < $nblines; $i++) |
||
| 326 | { |
||
| 327 | $objectligne = $object->lines[$i]; |
||
| 328 | |||
| 329 | $valide = empty($objectligne->id) ? 0 : $objectligne->fetch($objectligne->id); |
||
| 330 | if ($valide > 0 || $object->specimen) |
||
| 331 | { |
||
| 332 | $curY = $nexY; |
||
| 333 | $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage |
||
| 334 | $pdf->SetTextColor(0, 0, 0); |
||
| 335 | |||
| 336 | $pdf->setTopMargin($tab_top_newpage); |
||
| 337 | $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
||
| 338 | $pageposbefore=$pdf->getPage(); |
||
| 339 | |||
| 340 | // Description of product line |
||
| 341 | $curX = $this->posxdesc-1; |
||
| 342 | |||
| 343 | // Description of product line |
||
| 344 | if (empty($conf->global->FICHINTER_DATE_WITHOUT_HOUR)) { |
||
| 345 | $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'dayhour', false, $outputlangs, true); |
||
| 346 | } else { |
||
| 347 | $txt=$outputlangs->transnoentities("Date")." : ".dol_print_date($objectligne->datei, 'day', false, $outputlangs, true); |
||
| 348 | } |
||
| 349 | |||
| 350 | if ($objectligne->duration > 0) |
||
| 351 | { |
||
| 352 | $txt.=" - ".$outputlangs->transnoentities("Duration")." : ".convertSecondToTime($objectligne->duration); |
||
| 353 | } |
||
| 354 | $txt='<strong>'.dol_htmlentitiesbr($txt, 1, $outputlangs->charset_output).'</strong>'; |
||
| 355 | $desc=dol_htmlentitiesbr($objectligne->desc, 1); |
||
| 356 | |||
| 357 | $pdf->startTransaction(); |
||
| 358 | $pdf->writeHTMLCell(0, 0, $curX, $curY + 1, dol_concatdesc($txt, $desc), 0, 1, 0); |
||
| 359 | $pageposafter=$pdf->getPage(); |
||
| 360 | if ($pageposafter > $pageposbefore) // There is a pagebreak |
||
| 361 | { |
||
| 362 | $pdf->rollbackTransaction(true); |
||
| 363 | $pageposafter=$pageposbefore; |
||
| 364 | //print $pageposafter.'-'.$pageposbefore;exit; |
||
| 365 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
||
| 366 | $pdf->writeHTMLCell(0, 0, $curX, $curY, dol_concatdesc($txt, $desc), 0, 1, 0); |
||
| 367 | $pageposafter=$pdf->getPage(); |
||
| 368 | $posyafter=$pdf->GetY(); |
||
| 369 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
||
| 370 | if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
||
| 371 | { |
||
| 372 | if ($i == ($nblines-1)) // No more lines, and no space left to show total, so we create a new page |
||
| 373 | { |
||
| 374 | $pdf->AddPage('', '', true); |
||
| 375 | if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
||
| 376 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
||
| 377 | $pdf->setPage($pageposafter+1); |
||
| 378 | } |
||
| 379 | } |
||
| 380 | } |
||
| 381 | else // No pagebreak |
||
| 382 | { |
||
| 383 | $pdf->commitTransaction(); |
||
| 384 | } |
||
| 385 | |||
| 386 | $nexY = $pdf->GetY(); |
||
| 387 | $pageposafter=$pdf->getPage(); |
||
| 388 | $pdf->setPage($pageposbefore); |
||
| 389 | $pdf->setTopMargin($this->marge_haute); |
||
| 390 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
||
| 391 | |||
| 392 | // We suppose that a too long description is moved completely on next page |
||
| 393 | if ($pageposafter > $pageposbefore) { |
||
| 394 | $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
||
| 395 | } |
||
| 396 | |||
| 397 | $pdf->SetFont('', '', $default_font_size - 1); // On repositionne la police par defaut |
||
| 398 | |||
| 399 | // Detect if some page were added automatically and output _tableau for past pages |
||
| 400 | while ($pagenb < $pageposafter) |
||
| 401 | { |
||
| 402 | $pdf->setPage($pagenb); |
||
| 403 | if ($pagenb == 1) |
||
| 404 | { |
||
| 405 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
||
| 406 | } |
||
| 407 | else |
||
| 408 | { |
||
| 409 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
||
| 410 | } |
||
| 411 | $this->_pagefoot($pdf, $object, $outputlangs, 1); |
||
| 412 | $pagenb++; |
||
| 413 | $pdf->setPage($pagenb); |
||
| 414 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
||
| 415 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
||
| 416 | } |
||
| 417 | if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
||
| 418 | { |
||
| 419 | if ($pagenb == 1) |
||
| 420 | { |
||
| 421 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
||
| 422 | } |
||
| 423 | else |
||
| 424 | { |
||
| 425 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
||
| 426 | } |
||
| 427 | $this->_pagefoot($pdf, $object, $outputlangs, 1); |
||
| 428 | // New page |
||
| 429 | $pdf->AddPage(); |
||
| 430 | if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
||
| 431 | $pagenb++; |
||
| 432 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
||
| 433 | } |
||
| 434 | } |
||
| 435 | } |
||
| 436 | |||
| 437 | // Show square |
||
| 438 | if ($pagenb == 1) |
||
| 439 | { |
||
| 440 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
||
| 441 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
||
| 442 | } |
||
| 443 | else |
||
| 444 | { |
||
| 445 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
||
| 446 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
||
| 447 | } |
||
| 448 | |||
| 449 | $this->_pagefoot($pdf, $object, $outputlangs); |
||
| 450 | if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
||
| 451 | |||
| 452 | $pdf->Close(); |
||
| 453 | $pdf->Output($file, 'F'); |
||
| 454 | |||
| 455 | // Add pdfgeneration hook |
||
| 456 | $hookmanager->initHooks(array('pdfgeneration')); |
||
| 457 | $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
||
| 458 | global $action; |
||
| 459 | $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
||
| 460 | if ($reshook < 0) |
||
| 461 | { |
||
| 462 | $this->error = $hookmanager->error; |
||
| 463 | $this->errors = $hookmanager->errors; |
||
| 464 | } |
||
| 465 | |||
| 466 | if (! empty($conf->global->MAIN_UMASK)) |
||
| 467 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
||
| 468 | |||
| 469 | $this->result = array('fullpath'=>$file); |
||
| 470 | |||
| 471 | return 1; |
||
| 472 | } |
||
| 473 | else |
||
| 474 | { |
||
| 475 | $this->error=$langs->trans("ErrorCanNotCreateDir", $dir); |
||
| 476 | return 0; |
||
| 477 | } |
||
| 478 | } |
||
| 479 | else |
||
| 480 | { |
||
| 481 | $this->error=$langs->trans("ErrorConstantNotDefined", "FICHEINTER_OUTPUTDIR"); |
||
| 482 | return 0; |
||
| 483 | } |
||
| 484 | } |
||
| 485 | |||
| 486 | /** |
||
| 487 | * Show table for lines |
||
| 488 | * |
||
| 489 | * @param PDF $pdf Object PDF |
||
| 490 | * @param string $tab_top Top position of table |
||
| 491 | * @param string $tab_height Height of table (rectangle) |
||
| 492 | * @param int $nexY Y |
||
| 493 | * @param Translate $outputlangs Langs object |
||
| 494 | * @param int $hidetop Hide top bar of array |
||
| 495 | * @param int $hidebottom Hide bottom bar of array |
||
| 496 | * @return void |
||
| 497 | */ |
||
| 498 | private function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0) |
||
| 499 | { |
||
| 500 | global $conf; |
||
| 501 | |||
| 502 | |||
| 503 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
||
| 504 | /* |
||
| 505 | $pdf->SetXY($this->marge_gauche, $tab_top); |
||
| 506 | $pdf->MultiCell(190,8,$outputlangs->transnoentities("Description"),0,'L',0); |
||
| 507 | $pdf->line($this->marge_gauche, $tab_top + 8, $this->page_largeur-$this->marge_droite, $tab_top + 8); |
||
| 508 | |||
| 509 | $pdf->SetFont('','', $default_font_size - 1); |
||
| 510 | |||
| 511 | $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
||
| 512 | $pdf->SetXY($this->marge_gauche, $tab_top + 8); |
||
| 513 | $text=$object->description; |
||
| 514 | if ($object->duration > 0) |
||
| 515 | { |
||
| 516 | $totaltime=convertSecondToTime($object->duration,'all',$conf->global->MAIN_DURATION_OF_WORKDAY); |
||
| 517 | $text.=($text?' - ':'').$langs->trans("Total").": ".$totaltime; |
||
| 518 | } |
||
| 519 | $desc=dol_htmlentitiesbr($text,1); |
||
| 520 | //print $outputlangs->convToOutputCharset($desc); exit; |
||
| 521 | |||
| 522 | $pdf->writeHTMLCell(180, 3, 10, $tab_top + 8, $outputlangs->convToOutputCharset($desc), 0, 1); |
||
| 523 | $nexY = $pdf->GetY(); |
||
| 524 | |||
| 525 | $pdf->line($this->marge_gauche, $nexY, $this->page_largeur-$this->marge_droite, $nexY); |
||
| 526 | |||
| 527 | $pdf->MultiCell(0, 3, ''); // Set interline to 3. Then writeMultiCell must use 3 also. |
||
| 528 | */ |
||
| 529 | |||
| 530 | // Output Rect |
||
| 531 | $this->printRect($pdf, $this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height+1, 0, 0); // Rect prend une longueur en 3eme param et 4eme param |
||
| 532 | |||
| 533 | if (empty($hidebottom)) |
||
| 534 | { |
||
| 535 | $pdf->SetXY(20, 230); |
||
| 536 | $pdf->MultiCell(66, 5, $outputlangs->transnoentities("NameAndSignatureOfInternalContact"), 0, 'L', 0); |
||
| 537 | |||
| 538 | $pdf->SetXY(20, 235); |
||
| 539 | $pdf->MultiCell(80, 25, '', 1); |
||
| 540 | |||
| 541 | $pdf->SetXY(110, 230); |
||
| 542 | $pdf->MultiCell(80, 5, $outputlangs->transnoentities("NameAndSignatureOfExternalContact"), 0, 'L', 0); |
||
| 543 | |||
| 544 | $pdf->SetXY(110, 235); |
||
| 545 | $pdf->MultiCell(80, 25, '', 1); |
||
| 546 | } |
||
| 547 | } |
||
| 548 | |||
| 549 | /** |
||
| 550 | * Show top header of page. |
||
| 551 | * |
||
| 552 | * @param PDF $pdf Object PDF |
||
| 553 | * @param Object $object Object to show |
||
| 554 | * @param int $showaddress 0=no, 1=yes |
||
| 555 | * @param Translate $outputlangs Object lang for output |
||
| 556 | * @return void |
||
| 557 | */ |
||
| 558 | private function _pagehead(&$pdf, $object, $showaddress, $outputlangs) |
||
| 722 | } |
||
| 723 | } |
||
| 724 | |||
| 725 | /** |
||
| 726 | * Show footer of page. Need this->emetteur object |
||
| 727 | * |
||
| 728 | * @param PDF $pdf PDF |
||
| 729 | * @param Object $object Object to show |
||
| 730 | * @param Translate $outputlangs Object lang for output |
||
| 731 | * @param int $hidefreetext 1=Hide free text |
||
| 732 | * @return integer |
||
| 733 | */ |
||
| 734 | private function _pagefoot(&$pdf, $object, $outputlangs, $hidefreetext = 0) |
||
| 739 | } |
||
| 740 | } |
||
| 741 |