@@ -80,8 +80,7 @@ discard block |
||
80 | 80 | } else { |
81 | 81 | return 0; |
82 | 82 | } |
83 | - } |
|
84 | - catch(Exception $e) |
|
83 | + } catch(Exception $e) |
|
85 | 84 | { |
86 | 85 | print '<!-- FirePHP not available into PHP -->'."\n"; |
87 | 86 | } |
@@ -123,11 +122,12 @@ discard block |
||
123 | 122 | if (!file_exists($conf->global->SYSLOG_FIREPHP_INCLUDEPATH . self::$firephp_class_path)) |
124 | 123 | { |
125 | 124 | $conf->global->MAIN_SYSLOG_DISABLE_FIREPHP = 1; // avoid infinite loop |
126 | - if (is_object($langs)) // $langs may not be defined yet. |
|
125 | + if (is_object($langs)) { |
|
126 | + // $langs may not be defined yet. |
|
127 | 127 | { |
128 | 128 | $errors[] = $langs->trans("ErrorFailedToOpenFile", self::$firephp_class_path); |
129 | 129 | } |
130 | - else |
|
130 | + } else |
|
131 | 131 | { |
132 | 132 | $errors[] = "ErrorFailedToOpenFile " . self::$firephp_class_path; |
133 | 133 | } |
@@ -146,10 +146,15 @@ discard block |
||
146 | 146 | { |
147 | 147 | global $conf; |
148 | 148 | |
149 | - if (! empty($conf->global->MAIN_SYSLOG_DISABLE_FIREPHP)) return; // Global option to disable output of this handler |
|
149 | + if (! empty($conf->global->MAIN_SYSLOG_DISABLE_FIREPHP)) { |
|
150 | + return; |
|
151 | + } |
|
152 | + // Global option to disable output of this handler |
|
150 | 153 | |
151 | 154 | //We check the configuration to avoid showing PHP warnings |
152 | - if (count($this->checkConfiguration())) return false; |
|
155 | + if (count($this->checkConfiguration())) { |
|
156 | + return false; |
|
157 | + } |
|
153 | 158 | |
154 | 159 | try |
155 | 160 | { |
@@ -161,12 +166,16 @@ discard block |
||
161 | 166 | set_include_path($oldinclude); |
162 | 167 | ob_start(); // To be sure headers are not flushed until all page is completely processed |
163 | 168 | $firephp = FirePHP::getInstance(true); |
164 | - if ($content['level'] == LOG_ERR) $firephp->error($content['message']); |
|
165 | - elseif ($content['level'] == LOG_WARNING) $firephp->warn($content['message']); |
|
166 | - elseif ($content['level'] == LOG_INFO) $firephp->log($content['message']); |
|
167 | - else $firephp->log($content['message']); |
|
168 | - } |
|
169 | - catch (Exception $e) |
|
169 | + if ($content['level'] == LOG_ERR) { |
|
170 | + $firephp->error($content['message']); |
|
171 | + } elseif ($content['level'] == LOG_WARNING) { |
|
172 | + $firephp->warn($content['message']); |
|
173 | + } elseif ($content['level'] == LOG_INFO) { |
|
174 | + $firephp->log($content['message']); |
|
175 | + } else { |
|
176 | + $firephp->log($content['message']); |
|
177 | + } |
|
178 | + } catch (Exception $e) |
|
170 | 179 | { |
171 | 180 | // Do not use dol_syslog here to avoid infinite loop |
172 | 181 | return false; |
@@ -326,11 +326,13 @@ |
||
326 | 326 | // Add extra fields |
327 | 327 | $sql="SELECT name, label, fieldrequired FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'adherent' AND entity IN (0,".$conf->entity.")"; |
328 | 328 | $resql=$this->db->query($sql); |
329 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
329 | + if ($resql) { |
|
330 | + // This can fail when class is used on old database (during migration for example) |
|
330 | 331 | { |
331 | 332 | while ($obj=$this->db->fetch_object($resql)) |
332 | 333 | { |
333 | 334 | $fieldname='extra.'.$obj->name; |
335 | + } |
|
334 | 336 | $fieldlabel=ucfirst($obj->label); |
335 | 337 | $this->import_fields_array[$r][$fieldname]=$fieldlabel.($obj->fieldrequired?'*':''); |
336 | 338 | } |
@@ -187,11 +187,13 @@ discard block |
||
187 | 187 | // Add extra fields |
188 | 188 | $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'societe'"; |
189 | 189 | $resql=$this->db->query($sql); |
190 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
190 | + if ($resql) { |
|
191 | + // This can fail when class is used on old database (during migration for example) |
|
191 | 192 | { |
192 | 193 | while ($obj=$this->db->fetch_object($resql)) |
193 | 194 | { |
194 | 195 | $fieldname='extra.'.$obj->name; |
196 | + } |
|
195 | 197 | $fieldlabel=ucfirst($obj->label); |
196 | 198 | $typeFilter="Text"; |
197 | 199 | switch($obj->type) |
@@ -352,11 +354,13 @@ discard block |
||
352 | 354 | // Add extra fields |
353 | 355 | $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'socpeople'"; |
354 | 356 | $resql=$this->db->query($sql); |
355 | - if ($resql) // This can fail when class is used on old database (during migration for example) |
|
357 | + if ($resql) { |
|
358 | + // This can fail when class is used on old database (during migration for example) |
|
356 | 359 | { |
357 | 360 | while ($obj=$this->db->fetch_object($resql)) |
358 | 361 | { |
359 | 362 | $fieldname='extra.'.$obj->name; |
363 | + } |
|
360 | 364 | $fieldlabel=ucfirst($obj->label); |
361 | 365 | $typeFilter="Text"; |
362 | 366 | switch($obj->type) |
@@ -311,7 +311,9 @@ |
||
311 | 311 | $multicurrency->name = $langs->cache_currencies[$conf->currency]['label'].' ('.$langs->getCurrencySymbol($conf->currency).')'; |
312 | 312 | $r = $multicurrency->create($user); |
313 | 313 | |
314 | - if ($r > 0) $multicurrency->addRate(1); |
|
314 | + if ($r > 0) { |
|
315 | + $multicurrency->addRate(1); |
|
316 | + } |
|
315 | 317 | } |
316 | 318 | } |
317 | 319 | } |
@@ -133,7 +133,10 @@ discard block |
||
133 | 133 | |
134 | 134 | // Get source company |
135 | 135 | $this->emetteur=$mysoc; |
136 | - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
136 | + if (empty($this->emetteur->country_code)) { |
|
137 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
138 | + } |
|
139 | + // By default, if was not defined |
|
137 | 140 | |
138 | 141 | // Define position of columns |
139 | 142 | $this->posxdesc=$this->marge_gauche+1; |
@@ -163,9 +166,13 @@ discard block |
||
163 | 166 | // phpcs:enable |
164 | 167 | global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes; |
165 | 168 | |
166 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
169 | + if (! is_object($outputlangs)) { |
|
170 | + $outputlangs=$langs; |
|
171 | + } |
|
167 | 172 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
168 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
173 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
174 | + $outputlangs->charset_output='ISO-8859-1'; |
|
175 | + } |
|
169 | 176 | |
170 | 177 | // Translations |
171 | 178 | $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); |
@@ -183,8 +190,7 @@ discard block |
||
183 | 190 | { |
184 | 191 | $dir = $conf->commande->dir_output; |
185 | 192 | $file = $dir . "/SPECIMEN.pdf"; |
186 | - } |
|
187 | - else |
|
193 | + } else |
|
188 | 194 | { |
189 | 195 | $objectref = dol_sanitizeFileName($object->ref); |
190 | 196 | $dir = $conf->commande->dir_output . "/" . $objectref; |
@@ -244,7 +250,9 @@ discard block |
||
244 | 250 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
245 | 251 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
246 | 252 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
247 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
253 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
254 | + $pdf->SetCompression(false); |
|
255 | + } |
|
248 | 256 | |
249 | 257 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
250 | 258 | |
@@ -268,7 +276,9 @@ discard block |
||
268 | 276 | |
269 | 277 | // New page |
270 | 278 | $pdf->AddPage(); |
271 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
279 | + if (! empty($tplidx)) { |
|
280 | + $pdf->useTemplate($tplidx); |
|
281 | + } |
|
272 | 282 | $pagenb++; |
273 | 283 | $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); |
274 | 284 | $pdf->SetFont('','', $default_font_size - 1); |
@@ -310,7 +320,9 @@ discard block |
||
310 | 320 | $salereparray=$object->thirdparty->getSalesRepresentatives($user); |
311 | 321 | $salerepobj=new User($this->db); |
312 | 322 | $salerepobj->fetch($salereparray[0]['id']); |
313 | - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
323 | + if (! empty($salerepobj->signature)) { |
|
324 | + $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
325 | + } |
|
314 | 326 | } |
315 | 327 | } |
316 | 328 | |
@@ -342,8 +354,12 @@ discard block |
||
342 | 354 | while ($pagenb < $pageposafternote) { |
343 | 355 | $pdf->AddPage(); |
344 | 356 | $pagenb++; |
345 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
346 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
357 | + if (! empty($tplidx)) { |
|
358 | + $pdf->useTemplate($tplidx); |
|
359 | + } |
|
360 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
361 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
362 | + } |
|
347 | 363 | // $this->_pagefoot($pdf,$object,$outputlangs,1); |
348 | 364 | $pdf->setTopMargin($tab_top_newpage); |
349 | 365 | // The only function to edit the bottom margin of current page to set it. |
@@ -359,9 +375,11 @@ discard block |
||
359 | 375 | |
360 | 376 | $posyafter = $pdf->GetY(); |
361 | 377 | |
362 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20))) // There is no space left for total+free text |
|
378 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+20))) { |
|
379 | + // There is no space left for total+free text |
|
363 | 380 | { |
364 | 381 | $pdf->AddPage('','',true); |
382 | + } |
|
365 | 383 | $pagenb++; |
366 | 384 | $pageposafternote++; |
367 | 385 | $pdf->setPage($pageposafternote); |
@@ -383,8 +401,7 @@ discard block |
||
383 | 401 | if($i>$pageposbeforenote){ |
384 | 402 | $height_note = $this->page_hauteur - ($tab_top_newpage + $heightforfooter); |
385 | 403 | $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note + 1); |
386 | - } |
|
387 | - else{ |
|
404 | + } else{ |
|
388 | 405 | $height_note = $this->page_hauteur - ($tab_top + $heightforfooter); |
389 | 406 | $pdf->Rect($this->marge_gauche, $tab_top-1, $tab_width, $height_note + 1); |
390 | 407 | } |
@@ -398,12 +415,15 @@ discard block |
||
398 | 415 | |
399 | 416 | // apply note frame to last page |
400 | 417 | $pdf->setPage($pageposafternote); |
401 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
402 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
418 | + if (! empty($tplidx)) { |
|
419 | + $pdf->useTemplate($tplidx); |
|
420 | + } |
|
421 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
422 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
423 | + } |
|
403 | 424 | $height_note=$posyafter-$tab_top_newpage; |
404 | 425 | $pdf->Rect($this->marge_gauche, $tab_top_newpage-1, $tab_width, $height_note+1); |
405 | - } |
|
406 | - else // No pagebreak |
|
426 | + } else // No pagebreak |
|
407 | 427 | { |
408 | 428 | $pdf->commitTransaction(); |
409 | 429 | $posyafter = $pdf->GetY(); |
@@ -418,8 +438,12 @@ discard block |
||
418 | 438 | $pagenb++; |
419 | 439 | $pageposafternote++; |
420 | 440 | $pdf->setPage($pageposafternote); |
421 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
422 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
441 | + if (! empty($tplidx)) { |
|
442 | + $pdf->useTemplate($tplidx); |
|
443 | + } |
|
444 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
445 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
446 | + } |
|
423 | 447 | |
424 | 448 | $posyafter = $tab_top_newpage; |
425 | 449 | } |
@@ -427,8 +451,7 @@ discard block |
||
427 | 451 | |
428 | 452 | $tab_height = $tab_height - $height_note; |
429 | 453 | $tab_top = $posyafter +6; |
430 | - } |
|
431 | - else |
|
454 | + } else |
|
432 | 455 | { |
433 | 456 | $height_note=0; |
434 | 457 | } |
@@ -463,32 +486,36 @@ discard block |
||
463 | 486 | $pdf->startTransaction(); |
464 | 487 | pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc); |
465 | 488 | $pageposafter=$pdf->getPage(); |
466 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
489 | + if ($pageposafter > $pageposbefore) { |
|
490 | + // There is a pagebreak |
|
467 | 491 | { |
468 | 492 | $pdf->rollbackTransaction(true); |
493 | + } |
|
469 | 494 | $pageposafter=$pageposbefore; |
470 | 495 | //print $pageposafter.'-'.$pageposbefore;exit; |
471 | 496 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
472 | 497 | pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->getColumnContentWidth('desc'),3,$this->getColumnContentXStart('desc'),$curY,$hideref,$hidedesc); |
473 | 498 | $pageposafter=$pdf->getPage(); |
474 | 499 | $posyafter=$pdf->GetY(); |
475 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
500 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
501 | + // There is no space left for total+free text |
|
476 | 502 | { |
477 | 503 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
478 | 504 | { |
479 | 505 | $pdf->AddPage('','',true); |
480 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
506 | + } |
|
507 | + if (! empty($tplidx)) { |
|
508 | + $pdf->useTemplate($tplidx); |
|
509 | + } |
|
481 | 510 | //if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
482 | 511 | $pdf->setPage($pageposafter+1); |
483 | 512 | } |
484 | - } |
|
485 | - else |
|
513 | + } else |
|
486 | 514 | { |
487 | 515 | // We found a page break |
488 | 516 | $showpricebeforepagebreak=0; |
489 | 517 | } |
490 | - } |
|
491 | - else // No pagebreak |
|
518 | + } else // No pagebreak |
|
492 | 519 | { |
493 | 520 | $pdf->commitTransaction(); |
494 | 521 | } |
@@ -573,8 +600,11 @@ discard block |
||
573 | 600 | |
574 | 601 | |
575 | 602 | // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva |
576 | - if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; |
|
577 | - else $tvaligne=$object->lines[$i]->total_tva; |
|
603 | + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) { |
|
604 | + $tvaligne=$object->lines[$i]->multicurrency_total_tva; |
|
605 | + } else { |
|
606 | + $tvaligne=$object->lines[$i]->total_tva; |
|
607 | + } |
|
578 | 608 | |
579 | 609 | $localtax1ligne=$object->lines[$i]->total_localtax1; |
580 | 610 | $localtax2ligne=$object->lines[$i]->total_localtax2; |
@@ -583,29 +613,43 @@ discard block |
||
583 | 613 | $localtax1_type=$object->lines[$i]->localtax1_type; |
584 | 614 | $localtax2_type=$object->lines[$i]->localtax2_type; |
585 | 615 | |
586 | - if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
587 | - if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
|
588 | - if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
|
616 | + if ($object->remise_percent) { |
|
617 | + $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
618 | + } |
|
619 | + if ($object->remise_percent) { |
|
620 | + $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
|
621 | + } |
|
622 | + if ($object->remise_percent) { |
|
623 | + $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
|
624 | + } |
|
589 | 625 | |
590 | 626 | $vatrate=(string) $object->lines[$i]->tva_tx; |
591 | 627 | |
592 | 628 | // Retrieve type from database for backward compatibility with old records |
593 | 629 | if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined |
594 | - && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax |
|
630 | + && (! empty($localtax1_rate) || ! empty($localtax2_rate))) { |
|
631 | + // and there is local tax |
|
595 | 632 | { |
596 | 633 | $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc); |
634 | + } |
|
597 | 635 | $localtax1_type = $localtaxtmp_array[0]; |
598 | 636 | $localtax2_type = $localtaxtmp_array[2]; |
599 | 637 | } |
600 | 638 | |
601 | 639 | // retrieve global local tax |
602 | - if ($localtax1_type && $localtax1ligne != 0) |
|
603 | - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
|
604 | - if ($localtax2_type && $localtax2ligne != 0) |
|
605 | - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
|
640 | + if ($localtax1_type && $localtax1ligne != 0) { |
|
641 | + $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
|
642 | + } |
|
643 | + if ($localtax2_type && $localtax2ligne != 0) { |
|
644 | + $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
|
645 | + } |
|
606 | 646 | |
607 | - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; |
|
608 | - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; |
|
647 | + if (($object->lines[$i]->info_bits & 0x01) == 0x01) { |
|
648 | + $vatrate.='*'; |
|
649 | + } |
|
650 | + if (! isset($this->tva[$vatrate])) { |
|
651 | + $this->tva[$vatrate]=0; |
|
652 | + } |
|
609 | 653 | $this->tva[$vatrate] += $tvaligne; |
610 | 654 | |
611 | 655 | // Add line |
@@ -627,8 +671,7 @@ discard block |
||
627 | 671 | if ($pagenb == $pageposbeforeprintlines) |
628 | 672 | { |
629 | 673 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
630 | - } |
|
631 | - else |
|
674 | + } else |
|
632 | 675 | { |
633 | 676 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
634 | 677 | } |
@@ -636,32 +679,38 @@ discard block |
||
636 | 679 | $pagenb++; |
637 | 680 | $pdf->setPage($pagenb); |
638 | 681 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
639 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
682 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
683 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
684 | + } |
|
640 | 685 | } |
641 | 686 | if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
642 | 687 | { |
643 | 688 | if ($pagenb == $pageposafter) |
644 | 689 | { |
645 | 690 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
646 | - } |
|
647 | - else |
|
691 | + } else |
|
648 | 692 | { |
649 | 693 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
650 | 694 | } |
651 | 695 | $this->_pagefoot($pdf,$object,$outputlangs,1); |
652 | 696 | // New page |
653 | 697 | $pdf->AddPage(); |
654 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
698 | + if (! empty($tplidx)) { |
|
699 | + $pdf->useTemplate($tplidx); |
|
700 | + } |
|
655 | 701 | $pagenb++; |
656 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
702 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
703 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
704 | + } |
|
657 | 705 | } |
658 | 706 | } |
659 | 707 | |
660 | 708 | // Show square |
661 | - if ($pagenb == $pageposbeforeprintlines) |
|
662 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
|
663 | - else |
|
664 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); |
|
709 | + if ($pagenb == $pageposbeforeprintlines) { |
|
710 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
|
711 | + } else { |
|
712 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); |
|
713 | + } |
|
665 | 714 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
666 | 715 | |
667 | 716 | // Affiche zone infos |
@@ -680,7 +729,9 @@ discard block |
||
680 | 729 | |
681 | 730 | // Pied de page |
682 | 731 | $this->_pagefoot($pdf, $object, $outputlangs); |
683 | - if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
732 | + if (method_exists($pdf, 'AliasNbPages')) { |
|
733 | + $pdf->AliasNbPages(); |
|
734 | + } |
|
684 | 735 | |
685 | 736 | $pdf->Close(); |
686 | 737 | |
@@ -692,20 +743,19 @@ discard block |
||
692 | 743 | global $action; |
693 | 744 | $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
694 | 745 | |
695 | - if (! empty($conf->global->MAIN_UMASK)) |
|
696 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
746 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
747 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
748 | + } |
|
697 | 749 | |
698 | 750 | $this->result = array('fullpath'=>$file); |
699 | 751 | |
700 | 752 | return 1; // Pas d'erreur |
701 | - } |
|
702 | - else |
|
753 | + } else |
|
703 | 754 | { |
704 | 755 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
705 | 756 | return 0; |
706 | 757 | } |
707 | - } |
|
708 | - else |
|
758 | + } else |
|
709 | 759 | { |
710 | 760 | $this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR"); |
711 | 761 | return 0; |
@@ -811,10 +861,11 @@ discard block |
||
811 | 861 | $pdf->MultiCell(80, 4, $dlp, 0, 'L'); |
812 | 862 | |
813 | 863 | $posy=$pdf->GetY()+1; |
814 | - } |
|
815 | - elseif ($object->availability_code || $object->availability) // Show availability conditions |
|
864 | + } elseif ($object->availability_code || $object->availability) { |
|
865 | + // Show availability conditions |
|
816 | 866 | { |
817 | 867 | $pdf->SetFont('','B', $default_font_size - 2); |
868 | + } |
|
818 | 869 | $pdf->SetXY($this->marge_gauche, $posy); |
819 | 870 | $titre = $outputlangs->transnoentities("AvailabilityPeriod").':'; |
820 | 871 | $pdf->MultiCell(80, 4, $titre, 0, 'L'); |
@@ -894,7 +945,10 @@ discard block |
||
894 | 945 | if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER)) |
895 | 946 | { |
896 | 947 | $bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account); |
897 | - if (! empty($object->fk_bank)) $bankid=$object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank |
|
948 | + if (! empty($object->fk_bank)) { |
|
949 | + $bankid=$object->fk_bank; |
|
950 | + } |
|
951 | + // For backward compatibility when object->fk_account is forced with object->fk_bank |
|
898 | 952 | $account = new Account($this->db); |
899 | 953 | $account->fetch($bankid); |
900 | 954 | |
@@ -933,10 +987,12 @@ discard block |
||
933 | 987 | |
934 | 988 | // Tableau total |
935 | 989 | $col1x = 120; $col2x = 170; |
936 | - if ($this->page_largeur < 210) // To work with US executive format |
|
990 | + if ($this->page_largeur < 210) { |
|
991 | + // To work with US executive format |
|
937 | 992 | { |
938 | 993 | $col2x-=20; |
939 | 994 | } |
995 | + } |
|
940 | 996 | $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); |
941 | 997 | |
942 | 998 | $useborder=0; |
@@ -963,22 +1019,25 @@ discard block |
||
963 | 1019 | if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) |
964 | 1020 | { |
965 | 1021 | // Nothing to do |
966 | - } |
|
967 | - else |
|
1022 | + } else |
|
968 | 1023 | { |
969 | 1024 | //Local tax 1 before VAT |
970 | 1025 | //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
971 | 1026 | //{ |
972 | 1027 | foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
973 | 1028 | { |
974 | - if (in_array((string) $localtax_type, array('1','3','5'))) continue; |
|
1029 | + if (in_array((string) $localtax_type, array('1','3','5'))) { |
|
1030 | + continue; |
|
1031 | + } |
|
975 | 1032 | foreach( $localtax_rate as $tvakey => $tvaval ) |
976 | 1033 | { |
977 | - if ($tvakey!=0) // On affiche pas taux 0 |
|
1034 | + if ($tvakey!=0) { |
|
1035 | + // On affiche pas taux 0 |
|
978 | 1036 | { |
979 | 1037 | //$this->atleastoneratenotnull++; |
980 | 1038 | |
981 | 1039 | $index++; |
1040 | + } |
|
982 | 1041 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
983 | 1042 | |
984 | 1043 | $tvacompl=''; |
@@ -1002,16 +1061,20 @@ discard block |
||
1002 | 1061 | //{ |
1003 | 1062 | foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
1004 | 1063 | { |
1005 | - if (in_array((string) $localtax_type, array('1','3','5'))) continue; |
|
1064 | + if (in_array((string) $localtax_type, array('1','3','5'))) { |
|
1065 | + continue; |
|
1066 | + } |
|
1006 | 1067 | foreach( $localtax_rate as $tvakey => $tvaval ) |
1007 | 1068 | { |
1008 | - if ($tvakey!=0) // On affiche pas taux 0 |
|
1069 | + if ($tvakey!=0) { |
|
1070 | + // On affiche pas taux 0 |
|
1009 | 1071 | { |
1010 | 1072 | //$this->atleastoneratenotnull++; |
1011 | 1073 | |
1012 | 1074 | |
1013 | 1075 | |
1014 | 1076 | $index++; |
1077 | + } |
|
1015 | 1078 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1016 | 1079 | |
1017 | 1080 | $tvacompl=''; |
@@ -1033,9 +1096,11 @@ discard block |
||
1033 | 1096 | // VAT |
1034 | 1097 | foreach($this->tva as $tvakey => $tvaval) |
1035 | 1098 | { |
1036 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1099 | + if ($tvakey != 0) { |
|
1100 | + // On affiche pas taux 0 |
|
1037 | 1101 | { |
1038 | 1102 | $this->atleastoneratenotnull++; |
1103 | + } |
|
1039 | 1104 | |
1040 | 1105 | $index++; |
1041 | 1106 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
@@ -1060,15 +1125,19 @@ discard block |
||
1060 | 1125 | //{ |
1061 | 1126 | foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
1062 | 1127 | { |
1063 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
1128 | + if (in_array((string) $localtax_type, array('2','4','6'))) { |
|
1129 | + continue; |
|
1130 | + } |
|
1064 | 1131 | |
1065 | 1132 | foreach( $localtax_rate as $tvakey => $tvaval ) |
1066 | 1133 | { |
1067 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1134 | + if ($tvakey != 0) { |
|
1135 | + // On affiche pas taux 0 |
|
1068 | 1136 | { |
1069 | 1137 | //$this->atleastoneratenotnull++; |
1070 | 1138 | |
1071 | 1139 | $index++; |
1140 | + } |
|
1072 | 1141 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1073 | 1142 | |
1074 | 1143 | $tvacompl=''; |
@@ -1092,15 +1161,19 @@ discard block |
||
1092 | 1161 | //{ |
1093 | 1162 | foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
1094 | 1163 | { |
1095 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
1164 | + if (in_array((string) $localtax_type, array('2','4','6'))) { |
|
1165 | + continue; |
|
1166 | + } |
|
1096 | 1167 | |
1097 | 1168 | foreach( $localtax_rate as $tvakey => $tvaval ) |
1098 | 1169 | { |
1099 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1170 | + if ($tvakey != 0) { |
|
1171 | + // On affiche pas taux 0 |
|
1100 | 1172 | { |
1101 | 1173 | //$this->atleastoneratenotnull++; |
1102 | 1174 | |
1103 | 1175 | $index++; |
1176 | + } |
|
1104 | 1177 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1105 | 1178 | |
1106 | 1179 | $tvacompl=''; |
@@ -1141,7 +1214,9 @@ discard block |
||
1141 | 1214 | //$depositsamount=$object->getSumDepositsUsed(); |
1142 | 1215 | //print "x".$creditnoteamount."-".$depositsamount;exit; |
1143 | 1216 | $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); |
1144 | - if (! empty($object->paye)) $resteapayer=0; |
|
1217 | + if (! empty($object->paye)) { |
|
1218 | + $resteapayer=0; |
|
1219 | + } |
|
1145 | 1220 | |
1146 | 1221 | if ($deja_regle > 0) |
1147 | 1222 | { |
@@ -1189,7 +1264,9 @@ discard block |
||
1189 | 1264 | |
1190 | 1265 | // Force to disable hidetop and hidebottom |
1191 | 1266 | $hidebottom=0; |
1192 | - if ($hidetop) $hidetop=-1; |
|
1267 | + if ($hidetop) { |
|
1268 | + $hidetop=-1; |
|
1269 | + } |
|
1193 | 1270 | |
1194 | 1271 | $currency = !empty($currency) ? $currency : $conf->currency; |
1195 | 1272 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
@@ -1205,7 +1282,9 @@ discard block |
||
1205 | 1282 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
1206 | 1283 | |
1207 | 1284 | //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; |
1208 | - 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)); |
|
1285 | + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { |
|
1286 | + $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)); |
|
1287 | + } |
|
1209 | 1288 | } |
1210 | 1289 | |
1211 | 1290 | $pdf->SetDrawColor(128,128,128); |
@@ -1217,7 +1296,9 @@ discard block |
||
1217 | 1296 | |
1218 | 1297 | foreach ($this->cols as $colKey => $colDef) |
1219 | 1298 | { |
1220 | - if(!$this->getColumnStatus($colKey)) continue; |
|
1299 | + if(!$this->getColumnStatus($colKey)) { |
|
1300 | + continue; |
|
1301 | + } |
|
1221 | 1302 | |
1222 | 1303 | // get title label |
1223 | 1304 | $colDef['title']['label'] = !empty($colDef['title']['label'])?$colDef['title']['label']:$outputlangs->transnoentities($colDef['title']['textkey']); |
@@ -1286,16 +1367,14 @@ discard block |
||
1286 | 1367 | { |
1287 | 1368 | $height=pdf_getHeightForLogo($logo); |
1288 | 1369 | $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
1289 | - } |
|
1290 | - else |
|
1370 | + } else |
|
1291 | 1371 | { |
1292 | 1372 | $pdf->SetTextColor(200,0,0); |
1293 | 1373 | $pdf->SetFont('','B', $default_font_size -2); |
1294 | 1374 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
1295 | 1375 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
1296 | 1376 | } |
1297 | - } |
|
1298 | - else |
|
1377 | + } else |
|
1299 | 1378 | { |
1300 | 1379 | $text=$this->emetteur->name; |
1301 | 1380 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -1375,7 +1454,9 @@ discard block |
||
1375 | 1454 | // Show sender |
1376 | 1455 | $posy=42+$top_shift; |
1377 | 1456 | $posx=$this->marge_gauche; |
1378 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
1457 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
1458 | + $posx=$this->page_largeur-$this->marge_droite-80; |
|
1459 | + } |
|
1379 | 1460 | $hautcadre=40; |
1380 | 1461 | |
1381 | 1462 | // Show sender frame |
@@ -1424,10 +1505,15 @@ discard block |
||
1424 | 1505 | |
1425 | 1506 | // Show recipient |
1426 | 1507 | $widthrecbox=100; |
1427 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
1508 | + if ($this->page_largeur < 210) { |
|
1509 | + $widthrecbox=84; |
|
1510 | + } |
|
1511 | + // To work with US executive format |
|
1428 | 1512 | $posy=42+$top_shift; |
1429 | 1513 | $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
1430 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1514 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
1515 | + $posx=$this->marge_gauche; |
|
1516 | + } |
|
1431 | 1517 | |
1432 | 1518 | // Show recipient frame |
1433 | 1519 | $pdf->SetTextColor(0,0,0); |
@@ -1659,12 +1745,10 @@ discard block |
||
1659 | 1745 | if ($reshook < 0) |
1660 | 1746 | { |
1661 | 1747 | setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
1662 | - } |
|
1663 | - elseif (empty($reshook)) |
|
1748 | + } elseif (empty($reshook)) |
|
1664 | 1749 | { |
1665 | 1750 | $this->cols = array_replace($this->cols, $hookmanager->resArray); // array_replace is used to preserve keys |
1666 | - } |
|
1667 | - else |
|
1751 | + } else |
|
1668 | 1752 | { |
1669 | 1753 | $this->cols = $hookmanager->resArray; |
1670 | 1754 | } |
@@ -99,7 +99,10 @@ discard block |
||
99 | 99 | |
100 | 100 | // Recupere emetteur |
101 | 101 | $this->emetteur=$mysoc; |
102 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
102 | + if (! $this->emetteur->country_code) { |
|
103 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
104 | + } |
|
105 | + // By default if not defined |
|
103 | 106 | } |
104 | 107 | |
105 | 108 | |
@@ -137,11 +140,14 @@ discard block |
||
137 | 140 | if (! $tmpdir) { |
138 | 141 | unset($listofdir[$key]); continue; |
139 | 142 | } |
140 | - if (! is_dir($tmpdir)) $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
141 | - else |
|
143 | + if (! is_dir($tmpdir)) { |
|
144 | + $texttitle.=img_warning($langs->trans("ErrorDirNotFound",$tmpdir),0); |
|
145 | + } else |
|
142 | 146 | { |
143 | 147 | $tmpfiles=dol_dir_list($tmpdir,'files',0,'\.(ods|odt)'); |
144 | - if (count($tmpfiles)) $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
148 | + if (count($tmpfiles)) { |
|
149 | + $listoffiles=array_merge($listoffiles,$tmpfiles); |
|
150 | + } |
|
145 | 151 | } |
146 | 152 | } |
147 | 153 | $texthelp=$langs->trans("ListOfDirectoriesForModelGenODT"); |
@@ -224,7 +230,9 @@ discard block |
||
224 | 230 | $hookmanager->initHooks(array('odtgeneration')); |
225 | 231 | global $action; |
226 | 232 | |
227 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
233 | + if (! is_object($outputlangs)) { |
|
234 | + $outputlangs=$langs; |
|
235 | + } |
|
228 | 236 | $sav_charset_output=$outputlangs->charset_output; |
229 | 237 | $outputlangs->charset_output='UTF-8'; |
230 | 238 | |
@@ -247,7 +255,9 @@ discard block |
||
247 | 255 | |
248 | 256 | $dir = $conf->commande->dir_output; |
249 | 257 | $objectref = dol_sanitizeFileName($object->ref); |
250 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
258 | + if (! preg_match('/specimen/i',$objectref)) { |
|
259 | + $dir.= "/" . $objectref; |
|
260 | + } |
|
251 | 261 | $file = $dir . "/" . $objectref . ".odt"; |
252 | 262 | |
253 | 263 | if (! file_exists($dir)) |
@@ -273,10 +283,11 @@ discard block |
||
273 | 283 | if ( ! empty($conf->global->MAIN_DOC_USE_TIMING)) |
274 | 284 | { |
275 | 285 | $format=$conf->global->MAIN_DOC_USE_TIMING; |
276 | - if ($format == '1') $format='%Y%m%d%H%M%S'; |
|
286 | + if ($format == '1') { |
|
287 | + $format='%Y%m%d%H%M%S'; |
|
288 | + } |
|
277 | 289 | $filename=$newfiletmp.'-'.dol_print_date(dol_now(),$format).'.'.$newfileformat; |
278 | - } |
|
279 | - else |
|
290 | + } else |
|
280 | 291 | { |
281 | 292 | $filename=$newfiletmp.'.'.$newfileformat; |
282 | 293 | } |
@@ -303,14 +314,14 @@ discard block |
||
303 | 314 | if (! empty($usecontact)) |
304 | 315 | { |
305 | 316 | // On peut utiliser le nom de la societe du contact |
306 | - if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) $socobject = $object->contact; |
|
307 | - else { |
|
317 | + if (! empty($conf->global->MAIN_USE_COMPANY_NAME_OF_CONTACT)) { |
|
318 | + $socobject = $object->contact; |
|
319 | + } else { |
|
308 | 320 | $socobject = $object->thirdparty; |
309 | 321 | // if we have a CUSTOMER contact and we dont use it as recipient we store the contact object for later use |
310 | 322 | $contactobject = $object->contact; |
311 | 323 | } |
312 | - } |
|
313 | - else |
|
324 | + } else |
|
314 | 325 | { |
315 | 326 | $socobject=$object->thirdparty; |
316 | 327 | } |
@@ -348,8 +359,7 @@ discard block |
||
348 | 359 | 'DELIMITER_RIGHT' => '}' |
349 | 360 | ) |
350 | 361 | ); |
351 | - } |
|
352 | - catch(Exception $e) |
|
362 | + } catch(Exception $e) |
|
353 | 363 | { |
354 | 364 | $this->error=$e->getMessage(); |
355 | 365 | dol_syslog($e->getMessage(), LOG_INFO); |
@@ -365,8 +375,7 @@ discard block |
||
365 | 375 | // Make substitutions into odt of freetext |
366 | 376 | try { |
367 | 377 | $odfHandler->setVars('free_text', $newfreetext, true, 'UTF-8'); |
368 | - } |
|
369 | - catch(OdfException $e) |
|
378 | + } catch(OdfException $e) |
|
370 | 379 | { |
371 | 380 | dol_syslog($e->getMessage(), LOG_INFO); |
372 | 381 | } |
@@ -381,7 +390,9 @@ discard block |
||
381 | 390 | $array_other=$this->get_substitutionarray_other($outputlangs); |
382 | 391 | // retrieve contact information for use in object as contact_xxx tags |
383 | 392 | $array_thirdparty_contact = array(); |
384 | - if ($usecontact && is_object($contactobject)) $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
393 | + if ($usecontact && is_object($contactobject)) { |
|
394 | + $array_thirdparty_contact=$this->get_substitutionarray_contact($contactobject,$outputlangs,'contact'); |
|
395 | + } |
|
385 | 396 | |
386 | 397 | $tmparray = array_merge($substitutionarray,$array_object_from_properties,$array_user,$array_soc,$array_thirdparty,$array_objet,$array_other,$array_thirdparty_contact); |
387 | 398 | complete_substitutions_array($tmparray, $outputlangs, $object); |
@@ -393,17 +404,18 @@ discard block |
||
393 | 404 | foreach($tmparray as $key=>$value) |
394 | 405 | { |
395 | 406 | try { |
396 | - if (preg_match('/logo$/',$key)) // Image |
|
407 | + if (preg_match('/logo$/',$key)) { |
|
408 | + // Image |
|
397 | 409 | { |
398 | 410 | if (file_exists($value)) $odfHandler->setImage($key, $value); |
399 | - else $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
400 | - } |
|
401 | - else // Text |
|
411 | + } else { |
|
412 | + $odfHandler->setVars($key, 'ErrorFileNotFound', true, 'UTF-8'); |
|
413 | + } |
|
414 | + } else // Text |
|
402 | 415 | { |
403 | 416 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
404 | 417 | } |
405 | - } |
|
406 | - catch(OdfException $e) |
|
418 | + } catch(OdfException $e) |
|
407 | 419 | { |
408 | 420 | dol_syslog($e->getMessage(), LOG_INFO); |
409 | 421 | } |
@@ -414,8 +426,7 @@ discard block |
||
414 | 426 | $foundtagforlines = 1; |
415 | 427 | try { |
416 | 428 | $listlines = $odfHandler->setSegment('lines'); |
417 | - } |
|
418 | - catch(OdfException $e) |
|
429 | + } catch(OdfException $e) |
|
419 | 430 | { |
420 | 431 | // We may arrive here if tags for lines not present into template |
421 | 432 | $foundtagforlines = 0; |
@@ -435,12 +446,10 @@ discard block |
||
435 | 446 | try |
436 | 447 | { |
437 | 448 | $listlines->setVars($key, $val, true, 'UTF-8'); |
438 | - } |
|
439 | - catch(OdfException $e) |
|
449 | + } catch(OdfException $e) |
|
440 | 450 | { |
441 | 451 | dol_syslog($e->getMessage(), LOG_INFO); |
442 | - } |
|
443 | - catch(SegmentException $e) |
|
452 | + } catch(SegmentException $e) |
|
444 | 453 | { |
445 | 454 | dol_syslog($e->getMessage(), LOG_INFO); |
446 | 455 | } |
@@ -449,8 +458,7 @@ discard block |
||
449 | 458 | } |
450 | 459 | $odfHandler->mergeSegment($listlines); |
451 | 460 | } |
452 | - } |
|
453 | - catch(OdfException $e) |
|
461 | + } catch(OdfException $e) |
|
454 | 462 | { |
455 | 463 | $this->error=$e->getMessage(); |
456 | 464 | dol_syslog($this->error, LOG_WARNING); |
@@ -463,8 +471,7 @@ discard block |
||
463 | 471 | { |
464 | 472 | try { |
465 | 473 | $odfHandler->setVars($key, $value, true, 'UTF-8'); |
466 | - } |
|
467 | - catch(OdfException $e) |
|
474 | + } catch(OdfException $e) |
|
468 | 475 | { |
469 | 476 | dol_syslog($e->getMessage(), LOG_INFO); |
470 | 477 | } |
@@ -479,13 +486,12 @@ discard block |
||
479 | 486 | if (!empty($conf->global->MAIN_ODT_AS_PDF)) { |
480 | 487 | try { |
481 | 488 | $odfHandler->exportAsAttachedPDF($file); |
482 | - }catch (Exception $e){ |
|
489 | + } catch (Exception $e){ |
|
483 | 490 | $this->error=$e->getMessage(); |
484 | 491 | dol_syslog($e->getMessage(), LOG_INFO); |
485 | 492 | return -1; |
486 | 493 | } |
487 | - } |
|
488 | - else { |
|
494 | + } else { |
|
489 | 495 | try { |
490 | 496 | $odfHandler->saveToDisk($file); |
491 | 497 | } catch (Exception $e) { |
@@ -498,16 +504,16 @@ discard block |
||
498 | 504 | $parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs,'substitutionarray'=>&$tmparray); |
499 | 505 | $reshook=$hookmanager->executeHooks('afterODTCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks |
500 | 506 | |
501 | - if (! empty($conf->global->MAIN_UMASK)) |
|
502 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
507 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
508 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
509 | + } |
|
503 | 510 | |
504 | 511 | $odfHandler=null; // Destroy object |
505 | 512 | |
506 | 513 | $this->result = array('fullpath'=>$file); |
507 | 514 | |
508 | 515 | return 1; // Success |
509 | - } |
|
510 | - else |
|
516 | + } else |
|
511 | 517 | { |
512 | 518 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
513 | 519 | return -1; |
@@ -164,7 +164,10 @@ discard block |
||
164 | 164 | |
165 | 165 | // Get source company |
166 | 166 | $this->emetteur=$mysoc; |
167 | - if (empty($this->emetteur->country_code)) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default, if was not defined |
|
167 | + if (empty($this->emetteur->country_code)) { |
|
168 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
169 | + } |
|
170 | + // By default, if was not defined |
|
168 | 171 | |
169 | 172 | // Define position of columns |
170 | 173 | $this->posxdesc=$this->marge_gauche+1; |
@@ -174,8 +177,7 @@ discard block |
||
174 | 177 | $this->posxup=118; |
175 | 178 | $this->posxqty=135; |
176 | 179 | $this->posxunit=151; |
177 | - } |
|
178 | - else |
|
180 | + } else |
|
179 | 181 | { |
180 | 182 | $this->posxtva=110; |
181 | 183 | $this->posxup=126; |
@@ -183,11 +185,15 @@ discard block |
||
183 | 185 | } |
184 | 186 | $this->posxdiscount=162; |
185 | 187 | $this->postotalht=174; |
186 | - if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) $this->posxtva=$this->posxup; |
|
188 | + if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) || ! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN)) { |
|
189 | + $this->posxtva=$this->posxup; |
|
190 | + } |
|
187 | 191 | $this->posxpicture=$this->posxtva - (empty($conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH)?20:$conf->global->MAIN_DOCUMENTS_WITH_PICTURE_WIDTH); // width of images |
188 | - if ($this->page_largeur < 210) // To work with US executive format |
|
192 | + if ($this->page_largeur < 210) { |
|
193 | + // To work with US executive format |
|
189 | 194 | { |
190 | 195 | $this->posxpicture-=20; |
196 | + } |
|
191 | 197 | $this->posxtva-=20; |
192 | 198 | $this->posxup-=20; |
193 | 199 | $this->posxqty-=20; |
@@ -220,9 +226,13 @@ discard block |
||
220 | 226 | // phpcs:enable |
221 | 227 | global $user, $langs, $conf, $mysoc, $db, $hookmanager, $nblignes; |
222 | 228 | |
223 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
229 | + if (! is_object($outputlangs)) { |
|
230 | + $outputlangs=$langs; |
|
231 | + } |
|
224 | 232 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
225 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
233 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
234 | + $outputlangs->charset_output='ISO-8859-1'; |
|
235 | + } |
|
226 | 236 | |
227 | 237 | // Load translation files required by the page |
228 | 238 | $outputlangs->loadLangs(array("main", "dict", "companies", "bills", "products", "orders", "deliveries")); |
@@ -240,8 +250,7 @@ discard block |
||
240 | 250 | { |
241 | 251 | $dir = $conf->commande->dir_output; |
242 | 252 | $file = $dir . "/SPECIMEN.pdf"; |
243 | - } |
|
244 | - else |
|
253 | + } else |
|
245 | 254 | { |
246 | 255 | $objectref = dol_sanitizeFileName($object->ref); |
247 | 256 | $dir = $conf->commande->dir_output . "/" . $objectref; |
@@ -278,7 +287,9 @@ discard block |
||
278 | 287 | $heightforinfotot = 40; // Height reserved to output the info and total part |
279 | 288 | $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 |
280 | 289 | $heightforfooter = $this->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
281 | - if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) $heightforfooter+= 6; |
|
290 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) { |
|
291 | + $heightforfooter+= 6; |
|
292 | + } |
|
282 | 293 | |
283 | 294 | if (class_exists('TCPDF')) |
284 | 295 | { |
@@ -302,7 +313,9 @@ discard block |
||
302 | 313 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
303 | 314 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
304 | 315 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("PdfOrderTitle")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
305 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
316 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
317 | + $pdf->SetCompression(false); |
|
318 | + } |
|
306 | 319 | |
307 | 320 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
308 | 321 | |
@@ -326,7 +339,9 @@ discard block |
||
326 | 339 | |
327 | 340 | // New page |
328 | 341 | $pdf->AddPage(); |
329 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
342 | + if (! empty($tplidx)) { |
|
343 | + $pdf->useTemplate($tplidx); |
|
344 | + } |
|
330 | 345 | $pagenb++; |
331 | 346 | $top_shift = $this->_pagehead($pdf, $object, 1, $outputlangs); |
332 | 347 | $pdf->SetFont('','', $default_font_size - 1); |
@@ -368,7 +383,9 @@ discard block |
||
368 | 383 | $salereparray=$object->thirdparty->getSalesRepresentatives($user); |
369 | 384 | $salerepobj=new User($this->db); |
370 | 385 | $salerepobj->fetch($salereparray[0]['id']); |
371 | - if (! empty($salerepobj->signature)) $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
386 | + if (! empty($salerepobj->signature)) { |
|
387 | + $notetoshow=dol_concatdesc($notetoshow, $salerepobj->signature); |
|
388 | + } |
|
372 | 389 | } |
373 | 390 | } |
374 | 391 | if ($notetoshow) |
@@ -414,32 +431,38 @@ discard block |
||
414 | 431 | $pdf->startTransaction(); |
415 | 432 | pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,3,$curX,$curY,$hideref,$hidedesc); |
416 | 433 | $pageposafter=$pdf->getPage(); |
417 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
434 | + if ($pageposafter > $pageposbefore) { |
|
435 | + // There is a pagebreak |
|
418 | 436 | { |
419 | 437 | $pdf->rollbackTransaction(true); |
438 | + } |
|
420 | 439 | $pageposafter=$pageposbefore; |
421 | 440 | //print $pageposafter.'-'.$pageposbefore;exit; |
422 | 441 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
423 | 442 | pdf_writelinedesc($pdf,$object,$i,$outputlangs,$this->posxtva-$curX,4,$curX,$curY,$hideref,$hidedesc); |
424 | 443 | $pageposafter=$pdf->getPage(); |
425 | 444 | $posyafter=$pdf->GetY(); |
426 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
445 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
446 | + // There is no space left for total+free text |
|
427 | 447 | { |
428 | 448 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
429 | 449 | { |
430 | 450 | $pdf->AddPage('','',true); |
431 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
432 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
451 | + } |
|
452 | + if (! empty($tplidx)) { |
|
453 | + $pdf->useTemplate($tplidx); |
|
454 | + } |
|
455 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
456 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
457 | + } |
|
433 | 458 | $pdf->setPage($pageposafter+1); |
434 | 459 | } |
435 | - } |
|
436 | - else |
|
460 | + } else |
|
437 | 461 | { |
438 | 462 | // We found a page break |
439 | 463 | $showpricebeforepagebreak=0; |
440 | 464 | } |
441 | - } |
|
442 | - else // No pagebreak |
|
465 | + } else // No pagebreak |
|
443 | 466 | { |
444 | 467 | $pdf->commitTransaction(); |
445 | 468 | } |
@@ -479,8 +502,7 @@ discard block |
||
479 | 502 | if($conf->global->PRODUCT_USE_UNITS) |
480 | 503 | { |
481 | 504 | $pdf->MultiCell($this->posxunit-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
482 | - } |
|
483 | - else |
|
505 | + } else |
|
484 | 506 | { |
485 | 507 | $pdf->MultiCell($this->posxdiscount-$this->posxqty-0.8, 4, $qty, 0, 'R'); |
486 | 508 | } |
@@ -508,8 +530,11 @@ discard block |
||
508 | 530 | $pdf->MultiCell($this->page_largeur-$this->marge_droite-$this->postotalht, 3, $total_excl_tax, 0, 'R', 0); |
509 | 531 | |
510 | 532 | // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva |
511 | - if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) $tvaligne=$object->lines[$i]->multicurrency_total_tva; |
|
512 | - else $tvaligne=$object->lines[$i]->total_tva; |
|
533 | + if ($conf->multicurrency->enabled && $object->multicurrency_tx != 1) { |
|
534 | + $tvaligne=$object->lines[$i]->multicurrency_total_tva; |
|
535 | + } else { |
|
536 | + $tvaligne=$object->lines[$i]->total_tva; |
|
537 | + } |
|
513 | 538 | |
514 | 539 | $localtax1ligne=$object->lines[$i]->total_localtax1; |
515 | 540 | $localtax2ligne=$object->lines[$i]->total_localtax2; |
@@ -518,29 +543,43 @@ discard block |
||
518 | 543 | $localtax1_type=$object->lines[$i]->localtax1_type; |
519 | 544 | $localtax2_type=$object->lines[$i]->localtax2_type; |
520 | 545 | |
521 | - if ($object->remise_percent) $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
522 | - if ($object->remise_percent) $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
|
523 | - if ($object->remise_percent) $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
|
546 | + if ($object->remise_percent) { |
|
547 | + $tvaligne-=($tvaligne*$object->remise_percent)/100; |
|
548 | + } |
|
549 | + if ($object->remise_percent) { |
|
550 | + $localtax1ligne-=($localtax1ligne*$object->remise_percent)/100; |
|
551 | + } |
|
552 | + if ($object->remise_percent) { |
|
553 | + $localtax2ligne-=($localtax2ligne*$object->remise_percent)/100; |
|
554 | + } |
|
524 | 555 | |
525 | 556 | $vatrate=(string) $object->lines[$i]->tva_tx; |
526 | 557 | |
527 | 558 | // Retrieve type from database for backward compatibility with old records |
528 | 559 | if ((! isset($localtax1_type) || $localtax1_type=='' || ! isset($localtax2_type) || $localtax2_type=='') // if tax type not defined |
529 | - && (! empty($localtax1_rate) || ! empty($localtax2_rate))) // and there is local tax |
|
560 | + && (! empty($localtax1_rate) || ! empty($localtax2_rate))) { |
|
561 | + // and there is local tax |
|
530 | 562 | { |
531 | 563 | $localtaxtmp_array=getLocalTaxesFromRate($vatrate,0,$object->thirdparty,$mysoc); |
564 | + } |
|
532 | 565 | $localtax1_type = $localtaxtmp_array[0]; |
533 | 566 | $localtax2_type = $localtaxtmp_array[2]; |
534 | 567 | } |
535 | 568 | |
536 | 569 | // retrieve global local tax |
537 | - if ($localtax1_type && $localtax1ligne != 0) |
|
538 | - $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
|
539 | - if ($localtax2_type && $localtax2ligne != 0) |
|
540 | - $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
|
570 | + if ($localtax1_type && $localtax1ligne != 0) { |
|
571 | + $this->localtax1[$localtax1_type][$localtax1_rate]+=$localtax1ligne; |
|
572 | + } |
|
573 | + if ($localtax2_type && $localtax2ligne != 0) { |
|
574 | + $this->localtax2[$localtax2_type][$localtax2_rate]+=$localtax2ligne; |
|
575 | + } |
|
541 | 576 | |
542 | - if (($object->lines[$i]->info_bits & 0x01) == 0x01) $vatrate.='*'; |
|
543 | - if (! isset($this->tva[$vatrate])) $this->tva[$vatrate]=0; |
|
577 | + if (($object->lines[$i]->info_bits & 0x01) == 0x01) { |
|
578 | + $vatrate.='*'; |
|
579 | + } |
|
580 | + if (! isset($this->tva[$vatrate])) { |
|
581 | + $this->tva[$vatrate]=0; |
|
582 | + } |
|
544 | 583 | $this->tva[$vatrate] += $tvaligne; |
545 | 584 | |
546 | 585 | // Add line |
@@ -562,8 +601,7 @@ discard block |
||
562 | 601 | if ($pagenb == 1) |
563 | 602 | { |
564 | 603 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
565 | - } |
|
566 | - else |
|
604 | + } else |
|
567 | 605 | { |
568 | 606 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
569 | 607 | } |
@@ -571,32 +609,38 @@ discard block |
||
571 | 609 | $pagenb++; |
572 | 610 | $pdf->setPage($pagenb); |
573 | 611 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
574 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
612 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
613 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
614 | + } |
|
575 | 615 | } |
576 | 616 | if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
577 | 617 | { |
578 | 618 | if ($pagenb == 1) |
579 | 619 | { |
580 | 620 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
581 | - } |
|
582 | - else |
|
621 | + } else |
|
583 | 622 | { |
584 | 623 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1, $object->multicurrency_code); |
585 | 624 | } |
586 | 625 | $this->_pagefoot($pdf,$object,$outputlangs,1); |
587 | 626 | // New page |
588 | 627 | $pdf->AddPage(); |
589 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
628 | + if (! empty($tplidx)) { |
|
629 | + $pdf->useTemplate($tplidx); |
|
630 | + } |
|
590 | 631 | $pagenb++; |
591 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
632 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
633 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
634 | + } |
|
592 | 635 | } |
593 | 636 | } |
594 | 637 | |
595 | 638 | // Show square |
596 | - if ($pagenb == 1) |
|
597 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
|
598 | - else |
|
599 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); |
|
639 | + if ($pagenb == 1) { |
|
640 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
|
641 | + } else { |
|
642 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0, $object->multicurrency_code); |
|
643 | + } |
|
600 | 644 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
601 | 645 | |
602 | 646 | // Affiche zone infos |
@@ -615,7 +659,9 @@ discard block |
||
615 | 659 | |
616 | 660 | // Pied de page |
617 | 661 | $this->_pagefoot($pdf, $object, $outputlangs); |
618 | - if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
662 | + if (method_exists($pdf, 'AliasNbPages')) { |
|
663 | + $pdf->AliasNbPages(); |
|
664 | + } |
|
619 | 665 | |
620 | 666 | $pdf->Close(); |
621 | 667 | |
@@ -627,20 +673,19 @@ discard block |
||
627 | 673 | global $action; |
628 | 674 | $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
629 | 675 | |
630 | - if (! empty($conf->global->MAIN_UMASK)) |
|
631 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
676 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
677 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
678 | + } |
|
632 | 679 | |
633 | 680 | $this->result = array('fullpath'=>$file); |
634 | 681 | |
635 | 682 | return 1; // Pas d'erreur |
636 | - } |
|
637 | - else |
|
683 | + } else |
|
638 | 684 | { |
639 | 685 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
640 | 686 | return 0; |
641 | 687 | } |
642 | - } |
|
643 | - else |
|
688 | + } else |
|
644 | 689 | { |
645 | 690 | $this->error=$langs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR"); |
646 | 691 | return 0; |
@@ -751,10 +796,11 @@ discard block |
||
751 | 796 | $pdf->MultiCell(80, 4, $dlp, 0, 'L'); |
752 | 797 | |
753 | 798 | $posy=$pdf->GetY()+1; |
754 | - } |
|
755 | - elseif ($object->availability_code || $object->availability) // Show availability conditions |
|
799 | + } elseif ($object->availability_code || $object->availability) { |
|
800 | + // Show availability conditions |
|
756 | 801 | { |
757 | 802 | $pdf->SetFont('','B', $default_font_size - 2); |
803 | + } |
|
758 | 804 | $pdf->SetXY($this->marge_gauche, $posy); |
759 | 805 | $titre = $outputlangs->transnoentities("AvailabilityPeriod").':'; |
760 | 806 | $pdf->MultiCell(80, 4, $titre, 0, 'L'); |
@@ -834,7 +880,10 @@ discard block |
||
834 | 880 | if (! empty($object->fk_account) || ! empty($object->fk_bank) || ! empty($conf->global->FACTURE_RIB_NUMBER)) |
835 | 881 | { |
836 | 882 | $bankid=(empty($object->fk_account)?$conf->global->FACTURE_RIB_NUMBER:$object->fk_account); |
837 | - if (! empty($object->fk_bank)) $bankid=$object->fk_bank; // For backward compatibility when object->fk_account is forced with object->fk_bank |
|
883 | + if (! empty($object->fk_bank)) { |
|
884 | + $bankid=$object->fk_bank; |
|
885 | + } |
|
886 | + // For backward compatibility when object->fk_account is forced with object->fk_bank |
|
838 | 887 | $account = new Account($this->db); |
839 | 888 | $account->fetch($bankid); |
840 | 889 | |
@@ -875,10 +924,12 @@ discard block |
||
875 | 924 | |
876 | 925 | // Tableau total |
877 | 926 | $col1x = 120; $col2x = 170; |
878 | - if ($this->page_largeur < 210) // To work with US executive format |
|
927 | + if ($this->page_largeur < 210) { |
|
928 | + // To work with US executive format |
|
879 | 929 | { |
880 | 930 | $col2x-=20; |
881 | 931 | } |
932 | + } |
|
882 | 933 | $largcol2 = ($this->page_largeur - $this->marge_droite - $col2x); |
883 | 934 | |
884 | 935 | $useborder=0; |
@@ -905,22 +956,25 @@ discard block |
||
905 | 956 | if (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_IFNULL) && $tvaisnull) |
906 | 957 | { |
907 | 958 | // Nothing to do |
908 | - } |
|
909 | - else |
|
959 | + } else |
|
910 | 960 | { |
911 | 961 | //Local tax 1 before VAT |
912 | 962 | //if (! empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) && $conf->global->FACTURE_LOCAL_TAX1_OPTION=='localtax1on') |
913 | 963 | //{ |
914 | 964 | foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
915 | 965 | { |
916 | - if (in_array((string) $localtax_type, array('1','3','5'))) continue; |
|
966 | + if (in_array((string) $localtax_type, array('1','3','5'))) { |
|
967 | + continue; |
|
968 | + } |
|
917 | 969 | foreach( $localtax_rate as $tvakey => $tvaval ) |
918 | 970 | { |
919 | - if ($tvakey!=0) // On affiche pas taux 0 |
|
971 | + if ($tvakey!=0) { |
|
972 | + // On affiche pas taux 0 |
|
920 | 973 | { |
921 | 974 | //$this->atleastoneratenotnull++; |
922 | 975 | |
923 | 976 | $index++; |
977 | + } |
|
924 | 978 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
925 | 979 | |
926 | 980 | $tvacompl=''; |
@@ -944,16 +998,20 @@ discard block |
||
944 | 998 | //{ |
945 | 999 | foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
946 | 1000 | { |
947 | - if (in_array((string) $localtax_type, array('1','3','5'))) continue; |
|
1001 | + if (in_array((string) $localtax_type, array('1','3','5'))) { |
|
1002 | + continue; |
|
1003 | + } |
|
948 | 1004 | foreach( $localtax_rate as $tvakey => $tvaval ) |
949 | 1005 | { |
950 | - if ($tvakey!=0) // On affiche pas taux 0 |
|
1006 | + if ($tvakey!=0) { |
|
1007 | + // On affiche pas taux 0 |
|
951 | 1008 | { |
952 | 1009 | //$this->atleastoneratenotnull++; |
953 | 1010 | |
954 | 1011 | |
955 | 1012 | |
956 | 1013 | $index++; |
1014 | + } |
|
957 | 1015 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
958 | 1016 | |
959 | 1017 | $tvacompl=''; |
@@ -975,9 +1033,11 @@ discard block |
||
975 | 1033 | // VAT |
976 | 1034 | foreach($this->tva as $tvakey => $tvaval) |
977 | 1035 | { |
978 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1036 | + if ($tvakey != 0) { |
|
1037 | + // On affiche pas taux 0 |
|
979 | 1038 | { |
980 | 1039 | $this->atleastoneratenotnull++; |
1040 | + } |
|
981 | 1041 | |
982 | 1042 | $index++; |
983 | 1043 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
@@ -1002,15 +1062,19 @@ discard block |
||
1002 | 1062 | //{ |
1003 | 1063 | foreach( $this->localtax1 as $localtax_type => $localtax_rate ) |
1004 | 1064 | { |
1005 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
1065 | + if (in_array((string) $localtax_type, array('2','4','6'))) { |
|
1066 | + continue; |
|
1067 | + } |
|
1006 | 1068 | |
1007 | 1069 | foreach( $localtax_rate as $tvakey => $tvaval ) |
1008 | 1070 | { |
1009 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1071 | + if ($tvakey != 0) { |
|
1072 | + // On affiche pas taux 0 |
|
1010 | 1073 | { |
1011 | 1074 | //$this->atleastoneratenotnull++; |
1012 | 1075 | |
1013 | 1076 | $index++; |
1077 | + } |
|
1014 | 1078 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1015 | 1079 | |
1016 | 1080 | $tvacompl=''; |
@@ -1034,15 +1098,19 @@ discard block |
||
1034 | 1098 | //{ |
1035 | 1099 | foreach( $this->localtax2 as $localtax_type => $localtax_rate ) |
1036 | 1100 | { |
1037 | - if (in_array((string) $localtax_type, array('2','4','6'))) continue; |
|
1101 | + if (in_array((string) $localtax_type, array('2','4','6'))) { |
|
1102 | + continue; |
|
1103 | + } |
|
1038 | 1104 | |
1039 | 1105 | foreach( $localtax_rate as $tvakey => $tvaval ) |
1040 | 1106 | { |
1041 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1107 | + if ($tvakey != 0) { |
|
1108 | + // On affiche pas taux 0 |
|
1042 | 1109 | { |
1043 | 1110 | //$this->atleastoneratenotnull++; |
1044 | 1111 | |
1045 | 1112 | $index++; |
1113 | + } |
|
1046 | 1114 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
1047 | 1115 | |
1048 | 1116 | $tvacompl=''; |
@@ -1083,7 +1151,9 @@ discard block |
||
1083 | 1151 | //$depositsamount=$object->getSumDepositsUsed(); |
1084 | 1152 | //print "x".$creditnoteamount."-".$depositsamount;exit; |
1085 | 1153 | $resteapayer = price2num($total_ttc - $deja_regle - $creditnoteamount - $depositsamount, 'MT'); |
1086 | - if (! empty($object->paye)) $resteapayer=0; |
|
1154 | + if (! empty($object->paye)) { |
|
1155 | + $resteapayer=0; |
|
1156 | + } |
|
1087 | 1157 | |
1088 | 1158 | if ($deja_regle > 0) |
1089 | 1159 | { |
@@ -1131,7 +1201,9 @@ discard block |
||
1131 | 1201 | |
1132 | 1202 | // Force to disable hidetop and hidebottom |
1133 | 1203 | $hidebottom=0; |
1134 | - if ($hidetop) $hidetop=-1; |
|
1204 | + if ($hidetop) { |
|
1205 | + $hidetop=-1; |
|
1206 | + } |
|
1135 | 1207 | |
1136 | 1208 | $currency = !empty($currency) ? $currency : $conf->currency; |
1137 | 1209 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
@@ -1147,7 +1219,9 @@ discard block |
||
1147 | 1219 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
1148 | 1220 | |
1149 | 1221 | //$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR='230,230,230'; |
1150 | - 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)); |
|
1222 | + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { |
|
1223 | + $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)); |
|
1224 | + } |
|
1151 | 1225 | } |
1152 | 1226 | |
1153 | 1227 | $pdf->SetDrawColor(128,128,128); |
@@ -1188,8 +1262,7 @@ discard block |
||
1188 | 1262 | if($conf->global->PRODUCT_USE_UNITS) |
1189 | 1263 | { |
1190 | 1264 | $pdf->MultiCell($this->posxunit-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
1191 | - } |
|
1192 | - else |
|
1265 | + } else |
|
1193 | 1266 | { |
1194 | 1267 | $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); |
1195 | 1268 | } |
@@ -1270,16 +1343,14 @@ discard block |
||
1270 | 1343 | { |
1271 | 1344 | $height=pdf_getHeightForLogo($logo); |
1272 | 1345 | $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
1273 | - } |
|
1274 | - else |
|
1346 | + } else |
|
1275 | 1347 | { |
1276 | 1348 | $pdf->SetTextColor(200,0,0); |
1277 | 1349 | $pdf->SetFont('','B', $default_font_size -2); |
1278 | 1350 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
1279 | 1351 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
1280 | 1352 | } |
1281 | - } |
|
1282 | - else |
|
1353 | + } else |
|
1283 | 1354 | { |
1284 | 1355 | $text=$this->emetteur->name; |
1285 | 1356 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -1359,7 +1430,9 @@ discard block |
||
1359 | 1430 | // Show sender |
1360 | 1431 | $posy=42+$top_shift; |
1361 | 1432 | $posx=$this->marge_gauche; |
1362 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->page_largeur-$this->marge_droite-80; |
|
1433 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
1434 | + $posx=$this->page_largeur-$this->marge_droite-80; |
|
1435 | + } |
|
1363 | 1436 | $hautcadre=40; |
1364 | 1437 | |
1365 | 1438 | // Show sender frame |
@@ -1408,10 +1481,15 @@ discard block |
||
1408 | 1481 | |
1409 | 1482 | // Show recipient |
1410 | 1483 | $widthrecbox=100; |
1411 | - if ($this->page_largeur < 210) $widthrecbox=84; // To work with US executive format |
|
1484 | + if ($this->page_largeur < 210) { |
|
1485 | + $widthrecbox=84; |
|
1486 | + } |
|
1487 | + // To work with US executive format |
|
1412 | 1488 | $posy=42+$top_shift; |
1413 | 1489 | $posx=$this->page_largeur-$this->marge_droite-$widthrecbox; |
1414 | - if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) $posx=$this->marge_gauche; |
|
1490 | + if (! empty($conf->global->MAIN_INVERT_SENDER_RECIPIENT)) { |
|
1491 | + $posx=$this->marge_gauche; |
|
1492 | + } |
|
1415 | 1493 | |
1416 | 1494 | // Show recipient frame |
1417 | 1495 | $pdf->SetTextColor(0,0,0); |
@@ -134,10 +134,12 @@ discard block |
||
134 | 134 | if ($resql) |
135 | 135 | { |
136 | 136 | $obj = $db->fetch_object($resql); |
137 | - if ($obj) $max = intval($obj->max); |
|
138 | - else $max=0; |
|
139 | - } |
|
140 | - else |
|
137 | + if ($obj) { |
|
138 | + $max = intval($obj->max); |
|
139 | + } else { |
|
140 | + $max=0; |
|
141 | + } |
|
142 | + } else |
|
141 | 143 | { |
142 | 144 | dol_syslog("mod_commande_marbre::getNextValue", LOG_DEBUG); |
143 | 145 | return -1; |
@@ -147,8 +149,13 @@ discard block |
||
147 | 149 | $date=$object->date; |
148 | 150 | $yymm = strftime("%y%m",$date); |
149 | 151 | |
150 | - if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
151 | - else $num = sprintf("%04s", $max+1); |
|
152 | + if ($max >= (pow(10, 4) - 1)) { |
|
153 | + $num=$max+1; |
|
154 | + } |
|
155 | + // If counter > 9999, we do not format on 4 chars, we take number as it is |
|
156 | + else { |
|
157 | + $num = sprintf("%04s", $max+1); |
|
158 | + } |
|
152 | 159 | |
153 | 160 | dol_syslog("mod_commande_marbre::getNextValue return ".$this->prefix.$yymm."-".$num); |
154 | 161 | return $this->prefix.$yymm."-".$num; |
@@ -144,7 +144,10 @@ discard block |
||
144 | 144 | |
145 | 145 | // Recupere emmetteur |
146 | 146 | $this->emetteur=$mysoc; |
147 | - if (! $this->emetteur->country_code) $this->emetteur->country_code=substr($langs->defaultlang,-2); // By default if not defined |
|
147 | + if (! $this->emetteur->country_code) { |
|
148 | + $this->emetteur->country_code=substr($langs->defaultlang,-2); |
|
149 | + } |
|
150 | + // By default if not defined |
|
148 | 151 | |
149 | 152 | // Defini position des colonnes |
150 | 153 | $this->posxref=$this->marge_gauche+1; |
@@ -153,9 +156,11 @@ discard block |
||
153 | 156 | $this->posxprogress=$this->marge_gauche+140; |
154 | 157 | $this->posxdatestart=$this->marge_gauche+152; |
155 | 158 | $this->posxdateend=$this->marge_gauche+170; |
156 | - if ($this->page_largeur < 210) // To work with US executive format |
|
159 | + if ($this->page_largeur < 210) { |
|
160 | + // To work with US executive format |
|
157 | 161 | { |
158 | 162 | $this->posxref-=20; |
163 | + } |
|
159 | 164 | $this->posxlabel-=20; |
160 | 165 | $this->posxworkload-=20; |
161 | 166 | $this->posxprogress-=20; |
@@ -178,9 +183,13 @@ discard block |
||
178 | 183 | // phpcs:enable |
179 | 184 | global $conf, $hookmanager, $langs, $user; |
180 | 185 | |
181 | - if (! is_object($outputlangs)) $outputlangs=$langs; |
|
186 | + if (! is_object($outputlangs)) { |
|
187 | + $outputlangs=$langs; |
|
188 | + } |
|
182 | 189 | // For backward compatibility with FPDF, force output charset to ISO, because FPDF expect text to be encoded in ISO |
183 | - if (! empty($conf->global->MAIN_USE_FPDF)) $outputlangs->charset_output='ISO-8859-1'; |
|
190 | + if (! empty($conf->global->MAIN_USE_FPDF)) { |
|
191 | + $outputlangs->charset_output='ISO-8859-1'; |
|
192 | + } |
|
184 | 193 | |
185 | 194 | // Load traductions files requiredby by page |
186 | 195 | $outputlangs->loadLangs(array("main", "dict", "companies", "projects")); |
@@ -191,7 +200,9 @@ discard block |
||
191 | 200 | |
192 | 201 | $objectref = dol_sanitizeFileName($object->ref); |
193 | 202 | $dir = $conf->projet->dir_output; |
194 | - if (! preg_match('/specimen/i',$objectref)) $dir.= "/" . $objectref; |
|
203 | + if (! preg_match('/specimen/i',$objectref)) { |
|
204 | + $dir.= "/" . $objectref; |
|
205 | + } |
|
195 | 206 | $file = $dir . "/" . $objectref . ".pdf"; |
196 | 207 | |
197 | 208 | if (! file_exists($dir)) |
@@ -224,7 +235,9 @@ discard block |
||
224 | 235 | $heightforinfotot = 40; // Height reserved to output the info and total part |
225 | 236 | $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 | 237 | $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; |
|
238 | + if ($conf->global->MAIN_GENERATE_DOCUMENTS_SHOW_FOOT_DETAILS >0) { |
|
239 | + $heightforfooter+= 6; |
|
240 | + } |
|
228 | 241 | |
229 | 242 | if (class_exists('TCPDF')) |
230 | 243 | { |
@@ -243,10 +256,12 @@ discard block |
||
243 | 256 | $task = new Task($this->db); |
244 | 257 | $tasksarray = $task->getTasksArray(0,0,$object->id); |
245 | 258 | |
246 | - if (! $object->id > 0) // Special case when used with object = specimen, we may return all lines |
|
259 | + if (! $object->id > 0) { |
|
260 | + // Special case when used with object = specimen, we may return all lines |
|
247 | 261 | { |
248 | 262 | $tasksarray=array_slice($tasksarray, 0, min(5, count($tasksarray))); |
249 | 263 | } |
264 | + } |
|
250 | 265 | |
251 | 266 | $object->lines=$tasksarray; |
252 | 267 | $nblignes=count($object->lines); |
@@ -260,13 +275,17 @@ discard block |
||
260 | 275 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
261 | 276 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
262 | 277 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("Project")); |
263 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
278 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
279 | + $pdf->SetCompression(false); |
|
280 | + } |
|
264 | 281 | |
265 | 282 | $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
266 | 283 | |
267 | 284 | // New page |
268 | 285 | $pdf->AddPage(); |
269 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
286 | + if (! empty($tplidx)) { |
|
287 | + $pdf->useTemplate($tplidx); |
|
288 | + } |
|
270 | 289 | $pagenb++; |
271 | 290 | $this->_pagehead($pdf, $object, 1, $outputlangs); |
272 | 291 | $pdf->SetFont('','', $default_font_size - 1); |
@@ -299,8 +318,7 @@ discard block |
||
299 | 318 | |
300 | 319 | $tab_height = $tab_height - $height_note; |
301 | 320 | $tab_top = $nexY+6; |
302 | - } |
|
303 | - else |
|
321 | + } else |
|
304 | 322 | { |
305 | 323 | $height_note=0; |
306 | 324 | } |
@@ -336,9 +354,11 @@ discard block |
||
336 | 354 | $pdf->SetXY($this->posxlabel, $curY); |
337 | 355 | $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); |
338 | 356 | $pageposafter=$pdf->getPage(); |
339 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
357 | + if ($pageposafter > $pageposbefore) { |
|
358 | + // There is a pagebreak |
|
340 | 359 | { |
341 | 360 | $pdf->rollbackTransaction(true); |
361 | + } |
|
342 | 362 | $pageposafter=$pageposbefore; |
343 | 363 | //print $pageposafter.'-'.$pageposbefore;exit; |
344 | 364 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
@@ -348,17 +368,22 @@ discard block |
||
348 | 368 | $pdf->MultiCell($this->posxworkload-$this->posxlabel, 3, $outputlangs->convToOutputCharset($libelleline), 0, 'L'); |
349 | 369 | $pageposafter=$pdf->getPage(); |
350 | 370 | $posyafter=$pdf->GetY(); |
351 | - if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) // There is no space left for total+free text |
|
371 | + if ($posyafter > ($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))) { |
|
372 | + // There is no space left for total+free text |
|
352 | 373 | { |
353 | 374 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
354 | 375 | { |
355 | 376 | $pdf->AddPage('','',true); |
356 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
357 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
377 | + } |
|
378 | + if (! empty($tplidx)) { |
|
379 | + $pdf->useTemplate($tplidx); |
|
380 | + } |
|
381 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
382 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
383 | + } |
|
358 | 384 | $pdf->setPage($pageposafter+1); |
359 | 385 | } |
360 | - } |
|
361 | - else |
|
386 | + } else |
|
362 | 387 | { |
363 | 388 | // We found a page break |
364 | 389 | $showpricebeforepagebreak=0; |
@@ -370,8 +395,12 @@ discard block |
||
370 | 395 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
371 | 396 | |
372 | 397 | $pdf->AddPage('','',true); |
373 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
374 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
398 | + if (! empty($tplidx)) { |
|
399 | + $pdf->useTemplate($tplidx); |
|
400 | + } |
|
401 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
402 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
403 | + } |
|
375 | 404 | $pdf->setPage($pageposafter+1); |
376 | 405 | $pdf->SetFont('','', $default_font_size - 1); // On repositionne la police par defaut |
377 | 406 | $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
@@ -389,8 +418,7 @@ discard block |
||
389 | 418 | } |
390 | 419 | } |
391 | 420 | //var_dump($i.' '.$posybefore.' '.$posyafter.' '.($this->page_hauteur - ($heightforfooter + $heightforfreetext + $heightforinfotot)).' '.$showpricebeforepagebreak); |
392 | - } |
|
393 | - else // No pagebreak |
|
421 | + } else // No pagebreak |
|
394 | 422 | { |
395 | 423 | $pdf->commitTransaction(); |
396 | 424 | } |
@@ -444,8 +472,7 @@ discard block |
||
444 | 472 | if ($pagenb == 1) |
445 | 473 | { |
446 | 474 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
447 | - } |
|
448 | - else |
|
475 | + } else |
|
449 | 476 | { |
450 | 477 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
451 | 478 | } |
@@ -453,37 +480,45 @@ discard block |
||
453 | 480 | $pagenb++; |
454 | 481 | $pdf->setPage($pagenb); |
455 | 482 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
456 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
483 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
484 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
485 | + } |
|
457 | 486 | } |
458 | 487 | if (isset($object->lines[$i+1]->pagebreak) && $object->lines[$i+1]->pagebreak) |
459 | 488 | { |
460 | 489 | if ($pagenb == 1) |
461 | 490 | { |
462 | 491 | $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1); |
463 | - } |
|
464 | - else |
|
492 | + } else |
|
465 | 493 | { |
466 | 494 | $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, 1, 1); |
467 | 495 | } |
468 | 496 | $this->_pagefoot($pdf,$object,$outputlangs,1); |
469 | 497 | // New page |
470 | 498 | $pdf->AddPage(); |
471 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
499 | + if (! empty($tplidx)) { |
|
500 | + $pdf->useTemplate($tplidx); |
|
501 | + } |
|
472 | 502 | $pagenb++; |
473 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
503 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
504 | + $this->_pagehead($pdf, $object, 0, $outputlangs); |
|
505 | + } |
|
474 | 506 | } |
475 | 507 | } |
476 | 508 | |
477 | 509 | // Show square |
478 | - if ($pagenb == 1) |
|
479 | - $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
480 | - else |
|
481 | - $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
510 | + if ($pagenb == 1) { |
|
511 | + $this->_tableau($pdf, $tab_top, $this->page_hauteur - $tab_top - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 0, 0); |
|
512 | + } else { |
|
513 | + $this->_tableau($pdf, $tab_top_newpage, $this->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfreetext - $heightforfooter, 0, $outputlangs, 1, 0); |
|
514 | + } |
|
482 | 515 | $bottomlasttab=$this->page_hauteur - $heightforinfotot - $heightforfreetext - $heightforfooter + 1; |
483 | 516 | |
484 | 517 | // Pied de page |
485 | 518 | $this->_pagefoot($pdf, $object, $outputlangs); |
486 | - if (method_exists($pdf, 'AliasNbPages')) $pdf->AliasNbPages(); |
|
519 | + if (method_exists($pdf, 'AliasNbPages')) { |
|
520 | + $pdf->AliasNbPages(); |
|
521 | + } |
|
487 | 522 | |
488 | 523 | $pdf->Close(); |
489 | 524 | |
@@ -495,20 +530,19 @@ discard block |
||
495 | 530 | global $action; |
496 | 531 | $reshook=$hookmanager->executeHooks('afterPDFCreation', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
497 | 532 | |
498 | - if (! empty($conf->global->MAIN_UMASK)) |
|
499 | - @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
533 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
534 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
535 | + } |
|
500 | 536 | |
501 | 537 | $this->result = array('fullpath'=>$file); |
502 | 538 | |
503 | 539 | return 1; // Pas d'erreur |
504 | - } |
|
505 | - else |
|
540 | + } else |
|
506 | 541 | { |
507 | 542 | $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); |
508 | 543 | return 0; |
509 | 544 | } |
510 | - } |
|
511 | - else |
|
545 | + } else |
|
512 | 546 | { |
513 | 547 | $this->error=$langs->transnoentities("ErrorConstantNotDefined","PROJECT_OUTPUTDIR"); |
514 | 548 | return 0; |
@@ -599,16 +633,16 @@ discard block |
||
599 | 633 | { |
600 | 634 | $height=pdf_getHeightForLogo($logo); |
601 | 635 | $pdf->Image($logo, $this->marge_gauche, $posy, 0, $height); // width=0 (auto) |
602 | - } |
|
603 | - else |
|
636 | + } else |
|
604 | 637 | { |
605 | 638 | $pdf->SetTextColor(200,0,0); |
606 | 639 | $pdf->SetFont('','B', $default_font_size - 2); |
607 | 640 | $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
608 | 641 | $pdf->MultiCell(100, 3, $langs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); |
609 | 642 | } |
643 | + } else { |
|
644 | + $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
|
610 | 645 | } |
611 | - else $pdf->MultiCell(100, 4, $outputlangs->transnoentities($this->emetteur->name), 0, 'L'); |
|
612 | 646 | |
613 | 647 | $pdf->SetFont('','B', $default_font_size + 3); |
614 | 648 | $pdf->SetXY($posx,$posy); |