@@ -39,10 +39,10 @@ discard block |
||
| 39 | 39 | * @var $object Facture fournisseur |
| 40 | 40 | */ |
| 41 | 41 | else if($object->element=='invoice_supplier') { |
| 42 | - $object->special_code = TSubtotal::$module_number; |
|
| 43 | - $rang = $object->line_max() + 1; |
|
| 44 | - if($qty==50) $res = $object->addline($desc,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang); |
|
| 45 | - else $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang); |
|
| 42 | + $object->special_code = TSubtotal::$module_number; |
|
| 43 | + $rang = $object->line_max() + 1; |
|
| 44 | + if($qty==50) $res = $object->addline($desc,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang); |
|
| 45 | + else $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang); |
|
| 46 | 46 | } |
| 47 | 47 | /** |
| 48 | 48 | * @var $object Propal |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | * @var $object Commande fournisseur |
| 62 | 62 | */ |
| 63 | 63 | else if($object->element=='order_supplier') { |
| 64 | - $object->special_code = TSubtotal::$module_number; |
|
| 65 | - $res = $object->addline($label, 0,$qty,0,0,0,0,0,'',0,'HT', 0, 9); |
|
| 64 | + $object->special_code = TSubtotal::$module_number; |
|
| 65 | + $res = $object->addline($label, 0,$qty,0,0,0,0,0,'',0,'HT', 0, 9); |
|
| 66 | 66 | } |
| 67 | 67 | /** |
| 68 | 68 | * @var $object Facturerec |
@@ -368,10 +368,10 @@ discard block |
||
| 368 | 368 | |
| 369 | 369 | public static function isSubtotal(&$line, $level=-1) |
| 370 | 370 | { |
| 371 | - $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90; |
|
| 372 | - if($res && $level > -1) { |
|
| 373 | - return self::getNiveau($line) == $level; |
|
| 374 | - } else return $res; |
|
| 371 | + $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90; |
|
| 372 | + if($res && $level > -1) { |
|
| 373 | + return self::getNiveau($line) == $level; |
|
| 374 | + } else return $res; |
|
| 375 | 375 | } |
| 376 | 376 | |
| 377 | 377 | public static function isFreeText(&$line) |
@@ -408,16 +408,16 @@ discard block |
||
| 408 | 408 | $createRight = $user->rights->{$object->element}->creer; |
| 409 | 409 | if($object->element == 'facturerec' ) |
| 410 | 410 | { |
| 411 | - $object->statut = 0; // hack for facture rec |
|
| 412 | - $createRight = $user->rights->facture->creer; |
|
| 411 | + $object->statut = 0; // hack for facture rec |
|
| 412 | + $createRight = $user->rights->facture->creer; |
|
| 413 | 413 | } |
| 414 | 414 | elseif($object->element == 'order_supplier' ) |
| 415 | 415 | { |
| 416 | - $createRight = $user->rights->fournisseur->commande->creer; |
|
| 416 | + $createRight = $user->rights->fournisseur->commande->creer; |
|
| 417 | 417 | } |
| 418 | 418 | elseif($object->element == 'invoice_supplier' ) |
| 419 | 419 | { |
| 420 | - $createRight = $user->rights->fournisseur->facture->creer; |
|
| 420 | + $createRight = $user->rights->fournisseur->facture->creer; |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK)) |
@@ -442,8 +442,8 @@ discard block |
||
| 442 | 442 | break; |
| 443 | 443 | |
| 444 | 444 | case 'supplier_proposal': |
| 445 | - $res = $object->addline($line->desc, $line->subprice, $line->qty, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, $line->remise_percent, 'HT', 0, $line->info_bits, $line->product_type, -1, $line->special_code, 0, 0, $line->pa_ht, $line->label, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->origin, $line->origin_id); |
|
| 446 | - break; |
|
| 445 | + $res = $object->addline($line->desc, $line->subprice, $line->qty, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, $line->remise_percent, 'HT', 0, $line->info_bits, $line->product_type, -1, $line->special_code, 0, 0, $line->pa_ht, $line->label, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->origin, $line->origin_id); |
|
| 446 | + break; |
|
| 447 | 447 | |
| 448 | 448 | case 'commande': |
| 449 | 449 | //$desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0) |
@@ -451,10 +451,10 @@ discard block |
||
| 451 | 451 | break; |
| 452 | 452 | |
| 453 | 453 | case 'order_supplier': |
| 454 | - $object->line = $line; |
|
| 455 | - $object->line->fk_commande = $object->id; |
|
| 456 | - $object->line->rang = $object->line_max() +1; |
|
| 457 | - $res = $object->line->insert(1); |
|
| 454 | + $object->line = $line; |
|
| 455 | + $object->line->fk_commande = $object->id; |
|
| 456 | + $object->line->rang = $object->line_max() +1; |
|
| 457 | + $res = $object->line->insert(1); |
|
| 458 | 458 | break; |
| 459 | 459 | |
| 460 | 460 | case 'facture': |
@@ -507,8 +507,8 @@ discard block |
||
| 507 | 507 | $object->db->commit(); |
| 508 | 508 | foreach ($TLineAdded as &$line) |
| 509 | 509 | { |
| 510 | - // ça peut paraitre non optimisé de déclancher la fonction sur toutes les lignes mais ceci est nécessaire pour réappliquer l'état exact de chaque ligne |
|
| 511 | - _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']); |
|
| 510 | + // ça peut paraitre non optimisé de déclancher la fonction sur toutes les lignes mais ceci est nécessaire pour réappliquer l'état exact de chaque ligne |
|
| 511 | + _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']); |
|
| 512 | 512 | } |
| 513 | 513 | return count($TLineAdded); |
| 514 | 514 | } |
@@ -582,33 +582,33 @@ discard block |
||
| 582 | 582 | |
| 583 | 583 | switch ($object->element) |
| 584 | 584 | { |
| 585 | - case 'propal': |
|
| 586 | - $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $date_start, $date_end, $array_options, $fk_unit, 0, $notrigger); |
|
| 587 | - break; |
|
| 585 | + case 'propal': |
|
| 586 | + $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $date_start, $date_end, $array_options, $fk_unit, 0, $notrigger); |
|
| 587 | + break; |
|
| 588 | 588 | |
| 589 | - case 'supplier_proposal': |
|
| 590 | - $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $array_options,'', $fk_unit); |
|
| 591 | - break; |
|
| 589 | + case 'supplier_proposal': |
|
| 590 | + $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $array_options,'', $fk_unit); |
|
| 591 | + break; |
|
| 592 | 592 | |
| 593 | 593 | case 'commande': |
| 594 | 594 | $res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $date_start, $date_end, $type, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $special_code, $array_options, $fk_unit, 0, $notrigger); |
| 595 | 595 | break; |
| 596 | 596 | |
| 597 | 597 | case 'order_supplier': |
| 598 | - $object->special_code = SELF::$module_number; |
|
| 599 | - if (empty($desc)) $desc = $label; |
|
| 600 | - $res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, 0, $date_start, $date_end, $array_options, $fk_unit); |
|
| 601 | - break; |
|
| 598 | + $object->special_code = SELF::$module_number; |
|
| 599 | + if (empty($desc)) $desc = $label; |
|
| 600 | + $res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, 0, $date_start, $date_end, $array_options, $fk_unit); |
|
| 601 | + break; |
|
| 602 | 602 | |
| 603 | 603 | case 'facture': |
| 604 | 604 | $res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $special_code, $array_options, $situation_percent, $fk_unit, 0, $notrigger); |
| 605 | 605 | break; |
| 606 | 606 | |
| 607 | 607 | case 'invoice_supplier': |
| 608 | - $object->special_code = SELF::$module_number; |
|
| 609 | - if (empty($desc)) $desc = $label; |
|
| 610 | - $res = $object->updateline($rowid, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, 0, $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $fk_unit); |
|
| 611 | - break; |
|
| 608 | + $object->special_code = SELF::$module_number; |
|
| 609 | + if (empty($desc)) $desc = $label; |
|
| 610 | + $res = $object->updateline($rowid, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, 0, $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $fk_unit); |
|
| 611 | + break; |
|
| 612 | 612 | |
| 613 | 613 | case 'facturerec': |
| 614 | 614 | // Add extrafields and get rang |
@@ -999,8 +999,8 @@ discard block |
||
| 999 | 999 | { |
| 1000 | 1000 | if (is_readable($logo)) |
| 1001 | 1001 | { |
| 1002 | - $height=pdf_getHeightForLogo($logo); |
|
| 1003 | - $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
| 1002 | + $height=pdf_getHeightForLogo($logo); |
|
| 1003 | + $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
| 1004 | 1004 | } |
| 1005 | 1005 | else |
| 1006 | 1006 | { |
@@ -1191,13 +1191,13 @@ discard block |
||
| 1191 | 1191 | * @param int $hidebottom Hide bottom |
| 1192 | 1192 | * @return void |
| 1193 | 1193 | */ |
| 1194 | - private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
|
| 1195 | - { |
|
| 1196 | - if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
| 1197 | - $pdf->line($x+$l, $y, $x+$l, $y+$h); |
|
| 1198 | - if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
| 1199 | - $pdf->line($x, $y+$h, $x, $y); |
|
| 1200 | - } |
|
| 1194 | + private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
|
| 1195 | + { |
|
| 1196 | + if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
| 1197 | + $pdf->line($x+$l, $y, $x+$l, $y+$h); |
|
| 1198 | + if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
| 1199 | + $pdf->line($x, $y+$h, $x, $y); |
|
| 1200 | + } |
|
| 1201 | 1201 | |
| 1202 | 1202 | |
| 1203 | 1203 | public static function concat(&$outputlangs, $files, $fileoutput='') |
@@ -1207,14 +1207,14 @@ discard block |
||
| 1207 | 1207 | if (empty($fileoutput)) $fileoutput = $file[0]; |
| 1208 | 1208 | |
| 1209 | 1209 | $pdf=pdf_getInstance(); |
| 1210 | - if (class_exists('TCPDF')) |
|
| 1211 | - { |
|
| 1212 | - $pdf->setPrintHeader(false); |
|
| 1213 | - $pdf->setPrintFooter(false); |
|
| 1214 | - } |
|
| 1215 | - $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
|
| 1210 | + if (class_exists('TCPDF')) |
|
| 1211 | + { |
|
| 1212 | + $pdf->setPrintHeader(false); |
|
| 1213 | + $pdf->setPrintFooter(false); |
|
| 1214 | + } |
|
| 1215 | + $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
|
| 1216 | 1216 | |
| 1217 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 1217 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 1218 | 1218 | |
| 1219 | 1219 | |
| 1220 | 1220 | foreach($files as $file) |
@@ -5,28 +5,28 @@ discard block |
||
| 5 | 5 | |
| 6 | 6 | static $module_number = 104777; |
| 7 | 7 | |
| 8 | - static function addSubTotalLine(&$object, $label, $qty, $rang=-1) { |
|
| 8 | + static function addSubTotalLine(&$object, $label, $qty, $rang = -1) { |
|
| 9 | 9 | |
| 10 | 10 | $res = 0; |
| 11 | 11 | |
| 12 | - if( (float)DOL_VERSION <= 3.4 ) { |
|
| 12 | + if ((float) DOL_VERSION <= 3.4) { |
|
| 13 | 13 | /** |
| 14 | 14 | * @var $object Facture |
| 15 | 15 | */ |
| 16 | - if($object->element=='facture') $res = $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number); |
|
| 16 | + if ($object->element == 'facture') $res = $object->addline($object->id, $label, 0, $qty, 0, 0, 0, 0, 0, '', '', 0, 0, '', 'HT', 0, 9, -1, TSubtotal::$module_number); |
|
| 17 | 17 | /** |
| 18 | 18 | * @var $object Propal |
| 19 | 19 | */ |
| 20 | - else if($object->element=='propal') $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number); |
|
| 20 | + else if ($object->element == 'propal') $res = $object->addline($object->id, $label, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, -1, TSubtotal::$module_number); |
|
| 21 | 21 | /** |
| 22 | 22 | * @var $object Commande |
| 23 | 23 | */ |
| 24 | - else if($object->element=='commande') $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number); |
|
| 24 | + else if ($object->element == 'commande') $res = $object->addline($object->id, $label, 0, $qty, 0, 0, 0, 0, 0, 0, 0, 'HT', 0, '', '', 9, -1, TSubtotal::$module_number); |
|
| 25 | 25 | |
| 26 | 26 | } |
| 27 | 27 | else { |
| 28 | 28 | $desc = ''; |
| 29 | - if ((float) DOL_VERSION < 6 || $qty==50) { |
|
| 29 | + if ((float) DOL_VERSION < 6 || $qty == 50) { |
|
| 30 | 30 | $desc = $label; |
| 31 | 31 | $label = ''; |
| 32 | 32 | } |
@@ -34,40 +34,40 @@ discard block |
||
| 34 | 34 | /** |
| 35 | 35 | * @var $object Facture |
| 36 | 36 | */ |
| 37 | - if($object->element=='facture') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,$rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label); |
|
| 37 | + if ($object->element == 'facture') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, '', '', 0, 0, '', 'HT', 0, 9, $rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label); |
|
| 38 | 38 | /** |
| 39 | 39 | * @var $object Facture fournisseur |
| 40 | 40 | */ |
| 41 | - else if($object->element=='invoice_supplier') { |
|
| 41 | + else if ($object->element == 'invoice_supplier') { |
|
| 42 | 42 | $object->special_code = TSubtotal::$module_number; |
| 43 | 43 | $rang = $object->line_max() + 1; |
| 44 | - if($qty==50) $res = $object->addline($desc,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang); |
|
| 45 | - else $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang); |
|
| 44 | + if ($qty == 50) $res = $object->addline($desc, 0, 0, 0, 0, $qty, 0, 0, '', '', 0, 0, 'HT', 9, $rang); |
|
| 45 | + else $res = $object->addline($label, 0, 0, 0, 0, $qty, 0, 0, '', '', 0, 0, 'HT', 9, $rang); |
|
| 46 | 46 | } |
| 47 | 47 | /** |
| 48 | 48 | * @var $object Propal |
| 49 | 49 | */ |
| 50 | - else if($object->element=='propal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
| 50 | + else if ($object->element == 'propal') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, $rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
| 51 | 51 | /** |
| 52 | 52 | * @var $object Propal Fournisseur |
| 53 | 53 | */ |
| 54 | - else if($object->element=='supplier_proposal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
| 54 | + else if ($object->element == 'supplier_proposal') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, $rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * @var $object Commande |
| 58 | 58 | */ |
| 59 | - else if($object->element=='commande') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label); |
|
| 59 | + else if ($object->element == 'commande') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 0, 0, 'HT', 0, '', '', 9, $rang, TSubtotal::$module_number, 0, null, 0, $label); |
|
| 60 | 60 | /** |
| 61 | 61 | * @var $object Commande fournisseur |
| 62 | 62 | */ |
| 63 | - else if($object->element=='order_supplier') { |
|
| 63 | + else if ($object->element == 'order_supplier') { |
|
| 64 | 64 | $object->special_code = TSubtotal::$module_number; |
| 65 | - $res = $object->addline($label, 0,$qty,0,0,0,0,0,'',0,'HT', 0, 9); |
|
| 65 | + $res = $object->addline($label, 0, $qty, 0, 0, 0, 0, 0, '', 0, 'HT', 0, 9); |
|
| 66 | 66 | } |
| 67 | 67 | /** |
| 68 | 68 | * @var $object Facturerec |
| 69 | 69 | */ |
| 70 | - else if($object->element=='facturerec') $res = $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label); |
|
| 70 | + else if ($object->element == 'facturerec') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number, $label); |
|
| 71 | 71 | |
| 72 | 72 | } |
| 73 | 73 | |
@@ -78,20 +78,20 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | public static function generateDoc(&$object) |
| 80 | 80 | { |
| 81 | - global $conf,$langs,$db; |
|
| 81 | + global $conf, $langs, $db; |
|
| 82 | 82 | |
| 83 | 83 | if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) |
| 84 | 84 | { |
| 85 | - $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); |
|
| 86 | - $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); |
|
| 87 | - $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); |
|
| 85 | + $hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); |
|
| 86 | + $hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); |
|
| 87 | + $hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); |
|
| 88 | 88 | |
| 89 | 89 | // Define output language |
| 90 | 90 | $outputlangs = $langs; |
| 91 | 91 | $newlang = GETPOST('lang_id', 'alpha'); |
| 92 | - if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) |
|
| 92 | + if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) |
|
| 93 | 93 | $newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang; |
| 94 | - if (! empty($newlang)) { |
|
| 94 | + if (!empty($newlang)) { |
|
| 95 | 95 | $outputlangs = new Translate("", $conf); |
| 96 | 96 | $outputlangs->setDefaultLang($newlang); |
| 97 | 97 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | } |
| 106 | 106 | else |
| 107 | 107 | { |
| 108 | - if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 108 | + if ($object->element != 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 109 | 109 | } |
| 110 | 110 | } |
| 111 | 111 | } |
@@ -117,11 +117,11 @@ discard block |
||
| 117 | 117 | * @param type $rang_start |
| 118 | 118 | * @param type $move_to |
| 119 | 119 | */ |
| 120 | - public static function updateRang(&$object, $rang_start, $move_to=1) |
|
| 120 | + public static function updateRang(&$object, $rang_start, $move_to = 1) |
|
| 121 | 121 | { |
| 122 | 122 | if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
| 123 | 123 | |
| 124 | - $row=new GenericObject($object->db); |
|
| 124 | + $row = new GenericObject($object->db); |
|
| 125 | 125 | $row->table_element_line = $object->table_element_line; |
| 126 | 126 | $row->fk_element = $object->fk_element; |
| 127 | 127 | $row->id = $object->id; |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | { |
| 131 | 131 | if ($line->rang < $rang_start) continue; |
| 132 | 132 | |
| 133 | - $row->updateRangOfLine($line->id, $line->rang+$move_to); |
|
| 133 | + $row->updateRangOfLine($line->id, $line->rang + $move_to); |
|
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | { |
| 160 | 160 | if ($rang_to_add != -1) self::updateRang($object, $rang_to_add); |
| 161 | 161 | |
| 162 | - self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add); |
|
| 162 | + self::addSubTotalLine($object, $langs->trans('SubTotal'), 100 - $title_niveau, $rang_to_add); |
|
| 163 | 163 | |
| 164 | 164 | $object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas) |
| 165 | 165 | if ($rang_to_add != -1) |
@@ -171,14 +171,14 @@ discard block |
||
| 171 | 171 | } |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | - public static function addTitle(&$object, $label, $level, $rang=-1) |
|
| 174 | + public static function addTitle(&$object, $label, $level, $rang = -1) |
|
| 175 | 175 | { |
| 176 | 176 | self::addSubTotalLine($object, $label, $level, $rang); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - public static function addTotal(&$object, $label, $level, $rang=-1) |
|
| 179 | + public static function addTotal(&$object, $label, $level, $rang = -1) |
|
| 180 | 180 | { |
| 181 | - self::addSubTotalLine($object, $label, (100-$level), $rang); |
|
| 181 | + self::addSubTotalLine($object, $label, (100 - $level), $rang); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
@@ -189,7 +189,7 @@ discard block |
||
| 189 | 189 | * |
| 190 | 190 | * @return array |
| 191 | 191 | */ |
| 192 | - public static function getAllTitleWithoutTotalFromDocument(&$object, $get_block_total=false) |
|
| 192 | + public static function getAllTitleWithoutTotalFromDocument(&$object, $get_block_total = false) |
|
| 193 | 193 | { |
| 194 | 194 | $TTitle = self::getAllTitleFromDocument($object, $get_block_total); |
| 195 | 195 | |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | * @param boolean $return_rang_on_false si true alors renvoi le rang où devrait ce trouver le sous-total |
| 211 | 211 | * @return boolean |
| 212 | 212 | */ |
| 213 | - public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false) |
|
| 213 | + public static function titleHasTotalLine(&$object, &$title_line, $strict_mode = false, $return_rang_on_false = false) |
|
| 214 | 214 | { |
| 215 | 215 | if (empty($object->lines) || !is_array($object->lines)) return false; |
| 216 | 216 | |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | return ($return_rang_on_false) ? -1 : false; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | - public static function getAllTitleFromDocument(&$object, $get_block_total=false) |
|
| 239 | + public static function getAllTitleFromDocument(&$object, $get_block_total = false) |
|
| 240 | 240 | { |
| 241 | 241 | $TRes = array(); |
| 242 | 242 | if (!empty($object->lines)) |
@@ -357,19 +357,19 @@ discard block |
||
| 357 | 357 | return false; |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | - public static function isTitle(&$line, $level=-1) |
|
| 360 | + public static function isTitle(&$line, $level = -1) |
|
| 361 | 361 | { |
| 362 | 362 | $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty <= 9; |
| 363 | - if($res && $level > -1) { |
|
| 363 | + if ($res && $level > -1) { |
|
| 364 | 364 | return $line->qty == $level; |
| 365 | 365 | } else return $res; |
| 366 | 366 | |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | - public static function isSubtotal(&$line, $level=-1) |
|
| 369 | + public static function isSubtotal(&$line, $level = -1) |
|
| 370 | 370 | { |
| 371 | 371 | $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90; |
| 372 | - if($res && $level > -1) { |
|
| 372 | + if ($res && $level > -1) { |
|
| 373 | 373 | return self::getNiveau($line) == $level; |
| 374 | 374 | } else return $res; |
| 375 | 375 | } |
@@ -384,43 +384,43 @@ discard block |
||
| 384 | 384 | return self::isTitle($line) || self::isSubtotal($line) || self::isFreeText($line); |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | - public static function getFreeTextHtml(&$line, $readonly=0) |
|
| 387 | + public static function getFreeTextHtml(&$line, $readonly = 0) |
|
| 388 | 388 | { |
| 389 | 389 | global $conf; |
| 390 | 390 | |
| 391 | 391 | // Copie du fichier "objectline_edit.tpl.php" |
| 392 | 392 | // editeur wysiwyg |
| 393 | 393 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
| 394 | - $nbrows=ROWS_2; |
|
| 395 | - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
| 396 | - $enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); |
|
| 397 | - $toolbarname='dolibarr_details'; |
|
| 398 | - if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes'; |
|
| 399 | - $text = !empty($line->description)?$line->description:$line->label; |
|
| 400 | - $doleditor=new DolEditor('line-description',$text,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%', $readonly); |
|
| 394 | + $nbrows = ROWS_2; |
|
| 395 | + if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
| 396 | + $enable = (isset($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0); |
|
| 397 | + $toolbarname = 'dolibarr_details'; |
|
| 398 | + if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname = 'dolibarr_notes'; |
|
| 399 | + $text = !empty($line->description) ? $line->description : $line->label; |
|
| 400 | + $doleditor = new DolEditor('line-description', $text, '', 164, $toolbarname, '', false, true, $enable, $nbrows, '98%', $readonly); |
|
| 401 | 401 | return $doleditor->Create(1); |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - public static function duplicateLines(&$object, $lineid, $withBlockLine=false) |
|
| 404 | + public static function duplicateLines(&$object, $lineid, $withBlockLine = false) |
|
| 405 | 405 | { |
| 406 | - global $db,$user,$conf; |
|
| 406 | + global $db, $user, $conf; |
|
| 407 | 407 | |
| 408 | 408 | $createRight = $user->rights->{$object->element}->creer; |
| 409 | - if($object->element == 'facturerec' ) |
|
| 409 | + if ($object->element == 'facturerec') |
|
| 410 | 410 | { |
| 411 | 411 | $object->statut = 0; // hack for facture rec |
| 412 | 412 | $createRight = $user->rights->facture->creer; |
| 413 | 413 | } |
| 414 | - elseif($object->element == 'order_supplier' ) |
|
| 414 | + elseif ($object->element == 'order_supplier') |
|
| 415 | 415 | { |
| 416 | 416 | $createRight = $user->rights->fournisseur->commande->creer; |
| 417 | 417 | } |
| 418 | - elseif($object->element == 'invoice_supplier' ) |
|
| 418 | + elseif ($object->element == 'invoice_supplier') |
|
| 419 | 419 | { |
| 420 | 420 | $createRight = $user->rights->fournisseur->facture->creer; |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | - if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK)) |
|
| 423 | + if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK)) |
|
| 424 | 424 | { |
| 425 | 425 | dol_include_once('/subtotal/lib/subtotal.lib.php'); |
| 426 | 426 | |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | case 'order_supplier': |
| 454 | 454 | $object->line = $line; |
| 455 | 455 | $object->line->fk_commande = $object->id; |
| 456 | - $object->line->rang = $object->line_max() +1; |
|
| 456 | + $object->line->rang = $object->line_max() + 1; |
|
| 457 | 457 | $res = $object->line->insert(1); |
| 458 | 458 | break; |
| 459 | 459 | |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | { |
| 494 | 494 | $object->line_from = $line; |
| 495 | 495 | // Call trigger |
| 496 | - $result=$object->call_trigger('LINE_DUPLICATE',$user); // $object->line |
|
| 496 | + $result = $object->call_trigger('LINE_DUPLICATE', $user); // $object->line |
|
| 497 | 497 | if ($result < 0) |
| 498 | 498 | { |
| 499 | 499 | $object->db->rollback(); |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | } |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | - public static function getLinesFromTitle(&$object, $key_trad, $level=1, $under_title='', $withBlockLine=false, $key_is_id=false) |
|
| 526 | + public static function getLinesFromTitle(&$object, $key_trad, $level = 1, $under_title = '', $withBlockLine = false, $key_is_id = false) |
|
| 527 | 527 | { |
| 528 | 528 | global $langs; |
| 529 | 529 | |
@@ -535,17 +535,17 @@ discard block |
||
| 535 | 535 | |
| 536 | 536 | $TLine = array(); |
| 537 | 537 | $add_line = false; |
| 538 | - $under_title_found=false; |
|
| 538 | + $under_title_found = false; |
|
| 539 | 539 | |
| 540 | 540 | foreach ($object->lines as $key => &$line) |
| 541 | 541 | { |
| 542 | 542 | if (!$under_title_found && !empty($TTitle_under_search)) |
| 543 | 543 | { |
| 544 | - if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true; |
|
| 544 | + if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search))) $under_title_found = true; |
|
| 545 | 545 | } |
| 546 | 546 | else |
| 547 | 547 | { |
| 548 | - if ( ($key_is_id && $line->id == $key_trad) || (!$key_is_id && $line->product_type == 9 && $line->qty == $level && (in_array($line->desc, $TTitle_search) || in_array($line->label, $TTitle_search) ))) |
|
| 548 | + if (($key_is_id && $line->id == $key_trad) || (!$key_is_id && $line->product_type == 9 && $line->qty == $level && (in_array($line->desc, $TTitle_search) || in_array($line->label, $TTitle_search)))) |
|
| 549 | 549 | { |
| 550 | 550 | if ($key_is_id) $level = $line->qty; |
| 551 | 551 | |
@@ -553,7 +553,7 @@ discard block |
||
| 553 | 553 | if ($withBlockLine) $TLine[] = $line; |
| 554 | 554 | continue; |
| 555 | 555 | } |
| 556 | - elseif ($add_line && $line->product_type == 9 && (100 - $line->qty == $level) ) // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre |
|
| 556 | + elseif ($add_line && $line->product_type == 9 && (100 - $line->qty == $level)) // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre |
|
| 557 | 557 | { |
| 558 | 558 | if ($withBlockLine) $TLine[] = $line; |
| 559 | 559 | break; |
@@ -561,7 +561,7 @@ discard block |
||
| 561 | 561 | |
| 562 | 562 | if ($add_line) |
| 563 | 563 | { |
| 564 | - if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue; |
|
| 564 | + if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line))) continue; |
|
| 565 | 565 | else $TLine[] = $line; |
| 566 | 566 | } |
| 567 | 567 | } |
@@ -570,12 +570,12 @@ discard block |
||
| 570 | 570 | return $TLine; |
| 571 | 571 | } |
| 572 | 572 | |
| 573 | - public static function getLinesFromTitleId(&$object, $lineid, $withBlockLine=false) |
|
| 573 | + public static function getLinesFromTitleId(&$object, $lineid, $withBlockLine = false) |
|
| 574 | 574 | { |
| 575 | 575 | return self::getLinesFromTitle($object, $lineid, '', '', $withBlockLine, true); |
| 576 | 576 | } |
| 577 | 577 | |
| 578 | - public static function doUpdateLine(&$object, $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $type, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=0, $fk_unit = null, $notrigger = 0) |
|
| 578 | + public static function doUpdateLine(&$object, $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $type, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 0, $fk_unit = null, $notrigger = 0) |
|
| 579 | 579 | { |
| 580 | 580 | $res = 0; |
| 581 | 581 | $object->db->begin(); |
@@ -587,7 +587,7 @@ discard block |
||
| 587 | 587 | break; |
| 588 | 588 | |
| 589 | 589 | case 'supplier_proposal': |
| 590 | - $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $array_options,'', $fk_unit); |
|
| 590 | + $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $array_options, '', $fk_unit); |
|
| 591 | 591 | break; |
| 592 | 592 | |
| 593 | 593 | case 'commande': |
@@ -616,9 +616,9 @@ discard block |
||
| 616 | 616 | $factureRecLine->fetch($rowid); |
| 617 | 617 | $factureRecLine->array_options = $array_options; |
| 618 | 618 | $factureRecLine->insertExtraFields(); |
| 619 | - $rang=$factureRecLine->rang; |
|
| 619 | + $rang = $factureRecLine->rang; |
|
| 620 | 620 | |
| 621 | - $fk_product=0; $fk_remise_except=''; $pu_ttc=0; |
|
| 621 | + $fk_product = 0; $fk_remise_except = ''; $pu_ttc = 0; |
|
| 622 | 622 | $res = $object->updateline($rowid, $desc, $pu, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $price_base_type, $info_bits, $fk_remise_except, $pu_ttc, $type, $rang, $special_code, $label, $fk_unit); |
| 623 | 623 | break; |
| 624 | 624 | } |
@@ -634,7 +634,7 @@ discard block |
||
| 634 | 634 | global $db, $object; |
| 635 | 635 | |
| 636 | 636 | $TTitle = array(); |
| 637 | - if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} |
|
| 637 | + if (!empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} |
|
| 638 | 638 | else { |
| 639 | 639 | if ($origin_line->element == 'propaldet') |
| 640 | 640 | { |
@@ -714,7 +714,7 @@ discard block |
||
| 714 | 714 | */ |
| 715 | 715 | public static function addRecapPage(&$parameters, &$origin_pdf) |
| 716 | 716 | { |
| 717 | - global $user,$conf,$langs; |
|
| 717 | + global $user, $conf, $langs; |
|
| 718 | 718 | |
| 719 | 719 | $origin_file = $parameters['file']; |
| 720 | 720 | $outputlangs = $parameters['outputlangs']; |
@@ -730,21 +730,21 @@ discard block |
||
| 730 | 730 | $objmarge->marge_droite = 10; |
| 731 | 731 | |
| 732 | 732 | $objectref = dol_sanitizeFileName($object->ref); |
| 733 | - if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref; |
|
| 734 | - elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref; |
|
| 735 | - elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref; |
|
| 733 | + if ($object->element == 'propal') $dir = $conf->propal->dir_output.'/'.$objectref; |
|
| 734 | + elseif ($object->element == 'commande') $dir = $conf->commande->dir_output.'/'.$objectref; |
|
| 735 | + elseif ($object->element == 'facture') $dir = $conf->facture->dir_output.'/'.$objectref; |
|
| 736 | 736 | elseif ($object->element == 'facturerec') return; // no PDF for facturerec |
| 737 | 737 | else |
| 738 | 738 | { |
| 739 | 739 | setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings'); |
| 740 | 740 | return -1; |
| 741 | 741 | } |
| 742 | - $file = $dir . '/' . $objectref . '_recap.pdf'; |
|
| 742 | + $file = $dir.'/'.$objectref.'_recap.pdf'; |
|
| 743 | 743 | |
| 744 | 744 | // $pdf=pdf_getInstance($origin_pdf->format); |
| 745 | - $pdf=pdf_getInstance(array(210, 297)); // Format A4 Portrait |
|
| 746 | - $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
| 747 | - $pdf->SetAutoPageBreak(1,0); |
|
| 745 | + $pdf = pdf_getInstance(array(210, 297)); // Format A4 Portrait |
|
| 746 | + $default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance |
|
| 747 | + $pdf->SetAutoPageBreak(1, 0); |
|
| 748 | 748 | |
| 749 | 749 | if (class_exists('TCPDF')) |
| 750 | 750 | { |
@@ -753,49 +753,49 @@ discard block |
||
| 753 | 753 | } |
| 754 | 754 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
| 755 | 755 | // Set path to the background PDF File |
| 756 | - if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
| 756 | + if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND)) |
|
| 757 | 757 | { |
| 758 | 758 | $pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND); |
| 759 | 759 | $tplidx = $pdf->importPage(1); |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | 762 | $pdf->Open(); |
| 763 | - $pagenb=0; |
|
| 764 | - $pdf->SetDrawColor(128,128,128); |
|
| 763 | + $pagenb = 0; |
|
| 764 | + $pdf->SetDrawColor(128, 128, 128); |
|
| 765 | 765 | |
| 766 | 766 | $pdf->SetTitle($outputlangs->convToOutputCharset($object->ref)); |
| 767 | 767 | $pdf->SetSubject($outputlangs->transnoentities("subtotalRecap")); |
| 768 | 768 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
| 769 | 769 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
| 770 | 770 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
| 771 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 771 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 772 | 772 | |
| 773 | - $pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite); // Left, Top, Right |
|
| 773 | + $pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite); // Left, Top, Right |
|
| 774 | 774 | |
| 775 | - $pagenb=0; |
|
| 776 | - $pdf->SetDrawColor(128,128,128); |
|
| 775 | + $pagenb = 0; |
|
| 776 | + $pdf->SetDrawColor(128, 128, 128); |
|
| 777 | 777 | |
| 778 | 778 | |
| 779 | 779 | // New page |
| 780 | 780 | $pdf->AddPage(); |
| 781 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 781 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 782 | 782 | $pagenb++; |
| 783 | 783 | |
| 784 | 784 | |
| 785 | 785 | self::pagehead($objmarge, $pdf, $object, 1, $outputlangs); |
| 786 | - $pdf->SetFont('','', $default_font_size - 1); |
|
| 787 | - $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
| 788 | - $pdf->SetTextColor(0,0,0); |
|
| 786 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
| 787 | + $pdf->MultiCell(0, 3, ''); // Set interline to 3 |
|
| 788 | + $pdf->SetTextColor(0, 0, 0); |
|
| 789 | 789 | |
| 790 | - $heightforinfotot = 25; // Height reserved to output the info and total part |
|
| 791 | - $heightforfooter = $objmarge->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
| 790 | + $heightforinfotot = 25; // Height reserved to output the info and total part |
|
| 791 | + $heightforfooter = $objmarge->marge_basse + 8; // Height reserved to output the footer (value include bottom margin) |
|
| 792 | 792 | |
| 793 | 793 | $posx_designation = 25; |
| 794 | 794 | $posx_options = 150; |
| 795 | 795 | $posx_montant = 170; |
| 796 | 796 | |
| 797 | 797 | $tab_top = 72; |
| 798 | - $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?72:20); // TODO à vérifier |
|
| 798 | + $tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 72 : 20); // TODO à vérifier |
|
| 799 | 799 | |
| 800 | 800 | $TTot = array('total_ht' => 0, 'total_ttc' => 0, 'TTotal_tva' => array()); |
| 801 | 801 | |
@@ -809,14 +809,14 @@ discard block |
||
| 809 | 809 | $nexY = $tab_top + 10; |
| 810 | 810 | |
| 811 | 811 | $nblignes = count($TLine); |
| 812 | - foreach($TLine as $i => &$line) |
|
| 812 | + foreach ($TLine as $i => &$line) |
|
| 813 | 813 | { |
| 814 | 814 | $curY = $nexY; |
| 815 | 815 | |
| 816 | 816 | if (self::getNiveau($line) == 1) |
| 817 | 817 | { |
| 818 | - $pdf->SetFont('','B', $default_font_size - 1); // Into loop to work with multipage |
|
| 819 | - $curY+=2; |
|
| 818 | + $pdf->SetFont('', 'B', $default_font_size - 1); // Into loop to work with multipage |
|
| 819 | + $curY += 2; |
|
| 820 | 820 | |
| 821 | 821 | $TTot['total_ht'] += $line->total_ht; |
| 822 | 822 | $TTot['total_tva'] += $line->total_tva; |
@@ -835,67 +835,67 @@ discard block |
||
| 835 | 835 | $TTot['TTotal_tva_multicurrency'][$tx] += $amount; |
| 836 | 836 | } |
| 837 | 837 | } |
| 838 | - else $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
| 838 | + else $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage |
|
| 839 | 839 | |
| 840 | - $pdf->SetTextColor(0,0,0); |
|
| 840 | + $pdf->SetTextColor(0, 0, 0); |
|
| 841 | 841 | |
| 842 | 842 | $pdf->setTopMargin($tab_top_newpage + 10); |
| 843 | - $pdf->setPageOrientation('', 1, $heightforfooter+$heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
| 844 | - $pageposbefore=$pdf->getPage(); |
|
| 843 | + $pdf->setPageOrientation('', 1, $heightforfooter + $heightforinfotot); // The only function to edit the bottom margin of current page to set it. |
|
| 844 | + $pageposbefore = $pdf->getPage(); |
|
| 845 | 845 | |
| 846 | - $showpricebeforepagebreak=1; |
|
| 846 | + $showpricebeforepagebreak = 1; |
|
| 847 | 847 | |
| 848 | 848 | $decalage = (self::getNiveau($line) - 1) * 2; |
| 849 | 849 | |
| 850 | 850 | // Print: Designation |
| 851 | 851 | $label = $line->label; |
| 852 | - if( (float)DOL_VERSION < 6 ) { |
|
| 852 | + if ((float) DOL_VERSION < 6) { |
|
| 853 | 853 | $label = !empty($line->label) ? $line->label : $line->desc; |
| 854 | 854 | } |
| 855 | 855 | |
| 856 | 856 | |
| 857 | 857 | $pdf->startTransaction(); |
| 858 | - $pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true); |
|
| 859 | - $pageposafter=$pdf->getPage(); |
|
| 858 | + $pdf->writeHTMLCell($posx_options - $posx_designation - $decalage, 3, $posx_designation + $decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J', true); |
|
| 859 | + $pageposafter = $pdf->getPage(); |
|
| 860 | 860 | if ($pageposafter > $pageposbefore) // There is a pagebreak |
| 861 | 861 | { |
| 862 | 862 | $pdf->rollbackTransaction(true); |
| 863 | - $pageposafter=$pageposbefore; |
|
| 863 | + $pageposafter = $pageposbefore; |
|
| 864 | 864 | //print $pageposafter.'-'.$pageposbefore;exit; |
| 865 | - $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
| 866 | - $pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true); |
|
| 865 | + $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
|
| 866 | + $pdf->writeHTMLCell($posx_options - $posx_designation - $decalage, 3, $posx_designation + $decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J', true); |
|
| 867 | 867 | |
| 868 | - $pageposafter=$pdf->getPage(); |
|
| 869 | - $posyafter=$pdf->GetY(); |
|
| 868 | + $pageposafter = $pdf->getPage(); |
|
| 869 | + $posyafter = $pdf->GetY(); |
|
| 870 | 870 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
| 871 | - if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) // There is no space left for total+free text |
|
| 871 | + if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter + $heightforinfotot))) // There is no space left for total+free text |
|
| 872 | 872 | { |
| 873 | - if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
|
| 873 | + if ($i == ($nblignes - 1)) // No more lines, and no space left to show total, so we create a new page |
|
| 874 | 874 | { |
| 875 | - $pdf->AddPage('','',true); |
|
| 876 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 875 | + $pdf->AddPage('', '', true); |
|
| 876 | + if (!empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 877 | 877 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
| 878 | - $pdf->setPage($pageposafter+1); |
|
| 878 | + $pdf->setPage($pageposafter + 1); |
|
| 879 | 879 | } |
| 880 | 880 | } |
| 881 | 881 | else |
| 882 | 882 | { |
| 883 | 883 | // We found a page break |
| 884 | - $showpricebeforepagebreak=0; |
|
| 884 | + $showpricebeforepagebreak = 0; |
|
| 885 | 885 | } |
| 886 | 886 | } |
| 887 | 887 | else // No pagebreak |
| 888 | 888 | { |
| 889 | 889 | $pdf->commitTransaction(); |
| 890 | 890 | } |
| 891 | - $posYAfterDescription=$pdf->GetY(); |
|
| 891 | + $posYAfterDescription = $pdf->GetY(); |
|
| 892 | 892 | |
| 893 | 893 | $nexY = $pdf->GetY(); |
| 894 | - $pageposafter=$pdf->getPage(); |
|
| 894 | + $pageposafter = $pdf->getPage(); |
|
| 895 | 895 | |
| 896 | 896 | $pdf->setPage($pageposbefore); |
| 897 | 897 | $pdf->setTopMargin($objmarge->marge_haute); |
| 898 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
| 898 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
| 899 | 899 | |
| 900 | 900 | // We suppose that a too long description or photo were moved completely on next page |
| 901 | 901 | if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) { |
@@ -908,14 +908,14 @@ discard block |
||
| 908 | 908 | if (!empty($line->total_options)) |
| 909 | 909 | { |
| 910 | 910 | $pdf->SetXY($posx_options, $curY); |
| 911 | - $pdf->MultiCell($posx_montant-$posx_options-0.8, 3, price($line->total_options, 0, $outputlangs), 0, 'R', 0); |
|
| 911 | + $pdf->MultiCell($posx_montant - $posx_options - 0.8, 3, price($line->total_options, 0, $outputlangs), 0, 'R', 0); |
|
| 912 | 912 | } |
| 913 | 913 | |
| 914 | 914 | // Print: Montant |
| 915 | 915 | $pdf->SetXY($posx_montant, $curY); |
| 916 | - $pdf->MultiCell($objmarge->page_largeur-$objmarge->marge_droite-$posx_montant-0.8, 3, price($line->total_ht, 0, $outputlangs), 0, 'R', 0); |
|
| 916 | + $pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant - 0.8, 3, price($line->total_ht, 0, $outputlangs), 0, 'R', 0); |
|
| 917 | 917 | |
| 918 | - $nexY+=2; // Passe espace entre les lignes |
|
| 918 | + $nexY += 2; // Passe espace entre les lignes |
|
| 919 | 919 | |
| 920 | 920 | // Detect if some page were added automatically and output _tableau for past pages |
| 921 | 921 | while ($pagenb < $pageposafter) |
@@ -932,7 +932,7 @@ discard block |
||
| 932 | 932 | |
| 933 | 933 | $pagenb++; |
| 934 | 934 | $pdf->setPage($pagenb); |
| 935 | - $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
| 935 | + $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
|
| 936 | 936 | if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
| 937 | 937 | } |
| 938 | 938 | } |
@@ -942,19 +942,19 @@ discard block |
||
| 942 | 942 | if ($pagenb == 1) |
| 943 | 943 | { |
| 944 | 944 | self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $objmarge->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
| 945 | - $bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
|
| 945 | + $bottomlasttab = $objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
|
| 946 | 946 | } |
| 947 | 947 | else |
| 948 | 948 | { |
| 949 | 949 | self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top_newpage, $objmarge->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code); |
| 950 | - $bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
|
| 950 | + $bottomlasttab = $objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
|
| 951 | 951 | } |
| 952 | 952 | |
| 953 | 953 | // Affiche zone totaux |
| 954 | - $posy=self::tableau_tot($objmarge, $pdf, $object, $bottomlasttab, $outputlangs, $TTot); |
|
| 954 | + $posy = self::tableau_tot($objmarge, $pdf, $object, $bottomlasttab, $outputlangs, $TTot); |
|
| 955 | 955 | |
| 956 | 956 | $pdf->Close(); |
| 957 | - $pdf->Output($file,'F'); |
|
| 957 | + $pdf->Output($file, 'F'); |
|
| 958 | 958 | |
| 959 | 959 | $pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file); |
| 960 | 960 | |
@@ -966,7 +966,7 @@ discard block |
||
| 966 | 966 | $level = $line->qty; // TODO à améliorer |
| 967 | 967 | |
| 968 | 968 | $pdf->SetXY($objmarge->marge_gauche, $curY); |
| 969 | - $pdf->MultiCell($posx_designation-$objmarge->marge_gauche-0.8, 5, $level, 0, 'L', 0); |
|
| 969 | + $pdf->MultiCell($posx_designation - $objmarge->marge_gauche - 0.8, 5, $level, 0, 'L', 0); |
|
| 970 | 970 | } |
| 971 | 971 | |
| 972 | 972 | /** |
@@ -980,50 +980,50 @@ discard block |
||
| 980 | 980 | */ |
| 981 | 981 | private static function pagehead(&$objmarge, &$pdf, &$object, $showdetail, $outputlangs) |
| 982 | 982 | { |
| 983 | - global $conf,$mysoc; |
|
| 983 | + global $conf, $mysoc; |
|
| 984 | 984 | |
| 985 | 985 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
| 986 | 986 | |
| 987 | - pdf_pagehead($pdf,$outputlangs,$objmarge->page_hauteur); |
|
| 987 | + pdf_pagehead($pdf, $outputlangs, $objmarge->page_hauteur); |
|
| 988 | 988 | |
| 989 | - $pdf->SetTextColor(0,0,60); |
|
| 990 | - $pdf->SetFont('','B', $default_font_size + 3); |
|
| 989 | + $pdf->SetTextColor(0, 0, 60); |
|
| 990 | + $pdf->SetFont('', 'B', $default_font_size + 3); |
|
| 991 | 991 | |
| 992 | - $posy=$objmarge->marge_haute; |
|
| 993 | - $posx=$objmarge->page_largeur-$objmarge->marge_droite-100; |
|
| 992 | + $posy = $objmarge->marge_haute; |
|
| 993 | + $posx = $objmarge->page_largeur - $objmarge->marge_droite - 100; |
|
| 994 | 994 | |
| 995 | - $pdf->SetXY($objmarge->marge_gauche,$posy); |
|
| 995 | + $pdf->SetXY($objmarge->marge_gauche, $posy); |
|
| 996 | 996 | |
| 997 | - $logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
| 997 | + $logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo; |
|
| 998 | 998 | if ($mysoc->logo) |
| 999 | 999 | { |
| 1000 | 1000 | if (is_readable($logo)) |
| 1001 | 1001 | { |
| 1002 | - $height=pdf_getHeightForLogo($logo); |
|
| 1003 | - $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
| 1002 | + $height = pdf_getHeightForLogo($logo); |
|
| 1003 | + $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto) |
|
| 1004 | 1004 | } |
| 1005 | 1005 | else |
| 1006 | 1006 | { |
| 1007 | - $pdf->SetTextColor(200,0,0); |
|
| 1008 | - $pdf->SetFont('','B',$default_font_size - 2); |
|
| 1009 | - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); |
|
| 1007 | + $pdf->SetTextColor(200, 0, 0); |
|
| 1008 | + $pdf->SetFont('', 'B', $default_font_size - 2); |
|
| 1009 | + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L'); |
|
| 1010 | 1010 | $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); |
| 1011 | 1011 | } |
| 1012 | 1012 | |
| 1013 | - $posy+=35; |
|
| 1013 | + $posy += 35; |
|
| 1014 | 1014 | } |
| 1015 | 1015 | else |
| 1016 | 1016 | { |
| 1017 | - $text=$mysoc->name; |
|
| 1017 | + $text = $mysoc->name; |
|
| 1018 | 1018 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
| 1019 | 1019 | |
| 1020 | - $posy+=15; |
|
| 1020 | + $posy += 15; |
|
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | 1023 | |
| 1024 | - $pdf->SetTextColor(0,0,0); |
|
| 1025 | - $pdf->SetFont('','B', $default_font_size + 2); |
|
| 1026 | - $pdf->SetXY($objmarge->marge_gauche,$posy); |
|
| 1024 | + $pdf->SetTextColor(0, 0, 0); |
|
| 1025 | + $pdf->SetFont('', 'B', $default_font_size + 2); |
|
| 1026 | + $pdf->SetXY($objmarge->marge_gauche, $posy); |
|
| 1027 | 1027 | |
| 1028 | 1028 | $key = 'subtotalPropalTitle'; |
| 1029 | 1029 | if ($object->element == 'commande') $key = 'subtotalCommandeTitle'; |
@@ -1032,14 +1032,14 @@ discard block |
||
| 1032 | 1032 | |
| 1033 | 1033 | $pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L'); |
| 1034 | 1034 | |
| 1035 | - $pdf->SetFont('','', $default_font_size); |
|
| 1036 | - $pdf->SetXY($objmarge->page_largeur-$objmarge->marge_droite-40,$posy); |
|
| 1035 | + $pdf->SetFont('', '', $default_font_size); |
|
| 1036 | + $pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - 40, $posy); |
|
| 1037 | 1037 | $pdf->MultiCell(40, 4, dol_print_date($object->date, 'daytext'), '', 'R'); |
| 1038 | 1038 | |
| 1039 | 1039 | $posy += 8; |
| 1040 | 1040 | |
| 1041 | - $pdf->SetFont('','B', $default_font_size + 2); |
|
| 1042 | - $pdf->SetXY($objmarge->marge_gauche,$posy); |
|
| 1041 | + $pdf->SetFont('', 'B', $default_font_size + 2); |
|
| 1042 | + $pdf->SetXY($objmarge->marge_gauche, $posy); |
|
| 1043 | 1043 | $pdf->MultiCell(70, 4, $outputlangs->transnoentities('subtotalRecapLot'), '', 'L'); |
| 1044 | 1044 | |
| 1045 | 1045 | } |
@@ -1057,44 +1057,44 @@ discard block |
||
| 1057 | 1057 | * @param string $currency Currency code |
| 1058 | 1058 | * @return void |
| 1059 | 1059 | */ |
| 1060 | - private static function tableau(&$objmarge, &$pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='') |
|
| 1060 | + private static function tableau(&$objmarge, &$pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '') |
|
| 1061 | 1061 | { |
| 1062 | 1062 | global $conf; |
| 1063 | 1063 | |
| 1064 | 1064 | // Force to disable hidetop and hidebottom |
| 1065 | - $hidebottom=0; |
|
| 1066 | - if ($hidetop) $hidetop=-1; |
|
| 1065 | + $hidebottom = 0; |
|
| 1066 | + if ($hidetop) $hidetop = -1; |
|
| 1067 | 1067 | |
| 1068 | 1068 | $currency = !empty($currency) ? $currency : $conf->currency; |
| 1069 | 1069 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
| 1070 | 1070 | |
| 1071 | 1071 | // Amount in (at tab_top - 1) |
| 1072 | - $pdf->SetTextColor(0,0,0); |
|
| 1073 | - $pdf->SetFont('','',$default_font_size); |
|
| 1072 | + $pdf->SetTextColor(0, 0, 0); |
|
| 1073 | + $pdf->SetFont('', '', $default_font_size); |
|
| 1074 | 1074 | |
| 1075 | 1075 | if (empty($hidetop)) |
| 1076 | 1076 | { |
| 1077 | - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
| 1078 | - $pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5); |
|
| 1077 | + $titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency)); |
|
| 1078 | + $pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4.5); |
|
| 1079 | 1079 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
| 1080 | 1080 | |
| 1081 | - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite-$objmarge->marge_gauche, 8, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
| 1081 | + if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur - $objmarge->marge_droite - $objmarge->marge_gauche, 8, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
| 1082 | 1082 | |
| 1083 | 1083 | |
| 1084 | - $pdf->line($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top); // line prend une position y en 2eme param et 4eme param |
|
| 1084 | + $pdf->line($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur - $objmarge->marge_droite, $tab_top); // line prend une position y en 2eme param et 4eme param |
|
| 1085 | 1085 | |
| 1086 | - $pdf->SetXY($posx_designation, $tab_top+2); |
|
| 1087 | - $pdf->MultiCell($posx_options - $posx_designation,2, $outputlangs->transnoentities("Designation"),'','L'); |
|
| 1088 | - $pdf->SetXY($posx_options, $tab_top+2); |
|
| 1089 | - $pdf->MultiCell($posx_montant - $posx_options,2, $outputlangs->transnoentities("Options"),'','R'); |
|
| 1090 | - $pdf->SetXY($posx_montant, $tab_top+2); |
|
| 1091 | - $pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R'); |
|
| 1086 | + $pdf->SetXY($posx_designation, $tab_top + 2); |
|
| 1087 | + $pdf->MultiCell($posx_options - $posx_designation, 2, $outputlangs->transnoentities("Designation"), '', 'L'); |
|
| 1088 | + $pdf->SetXY($posx_options, $tab_top + 2); |
|
| 1089 | + $pdf->MultiCell($posx_montant - $posx_options, 2, $outputlangs->transnoentities("Options"), '', 'R'); |
|
| 1090 | + $pdf->SetXY($posx_montant, $tab_top + 2); |
|
| 1091 | + $pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant, 2, $outputlangs->transnoentities("Amount"), '', 'R'); |
|
| 1092 | 1092 | |
| 1093 | - $pdf->line($objmarge->marge_gauche, $tab_top+8, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top+8); // line prend une position y en 2eme param et 4eme param |
|
| 1093 | + $pdf->line($objmarge->marge_gauche, $tab_top + 8, $objmarge->page_largeur - $objmarge->marge_droite, $tab_top + 8); // line prend une position y en 2eme param et 4eme param |
|
| 1094 | 1094 | } |
| 1095 | 1095 | else |
| 1096 | 1096 | { |
| 1097 | - $pdf->line($objmarge->marge_gauche, $tab_top-2, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top-2); // line prend une position y en 2eme param et 4eme param |
|
| 1097 | + $pdf->line($objmarge->marge_gauche, $tab_top - 2, $objmarge->page_largeur - $objmarge->marge_droite, $tab_top - 2); // line prend une position y en 2eme param et 4eme param |
|
| 1098 | 1098 | } |
| 1099 | 1099 | |
| 1100 | 1100 | } |
@@ -1103,29 +1103,29 @@ discard block |
||
| 1103 | 1103 | { |
| 1104 | 1104 | global $conf; |
| 1105 | 1105 | |
| 1106 | - $pdf->line($objmarge->marge_gauche, $posy, $objmarge->page_largeur-$objmarge->marge_droite, $posy); // line prend une position y en 2eme param et 4eme param |
|
| 1106 | + $pdf->line($objmarge->marge_gauche, $posy, $objmarge->page_largeur - $objmarge->marge_droite, $posy); // line prend une position y en 2eme param et 4eme param |
|
| 1107 | 1107 | |
| 1108 | 1108 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
| 1109 | 1109 | |
| 1110 | - $tab2_top = $posy+2; |
|
| 1110 | + $tab2_top = $posy + 2; |
|
| 1111 | 1111 | $tab2_hl = 4; |
| 1112 | - $pdf->SetFont('','', $default_font_size - 1); |
|
| 1112 | + $pdf->SetFont('', '', $default_font_size - 1); |
|
| 1113 | 1113 | |
| 1114 | 1114 | // Tableau total |
| 1115 | 1115 | $col1x = 120; $col2x = 170; |
| 1116 | 1116 | if ($objmarge->page_largeur < 210) // To work with US executive format |
| 1117 | 1117 | { |
| 1118 | - $col2x-=20; |
|
| 1118 | + $col2x -= 20; |
|
| 1119 | 1119 | } |
| 1120 | 1120 | $largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x); |
| 1121 | 1121 | |
| 1122 | - $useborder=0; |
|
| 1122 | + $useborder = 0; |
|
| 1123 | 1123 | $index = 0; |
| 1124 | 1124 | |
| 1125 | 1125 | // Total HT |
| 1126 | - $pdf->SetFillColor(255,255,255); |
|
| 1126 | + $pdf->SetFillColor(255, 255, 255); |
|
| 1127 | 1127 | $pdf->SetXY($col1x, $tab2_top + 0); |
| 1128 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); |
|
| 1128 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); |
|
| 1129 | 1129 | |
| 1130 | 1130 | // $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1) ? $TTot['multicurrency_total_ht'] : $TTot['total_ht']; |
| 1131 | 1131 | $total_ht = $TTot['total_ht']; |
@@ -1133,10 +1133,10 @@ discard block |
||
| 1133 | 1133 | $pdf->MultiCell($largcol2, $tab2_hl, price($total_ht, 0, $outputlangs), 0, 'R', 1); |
| 1134 | 1134 | |
| 1135 | 1135 | // Show VAT by rates and total |
| 1136 | - $pdf->SetFillColor(248,248,248); |
|
| 1136 | + $pdf->SetFillColor(248, 248, 248); |
|
| 1137 | 1137 | |
| 1138 | - $atleastoneratenotnull=0; |
|
| 1139 | - foreach($TTot['TTotal_tva'] as $tvakey => $tvaval) |
|
| 1138 | + $atleastoneratenotnull = 0; |
|
| 1139 | + foreach ($TTot['TTotal_tva'] as $tvakey => $tvaval) |
|
| 1140 | 1140 | { |
| 1141 | 1141 | if ($tvakey != 0) // On affiche pas taux 0 |
| 1142 | 1142 | { |
@@ -1145,15 +1145,15 @@ discard block |
||
| 1145 | 1145 | $index++; |
| 1146 | 1146 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
| 1147 | 1147 | |
| 1148 | - $tvacompl=''; |
|
| 1149 | - if (preg_match('/\*/',$tvakey)) |
|
| 1148 | + $tvacompl = ''; |
|
| 1149 | + if (preg_match('/\*/', $tvakey)) |
|
| 1150 | 1150 | { |
| 1151 | - $tvakey=str_replace('*','',$tvakey); |
|
| 1151 | + $tvakey = str_replace('*', '', $tvakey); |
|
| 1152 | 1152 | $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; |
| 1153 | 1153 | } |
| 1154 | - $totalvat =$outputlangs->transnoentities("TotalVAT").' '; |
|
| 1155 | - $totalvat.=vatrate($tvakey,1).$tvacompl; |
|
| 1156 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
| 1154 | + $totalvat = $outputlangs->transnoentities("TotalVAT").' '; |
|
| 1155 | + $totalvat .= vatrate($tvakey, 1).$tvacompl; |
|
| 1156 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1); |
|
| 1157 | 1157 | |
| 1158 | 1158 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
| 1159 | 1159 | $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1); |
@@ -1163,16 +1163,16 @@ discard block |
||
| 1163 | 1163 | // Total TTC |
| 1164 | 1164 | $index++; |
| 1165 | 1165 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
| 1166 | - $pdf->SetTextColor(0,0,60); |
|
| 1167 | - $pdf->SetFillColor(224,224,224); |
|
| 1168 | - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); |
|
| 1166 | + $pdf->SetTextColor(0, 0, 60); |
|
| 1167 | + $pdf->SetFillColor(224, 224, 224); |
|
| 1168 | + $pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); |
|
| 1169 | 1169 | |
| 1170 | 1170 | // $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $TTot['multicurrency_total_ttc'] : $TTot['total_ttc']; |
| 1171 | 1171 | $total_ttc = $TTot['total_ttc']; |
| 1172 | 1172 | $pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index); |
| 1173 | 1173 | $pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1); |
| 1174 | 1174 | |
| 1175 | - $pdf->SetTextColor(0,0,0); |
|
| 1175 | + $pdf->SetTextColor(0, 0, 0); |
|
| 1176 | 1176 | |
| 1177 | 1177 | $index++; |
| 1178 | 1178 | return ($tab2_top + ($tab2_hl * $index)); |
@@ -1191,22 +1191,22 @@ discard block |
||
| 1191 | 1191 | * @param int $hidebottom Hide bottom |
| 1192 | 1192 | * @return void |
| 1193 | 1193 | */ |
| 1194 | - private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
|
| 1194 | + private static function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0) |
|
| 1195 | 1195 | { |
| 1196 | - if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
| 1197 | - $pdf->line($x+$l, $y, $x+$l, $y+$h); |
|
| 1198 | - if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
| 1199 | - $pdf->line($x, $y+$h, $x, $y); |
|
| 1196 | + if (empty($hidetop) || $hidetop == -1) $pdf->line($x, $y, $x + $l, $y); |
|
| 1197 | + $pdf->line($x + $l, $y, $x + $l, $y + $h); |
|
| 1198 | + if (empty($hidebottom)) $pdf->line($x + $l, $y + $h, $x, $y + $h); |
|
| 1199 | + $pdf->line($x, $y + $h, $x, $y); |
|
| 1200 | 1200 | } |
| 1201 | 1201 | |
| 1202 | 1202 | |
| 1203 | - public static function concat(&$outputlangs, $files, $fileoutput='') |
|
| 1203 | + public static function concat(&$outputlangs, $files, $fileoutput = '') |
|
| 1204 | 1204 | { |
| 1205 | 1205 | global $conf; |
| 1206 | 1206 | |
| 1207 | 1207 | if (empty($fileoutput)) $fileoutput = $file[0]; |
| 1208 | 1208 | |
| 1209 | - $pdf=pdf_getInstance(); |
|
| 1209 | + $pdf = pdf_getInstance(); |
|
| 1210 | 1210 | if (class_exists('TCPDF')) |
| 1211 | 1211 | { |
| 1212 | 1212 | $pdf->setPrintHeader(false); |
@@ -1214,10 +1214,10 @@ discard block |
||
| 1214 | 1214 | } |
| 1215 | 1215 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
| 1216 | 1216 | |
| 1217 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 1217 | + if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 1218 | 1218 | |
| 1219 | 1219 | |
| 1220 | - foreach($files as $file) |
|
| 1220 | + foreach ($files as $file) |
|
| 1221 | 1221 | { |
| 1222 | 1222 | $pagecount = $pdf->setSourceFile($file); |
| 1223 | 1223 | for ($i = 1; $i <= $pagecount; $i++) |
@@ -1229,8 +1229,8 @@ discard block |
||
| 1229 | 1229 | } |
| 1230 | 1230 | } |
| 1231 | 1231 | |
| 1232 | - $pdf->Output($fileoutput,'F'); |
|
| 1233 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 1232 | + $pdf->Output($fileoutput, 'F'); |
|
| 1233 | + if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 1234 | 1234 | |
| 1235 | 1235 | return $pagecount; |
| 1236 | 1236 | } |
@@ -1243,7 +1243,7 @@ discard block |
||
| 1243 | 1243 | */ |
| 1244 | 1244 | public static function hasNcTitle(&$line) |
| 1245 | 1245 | { |
| 1246 | - if(isset($line->has_nc_title)) return $line->has_nc_title; |
|
| 1246 | + if (isset($line->has_nc_title)) return $line->has_nc_title; |
|
| 1247 | 1247 | |
| 1248 | 1248 | $TTitle = self::getAllTitleFromLine($line); |
| 1249 | 1249 | foreach ($TTitle as &$line_title) |
@@ -13,18 +13,23 @@ discard block |
||
| 13 | 13 | /** |
| 14 | 14 | * @var $object Facture |
| 15 | 15 | */ |
| 16 | - if($object->element=='facture') $res = $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number); |
|
| 16 | + if($object->element=='facture') { |
|
| 17 | + $res = $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number); |
|
| 18 | + } |
|
| 17 | 19 | /** |
| 18 | 20 | * @var $object Propal |
| 19 | 21 | */ |
| 20 | - else if($object->element=='propal') $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number); |
|
| 22 | + else if($object->element=='propal') { |
|
| 23 | + $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number); |
|
| 24 | + } |
|
| 21 | 25 | /** |
| 22 | 26 | * @var $object Commande |
| 23 | 27 | */ |
| 24 | - else if($object->element=='commande') $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number); |
|
| 28 | + else if($object->element=='commande') { |
|
| 29 | + $res = $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number); |
|
| 30 | + } |
|
| 25 | 31 | |
| 26 | - } |
|
| 27 | - else { |
|
| 32 | + } else { |
|
| 28 | 33 | $desc = ''; |
| 29 | 34 | if ((float) DOL_VERSION < 6 || $qty==50) { |
| 30 | 35 | $desc = $label; |
@@ -34,29 +39,40 @@ discard block |
||
| 34 | 39 | /** |
| 35 | 40 | * @var $object Facture |
| 36 | 41 | */ |
| 37 | - if($object->element=='facture') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,$rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label); |
|
| 42 | + if($object->element=='facture') { |
|
| 43 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,$rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label); |
|
| 44 | + } |
|
| 38 | 45 | /** |
| 39 | 46 | * @var $object Facture fournisseur |
| 40 | 47 | */ |
| 41 | 48 | else if($object->element=='invoice_supplier') { |
| 42 | 49 | $object->special_code = TSubtotal::$module_number; |
| 43 | 50 | $rang = $object->line_max() + 1; |
| 44 | - if($qty==50) $res = $object->addline($desc,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang); |
|
| 45 | - else $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang); |
|
| 51 | + if($qty==50) { |
|
| 52 | + $res = $object->addline($desc,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang); |
|
| 53 | + } else { |
|
| 54 | + $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang); |
|
| 55 | + } |
|
| 46 | 56 | } |
| 47 | 57 | /** |
| 48 | 58 | * @var $object Propal |
| 49 | 59 | */ |
| 50 | - else if($object->element=='propal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
| 60 | + else if($object->element=='propal') { |
|
| 61 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
| 62 | + } |
|
| 51 | 63 | /** |
| 52 | 64 | * @var $object Propal Fournisseur |
| 53 | 65 | */ |
| 54 | - else if($object->element=='supplier_proposal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
| 66 | + else if($object->element=='supplier_proposal') { |
|
| 67 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
| 68 | + } |
|
| 55 | 69 | |
| 56 | 70 | /** |
| 57 | 71 | * @var $object Commande |
| 58 | 72 | */ |
| 59 | - else if($object->element=='commande') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label); |
|
| 73 | + else if($object->element=='commande') { |
|
| 74 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label); |
|
| 75 | + } |
|
| 60 | 76 | /** |
| 61 | 77 | * @var $object Commande fournisseur |
| 62 | 78 | */ |
@@ -67,7 +83,9 @@ discard block |
||
| 67 | 83 | /** |
| 68 | 84 | * @var $object Facturerec |
| 69 | 85 | */ |
| 70 | - else if($object->element=='facturerec') $res = $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label); |
|
| 86 | + else if($object->element=='facturerec') { |
|
| 87 | + $res = $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label); |
|
| 88 | + } |
|
| 71 | 89 | |
| 72 | 90 | } |
| 73 | 91 | |
@@ -89,8 +107,9 @@ discard block |
||
| 89 | 107 | // Define output language |
| 90 | 108 | $outputlangs = $langs; |
| 91 | 109 | $newlang = GETPOST('lang_id', 'alpha'); |
| 92 | - if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) |
|
| 93 | - $newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang; |
|
| 110 | + if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { |
|
| 111 | + $newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang; |
|
| 112 | + } |
|
| 94 | 113 | if (! empty($newlang)) { |
| 95 | 114 | $outputlangs = new Translate("", $conf); |
| 96 | 115 | $outputlangs->setDefaultLang($newlang); |
@@ -99,13 +118,18 @@ discard block |
||
| 99 | 118 | $ret = $object->fetch($object->id); // Reload to get new records |
| 100 | 119 | if ((float) DOL_VERSION <= 3.6) |
| 101 | 120 | { |
| 102 | - if ($object->element == 'propal') propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 103 | - elseif ($object->element == 'commande') commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 104 | - elseif ($object->element == 'facture') facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 105 | - } |
|
| 106 | - else |
|
| 121 | + if ($object->element == 'propal') { |
|
| 122 | + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 123 | + } elseif ($object->element == 'commande') { |
|
| 124 | + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 125 | + } elseif ($object->element == 'facture') { |
|
| 126 | + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 127 | + } |
|
| 128 | + } else |
|
| 107 | 129 | { |
| 108 | - if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 130 | + if ($object->element!= 'facturerec') { |
|
| 131 | + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
| 132 | + } |
|
| 109 | 133 | } |
| 110 | 134 | } |
| 111 | 135 | } |
@@ -119,7 +143,9 @@ discard block |
||
| 119 | 143 | */ |
| 120 | 144 | public static function updateRang(&$object, $rang_start, $move_to=1) |
| 121 | 145 | { |
| 122 | - if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
|
| 146 | + if (!class_exists('GenericObject')) { |
|
| 147 | + require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
|
| 148 | + } |
|
| 123 | 149 | |
| 124 | 150 | $row=new GenericObject($object->db); |
| 125 | 151 | $row->table_element_line = $object->table_element_line; |
@@ -128,7 +154,9 @@ discard block |
||
| 128 | 154 | |
| 129 | 155 | foreach ($object->lines as &$line) |
| 130 | 156 | { |
| 131 | - if ($line->rang < $rang_start) continue; |
|
| 157 | + if ($line->rang < $rang_start) { |
|
| 158 | + continue; |
|
| 159 | + } |
|
| 132 | 160 | |
| 133 | 161 | $row->updateRangOfLine($line->id, $line->rang+$move_to); |
| 134 | 162 | } |
@@ -151,21 +179,28 @@ discard block |
||
| 151 | 179 | foreach ($TTitle_reverse as $k => $title_line) |
| 152 | 180 | { |
| 153 | 181 | $title_niveau = self::getNiveau($title_line); |
| 154 | - if ($title_niveau < $level_new_title) break; |
|
| 182 | + if ($title_niveau < $level_new_title) { |
|
| 183 | + break; |
|
| 184 | + } |
|
| 155 | 185 | |
| 156 | 186 | $rang_to_add = self::titleHasTotalLine($object, $title_line, true, true); |
| 157 | 187 | |
| 158 | 188 | if (is_numeric($rang_to_add)) |
| 159 | 189 | { |
| 160 | - if ($rang_to_add != -1) self::updateRang($object, $rang_to_add); |
|
| 190 | + if ($rang_to_add != -1) { |
|
| 191 | + self::updateRang($object, $rang_to_add); |
|
| 192 | + } |
|
| 161 | 193 | |
| 162 | 194 | self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add); |
| 163 | 195 | |
| 164 | 196 | $object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas) |
| 165 | 197 | if ($rang_to_add != -1) |
| 166 | 198 | { |
| 167 | - if (method_exists($object, 'fetch_lines')) $object->fetch_lines(); |
|
| 168 | - else $object->fetch($object->id); |
|
| 199 | + if (method_exists($object, 'fetch_lines')) { |
|
| 200 | + $object->fetch_lines(); |
|
| 201 | + } else { |
|
| 202 | + $object->fetch($object->id); |
|
| 203 | + } |
|
| 169 | 204 | } |
| 170 | 205 | } |
| 171 | 206 | } |
@@ -195,7 +230,9 @@ discard block |
||
| 195 | 230 | |
| 196 | 231 | foreach ($TTitle as $k => $title_line) |
| 197 | 232 | { |
| 198 | - if (self::titleHasTotalLine($object, $title_line)) unset($TTitle[$k]); |
|
| 233 | + if (self::titleHasTotalLine($object, $title_line)) { |
|
| 234 | + unset($TTitle[$k]); |
|
| 235 | + } |
|
| 199 | 236 | } |
| 200 | 237 | |
| 201 | 238 | return $TTitle; |
@@ -212,23 +249,41 @@ discard block |
||
| 212 | 249 | */ |
| 213 | 250 | public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false) |
| 214 | 251 | { |
| 215 | - if (empty($object->lines) || !is_array($object->lines)) return false; |
|
| 252 | + if (empty($object->lines) || !is_array($object->lines)) { |
|
| 253 | + return false; |
|
| 254 | + } |
|
| 216 | 255 | |
| 217 | 256 | $title_niveau = self::getNiveau($title_line); |
| 218 | 257 | foreach ($object->lines as &$line) |
| 219 | 258 | { |
| 220 | - if ($line->rang <= $title_line->rang) continue; |
|
| 221 | - if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) return false; // Oups on croise un titre d'un niveau inférieur ou égale (exemple : je croise un titre niveau 2 alors que je suis sur un titre de niveau 3) pas lieu de continuer car un nouveau bloc commence |
|
| 222 | - if (!self::isSubtotal($line)) continue; |
|
| 259 | + if ($line->rang <= $title_line->rang) { |
|
| 260 | + continue; |
|
| 261 | + } |
|
| 262 | + if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) { |
|
| 263 | + return false; |
|
| 264 | + } |
|
| 265 | + // Oups on croise un titre d'un niveau inférieur ou égale (exemple : je croise un titre niveau 2 alors que je suis sur un titre de niveau 3) pas lieu de continuer car un nouveau bloc commence |
|
| 266 | + if (!self::isSubtotal($line)) { |
|
| 267 | + continue; |
|
| 268 | + } |
|
| 223 | 269 | |
| 224 | 270 | $subtotal_niveau = self::getNiveau($line); |
| 225 | 271 | |
| 226 | 272 | // Comparaison du niveau de la ligne de sous-total avec celui du titre |
| 227 | - if ($subtotal_niveau == $title_niveau) return true; // niveau égale => Ok mon titre a un sous-total |
|
| 228 | - elseif ($subtotal_niveau < $title_niveau) // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3) |
|
| 273 | + if ($subtotal_niveau == $title_niveau) { |
|
| 274 | + return true; |
|
| 275 | + } |
|
| 276 | + // niveau égale => Ok mon titre a un sous-total |
|
| 277 | + elseif ($subtotal_niveau < $title_niveau) { |
|
| 278 | + // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3) |
|
| 229 | 279 | { |
| 230 | - if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; // mode strict niveau pas égale donc faux |
|
| 231 | - else return true; // mode libre => OK je considère que mon titre à un sous-total |
|
| 280 | + if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; |
|
| 281 | + } |
|
| 282 | + // mode strict niveau pas égale donc faux |
|
| 283 | + else { |
|
| 284 | + return true; |
|
| 285 | + } |
|
| 286 | + // mode libre => OK je considère que mon titre à un sous-total |
|
| 232 | 287 | } |
| 233 | 288 | } |
| 234 | 289 | |
@@ -276,16 +331,19 @@ discard block |
||
| 276 | 331 | |
| 277 | 332 | foreach ($object->lines as &$l) |
| 278 | 333 | { |
| 279 | - if ($l->rang <= $line->rang) continue; |
|
| 280 | - elseif (self::isSubtotal($l) && self::getNiveau($l) == $line->qty) break; |
|
| 281 | - elseif (self::isModSubtotalLine($l)) continue; |
|
| 334 | + if ($l->rang <= $line->rang) { |
|
| 335 | + continue; |
|
| 336 | + } elseif (self::isSubtotal($l) && self::getNiveau($l) == $line->qty) { |
|
| 337 | + break; |
|
| 338 | + } elseif (self::isModSubtotalLine($l)) { |
|
| 339 | + continue; |
|
| 340 | + } |
|
| 282 | 341 | |
| 283 | 342 | if (!empty($l->array_options['options_subtotal_nc'])) |
| 284 | 343 | { |
| 285 | 344 | $tabprice = calcul_price_total($l->qty, $l->subprice, $l->remise_percent, $l->tva_tx, $l->localtax1_tx, $l->localtax2_tx, 0, 'HT', $l->info_bits, $l->product_type); |
| 286 | 345 | $TTot['total_options'] += $tabprice[0]; // total ht |
| 287 | - } |
|
| 288 | - else |
|
| 346 | + } else |
|
| 289 | 347 | { |
| 290 | 348 | $TTot['total_pa_ht'] += $l->pa_ht * $l->qty; |
| 291 | 349 | $TTot['total_subprice'] += $l->subprice * $l->qty; |
@@ -305,29 +363,41 @@ discard block |
||
| 305 | 363 | |
| 306 | 364 | public static function getOrderIdFromLineId(&$db, $fk_commandedet) |
| 307 | 365 | { |
| 308 | - if (empty($fk_commandedet)) return false; |
|
| 366 | + if (empty($fk_commandedet)) { |
|
| 367 | + return false; |
|
| 368 | + } |
|
| 309 | 369 | |
| 310 | 370 | $sql = 'SELECT fk_commande FROM '.MAIN_DB_PREFIX.'commandedet WHERE rowid = '.$fk_commandedet; |
| 311 | 371 | $resql = $db->query($sql); |
| 312 | 372 | |
| 313 | - if ($resql && ($row = $db->fetch_object($resql))) return $row->fk_commande; |
|
| 314 | - else return false; |
|
| 373 | + if ($resql && ($row = $db->fetch_object($resql))) { |
|
| 374 | + return $row->fk_commande; |
|
| 375 | + } else { |
|
| 376 | + return false; |
|
| 377 | + } |
|
| 315 | 378 | } |
| 316 | 379 | |
| 317 | 380 | public static function getLastLineOrderId(&$db, $fk_commande) |
| 318 | 381 | { |
| 319 | - if (empty($fk_commande)) return false; |
|
| 382 | + if (empty($fk_commande)) { |
|
| 383 | + return false; |
|
| 384 | + } |
|
| 320 | 385 | |
| 321 | 386 | $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'commandedet WHERE fk_commande = '.$fk_commande.' ORDER BY rang DESC LIMIT 1'; |
| 322 | 387 | $resql = $db->query($sql); |
| 323 | 388 | |
| 324 | - if ($resql && ($row = $db->fetch_object($resql))) return $row->rowid; |
|
| 325 | - else return false; |
|
| 389 | + if ($resql && ($row = $db->fetch_object($resql))) { |
|
| 390 | + return $row->rowid; |
|
| 391 | + } else { |
|
| 392 | + return false; |
|
| 393 | + } |
|
| 326 | 394 | } |
| 327 | 395 | |
| 328 | 396 | public static function getParentTitleOfLine(&$object, $i) |
| 329 | 397 | { |
| 330 | - if ($i <= 0) return false; |
|
| 398 | + if ($i <= 0) { |
|
| 399 | + return false; |
|
| 400 | + } |
|
| 331 | 401 | |
| 332 | 402 | $skip_title = 0; |
| 333 | 403 | // Je parcours les lignes précédentes |
@@ -346,8 +416,7 @@ discard block |
||
| 346 | 416 | //@INFO J'ai ma ligne titre qui contient ma ligne, par contre je check pas s'il y a un sous-total |
| 347 | 417 | return $line; |
| 348 | 418 | break; |
| 349 | - } |
|
| 350 | - elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99) |
|
| 419 | + } elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99) |
|
| 351 | 420 | { |
| 352 | 421 | // Il s'agit d'un sous-total, ça veut dire que le prochain titre théoriquement doit être ignorer (je travail avec un incrément au cas ou je croise plusieurs sous-totaux) |
| 353 | 422 | $skip_title++; |
@@ -362,7 +431,9 @@ discard block |
||
| 362 | 431 | $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty <= 9; |
| 363 | 432 | if($res && $level > -1) { |
| 364 | 433 | return $line->qty == $level; |
| 365 | - } else return $res; |
|
| 434 | + } else { |
|
| 435 | + return $res; |
|
| 436 | + } |
|
| 366 | 437 | |
| 367 | 438 | } |
| 368 | 439 | |
@@ -371,7 +442,9 @@ discard block |
||
| 371 | 442 | $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90; |
| 372 | 443 | if($res && $level > -1) { |
| 373 | 444 | return self::getNiveau($line) == $level; |
| 374 | - } else return $res; |
|
| 445 | + } else { |
|
| 446 | + return $res; |
|
| 447 | + } |
|
| 375 | 448 | } |
| 376 | 449 | |
| 377 | 450 | public static function isFreeText(&$line) |
@@ -392,10 +465,14 @@ discard block |
||
| 392 | 465 | // editeur wysiwyg |
| 393 | 466 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
| 394 | 467 | $nbrows=ROWS_2; |
| 395 | - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
| 468 | + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) { |
|
| 469 | + $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
| 470 | + } |
|
| 396 | 471 | $enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); |
| 397 | 472 | $toolbarname='dolibarr_details'; |
| 398 | - if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes'; |
|
| 473 | + if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) { |
|
| 474 | + $toolbarname='dolibarr_notes'; |
|
| 475 | + } |
|
| 399 | 476 | $text = !empty($line->description)?$line->description:$line->label; |
| 400 | 477 | $doleditor=new DolEditor('line-description',$text,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%', $readonly); |
| 401 | 478 | return $doleditor->Create(1); |
@@ -410,12 +487,10 @@ discard block |
||
| 410 | 487 | { |
| 411 | 488 | $object->statut = 0; // hack for facture rec |
| 412 | 489 | $createRight = $user->rights->facture->creer; |
| 413 | - } |
|
| 414 | - elseif($object->element == 'order_supplier' ) |
|
| 490 | + } elseif($object->element == 'order_supplier' ) |
|
| 415 | 491 | { |
| 416 | 492 | $createRight = $user->rights->fournisseur->commande->creer; |
| 417 | - } |
|
| 418 | - elseif($object->element == 'invoice_supplier' ) |
|
| 493 | + } elseif($object->element == 'invoice_supplier' ) |
|
| 419 | 494 | { |
| 420 | 495 | $createRight = $user->rights->fournisseur->facture->creer; |
| 421 | 496 | } |
@@ -488,8 +563,9 @@ discard block |
||
| 488 | 563 | |
| 489 | 564 | $TLineAdded[] = $object->line; |
| 490 | 565 | // Error from addline |
| 491 | - if ($res <= 0) break; |
|
| 492 | - else |
|
| 566 | + if ($res <= 0) { |
|
| 567 | + break; |
|
| 568 | + } else |
|
| 493 | 569 | { |
| 494 | 570 | $object->line_from = $line; |
| 495 | 571 | // Call trigger |
@@ -511,8 +587,7 @@ discard block |
||
| 511 | 587 | _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']); |
| 512 | 588 | } |
| 513 | 589 | return count($TLineAdded); |
| 514 | - } |
|
| 515 | - else |
|
| 590 | + } else |
|
| 516 | 591 | { |
| 517 | 592 | $object->db->rollback(); |
| 518 | 593 | return -1; |
@@ -528,10 +603,14 @@ discard block |
||
| 528 | 603 | global $langs; |
| 529 | 604 | |
| 530 | 605 | // Besoin de comparer sur les 2 formes d'écriture |
| 531 | - if (!$key_is_id) $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad)); |
|
| 606 | + if (!$key_is_id) { |
|
| 607 | + $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad)); |
|
| 608 | + } |
|
| 532 | 609 | |
| 533 | 610 | $TTitle_under_search = array(); |
| 534 | - if (!empty($under_title)) $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title)); |
|
| 611 | + if (!empty($under_title)) { |
|
| 612 | + $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title)); |
|
| 613 | + } |
|
| 535 | 614 | |
| 536 | 615 | $TLine = array(); |
| 537 | 616 | $add_line = false; |
@@ -541,28 +620,37 @@ discard block |
||
| 541 | 620 | { |
| 542 | 621 | if (!$under_title_found && !empty($TTitle_under_search)) |
| 543 | 622 | { |
| 544 | - if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true; |
|
| 545 | - } |
|
| 546 | - else |
|
| 623 | + if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) { |
|
| 624 | + $under_title_found = true; |
|
| 625 | + } |
|
| 626 | + } else |
|
| 547 | 627 | { |
| 548 | 628 | if ( ($key_is_id && $line->id == $key_trad) || (!$key_is_id && $line->product_type == 9 && $line->qty == $level && (in_array($line->desc, $TTitle_search) || in_array($line->label, $TTitle_search) ))) |
| 549 | 629 | { |
| 550 | - if ($key_is_id) $level = $line->qty; |
|
| 630 | + if ($key_is_id) { |
|
| 631 | + $level = $line->qty; |
|
| 632 | + } |
|
| 551 | 633 | |
| 552 | 634 | $add_line = true; |
| 553 | - if ($withBlockLine) $TLine[] = $line; |
|
| 635 | + if ($withBlockLine) { |
|
| 636 | + $TLine[] = $line; |
|
| 637 | + } |
|
| 554 | 638 | continue; |
| 555 | - } |
|
| 556 | - elseif ($add_line && $line->product_type == 9 && (100 - $line->qty == $level) ) // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre |
|
| 639 | + } elseif ($add_line && $line->product_type == 9 && (100 - $line->qty == $level) ) { |
|
| 640 | + // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre |
|
| 557 | 641 | { |
| 558 | 642 | if ($withBlockLine) $TLine[] = $line; |
| 643 | + } |
|
| 559 | 644 | break; |
| 560 | 645 | } |
| 561 | 646 | |
| 562 | 647 | if ($add_line) |
| 563 | 648 | { |
| 564 | - if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue; |
|
| 565 | - else $TLine[] = $line; |
|
| 649 | + if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) { |
|
| 650 | + continue; |
|
| 651 | + } else { |
|
| 652 | + $TLine[] = $line; |
|
| 653 | + } |
|
| 566 | 654 | } |
| 567 | 655 | } |
| 568 | 656 | } |
@@ -596,7 +684,9 @@ discard block |
||
| 596 | 684 | |
| 597 | 685 | case 'order_supplier': |
| 598 | 686 | $object->special_code = SELF::$module_number; |
| 599 | - if (empty($desc)) $desc = $label; |
|
| 687 | + if (empty($desc)) { |
|
| 688 | + $desc = $label; |
|
| 689 | + } |
|
| 600 | 690 | $res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, 0, $date_start, $date_end, $array_options, $fk_unit); |
| 601 | 691 | break; |
| 602 | 692 | |
@@ -606,7 +696,9 @@ discard block |
||
| 606 | 696 | |
| 607 | 697 | case 'invoice_supplier': |
| 608 | 698 | $object->special_code = SELF::$module_number; |
| 609 | - if (empty($desc)) $desc = $label; |
|
| 699 | + if (empty($desc)) { |
|
| 700 | + $desc = $label; |
|
| 701 | + } |
|
| 610 | 702 | $res = $object->updateline($rowid, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, 0, $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $fk_unit); |
| 611 | 703 | break; |
| 612 | 704 | |
@@ -623,8 +715,11 @@ discard block |
||
| 623 | 715 | break; |
| 624 | 716 | } |
| 625 | 717 | |
| 626 | - if ($res <= 0) $object->db->rollback(); |
|
| 627 | - else $object->db->commit(); |
|
| 718 | + if ($res <= 0) { |
|
| 719 | + $object->db->rollback(); |
|
| 720 | + } else { |
|
| 721 | + $object->db->commit(); |
|
| 722 | + } |
|
| 628 | 723 | |
| 629 | 724 | return $res; |
| 630 | 725 | } |
@@ -634,24 +729,20 @@ discard block |
||
| 634 | 729 | global $db, $object; |
| 635 | 730 | |
| 636 | 731 | $TTitle = array(); |
| 637 | - if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} |
|
| 638 | - else { |
|
| 732 | + if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} else { |
|
| 639 | 733 | if ($origin_line->element == 'propaldet') |
| 640 | 734 | { |
| 641 | 735 | $object = new Propal($db); |
| 642 | 736 | $object->fetch($origin_line->fk_propal); |
| 643 | - } |
|
| 644 | - else if ($origin_line->element == 'commandedet') |
|
| 737 | + } else if ($origin_line->element == 'commandedet') |
|
| 645 | 738 | { |
| 646 | 739 | $object = new Commande($db); |
| 647 | 740 | $object->fetch($origin_line->fk_commande); |
| 648 | - } |
|
| 649 | - else if ($origin_line->element == 'facturedet') |
|
| 741 | + } else if ($origin_line->element == 'facturedet') |
|
| 650 | 742 | { |
| 651 | 743 | $object = new Facture($db); |
| 652 | 744 | $object->fetch($origin_line->fk_facture); |
| 653 | - } |
|
| 654 | - else |
|
| 745 | + } else |
|
| 655 | 746 | { |
| 656 | 747 | return $TTitle; |
| 657 | 748 | } |
@@ -661,8 +752,11 @@ discard block |
||
| 661 | 752 | $i = 0; |
| 662 | 753 | foreach ($object->lines as &$line) |
| 663 | 754 | { |
| 664 | - if ($origin_line->id == $line->id) break; |
|
| 665 | - else $i++; |
|
| 755 | + if ($origin_line->id == $line->id) { |
|
| 756 | + break; |
|
| 757 | + } else { |
|
| 758 | + $i++; |
|
| 759 | + } |
|
| 666 | 760 | } |
| 667 | 761 | |
| 668 | 762 | $i--; // Skip la ligne d'origine |
@@ -677,35 +771,43 @@ discard block |
||
| 677 | 771 | if (self::isSubtotal($object->lines[$y])) |
| 678 | 772 | { |
| 679 | 773 | $next_title_lvl_to_skip = self::getNiveau($object->lines[$y]); |
| 680 | - } |
|
| 681 | - elseif (self::isTitle($object->lines[$y])) |
|
| 774 | + } elseif (self::isTitle($object->lines[$y])) |
|
| 682 | 775 | { |
| 683 | 776 | if ($object->lines[$y]->qty == $next_title_lvl_to_skip) |
| 684 | 777 | { |
| 685 | 778 | $next_title_lvl_to_skip = 0; |
| 686 | 779 | continue; |
| 687 | - } |
|
| 688 | - else |
|
| 780 | + } else |
|
| 689 | 781 | { |
| 690 | - if (empty($object->lines[$y]->array_options)) $object->lines[$y]->fetch_optionals(); |
|
| 782 | + if (empty($object->lines[$y]->array_options)) { |
|
| 783 | + $object->lines[$y]->fetch_optionals(); |
|
| 784 | + } |
|
| 691 | 785 | $TTitle[$object->lines[$y]->id] = $object->lines[$y]; |
| 692 | 786 | |
| 693 | - if ($object->lines[$y]->qty == 1) break; |
|
| 787 | + if ($object->lines[$y]->qty == 1) { |
|
| 788 | + break; |
|
| 789 | + } |
|
| 694 | 790 | } |
| 695 | 791 | } |
| 696 | 792 | } |
| 697 | 793 | } |
| 698 | 794 | |
| 699 | - if ($reverse) $TTitle = array_reverse($TTitle, true); |
|
| 795 | + if ($reverse) { |
|
| 796 | + $TTitle = array_reverse($TTitle, true); |
|
| 797 | + } |
|
| 700 | 798 | |
| 701 | 799 | return $TTitle; |
| 702 | 800 | } |
| 703 | 801 | |
| 704 | 802 | public static function getNiveau(&$line) |
| 705 | 803 | { |
| 706 | - if (self::isTitle($line)) return $line->qty; |
|
| 707 | - elseif (self::isSubtotal($line)) return 100 - $line->qty; |
|
| 708 | - else return 0; |
|
| 804 | + if (self::isTitle($line)) { |
|
| 805 | + return $line->qty; |
|
| 806 | + } elseif (self::isSubtotal($line)) { |
|
| 807 | + return 100 - $line->qty; |
|
| 808 | + } else { |
|
| 809 | + return 0; |
|
| 810 | + } |
|
| 709 | 811 | } |
| 710 | 812 | |
| 711 | 813 | /** |
@@ -730,10 +832,16 @@ discard block |
||
| 730 | 832 | $objmarge->marge_droite = 10; |
| 731 | 833 | |
| 732 | 834 | $objectref = dol_sanitizeFileName($object->ref); |
| 733 | - if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref; |
|
| 734 | - elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref; |
|
| 735 | - elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref; |
|
| 736 | - elseif ($object->element == 'facturerec') return; // no PDF for facturerec |
|
| 835 | + if ($object->element == 'propal') { |
|
| 836 | + $dir = $conf->propal->dir_output . '/' . $objectref; |
|
| 837 | + } elseif ($object->element == 'commande') { |
|
| 838 | + $dir = $conf->commande->dir_output . '/' . $objectref; |
|
| 839 | + } elseif ($object->element == 'facture') { |
|
| 840 | + $dir = $conf->facture->dir_output . '/' . $objectref; |
|
| 841 | + } elseif ($object->element == 'facturerec') { |
|
| 842 | + return; |
|
| 843 | + } |
|
| 844 | + // no PDF for facturerec |
|
| 737 | 845 | else |
| 738 | 846 | { |
| 739 | 847 | setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings'); |
@@ -768,7 +876,9 @@ discard block |
||
| 768 | 876 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
| 769 | 877 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
| 770 | 878 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
| 771 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 879 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
| 880 | + $pdf->SetCompression(false); |
|
| 881 | + } |
|
| 772 | 882 | |
| 773 | 883 | $pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite); // Left, Top, Right |
| 774 | 884 | |
@@ -778,7 +888,9 @@ discard block |
||
| 778 | 888 | |
| 779 | 889 | // New page |
| 780 | 890 | $pdf->AddPage(); |
| 781 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 891 | + if (! empty($tplidx)) { |
|
| 892 | + $pdf->useTemplate($tplidx); |
|
| 893 | + } |
|
| 782 | 894 | $pagenb++; |
| 783 | 895 | |
| 784 | 896 | |
@@ -834,8 +946,10 @@ discard block |
||
| 834 | 946 | { |
| 835 | 947 | $TTot['TTotal_tva_multicurrency'][$tx] += $amount; |
| 836 | 948 | } |
| 949 | + } else { |
|
| 950 | + $pdf->SetFont('','', $default_font_size - 1); |
|
| 837 | 951 | } |
| 838 | - else $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
| 952 | + // Into loop to work with multipage |
|
| 839 | 953 | |
| 840 | 954 | $pdf->SetTextColor(0,0,0); |
| 841 | 955 | |
@@ -857,9 +971,11 @@ discard block |
||
| 857 | 971 | $pdf->startTransaction(); |
| 858 | 972 | $pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true); |
| 859 | 973 | $pageposafter=$pdf->getPage(); |
| 860 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
| 974 | + if ($pageposafter > $pageposbefore) { |
|
| 975 | + // There is a pagebreak |
|
| 861 | 976 | { |
| 862 | 977 | $pdf->rollbackTransaction(true); |
| 978 | + } |
|
| 863 | 979 | $pageposafter=$pageposbefore; |
| 864 | 980 | //print $pageposafter.'-'.$pageposbefore;exit; |
| 865 | 981 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
@@ -868,23 +984,27 @@ discard block |
||
| 868 | 984 | $pageposafter=$pdf->getPage(); |
| 869 | 985 | $posyafter=$pdf->GetY(); |
| 870 | 986 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
| 871 | - if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) // There is no space left for total+free text |
|
| 987 | + if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) { |
|
| 988 | + // There is no space left for total+free text |
|
| 872 | 989 | { |
| 873 | 990 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
| 874 | 991 | { |
| 875 | 992 | $pdf->AddPage('','',true); |
| 876 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
| 877 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
| 993 | + } |
|
| 994 | + if (! empty($tplidx)) { |
|
| 995 | + $pdf->useTemplate($tplidx); |
|
| 996 | + } |
|
| 997 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
| 998 | + self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
| 999 | + } |
|
| 878 | 1000 | $pdf->setPage($pageposafter+1); |
| 879 | 1001 | } |
| 880 | - } |
|
| 881 | - else |
|
| 1002 | + } else |
|
| 882 | 1003 | { |
| 883 | 1004 | // We found a page break |
| 884 | 1005 | $showpricebeforepagebreak=0; |
| 885 | 1006 | } |
| 886 | - } |
|
| 887 | - else // No pagebreak |
|
| 1007 | + } else // No pagebreak |
|
| 888 | 1008 | { |
| 889 | 1009 | $pdf->commitTransaction(); |
| 890 | 1010 | } |
@@ -924,8 +1044,7 @@ discard block |
||
| 924 | 1044 | if ($pagenb == 1) |
| 925 | 1045 | { |
| 926 | 1046 | self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $objmarge->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code); |
| 927 | - } |
|
| 928 | - else |
|
| 1047 | + } else |
|
| 929 | 1048 | { |
| 930 | 1049 | self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top_newpage, $objmarge->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code); |
| 931 | 1050 | } |
@@ -933,7 +1052,9 @@ discard block |
||
| 933 | 1052 | $pagenb++; |
| 934 | 1053 | $pdf->setPage($pagenb); |
| 935 | 1054 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
| 936 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
| 1055 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
| 1056 | + self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
| 1057 | + } |
|
| 937 | 1058 | } |
| 938 | 1059 | } |
| 939 | 1060 | } |
@@ -943,8 +1064,7 @@ discard block |
||
| 943 | 1064 | { |
| 944 | 1065 | self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $objmarge->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code); |
| 945 | 1066 | $bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
| 946 | - } |
|
| 947 | - else |
|
| 1067 | + } else |
|
| 948 | 1068 | { |
| 949 | 1069 | self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top_newpage, $objmarge->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code); |
| 950 | 1070 | $bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
@@ -958,7 +1078,9 @@ discard block |
||
| 958 | 1078 | |
| 959 | 1079 | $pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file); |
| 960 | 1080 | |
| 961 | - if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) unlink($file); |
|
| 1081 | + if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) { |
|
| 1082 | + unlink($file); |
|
| 1083 | + } |
|
| 962 | 1084 | } |
| 963 | 1085 | |
| 964 | 1086 | private static function printLevel($objmarge, $pdf, $line, $curY, $posx_designation) |
@@ -1001,8 +1123,7 @@ discard block |
||
| 1001 | 1123 | { |
| 1002 | 1124 | $height=pdf_getHeightForLogo($logo); |
| 1003 | 1125 | $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto) |
| 1004 | - } |
|
| 1005 | - else |
|
| 1126 | + } else |
|
| 1006 | 1127 | { |
| 1007 | 1128 | $pdf->SetTextColor(200,0,0); |
| 1008 | 1129 | $pdf->SetFont('','B',$default_font_size - 2); |
@@ -1011,8 +1132,7 @@ discard block |
||
| 1011 | 1132 | } |
| 1012 | 1133 | |
| 1013 | 1134 | $posy+=35; |
| 1014 | - } |
|
| 1015 | - else |
|
| 1135 | + } else |
|
| 1016 | 1136 | { |
| 1017 | 1137 | $text=$mysoc->name; |
| 1018 | 1138 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -1026,9 +1146,13 @@ discard block |
||
| 1026 | 1146 | $pdf->SetXY($objmarge->marge_gauche,$posy); |
| 1027 | 1147 | |
| 1028 | 1148 | $key = 'subtotalPropalTitle'; |
| 1029 | - if ($object->element == 'commande') $key = 'subtotalCommandeTitle'; |
|
| 1030 | - elseif ($object->element == 'facture') $key = 'subtotalInvoiceTitle'; |
|
| 1031 | - elseif ($object->element == 'facturerec') $key = 'subtotalInvoiceTitle'; |
|
| 1149 | + if ($object->element == 'commande') { |
|
| 1150 | + $key = 'subtotalCommandeTitle'; |
|
| 1151 | + } elseif ($object->element == 'facture') { |
|
| 1152 | + $key = 'subtotalInvoiceTitle'; |
|
| 1153 | + } elseif ($object->element == 'facturerec') { |
|
| 1154 | + $key = 'subtotalInvoiceTitle'; |
|
| 1155 | + } |
|
| 1032 | 1156 | |
| 1033 | 1157 | $pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L'); |
| 1034 | 1158 | |
@@ -1063,7 +1187,9 @@ discard block |
||
| 1063 | 1187 | |
| 1064 | 1188 | // Force to disable hidetop and hidebottom |
| 1065 | 1189 | $hidebottom=0; |
| 1066 | - if ($hidetop) $hidetop=-1; |
|
| 1190 | + if ($hidetop) { |
|
| 1191 | + $hidetop=-1; |
|
| 1192 | + } |
|
| 1067 | 1193 | |
| 1068 | 1194 | $currency = !empty($currency) ? $currency : $conf->currency; |
| 1069 | 1195 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
@@ -1078,7 +1204,9 @@ discard block |
||
| 1078 | 1204 | $pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5); |
| 1079 | 1205 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
| 1080 | 1206 | |
| 1081 | - if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite-$objmarge->marge_gauche, 8, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
| 1207 | + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { |
|
| 1208 | + $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite-$objmarge->marge_gauche, 8, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)); |
|
| 1209 | + } |
|
| 1082 | 1210 | |
| 1083 | 1211 | |
| 1084 | 1212 | $pdf->line($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top); // line prend une position y en 2eme param et 4eme param |
@@ -1091,8 +1219,7 @@ discard block |
||
| 1091 | 1219 | $pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R'); |
| 1092 | 1220 | |
| 1093 | 1221 | $pdf->line($objmarge->marge_gauche, $tab_top+8, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top+8); // line prend une position y en 2eme param et 4eme param |
| 1094 | - } |
|
| 1095 | - else |
|
| 1222 | + } else |
|
| 1096 | 1223 | { |
| 1097 | 1224 | $pdf->line($objmarge->marge_gauche, $tab_top-2, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top-2); // line prend une position y en 2eme param et 4eme param |
| 1098 | 1225 | } |
@@ -1113,10 +1240,12 @@ discard block |
||
| 1113 | 1240 | |
| 1114 | 1241 | // Tableau total |
| 1115 | 1242 | $col1x = 120; $col2x = 170; |
| 1116 | - if ($objmarge->page_largeur < 210) // To work with US executive format |
|
| 1243 | + if ($objmarge->page_largeur < 210) { |
|
| 1244 | + // To work with US executive format |
|
| 1117 | 1245 | { |
| 1118 | 1246 | $col2x-=20; |
| 1119 | 1247 | } |
| 1248 | + } |
|
| 1120 | 1249 | $largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x); |
| 1121 | 1250 | |
| 1122 | 1251 | $useborder=0; |
@@ -1138,9 +1267,11 @@ discard block |
||
| 1138 | 1267 | $atleastoneratenotnull=0; |
| 1139 | 1268 | foreach($TTot['TTotal_tva'] as $tvakey => $tvaval) |
| 1140 | 1269 | { |
| 1141 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
| 1270 | + if ($tvakey != 0) { |
|
| 1271 | + // On affiche pas taux 0 |
|
| 1142 | 1272 | { |
| 1143 | 1273 | $atleastoneratenotnull++; |
| 1274 | + } |
|
| 1144 | 1275 | |
| 1145 | 1276 | $index++; |
| 1146 | 1277 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
@@ -1193,9 +1324,13 @@ discard block |
||
| 1193 | 1324 | */ |
| 1194 | 1325 | private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
| 1195 | 1326 | { |
| 1196 | - if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
| 1327 | + if (empty($hidetop) || $hidetop==-1) { |
|
| 1328 | + $pdf->line($x, $y, $x+$l, $y); |
|
| 1329 | + } |
|
| 1197 | 1330 | $pdf->line($x+$l, $y, $x+$l, $y+$h); |
| 1198 | - if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
| 1331 | + if (empty($hidebottom)) { |
|
| 1332 | + $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
| 1333 | + } |
|
| 1199 | 1334 | $pdf->line($x, $y+$h, $x, $y); |
| 1200 | 1335 | } |
| 1201 | 1336 | |
@@ -1204,7 +1339,9 @@ discard block |
||
| 1204 | 1339 | { |
| 1205 | 1340 | global $conf; |
| 1206 | 1341 | |
| 1207 | - if (empty($fileoutput)) $fileoutput = $file[0]; |
|
| 1342 | + if (empty($fileoutput)) { |
|
| 1343 | + $fileoutput = $file[0]; |
|
| 1344 | + } |
|
| 1208 | 1345 | |
| 1209 | 1346 | $pdf=pdf_getInstance(); |
| 1210 | 1347 | if (class_exists('TCPDF')) |
@@ -1214,7 +1351,9 @@ discard block |
||
| 1214 | 1351 | } |
| 1215 | 1352 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
| 1216 | 1353 | |
| 1217 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
| 1354 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
| 1355 | + $pdf->SetCompression(false); |
|
| 1356 | + } |
|
| 1218 | 1357 | |
| 1219 | 1358 | |
| 1220 | 1359 | foreach($files as $file) |
@@ -1230,7 +1369,9 @@ discard block |
||
| 1230 | 1369 | } |
| 1231 | 1370 | |
| 1232 | 1371 | $pdf->Output($fileoutput,'F'); |
| 1233 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 1372 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
| 1373 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
| 1374 | + } |
|
| 1234 | 1375 | |
| 1235 | 1376 | return $pagecount; |
| 1236 | 1377 | } |
@@ -1243,7 +1384,9 @@ discard block |
||
| 1243 | 1384 | */ |
| 1244 | 1385 | public static function hasNcTitle(&$line) |
| 1245 | 1386 | { |
| 1246 | - if(isset($line->has_nc_title)) return $line->has_nc_title; |
|
| 1387 | + if(isset($line->has_nc_title)) { |
|
| 1388 | + return $line->has_nc_title; |
|
| 1389 | + } |
|
| 1247 | 1390 | |
| 1248 | 1391 | $TTitle = self::getAllTitleFromLine($line); |
| 1249 | 1392 | foreach ($TTitle as &$line_title) |
@@ -1268,7 +1411,9 @@ discard block |
||
| 1268 | 1411 | public static function getTitleLabel($line) |
| 1269 | 1412 | { |
| 1270 | 1413 | $title = $line->label; |
| 1271 | - if (empty($title)) $title = !empty($line->description) ? $line->description : $line->desc; |
|
| 1414 | + if (empty($title)) { |
|
| 1415 | + $title = !empty($line->description) ? $line->description : $line->desc; |
|
| 1416 | + } |
|
| 1272 | 1417 | return $title; |
| 1273 | 1418 | } |
| 1274 | 1419 | } |