Passed
Pull Request — master (#112)
by
unknown
02:07
created
class/actions_subtotal.class.php 1 patch
Braces   +353 added lines, -215 removed lines patch added patch discarded remove patch
@@ -75,8 +75,11 @@  discard block
 block discarded – undo
75 75
 			if ($object->statut == 0  && $createRight) {
76 76
 			
77 77
 
78
-				if($object->element=='facture')$idvar = 'facid';
79
-				else $idvar='id';
78
+				if($object->element=='facture') {
79
+					$idvar = 'facid';
80
+				} else {
81
+					$idvar='id';
82
+				}
80 83
 				
81 84
 				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
82 85
 				{
@@ -84,10 +87,11 @@  discard block
 block discarded – undo
84 87
 					
85 88
 					if($action=='add_title_line') {
86 89
 						$title = GETPOST('title');
87
-						if(empty($title)) $title = $langs->trans('title');
90
+						if(empty($title)) {
91
+							$title = $langs->trans('title');
92
+						}
88 93
 						$qty = $level<1 ? 1 : $level ;
89
-					}
90
-					else if($action=='add_free_text') {
94
+					} else if($action=='add_free_text') {
91 95
 						$title = GETPOST('title');
92 96
 
93 97
 						if (empty($title)) {
@@ -99,29 +103,31 @@  discard block
 block discarded – undo
99 103
 								}
100 104
 							}
101 105
 						}
102
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
106
+						if(empty($title)) {
107
+							$title = $langs->trans('subtotalAddLineDescription');
108
+						}
103 109
 						$qty = 50;
104
-					}
105
-					else if($action=='add_subtitle_line') {
110
+					} else if($action=='add_subtitle_line') {
106 111
 						$title = GETPOST('title');
107
-						if(empty($title)) $title = $langs->trans('subtitle');
112
+						if(empty($title)) {
113
+							$title = $langs->trans('subtitle');
114
+						}
108 115
 						$qty = 2;
109
-					}
110
-					else if($action=='add_subtotal_line') {
116
+					} else if($action=='add_subtotal_line') {
111 117
 						$title = $langs->trans('SubSubTotal');
112 118
 						$qty = 98;
113
-					}
114
-					else {
119
+					} else {
115 120
 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
116 121
 						$qty = $level ? 100-$level : 99;
117 122
 					}
118 123
 					dol_include_once('/subtotal/class/subtotal.class.php');
119 124
 					
120
-					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
125
+					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) {
126
+						TSubtotal::addSubtotalMissing($object, $qty);
127
+					}
121 128
 					
122 129
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
123
-				}
124
-				else if($action==='ask_deleteallline') {
130
+				} else if($action==='ask_deleteallline') {
125 131
 						$form=new Form($db);
126 132
 						
127 133
 						$lineid = GETPOST('lineid','integer');
@@ -144,8 +150,7 @@  discard block
 block discarded – undo
144 150
 					$this->printNewFormat($object, $conf, $langs, $idvar);
145 151
 				}
146 152
 			}
147
-		}
148
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
153
+		} elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
149 154
 		{
150 155
 			?>
151 156
 			<script type="text/javascript">
@@ -163,8 +168,13 @@  discard block
 block discarded – undo
163 168
      
164 169
 	function printNewFormat(&$object, &$conf, &$langs, $idvar)
165 170
 	{
166
-		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) return false;
167
-		if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) return false; // Si facture de situation
171
+		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) {
172
+			return false;
173
+		}
174
+		if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) {
175
+			return false;
176
+		}
177
+		// Si facture de situation
168 178
 		?>
169 179
 		 	<script type="text/javascript">
170 180
 				$(document).ready(function() {
@@ -450,8 +460,7 @@  discard block
 block discarded – undo
450 460
 				}
451 461
 				
452 462
 				
453
-			}	
454
-			else{
463
+			} else{
455 464
 				$substitutionarray['line_not_modsubtotal'] = true;
456 465
 				$substitutionarray['line_modsubtotal'] = 0;
457 466
 			}
@@ -509,8 +518,11 @@  discard block
 block discarded – undo
509 518
 		
510 519
 		$showBlockExtrafields = GETPOST('showBlockExtrafields');
511 520
 		
512
-		if($object->element=='facture') $idvar = 'facid';
513
-		else $idvar = 'id';
521
+		if($object->element=='facture') {
522
+			$idvar = 'facid';
523
+		} else {
524
+			$idvar = 'id';
525
+		}
514 526
 			
515 527
 		if ($action == 'updateligne' || $action == 'updateline')
516 528
 		{
@@ -540,8 +552,7 @@  discard block
 block discarded – undo
540 552
 				header('Location: '.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id);
541 553
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
542 554
 			}
543
-		}
544
-		else if($action === 'builddoc') {
555
+		} else if($action === 'builddoc') {
545 556
 			
546 557
 			if (
547 558
 				in_array('invoicecard',explode(':',$parameters['context']))
@@ -556,33 +567,27 @@  discard block
 block discarded – undo
556 567
 					$sessname = 'subtotal_hideInnerLines_facture';	
557 568
 					$sessname2 = 'subtotal_hidedetails_facture';
558 569
 					$sessname3 = 'subtotal_hideprices_facture';
559
-				}
560
-				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
570
+				} elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
561 571
 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
