Conditions | 98 |
Total Lines | 512 |
Code Lines | 293 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
142 | function write_file($object,$outputlangs,$srctemplatepath='',$hidedetails=0,$hidedesc=0,$hideref=0) |
||
143 | { |
||
144 | global $user,$langs,$conf,$mysoc,$db,$hookmanager; |
||
145 | |||
146 | if (! is_object($outputlangs)) $outputlangs=$langs; |
||
147 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
||
148 | if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
||
149 | |||
150 | $outputlangs->load("main"); |
||
151 | $outputlangs->load("dict"); |
||
152 | $outputlangs->load("companies"); |
||
153 | $outputlangs->load("bills"); |
||
154 | $outputlangs->load("products"); |
||
155 | $outputlangs->load("orders"); |
||
156 | $outputlangs->load("deliveries"); |
||
157 | |||
158 | $nblignes = count($object->lines); |
||
159 | |||
160 | if ($conf->commande->dir_output) |
||
161 | { |
||
162 | $object->fetch_thirdparty(); |
||
163 | if(!empty($object->client) ){ |
||
164 | $object->thirdparty = $object->client; |
||
165 | } |
||
166 | $deja_regle = ""; |
||
167 | |||
168 | // Definition of $dir and $file |
||
169 | if ($object->specimen) |
||
170 | { |
||
171 | $dir = $conf->commande->dir_output; |
||
172 | $file = $dir . "/SPECIMEN.pdf"; |
||
173 | } |
||
174 | else |
||
175 | { |
||
176 | $objectref = dol_sanitizeFileName($object->ref); |
||
177 | $dir = $conf->commande->dir_output . "/" . $objectref; |
||
178 | $file = $dir . "/" . $objectref . ".pdf"; |
||
179 | } |
||
180 | |||
181 | if (! file_exists($dir)) |
||
182 | { |
||
183 | if (dol_mkdir($dir) < 0) |
||
184 | { |
||
185 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
||
186 | return 0; |
||
187 | } |
||
188 | } |
||
189 | |||
190 | if (file_exists($dir)) |
||
191 | { |
||
192 | // Add pdfgeneration hook |
||
193 | if (! is_object($hookmanager)) |
||
194 | { |
||
195 | include_once DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php'; |
||
196 | $hookmanager=new HookManager($this->db); |
||
197 | } |
||
198 | $hookmanager->initHooks(array('pdfgeneration')); |
||
199 | $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
||
200 | global $action; |
||
201 | $reshook=$hookmanager->executeHooks('beforePDFCreation',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks |
||
202 | |||
203 | // Create pdf instance |
||
204 | $pdf=pdf_getInstance($this->format); |
||
205 | $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
||
206 | $heightforinfotot = 50; // Height reserved to output the info and total part |
||
207 | $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 |
||
208 | $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
||
209 | $pdf->SetAutoPageBreak(1,0); |
||
210 | |||
211 | if (class_exists('TCPDF')) |
||
212 | { |
||
213 | $pdf->setPrintHeader(false); |
||
214 | $pdf->setPrintFooter(false); |
||
215 | } |
||
216 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
||
217 | // Set path to the background PDF File |
||
218 | if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
||
219 | { |
||
220 | $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); |
||
221 | $tplidx = $pdf->importPage(1); |
||
222 | } |
||
223 | |||
224 | $pdf->Open(); |
||
225 | $pagenb=0; |
||
226 | $pdf->SetDrawColor(128,128,128); |
||
227 | |||
228 | $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
||
229 | $pdf->SetSubject($outputlangs->transnoentities("Order")); |
||
230 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
||
231 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
||
232 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Order")); |
||
233 | if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
||
234 | |||
235 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
||
236 | |||
237 | // Positionne $this->atleastonediscount si on a au moins une remise |
||
238 | for ($i = 0 ; $i < $nblignes ; $i++) |
||
239 | { |
||
240 | if ($object->lines[$i]->remise_percent) |
||
241 | { |
||
242 | $this->atleastonediscount++; |
||
243 | } |
||
244 | } |
||
245 | if (empty($this->atleastonediscount)) |
||
246 | { |
||
247 | $this->posxpicture+=($this->postotalht - $this->posxdiscount); |
||
248 | $this->posxtva+=($this->postotalht - $this->posxdiscount); |
||
249 | $this->posxup+=($this->postotalht - $this->posxdiscount); |
||
250 | $this->posxqty+=($this->postotalht - $this->posxdiscount); |
||
251 | $this->posxdiscount+=($this->postotalht - $this->posxdiscount); |
||
252 | //$this->postotalht; |
||
253 | } |
||
254 | |||
255 | // New page |
||
256 | $pdf->AddPage(); |
||
257 | if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
||
258 | $pagenb++; |
||
259 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
||
260 | $pdf->SetFont('','', $default_font_size - 1); |
||
261 | $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
||
262 | $pdf->SetTextColor(0,0,0); |
||
263 | |||
264 | |||
265 | $tab_top = 90; |
||
266 | $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?42:10); |
||
267 | $tab_height = 130; |
||
268 | $tab_height_newpage = 150; |
||
269 | |||
270 | // Affiche notes |
||
271 | $notetoshow=empty($object->note_public)?'':$object->note_public; |
||
272 | if (! empty($conf->global->MAIN_ADD_SALE_REP_SIGNATURE_IN_NOTE)) |
||
273 | { |
||
274 | // Get first sale rep |
||
275 | if (is_object($object->thirdparty)) |
||
276 | { |
||
277 | $salereparray=$object->thirdparty->getSalesRepresentatives($user); |
||
278 | $salerepobj=new User($this->db); |
||
279 | $salerepobj->fetch($salereparray[0]['id']); |
||
280 | if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
||
281 | } |
||
282 | } |
||
283 | if ($notetoshow) |
||
284 | { |
||
285 | $tab_top = 88; |
||
286 | |||
287 | $pdf->SetFont('','', $default_font_size - 1); |
||
288 | $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($notetoshow), 0, 1); |
||
289 | $nexY = $pdf->GetY(); |
||
290 | $height_note=$nexY-$tab_top; |
||
291 | |||
292 | // Rect prend une longueur en 3eme param |
||
293 | $pdf->SetDrawColor(192,192,192); |
||
294 | $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); |
||
295 | |||
296 | $tab_height = $tab_height - $height_note; |
||
297 | $tab_top = $nexY+6; |
||
298 | } |
||
299 | else |
||
300 | { |
||
301 | $height_note=0; |
||
302 | } |
||
303 | |||
304 | $iniY = $tab_top + 7; |
||
305 | $curY = $tab_top + 7; |
||
306 | $nexY = $tab_top + 7; |
||
307 | |||
308 | $inPackage = false; |
||
309 | $TPackageInfos = array(); |
||
310 | $TChilds = array(); |
||
311 | $package_qty = 0; |
||
312 | $TStack = array(); |
||
313 | |||
314 | // Loop on each lines |
||
315 | for ($i = 0 ; $i < $nblignes ; $i++) |
||
316 | { |
||
317 | $package_qty = $TStack[count($TStack) - 1]['package_qty']; |
||
318 | $inPackage = count($TStack) > 0; |
||
319 | |||
320 | // Ligne de titre |
||
321 | if ($object->lines[$i]->product_type == 9 && $object->lines[$i]->qty < 97 && $object->lines[$i]->fk_product > 0) { |
||
322 | $inPackage = true; |
||
323 | |||
324 | if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) { |
||
325 | if (!empty($object->lines[$i]->fk_product)) { |
||
326 | $product = new Product($db); |
||
327 | $product->fetch($object->lines[$i]->fk_product); |
||
328 | |||
329 | $TChilds = $product->getChildsArbo($product->id); |
||
330 | |||
331 | $TStack[count($TStack)] = array( |
||
332 | 'childs' => $TChilds, |
||
333 | 'package' => array(), |
||
334 | 'package_qty' => 0 |
||
335 | ); |
||
336 | |||
337 | // Si on se trouvait déjà dans un package, on rajoute ce produit à la liste des produits |
||
338 | // du précédent package |
||
339 | if (count($TStack) > 1) { |
||
340 | $TStack[count($TStack) - 2]['package'][$object->lines[$i]->fk_product] += $object->lines[$i]->qty; |
||
341 | } |
||
342 | } |
||
343 | } |
||
344 | } |
||
345 | |||
346 | if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) { |
||
347 | if ($inPackage && $object->lines[$i]->product_type != 9 && $object->lines[$i]->fk_product > 0) { |
||
348 | $TStack[count($TStack) - 1]['package'][$object->lines[$i]->fk_product] += $object->lines[$i]->qty; |
||
349 | } |
||
350 | } |
||
351 | |||
352 | // Ligne de sous-total |
||
353 | if ($inPackage && $object->lines[$i]->product_type == 9 && $object->lines[$i]->qty >= 97) { |
||
354 | if (count($TStack) <= 1) { |
||
355 | $inPackage = false; |
||
356 | } |
||
357 | |||
358 | if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES) { |
||
359 | // Comparaison pour déterminer la quantité de package |
||
360 | $TProducts = array_keys($TStack[count($TStack) - 1]['package']); |
||
361 | $TProductsChilds = array_keys($TStack[count($TStack) - 1]['childs']); |
||
362 | |||
363 | if ($TProductsChilds == $TProducts) { |
||
364 | // Il s'agit d'un package |
||
365 | // On récupére la quantité |
||
366 | $first_child_id = $TProducts[0]; |
||
367 | $document_qty = $TStack[count($TStack) - 1]['package'][$first_child_id]; |
||
368 | $base_qty = $TStack[count($TStack) - 1]['childs'][$first_child_id][1]; |
||
369 | |||
370 | $TStack[count($TStack) - 1]['package_qty'] = $document_qty / $base_qty; |
||
371 | $package_qty = $TStack[count($TStack) - 1]['package_qty']; |
||
372 | } |
||
373 | |||
374 | array_pop($TStack); |
||
375 | } |
||
376 | } |
||
377 | |||
378 | $curY = $nexY; |
||
379 | $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
||
380 | $pdf->SetTextColor(0,0,0); |
||
381 | |||
382 | $pdf->setTopMargin($tab_top_newpage); |
||
383 | $pdf->setPageOrientation('', 1, $heightforfooter+$heightforfreetext+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
||
384 | $pageposbefore=$pdf->getPage(); |
||
385 | |||
386 | // Description of product line |
||
387 | $curX = $this->posxdesc-1; |
||
388 | |||
389 | $showpricebeforepagebreak=1; |
||
390 | |||
391 | $pdf->startTransaction(); |
||
392 | pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc); |
||
393 | $pageposafter=$pdf->getPage(); |
||
394 | if ($pageposafter > $pageposbefore) // There is a pagebreak |
||
395 | { |
||
396 | $pdf->rollbackTransaction(true); |
||
397 | $pageposafter=$pageposbefore; |
||
398 | //print $pageposafter.'-'.$pageposbefore;exit; |
||
399 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
||
400 | pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc); |
||
401 | $pageposafter=$pdf->getPage(); |
||
402 | $posyafter=$pdf->GetY(); |
||
403 | if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
||
404 | { |
||
405 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
||
406 | { |
||
407 | $pdf->AddPage('','',true); |
||
408 | if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
||
409 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
||
410 | $pdf->setPage($pageposafter+1); |
||
411 | } |
||
412 | } |
||
413 | else |
||
414 | { |
||
415 | // We found a page break |
||
416 | $showpricebeforepagebreak=0; |
||
417 | } |
||
418 | } |
||
419 | else // No pagebreak |
||
420 | { |
||
421 | $pdf->commitTransaction(); |
||
422 | } |
||
423 | |||
424 | $nexY = $pdf->GetY(); |
||
425 | $pageposafter=$pdf->getPage(); |
||
426 | $pdf->setPage($pageposbefore); |
||
427 | $pdf->setTopMargin($this->marge_haute); |
||
428 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
||
429 | |||
430 | // We suppose that a too long description is moved completely on next page |
||
431 | if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
||
432 | $pdf->setPage($pageposafter); $curY = $tab_top_newpage; |
||
433 | } |
||
434 | |||
435 | $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
||
436 | |||
437 | // VAT Rate |
||
438 | if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT)) |
||
439 | { |
||
440 | // Si on ne doit masquer que les sous-produits |
||
441 | if ($hidedetails && !$inPackage && $conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES) { |
||
442 | $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, 0); |
||
443 | } else { |
||
444 | $vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails); |
||
445 | } |
||
446 | |||
447 | $pdf->SetXY($this->posxtva, $curY); |
||
448 | $pdf->MultiCell($this->posxup-$this->posxtva-0.8, 3, $vat_rate, 0, 'R'); |
||
449 | } |
||
450 | |||
451 | // Unit price before discount |
||
452 | if ($hidedetails && !$inPackage && $conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES) { |
||
453 | $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, 0); |
||
454 | } else { |
||
455 | $up_excl_tax = pdf_getlineupexcltax($object, $i, $outputlangs, $hidedetails); |
||
456 | } |
||
457 | |||
458 | $pdf->SetXY($this->posxup, $curY); |
||
459 | $pdf->MultiCell($this->posxqty-$this->posxup-0.8, 3, $up_excl_tax, 0, 'R', 0); |
||
460 | |||
461 | // Booléen pour déterminer s'il s'agit d'une ligne de titre ou non |
||
462 | $isTitle = false; |
||
463 | |||
464 | // Quantity |
||
465 | // Récupération de la quantité à afficher |
||
466 | if ($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY) { |
||
467 | if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES && $package_qty > 0) { |
||
468 | $qty = $package_qty; |
||
469 | } else { |
||
470 | $qty = pdf_getlineqty($object, $i, $outputlangs, 0); |
||
471 | } |
||
472 | } else { |
||
473 | if ($conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES && $package_qty > 0) { |
||
474 | $qty = $package_qty; |
||
475 | } else { |
||
476 | $qty = pdf_getlineqty($object, $i, $outputlangs, $hidedetails); |
||
477 | } |
||
478 | } |
||
479 | |||
480 | $pdf->SetXY($this->posxqty, $curY); |
||
481 | $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 3, $qty, 0, 'R'); // Enough for 6 chars |
||
482 | |||
483 | // Discount on line |
||
484 | if ($object->lines[$i]->remise_percent) |
||
485 | { |
||
486 | $pdf->SetXY($this->posxdiscount-2, $curY); |
||
487 | $remise_percent = pdf_getlineremisepercent($object, $i, $outputlangs, $hidedetails); |
||
488 | $pdf->MultiCell($this->postotalht-$this->posxdiscount+2, 3, $remise_percent, 0, 'R'); |
||
489 | } |
||
490 | |||
491 | // Total HT line |
||
492 | if ($hidedetails && !$inPackage && $conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES) { |
||
493 | $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, 0); |
||
494 | } else { |
||
495 | $total_excl_tax = pdf_getlinetotalexcltax($object, $i, $outputlangs, $hidedetails); |
||
496 | } |
||
497 | |||
498 | $pdf->SetXY($this->postotalht, $curY); |
||
499 | $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); |
||
500 | |||
501 | // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva |
||
502 | $tvaligne=doubleval($object->lines[$i]->total_tva); |
||
503 | |||
504 | $localtax1ligne=$object->lines[$i]->total_localtax1; |
||
505 | $localtax2ligne=$object->lines[$i]->total_localtax2; |
||
506 | $localtax1_rate=$object->lines[$i]->localtax1_tx; |
||
507 | $localtax2_rate=$object->lines[$i]->localtax2_tx; |
||
508 | $localtax1_type=$object->lines[$i]->localtax1_type; |
||
509 | $localtax2_type=$object->lines[$i]->localtax2_type; |
||
510 | |||
511 | if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; |
||
512 | if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
||
513 | if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
||
514 | |||
515 | $vatrate=(string) $object->lines[$i]->tva_tx; |
||
516 | |||
517 | // Retrieve type from database for backward compatibility with old records |
||
518 | if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined |
||
519 | && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax |
||
520 | { |
||
521 | $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc); |
||
522 | $localtax1_type = $localtaxtmp_array[0]; |
||
523 | $localtax2_type = $localtaxtmp_array[2]; |
||
524 | } |
||
525 | |||
526 | // retrieve global local tax |
||
527 | if ($localtax1_type && $localtax1ligne != 0) |
||
528 | $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
||
529 | if ($localtax2_type && $localtax2ligne != 0) |
||
530 | $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
||
531 | |||
532 | if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; |
||
533 | if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; |
||
534 | |||
535 | if (!empty($object->lines[$i]->TTotal_tva)) |
||
536 | { |
||
537 | foreach ($object->lines[$i]->TTotal_tva as $vatrate => $tvaligne) |
||
538 | { |
||
539 | $this->tva[$vatrate] += $tvaligne; |
||
540 | } |
||
541 | } |
||
542 | else { |
||
543 | // standard |
||
544 | if(!empty($tvaligne)) $this->tva[$vatrate] += $tvaligne; |
||
545 | } |
||
546 | |||
547 | // Add line |
||
548 | if (! empty($conf->global->MAIN_PDF_DASH_BETWEEN_LINES) && $i < ($nblignes - 1)) |
||
549 | { |
||
550 | $pdf->setPage($pageposafter); |
||
551 | $pdf->SetLineStyle(array('dash'=>'1,1','color'=>array(210,210,210))); |
||
552 | //$pdf->SetDrawColor(190,190,200); |
||
553 | $pdf->line($this->marge_gauche, $nexY+1, $this->page_largeur - $this->marge_droite, $nexY+1); |
||
554 | $pdf->SetLineStyle(array('dash'=>0)); |
||
555 | } |
||
556 | |||
557 | $nexY+=2; // Passe espace entre les lignes |
||
558 | |||
559 | // Detect if some page were added automatically and output _tableau for past pages |
||
560 | while ($pagenb < $pageposafter) |
||
561 | { |
||
562 | $pdf->setPage($pagenb); |
||
563 | if ($pagenb == 1) |
||
564 | { |
||
565 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
||
566 | } |
||
567 | else |
||
568 | { |
||
569 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
||
570 | } |
||
571 | $this->_pagefoot($pdf,$object,$outputlangs,1); |
||
572 | $pagenb++; |
||
573 | $pdf->setPage($pagenb); |
||
574 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
||
575 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
||
576 | } |
||
577 | if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
||
578 | { |
||
579 | if ($pagenb == 1) |
||
580 | { |
||
581 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
||
582 | } |
||
583 | else |
||
584 | { |
||
585 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
||
586 | } |
||
587 | $this->_pagefoot($pdf,$object,$outputlangs,1); |
||
588 | // New page |
||
589 | $pdf->AddPage(); |
||
590 | if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
||
591 | $pagenb++; |
||
592 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
||
593 | } |
||
594 | } |
||
595 | |||
596 | // Show square |
||
597 | if ($pagenb == 1) |
||
598 | { |
||
599 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
||
600 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
||
601 | } |
||
602 | else |
||
603 | { |
||
604 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
||
605 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
||
606 | } |
||
607 | |||
608 | // Affiche zone infos |
||
609 | $posy=$this->_tableau_info($pdf, $object, $bottomlasttab, $outputlangs); |
||
610 | |||
611 | if (!$conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL) { |
||
612 | // Affiche zone totaux |
||
613 | $posy=$this->_tableau_tot($pdf, $object, $deja_regle, $bottomlasttab, $outputlangs); |
||
614 | } |
||
615 | |||
616 | // Affiche zone versements |
||
617 | if ($deja_regle) |
||
618 | { |
||
619 | $posy=$this->_tableau_versements($pdf, $object, $posy, $outputlangs); |
||
620 | } |
||
621 | |||
622 | // Pied de page |
||
623 | $this->_pagefoot($pdf,$object,$outputlangs); |
||
624 | if (method_exists($pdf,'AliasNbPages')) $pdf->AliasNbPages(); |
||
625 | |||
626 | $pdf->Close(); |
||
627 | |||
628 | $pdf->Output($file,'F'); |
||
629 | |||
630 | // Add pdfgeneration hook |
||
631 | $hookmanager->initHooks(array('pdfgeneration')); |
||
632 | $parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs); |
||
633 | global $action; |
||
634 | $reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
||
635 | |||
636 | if (! empty($conf->global->MAIN_UMASK)) |
||
637 | @chmod($file, octdec($conf->global->MAIN_UMASK)); |
||
638 | |||
639 | return 1; // Pas d'erreur |
||
640 | } |
||
641 | else |
||
642 | { |
||
643 | $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); |
||
644 | return 0; |
||
645 | } |
||
646 | } |
||
647 | else |
||
648 | { |
||
649 | $this->error=$langs->trans("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR"); |
||
650 | return 0; |
||
651 | } |
||
652 | $this->error=$langs->trans("ErrorUnknown"); |
||
653 | return 0; // Erreur par defaut |
||
654 | } |
||
1405 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.