Completed
Push — master ( 458bae...eeda68 )
by
unknown
13s queued 11s
created
class/actions_subtotal.class.php 1 patch
Braces   +378 added lines, -232 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) return false; // Si facture de situation
227
+		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) {
228
+			return false;
229
+		}
230
+		if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) {
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 		}
@@ -835,17 +868,18 @@  discard block
 block discarded – undo
835 868
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
836 869
 			if($l->rang>=$rang) {
837 870
 				//echo 'return!<br>';
838
-				if (!$return_all) return $total;
839
-				else return array($total, $total_tva, $total_ttc, $TTotal_tva);
840
-			}
841
-			else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
871
+				if (!$return_all) {
872
+					return $total;
873
+				} else {
874
+					return array($total, $total_tva, $total_ttc, $TTotal_tva);
875
+				}
876
+			} else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
842 877
 		  	{
843 878
 				$total = 0;
844 879
 				$total_tva = 0;
845 880
 				$total_ttc = 0;
846 881
 				$TTotal_tva = array();
847
-			}
848
-			elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
882
+			} elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
849 883
 				$total += $l->total_ht;
850 884
 				$total_tva += $l->total_tva;
851 885
 				$TTotal_tva[$l->tva_tx] += $l->total_tva;
@@ -853,8 +887,11 @@  discard block
 block discarded – undo
853 887
 			}
854 888
 			
855 889
 		}
856
-		if (!$return_all) return $total;
857
-		else return array($total, $total_tva, $total_ttc, $TTotal_tva);
890
+		if (!$return_all) {
891
+			return $total;
892
+		} else {
893
+			return array($total, $total_tva, $total_ttc, $TTotal_tva);
894
+		}
858 895
 	}
859 896
 