562 572
 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
563 573
 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
564
-				}
565
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
574
+				} elseif(in_array('propalcard',explode(':',$parameters['context']))) {
566 575
 					$sessname = 'subtotal_hideInnerLines_propal';
567 576
 					$sessname2 = 'subtotal_hidedetails_propal';	
568 577
 					$sessname3 = 'subtotal_hideprices_propal';
569
-				}
570
-				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
578
+				} elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
571 579
 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
572 580
 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
573 581
 				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
574
-				}
575
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
582
+				} elseif(in_array('ordercard',explode(':',$parameters['context']))) {
576 583
 					$sessname = 'subtotal_hideInnerLines_commande';
577 584
 					$sessname2 = 'subtotal_hidedetails_commande';	
578 585
 					$sessname3 = 'subtotal_hideprices_commande';
579
-				}
580
-				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
586
+				} elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
581 587
 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
582 588
 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
583 589
 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
584
-				}
585
-				else {
590
+				} else {
586 591
 					$sessname = 'subtotal_hideInnerLines_unknown';
587 592
 					$sessname2 = 'subtotal_hidedetails_unknown';
588 593
 					$sessname3 = 'subtotal_hideprices_unknown';
@@ -604,8 +609,7 @@  discard block
 block discarded – undo
604 609
 					    
605 610
                         if($line->qty>=90) {
606 611
                             $line->modsubtotal_total = 1;
607
-                        }
608
-                        else{
612
+                        } else{
609 613
                             $line->modsubtotal_title = 1;
610 614
                         }
611 615
                         
@@ -614,8 +618,7 @@  discard block
 block discarded – undo
614 618
 	        	}
615 619
 	        }
616 620
 			
617
-		}
618
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
621
+		} else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
619 622
 			
620 623
 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
621 624
 			
@@ -623,7 +626,9 @@  discard block
 block discarded – undo
623 626
 				/**
624 627
 				 * @var $object Facture
625 628
 				 */
626
-				if($object->element=='facture') $object->deleteline($idLine);
629
+				if($object->element=='facture') {
630
+					$object->deleteline($idLine);
631
+				}
627 632
 				/**
628 633
 				 * @var $object Facture fournisseur
629 634
 				 */
@@ -634,18 +639,25 @@  discard block
 block discarded – undo
634 639
 				/**
635 640
 				 * @var $object Propal
636 641
 				 */
637
-				else if($object->element=='propal') $object->deleteline($idLine);
642
+				else if($object->element=='propal') {
643
+					$object->deleteline($idLine);
644
+				}
638 645
 				/**
639 646
 				 * @var $object Propal Fournisseur
640 647
 				 */
641
-				else if($object->element=='supplier_proposal') $object->deleteline($idLine);
648
+				else if($object->element=='supplier_proposal') {
649
+					$object->deleteline($idLine);
650
+				}
642 651
 				/**
643 652
 				 * @var $object Commande
644 653
 				 */
645 654
 				else if($object->element=='commande') 
646 655
 				{
647
-					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
648
-					else $object->deleteline($idLine);
656
+					if ((float) DOL_VERSION >= 5.0) {
657
+						$object->deleteline($user, $idLine);
658
+					} else {
659
+						$object->deleteline($idLine);
660
+					}
649 661
 				}
650 662
 				/**
651 663
 				 * @var $object Commande fournisseur
@@ -657,21 +669,26 @@  discard block
 block discarded – undo
657 669
 				/**
658 670
 				 * @var $object Facturerec
659 671
 				 */
660
-				else if($object->element=='facturerec') $object->deleteline($idLine);
672
+				else if($object->element=='facturerec') {
673
+					$object->deleteline($idLine);
674
+				}
661 675
 			}
662 676
 			
663 677
 			header('location:?id='.$object->id);
664 678
 			exit;
665 679
 			
666
-		}
667
-		else if ($action == 'duplicate')
680
+		} else if ($action == 'duplicate')
668 681
 		{
669 682
 			$lineid = GETPOST('lineid', 'int');
670 683
 			$nbDuplicate = TSubtotal::duplicateLines($object, $lineid, true);
671 684
 			
672
-			if ($nbDuplicate > 0) setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
673
-			elseif ($nbDuplicate == 0) setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
674
-			else setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
685
+			if ($nbDuplicate > 0) {
686
+				setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
687
+			} elseif ($nbDuplicate == 0) {
688
+				setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
689
+			} else {
690
+				setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
691
+			}
675 692
 			
676 693
 			header('Location: ?id='.$object->id);
677 694
 			exit;
@@ -751,17 +768,18 @@  discard block
 block discarded – undo
751 768
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
752 769
 			if($l->rang>=$rang) {
753 770
 				//echo 'return!<br>';
754
-				if (!$return_all) return $total;
755
-				else return array($total, $total_tva, $total_ttc, $TTotal_tva);
756
-			}
757
-			else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
771
+				if (!$return_all) {
772
+					return $total;
773
+				} else {
774
+					return array($total, $total_tva, $total_ttc, $TTotal_tva);
775
+				}
776
+			} else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
758 777
 		  	{
759 778
 				$total = 0;
760 779
 				$total_tva = 0;
761 780
 				$total_ttc = 0;
762 781
 				$TTotal_tva = array();
763
-			}
764
-			elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
782
+			} elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
765 783
 				$total += $l->total_ht;
