@@ -45,7 +45,9 @@ discard block |
||
45 | 45 | $value = ''; |
46 | 46 | $sql = 'SELECT content FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text WHERE rowid = '.GETPOST('rowid'); |
47 | 47 | $resql = $this->db->query($sql); |
48 | - if ($resql && ($obj = $this->db->fetch_object($resql))) $value = $obj->content; |
|
48 | + if ($resql && ($obj = $this->db->fetch_object($resql))) { |
|
49 | + $value = $obj->content; |
|
50 | + } |
|
49 | 51 | } |
50 | 52 | |
51 | 53 | ?> |
@@ -129,8 +131,11 @@ discard block |
||
129 | 131 | if ($object->statut == 0 && $createRight) { |
130 | 132 | |
131 | 133 | |
132 | - if($object->element=='facture')$idvar = 'facid'; |
|
133 | - else $idvar='id'; |
|
134 | + if($object->element=='facture') { |
|
135 | + $idvar = 'facid'; |
|
136 | + } else { |
|
137 | + $idvar='id'; |
|
138 | + } |
|
134 | 139 | |
135 | 140 | if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) ) |
136 | 141 | { |
@@ -138,10 +143,11 @@ discard block |
||
138 | 143 | |
139 | 144 | if($action=='add_title_line') { |
140 | 145 | $title = GETPOST('title'); |
141 | - if(empty($title)) $title = $langs->trans('title'); |
|
146 | + if(empty($title)) { |
|
147 | + $title = $langs->trans('title'); |
|
148 | + } |
|
142 | 149 | $qty = $level<1 ? 1 : $level ; |
143 | - } |
|
144 | - else if($action=='add_free_text') { |
|
150 | + } else if($action=='add_free_text') { |
|
145 | 151 | $title = GETPOST('title'); |
146 | 152 | |
147 | 153 | if (empty($title)) { |
@@ -153,29 +159,31 @@ discard block |
||
153 | 159 | } |
154 | 160 | } |
155 | 161 | } |
156 | - if(empty($title)) $title = $langs->trans('subtotalAddLineDescription'); |
|
162 | + if(empty($title)) { |
|
163 | + $title = $langs->trans('subtotalAddLineDescription'); |
|
164 | + } |
|
157 | 165 | $qty = 50; |
158 | - } |
|
159 | - else if($action=='add_subtitle_line') { |
|
166 | + } else if($action=='add_subtitle_line') { |
|
160 | 167 | $title = GETPOST('title'); |
161 | - if(empty($title)) $title = $langs->trans('subtitle'); |
|
168 | + if(empty($title)) { |
|
169 | + $title = $langs->trans('subtitle'); |
|
170 | + } |
|
162 | 171 | $qty = 2; |
163 | - } |
|
164 | - else if($action=='add_subtotal_line') { |
|
172 | + } else if($action=='add_subtotal_line') { |
|
165 | 173 | $title = $langs->trans('SubSubTotal'); |
166 | 174 | $qty = 98; |
167 | - } |
|
168 | - else { |
|
175 | + } else { |
|
169 | 176 | $title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal'); |
170 | 177 | $qty = $level ? 100-$level : 99; |
171 | 178 | } |
172 | 179 | dol_include_once('/subtotal/class/subtotal.class.php'); |
173 | 180 | |
174 | - if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty); |
|
181 | + if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) { |
|
182 | + TSubtotal::addSubtotalMissing($object, $qty); |
|
183 | + } |
|
175 | 184 | |
176 | 185 | TSubtotal::addSubTotalLine($object, $title, $qty); |
177 | - } |
|
178 | - else if($action==='ask_deleteallline') { |
|
186 | + } else if($action==='ask_deleteallline') { |
|
179 | 187 | $form=new Form($db); |
180 | 188 | |
181 | 189 | $lineid = GETPOST('lineid','integer'); |
@@ -198,8 +206,7 @@ discard block |
||
198 | 206 | $this->printNewFormat($object, $conf, $langs, $idvar); |
199 | 207 | } |
200 | 208 | } |
201 | - } |
|
202 | - elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts)) |
|
209 | + } elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts)) |
|
203 | 210 | { |
204 | 211 | ?> |
205 | 212 | <script type="text/javascript"> |
@@ -217,8 +224,13 @@ discard block |
||
217 | 224 | |
218 | 225 | function printNewFormat(&$object, &$conf, &$langs, $idvar) |
219 | 226 | { |
220 | - if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) return false; |
|
221 | - if ($line->fk_prev_id != null && !empty($line->fk_prev_id)) return false; // Si facture de situation |
|
227 | + if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) { |
|
228 | + return false; |
|
229 | + } |
|
230 | + if ($line->fk_prev_id != null && !empty($line->fk_prev_id)) { |
|
231 | + return false; |
|
232 | + } |
|
233 | + // Si facture de situation |
|
222 | 234 | ?> |
223 | 235 | <script type="text/javascript"> |
224 | 236 | $(document).ready(function() { |
@@ -504,8 +516,7 @@ discard block |
||
504 | 516 | } |
505 | 517 | |
506 | 518 | |
507 | - } |
|
508 | - else{ |
|
519 | + } else{ |
|
509 | 520 | $substitutionarray['line_not_modsubtotal'] = true; |
510 | 521 | $substitutionarray['line_modsubtotal'] = 0; |
511 | 522 | } |
@@ -563,8 +574,11 @@ discard block |
||
563 | 574 | |
564 | 575 | $showBlockExtrafields = GETPOST('showBlockExtrafields'); |
565 | 576 | |
566 | - if($object->element=='facture') $idvar = 'facid'; |
|
567 | - else $idvar = 'id'; |
|
577 | + if($object->element=='facture') { |
|
578 | + $idvar = 'facid'; |
|
579 | + } else { |
|
580 | + $idvar = 'id'; |
|
581 | + } |
|
568 | 582 | |
569 | 583 | if ($action == 'updateligne' || $action == 'updateline') |
570 | 584 | { |
@@ -594,8 +608,7 @@ discard block |
||
594 | 608 | header('Location: '.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id); |
595 | 609 | exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne |
596 | 610 | } |
597 | - } |
|
598 | - else if($action === 'builddoc') { |
|
611 | + } else if($action === 'builddoc') { |
|
599 | 612 | |
600 | 613 | if ( |
601 | 614 | in_array('invoicecard',explode(':',$parameters['context'])) |
@@ -610,33 +623,27 @@ discard block |
||
610 | 623 | $sessname = 'subtotal_hideInnerLines_facture'; |
611 | 624 | $sessname2 = 'subtotal_hidedetails_facture'; |
612 | 625 | $sessname3 = 'subtotal_hideprices_facture'; |
613 | - } |
|
614 | - elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) { |
|
626 | + } elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) { |
|
615 | 627 | $sessname = 'subtotal_hideInnerLines_facture_fournisseur'; |
616 | 628 | $sessname2 = 'subtotal_hidedetails_facture_fournisseur'; |
617 | 629 | $sessname3 = 'subtotal_hideprices_facture_fournisseur'; |
618 | - } |
|
619 | - elseif(in_array('propalcard',explode(':',$parameters['context']))) { |
|
630 | + } elseif(in_array('propalcard',explode(':',$parameters['context']))) { |
|
620 | 631 | $sessname = 'subtotal_hideInnerLines_propal'; |
621 | 632 | $sessname2 = 'subtotal_hidedetails_propal'; |
622 | 633 | $sessname3 = 'subtotal_hideprices_propal'; |
623 | - } |
|
624 | - elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) { |
|
634 | + } elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) { |
|
625 | 635 | $sessname = 'subtotal_hideInnerLines_supplier_proposal'; |
626 | 636 | $sessname2 = 'subtotal_hidedetails_supplier_proposal'; |
627 | 637 | $sessname3 = 'subtotal_hideprices_supplier_proposal'; |
628 | - } |
|
629 | - elseif(in_array('ordercard',explode(':',$parameters['context']))) { |
|
638 | + } elseif(in_array('ordercard',explode(':',$parameters['context']))) { |
|
630 | 639 | $sessname = 'subtotal_hideInnerLines_commande'; |
631 | 640 | $sessname2 = 'subtotal_hidedetails_commande'; |
632 | 641 | $sessname3 = 'subtotal_hideprices_commande'; |
633 | - } |
|
634 | - elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) { |
|
642 | + } elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) { |
|
635 | 643 | $sessname = 'subtotal_hideInnerLines_commande_fournisseur'; |
636 | 644 | $sessname2 = 'subtotal_hidedetails_commande_fournisseur'; |
637 | 645 | $sessname3 = 'subtotal_hideprices_commande_fournisseur'; |
638 | - } |
|
639 | - else { |
|
646 | + } else { |
|
640 | 647 | $sessname = 'subtotal_hideInnerLines_unknown'; |
641 | 648 | $sessname2 = 'subtotal_hidedetails_unknown'; |
642 | 649 | $sessname3 = 'subtotal_hideprices_unknown'; |
@@ -645,15 +652,24 @@ discard block |
||
645 | 652 | global $hideprices; |
646 | 653 | |
647 | 654 | $hideInnerLines = (int)GETPOST('hideInnerLines'); |
648 | - if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) $_SESSION[$sessname] = array(); // prevent old system |
|
655 | + if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) { |
|
656 | + $_SESSION[$sessname] = array(); |
|
657 | + } |
|
658 | + // prevent old system |
|
649 | 659 | $_SESSION[$sessname][$object->id] = $hideInnerLines; |
650 | 660 | |
651 | 661 | $hidedetails= (int)GETPOST('hidedetails'); |
652 | - if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) $_SESSION[$sessname2] = array(); // prevent old system |
|
662 | + if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) { |
|
663 | + $_SESSION[$sessname2] = array(); |
|
664 | + } |
|
665 | + // prevent old system |
|
653 | 666 | $_SESSION[$sessname2][$object->id] = $hidedetails; |
654 | 667 | |
655 | 668 | $hideprices= (int)GETPOST('hideprices'); |
656 | - if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) $_SESSION[$sessname3] = array(); // prevent old system |
|
669 | + if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) { |
|
670 | + $_SESSION[$sessname3] = array(); |
|
671 | + } |
|
672 | + // prevent old system |
|
657 | 673 | $_SESSION[$sessname3][$object->id] = $hideprices; |
658 | 674 | |
659 | 675 | foreach($object->lines as &$line) { |
@@ -661,8 +677,7 @@ discard block |
||
661 | 677 | |
662 | 678 | if($line->qty>=90) { |
663 | 679 | $line->modsubtotal_total = 1; |
664 | - } |
|
665 | - else{ |
|
680 | + } else{ |
|
666 | 681 | $line->modsubtotal_title = 1; |
667 | 682 | } |
668 | 683 | |
@@ -671,8 +686,7 @@ discard block |
||
671 | 686 | } |
672 | 687 | } |
673 | 688 | |
674 | - } |
|
675 | - else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') { |
|
689 | + } else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') { |
|
676 | 690 | |
677 | 691 | $Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid')); |
678 | 692 | |
@@ -680,7 +694,9 @@ discard block |
||
680 | 694 | /** |
681 | 695 | * @var $object Facture |
682 | 696 | */ |
683 | - if($object->element=='facture') $object->deleteline($idLine); |
|
697 | + if($object->element=='facture') { |
|
698 | + $object->deleteline($idLine); |
|
699 | + } |
|
684 | 700 | /** |
685 | 701 | * @var $object Facture fournisseur |
686 | 702 | */ |
@@ -691,18 +707,25 @@ discard block |
||
691 | 707 | /** |
692 | 708 | * @var $object Propal |
693 | 709 | */ |
694 | - else if($object->element=='propal') $object->deleteline($idLine); |
|
710 | + else if($object->element=='propal') { |
|
711 | + $object->deleteline($idLine); |
|
712 | + } |
|
695 | 713 | /** |
696 | 714 | * @var $object Propal Fournisseur |
697 | 715 | */ |
698 | - else if($object->element=='supplier_proposal') $object->deleteline($idLine); |
|
716 | + else if($object->element=='supplier_proposal') { |
|
717 | + $object->deleteline($idLine); |
|
718 | + } |
|
699 | 719 | /** |
700 | 720 | * @var $object Commande |
701 | 721 | */ |
702 | 722 | else if($object->element=='commande') |
703 | 723 | { |
704 | - if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine); |
|
705 | - else $object->deleteline($idLine); |
|
724 | + if ((float) DOL_VERSION >= 5.0) { |
|
725 | + $object->deleteline($user, $idLine); |
|
726 | + } else { |
|
727 | + $object->deleteline($idLine); |
|
728 | + } |
|
706 | 729 | } |
707 | 730 | /** |
708 | 731 | * @var $object Commande fournisseur |
@@ -714,21 +737,26 @@ discard block |
||
714 | 737 | /** |
715 | 738 | * @var $object Facturerec |
716 | 739 | */ |
717 | - else if($object->element=='facturerec') $object->deleteline($idLine); |
|
740 | + else if($object->element=='facturerec') { |
|
741 | + $object->deleteline($idLine); |
|
742 | + } |
|
718 | 743 | } |
719 | 744 | |
720 | 745 | header('location:?id='.$object->id); |
721 | 746 | exit; |
722 | 747 | |
723 | - } |
|
724 | - else if ($action == 'duplicate') |
|
748 | + } else if ($action == 'duplicate') |
|
725 | 749 | { |
726 | 750 | $lineid = GETPOST('lineid', 'int'); |
727 | 751 | $nbDuplicate = TSubtotal::duplicateLines($object, $lineid, true); |
728 | 752 | |
729 | - if ($nbDuplicate > 0) setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate)); |
|
730 | - elseif ($nbDuplicate == 0) setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings'); |
|
731 | - else setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors'); |
|
753 | + if ($nbDuplicate > 0) { |
|
754 | + setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate)); |
|
755 | + } elseif ($nbDuplicate == 0) { |
|
756 | + setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings'); |
|
757 | + } else { |
|
758 | + setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors'); |
|
759 | + } |
|
732 | 760 | |
733 | 761 | header('Location: ?id='.$object->id); |
734 | 762 | exit; |
@@ -746,21 +774,26 @@ discard block |
||
746 | 774 | global $conf; |
747 | 775 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && !empty($object->table_element_line) && in_array($object->element, array('commande', 'facture', 'propal'))) |
748 | 776 | { |
749 | - if ($object->element == 'commande') |
|
750 | - $obj = new OrderLine($object->db); |
|
751 | - if ($object->element == 'propal') |
|
752 | - $obj = new PropaleLigne($object->db); |
|
753 | - if ($object->element == 'facture') |
|
754 | - $obj = new FactureLigne($object->db); |
|
777 | + if ($object->element == 'commande') { |
|
778 | + $obj = new OrderLine($object->db); |
|
779 | + } |
|
780 | + if ($object->element == 'propal') { |
|
781 | + $obj = new PropaleLigne($object->db); |
|
782 | + } |
|
783 | + if ($object->element == 'facture') { |
|
784 | + $obj = new FactureLigne($object->db); |
|
785 | + } |
|
755 | 786 | if (!empty($parameters['fk_element'])) |
756 | 787 | { |
757 | 788 | |
758 | 789 | if($obj->fetch($parameters['fk_element'])){ |
759 | 790 | $obj->id= $obj->rowid; |
760 | - if (empty($obj->array_options)) |
|
761 | - $obj->fetch_optionals(); |
|
762 | - if (!empty($obj->array_options['options_subtotal_nc'])) |
|
763 | - return 1; |
|
791 | + if (empty($obj->array_options)) { |
|
792 | + $obj->fetch_optionals(); |
|
793 | + } |
|
794 | + if (!empty($obj->array_options['options_subtotal_nc'])) { |
|
795 | + return 1; |
|
796 | + } |
|
764 | 797 | } |
765 | 798 | } |
766 | 799 | } |
@@ -832,27 +865,33 @@ discard block |
||
832 | 865 | $TTotal_tva = array(); |
833 | 866 | |
834 | 867 | $sign=1; |
835 | - if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1; |
|
868 | + if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) { |
|
869 | + $sign=-1; |
|
870 | + } |
|
836 | 871 | |
837 | - if (GETPOST('action') == 'builddoc') $builddoc = true; |
|
838 | - else $builddoc = false; |
|
872 | + if (GETPOST('action') == 'builddoc') { |
|
873 | + $builddoc = true; |
|
874 | + } else { |
|
875 | + $builddoc = false; |
|
876 | + } |
|
839 | 877 | |
840 | 878 | dol_include_once('/subtotal/class/subtotal.class.php'); |
841 | 879 | foreach($object->lines as $l) { |
842 | 880 | //print $l->rang.'>='.$rang.' '.$total.'<br/>'; |
843 | 881 | if($l->rang>=$rang) { |
844 | 882 | //echo 'return!<br>'; |
845 | - if (!$return_all) return $total; |
|
846 | - else return array($total, $total_tva, $total_ttc, $TTotal_tva); |
|
847 | - } |
|
848 | - else if(TSubtotal::isTitle($l, 100 - $qty_line)) |
|
883 | + if (!$return_all) { |
|
884 | + return $total; |
|
885 | + } else { |
|
886 | + return array($total, $total_tva, $total_ttc, $TTotal_tva); |
|
887 | + } |
|
888 | + } else if(TSubtotal::isTitle($l, 100 - $qty_line)) |
|
849 | 889 | { |
850 | 890 | $total = 0; |
851 | 891 | $total_tva = 0; |
852 | 892 | $total_ttc = 0; |
853 | 893 | $TTotal_tva = array(); |
854 | - } |
|
855 | - elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) { |
|
894 | + } elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) { |
|
856 | 895 | |
857 | 896 | // TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF |
858 | 897 | if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION) |
@@ -874,8 +913,7 @@ discard block |
||
874 | 913 | $TTotal_tva[$l->tva_tx] += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress; |
875 | 914 | $total_ttc += $sign * ($l->total_tva / ($l->total_ttc / 100)) * $progress; |
876 | 915 | } |
877 | - } |
|
878 | - else |
|
916 | + } else |
|
879 | 917 | { |
880 | 918 | $total += $l->total_ht; |
881 | 919 | $total_tva += $l->total_tva; |
@@ -885,8 +923,11 @@ discard block |
||
885 | 923 | } |
886 | 924 | |
887 | 925 | } |
888 | - if (!$return_all) return $total; |
|
889 | - else return array($total, $total_tva, $total_ttc, $TTotal_tva); |
|
926 | + if (!$return_all) { |
|
927 | + return $total; |
|
928 | + } else { |
|
929 | + return array($total, $total_tva, $total_ttc, $TTotal_tva); |
|
930 | + } |
|
890 | 931 | } |
891 | 932 | |
892 | 933 | /** |
@@ -928,15 +969,18 @@ discard block |
||
928 | 969 | } |
929 | 970 | |
930 | 971 | |
931 | - if($line->qty==99) |
|
932 | - $pdf->SetFillColor(220,220,220); |
|
933 | - elseif ($line->qty==98) |
|
934 | - $pdf->SetFillColor(230,230,230); |
|
935 | - else |
|
936 | - $pdf->SetFillColor(240,240,240); |
|
972 | + if($line->qty==99) { |
|
973 | + $pdf->SetFillColor(220,220,220); |
|
974 | + } elseif ($line->qty==98) { |
|
975 | + $pdf->SetFillColor(230,230,230); |
|
976 | + } else { |
|
977 | + $pdf->SetFillColor(240,240,240); |
|
978 | + } |
|
937 | 979 | |
938 | 980 | $style = 'B'; |
939 | - if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE; |
|
981 | + if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) { |
|
982 | + $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE; |
|
983 | + } |
|
940 | 984 | |
941 | 985 | $pdf->SetFont('', $style, 9); |
942 | 986 | |
@@ -978,8 +1022,7 @@ discard block |
||
978 | 1022 | // $line->total_tva |
979 | 1023 | // $line->total |
980 | 1024 | // $line->total_ttc |
981 | - } |
|
982 | - else |
|
1025 | + } else |
|
983 | 1026 | { |
984 | 1027 | list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1); |
985 | 1028 | $total_to_print = price($total); |
@@ -992,11 +1035,14 @@ discard block |
||
992 | 1035 | } |
993 | 1036 | |
994 | 1037 | $pdf->SetXY($pdf->postotalht, $posy); |
995 | - if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); |
|
1038 | + if($set_pagebreak_margin) { |
|
1039 | + $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); |
|
1040 | + } |
|
996 | 1041 | $pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0); |
997 | - } |
|
998 | - else{ |
|
999 | - if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); |
|
1042 | + } else{ |
|
1043 | + if($set_pagebreak_margin) { |
|
1044 | + $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin); |
|
1045 | + } |
|
1000 | 1046 | } |
1001 | 1047 | |
1002 | 1048 | $posy = $posy + $cell_height; |
@@ -1028,25 +1074,40 @@ discard block |
||
1028 | 1074 | |
1029 | 1075 | |
1030 | 1076 | $style = ($line->qty==1) ? 'BU' : 'BUI'; |
1031 | - if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE; |
|
1077 | + if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) { |
|
1078 | + $style = $conf->global->SUBTOTAL_TITLE_STYLE; |
|
1079 | + } |
|
1032 | 1080 | |
1033 | 1081 | if($hideInnerLines) { |
1034 | - if($line->qty==1)$pdf->SetFont('', $style, 9); |
|
1035 | - else |
|
1082 | + if($line->qty==1) { |
|
1083 | + $pdf->SetFont('', $style, 9); |
|
1084 | + } else |
|
1036 | 1085 | { |
1037 | - if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES; |
|
1086 | + if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) { |
|
1087 | + $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES; |
|
1088 | + } |
|
1038 | 1089 | $pdf->SetFont('', $style, 9); |
1039 | 1090 | } |
1040 | - } |
|
1041 | - else { |
|
1091 | + } else { |
|
1042 | 1092 | |
1043 | - if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile |
|
1044 | - else $pdf->SetFont('', $style, 9); |
|
1093 | + if($line->qty==1) { |
|
1094 | + $pdf->SetFont('', $style, 9); |
|
1095 | + } |
|
1096 | + //TODO if super utile |
|
1097 | + else { |
|
1098 | + $pdf->SetFont('', $style, 9); |
|
1099 | + } |
|
1045 | 1100 | |
1046 | 1101 | } |
1047 | 1102 | |
1048 | - if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) $pdf->MultiCell($w, $h, $label, 0, 'L'); // Pas de HTML dans la chaine |
|
1049 | - else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML |
|
1103 | + if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) { |
|
1104 | + $pdf->MultiCell($w, $h, $label, 0, 'L'); |
|
1105 | + } |
|
1106 | + // Pas de HTML dans la chaine |
|
1107 | + else { |
|
1108 | + $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); |
|
1109 | + } |
|
1110 | + // et maintenant avec du HTML |
|
1050 | 1111 | |
1051 | 1112 | if($description && !$hidedesc) { |
1052 | 1113 | $posy = $pdf->GetY(); |
@@ -1070,8 +1131,7 @@ discard block |
||
1070 | 1131 | |
1071 | 1132 | if(is_array($parameters)) { |
1072 | 1133 | $i = & $parameters['i']; |
1073 | - } |
|
1074 | - else { |
|
1134 | + } else { |
|
1075 | 1135 | $i = (int)$parameters; |
1076 | 1136 | } |
1077 | 1137 | |
@@ -1093,17 +1153,14 @@ discard block |
||
1093 | 1153 | |
1094 | 1154 | if((float)DOL_VERSION<=3.6) { |
1095 | 1155 | return ''; |
1096 | - } |
|
1097 | - else if((float)DOL_VERSION>=3.8) { |
|
1156 | + } else if((float)DOL_VERSION>=3.8) { |
|
1098 | 1157 | return 1; |
1099 | 1158 | } |
1100 | 1159 | |
1101 | - } |
|
1102 | - elseif(!empty($hideprices)) { |
|
1160 | + } elseif(!empty($hideprices)) { |
|
1103 | 1161 | $this->resprints = $object->lines[$parameters['i']]->qty; |
1104 | 1162 | return 1; |
1105 | - } |
|
1106 | - elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY)) |
|
1163 | + } elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY)) |
|
1107 | 1164 | { |
1108 | 1165 | $hideInnerLines = (int)GETPOST('hideInnerLines'); |
1109 | 1166 | $hidedetails = (int)GETPOST('hidedetails'); |
@@ -1113,12 +1170,20 @@ discard block |
||
1113 | 1170 | } |
1114 | 1171 | } |
1115 | 1172 | |
1116 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1117 | - else $i = (int)$parameters; |
|
1173 | + if(is_array($parameters)) { |
|
1174 | + $i = & $parameters['i']; |
|
1175 | + } else { |
|
1176 | + $i = (int)$parameters; |
|
1177 | + } |
|
1118 | 1178 | |
1119 | - if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0) |
|
1179 | + if (empty($object->lines[$i])) { |
|
1180 | + return 0; |
|
1181 | + } |
|
1182 | + // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0) |
|
1120 | 1183 | |
1121 | - if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals(); |
|
1184 | + if(empty($object->lines[$i]->array_options)) { |
|
1185 | + $object->lines[$i]->fetch_optionals(); |
|
1186 | + } |
|
1122 | 1187 | |
1123 | 1188 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
1124 | 1189 | { |
@@ -1135,8 +1200,11 @@ discard block |
||
1135 | 1200 | function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') { |
1136 | 1201 | global $conf, $hideprices, $hookmanager; |
1137 | 1202 | |
1138 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1139 | - else $i = (int)$parameters; |
|
1203 | + if(is_array($parameters)) { |
|
1204 | + $i = & $parameters['i']; |
|
1205 | + } else { |
|
1206 | + $i = (int)$parameters; |
|
1207 | + } |
|
1140 | 1208 | |
1141 | 1209 | if($this->isModSubtotalLine($parameters,$object) ){ |
1142 | 1210 | |
@@ -1144,13 +1212,11 @@ discard block |
||
1144 | 1212 | |
1145 | 1213 | if((float)DOL_VERSION<=3.6) { |
1146 | 1214 | return ''; |
1147 | - } |
|
1148 | - else if((float)DOL_VERSION>=3.8) { |
|
1215 | + } else if((float)DOL_VERSION>=3.8) { |
|
1149 | 1216 | return 1; |
1150 | 1217 | } |
1151 | 1218 | |
1152 | - } |
|
1153 | - elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS)) |
|
1219 | + } elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS)) |
|
1154 | 1220 | { |
1155 | 1221 | if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC))) |
1156 | 1222 | { |
@@ -1222,12 +1288,10 @@ discard block |
||
1222 | 1288 | $this->error = $hookmanager->error; |
1223 | 1289 | $this->errors = $hookmanager->errors; |
1224 | 1290 | return -1; |
1225 | - } |
|
1226 | - elseif (empty($reshook)) |
|
1291 | + } elseif (empty($reshook)) |
|
1227 | 1292 | { |
1228 | 1293 | $this->resprints .= $hookmanager->resprints; |
1229 | - } |
|
1230 | - else |
|
1294 | + } else |
|
1231 | 1295 | { |
1232 | 1296 | $this->resprints = $hookmanager->resprints; |
1233 | 1297 | |
@@ -1250,14 +1314,16 @@ discard block |
||
1250 | 1314 | |
1251 | 1315 | if((float)DOL_VERSION<=3.6) { |
1252 | 1316 | return ''; |
1253 | - } |
|
1254 | - else if((float)DOL_VERSION>=3.8) { |
|
1317 | + } else if((float)DOL_VERSION>=3.8) { |
|
1255 | 1318 | return 1; |
1256 | 1319 | } |
1257 | 1320 | } |
1258 | 1321 | |
1259 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1260 | - else $i = (int)$parameters; |
|
1322 | + if(is_array($parameters)) { |
|
1323 | + $i = & $parameters['i']; |
|
1324 | + } else { |
|
1325 | + $i = (int)$parameters; |
|
1326 | + } |
|
1261 | 1327 | |
1262 | 1328 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
1263 | 1329 | { |
@@ -1279,14 +1345,16 @@ discard block |
||
1279 | 1345 | |
1280 | 1346 | if((float)DOL_VERSION<=3.6) { |
1281 | 1347 | return ''; |
1282 | - } |
|
1283 | - else if((float)DOL_VERSION>=3.8) { |
|
1348 | + } else if((float)DOL_VERSION>=3.8) { |
|
1284 | 1349 | return 1; |
1285 | 1350 | } |
1286 | 1351 | } |
1287 | 1352 | |
1288 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1289 | - else $i = (int)$parameters; |
|
1353 | + if(is_array($parameters)) { |
|
1354 | + $i = & $parameters['i']; |
|
1355 | + } else { |
|
1356 | + $i = (int)$parameters; |
|
1357 | + } |
|
1290 | 1358 | |
1291 | 1359 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
1292 | 1360 | { |
@@ -1303,8 +1371,11 @@ discard block |
||
1303 | 1371 | function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') { |
1304 | 1372 | global $conf,$hideprices,$hookmanager; |
1305 | 1373 | |
1306 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1307 | - else $i = (int)$parameters; |
|
1374 | + if(is_array($parameters)) { |
|
1375 | + $i = & $parameters['i']; |
|
1376 | + } else { |
|
1377 | + $i = (int)$parameters; |
|
1378 | + } |
|
1308 | 1379 | |
1309 | 1380 | if($this->isModSubtotalLine($parameters,$object) ) { |
1310 | 1381 | $this->resprints = ' '; |
@@ -1315,7 +1386,9 @@ discard block |
||
1315 | 1386 | if(TSubtotal::isSubtotal($line)) { |
1316 | 1387 | $parentTitle = TSubtotal::getParentTitleOfLine($object, $i); |
1317 | 1388 | |
1318 | - if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals(); |
|
1389 | + if(is_object($parentTitle) && empty($parentTitle->array_options)) { |
|
1390 | + $parentTitle->fetch_optionals(); |
|
1391 | + } |
|
1319 | 1392 | if(! empty($parentTitle->array_options['options_show_total_ht'])) { |
1320 | 1393 | $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle); |
1321 | 1394 | $this->resprints = price($TTotal['total_subprice']); |
@@ -1324,8 +1397,7 @@ discard block |
||
1324 | 1397 | |
1325 | 1398 | if((float)DOL_VERSION<=3.6) { |
1326 | 1399 | return ''; |
1327 | - } |
|
1328 | - else if((float)DOL_VERSION>=3.8) { |
|
1400 | + } else if((float)DOL_VERSION>=3.8) { |
|
1329 | 1401 | return 1; |
1330 | 1402 | } |
1331 | 1403 | } |
@@ -1370,8 +1442,11 @@ discard block |
||
1370 | 1442 | function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') { |
1371 | 1443 | global $conf,$hideprices,$hookmanager; |
1372 | 1444 | |
1373 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1374 | - else $i = (int) $parameters; |
|
1445 | + if(is_array($parameters)) { |
|
1446 | + $i = & $parameters['i']; |
|
1447 | + } else { |
|
1448 | + $i = (int) $parameters; |
|
1449 | + } |
|
1375 | 1450 | |
1376 | 1451 | if($this->isModSubtotalLine($parameters,$object) ) { |
1377 | 1452 | $this->resprints = ' '; |
@@ -1382,7 +1457,9 @@ discard block |
||
1382 | 1457 | if(TSubtotal::isSubtotal($line)) { |
1383 | 1458 | $parentTitle = TSubtotal::getParentTitleOfLine($object, $i); |
1384 | 1459 | |
1385 | - if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals(); |
|
1460 | + if(empty($parentTitle->array_options)) { |
|
1461 | + $parentTitle->fetch_optionals(); |
|
1462 | + } |
|
1386 | 1463 | if(! empty($parentTitle->array_options['options_show_reduc'])) { |
1387 | 1464 | $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle); |
1388 | 1465 | $this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%'; |
@@ -1391,12 +1468,10 @@ discard block |
||
1391 | 1468 | |
1392 | 1469 | if((float)DOL_VERSION<=3.6) { |
1393 | 1470 | return ''; |
1394 | - } |
|
1395 | - else if((float)DOL_VERSION>=3.8) { |
|
1471 | + } else if((float)DOL_VERSION>=3.8) { |
|
1396 | 1472 | return 1; |
1397 | 1473 | } |
1398 | - } |
|
1399 | - elseif (!empty($hideprices) |
|
1474 | + } elseif (!empty($hideprices) |
|
1400 | 1475 | || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
1401 | 1476 | ) |
1402 | 1477 | { |
@@ -1417,14 +1492,16 @@ discard block |
||
1417 | 1492 | $this->resprints = ' '; |
1418 | 1493 | if((float)DOL_VERSION<=3.6) { |
1419 | 1494 | return ''; |
1420 | - } |
|
1421 | - else if((float)DOL_VERSION>=3.8) { |
|
1495 | + } else if((float)DOL_VERSION>=3.8) { |
|
1422 | 1496 | return 1; |
1423 | 1497 | } |
1424 | 1498 | } |
1425 | 1499 | |
1426 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1427 | - else $i = (int)$parameters; |
|
1500 | + if(is_array($parameters)) { |
|
1501 | + $i = & $parameters['i']; |
|
1502 | + } else { |
|
1503 | + $i = (int)$parameters; |
|
1504 | + } |
|
1428 | 1505 | |
1429 | 1506 | if (!empty($hideprices) |
1430 | 1507 | || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
@@ -1448,16 +1525,21 @@ discard block |
||
1448 | 1525 | |
1449 | 1526 | if((float)DOL_VERSION<=3.6) { |
1450 | 1527 | return ''; |
1451 | - } |
|
1452 | - else if((float)DOL_VERSION>=3.8) { |
|
1528 | + } else if((float)DOL_VERSION>=3.8) { |
|
1453 | 1529 | return 1; |
1454 | 1530 | } |
1455 | 1531 | } |
1456 | 1532 | |
1457 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1458 | - else $i = (int)$parameters; |
|
1533 | + if(is_array($parameters)) { |
|
1534 | + $i = & $parameters['i']; |
|
1535 | + } else { |
|
1536 | + $i = (int)$parameters; |
|
1537 | + } |
|
1459 | 1538 | |
1460 | - if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0) |
|
1539 | + if (empty($object->lines[$i])) { |
|
1540 | + return 0; |
|
1541 | + } |
|
1542 | + // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0) |
|
1461 | 1543 | |
1462 | 1544 | $object->lines[$i]->fetch_optionals(); |
1463 | 1545 | // Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché |
@@ -1503,14 +1585,16 @@ discard block |
||
1503 | 1585 | $this->resprints = ' '; |
1504 | 1586 | if((float)DOL_VERSION<=3.6) { |
1505 | 1587 | return ''; |
1506 | - } |
|
1507 | - else if((float)DOL_VERSION>=3.8) { |
|
1588 | + } else if((float)DOL_VERSION>=3.8) { |
|
1508 | 1589 | return 1; |
1509 | 1590 | } |
1510 | 1591 | } |
1511 | 1592 | |
1512 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1513 | - else $i = (int)$parameters; |
|
1593 | + if(is_array($parameters)) { |
|
1594 | + $i = & $parameters['i']; |
|
1595 | + } else { |
|
1596 | + $i = (int)$parameters; |
|
1597 | + } |
|
1514 | 1598 | |
1515 | 1599 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
1516 | 1600 | { |
@@ -1540,7 +1624,9 @@ discard block |
||
1540 | 1624 | } |
1541 | 1625 | } |
1542 | 1626 | |
1543 | - if (!empty($TLineTitle)) $TTitleNumeroted = $this->formatNumerotation($TLineTitle); |
|
1627 | + if (!empty($TLineTitle)) { |
|
1628 | + $TTitleNumeroted = $this->formatNumerotation($TLineTitle); |
|
1629 | + } |
|
1544 | 1630 | } |
1545 | 1631 | |
1546 | 1632 | } |
@@ -1554,8 +1640,12 @@ discard block |
||
1554 | 1640 | $j=0; |
1555 | 1641 | foreach ($TLineTitle as $k => &$line) |
1556 | 1642 | { |
1557 | - if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue; |
|
1558 | - if (!empty($line_reference) && $line->qty <= $line_reference->qty) break; |
|
1643 | + if (!empty($line_reference) && $line->rang <= $line_reference->rang) { |
|
1644 | + continue; |
|
1645 | + } |
|
1646 | + if (!empty($line_reference) && $line->qty <= $line_reference->qty) { |
|
1647 | + break; |
|
1648 | + } |
|
1559 | 1649 | |
1560 | 1650 | if ($line->qty == $level) |
1561 | 1651 | { |
@@ -1589,7 +1679,9 @@ discard block |
||
1589 | 1679 | |
1590 | 1680 | $hidedetails = (int)GETPOST('hidedetails'); |
1591 | 1681 | |
1592 | - if(empty($hidedetails)) return false; |
|
1682 | + if(empty($hidedetails)) { |
|
1683 | + return false; |
|
1684 | + } |
|
1593 | 1685 | |
1594 | 1686 | // TODO can't add VAT to document without lines... :-/ |
1595 | 1687 | |
@@ -1617,7 +1709,9 @@ discard block |
||
1617 | 1709 | foreach($object->lines as $k => &$l) { |
1618 | 1710 | if(TSubtotal::isSubtotal($l)) { |
1619 | 1711 | $parentTitle = TSubtotal::getParentTitleOfLine($object, $k); |
1620 | - if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals(); |
|
1712 | + if(is_object($parentTitle) && empty($parentTitle->array_options)) { |
|
1713 | + $parentTitle->fetch_optionals(); |
|
1714 | + } |
|
1621 | 1715 | if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_total_ht'])) { |
1622 | 1716 | $l->remise_percent = 100; // Affichage de la réduction sur la ligne de sous-total |
1623 | 1717 | } |
@@ -1651,7 +1745,9 @@ discard block |
||
1651 | 1745 | */ |
1652 | 1746 | list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1); |
1653 | 1747 | |
1654 | - if (TSubtotal::getNiveau($line) == 1) $line->TTotal_tva = $TTotal_tva; |
|
1748 | + if (TSubtotal::getNiveau($line) == 1) { |
|
1749 | + $line->TTotal_tva = $TTotal_tva; |
|
1750 | + } |
|
1655 | 1751 | $line->total_ht = $total; |
1656 | 1752 | $line->total_tva = $total_tva; |
1657 | 1753 | $line->total = $line->total_ht; |
@@ -1715,8 +1811,7 @@ discard block |
||
1715 | 1811 | } |
1716 | 1812 | |
1717 | 1813 | |
1718 | - } |
|
1719 | - elseif ($hidedetails) |
|
1814 | + } elseif ($hidedetails) |
|
1720 | 1815 | { |
1721 | 1816 | $TLines[] = $line; //Cas où je cache uniquement les prix des produits |
1722 | 1817 | } |
@@ -1787,7 +1882,9 @@ discard block |
||
1787 | 1882 | |
1788 | 1883 | if(!empty($hideprices)) { |
1789 | 1884 | foreach($object->lines as &$line) { |
1790 | - if($line->fk_product_type!=9) $line->fk_parent_line = -1; |
|
1885 | + if($line->fk_product_type!=9) { |
|
1886 | + $line->fk_parent_line = -1; |
|
1887 | + } |
|
1791 | 1888 | } |
1792 | 1889 | } |
1793 | 1890 | |
@@ -1808,7 +1905,9 @@ discard block |
||
1808 | 1905 | |
1809 | 1906 | if($line->qty>90) { |
1810 | 1907 | |
1811 | - if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) $label .= ' '.$this->getTitle($object, $line); |
|
1908 | + if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) { |
|
1909 | + $label .= ' '.$this->getTitle($object, $line); |
|
1910 | + } |
|
1812 | 1911 | |
1813 | 1912 | $pageBefore = $pdf->getPage(); |
1814 | 1913 | $this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); |
@@ -1826,8 +1925,7 @@ discard block |
||
1826 | 1925 | |
1827 | 1926 | $posy = $pdf->GetY(); |
1828 | 1927 | return 1; |
1829 | - } |
|
1830 | - else if ($line->qty < 10) { |
|
1928 | + } else if ($line->qty < 10) { |
|
1831 | 1929 | $pageBefore = $pdf->getPage(); |
1832 | 1930 | |
1833 | 1931 | $this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); |
@@ -1851,8 +1949,7 @@ discard block |
||
1851 | 1949 | // if($line->rowid==47) exit; |
1852 | 1950 | |
1853 | 1951 | return 0; |
1854 | - } |
|
1855 | - elseif (empty($object->lines[$parameters['i']])) |
|
1952 | + } elseif (empty($object->lines[$parameters['i']])) |
|
1856 | 1953 | { |
1857 | 1954 | $this->resprints = -1; |
1858 | 1955 | } |
@@ -1885,7 +1982,9 @@ discard block |
||
1885 | 1982 | |
1886 | 1983 | foreach ($object->lines as $line) |
1887 | 1984 | { |
1888 | - if ($line->id == $currentLine->id) break; |
|
1985 | + if ($line->id == $currentLine->id) { |
|
1986 | + break; |
|
1987 | + } |
|
1889 | 1988 | |
1890 | 1989 | $qty_search = 100 - $currentLine->qty; |
1891 | 1990 | |
@@ -1922,23 +2021,23 @@ discard block |
||
1922 | 2021 | { |
1923 | 2022 | $object->statut = 0; // hack for facture rec |
1924 | 2023 | $createRight = $user->rights->facture->creer; |
1925 | - } |
|
1926 | - elseif($object->element == 'order_supplier' ) |
|
2024 | + } elseif($object->element == 'order_supplier' ) |
|
1927 | 2025 | { |
1928 | 2026 | $createRight = $user->rights->fournisseur->commande->creer; |
1929 | - } |
|
1930 | - elseif($object->element == 'invoice_supplier' ) |
|
2027 | + } elseif($object->element == 'invoice_supplier' ) |
|
1931 | 2028 | { |
1932 | 2029 | $createRight = $user->rights->fournisseur->facture->creer; |
1933 | 2030 | } |
1934 | 2031 | |
1935 | 2032 | if($line->special_code!=$this->module_number || $line->product_type!=9) { |
1936 | 2033 | null; |
1937 | - } |
|
1938 | - else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) |
|
2034 | + } else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) |
|
1939 | 2035 | { |
1940 | - if($object->element=='facture')$idvar = 'facid'; |
|
1941 | - else $idvar='id'; |
|
2036 | + if($object->element=='facture') { |
|
2037 | + $idvar = 'facid'; |
|
2038 | + } else { |
|
2039 | + $idvar='id'; |
|
2040 | + } |
|
1942 | 2041 | |
1943 | 2042 | if((float)DOL_VERSION <= 3.4) |
1944 | 2043 | { |
@@ -1964,22 +2063,44 @@ discard block |
||
1964 | 2063 | <?php |
1965 | 2064 | } |
1966 | 2065 | |
1967 | - if(empty($line->description)) $line->description = $line->desc; |
|
2066 | + if(empty($line->description)) { |
|
2067 | + $line->description = $line->desc; |
|
2068 | + } |
|
1968 | 2069 | |
1969 | 2070 | $colspan = 5; |
1970 | - if($object->element == 'facturerec' ) $colspan = 3; |
|
1971 | - if($object->element == 'order_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6; |
|
1972 | - if($object->element == 'invoice_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7; |
|
1973 | - if($object->element == 'supplier_proposal') (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3; |
|
2071 | + if($object->element == 'facturerec' ) { |
|
2072 | + $colspan = 3; |
|
2073 | + } |
|
2074 | + if($object->element == 'order_supplier') { |
|
2075 | + (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6; |
|
2076 | + } |
|
2077 | + if($object->element == 'invoice_supplier') { |
|
2078 | + (float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7; |
|
2079 | + } |
|
2080 | + if($object->element == 'supplier_proposal') { |
|
2081 | + (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3; |
|
2082 | + } |
|
1974 | 2083 | if(!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) { |
1975 | 2084 | $colspan++; // Colonne PU Devise |
1976 | 2085 | } |
1977 | - if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++; |
|
1978 | - if(!empty($conf->margin->enabled)) $colspan++; |
|
1979 | - if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; |
|
1980 | - if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; |
|
1981 | - if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++; |
|
1982 | - if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++; |
|
2086 | + if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) { |
|
2087 | + $colspan++; |
|
2088 | + } |
|
2089 | + if(!empty($conf->margin->enabled)) { |
|
2090 | + $colspan++; |
|
2091 | + } |
|
2092 | + if(!empty($conf->global->DISPLAY_MARGIN_RATES)) { |
|
2093 | + $colspan++; |
|
2094 | + } |
|
2095 | + if(!empty($conf->global->DISPLAY_MARK_RATES)) { |
|
2096 | + $colspan++; |
|
2097 | + } |
|
2098 | + if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) { |
|
2099 | + $colspan++; |
|
2100 | + } |
|
2101 | + if(!empty($conf->global->PRODUCT_USE_UNITS)) { |
|
2102 | + $colspan++; |
|
2103 | + } |
|
1983 | 2104 | |
1984 | 2105 | /* Titre */ |
1985 | 2106 | //var_dump($line); |
@@ -1992,23 +2113,36 @@ discard block |
||
1992 | 2113 | <tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php |
1993 | 2114 | if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT)) |
1994 | 2115 | { |
1995 | - if($line->qty==99) print 'background:#adadcf'; |
|
1996 | - else if($line->qty==98) print 'background:#ddddff;'; |
|
1997 | - else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;'; |
|
1998 | - else if($line->qty==1) print 'background:#adadcf;'; |
|
1999 | - else if($line->qty==2) print 'background:#ddddff;'; |
|
2000 | - else if($line->qty==50) print ''; |
|
2001 | - else print 'background:#eeeeff;'; |
|
2116 | + if($line->qty==99) { |
|
2117 | + print 'background:#adadcf'; |
|
2118 | + } else if($line->qty==98) { |
|
2119 | + print 'background:#ddddff;'; |
|
2120 | + } else if($line->qty<=97 && $line->qty>=91) { |
|
2121 | + print 'background:#eeeeff;'; |
|
2122 | + } else if($line->qty==1) { |
|
2123 | + print 'background:#adadcf;'; |
|
2124 | + } else if($line->qty==2) { |
|
2125 | + print 'background:#ddddff;'; |
|
2126 | + } else if($line->qty==50) { |
|
2127 | + print ''; |
|
2128 | + } else { |
|
2129 | + print 'background:#eeeeff;'; |
|
2130 | + } |
|
2002 | 2131 | |
2003 | 2132 | //A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9 |
2004 | - } |
|
2005 | - else |
|
2133 | + } else |
|
2006 | 2134 | { |
2007 | - if($line->qty==99) print 'background:#ddffdd'; |
|
2008 | - else if($line->qty==98) print 'background:#ddddff;'; |
|
2009 | - else if($line->qty==2) print 'background:#eeeeff; '; |
|
2010 | - else if($line->qty==50) print ''; |
|
2011 | - else print 'background:#eeffee;' ; |
|
2135 | + if($line->qty==99) { |
|
2136 | + print 'background:#ddffdd'; |
|
2137 | + } else if($line->qty==98) { |
|
2138 | + print 'background:#ddddff;'; |
|
2139 | + } else if($line->qty==2) { |
|
2140 | + print 'background:#eeeeff; '; |
|
2141 | + } else if($line->qty==50) { |
|
2142 | + print ''; |
|
2143 | + } else { |
|
2144 | + print 'background:#eeffee;' ; |
|
2145 | + } |
|
2012 | 2146 | } |
2013 | 2147 | |
2014 | 2148 | ?>;"> |
@@ -2035,13 +2169,11 @@ discard block |
||
2035 | 2169 | $qty_displayed = $line->qty; |
2036 | 2170 | print img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span> '; |
2037 | 2171 | |
2038 | - } |
|
2039 | - else if (TSubtotal::isSubtotal($line)) |
|
2172 | + } else if (TSubtotal::isSubtotal($line)) |
|
2040 | 2173 | { |
2041 | 2174 | $qty_displayed = 100 - $line->qty; |
2042 | 2175 | print img_picto('', 'subsubtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;color:#0075DE;">'.$qty_displayed.'</span> '; |
2043 | - } |
|
2044 | - else |
|
2176 | + } else |
|
2045 | 2177 | { |
2046 | 2178 | $isFreeText = true; |
2047 | 2179 | } |
@@ -2062,9 +2194,13 @@ discard block |
||
2062 | 2194 | } |
2063 | 2195 | |
2064 | 2196 | $readonlyForSituation = ''; |
2065 | - if (!empty($line->fk_prev_id) && $line->fk_prev_id != null) $readonlyForSituation = 'readonly'; |
|
2197 | + if (!empty($line->fk_prev_id) && $line->fk_prev_id != null) { |
|
2198 | + $readonlyForSituation = 'readonly'; |
|
2199 | + } |
|
2066 | 2200 | |
2067 | - if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/> '; |
|
2201 | + if (!$isFreeText) { |
|
2202 | + echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/> '; |
|
2203 | + } |
|
2068 | 2204 | |
2069 | 2205 | if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) ) |
2070 | 2206 | { |
@@ -2072,8 +2208,12 @@ discard block |
||
2072 | 2208 | for ($j=1; $j<10; $j++) |
2073 | 2209 | { |
2074 | 2210 | if (!empty($readonlyForSituation)) { |
2075 | - if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
|
2076 | - } else $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
|
2211 | + if ($qty_displayed == $j) { |
|
2212 | + $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
|
2213 | + } |
|
2214 | + } else { |
|
2215 | + $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
|
2216 | + } |
|
2077 | 2217 | } |
2078 | 2218 | $select .= '</select> '; |
2079 | 2219 | |
@@ -2093,7 +2233,9 @@ discard block |
||
2093 | 2233 | echo '<div>'; |
2094 | 2234 | echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>'; |
2095 | 2235 | echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>'; |
2096 | - if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true)); |
|
2236 | + if (empty($readonlyForSituation)) { |
|
2237 | + echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true)); |
|
2238 | + } |
|
2097 | 2239 | echo '</select>'; |
2098 | 2240 | echo '</div>'; |
2099 | 2241 | |
@@ -2112,8 +2254,9 @@ discard block |
||
2112 | 2254 | echo '<input style="vertical-align:sub;" type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' /> '; |
2113 | 2255 | echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>'; |
2114 | 2256 | echo '</div>'; |
2257 | + } else if ($isFreeText) { |
|
2258 | + echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation); |
|
2115 | 2259 | } |
2116 | - else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation); |
|
2117 | 2260 | echo '</div>'; |
2118 | 2261 | |
2119 | 2262 | if($line->qty<10) { |
@@ -2133,8 +2276,7 @@ discard block |
||
2133 | 2276 | $doleditor->Create(); |
2134 | 2277 | } |
2135 | 2278 | |
2136 | - } |
|
2137 | - else { |
|
2279 | + } else { |
|
2138 | 2280 | |
2139 | 2281 | if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) |
2140 | 2282 | { |
@@ -2142,14 +2284,19 @@ discard block |
||
2142 | 2284 | { |
2143 | 2285 | echo str_repeat(' ', $line->qty-1); |
2144 | 2286 | |
2145 | - if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span> '; |
|
2146 | - else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span> '; |
|
2287 | + if (TSubtotal::isTitle($line)) { |
|
2288 | + print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span> '; |
|
2289 | + } else { |
|
2290 | + print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span> '; |
|
2291 | + } |
|
2147 | 2292 | } |
2148 | - } |
|
2149 | - else |
|
2293 | + } else |
|
2150 | 2294 | { |
2151 | - if($line->qty<=1) print img_picto('', 'subtotal@subtotal'); |
|
2152 | - else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').' '; |
|
2295 | + if($line->qty<=1) { |
|
2296 | + print img_picto('', 'subtotal@subtotal'); |
|
2297 | + } else if($line->qty==2) { |
|
2298 | + print img_picto('', 'subsubtotal@subtotal').' '; |
|
2299 | + } |
|
2153 | 2300 | } |
2154 | 2301 | |
2155 | 2302 | |
@@ -2159,21 +2306,26 @@ discard block |
||
2159 | 2306 | $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;'; |
2160 | 2307 | |
2161 | 2308 | if (empty($line->label)) { |
2162 | - if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print $line->description.' '.$this->getTitle($object, $line); |
|
2163 | - else print $line->description; |
|
2164 | - } |
|
2165 | - else { |
|
2309 | + if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) { |
|
2310 | + print $line->description.' '.$this->getTitle($object, $line); |
|
2311 | + } else { |
|
2312 | + print $line->description; |
|
2313 | + } |
|
2314 | + } else { |
|
2166 | 2315 | |
2167 | 2316 | if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) { |
2168 | 2317 | print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>'; |
2169 | - } |
|
2170 | - else{ |
|
2318 | + } else{ |
|
2171 | 2319 | print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>'; |
2172 | 2320 | } |
2173 | 2321 | |
2174 | 2322 | } |
2175 | - if($line->qty>90) print ' : '; |
|
2176 | - if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal'); |
|
2323 | + if($line->qty>90) { |
|
2324 | + print ' : '; |
|
2325 | + } |
|
2326 | + if($line->info_bits > 0) { |
|
2327 | + echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal'); |
|
2328 | + } |
|
2177 | 2329 | |
2178 | 2330 | |
2179 | 2331 | |
@@ -2216,11 +2368,12 @@ discard block |
||
2216 | 2368 | </script> |
2217 | 2369 | <?php |
2218 | 2370 | |
2219 | - } |
|
2220 | - else{ |
|
2371 | + } else{ |
|
2221 | 2372 | if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier') |
2222 | 2373 | { |
2223 | - if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>'; |
|
2374 | + if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) { |
|
2375 | + echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>'; |
|
2376 | + } |
|
2224 | 2377 | } |
2225 | 2378 | |
2226 | 2379 | if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) |
@@ -2309,7 +2462,9 @@ discard block |
||
2309 | 2462 | $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); |
2310 | 2463 | |
2311 | 2464 | $colspan+=3; $mode = 'view'; |
2312 | - if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit'; |
|
2465 | + if($action === 'editline' && $line->rowid == GETPOST('lineid')) { |
|
2466 | + $mode = 'edit'; |
|
2467 | + } |
|
2313 | 2468 | |
2314 | 2469 | $ex_element = $line->element; |
2315 | 2470 | $line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr |
@@ -2491,10 +2646,9 @@ discard block |
||
2491 | 2646 | |
2492 | 2647 | if(TSubtotal::isTitle($line)){ |
2493 | 2648 | $ThtmlData['data-issubtotal'] = 'title'; |
2494 | - }elseif(TSubtotal::isSubtotal($line)){ |
|
2649 | + } elseif(TSubtotal::isSubtotal($line)){ |
|
2495 | 2650 | $ThtmlData['data-issubtotal'] = 'subtotal'; |
2496 | - } |
|
2497 | - else{ |
|
2651 | + } else{ |
|
2498 | 2652 | $ThtmlData['data-issubtotal'] = 'freetext'; |
2499 | 2653 | } |
2500 | 2654 | |
@@ -2504,7 +2658,9 @@ discard block |
||
2504 | 2658 | |
2505 | 2659 | // hook |
2506 | 2660 | $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
2507 | - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
2661 | + if ($reshook < 0) { |
|
2662 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
2663 | + } |
|
2508 | 2664 | if ($reshook>0) |
2509 | 2665 | { |
2510 | 2666 | $ThtmlData = $hookmanager->resArray; |
@@ -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 | |
30 | 35 | $TNotElements = array ('invoice_supplier', 'order_supplier'); |
@@ -36,7 +41,9 @@ discard block |
||
36 | 41 | /** |
37 | 42 | * @var $object Facture |
38 | 43 | */ |
39 | - 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); |
|
44 | + if($object->element=='facture') { |
|
45 | + $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); |
|
46 | + } |
|
40 | 47 | /** |
41 | 48 | * @var $object Facture fournisseur |
42 | 49 | */ |
@@ -48,16 +55,22 @@ discard block |
||
48 | 55 | /** |
49 | 56 | * @var $object Propal |
50 | 57 | */ |
51 | - 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); |
|
58 | + else if($object->element=='propal') { |
|
59 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
60 | + } |
|
52 | 61 | /** |
53 | 62 | * @var $object Propal Fournisseur |
54 | 63 | */ |
55 | - 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); |
|
64 | + else if($object->element=='supplier_proposal') { |
|
65 | + $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label); |
|
66 | + } |
|
56 | 67 | |
57 | 68 | /** |
58 | 69 | * @var $object Commande |
59 | 70 | */ |
60 | - 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); |
|
71 | + else if($object->element=='commande') { |
|
72 | + $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 | + } |
|
61 | 74 | /** |
62 | 75 | * @var $object Commande fournisseur |
63 | 76 | */ |
@@ -68,7 +81,9 @@ discard block |
||
68 | 81 | /** |
69 | 82 | * @var $object Facturerec |
70 | 83 | */ |
71 | - 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); |
|
84 | + else if($object->element=='facturerec') { |
|
85 | + $res = $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label); |
|
86 | + } |
|
72 | 87 | |
73 | 88 | } |
74 | 89 | |
@@ -90,8 +105,9 @@ discard block |
||
90 | 105 | // Define output language |
91 | 106 | $outputlangs = $langs; |
92 | 107 | $newlang = GETPOST('lang_id', 'alpha'); |
93 | - if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) |
|
94 | - $newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang; |
|
108 | + if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) { |
|
109 | + $newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang; |
|
110 | + } |
|
95 | 111 | if (! empty($newlang)) { |
96 | 112 | $outputlangs = new Translate("", $conf); |
97 | 113 | $outputlangs->setDefaultLang($newlang); |
@@ -100,13 +116,18 @@ discard block |
||
100 | 116 | $ret = $object->fetch($object->id); // Reload to get new records |
101 | 117 | if ((float) DOL_VERSION <= 3.6) |
102 | 118 | { |
103 | - if ($object->element == 'propal') propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
104 | - elseif ($object->element == 'commande') commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
105 | - elseif ($object->element == 'facture') facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
106 | - } |
|
107 | - else |
|
119 | + if ($object->element == 'propal') { |
|
120 | + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
121 | + } elseif ($object->element == 'commande') { |
|
122 | + commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
123 | + } elseif ($object->element == 'facture') { |
|
124 | + facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
125 | + } |
|
126 | + } else |
|
108 | 127 | { |
109 | - if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
128 | + if ($object->element!= 'facturerec') { |
|
129 | + $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); |
|
130 | + } |
|
110 | 131 | } |
111 | 132 | } |
112 | 133 | } |
@@ -120,7 +141,9 @@ discard block |
||
120 | 141 | */ |
121 | 142 | public static function updateRang(&$object, $rang_start, $move_to=1) |
122 | 143 | { |
123 | - if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
|
144 | + if (!class_exists('GenericObject')) { |
|
145 | + require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php'; |
|
146 | + } |
|
124 | 147 | |
125 | 148 | $row=new GenericObject($object->db); |
126 | 149 | $row->table_element_line = $object->table_element_line; |
@@ -129,7 +152,9 @@ discard block |
||
129 | 152 | |
130 | 153 | foreach ($object->lines as &$line) |
131 | 154 | { |
132 | - if ($line->rang < $rang_start) continue; |
|
155 | + if ($line->rang < $rang_start) { |
|
156 | + continue; |
|
157 | + } |
|
133 | 158 | |
134 | 159 | $row->updateRangOfLine($line->id, $line->rang+$move_to); |
135 | 160 | } |
@@ -152,21 +177,28 @@ discard block |
||
152 | 177 | foreach ($TTitle_reverse as $k => $title_line) |
153 | 178 | { |
154 | 179 | $title_niveau = self::getNiveau($title_line); |
155 | - if ($title_niveau < $level_new_title) break; |
|
180 | + if ($title_niveau < $level_new_title) { |
|
181 | + break; |
|
182 | + } |
|
156 | 183 | |
157 | 184 | $rang_to_add = self::titleHasTotalLine($object, $title_line, true, true); |
158 | 185 | |
159 | 186 | if (is_numeric($rang_to_add)) |
160 | 187 | { |
161 | - if ($rang_to_add != -1) self::updateRang($object, $rang_to_add); |
|
188 | + if ($rang_to_add != -1) { |
|
189 | + self::updateRang($object, $rang_to_add); |
|
190 | + } |
|
162 | 191 | |
163 | 192 | self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add); |
164 | 193 | |
165 | 194 | $object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas) |
166 | 195 | if ($rang_to_add != -1) |
167 | 196 | { |
168 | - if (method_exists($object, 'fetch_lines')) $object->fetch_lines(); |
|
169 | - else $object->fetch($object->id); |
|
197 | + if (method_exists($object, 'fetch_lines')) { |
|
198 | + $object->fetch_lines(); |
|
199 | + } else { |
|
200 | + $object->fetch($object->id); |
|
201 | + } |
|
170 | 202 | } |
171 | 203 | } |
172 | 204 | } |
@@ -196,7 +228,9 @@ discard block |
||
196 | 228 | |
197 | 229 | foreach ($TTitle as $k => $title_line) |
198 | 230 | { |
199 | - if (self::titleHasTotalLine($object, $title_line)) unset($TTitle[$k]); |
|
231 | + if (self::titleHasTotalLine($object, $title_line)) { |
|
232 | + unset($TTitle[$k]); |
|
233 | + } |
|
200 | 234 | } |
201 | 235 | |
202 | 236 | return $TTitle; |
@@ -213,23 +247,41 @@ discard block |
||
213 | 247 | */ |
214 | 248 | public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false) |
215 | 249 | { |
216 | - if (empty($object->lines) || !is_array($object->lines)) return false; |
|
250 | + if (empty($object->lines) || !is_array($object->lines)) { |
|
251 | + return false; |
|
252 | + } |
|
217 | 253 | |
218 | 254 | $title_niveau = self::getNiveau($title_line); |
219 | 255 | foreach ($object->lines as &$line) |
220 | 256 | { |
221 | - if ($line->rang <= $title_line->rang) continue; |
|
222 | - 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 |
|
223 | - if (!self::isSubtotal($line)) continue; |
|
257 | + if ($line->rang <= $title_line->rang) { |
|
258 | + continue; |
|
259 | + } |
|
260 | + if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) { |
|
261 | + return false; |
|
262 | + } |
|
263 | + // 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 |
|
264 | + if (!self::isSubtotal($line)) { |
|
265 | + continue; |
|
266 | + } |
|
224 | 267 | |
225 | 268 | $subtotal_niveau = self::getNiveau($line); |
226 | 269 | |
227 | 270 | // Comparaison du niveau de la ligne de sous-total avec celui du titre |
228 | - if ($subtotal_niveau == $title_niveau) return true; // niveau égale => Ok mon titre a un sous-total |
|
229 | - elseif ($subtotal_niveau < $title_niveau) // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3) |
|
271 | + if ($subtotal_niveau == $title_niveau) { |
|
272 | + return true; |
|
273 | + } |
|
274 | + // niveau égale => Ok mon titre a un sous-total |
|
275 | + elseif ($subtotal_niveau < $title_niveau) { |
|
276 | + // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3) |
|
230 | 277 | { |
231 | - if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; // mode strict niveau pas égale donc faux |
|
232 | - else return true; // mode libre => OK je considère que mon titre à un sous-total |
|
278 | + if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; |
|
279 | + } |
|
280 | + // mode strict niveau pas égale donc faux |
|
281 | + else { |
|
282 | + return true; |
|
283 | + } |
|
284 | + // mode libre => OK je considère que mon titre à un sous-total |
|
233 | 285 | } |
234 | 286 | } |
235 | 287 | |
@@ -277,16 +329,19 @@ discard block |
||
277 | 329 | |
278 | 330 | foreach ($object->lines as &$l) |
279 | 331 | { |
280 | - if ($l->rang <= $line->rang) continue; |
|
281 | - elseif (self::isSubtotal($l) && self::getNiveau($l) <= self::getNiveau($line)) break; |
|
282 | - elseif ($breakOnTitle && self::isTitle($l) && self::getNiveau($l) <= self::getNiveau($line)) break; |
|
332 | + if ($l->rang <= $line->rang) { |
|
333 | + continue; |
|
334 | + } elseif (self::isSubtotal($l) && self::getNiveau($l) <= self::getNiveau($line)) { |
|
335 | + break; |
|
336 | + } elseif ($breakOnTitle && self::isTitle($l) && self::getNiveau($l) <= self::getNiveau($line)) { |
|
337 | + break; |
|
338 | + } |
|
283 | 339 | |
284 | 340 | if (!empty($l->array_options['options_subtotal_nc'])) |
285 | 341 | { |
286 | 342 | $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); |
287 | 343 | $TTot['total_options'] += $tabprice[0]; // total ht |
288 | - } |
|
289 | - else |
|
344 | + } else |
|
290 | 345 | { |
291 | 346 | $TTot['total_pa_ht'] += $l->pa_ht * $l->qty; |
292 | 347 | $TTot['total_subprice'] += $l->subprice * $l->qty; |
@@ -306,29 +361,41 @@ discard block |
||
306 | 361 | |
307 | 362 | public static function getOrderIdFromLineId(&$db, $fk_commandedet) |
308 | 363 | { |
309 | - if (empty($fk_commandedet)) return false; |
|
364 | + if (empty($fk_commandedet)) { |
|
365 | + return false; |
|
366 | + } |
|
310 | 367 | |
311 | 368 | $sql = 'SELECT fk_commande FROM '.MAIN_DB_PREFIX.'commandedet WHERE rowid = '.$fk_commandedet; |
312 | 369 | $resql = $db->query($sql); |
313 | 370 | |
314 | - if ($resql && ($row = $db->fetch_object($resql))) return $row->fk_commande; |
|
315 | - else return false; |
|
371 | + if ($resql && ($row = $db->fetch_object($resql))) { |
|
372 | + return $row->fk_commande; |
|
373 | + } else { |
|
374 | + return false; |
|
375 | + } |
|
316 | 376 | } |
317 | 377 | |
318 | 378 | public static function getLastLineOrderId(&$db, $fk_commande) |
319 | 379 | { |
320 | - if (empty($fk_commande)) return false; |
|
380 | + if (empty($fk_commande)) { |
|
381 | + return false; |
|
382 | + } |
|
321 | 383 | |
322 | 384 | $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'commandedet WHERE fk_commande = '.$fk_commande.' ORDER BY rang DESC LIMIT 1'; |
323 | 385 | $resql = $db->query($sql); |
324 | 386 | |
325 | - if ($resql && ($row = $db->fetch_object($resql))) return $row->rowid; |
|
326 | - else return false; |
|
387 | + if ($resql && ($row = $db->fetch_object($resql))) { |
|
388 | + return $row->rowid; |
|
389 | + } else { |
|
390 | + return false; |
|
391 | + } |
|
327 | 392 | } |
328 | 393 | |
329 | 394 | public static function getParentTitleOfLine(&$object, $i) |
330 | 395 | { |
331 | - if ($i <= 0) return false; |
|
396 | + if ($i <= 0) { |
|
397 | + return false; |
|
398 | + } |
|
332 | 399 | |
333 | 400 | $skip_title = 0; |
334 | 401 | // Je parcours les lignes précédentes |
@@ -347,8 +414,7 @@ discard block |
||
347 | 414 | //@INFO J'ai ma ligne titre qui contient ma ligne, par contre je check pas s'il y a un sous-total |
348 | 415 | return $line; |
349 | 416 | break; |
350 | - } |
|
351 | - elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99) |
|
417 | + } elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99) |
|
352 | 418 | { |
353 | 419 | // 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) |
354 | 420 | $skip_title++; |
@@ -363,7 +429,9 @@ discard block |
||
363 | 429 | $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty <= 9; |
364 | 430 | if($res && $level > -1) { |
365 | 431 | return $line->qty == $level; |
366 | - } else return $res; |
|
432 | + } else { |
|
433 | + return $res; |
|
434 | + } |
|
367 | 435 | |
368 | 436 | } |
369 | 437 | |
@@ -372,7 +440,9 @@ discard block |
||
372 | 440 | $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90; |
373 | 441 | if($res && $level > -1) { |
374 | 442 | return self::getNiveau($line) == $level; |
375 | - } else return $res; |
|
443 | + } else { |
|
444 | + return $res; |
|
445 | + } |
|
376 | 446 | } |
377 | 447 | |
378 | 448 | public static function isFreeText(&$line) |
@@ -393,10 +463,14 @@ discard block |
||
393 | 463 | // editeur wysiwyg |
394 | 464 | require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; |
395 | 465 | $nbrows=ROWS_2; |
396 | - if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
466 | + if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) { |
|
467 | + $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT; |
|
468 | + } |
|
397 | 469 | $enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0); |
398 | 470 | $toolbarname='dolibarr_details'; |
399 | - if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes'; |
|
471 | + if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) { |
|
472 | + $toolbarname='dolibarr_notes'; |
|
473 | + } |
|
400 | 474 | $text = !empty($line->description)?$line->description:$line->label; |
401 | 475 | $doleditor=new DolEditor('line-description',$text,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%', $readonly); |
402 | 476 | return $doleditor->Create(1); |
@@ -411,12 +485,10 @@ discard block |
||
411 | 485 | { |
412 | 486 | $object->statut = 0; // hack for facture rec |
413 | 487 | $createRight = $user->rights->facture->creer; |
414 | - } |
|
415 | - elseif($object->element == 'order_supplier' ) |
|
488 | + } elseif($object->element == 'order_supplier' ) |
|
416 | 489 | { |
417 | 490 | $createRight = $user->rights->fournisseur->commande->creer; |
418 | - } |
|
419 | - elseif($object->element == 'invoice_supplier' ) |
|
491 | + } elseif($object->element == 'invoice_supplier' ) |
|
420 | 492 | { |
421 | 493 | $createRight = $user->rights->fournisseur->facture->creer; |
422 | 494 | } |
@@ -489,8 +561,9 @@ discard block |
||
489 | 561 | |
490 | 562 | $TLineAdded[] = $object->line; |
491 | 563 | // Error from addline |
492 | - if ($res <= 0) break; |
|
493 | - else |
|
564 | + if ($res <= 0) { |
|
565 | + break; |
|
566 | + } else |
|
494 | 567 | { |
495 | 568 | $object->line_from = $line; |
496 | 569 | // Call trigger |
@@ -512,8 +585,7 @@ discard block |
||
512 | 585 | _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']); |
513 | 586 | } |
514 | 587 | return count($TLineAdded); |
515 | - } |
|
516 | - else |
|
588 | + } else |
|
517 | 589 | { |
518 | 590 | $object->db->rollback(); |
519 | 591 | return -1; |
@@ -529,10 +601,14 @@ discard block |
||
529 | 601 | global $langs; |
530 | 602 | |
531 | 603 | // Besoin de comparer sur les 2 formes d'écriture |
532 | - if (!$key_is_id) $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad)); |
|
604 | + if (!$key_is_id) { |
|
605 | + $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad)); |
|
606 | + } |
|
533 | 607 | |
534 | 608 | $TTitle_under_search = array(); |
535 | - if (!empty($under_title)) $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title)); |
|
609 | + if (!empty($under_title)) { |
|
610 | + $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title)); |
|
611 | + } |
|
536 | 612 | |
537 | 613 | $TLine = array(); |
538 | 614 | $add_line = false; |
@@ -542,28 +618,37 @@ discard block |
||
542 | 618 | { |
543 | 619 | if (!$under_title_found && !empty($TTitle_under_search)) |
544 | 620 | { |
545 | - if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true; |
|
546 | - } |
|
547 | - else |
|
621 | + if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) { |
|
622 | + $under_title_found = true; |
|
623 | + } |
|
624 | + } else |
|
548 | 625 | { |
549 | 626 | 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) ))) |
550 | 627 | { |
551 | - if ($key_is_id) $level = $line->qty; |
|
628 | + if ($key_is_id) { |
|
629 | + $level = $line->qty; |
|
630 | + } |
|
552 | 631 | |
553 | 632 | $add_line = true; |
554 | - if ($withBlockLine) $TLine[] = $line; |
|
633 | + if ($withBlockLine) { |
|
634 | + $TLine[] = $line; |
|
635 | + } |
|
555 | 636 | continue; |
556 | - } |
|
557 | - elseif ($add_line && TSubtotal::isModSubtotalLine($line) && TSubtotal::getNiveau($line) == $level) // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre |
|
637 | + } elseif ($add_line && TSubtotal::isModSubtotalLine($line) && TSubtotal::getNiveau($line) == $level) { |
|
638 | + // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre |
|
558 | 639 | { |
559 | 640 | if ($withBlockLine) $TLine[] = $line; |
641 | + } |
|
560 | 642 | break; |
561 | 643 | } |
562 | 644 | |
563 | 645 | if ($add_line) |
564 | 646 | { |
565 | - if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue; |
|
566 | - else $TLine[] = $line; |
|
647 | + if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) { |
|
648 | + continue; |
|
649 | + } else { |
|
650 | + $TLine[] = $line; |
|
651 | + } |
|
567 | 652 | } |
568 | 653 | } |
569 | 654 | } |
@@ -597,7 +682,9 @@ discard block |
||
597 | 682 | |
598 | 683 | case 'order_supplier': |
599 | 684 | $object->special_code = SELF::$module_number; |
600 | - if (empty($desc)) $desc = $label; |
|
685 | + if (empty($desc)) { |
|
686 | + $desc = $label; |
|
687 | + } |
|
601 | 688 | $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); |
602 | 689 | break; |
603 | 690 | |
@@ -607,7 +694,9 @@ discard block |
||
607 | 694 | |
608 | 695 | case 'invoice_supplier': |
609 | 696 | $object->special_code = SELF::$module_number; |
610 | - if (empty($desc)) $desc = $label; |
|
697 | + if (empty($desc)) { |
|
698 | + $desc = $label; |
|
699 | + } |
|
611 | 700 | $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); |
612 | 701 | break; |
613 | 702 | |
@@ -624,8 +713,11 @@ discard block |
||
624 | 713 | break; |
625 | 714 | } |
626 | 715 | |
627 | - if ($res <= 0) $object->db->rollback(); |
|
628 | - else $object->db->commit(); |
|
716 | + if ($res <= 0) { |
|
717 | + $object->db->rollback(); |
|
718 | + } else { |
|
719 | + $object->db->commit(); |
|
720 | + } |
|
629 | 721 | |
630 | 722 | return $res; |
631 | 723 | } |
@@ -635,24 +727,20 @@ discard block |
||
635 | 727 | global $db, $object; |
636 | 728 | |
637 | 729 | $TTitle = array(); |
638 | - if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} |
|
639 | - else { |
|
730 | + if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} else { |
|
640 | 731 | if ($origin_line->element == 'propaldet') |
641 | 732 | { |
642 | 733 | $object = new Propal($db); |
643 | 734 | $object->fetch($origin_line->fk_propal); |
644 | - } |
|
645 | - else if ($origin_line->element == 'commandedet') |
|
735 | + } else if ($origin_line->element == 'commandedet') |
|
646 | 736 | { |
647 | 737 | $object = new Commande($db); |
648 | 738 | $object->fetch($origin_line->fk_commande); |
649 | - } |
|
650 | - else if ($origin_line->element == 'facturedet') |
|
739 | + } else if ($origin_line->element == 'facturedet') |
|
651 | 740 | { |
652 | 741 | $object = new Facture($db); |
653 | 742 | $object->fetch($origin_line->fk_facture); |
654 | - } |
|
655 | - else |
|
743 | + } else |
|
656 | 744 | { |
657 | 745 | return $TTitle; |
658 | 746 | } |
@@ -662,8 +750,11 @@ discard block |
||
662 | 750 | $i = 0; |
663 | 751 | foreach ($object->lines as &$line) |
664 | 752 | { |
665 | - if ($origin_line->id == $line->id) break; |
|
666 | - else $i++; |
|
753 | + if ($origin_line->id == $line->id) { |
|
754 | + break; |
|
755 | + } else { |
|
756 | + $i++; |
|
757 | + } |
|
667 | 758 | } |
668 | 759 | |
669 | 760 | $i--; // Skip la ligne d'origine |
@@ -678,35 +769,43 @@ discard block |
||
678 | 769 | if (self::isSubtotal($object->lines[$y])) |
679 | 770 | { |
680 | 771 | $next_title_lvl_to_skip = self::getNiveau($object->lines[$y]); |
681 | - } |
|
682 | - elseif (self::isTitle($object->lines[$y])) |
|
772 | + } elseif (self::isTitle($object->lines[$y])) |
|
683 | 773 | { |
684 | 774 | if ($object->lines[$y]->qty == $next_title_lvl_to_skip) |
685 | 775 | { |
686 | 776 | $next_title_lvl_to_skip = 0; |
687 | 777 | continue; |
688 | - } |
|
689 | - else |
|
778 | + } else |
|
690 | 779 | { |
691 | - if (empty($object->lines[$y]->array_options)) $object->lines[$y]->fetch_optionals(); |
|
780 | + if (empty($object->lines[$y]->array_options)) { |
|
781 | + $object->lines[$y]->fetch_optionals(); |
|
782 | + } |
|
692 | 783 | $TTitle[$object->lines[$y]->id] = $object->lines[$y]; |
693 | 784 | |
694 | - if ($object->lines[$y]->qty == 1) break; |
|
785 | + if ($object->lines[$y]->qty == 1) { |
|
786 | + break; |
|
787 | + } |
|
695 | 788 | } |
696 | 789 | } |
697 | 790 | } |
698 | 791 | } |
699 | 792 | |
700 | - if ($reverse) $TTitle = array_reverse($TTitle, true); |
|
793 | + if ($reverse) { |
|
794 | + $TTitle = array_reverse($TTitle, true); |
|
795 | + } |
|
701 | 796 | |
702 | 797 | return $TTitle; |
703 | 798 | } |
704 | 799 | |
705 | 800 | public static function getNiveau(&$line) |
706 | 801 | { |
707 | - if (self::isTitle($line)) return $line->qty; |
|
708 | - elseif (self::isSubtotal($line)) return 100 - $line->qty; |
|
709 | - else return 0; |
|
802 | + if (self::isTitle($line)) { |
|
803 | + return $line->qty; |
|
804 | + } elseif (self::isSubtotal($line)) { |
|
805 | + return 100 - $line->qty; |
|
806 | + } else { |
|
807 | + return 0; |
|
808 | + } |
|
710 | 809 | } |
711 | 810 | |
712 | 811 | /** |
@@ -731,10 +830,16 @@ discard block |
||
731 | 830 | $objmarge->marge_droite = 10; |
732 | 831 | |
733 | 832 | $objectref = dol_sanitizeFileName($object->ref); |
734 | - if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref; |
|
735 | - elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref; |
|
736 | - elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref; |
|
737 | - elseif ($object->element == 'facturerec') return; // no PDF for facturerec |
|
833 | + if ($object->element == 'propal') { |
|
834 | + $dir = $conf->propal->dir_output . '/' . $objectref; |
|
835 | + } elseif ($object->element == 'commande') { |
|
836 | + $dir = $conf->commande->dir_output . '/' . $objectref; |
|
837 | + } elseif ($object->element == 'facture') { |
|
838 | + $dir = $conf->facture->dir_output . '/' . $objectref; |
|
839 | + } elseif ($object->element == 'facturerec') { |
|
840 | + return; |
|
841 | + } |
|
842 | + // no PDF for facturerec |
|
738 | 843 | else |
739 | 844 | { |
740 | 845 | setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings'); |
@@ -769,7 +874,9 @@ discard block |
||
769 | 874 | $pdf->SetCreator("Dolibarr ".DOL_VERSION); |
770 | 875 | $pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs))); |
771 | 876 | $pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name)); |
772 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
877 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
878 | + $pdf->SetCompression(false); |
|
879 | + } |
|
773 | 880 | |
774 | 881 | $pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite); // Left, Top, Right |
775 | 882 | |
@@ -779,7 +886,9 @@ discard block |
||
779 | 886 | |
780 | 887 | // New page |
781 | 888 | $pdf->AddPage(); |
782 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
889 | + if (! empty($tplidx)) { |
|
890 | + $pdf->useTemplate($tplidx); |
|
891 | + } |
|
783 | 892 | $pagenb++; |
784 | 893 | |
785 | 894 | |
@@ -835,8 +944,10 @@ discard block |
||
835 | 944 | { |
836 | 945 | $TTot['TTotal_tva_multicurrency'][$tx] += $amount; |
837 | 946 | } |
947 | + } else { |
|
948 | + $pdf->SetFont('','', $default_font_size - 1); |
|
838 | 949 | } |
839 | - else $pdf->SetFont('','', $default_font_size - 1); // Into loop to work with multipage |
|
950 | + // Into loop to work with multipage |
|
840 | 951 | |
841 | 952 | $pdf->SetTextColor(0,0,0); |
842 | 953 | |
@@ -858,9 +969,11 @@ discard block |
||
858 | 969 | $pdf->startTransaction(); |
859 | 970 | $pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true); |
860 | 971 | $pageposafter=$pdf->getPage(); |
861 | - if ($pageposafter > $pageposbefore) // There is a pagebreak |
|
972 | + if ($pageposafter > $pageposbefore) { |
|
973 | + // There is a pagebreak |
|
862 | 974 | { |
863 | 975 | $pdf->rollbackTransaction(true); |
976 | + } |
|
864 | 977 | $pageposafter=$pageposbefore; |
865 | 978 | //print $pageposafter.'-'.$pageposbefore;exit; |
866 | 979 | $pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it. |
@@ -869,23 +982,27 @@ discard block |
||
869 | 982 | $pageposafter=$pdf->getPage(); |
870 | 983 | $posyafter=$pdf->GetY(); |
871 | 984 | //var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit; |
872 | - if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) // There is no space left for total+free text |
|
985 | + if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) { |
|
986 | + // There is no space left for total+free text |
|
873 | 987 | { |
874 | 988 | if ($i == ($nblignes-1)) // No more lines, and no space left to show total, so we create a new page |
875 | 989 | { |
876 | 990 | $pdf->AddPage('','',true); |
877 | - if (! empty($tplidx)) $pdf->useTemplate($tplidx); |
|
878 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
991 | + } |
|
992 | + if (! empty($tplidx)) { |
|
993 | + $pdf->useTemplate($tplidx); |
|
994 | + } |
|
995 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
996 | + self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
997 | + } |
|
879 | 998 | $pdf->setPage($pageposafter+1); |
880 | 999 | } |
881 | - } |
|
882 | - else |
|
1000 | + } else |
|
883 | 1001 | { |
884 | 1002 | // We found a page break |
885 | 1003 | $showpricebeforepagebreak=0; |
886 | 1004 | } |
887 | - } |
|
888 | - else // No pagebreak |
|
1005 | + } else // No pagebreak |
|
889 | 1006 | { |
890 | 1007 | $pdf->commitTransaction(); |
891 | 1008 | } |
@@ -925,8 +1042,7 @@ discard block |
||
925 | 1042 | if ($pagenb == 1) |
926 | 1043 | { |
927 | 1044 | 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); |
928 | - } |
|
929 | - else |
|
1045 | + } else |
|
930 | 1046 | { |
931 | 1047 | 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); |
932 | 1048 | } |
@@ -934,7 +1050,9 @@ discard block |
||
934 | 1050 | $pagenb++; |
935 | 1051 | $pdf->setPage($pagenb); |
936 | 1052 | $pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it. |
937 | - if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
1053 | + if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) { |
|
1054 | + self::pagehead($objmarge, $pdf, $object, 0, $outputlangs); |
|
1055 | + } |
|
938 | 1056 | } |
939 | 1057 | } |
940 | 1058 | } |
@@ -944,8 +1062,7 @@ discard block |
||
944 | 1062 | { |
945 | 1063 | 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); |
946 | 1064 | $bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
947 | - } |
|
948 | - else |
|
1065 | + } else |
|
949 | 1066 | { |
950 | 1067 | 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); |
951 | 1068 | $bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1; |
@@ -959,7 +1076,9 @@ discard block |
||
959 | 1076 | |
960 | 1077 | $pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file); |
961 | 1078 | |
962 | - if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) unlink($file); |
|
1079 | + if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) { |
|
1080 | + unlink($file); |
|
1081 | + } |
|
963 | 1082 | } |
964 | 1083 | |
965 | 1084 | private static function printLevel($objmarge, $pdf, $line, $curY, $posx_designation) |
@@ -1002,8 +1121,7 @@ discard block |
||
1002 | 1121 | { |
1003 | 1122 | $height=pdf_getHeightForLogo($logo); |
1004 | 1123 | $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto) |
1005 | - } |
|
1006 | - else |
|
1124 | + } else |
|
1007 | 1125 | { |
1008 | 1126 | $pdf->SetTextColor(200,0,0); |
1009 | 1127 | $pdf->SetFont('','B',$default_font_size - 2); |
@@ -1012,8 +1130,7 @@ discard block |
||
1012 | 1130 | } |
1013 | 1131 | |
1014 | 1132 | $posy+=35; |
1015 | - } |
|
1016 | - else |
|
1133 | + } else |
|
1017 | 1134 | { |
1018 | 1135 | $text=$mysoc->name; |
1019 | 1136 | $pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L'); |
@@ -1027,9 +1144,13 @@ discard block |
||
1027 | 1144 | $pdf->SetXY($objmarge->marge_gauche,$posy); |
1028 | 1145 | |
1029 | 1146 | $key = 'subtotalPropalTitle'; |
1030 | - if ($object->element == 'commande') $key = 'subtotalCommandeTitle'; |
|
1031 | - elseif ($object->element == 'facture') $key = 'subtotalInvoiceTitle'; |
|
1032 | - elseif ($object->element == 'facturerec') $key = 'subtotalInvoiceTitle'; |
|
1147 | + if ($object->element == 'commande') { |
|
1148 | + $key = 'subtotalCommandeTitle'; |
|
1149 | + } elseif ($object->element == 'facture') { |
|
1150 | + $key = 'subtotalInvoiceTitle'; |
|
1151 | + } elseif ($object->element == 'facturerec') { |
|
1152 | + $key = 'subtotalInvoiceTitle'; |
|
1153 | + } |
|
1033 | 1154 | |
1034 | 1155 | $pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L'); |
1035 | 1156 | |
@@ -1064,7 +1185,9 @@ discard block |
||
1064 | 1185 | |
1065 | 1186 | // Force to disable hidetop and hidebottom |
1066 | 1187 | $hidebottom=0; |
1067 | - if ($hidetop) $hidetop=-1; |
|
1188 | + if ($hidetop) { |
|
1189 | + $hidetop=-1; |
|
1190 | + } |
|
1068 | 1191 | |
1069 | 1192 | $currency = !empty($currency) ? $currency : $conf->currency; |
1070 | 1193 | $default_font_size = pdf_getPDFFontSize($outputlangs); |
@@ -1079,7 +1202,9 @@ discard block |
||
1079 | 1202 | $pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5); |
1080 | 1203 | $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre); |
1081 | 1204 | |
1082 | - 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)); |
|
1205 | + if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) { |
|
1206 | + $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 | + } |
|
1083 | 1208 | |
1084 | 1209 | |
1085 | 1210 | $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 |
@@ -1092,8 +1217,7 @@ discard block |
||
1092 | 1217 | $pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R'); |
1093 | 1218 | |
1094 | 1219 | $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 |
1095 | - } |
|
1096 | - else |
|
1220 | + } else |
|
1097 | 1221 | { |
1098 | 1222 | $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 |
1099 | 1223 | } |
@@ -1114,10 +1238,12 @@ discard block |
||
1114 | 1238 | |
1115 | 1239 | // Tableau total |
1116 | 1240 | $col1x = 120; $col2x = 170; |
1117 | - if ($objmarge->page_largeur < 210) // To work with US executive format |
|
1241 | + if ($objmarge->page_largeur < 210) { |
|
1242 | + // To work with US executive format |
|
1118 | 1243 | { |
1119 | 1244 | $col2x-=20; |
1120 | 1245 | } |
1246 | + } |
|
1121 | 1247 | $largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x); |
1122 | 1248 | |
1123 | 1249 | $useborder=0; |
@@ -1139,9 +1265,11 @@ discard block |
||
1139 | 1265 | $atleastoneratenotnull=0; |
1140 | 1266 | foreach($TTot['TTotal_tva'] as $tvakey => $tvaval) |
1141 | 1267 | { |
1142 | - if ($tvakey != 0) // On affiche pas taux 0 |
|
1268 | + if ($tvakey != 0) { |
|
1269 | + // On affiche pas taux 0 |
|
1143 | 1270 | { |
1144 | 1271 | $atleastoneratenotnull++; |
1272 | + } |
|
1145 | 1273 | |
1146 | 1274 | $index++; |
1147 | 1275 | $pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index); |
@@ -1194,9 +1322,13 @@ discard block |
||
1194 | 1322 | */ |
1195 | 1323 | private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0) |
1196 | 1324 | { |
1197 | - if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y); |
|
1325 | + if (empty($hidetop) || $hidetop==-1) { |
|
1326 | + $pdf->line($x, $y, $x+$l, $y); |
|
1327 | + } |
|
1198 | 1328 | $pdf->line($x+$l, $y, $x+$l, $y+$h); |
1199 | - if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
1329 | + if (empty($hidebottom)) { |
|
1330 | + $pdf->line($x+$l, $y+$h, $x, $y+$h); |
|
1331 | + } |
|
1200 | 1332 | $pdf->line($x, $y+$h, $x, $y); |
1201 | 1333 | } |
1202 | 1334 | |
@@ -1205,7 +1337,9 @@ discard block |
||
1205 | 1337 | { |
1206 | 1338 | global $conf; |
1207 | 1339 | |
1208 | - if (empty($fileoutput)) $fileoutput = $file[0]; |
|
1340 | + if (empty($fileoutput)) { |
|
1341 | + $fileoutput = $file[0]; |
|
1342 | + } |
|
1209 | 1343 | |
1210 | 1344 | $pdf=pdf_getInstance(); |
1211 | 1345 | if (class_exists('TCPDF')) |
@@ -1215,7 +1349,9 @@ discard block |
||
1215 | 1349 | } |
1216 | 1350 | $pdf->SetFont(pdf_getPDFFont($outputlangs)); |
1217 | 1351 | |
1218 | - if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false); |
|
1352 | + if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) { |
|
1353 | + $pdf->SetCompression(false); |
|
1354 | + } |
|
1219 | 1355 | |
1220 | 1356 | |
1221 | 1357 | foreach($files as $file) |
@@ -1231,7 +1367,9 @@ discard block |
||
1231 | 1367 | } |
1232 | 1368 | |
1233 | 1369 | $pdf->Output($fileoutput,'F'); |
1234 | - if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
1370 | + if (! empty($conf->global->MAIN_UMASK)) { |
|
1371 | + @chmod($file, octdec($conf->global->MAIN_UMASK)); |
|
1372 | + } |
|
1235 | 1373 | |
1236 | 1374 | return $pagecount; |
1237 | 1375 | } |
@@ -1244,7 +1382,9 @@ discard block |
||
1244 | 1382 | */ |
1245 | 1383 | public static function hasNcTitle(&$line) |
1246 | 1384 | { |
1247 | - if(isset($line->has_nc_title)) return $line->has_nc_title; |
|
1385 | + if(isset($line->has_nc_title)) { |
|
1386 | + return $line->has_nc_title; |
|
1387 | + } |
|
1248 | 1388 | |
1249 | 1389 | $TTitle = self::getAllTitleFromLine($line); |
1250 | 1390 | foreach ($TTitle as &$line_title) |
@@ -1269,7 +1409,9 @@ discard block |
||
1269 | 1409 | public static function getTitleLabel($line) |
1270 | 1410 | { |
1271 | 1411 | $title = $line->label; |
1272 | - if (empty($title)) $title = !empty($line->description) ? $line->description : $line->desc; |
|
1412 | + if (empty($title)) { |
|
1413 | + $title = !empty($line->description) ? $line->description : $line->desc; |
|
1414 | + } |
|
1273 | 1415 | return $title; |
1274 | 1416 | } |
1275 | 1417 | } |