860 897
 	/*
@@ -922,15 +959,18 @@  discard block
 block discarded – undo
922 959
 		}
923 960
 		
924 961
 			
925
-		if($line->qty==99)
926
-			$pdf->SetFillColor(220,220,220);
927
-		elseif ($line->qty==98)
928
-			$pdf->SetFillColor(230,230,230);
929
-		else
930
-			$pdf->SetFillColor(240,240,240);
962
+		if($line->qty==99) {
963
+					$pdf->SetFillColor(220,220,220);
964
+		} elseif ($line->qty==98) {
965
+					$pdf->SetFillColor(230,230,230);
966
+		} else {
967
+					$pdf->SetFillColor(240,240,240);
968
+		}
931 969
 		
932 970
 		$style = 'B';
933
-		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
971
+		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) {
972
+			$style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
973
+		}
934 974
 		
935 975
 		$pdf->SetFont('', $style, 9);
936 976
 		
@@ -969,8 +1009,7 @@  discard block
 block discarded – undo
969 1009
 //					$line->total_tva
970 1010
 //					$line->total
971 1011
 //					$line->total_ttc
972
-				}
973
-				else
1012
+				} else
974 1013
 				{
975 1014
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
976 1015
                                         if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
@@ -987,11 +1026,14 @@  discard block
 block discarded – undo
987 1026
 			}
988 1027
 
989 1028
 			$pdf->SetXY($pdf->postotalht, $posy);
990
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1029
+			if($set_pagebreak_margin) {
1030
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1031
+			}
991 1032
 			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
992
-		}
993
-		else{
994
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1033
+		} else{
1034
+			if($set_pagebreak_margin) {
1035
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1036
+			}
995 1037
 		}
996 1038
 		
997 1039
 		$posy = $posy + $cell_height;
@@ -1023,25 +1065,40 @@  discard block
 block discarded – undo
1023 1065
 		
1024 1066
  
1025 1067
 		$style = ($line->qty==1) ? 'BU' : 'BUI';
1026
-		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
1068
+		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) {
1069
+			$style = $conf->global->SUBTOTAL_TITLE_STYLE;
1070
+		}
1027 1071
 		
1028 1072
 		if($hideInnerLines) {
1029
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
1030
-			else 
1073
+			if($line->qty==1) {
1074
+				$pdf->SetFont('', $style, 9);
1075
+			} else 
1031 1076
 			{
1032
-				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
1077
+				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) {
1078
+					$style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
1079
+				}
1033 1080
 				$pdf->SetFont('', $style, 9);
1034 1081
 			}
1035
-		}
1036
-		else {
1082
+		} else {
1037 1083
 
1038
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
1039
-			else $pdf->SetFont('', $style, 9);
1084
+			if($line->qty==1) {
1085
+				$pdf->SetFont('', $style, 9);
1086
+			}
1087
+			//TODO if super utile
1088
+			else {
1089
+				$pdf->SetFont('', $style, 9);
1090
+			}
1040 1091
 			
1041 1092
 		}
1042 1093
 		
1043
-		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
1044
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
1094
+		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) {
1095
+			$pdf->MultiCell($w, $h, $label, 0, 'L');
1096
+		}
1097
+		// Pas de HTML dans la chaine
1098
+		else {
1099
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true);
1100
+		}
1101
+		// et maintenant avec du HTML
1045 1102
 		
1046 1103
 		if($description && !$hidedesc) {
1047 1104
 			$posy = $pdf->GetY();
@@ -1065,8 +1122,7 @@  discard block
 block discarded – undo
1065 1122
 		
1066 1123
 		if(is_array($parameters)) {
1067 1124
 			$i = & $parameters['i'];	
1068
-		}
1069
-		else {
1125
+		} else {
1070 1126
 			$i = (int)$parameters;
1071 1127
 		}
1072 1128
 		
@@ -1088,17 +1144,14 @@  discard block
 block discarded – undo
1088 1144
 			
1089 1145
 			if((float)DOL_VERSION<=3.6) {
1090 1146
 				return '';
1091
-			}
1092
-			else if((float)DOL_VERSION>=3.8) {
1147
+			} else if((float)DOL_VERSION>=3.8) {
1093 1148
 				return 1;
1094 1149
 			}
1095 1150
 			
1096
-		}
1097
-		elseif(!empty($hideprices)) {
1151
+		} elseif(!empty($hideprices)) {
1098 1152
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1099 1153
 			return 1;
1100
-		}
1101
-		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1154
+		} elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1102 1155
 		{
1103 1156
 			$hideInnerLines = (int)GETPOST('hideInnerLines');
1104 1157
 			$hidedetails = (int)GETPOST('hidedetails');
@@ -1108,12 +1161,20 @@  discard block
 block discarded – undo
1108 1161
 			}
1109 1162
 		}
1110 1163
 		
1111
-		if(is_array($parameters)) $i = & $parameters['i'];
1112
-		else $i = (int)$parameters;
1164
+		if(is_array($parameters)) {
1165
+			$i = & $parameters['i'];
1166
+		} else {
1167
+			$i = (int)$parameters;
1168
+		}
1113 1169
 
1114
-		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)
1170
+		if (empty($object->lines[$i])) {
1171
+			return 0;
1172
+		}
1173
+		// 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)
1115 1174
 		
1116
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1175
+		if(empty($object->lines[$i]->array_options)) {
1176
+			$object->lines[$i]->fetch_optionals();
1177
+		}
1117 1178
 
1118 1179
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1119 1180
 		{
@@ -1130,8 +1191,11 @@  discard block
 block discarded – undo
1130 1191
 	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1131 1192
 	    global $conf, $hideprices, $hookmanager;
1132 1193
 		
1133
-		if(is_array($parameters)) $i = & $parameters['i'];
1134
-		else $i = (int)$parameters;
1194
+		if(is_array($parameters)) {
1195
+			$i = & $parameters['i'];
1196
+		} else {
1197
+			$i = (int)$parameters;
1198
+		}
1135 1199
 			
1136 1200
 		if($this->isModSubtotalLine($parameters,$object) ){
1137 1201
 			
@@ -1139,13 +1203,11 @@  discard block
 block discarded – undo
1139 1203
 			
1140 1204
 			if((float)DOL_VERSION<=3.6) {
1141 1205
 				return '';
1142
-			}
1143
-			else if((float)DOL_VERSION>=3.8) {
1206
+			} else if((float)DOL_VERSION>=3.8) {
1144 1207
 				return 1;
1145 1208
 			}
1146 1209
 			
1147
-		}
1148
-		elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1210
+		} elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1149 1211
 		{
1150 1212
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1151 1213
 			{
@@ -1217,12 +1279,10 @@  discard block
 block discarded – undo
1217 1279
 			$this->error = $hookmanager->error;
1218 1280
 			$this->errors = $hookmanager->errors;
1219 1281
 			return -1;
1220
-		}
1221
-		elseif (empty($reshook))
1282
+		} elseif (empty($reshook))
1222 1283
 		{
1223 1284
 			$this->resprints .= $hookmanager->resprints;
1224
-		}
1225
-		else
1285
+		} else
1226 1286
 		{
1227 1287
 			$this->resprints = $hookmanager->resprints;
1228 1288
 
@@ -1245,14 +1305,16 @@  discard block
 block discarded – undo
1245 1305
 		
1246 1306
 			if((float)DOL_VERSION<=3.6) {
1247 1307
 				return '';
1248
-			}
1249
-			else if((float)DOL_VERSION>=3.8) {
1308
+			} else if((float)DOL_VERSION>=3.8) {
1250 1309
 				return 1;
1251 1310
 			}
1252 1311
 		}
1253 1312
 		
1254
-		if(is_array($parameters)) $i = & $parameters['i'];
1255
-		else $i = (int)$parameters;
1313
+		if(is_array($parameters)) {
1314
+			$i = & $parameters['i'];
1315
+		} else {
1316
+			$i = (int)$parameters;
1317
+		}
1256 1318
 		
1257 1319
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1258 1320
 		{
@@ -1274,14 +1336,16 @@  discard block
 block discarded – undo
1274 1336
 		
1275 1337
 			if((float)DOL_VERSION<=3.6) {
1276 1338
 				return '';
1277
-			}
1278
-			else if((float)DOL_VERSION>=3.8) {
1339
+			} else if((float)DOL_VERSION>=3.8) {
1279 1340
 				return 1;
1280 1341
 			}
1281 1342
 		}
1282 1343
 		
1283
-		if(is_array($parameters)) $i = & $parameters['i'];
1284
-		else $i = (int)$parameters;
1344
+		if(is_array($parameters)) {
1345
+			$i = & $parameters['i'];
1346
+		} else {
1347
+			$i = (int)$parameters;
1348
+		}
1285 1349
 			
1286 1350
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1287 1351
 		{
@@ -1298,8 +1362,11 @@  discard block
 block discarded – undo
1298 1362
 	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1299 1363
 	    global $conf,$hideprices,$hookmanager;
1300 1364
 
1301
-		if(is_array($parameters)) $i = & $parameters['i'];
1302
-		else $i = (int)$parameters;
1365
+		if(is_array($parameters)) {
1366
+			$i = & $parameters['i'];
1367
+		} else {
1368
+			$i = (int)$parameters;
1369
+		}
1303 1370
 
1304 1371
 		if($this->isModSubtotalLine($parameters,$object) ) {
1305 1372
 			$this->resprints = ' ';
@@ -1318,8 +1385,7 @@  discard block
 block discarded – undo
1318 1385
 		
1319 1386
 			if((float)DOL_VERSION<=3.6) {
1320 1387
 				return '';
1321
-			}
1322
-			else if((float)DOL_VERSION>=3.8) {
1388
+			} else if((float)DOL_VERSION>=3.8) {
1323 1389
 				return 1;
1324 1390
 			}
1325 1391
 		}
@@ -1364,8 +1430,11 @@  discard block
 block discarded – undo
1364 1430
 	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1365 1431
 	    global $conf,$hideprices,$hookmanager;
1366 1432
 
1367
-        if(is_array($parameters)) $i = & $parameters['i'];
1368
-        else $i = (int) $parameters;
1433
+        if(is_array($parameters)) {
1434
+        	$i = & $parameters['i'];
1435
+        } else {
1436
+        	$i = (int) $parameters;
1437
+        }
1369 1438
 
1370 1439
 		if($this->isModSubtotalLine($parameters,$object) ) {
1371 1440
 			$this->resprints = ' ';
@@ -1384,12 +1453,10 @@  discard block
 block discarded – undo
1384 1453
 		
1385 1454
 			if((float)DOL_VERSION<=3.6) {
1386 1455
 				return '';
1387
-			}
1388
-			else if((float)DOL_VERSION>=3.8) {
1456
+			} else if((float)DOL_VERSION>=3.8) {
1389 1457
 				return 1;
1390 1458
 			}
1391
-		}
1392
-		elseif (!empty($hideprices)
1459
+		} elseif (!empty($hideprices)
1393 1460
 		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1394 1461
 		        )
1395 1462
 		    {
@@ -1410,14 +1477,16 @@  discard block
 block discarded – undo
1410 1477
 			$this->resprints = ' ';
1411 1478
 			if((float)DOL_VERSION<=3.6) {
1412 1479
 				return '';
1413
-			}
1414
-			else if((float)DOL_VERSION>=3.8) {
1480
+			} else if((float)DOL_VERSION>=3.8) {
1415 1481
 				return 1;
1416 1482
 			}
1417 1483
 		}
1418 1484
 		
1419
-		if(is_array($parameters)) $i = & $parameters['i'];
1420
-		else $i = (int)$parameters;
1485
+		if(is_array($parameters)) {
1486
+			$i = & $parameters['i'];
1487
+		} else {
1488
+			$i = (int)$parameters;
1489
+		}
1421 1490
 			
1422 1491
 		if (!empty($hideprices)
1423 1492
 				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
@@ -1441,16 +1510,21 @@  discard block
 block discarded – undo
1441 1510
 			
1442 1511
 			if((float)DOL_VERSION<=3.6) {
1443 1512
 				return '';
1444
-			}
1445
-			else if((float)DOL_VERSION>=3.8) {
1513
+			} else if((float)DOL_VERSION>=3.8) {
1446 1514
 				return 1;
1447 1515
 			}
1448 1516
 		}
1449 1517
 		
1450
-		if(is_array($parameters)) $i = & $parameters['i'];
1451
-		else $i = (int)$parameters;
1518
+		if(is_array($parameters)) {
1519
+			$i = & $parameters['i'];
1520
+		} else {
1521
+			$i = (int)$parameters;
1522
+		}
1452 1523
 		
1453
-		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)
1524
+		if (empty($object->lines[$i])) {
1525
+			return 0;
1526
+		}
1527
+		// 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)
1454 1528
 
1455 1529
 		$object->lines[$i]->fetch_optionals();
1456 1530
 		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
@@ -1496,14 +1570,16 @@  discard block
 block discarded – undo
1496 1570
 			$this->resprints = ' ';
1497 1571
 			if((float)DOL_VERSION<=3.6) {
1498 1572
 				return '';
1499
-			}
1500
-			else if((float)DOL_VERSION>=3.8) {
1573
+			} else if((float)DOL_VERSION>=3.8) {
1501 1574
 				return 1;
1502 1575
 			}
1503 1576
 		}
1504 1577
 		
1505
-		if(is_array($parameters)) $i = & $parameters['i'];
1506
-		else $i = (int)$parameters;
1578
+		if(is_array($parameters)) {
1579
+			$i = & $parameters['i'];
1580
+		} else {
1581
+			$i = (int)$parameters;
1582
+		}
1507 1583
 			
1508 1584
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1509 1585
 		{
@@ -1533,7 +1609,9 @@  discard block
 block discarded – undo
1533 1609
 				}
1534 1610
 			}
1535 1611
 			
1536
-			if (!empty($TLineTitle)) $TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1612
+			if (!empty($TLineTitle)) {
1613
+				$TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1614
+			}
1537 1615
 		}
1538 1616
 		
1539 1617
 	}
@@ -1547,8 +1625,12 @@  discard block
 block discarded – undo
1547 1625
 		$j=0;
1548 1626
 		foreach ($TLineTitle as $k => &$line)
1549 1627
 		{
1550
-			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
1551
-			if (!empty($line_reference) && $line->qty <= $line_reference->qty) break;
1628
+			if (!empty($line_reference) && $line->rang <= $line_reference->rang) {
1629
+				continue;
1630
+			}
1631
+			if (!empty($line_reference) && $line->qty <= $line_reference->qty) {
1632
+				break;
1633
+			}
1552 1634
 			
1553 1635
 			if ($line->qty == $level)
1554 1636
 			{
@@ -1582,7 +1664,9 @@  discard block
 block discarded – undo
1582 1664
 		
1583 1665
 		$hidedetails = (int)GETPOST('hidedetails');
1584 1666
 		
1585
-		if(empty($hidedetails)) return false;
1667
+		if(empty($hidedetails)) {
1668
+			return false;
1669
+		}
1586 1670
 		
1587 1671
 		// TODO can't add VAT to document without lines... :-/
1588 1672
 		
@@ -1643,7 +1727,9 @@  discard block
 block discarded – undo
1643 1727
 						*/