766 784
 				$total_tva += $l->total_tva;
767 785
 				$TTotal_tva[$l->tva_tx] += $l->total_tva;
@@ -769,8 +787,11 @@  discard block
 block discarded – undo
769 787
 			}
770 788
 			
771 789
 		}
772
-		if (!$return_all) return $total;
773
-		else return array($total, $total_tva, $total_ttc, $TTotal_tva);
790
+		if (!$return_all) {
791
+			return $total;
792
+		} else {
793
+			return array($total, $total_tva, $total_ttc, $TTotal_tva);
794
+		}
774 795
 	}
775 796
 
776 797
 	/*
@@ -838,15 +859,18 @@  discard block
 block discarded – undo
838 859
 		}
839 860
 		
840 861
 			
841
-		if($line->qty==99)
842
-			$pdf->SetFillColor(220,220,220);
843
-		elseif ($line->qty==98)
844
-			$pdf->SetFillColor(230,230,230);
845
-		else
846
-			$pdf->SetFillColor(240,240,240);
862
+		if($line->qty==99) {
863
+					$pdf->SetFillColor(220,220,220);
864
+		} elseif ($line->qty==98) {
865
+					$pdf->SetFillColor(230,230,230);
866
+		} else {
867
+					$pdf->SetFillColor(240,240,240);
868
+		}
847 869
 		
848 870
 		$style = 'B';
849
-		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
871
+		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) {
872
+			$style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
873
+		}
850 874
 		
851 875
 		$pdf->SetFont('', $style, 9);
852 876
 		
@@ -885,8 +909,7 @@  discard block
 block discarded – undo
885 909
 //					$line->total_tva
886 910
 //					$line->total
887 911
 //					$line->total_ttc
888
-				}
889
-				else
912
+				} else
890 913
 				{
891 914
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
892 915
                                         if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
@@ -903,11 +926,14 @@  discard block
 block discarded – undo
903 926
 			}
904 927
 
905 928
 			$pdf->SetXY($pdf->postotalht, $posy);
906
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
929
+			if($set_pagebreak_margin) {
930
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
931
+			}
907 932
 			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
908
-		}
909
-		else{
910
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
933
+		} else{
934
+			if($set_pagebreak_margin) {
935
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
936
+			}
911 937
 		}
912 938
 		
913 939
 		$posy = $posy + $cell_height;
@@ -939,25 +965,40 @@  discard block
 block discarded – undo
939 965
 		
940 966
  
941 967
 		$style = ($line->qty==1) ? 'BU' : 'BUI';
942
-		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
968
+		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) {
969
+			$style = $conf->global->SUBTOTAL_TITLE_STYLE;
970
+		}
943 971
 		
944 972
 		if($hideInnerLines) {
945
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
946
-			else 
973
+			if($line->qty==1) {
974
+				$pdf->SetFont('', $style, 9);
975
+			} else 
947 976
 			{
948
-				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
977
+				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) {
978
+					$style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
979
+				}
949 980
 				$pdf->SetFont('', $style, 9);
950 981
 			}
951
-		}
952
-		else {
982
+		} else {
953 983
 
954
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
955
-			else $pdf->SetFont('', $style, 9);
984
+			if($line->qty==1) {
985
+				$pdf->SetFont('', $style, 9);
986
+			}
987
+			//TODO if super utile
988
+			else {
989
+				$pdf->SetFont('', $style, 9);
990
+			}
956 991
 			
957 992
 		}
958 993
 		
959
-		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
960
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
994
+		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) {
995
+			$pdf->MultiCell($w, $h, $label, 0, 'L');
996
+		}
997
+		// Pas de HTML dans la chaine
998
+		else {
999
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true);
1000
+		}
1001
+		// et maintenant avec du HTML
961 1002
 		
962 1003
 		if($description && !$hidedesc) {
963 1004
 			$posy = $pdf->GetY();
@@ -981,8 +1022,7 @@  discard block
 block discarded – undo
981 1022
 		
982 1023
 		if(is_array($parameters)) {
983 1024
 			$i = & $parameters['i'];	
984
-		}
985
-		else {
1025
+		} else {
986 1026
 			$i = (int)$parameters;
987 1027
 		}
988 1028
 		
@@ -1004,17 +1044,14 @@  discard block
 block discarded – undo
1004 1044
 			
1005 1045
 			if((float)DOL_VERSION<=3.6) {
1006 1046
 				return '';
1007
-			}
1008
-			else if((float)DOL_VERSION>=3.8) {
1047
+			} else if((float)DOL_VERSION>=3.8) {
1009 1048
 				return 1;
1010 1049
 			}
1011 1050
 			
1012
-		}
1013
-		elseif(!empty($hideprices)) {
1051
+		} elseif(!empty($hideprices)) {
1014 1052
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1015 1053
 			return 1;
1016
-		}
1017
-		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1054
+		} elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1018 1055
 		{
1019 1056
 			$hideInnerLines = (int)GETPOST('hideInnerLines');
1020 1057
 			$hidedetails = (int)GETPOST('hidedetails');
@@ -1024,12 +1061,20 @@  discard block
 block discarded – undo
1024 1061
 			}
1025 1062
 		}
1026 1063
 		
1027
-		if(is_array($parameters)) $i = & $parameters['i'];
1028
-		else $i = (int)$parameters;
1064
+		if(is_array($parameters)) {
1065
+			$i = & $parameters['i'];
1066
+		} else {
1067
+			$i = (int)$parameters;
1068
+		}
1029 1069
 
1030
-		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)
1070
+		if (empty($object->lines[$i])) {
1071
+			return 0;
1072
+		}
1073
+		// 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)
1031 1074
 		
1032
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1075
+		if(empty($object->lines[$i]->array_options)) {
1076
+			$object->lines[$i]->fetch_optionals();
1077
+		}
1033 1078
 
1034 1079
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1035 1080
 		{
@@ -1052,16 +1097,17 @@  discard block
 block discarded – undo
1052 1097
 			
1053 1098
 			if((float)DOL_VERSION<=3.6) {
1054 1099
 				return '';
1055
-			}
1056
-			else if((float)DOL_VERSION>=3.8) {
1100
+			} else if((float)DOL_VERSION>=3.8) {
1057 1101
 				return 1;
1058 1102
 			}
1059 1103
 			
1060
-		}
1061
-		elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1104
+		} elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1062 1105
 		{
1063
-			if(is_array($parameters)) $i = & $parameters['i'];
1064
-			else $i = (int)$parameters;
1106
+			if(is_array($parameters)) {
1107
+				$i = & $parameters['i'];
1108
+			} else {
1109
+				$i = (int)$parameters;
1110
+			}
1065 1111
 			
1066 1112
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1067 1113
 			{
@@ -1083,8 +1129,11 @@  discard block
 block discarded – undo
1083 1129
 			}
1084 1130
 		}
1085 1131
 		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1086
-		    if(is_array($parameters)) $i = & $parameters['i'];
1087
-		    else $i = (int)$parameters;
1132
+		    if(is_array($parameters)) {
1133
+		    	$i = & $parameters['i'];
1134
+		    } else {
1135
+		    	$i = (int)$parameters;
1136
+		    }
1088 1137
 		    $this->resprints = price($object->lines[$i]->total_ht);
1089 1138
 		}
1090 1139
 		if (!empty($hideprices)
@@ -1094,8 +1143,11 @@  discard block
 block discarded – undo
1094 1143
 		    if (!empty($hideprices))
1095 1144
 		    {
1096 1145
 		        
1097
-		        if(is_array($parameters)) $i = & $parameters['i'];
1098
-		        else $i = (int)$parameters;
1146
+		        if(is_array($parameters)) {
1147
+		        	$i = & $parameters['i'];
1148
+		        } else {
1149
+		        	$i = (int)$parameters;
1150
+		        }
1099 1151
 		        
1100 1152
 		        // Check if a title exist for this line && if the title have subtotal
1101 1153
 		        $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
@@ -1104,8 +1156,7 @@  discard block
 block discarded – undo
1104 1156
 		            $this->resprints = ' ';
1105 1157
 		            return 1;
1106 1158
 		        }
1107
-		    }
1108
-		    elseif (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1159
+		    } elseif (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1109 1160
 		    {
1110 1161
 		        $this->resprints = ' ';
1111 1162
 		        return 1;
@@ -1124,14 +1175,16 @@  discard block
 block discarded – undo
1124 1175
 		
1125 1176
 			if((float)DOL_VERSION<=3.6) {
1126 1177
 				return '';
1127
-			}
1128
-			else if((float)DOL_VERSION>=3.8) {
1178
+			} else if((float)DOL_VERSION>=3.8) {
1129 1179
 				return 1;
1130 1180
 			}
1131 1181
 		}
1132 1182
 		
1133
-		if(is_array($parameters)) $i = & $parameters['i'];
1134
-		else $i = (int)$parameters;
1183
+		if(is_array($parameters)) {
1184
+			$i = & $parameters['i'];
1185
+		} else {
1186
+			$i = (int)$parameters;
1187
+		}
1135 1188
 		
1136 1189
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1137 1190
 		{
@@ -1153,14 +1206,16 @@  discard block
 block discarded – undo
1153 1206
 		
1154 1207
 			if((float)DOL_VERSION<=3.6) {
1155 1208
 				return '';
1156
-			}
1157
-			else if((float)DOL_VERSION>=3.8) {
1209
+			} else if((float)DOL_VERSION>=3.8) {
1158 1210
 				return 1;
1159 1211
 			}
1160 1212
 		}
1161 1213
 		
1162
-		if(is_array($parameters)) $i = & $parameters['i'];
1163
-		else $i = (int)$parameters;
1214
+		if(is_array($parameters)) {
1215
+			$i = & $parameters['i'];
1216
+		} else {
1217
+			$i = (int)$parameters;
1218
+		}
1164 1219
 			
1165 1220
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1166 1221
 		{
@@ -1182,13 +1237,15 @@  discard block
 block discarded – undo
1182 1237
 		
1183 1238
 			if((float)DOL_VERSION<=3.6) {
1184 1239
 				return '';
1185
-			}
1186
-			else if((float)DOL_VERSION>=3.8) {
1240
+			} else if((float)DOL_VERSION>=3.8) {
1187 1241
 				return 1;
1188 1242
 			}
1189 1243
 		}
1190
-		if(is_array($parameters)) $i = & $parameters['i'];
1191
-		else $i = (int)$parameters;
1244
+		if(is_array($parameters)) {
1245
+			$i = & $parameters['i'];
1246
+		} else {
1247
+			$i = (int)$parameters;
1248
+		}
1192 1249
 		
1193 1250
 		if (!empty($hideprices) 
1194 1251
 				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
@@ -1211,14 +1268,16 @@  discard block
 block discarded – undo
1211 1268
 			$this->resprints = ' ';
1212 1269
 			if((float)DOL_VERSION<=3.6) {
1213 1270
 				return '';
1214
-			}
1215
-			else if((float)DOL_VERSION>=3.8) {
1271
+			} else if((float)DOL_VERSION>=3.8) {
1216 1272
 				return 1;
1217 1273
 			}
1218 1274
 		}
1219 1275
 		
1220
-		if(is_array($parameters)) $i = & $parameters['i'];
1221
-		else $i = (int)$parameters;
1276
+		if(is_array($parameters)) {
1277
+			$i = & $parameters['i'];
1278
+		} else {
1279
+			$i = (int)$parameters;
1280
+		}
1222 1281
 			
1223 1282
 		if (!empty($hideprices)
1224 1283
 				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
@@ -1242,16 +1301,21 @@  discard block
 block discarded – undo
1242 1301
 			
1243 1302
 			if((float)DOL_VERSION<=3.6) {
1244 1303
 				return '';
1245
-			}
1246
-			else if((float)DOL_VERSION>=3.8) {
1304
+			} else if((float)DOL_VERSION>=3.8) {
1247 1305
 				return 1;
1248 1306
 			}
1249 1307
 		}
1250 1308
 		
1251
-		if(is_array($parameters)) $i = & $parameters['i'];
1252
-		else $i = (int)$parameters;
1309
+		if(is_array($parameters)) {
1310
+			$i = & $parameters['i'];
1311
+		} else {
1312
+			$i = (int)$parameters;
1313
+		}
1253 1314
 		
1254
-		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)
1315
+		if (empty($object->lines[$i])) {
1316
+			return 0;
1317
+		}
1318
+		// 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)
1255 1319
 
1256 1320
 		$object->lines[$i]->fetch_optionals();
1257 1321
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
@@ -1273,14 +1337,16 @@  discard block
 block discarded – undo
1273 1337
 			$this->resprints = ' ';
1274 1338
 			if((float)DOL_VERSION<=3.6) {
1275 1339
 				return '';
1276
-			}
1277
-			else if((float)DOL_VERSION>=3.8) {
1340
+			} else if((float)DOL_VERSION>=3.8) {
1278 1341
 				return 1;
1279 1342
 			}
1280 1343
 		}
1281 1344
 		
1282
-		if(is_array($parameters)) $i = & $parameters['i'];
1283
-		else $i = (int)$parameters;
1345
+		if(is_array($parameters)) {
1346
+			$i = & $parameters['i'];
1347
+		} else {
1348
+			$i = (int)$parameters;
1349
+		}
1284 1350
 			
1285 1351
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1286 1352
 		{
@@ -1310,7 +1376,9 @@  discard block
 block discarded – undo
1310 1376
 				}
1311 1377
 			}
1312 1378
 			
1313
-			if (!empty($TLineTitle)) $TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1379
+			if (!empty($TLineTitle)) {
1380
+				$TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1381
+			}
1314 1382
 		}
1315 1383
 		
1316 1384
 	}
@@ -1324,8 +1392,12 @@  discard block
 block discarded – undo
1324 1392
 		$j=0;
1325 1393
 		foreach ($TLineTitle as $k => &$line)
1326 1394
 		{
1327
-			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
1328
-			if (!empty($line_reference) && $line->qty <= $line_reference->qty) break;
1395
+			if (!empty($line_reference) && $line->rang <= $line_reference->rang) {
1396
+				continue;
1397
+			}
1398
+			if (!empty($line_reference) && $line->qty <= $line_reference->qty) {
1399
+				break;
1400
+			}
1329 1401
 			
1330 1402
 			if ($line->qty == $level)
1331 1403
 			{
@@ -1359,7 +1431,9 @@  discard block
 block discarded – undo
1359 1431
 		
1360 1432
 		$hidedetails = (int)GETPOST('hidedetails');
1361 1433
 		
1362
-		if(empty($hidedetails)) return false;
1434
+		if(empty($hidedetails)) {
1435
+			return false;
1436
+		}
1363 1437
 		
1364 1438
 		// TODO can't add VAT to document without lines... :-/
1365 1439
 		
@@ -1412,7 +1486,9 @@  discard block
 block discarded – undo
1412 1486
 						*/
