@@ -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 ) 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 ) { |
|
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 = ' '; |
@@ -1323,8 +1394,7 @@ discard block |
||
1323 | 1394 | |
1324 | 1395 | if((float)DOL_VERSION<=3.6) { |
1325 | 1396 | return ''; |
1326 | - } |
|
1327 | - else if((float)DOL_VERSION>=3.8) { |
|
1397 | + } else if((float)DOL_VERSION>=3.8) { |
|
1328 | 1398 | return 1; |
1329 | 1399 | } |
1330 | 1400 | } |
@@ -1369,8 +1439,11 @@ discard block |
||
1369 | 1439 | function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') { |
1370 | 1440 | global $conf,$hideprices,$hookmanager; |
1371 | 1441 | |
1372 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1373 | - else $i = (int) $parameters; |
|
1442 | + if(is_array($parameters)) { |
|
1443 | + $i = & $parameters['i']; |
|
1444 | + } else { |
|
1445 | + $i = (int) $parameters; |
|
1446 | + } |
|
1374 | 1447 | |
1375 | 1448 | if($this->isModSubtotalLine($parameters,$object) ) { |
1376 | 1449 | $this->resprints = ' '; |
@@ -1389,12 +1462,10 @@ discard block |
||
1389 | 1462 | |
1390 | 1463 | if((float)DOL_VERSION<=3.6) { |
1391 | 1464 | return ''; |
1392 | - } |
|
1393 | - else if((float)DOL_VERSION>=3.8) { |
|
1465 | + } else if((float)DOL_VERSION>=3.8) { |
|
1394 | 1466 | return 1; |
1395 | 1467 | } |
1396 | - } |
|
1397 | - elseif (!empty($hideprices) |
|
1468 | + } elseif (!empty($hideprices) |
|
1398 | 1469 | || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
1399 | 1470 | ) |
1400 | 1471 | { |
@@ -1415,14 +1486,16 @@ discard block |
||
1415 | 1486 | $this->resprints = ' '; |
1416 | 1487 | if((float)DOL_VERSION<=3.6) { |
1417 | 1488 | return ''; |
1418 | - } |
|
1419 | - else if((float)DOL_VERSION>=3.8) { |
|
1489 | + } else if((float)DOL_VERSION>=3.8) { |
|
1420 | 1490 | return 1; |
1421 | 1491 | } |
1422 | 1492 | } |
1423 | 1493 | |
1424 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1425 | - else $i = (int)$parameters; |
|
1494 | + if(is_array($parameters)) { |
|
1495 | + $i = & $parameters['i']; |
|
1496 | + } else { |
|
1497 | + $i = (int)$parameters; |
|
1498 | + } |
|
1426 | 1499 | |
1427 | 1500 | if (!empty($hideprices) |
1428 | 1501 | || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
@@ -1446,16 +1519,21 @@ discard block |
||
1446 | 1519 | |
1447 | 1520 | if((float)DOL_VERSION<=3.6) { |
1448 | 1521 | return ''; |
1449 | - } |
|
1450 | - else if((float)DOL_VERSION>=3.8) { |
|
1522 | + } else if((float)DOL_VERSION>=3.8) { |
|
1451 | 1523 | return 1; |
1452 | 1524 | } |
1453 | 1525 | } |
1454 | 1526 | |
1455 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1456 | - else $i = (int)$parameters; |
|
1527 | + if(is_array($parameters)) { |
|
1528 | + $i = & $parameters['i']; |
|
1529 | + } else { |
|
1530 | + $i = (int)$parameters; |
|
1531 | + } |
|
1457 | 1532 | |
1458 | - 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) |
|
1533 | + if (empty($object->lines[$i])) { |
|
1534 | + return 0; |
|
1535 | + } |
|
1536 | + // 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) |
|
1459 | 1537 | |
1460 | 1538 | $object->lines[$i]->fetch_optionals(); |
1461 | 1539 | // Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché |
@@ -1501,14 +1579,16 @@ discard block |
||
1501 | 1579 | $this->resprints = ' '; |
1502 | 1580 | if((float)DOL_VERSION<=3.6) { |
1503 | 1581 | return ''; |
1504 | - } |
|
1505 | - else if((float)DOL_VERSION>=3.8) { |
|
1582 | + } else if((float)DOL_VERSION>=3.8) { |
|
1506 | 1583 | return 1; |
1507 | 1584 | } |
1508 | 1585 | } |
1509 | 1586 | |
1510 | - if(is_array($parameters)) $i = & $parameters['i']; |
|
1511 | - else $i = (int)$parameters; |
|
1587 | + if(is_array($parameters)) { |
|
1588 | + $i = & $parameters['i']; |
|
1589 | + } else { |
|
1590 | + $i = (int)$parameters; |
|
1591 | + } |
|
1512 | 1592 | |
1513 | 1593 | if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) |
1514 | 1594 | { |
@@ -1538,7 +1618,9 @@ discard block |
||
1538 | 1618 | } |
1539 | 1619 | } |
1540 | 1620 | |
1541 | - if (!empty($TLineTitle)) $TTitleNumeroted = $this->formatNumerotation($TLineTitle); |
|
1621 | + if (!empty($TLineTitle)) { |
|
1622 | + $TTitleNumeroted = $this->formatNumerotation($TLineTitle); |
|
1623 | + } |
|
1542 | 1624 | } |
1543 | 1625 | |
1544 | 1626 | } |
@@ -1552,8 +1634,12 @@ discard block |
||
1552 | 1634 | $j=0; |
1553 | 1635 | foreach ($TLineTitle as $k => &$line) |
1554 | 1636 | { |
1555 | - if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue; |
|
1556 | - if (!empty($line_reference) && $line->qty <= $line_reference->qty) break; |
|
1637 | + if (!empty($line_reference) && $line->rang <= $line_reference->rang) { |
|
1638 | + continue; |
|
1639 | + } |
|
1640 | + if (!empty($line_reference) && $line->qty <= $line_reference->qty) { |
|
1641 | + break; |
|
1642 | + } |
|
1557 | 1643 | |
1558 | 1644 | if ($line->qty == $level) |
1559 | 1645 | { |
@@ -1587,7 +1673,9 @@ discard block |
||
1587 | 1673 | |
1588 | 1674 | $hidedetails = (int)GETPOST('hidedetails'); |
1589 | 1675 | |
1590 | - if(empty($hidedetails)) return false; |
|
1676 | + if(empty($hidedetails)) { |
|
1677 | + return false; |
|
1678 | + } |
|
1591 | 1679 | |
1592 | 1680 | // TODO can't add VAT to document without lines... :-/ |
1593 | 1681 | |
@@ -1648,7 +1736,9 @@ discard block |
||
1648 | 1736 | */ |
1649 | 1737 | list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1); |
1650 | 1738 | |
1651 | - if (TSubtotal::getNiveau($line) == 1) $line->TTotal_tva = $TTotal_tva; |
|
1739 | + if (TSubtotal::getNiveau($line) == 1) { |
|
1740 | + $line->TTotal_tva = $TTotal_tva; |
|
1741 | + } |
|
1652 | 1742 | $line->total_ht = $total; |
1653 | 1743 | $line->total_tva = $total_tva; |
1654 | 1744 | $line->total = $line->total_ht; |
@@ -1712,8 +1802,7 @@ discard block |
||
1712 | 1802 | } |
1713 | 1803 | |
1714 | 1804 | |
1715 | - } |
|
1716 | - elseif ($hidedetails) |
|
1805 | + } elseif ($hidedetails) |
|
1717 | 1806 | { |
1718 | 1807 | $TLines[] = $line; //Cas oĂą je cache uniquement les prix des produits |
1719 | 1808 | } |
@@ -1784,7 +1873,9 @@ discard block |
||
1784 | 1873 | |
1785 | 1874 | if(!empty($hideprices)) { |
1786 | 1875 | foreach($object->lines as &$line) { |
1787 | - if($line->fk_product_type!=9) $line->fk_parent_line = -1; |
|
1876 | + if($line->fk_product_type!=9) { |
|
1877 | + $line->fk_parent_line = -1; |
|
1878 | + } |
|
1788 | 1879 | } |
1789 | 1880 | } |
1790 | 1881 | |
@@ -1805,7 +1896,9 @@ discard block |
||
1805 | 1896 | |
1806 | 1897 | if($line->qty>90) { |
1807 | 1898 | |
1808 | - if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) $label .= ' '.$this->getTitle($object, $line); |
|
1899 | + if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) { |
|
1900 | + $label .= ' '.$this->getTitle($object, $line); |
|
1901 | + } |
|
1809 | 1902 | |
1810 | 1903 | $pageBefore = $pdf->getPage(); |
1811 | 1904 | $this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); |
@@ -1823,8 +1916,7 @@ discard block |
||
1823 | 1916 | |
1824 | 1917 | $posy = $pdf->GetY(); |
1825 | 1918 | return 1; |
1826 | - } |
|
1827 | - else if ($line->qty < 10) { |
|
1919 | + } else if ($line->qty < 10) { |
|
1828 | 1920 | $pageBefore = $pdf->getPage(); |
1829 | 1921 | |
1830 | 1922 | $this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); |
@@ -1848,8 +1940,7 @@ discard block |
||
1848 | 1940 | // if($line->rowid==47) exit; |
1849 | 1941 | |
1850 | 1942 | return 0; |
1851 | - } |
|
1852 | - elseif (empty($object->lines[$parameters['i']])) |
|
1943 | + } elseif (empty($object->lines[$parameters['i']])) |
|
1853 | 1944 | { |
1854 | 1945 | $this->resprints = -1; |
1855 | 1946 | } |
@@ -1882,7 +1973,9 @@ discard block |
||
1882 | 1973 | |
1883 | 1974 | foreach ($object->lines as $line) |
1884 | 1975 | { |
1885 | - if ($line->id == $currentLine->id) break; |
|
1976 | + if ($line->id == $currentLine->id) { |
|
1977 | + break; |
|
1978 | + } |
|
1886 | 1979 | |
1887 | 1980 | $qty_search = 100 - $currentLine->qty; |
1888 | 1981 | |
@@ -1919,23 +2012,23 @@ discard block |
||
1919 | 2012 | { |
1920 | 2013 | $object->statut = 0; // hack for facture rec |
1921 | 2014 | $createRight = $user->rights->facture->creer; |
1922 | - } |
|
1923 | - elseif($object->element == 'order_supplier' ) |
|
2015 | + } elseif($object->element == 'order_supplier' ) |
|
1924 | 2016 | { |
1925 | 2017 | $createRight = $user->rights->fournisseur->commande->creer; |
1926 | - } |
|
1927 | - elseif($object->element == 'invoice_supplier' ) |
|
2018 | + } elseif($object->element == 'invoice_supplier' ) |
|
1928 | 2019 | { |
1929 | 2020 | $createRight = $user->rights->fournisseur->facture->creer; |
1930 | 2021 | } |
1931 | 2022 | |
1932 | 2023 | if($line->special_code!=$this->module_number || $line->product_type!=9) { |
1933 | 2024 | null; |
1934 | - } |
|
1935 | - 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)) |
|
2025 | + } 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)) |
|
1936 | 2026 | { |
1937 | - if($object->element=='facture')$idvar = 'facid'; |
|
1938 | - else $idvar='id'; |
|
2027 | + if($object->element=='facture') { |
|
2028 | + $idvar = 'facid'; |
|
2029 | + } else { |
|
2030 | + $idvar='id'; |
|
2031 | + } |
|
1939 | 2032 | |
1940 | 2033 | if((float)DOL_VERSION <= 3.4) |
1941 | 2034 | { |
@@ -1961,22 +2054,44 @@ discard block |
||
1961 | 2054 | <?php |
1962 | 2055 | } |
1963 | 2056 | |
1964 | - if(empty($line->description)) $line->description = $line->desc; |
|
2057 | + if(empty($line->description)) { |
|
2058 | + $line->description = $line->desc; |
|
2059 | + } |
|
1965 | 2060 | |
1966 | 2061 | $colspan = 5; |
1967 | - if($object->element == 'facturerec' ) $colspan = 3; |
|
1968 | - if($object->element == 'order_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6; |
|
1969 | - if($object->element == 'invoice_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7; |
|
1970 | - if($object->element == 'supplier_proposal') (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3; |
|
2062 | + if($object->element == 'facturerec' ) { |
|
2063 | + $colspan = 3; |
|
2064 | + } |
|
2065 | + if($object->element == 'order_supplier') { |
|
2066 | + (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6; |
|
2067 | + } |
|
2068 | + if($object->element == 'invoice_supplier') { |
|
2069 | + (float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7; |
|
2070 | + } |
|
2071 | + if($object->element == 'supplier_proposal') { |
|
2072 | + (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3; |
|
2073 | + } |
|
1971 | 2074 | if(!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) { |
1972 | 2075 | $colspan++; // Colonne PU Devise |
1973 | 2076 | } |
1974 | - if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++; |
|
1975 | - if(!empty($conf->margin->enabled)) $colspan++; |
|
1976 | - if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++; |
|
1977 | - if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++; |
|
1978 | - if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++; |
|
1979 | - if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++; |
|
2077 | + if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) { |
|
2078 | + $colspan++; |
|
2079 | + } |
|
2080 | + if(!empty($conf->margin->enabled)) { |
|
2081 | + $colspan++; |
|
2082 | + } |
|
2083 | + if(!empty($conf->global->DISPLAY_MARGIN_RATES)) { |
|
2084 | + $colspan++; |
|
2085 | + } |
|
2086 | + if(!empty($conf->global->DISPLAY_MARK_RATES)) { |
|
2087 | + $colspan++; |
|
2088 | + } |
|
2089 | + if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) { |
|
2090 | + $colspan++; |
|
2091 | + } |
|
2092 | + if(!empty($conf->global->PRODUCT_USE_UNITS)) { |
|
2093 | + $colspan++; |
|
2094 | + } |
|
1980 | 2095 | |
1981 | 2096 | /* Titre */ |
1982 | 2097 | //var_dump($line); |
@@ -1989,23 +2104,36 @@ discard block |
||
1989 | 2104 | <tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php |
1990 | 2105 | if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT)) |
1991 | 2106 | { |
1992 | - if($line->qty==99) print 'background:#adadcf'; |
|
1993 | - else if($line->qty==98) print 'background:#ddddff;'; |
|
1994 | - else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;'; |
|
1995 | - else if($line->qty==1) print 'background:#adadcf;'; |
|
1996 | - else if($line->qty==2) print 'background:#ddddff;'; |
|
1997 | - else if($line->qty==50) print ''; |
|
1998 | - else print 'background:#eeeeff;'; |
|
2107 | + if($line->qty==99) { |
|
2108 | + print 'background:#adadcf'; |
|
2109 | + } else if($line->qty==98) { |
|
2110 | + print 'background:#ddddff;'; |
|
2111 | + } else if($line->qty<=97 && $line->qty>=91) { |
|
2112 | + print 'background:#eeeeff;'; |
|
2113 | + } else if($line->qty==1) { |
|
2114 | + print 'background:#adadcf;'; |
|
2115 | + } else if($line->qty==2) { |
|
2116 | + print 'background:#ddddff;'; |
|
2117 | + } else if($line->qty==50) { |
|
2118 | + print ''; |
|
2119 | + } else { |
|
2120 | + print 'background:#eeeeff;'; |
|
2121 | + } |
|
1999 | 2122 | |
2000 | 2123 | //A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9 |
2001 | - } |
|
2002 | - else |
|
2124 | + } else |
|
2003 | 2125 | { |
2004 | - if($line->qty==99) print 'background:#ddffdd'; |
|
2005 | - else if($line->qty==98) print 'background:#ddddff;'; |
|
2006 | - else if($line->qty==2) print 'background:#eeeeff; '; |
|
2007 | - else if($line->qty==50) print ''; |
|
2008 | - else print 'background:#eeffee;' ; |
|
2126 | + if($line->qty==99) { |
|
2127 | + print 'background:#ddffdd'; |
|
2128 | + } else if($line->qty==98) { |
|
2129 | + print 'background:#ddddff;'; |
|
2130 | + } else if($line->qty==2) { |
|
2131 | + print 'background:#eeeeff; '; |
|
2132 | + } else if($line->qty==50) { |
|
2133 | + print ''; |
|
2134 | + } else { |
|
2135 | + print 'background:#eeffee;' ; |
|
2136 | + } |
|
2009 | 2137 | } |
2010 | 2138 | |
2011 | 2139 | ?>;"> |
@@ -2032,13 +2160,11 @@ discard block |
||
2032 | 2160 | $qty_displayed = $line->qty; |
2033 | 2161 | print img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span> '; |
2034 | 2162 | |
2035 | - } |
|
2036 | - else if (TSubtotal::isSubtotal($line)) |
|
2163 | + } else if (TSubtotal::isSubtotal($line)) |
|
2037 | 2164 | { |
2038 | 2165 | $qty_displayed = 100 - $line->qty; |
2039 | 2166 | print img_picto('', 'subsubtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;color:#0075DE;">'.$qty_displayed.'</span> '; |
2040 | - } |
|
2041 | - else |
|
2167 | + } else |
|
2042 | 2168 | { |
2043 | 2169 | $isFreeText = true; |
2044 | 2170 | } |
@@ -2059,9 +2185,13 @@ discard block |
||
2059 | 2185 | } |
2060 | 2186 | |
2061 | 2187 | $readonlyForSituation = ''; |
2062 | - if ($line->fk_prev_id != NULL ) $readonlyForSituation = 'readonly'; |
|
2188 | + if ($line->fk_prev_id != NULL ) { |
|
2189 | + $readonlyForSituation = 'readonly'; |
|
2190 | + } |
|
2063 | 2191 | |
2064 | - if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/> '; |
|
2192 | + if (!$isFreeText) { |
|
2193 | + echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/> '; |
|
2194 | + } |
|
2065 | 2195 | |
2066 | 2196 | if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) ) |
2067 | 2197 | { |
@@ -2069,8 +2199,12 @@ discard block |
||
2069 | 2199 | for ($j=1; $j<10; $j++) |
2070 | 2200 | { |
2071 | 2201 | if (!empty($readonlyForSituation)) { |
2072 | - if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
|
2073 | - } else $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
|
2202 | + if ($qty_displayed == $j) { |
|
2203 | + $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
|
2204 | + } |
|
2205 | + } else { |
|
2206 | + $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>'; |
|
2207 | + } |
|
2074 | 2208 | } |
2075 | 2209 | $select .= '</select> '; |
2076 | 2210 | |
@@ -2090,7 +2224,9 @@ discard block |
||
2090 | 2224 | echo '<div>'; |
2091 | 2225 | echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>'; |
2092 | 2226 | echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>'; |
2093 | - if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true)); |
|
2227 | + if (empty($readonlyForSituation)) { |
|
2228 | + echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true)); |
|
2229 | + } |
|
2094 | 2230 | echo '</select>'; |
2095 | 2231 | echo '</div>'; |
2096 | 2232 | |
@@ -2109,8 +2245,9 @@ discard block |
||
2109 | 2245 | 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"' : '') .' /> '; |
2110 | 2246 | echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>'; |
2111 | 2247 | echo '</div>'; |
2248 | + } else if ($isFreeText) { |
|
2249 | + echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation); |
|
2112 | 2250 | } |
2113 | - else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation); |
|
2114 | 2251 | echo '</div>'; |
2115 | 2252 | |
2116 | 2253 | if($line->qty<10) { |
@@ -2130,8 +2267,7 @@ discard block |
||
2130 | 2267 | $doleditor->Create(); |
2131 | 2268 | } |
2132 | 2269 | |
2133 | - } |
|
2134 | - else { |
|
2270 | + } else { |
|
2135 | 2271 | |
2136 | 2272 | if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) |
2137 | 2273 | { |
@@ -2139,14 +2275,19 @@ discard block |
||
2139 | 2275 | { |
2140 | 2276 | echo str_repeat(' ', $line->qty-1); |
2141 | 2277 | |
2142 | - if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span> '; |
|
2143 | - else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span> '; |
|
2278 | + if (TSubtotal::isTitle($line)) { |
|
2279 | + print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span> '; |
|
2280 | + } else { |
|
2281 | + print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span> '; |
|
2282 | + } |
|
2144 | 2283 | } |
2145 | - } |
|
2146 | - else |
|
2284 | + } else |
|
2147 | 2285 | { |
2148 | - if($line->qty<=1) print img_picto('', 'subtotal@subtotal'); |
|
2149 | - else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').' '; |
|
2286 | + if($line->qty<=1) { |
|
2287 | + print img_picto('', 'subtotal@subtotal'); |
|
2288 | + } else if($line->qty==2) { |
|
2289 | + print img_picto('', 'subsubtotal@subtotal').' '; |
|
2290 | + } |
|
2150 | 2291 | } |
2151 | 2292 | |
2152 | 2293 | |
@@ -2156,21 +2297,26 @@ discard block |
||
2156 | 2297 | $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;'; |
2157 | 2298 | |
2158 | 2299 | if (empty($line->label)) { |
2159 | - if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print $line->description.' '.$this->getTitle($object, $line); |
|
2160 | - else print $line->description; |
|
2161 | - } |
|
2162 | - else { |
|
2300 | + if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) { |
|
2301 | + print $line->description.' '.$this->getTitle($object, $line); |
|
2302 | + } else { |
|
2303 | + print $line->description; |
|
2304 | + } |
|
2305 | + } else { |
|
2163 | 2306 | |
2164 | 2307 | if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) { |
2165 | 2308 | print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>'; |
2166 | - } |
|
2167 | - else{ |
|
2309 | + } else{ |
|
2168 | 2310 | print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>'; |
2169 | 2311 | } |
2170 | 2312 | |
2171 | 2313 | } |
2172 | - if($line->qty>90) print ' : '; |
|
2173 | - if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal'); |
|
2314 | + if($line->qty>90) { |
|
2315 | + print ' : '; |
|
2316 | + } |
|
2317 | + if($line->info_bits > 0) { |
|
2318 | + echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal'); |
|
2319 | + } |
|
2174 | 2320 | |
2175 | 2321 | |
2176 | 2322 | |
@@ -2213,11 +2359,12 @@ discard block |
||
2213 | 2359 | </script> |
2214 | 2360 | <?php |
2215 | 2361 | |
2216 | - } |
|
2217 | - else{ |
|
2362 | + } else{ |
|
2218 | 2363 | if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier') |
2219 | 2364 | { |
2220 | - 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>'; |
|
2365 | + if(TSubtotal::isTitle($line) && ($line->fk_prev_id == NULL ) ) { |
|
2366 | + echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>'; |
|
2367 | + } |
|
2221 | 2368 | } |
2222 | 2369 | |
2223 | 2370 | if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) |
@@ -2306,7 +2453,9 @@ discard block |
||
2306 | 2453 | $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); |
2307 | 2454 | |
2308 | 2455 | $colspan+=3; $mode = 'view'; |
2309 | - if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit'; |
|
2456 | + if($action === 'editline' && $line->rowid == GETPOST('lineid')) { |
|
2457 | + $mode = 'edit'; |
|
2458 | + } |
|
2310 | 2459 | |
2311 | 2460 | $ex_element = $line->element; |
2312 | 2461 | $line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr |
@@ -2488,10 +2637,9 @@ discard block |
||
2488 | 2637 | |
2489 | 2638 | if(TSubtotal::isTitle($line)){ |
2490 | 2639 | $ThtmlData['data-issubtotal'] = 'title'; |
2491 | - }elseif(TSubtotal::isSubtotal($line)){ |
|
2640 | + } elseif(TSubtotal::isSubtotal($line)){ |
|
2492 | 2641 | $ThtmlData['data-issubtotal'] = 'subtotal'; |
2493 | - } |
|
2494 | - else{ |
|
2642 | + } else{ |
|
2495 | 2643 | $ThtmlData['data-issubtotal'] = 'freetext'; |
2496 | 2644 | } |
2497 | 2645 | |
@@ -2501,7 +2649,9 @@ discard block |
||
2501 | 2649 | |
2502 | 2650 | // hook |
2503 | 2651 | $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook |
2504 | - if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
2652 | + if ($reshook < 0) { |
|
2653 | + setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); |
|
2654 | + } |
|
2505 | 2655 | if ($reshook>0) |
2506 | 2656 | { |
2507 | 2657 | $ThtmlData = $hookmanager->resArray; |