1644 1728
 						list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
1645 1729
 						
1646
-						if (TSubtotal::getNiveau($line) == 1) $line->TTotal_tva = $TTotal_tva;
1730
+						if (TSubtotal::getNiveau($line) == 1) {
1731
+							$line->TTotal_tva = $TTotal_tva;
1732
+						}
1647 1733
 						$line->total_ht = $total;
1648 1734
 						$line->total_tva = $total_tva;
1649 1735
 						$line->total = $line->total_ht;
@@ -1707,8 +1793,7 @@  discard block
 block discarded – undo
1707 1793
 				    }
1708 1794
 				    
1709 1795
 					
1710
-				}
1711
-				elseif ($hidedetails)
1796
+				} elseif ($hidedetails)
1712 1797
 				{
1713 1798
 					$TLines[] = $line; //Cas où je cache uniquement les prix des produits	
1714 1799
 				}
@@ -1779,7 +1864,9 @@  discard block
 block discarded – undo
1779 1864
 				
1780 1865
 				if(!empty($hideprices)) {
1781 1866
 					foreach($object->lines as &$line) {
1782
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1867
+						if($line->fk_product_type!=9) {
1868
+							$line->fk_parent_line = -1;
1869
+						}
1783 1870
 					}
1784 1871
 				}
1785 1872
 			