1413 1487
 						list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
1414 1488
 						
1415
-						if (TSubtotal::getNiveau($line) == 1) $line->TTotal_tva = $TTotal_tva;
1489
+						if (TSubtotal::getNiveau($line) == 1) {
1490
+							$line->TTotal_tva = $TTotal_tva;
1491
+						}
1416 1492
 						$line->total_ht = $total;
1417 1493
 						$line->total_tva = $total_tva;
1418 1494
 						$line->total = $line->total_ht;
@@ -1467,8 +1543,7 @@  discard block
 block discarded – undo
1467 1543
 				    }
1468 1544
 				    
1469 1545
 					
1470
-				}
1471
-				elseif ($hidedetails)
1546
+				} elseif ($hidedetails)
1472 1547
 				{
1473 1548
 					$TLines[] = $line; //Cas où je cache uniquement les prix des produits	
1474 1549
 				}
@@ -1539,7 +1614,9 @@  discard block
 block discarded – undo
1539 1614
 				
1540 1615
 				if(!empty($hideprices)) {
1541 1616
 					foreach($object->lines as &$line) {
1542
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1617
+						if($line->fk_product_type!=9) {
1618
+							$line->fk_parent_line = -1;
1619
+						}
1543 1620
 					}
1544 1621
 				}
1545 1622
 			