@@ -1800,7 +1887,9 @@  discard block
 block discarded – undo
1800 1887
 				
1801 1888
 				if($line->qty>90) {
1802 1889
 					
1803
-					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1890
+					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) {
1891
+						$label .= ' '.$this->getTitle($object, $line);
1892
+					}
1804 1893
 					
1805 1894
 					$pageBefore = $pdf->getPage();
1806 1895
 					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
@@ -1818,8 +1907,7 @@  discard block
 block discarded – undo
1818 1907
 				
1819 1908
 					$posy = $pdf->GetY();
1820 1909
 					return 1;
1821
-				}	
1822
-				else if ($line->qty < 10) {
1910
+				} else if ($line->qty < 10) {
1823 1911
 					$pageBefore = $pdf->getPage();
1824 1912
 
1825 1913
 					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
@@ -1843,8 +1931,7 @@  discard block
 block discarded – undo
1843 1931
 //	if($line->rowid==47) exit;
1844 1932
 			
1845 1933
 			return 0;
1846
-		}
1847
-		elseif (empty($object->lines[$parameters['i']]))
1934
+		} elseif (empty($object->lines[$parameters['i']]))
1848 1935
 		{
1849 1936
 			$this->resprints = -1;
1850 1937
 		}
@@ -1877,7 +1964,9 @@  discard block
 block discarded – undo
1877 1964
 		
1878 1965
 		foreach ($object->lines as $line)
1879 1966
 		{
1880
-			if ($line->id == $currentLine->id) break;
1967
+			if ($line->id == $currentLine->id) {
1968
+				break;
1969
+			}
1881 1970
 			
1882 1971
 			$qty_search = 100 - $currentLine->qty;
1883 1972
 			
@@ -1914,23 +2003,23 @@  discard block
 block discarded – undo
1914 2003
 		{
1915 2004
 			$object->statut = 0; // hack for facture rec
1916 2005
 			$createRight = $user->rights->facture->creer;
1917
-		}
1918
-		elseif($object->element == 'order_supplier' )
2006
+		} elseif($object->element == 'order_supplier' )
1919 2007
 		{
1920 2008
 		    $createRight = $user->rights->fournisseur->commande->creer;
1921
-		}
1922
-		elseif($object->element == 'invoice_supplier' )
2009
+		} elseif($object->element == 'invoice_supplier' )
1923 2010
 		{
1924 2011
 		    $createRight = $user->rights->fournisseur->facture->creer;
1925 2012
 		}
1926 2013
 		
1927 2014
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1928 2015
 			null;
1929
-		}	
1930
-		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)) 
2016
+		} 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)) 
1931 2017
         {
1932
-			if($object->element=='facture')$idvar = 'facid';
1933
-			else $idvar='id';
2018
+			if($object->element=='facture') {
2019
+				$idvar = 'facid';
2020
+			} else {
2021
+				$idvar='id';
2022
+			}
1934 2023
 			
1935 2024
 			if((float)DOL_VERSION <= 3.4)
1936 2025
 			{
@@ -1956,22 +2045,44 @@  discard block
 block discarded – undo
1956 2045
 				<?php
1957 2046
 			}
1958 2047
 			
1959
-			if(empty($line->description)) $line->description = $line->desc;
2048
+			if(empty($line->description)) {
2049
+				$line->description = $line->desc;
2050
+			}
1960 2051
 			
1961 2052
 			$colspan = 5;
1962
-			if($object->element == 'facturerec' ) $colspan = 3;
1963
-			if($object->element == 'order_supplier') $colspan = 3;
1964
-			if($object->element == 'invoice_supplier') $colspan = 4;
1965
-			if($object->element == 'supplier_proposal') $colspan = 4;
2053
+			if($object->element == 'facturerec' ) {
2054
+				$colspan = 3;
2055
+			}
2056
+			if($object->element == 'order_supplier') {
2057
+				$colspan = 3;
2058
+			}
2059
+			if($object->element == 'invoice_supplier') {
2060
+				$colspan = 4;
2061
+			}
2062
+			if($object->element == 'supplier_proposal') {
2063
+				$colspan = 4;
2064
+			}
1966 2065
 			if(!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
1967 2066
 				$colspan++; // Colonne PU Devise
1968 2067
 			}
1969
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1970
-			if(!empty($conf->margin->enabled)) $colspan++;
1971
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1972
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1973
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1974
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
2068
+			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) {
2069
+				$colspan++;
2070
+			}
2071
+			if(!empty($conf->margin->enabled)) {
2072
+				$colspan++;
2073
+			}
2074
+			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) {
2075
+				$colspan++;
2076
+			}
2077
+			if(!empty($conf->global->DISPLAY_MARK_RATES)) {
2078
+				$colspan++;
2079
+			}
2080
+			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) {
2081
+				$colspan++;
2082
+			}
2083
+			if(!empty($conf->global->PRODUCT_USE_UNITS)) {
2084
+				$colspan++;
2085
+			}
1975 2086
 					