@@ -1560,7 +1637,9 @@  discard block
 block discarded – undo
1560 1637
 				
1561 1638
 				if($line->qty>90) {
1562 1639
 					
1563
-					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1640
+					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) {
1641
+						$label .= ' '.$this->getTitle($object, $line);
1642
+					}
1564 1643
 					
1565 1644
 					$pageBefore = $pdf->getPage();
1566 1645
 					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
@@ -1578,8 +1657,7 @@  discard block
 block discarded – undo
1578 1657
 				
1579 1658
 					$posy = $pdf->GetY();
1580 1659
 					return 1;
1581
-				}	
1582
-				else if ($line->qty < 10) {
1660
+				} else if ($line->qty < 10) {
1583 1661
 					$pageBefore = $pdf->getPage();
1584 1662
 
1585 1663
 					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
@@ -1603,8 +1681,7 @@  discard block
 block discarded – undo
1603 1681
 //	if($line->rowid==47) exit;
1604 1682
 			
1605 1683
 			return 0;
1606
-		}
1607
-		elseif (empty($object->lines[$parameters['i']]))
1684
+		} elseif (empty($object->lines[$parameters['i']]))
1608 1685
 		{
1609 1686
 			$this->resprints = -1;
1610 1687
 		}
@@ -1637,7 +1714,9 @@  discard block
 block discarded – undo