1976 2087
 			/* Titre */
1977 2088
 			//var_dump($line);
@@ -1984,23 +2095,36 @@  discard block
 block discarded – undo
1984 2095
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
1985 2096
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
1986 2097
 					{
1987
-						if($line->qty==99) print 'background:#adadcf';
1988
-						else if($line->qty==98) print 'background:#ddddff;';
1989
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
1990
-						else if($line->qty==1) print 'background:#adadcf;';
1991
-						else if($line->qty==2) print 'background:#ddddff;';
1992
-						else if($line->qty==50) print '';
1993
-						else print 'background:#eeeeff;';
2098
+						if($line->qty==99) {
2099
+							print 'background:#adadcf';
2100
+						} else if($line->qty==98) {
2101
+							print 'background:#ddddff;';
2102
+						} else if($line->qty<=97 && $line->qty>=91) {
2103
+							print 'background:#eeeeff;';
2104
+						} else if($line->qty==1) {
2105
+							print 'background:#adadcf;';
2106
+						} else if($line->qty==2) {
2107
+							print 'background:#ddddff;';
2108
+						} else if($line->qty==50) {
2109
+							print '';
2110
+						} else {
2111
+							print 'background:#eeeeff;';
2112
+						}
1994 2113
 
1995 2114
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
1996
-					}
1997
-					else 
2115
+					} else 
1998 2116
 					{
1999
-						if($line->qty==99) print 'background:#ddffdd';
2000
-						else if($line->qty==98) print 'background:#ddddff;';
2001
-						else if($line->qty==2) print 'background:#eeeeff; ';
2002
-						else if($line->qty==50) print '';
2003
-						else print 'background:#eeffee;' ;
2117
+						if($line->qty==99) {
2118
+							print 'background:#ddffdd';
2119
+						} else if($line->qty==98) {
2120
+							print 'background:#ddddff;';
2121
+						} else if($line->qty==2) {
2122
+							print 'background:#eeeeff; ';
2123
+						} else if($line->qty==50) {
2124
+							print '';
2125
+						} else {
2126
+							print 'background:#eeffee;' ;
2127
+						}
2004 2128
 					}
2005 2129
 
2006 2130
 			?>;">
@@ -2027,13 +2151,11 @@  discard block
 block discarded – undo
2027 2151
 							$qty_displayed = $line->qty;
2028 2152
 							print img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
2029 2153
 							
2030
-						}
2031
-						else if (TSubtotal::isSubtotal($line))
2154
+						} else if (TSubtotal::isSubtotal($line))
2032 2155
 						{
2033 2156
 							$qty_displayed = 100 - $line->qty;
2034 2157
 							print img_picto('', 'subsubtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
2035
-						}
2036
-						else
2158
+						} else
2037 2159
 						{
2038 2160
 							$isFreeText = true;
2039 2161
 						}
@@ -2054,9 +2176,13 @@  discard block
 block discarded – undo
2054 2176
 						}
2055 2177
 
2056 2178
 						$readonlyForSituation = '';
2057
-						if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) $readonlyForSituation = 'readonly';
2179
+						if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) {
2180
+							$readonlyForSituation = 'readonly';
2181
+						}
2058 2182
 						
2059
-						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2183
+						if (!$isFreeText) {
2184
+							echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2185
+						}
2060 2186
 						
2061 2187
 						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
2062 2188
 						{
@@ -2064,8 +2190,12 @@  discard block
 block discarded – undo
2064 2190
 							for ($j=1; $j<10; $j++)
2065 2191
 							{
2066 2192
 								if (!empty($readonlyForSituation)) {
2067
-									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2068
-								} else $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2193
+									if ($qty_displayed == $j) {
2194
+										$select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2195
+									}
2196
+								} else {
2197
+									$select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2198
+								}
2069 2199
 							}
2070 2200
 							$select .= '</select>&nbsp;';
2071 2201
 
@@ -2085,7 +2215,9 @@  discard block
 block discarded – undo
2085 2215
                             echo '<div>';
2086 2216
                             echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2087 2217
                             echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2088
-                            if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2218
+                            if (empty($readonlyForSituation)) {
2219
+                            	echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2220
+                            }
2089 2221
                             echo '</select>';
2090 2222
                             echo '</div>';
2091 2223
 
@@ -2104,8 +2236,9 @@  discard block
 block discarded – undo
2104 2236
                             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"' : '') .' />&nbsp;';
2105 2237
                             echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2106 2238
                             echo '</div>';