1637 1714
 		
1638 1715
 		foreach ($object->lines as $line)
1639 1716
 		{
1640
-			if ($line->id == $currentLine->id) break;
1717
+			if ($line->id == $currentLine->id) {
1718
+				break;
1719
+			}
1641 1720
 			
1642 1721
 			$qty_search = 100 - $currentLine->qty;
1643 1722
 			
@@ -1674,23 +1753,23 @@  discard block
 block discarded – undo
1674 1753
 		{
1675 1754
 			$object->statut = 0; // hack for facture rec
1676 1755
 			$createRight = $user->rights->facture->creer;
1677
-		}
1678
-		elseif($object->element == 'order_supplier' )
1756
+		} elseif($object->element == 'order_supplier' )
1679 1757
 		{
1680 1758
 		    $createRight = $user->rights->fournisseur->commande->creer;
1681
-		}
1682
-		elseif($object->element == 'invoice_supplier' )
1759
+		} elseif($object->element == 'invoice_supplier' )
1683 1760
 		{
1684 1761
 		    $createRight = $user->rights->fournisseur->facture->creer;
1685 1762
 		}
1686 1763
 		
1687 1764
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1688 1765
 			null;
1689
-		}	
1690
-		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)) 
1766
+		} 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)) 
1691 1767
         {
1692
-			if($object->element=='facture')$idvar = 'facid';
1693
-			else $idvar='id';
1768
+			if($object->element=='facture') {
1769
+				$idvar = 'facid';
1770
+			} else {
1771
+				$idvar='id';
1772
+			}
1694 1773
 			
1695 1774
 			if((float)DOL_VERSION <= 3.4)
1696 1775
 			{
@@ -1716,20 +1795,44 @@  discard block
 block discarded – undo
1716 1795
 				<?php
1717 1796
 			}
1718 1797
 			
1719
-			if(empty($line->description)) $line->description = $line->desc;
1798
+			if(empty($line->description)) {
1799
+				$line->description = $line->desc;
1800
+			}
1720 1801
 			
1721 1802
 			$colspan = 5;
1722
-			if($object->element == 'facturerec' ) $colspan = 3;
1723
-			if($object->element == 'order_supplier') $colspan = 3;
1724
-			if($object->element == 'invoice_supplier') $colspan = 4;
1725
-			if($object->element == 'supplier_proposal') $colspan = 4;
1726
-			if(!empty($conf->multicurrency->enabled)) $colspan+=2;
1727
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1728
-			if(!empty($conf->margin->enabled)) $colspan++;
1729
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1730
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1731
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1732
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
1803
+			if($object->element == 'facturerec' ) {
1804
+				$colspan = 3;
1805
+			}
1806
+			if($object->element == 'order_supplier') {
1807
+				$colspan = 3;
1808
+			}
1809
+			if($object->element == 'invoice_supplier') {
1810
+				$colspan = 4;
1811
+			}
1812
+			if($object->element == 'supplier_proposal') {
1813
+				$colspan = 4;
1814
+			}
1815
+			if(!empty($conf->multicurrency->enabled)) {
1816
+				$colspan+=2;
1817
+			}
1818
+			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) {
1819
+				$colspan++;
1820
+			}
1821
+			if(!empty($conf->margin->enabled)) {
1822
+				$colspan++;
1823
+			}
1824
+			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) {
1825
+				$colspan++;
1826
+			}
1827
+			if(!empty($conf->global->DISPLAY_MARK_RATES)) {
1828
+				$colspan++;
1829
+			}
1830
+			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) {
1831
+				$colspan++;
1832
+			}
1833
+			if(!empty($conf->global->PRODUCT_USE_UNITS)) {
1834
+				$colspan++;
1835
+			}
1733 1836
 					