2239
+                        } else if ($isFreeText) {
2240
+                        	echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2107 2241
                         }
2108
-                        else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2109 2242
 						echo '</div>';
2110 2243
 
2111 2244
 						if($line->qty<10) {
@@ -2125,8 +2258,7 @@  discard block
 block discarded – undo
2125 2258
 							$doleditor->Create();
2126 2259
 						}
2127 2260
 						
2128
-					}
2129
-					else {
2261
+					} else {
2130 2262
 
2131 2263
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2132 2264
 						 {
@@ -2134,14 +2266,19 @@  discard block
 block discarded – undo
2134 2266
 							{
2135 2267
 								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2136 2268
 								
2137
-								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2138
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2269
+								if (TSubtotal::isTitle($line)) {
2270
+									print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2271
+								} else {
2272
+									print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2273
+								}
2139 2274
 							}
2140
-						 }
2141
-						 else 
2275
+						 } else 
2142 2276
 						 {
2143
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2144
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2277
+							if($line->qty<=1) {
2278
+								print img_picto('', 'subtotal@subtotal');
2279
+							} else if($line->qty==2) {
2280
+								print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2281
+							}
2145 2282
 						 }
2146 2283
 						 
2147 2284
 						 
@@ -2151,21 +2288,26 @@  discard block
 block discarded – undo
2151 2288
 						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2152 2289
 						 
2153 2290
 						 if (empty($line->label)) {
2154
-							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2155
-							else print  $line->description;
2156
-						 } 
2157
-						 else {
2291
+							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2292
+								print  $line->description.' '.$this->getTitle($object, $line);
2293
+							} else {
2294
+								print  $line->description;
2295
+							}
2296
+						 } else {
2158 2297
 
2159 2298
 							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2160 2299
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2161
-							}
2162
-							else{
2300
+							} else{
2163 2301
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
2164 2302
 							}
2165 2303
 
2166 2304
 						 } 
2167
-						if($line->qty>90) print ' : ';
2168
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2305
+						if($line->qty>90) {
2306
+							print ' : ';
2307
+						}
2308
+						if($line->info_bits > 0) {
2309
+							echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2310
+						}
2169 2311
 
2170 2312
 						 
2171 2313
 
@@ -2208,11 +2350,12 @@  discard block
 block discarded – undo
2208 2350
 						</script>
2209 2351
 						<?php
2210 2352
 						
2211
-					}
2212
-					else{
2353
+					} else{
2213 2354
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2214 2355
 						{
2215
-							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>';
2356
+							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) {
2357
+								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2358
+							}
2216 2359
 						}
2217 2360
 
2218 2361
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
@@ -2301,7 +2444,9 @@  discard block
 block discarded – undo
2301 2444
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2302 2445
 				
2303 2446
 				$colspan+=3; $mode = 'view';
2304
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2447
+				if($action === 'editline' && $line->rowid == GETPOST('lineid')) {
2448
+					$mode = 'edit';
2449
+				}
2305 2450
 				
2306 2451
 				$ex_element = $line->element;
2307 2452
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
@@ -2483,10 +2628,9 @@  discard block
 block discarded – undo
2483 2628
 	    
2484 2629
 	    if(TSubtotal::isTitle($line)){
2485 2630
 	        $ThtmlData['data-issubtotal'] = 'title';
2486
-	    }elseif(TSubtotal::isSubtotal($line)){
2631
+	    } elseif(TSubtotal::isSubtotal($line)){
2487 2632
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2488
-	    }
2489
-	    else{
2633
+	    } else{
2490 2634
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2491 2635
 	    }
2492 2636
 	    
@@ -2496,7 +2640,9 @@  discard block
 block discarded – undo
2496 2640
 	    
2497 2641
 	    // hook 
2498 2642
 	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2499
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2643
+	    if ($reshook < 0) {
2644
+	    	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2645
+	    }
2500 2646
 	    if ($reshook>0)
2501 2647
 	    {
2502 2648
 	        $ThtmlData = $hookmanager->resArray;
Please login to merge, or discard this patch.