1734 1837
 			/* Titre */
1735 1838
 			//var_dump($line);
@@ -1742,23 +1845,36 @@  discard block
 block discarded – undo
1742 1845
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
1743 1846
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
1744 1847
 					{
1745
-						if($line->qty==99) print 'background:#adadcf';
1746
-						else if($line->qty==98) print 'background:#ddddff;';
1747
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
1748
-						else if($line->qty==1) print 'background:#adadcf;';
1749
-						else if($line->qty==2) print 'background:#ddddff;';
1750
-						else if($line->qty==50) print '';
1751
-						else print 'background:#eeeeff;';
1848
+						if($line->qty==99) {
1849
+							print 'background:#adadcf';
1850
+						} else if($line->qty==98) {
1851
+							print 'background:#ddddff;';
1852
+						} else if($line->qty<=97 && $line->qty>=91) {
1853
+							print 'background:#eeeeff;';
1854
+						} else if($line->qty==1) {
1855
+							print 'background:#adadcf;';
1856
+						} else if($line->qty==2) {
1857
+							print 'background:#ddddff;';
1858
+						} else if($line->qty==50) {
1859
+							print '';
1860
+						} else {
1861
+							print 'background:#eeeeff;';
1862
+						}
1752 1863
 
1753 1864
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
1754
-					}
1755
-					else 
1865
+					} else 
1756 1866
 					{
1757
-						if($line->qty==99) print 'background:#ddffdd';
1758
-						else if($line->qty==98) print 'background:#ddddff;';
1759
-						else if($line->qty==2) print 'background:#eeeeff; ';
1760
-						else if($line->qty==50) print '';
1761
-						else print 'background:#eeffee;' ;
1867
+						if($line->qty==99) {
1868
+							print 'background:#ddffdd';
1869
+						} else if($line->qty==98) {
1870
+							print 'background:#ddddff;';
1871
+						} else if($line->qty==2) {
1872
+							print 'background:#eeeeff; ';
1873
+						} else if($line->qty==50) {
1874
+							print '';
1875
+						} else {
1876
+							print 'background:#eeffee;' ;
1877
+						}
1762 1878
 					}
1763 1879
 
1764 1880
 			?>;">
@@ -1781,13 +1897,11 @@  discard block
 block discarded – undo
1781 1897
 							$qty_displayed = $line->qty;
1782 1898
 							print img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
1783 1899
 							
1784
-						}
1785
-						else if (TSubtotal::isSubtotal($line))
1900
+						} else if (TSubtotal::isSubtotal($line))
1786 1901
 						{
1787 1902
 							$qty_displayed = 100 - $line->qty;
1788 1903
 							print img_picto('', 'subsubtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
1789
-						}
1790
-						else
1904
+						} else
1791 1905
 						{
1792 1906
 							$isFreeText = true;
1793 1907
 						}
@@ -1808,9 +1922,13 @@  discard block
 block discarded – undo
1808 1922
 						}
1809 1923
 
1810 1924
 						$readonlyForSituation = '';
1811
-						if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) $readonlyForSituation = 'readonly';
1925
+						if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) {
1926
+							$readonlyForSituation = 'readonly';
1927
+						}
1812 1928
 						
1813
-						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
1929
+						if (!$isFreeText) {
1930
+							echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
1931
+						}
1814 1932
 						
1815 1933
 						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
1816 1934
 						{
@@ -1818,8 +1936,12 @@  discard block
 block discarded – undo
1818 1936
 							for ($j=1; $j<10; $j++)
1819 1937
 							{
1820 1938
 								if (!empty($readonlyForSituation)) {
1821
-									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
1822
-								} else $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
1939
+									if ($qty_displayed == $j) {
1940
+										$select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
1941
+									}
1942
+								} else {
1943
+									$select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
1944
+								}
1823 1945
 							}
1824 1946
 							$select .= '</select>&nbsp;';
1825 1947
 
@@ -1835,15 +1957,18 @@  discard block
 block discarded – undo
1835 1957
 								$form = new Form($db);
1836 1958
 								echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
1837 1959
 								echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
1838
-								if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
1960
+								if (empty($readonlyForSituation)) {
1961
+									echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
1962
+								}
1839 1963
 								echo '</select>&nbsp;&nbsp;';
1840 1964
 								
1841 1965
 								if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
1842 1966
 								{
1843 1967
 									echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%';
1844 1968
 								}
1969
+							} else if ($isFreeText) {
1970
+								echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
1845 1971
 							}
1846
-							else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
1847 1972
 						echo '</div>';
1848 1973
 
1849 1974
 						if($line->qty<10) {
@@ -1863,8 +1988,7 @@  discard block
 block discarded – undo
1863 1988
 							$doleditor->Create();
1864 1989
 						}
1865 1990
 						
1866
-					}
1867
-					else {
1991
+					} else {
1868 1992
 
1869 1993
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
1870 1994
 						 {
@@ -1872,14 +1996,19 @@  discard block
 block discarded – undo
1872 1996
 							{
1873 1997
 								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
1874 1998
 								
1875
-								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
1876
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
1999
+								if (TSubtotal::isTitle($line)) {
2000
+									print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2001
+								} else {
2002
+									print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2003
+								}
1877 2004
 							}
1878
-						 }
1879
-						 else 
2005
+						 } else 
1880 2006
 						 {
1881
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
1882
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2007
+							if($line->qty<=1) {
2008
+								print img_picto('', 'subtotal@subtotal');
2009
+							} else if($line->qty==2) {
2010
+								print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2011
+							}
1883 2012
 						 }
1884 2013
 						 
1885 2014
 						 
@@ -1889,21 +2018,26 @@  discard block
 block discarded – undo
1889 2018
 						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
1890 2019
 						 
1891 2020
 						 if (empty($line->label)) {
1892
-							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
1893
-							else print  $line->description;
1894
-						 } 
1895
-						 else {
2021
+							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2022
+								print  $line->description.' '.$this->getTitle($object, $line);
2023
+							} else {
2024
+								print  $line->description;
2025
+							}
2026
+						 } else {
1896 2027
 
1897 2028
 							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
1898 2029
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
1899
-							}
1900
-							else{
2030
+							} else{
1901 2031
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
1902 2032
 							}
1903 2033
 
1904 2034
 						 } 
1905
-						if($line->qty>90) print ' : ';
1906
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2035
+						if($line->qty>90) {
2036
+							print ' : ';
2037
+						}
2038
+						if($line->info_bits > 0) {
2039
+							echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2040
+						}
1907 2041
 
1908 2042
 						 
1909 2043
 
@@ -1940,11 +2074,12 @@  discard block
 block discarded – undo
1940 2074
 						</script>
1941 2075
 						<?php
1942 2076
 						
1943
-					}
1944
-					else{
2077
+					} else{
1945 2078
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
1946 2079
 						{
1947
-							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2080
+							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) {
2081
+								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2082
+							}
1948 2083
 						}
1949 2084
 
1950 2085
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
@@ -2013,7 +2148,9 @@  discard block
 block discarded – undo
2013 2148
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2014 2149
 				
2015 2150
 				$colspan+=3; $mode = 'view';
2016
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2151
+				if($action === 'editline' && $line->rowid == GETPOST('lineid')) {
2152
+					$mode = 'edit';
2153
+				}
2017 2154
 				
2018 2155
 				$ex_element = $line->element;
2019 2156
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
@@ -2195,10 +2332,9 @@  discard block
 block discarded – undo
2195 2332
 	    
2196 2333
 	    if(TSubtotal::isTitle($line)){
2197 2334
 	        $ThtmlData['data-issubtotal'] = 'title';
2198
-	    }elseif(TSubtotal::isSubtotal($line)){
2335
+	    } elseif(TSubtotal::isSubtotal($line)){
2199 2336
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2200
-	    }
2201
-	    else{
2337
+	    } else{
2202 2338
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2203 2339
 	    }
2204 2340
 	    
@@ -2208,7 +2344,9 @@  discard block
 block discarded – undo
2208 2344
 	    
2209 2345
 	    // hook 
2210 2346
 	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2211
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2347
+	    if ($reshook < 0) {
2348
+	    	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2349
+	    }
2212 2350
 	    if ($reshook>0)
2213 2351
 	    {
2214 2352
 	        $ThtmlData = $hookmanager->resArray;
Please login to merge, or discard this patch.