Passed
Pull Request — master (#134)
by
unknown
03:00
created
class/actions_subtotal.class.php 1 patch
Braces   +521 added lines, -312 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
 			?>
@@ -124,8 +126,7 @@  discard block
 block discarded – undo
124 126
 			} elseif($object->element == 'invoice_supplier' )
125 127
 			{
126 128
 			    $createRight = $user->rights->fournisseur->facture->creer;
127
-			}
128
-			elseif($object->element == 'shipping')
129
+			} elseif($object->element == 'shipping')
129 130
 			{
130 131
 				$createRight = true; // No rights management for shipments
131 132
 			}
@@ -133,8 +134,11 @@  discard block
 block discarded – undo
133 134
 			if ($object->statut == 0  && $createRight) {
134 135
 			
135 136
 
136
-				if($object->element=='facture')$idvar = 'facid';
137
-				else $idvar='id';
137
+				if($object->element=='facture') {
138
+					$idvar = 'facid';
139
+				} else {
140
+					$idvar='id';
141
+				}
138 142
 				
139 143
 				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
140 144
 				{
@@ -142,10 +146,11 @@  discard block
 block discarded – undo
142 146
 					
143 147
 					if($action=='add_title_line') {
144 148
 						$title = GETPOST('title');
145
-						if(empty($title)) $title = $langs->trans('title');
149
+						if(empty($title)) {
150
+							$title = $langs->trans('title');
151
+						}
146 152
 						$qty = $level<1 ? 1 : $level ;
147
-					}
148
-					else if($action=='add_free_text') {
153
+					} else if($action=='add_free_text') {
149 154
 						$title = GETPOST('title');
150 155
 
151 156
 						if (empty($title)) {
@@ -157,29 +162,31 @@  discard block
 block discarded – undo
157 162
 								}
158 163
 							}
159 164
 						}
160
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
165
+						if(empty($title)) {
166
+							$title = $langs->trans('subtotalAddLineDescription');
167
+						}
161 168
 						$qty = 50;
162
-					}
163
-					else if($action=='add_subtitle_line') {
169
+					} else if($action=='add_subtitle_line') {
164 170
 						$title = GETPOST('title');
165
-						if(empty($title)) $title = $langs->trans('subtitle');
171
+						if(empty($title)) {
172
+							$title = $langs->trans('subtitle');
173
+						}
166 174
 						$qty = 2;
167
-					}
168
-					else if($action=='add_subtotal_line') {
175
+					} else if($action=='add_subtotal_line') {
169 176
 						$title = $langs->trans('SubSubTotal');
170 177
 						$qty = 98;
171
-					}
172
-					else {
178
+					} else {
173 179
 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
174 180
 						$qty = $level ? 100-$level : 99;
175 181
 					}
176 182
 					dol_include_once('/subtotal/class/subtotal.class.php');
177 183
 					
178
-					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
184
+					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) {
185
+						TSubtotal::addSubtotalMissing($object, $qty);
186
+					}
179 187
 					
180 188
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
181
-				}
182
-				else if($action==='ask_deleteallline') {
189
+				} else if($action==='ask_deleteallline') {
183 190
 						$form=new Form($db);
184 191
 
185 192
 						$lineid = GETPOST('lineid','integer');
@@ -202,8 +209,7 @@  discard block
 block discarded – undo
202 209
 					$this->printNewFormat($object, $conf, $langs, $idvar);
203 210
 				}
204 211
 			}
205
-		}
206
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
212
+		} elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
207 213
 		{
208 214
 			?>
209 215
 			<script type="text/javascript">
@@ -221,8 +227,13 @@  discard block
 block discarded – undo
221 227
      
222 228
 	function printNewFormat(&$object, &$conf, &$langs, $idvar)
223 229
 	{
224
-		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) return false;
225
-		if ($line->fk_prev_id != null && !empty($line->fk_prev_id)) return false; // Si facture de situation
230
+		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) {
231
+			return false;
232
+		}
233
+		if ($line->fk_prev_id != null && !empty($line->fk_prev_id)) {
234
+			return false;
235
+		}
236
+		// Si facture de situation
226 237
 		?>
227 238
 		 	<script type="text/javascript">
228 239
 				$(document).ready(function() {
@@ -508,8 +519,7 @@  discard block
 block discarded – undo
508 519
 				}
509 520
 				
510 521
 				
511
-			}	
512
-			else{
522
+			} else{
513 523
 				$substitutionarray['line_not_modsubtotal'] = true;
514 524
 				$substitutionarray['line_modsubtotal'] = 0;
515 525
 			}
@@ -567,8 +577,11 @@  discard block
 block discarded – undo
567 577
 		
568 578
 		$showBlockExtrafields = GETPOST('showBlockExtrafields');
569 579
 		
570
-		if($object->element=='facture') $idvar = 'facid';
571
-		else $idvar = 'id';
580
+		if($object->element=='facture') {
581
+			$idvar = 'facid';
582
+		} else {
583
+			$idvar = 'id';
584
+		}
572 585
 			
573 586
 		if ($action == 'updateligne' || $action == 'updateline')
574 587
 		{
@@ -598,8 +611,7 @@  discard block
 block discarded – undo
598 611
 				header('Location: '.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id);
599 612
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
600 613
 			}
601
-		}
602
-		else if($action === 'builddoc') {
614
+		} else if($action === 'builddoc') {
603 615
 			
604 616
 			if (
605 617
 				in_array('invoicecard',explode(':',$parameters['context']))
@@ -614,33 +626,27 @@  discard block
 block discarded – undo
614 626
 					$sessname = 'subtotal_hideInnerLines_facture';	
615 627
 					$sessname2 = 'subtotal_hidedetails_facture';
616 628
 					$sessname3 = 'subtotal_hideprices_facture';
617
-				}
618
-				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
629
+				} elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
619 630
 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
620 631
 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
621 632
 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
622
-				}
623
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
633
+				} elseif(in_array('propalcard',explode(':',$parameters['context']))) {
624 634
 					$sessname = 'subtotal_hideInnerLines_propal';
625 635
 					$sessname2 = 'subtotal_hidedetails_propal';	
626 636
 					$sessname3 = 'subtotal_hideprices_propal';
627
-				}
628
-				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
637
+				} elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
629 638
 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
630 639
 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
631 640
 				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
632
-				}
633
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
641
+				} elseif(in_array('ordercard',explode(':',$parameters['context']))) {
634 642
 					$sessname = 'subtotal_hideInnerLines_commande';
635 643
 					$sessname2 = 'subtotal_hidedetails_commande';	
636 644
 					$sessname3 = 'subtotal_hideprices_commande';
637
-				}
638
-				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
645
+				} elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
639 646
 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
640 647
 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
641 648
 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
642
-				}
643
-				else {
649
+				} else {
644 650
 					$sessname = 'subtotal_hideInnerLines_unknown';
645 651
 					$sessname2 = 'subtotal_hidedetails_unknown';
646 652
 					$sessname3 = 'subtotal_hideprices_unknown';
@@ -649,15 +655,24 @@  discard block
 block discarded – undo
649 655
 				global $hideprices;
650 656
 				
651 657
 				$hideInnerLines = (int)GETPOST('hideInnerLines');
652
-				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) $_SESSION[$sessname] = array(); // prevent old system
658
+				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) {
659
+					$_SESSION[$sessname] = array();
660
+				}
661
+				// prevent old system
653 662
 				$_SESSION[$sessname][$object->id] = $hideInnerLines;		
654 663
 				
655 664
 				$hidedetails= (int)GETPOST('hidedetails');
656
-				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) $_SESSION[$sessname2] = array(); // prevent old system
665
+				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) {
666
+					$_SESSION[$sessname2] = array();
667
+				}
668
+				// prevent old system
657 669
 				$_SESSION[$sessname2][$object->id] = $hidedetails;
658 670
 				
659 671
 				$hideprices= (int)GETPOST('hideprices');
660
-				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) $_SESSION[$sessname3] = array(); // prevent old system
672
+				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) {
673
+					$_SESSION[$sessname3] = array();
674
+				}
675
+				// prevent old system
661 676
 				$_SESSION[$sessname3][$object->id] = $hideprices;
662 677
 				
663 678
 				foreach($object->lines as &$line) {
@@ -665,8 +680,7 @@  discard block
 block discarded – undo
665 680
 					    
666 681
                         if($line->qty>=90) {
667 682
                             $line->modsubtotal_total = 1;
668
-                        }
669
-                        else{
683
+                        } else{
670 684
                             $line->modsubtotal_title = 1;
671 685
                         }
672 686
                         
@@ -675,8 +689,7 @@  discard block
 block discarded – undo
675 689
 	        	}
676 690
 	        }
677 691
 			
678
-		}
679
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
692
+		} else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
680 693
 			
681 694
 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
682 695
 			
@@ -684,7 +697,9 @@  discard block
 block discarded – undo
684 697
 				/**
685 698
 				 * @var $object Facture
686 699
 				 */
687
-				if($object->element=='facture') $object->deleteline($idLine);
700
+				if($object->element=='facture') {
701
+					$object->deleteline($idLine);
702
+				}
688 703
 				/**
689 704
 				 * @var $object Facture fournisseur
690 705
 				 */
@@ -695,18 +710,25 @@  discard block
 block discarded – undo
695 710
 				/**
696 711
 				 * @var $object Propal
697 712
 				 */
698
-				else if($object->element=='propal') $object->deleteline($idLine);
713
+				else if($object->element=='propal') {
714
+					$object->deleteline($idLine);
715
+				}
699 716
 				/**
700 717
 				 * @var $object Propal Fournisseur
701 718
 				 */
702
-				else if($object->element=='supplier_proposal') $object->deleteline($idLine);
719
+				else if($object->element=='supplier_proposal') {
720
+					$object->deleteline($idLine);
721
+				}
703 722
 				/**
704 723
 				 * @var $object Commande
705 724
 				 */
706 725
 				else if($object->element=='commande') 
707 726
 				{
708
-					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
709
-					else $object->deleteline($idLine);
727
+					if ((float) DOL_VERSION >= 5.0) {
728
+						$object->deleteline($user, $idLine);
729
+					} else {
730
+						$object->deleteline($idLine);
731
+					}
710 732
 				}
711 733
 				/**
712 734
 				 * @var $object Commande fournisseur
@@ -718,25 +740,32 @@  discard block
 block discarded – undo
718 740
 				/**
719 741
 				 * @var $object Facturerec
720 742
 				 */
721
-				else if($object->element=='facturerec') $object->deleteline($idLine);
743
+				else if($object->element=='facturerec') {
744
+					$object->deleteline($idLine);
745
+				}
722 746
 				/**
723 747
 				 * @var $object Expedition
724 748
 				 */
725
-				else if($object->element=='shipping') $object->deleteline($user, $idLine);
749
+				else if($object->element=='shipping') {
750
+					$object->deleteline($user, $idLine);
751
+				}
726 752
 			}
727 753
 			
728 754
 			header('location:?id='.$object->id);
729 755
 			exit;
730 756
 			
731
-		}
732
-		else if ($action == 'duplicate')
757
+		} else if ($action == 'duplicate')
733 758
 		{
734 759
 			$lineid = GETPOST('lineid', 'int');
735 760
 			$nbDuplicate = TSubtotal::duplicateLines($object, $lineid, true);
736 761
 			
737
-			if ($nbDuplicate > 0) setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
738
-			elseif ($nbDuplicate == 0) setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
739
-			else setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
762
+			if ($nbDuplicate > 0) {
763
+				setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
764
+			} elseif ($nbDuplicate == 0) {
765
+				setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
766
+			} else {
767
+				setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
768
+			}
740 769
 			
741 770
 			header('Location: ?id='.$object->id);
742 771
 			exit;
@@ -754,21 +783,26 @@  discard block
 block discarded – undo
754 783
 		global $conf;
755 784
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && !empty($object->table_element_line) && in_array($object->element, array('commande', 'facture', 'propal')))
756 785
 		{
757
-			if ($object->element == 'commande')
758
-				$obj = new OrderLine($object->db);
759
-			if ($object->element == 'propal')
760
-				$obj = new PropaleLigne($object->db);
761
-			if ($object->element == 'facture')
762
-				$obj = new FactureLigne($object->db);
786
+			if ($object->element == 'commande') {
787
+							$obj = new OrderLine($object->db);
788
+			}
789
+			if ($object->element == 'propal') {
790
+							$obj = new PropaleLigne($object->db);
791
+			}
792
+			if ($object->element == 'facture') {
793
+							$obj = new FactureLigne($object->db);
794
+			}
763 795
 			if (!empty($parameters['fk_element']))
764 796
 			{
765 797
 				
766 798
 				if($obj->fetch($parameters['fk_element'])){
767 799
 					$obj->id= $obj->rowid;
768
-					if (empty($obj->array_options))
769
-						$obj->fetch_optionals();
770
-					if (!empty($obj->array_options['options_subtotal_nc']))
771
-						return 1;
800
+					if (empty($obj->array_options)) {
801
+											$obj->fetch_optionals();
802
+					}
803
+					if (!empty($obj->array_options['options_subtotal_nc'])) {
804
+											return 1;
805
+					}
772 806
 				}
773 807
 			}
774 808
 		}
@@ -840,27 +874,33 @@  discard block
 block discarded – undo
840 874
 		$TTotal_tva = array();
841 875
 		
842 876
 		$sign=1;
843
-		if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
877
+		if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
878
+			$sign=-1;
879
+		}
844 880
 		
845
-		if (GETPOST('action') == 'builddoc') $builddoc = true;
846
-		else $builddoc = false;
881
+		if (GETPOST('action') == 'builddoc') {
882
+			$builddoc = true;
883
+		} else {
884
+			$builddoc = false;
885
+		}
847 886
 		
848 887
 		dol_include_once('/subtotal/class/subtotal.class.php');
849 888
 		foreach($object->lines as $l) {
850 889
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
851 890
 			if($l->rang>=$rang) {
852 891
 				//echo 'return!<br>';
853
-				if (!$return_all) return $total;
854
-				else return array($total, $total_tva, $total_ttc, $TTotal_tva);
855
-			}
856
-			else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
892
+				if (!$return_all) {
893
+					return $total;
894
+				} else {
895
+					return array($total, $total_tva, $total_ttc, $TTotal_tva);
896
+				}
897
+			} else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
857 898
 		  	{
858 899
 				$total = 0;
859 900
 				$total_tva = 0;
860 901
 				$total_ttc = 0;
861 902
 				$TTotal_tva = array();
862
-			}
863
-			elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
903
+			} elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
864 904
 				
865 905
 				// TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF
866 906
 				if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION)
@@ -882,8 +922,7 @@  discard block
 block discarded – undo
882 922
 						$TTotal_tva[$l->tva_tx] += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
883 923
 						$total_ttc += $sign * ($l->total_tva / ($l->total_ttc / 100)) * $progress;
884 924
 					}
885
-				}
886
-				else
925
+				} else
887 926
 				{
888 927
 					$total += $l->total_ht;
889 928
 					$total_tva += $l->total_tva;
@@ -893,8 +932,11 @@  discard block
 block discarded – undo
893 932
 			}
894 933
 			
895 934
 		}
896
-		if (!$return_all) return $total;
897
-		else return array($total, $total_tva, $total_ttc, $TTotal_tva);
935
+		if (!$return_all) {
936
+			return $total;
937
+		} else {
938
+			return array($total, $total_tva, $total_ttc, $TTotal_tva);
939
+		}
898 940
 	}
899 941
 
900 942
 	/**
@@ -941,15 +983,18 @@  discard block
 block discarded – undo
941 983
 		}
942 984
 		
943 985
 			
944
-		if($line->qty==99)
945
-			$pdf->SetFillColor(220,220,220);
946
-		elseif ($line->qty==98)
947
-			$pdf->SetFillColor(230,230,230);
948
-		else
949
-			$pdf->SetFillColor(240,240,240);
986
+		if($line->qty==99) {
987
+					$pdf->SetFillColor(220,220,220);
988
+		} elseif ($line->qty==98) {
989
+					$pdf->SetFillColor(230,230,230);
990
+		} else {
991
+					$pdf->SetFillColor(240,240,240);
992
+		}
950 993
 		
951 994
 		$style = 'B';
952
-		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
995
+		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) {
996
+			$style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
997
+		}
953 998
 		
954 999
 		$pdf->SetFont('', $style, 9);
955 1000
 		
@@ -991,8 +1036,7 @@  discard block
 block discarded – undo
991 1036
 //					$line->total_tva
992 1037
 //					$line->total
993 1038
 //					$line->total_ttc
994
-				}
995
-				else
1039
+				} else
996 1040
 				{
997 1041
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
998 1042
 					$total_to_print = price($total);
@@ -1005,11 +1049,14 @@  discard block
 block discarded – undo
1005 1049
 			}
1006 1050
 
1007 1051
 			$pdf->SetXY($pdf->postotalht, $posy);
1008
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1052
+			if($set_pagebreak_margin) {
1053
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1054
+			}
1009 1055
 			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
1010
-		}
1011
-		else{
1012
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1056
+		} else{
1057
+			if($set_pagebreak_margin) {
1058
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1059
+			}
1013 1060
 		}
1014 1061
 		
1015 1062
 		$posy = $posy + $cell_height;
@@ -1041,25 +1088,40 @@  discard block
 block discarded – undo
1041 1088
 		
1042 1089
  
1043 1090
 		$style = ($line->qty==1) ? 'BU' : 'BUI';
1044
-		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
1091
+		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) {
1092
+			$style = $conf->global->SUBTOTAL_TITLE_STYLE;
1093
+		}
1045 1094
 		
1046 1095
 		if($hideInnerLines) {
1047
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
1048
-			else 
1096
+			if($line->qty==1) {
1097
+				$pdf->SetFont('', $style, 9);
1098
+			} else 
1049 1099
 			{
1050
-				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
1100
+				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) {
1101
+					$style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
1102
+				}
1051 1103
 				$pdf->SetFont('', $style, 9);
1052 1104
 			}
1053
-		}
1054
-		else {
1105
+		} else {
1055 1106
 
1056
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
1057
-			else $pdf->SetFont('', $style, 9);
1107
+			if($line->qty==1) {
1108
+				$pdf->SetFont('', $style, 9);
1109
+			}
1110
+			//TODO if super utile
1111
+			else {
1112
+				$pdf->SetFont('', $style, 9);
1113
+			}
1058 1114
 			
1059 1115
 		}
1060 1116
 		
1061
-		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
1062
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
1117
+		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) {
1118
+			$pdf->MultiCell($w, $h, $label, 0, 'L');
1119
+		}
1120
+		// Pas de HTML dans la chaine
1121
+		else {
1122
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true);
1123
+		}
1124
+		// et maintenant avec du HTML
1063 1125
 		
1064 1126
 		if($description && !$hidedesc) {
1065 1127
 			$posy = $pdf->GetY();
@@ -1083,8 +1145,7 @@  discard block
 block discarded – undo
1083 1145
 		
1084 1146
 		if(is_array($parameters)) {
1085 1147
 			$i = & $parameters['i'];	
1086
-		}
1087
-		else {
1148
+		} else {
1088 1149
 			$i = (int)$parameters;
1089 1150
 		}
1090 1151
 
@@ -1114,17 +1175,14 @@  discard block
 block discarded – undo
1114 1175
 			
1115 1176
 			if((float)DOL_VERSION<=3.6) {
1116 1177
 				return '';
1117
-			}
1118
-			else if((float)DOL_VERSION>=3.8) {
1178
+			} else if((float)DOL_VERSION>=3.8) {
1119 1179
 				return 1;
1120 1180
 			}
1121 1181
 			
1122
-		}
1123
-		elseif(!empty($hideprices)) {
1182
+		} elseif(!empty($hideprices)) {
1124 1183
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1125 1184
 			return 1;
1126
-		}
1127
-		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1185
+		} elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1128 1186
 		{
1129 1187
 			$hideInnerLines = (int)GETPOST('hideInnerLines');
1130 1188
 			$hidedetails = (int)GETPOST('hidedetails');
@@ -1134,12 +1192,20 @@  discard block
 block discarded – undo
1134 1192
 			}
1135 1193
 		}
1136 1194
 		
1137
-		if(is_array($parameters)) $i = & $parameters['i'];
1138
-		else $i = (int)$parameters;
1195
+		if(is_array($parameters)) {
1196
+			$i = & $parameters['i'];
1197
+		} else {
1198
+			$i = (int)$parameters;
1199
+		}
1139 1200
 
1140
-		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)
1201
+		if (empty($object->lines[$i])) {
1202
+			return 0;
1203
+		}
1204
+		// 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)
1141 1205
 		
1142
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1206
+		if(empty($object->lines[$i]->array_options)) {
1207
+			$object->lines[$i]->fetch_optionals();
1208
+		}
1143 1209
 
1144 1210
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1145 1211
 		{
@@ -1156,8 +1222,11 @@  discard block
 block discarded – undo
1156 1222
 	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1157 1223
 	    global $conf, $hideprices, $hookmanager;
1158 1224
 		
1159
-		if(is_array($parameters)) $i = & $parameters['i'];
1160
-		else $i = (int)$parameters;
1225
+		if(is_array($parameters)) {
1226
+			$i = & $parameters['i'];
1227
+		} else {
1228
+			$i = (int)$parameters;
1229
+		}
1161 1230
 			
1162 1231
 		if($this->isModSubtotalLine($parameters,$object) ){
1163 1232
 			
@@ -1165,13 +1234,11 @@  discard block
 block discarded – undo
1165 1234
 			
1166 1235
 			if((float)DOL_VERSION<=3.6) {
1167 1236
 				return '';
1168
-			}
1169
-			else if((float)DOL_VERSION>=3.8) {
1237
+			} else if((float)DOL_VERSION>=3.8) {
1170 1238
 				return 1;
1171 1239
 			}
1172 1240
 			
1173
-		}
1174
-		elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1241
+		} elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1175 1242
 		{
1176 1243
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1177 1244
 			{
@@ -1243,12 +1310,10 @@  discard block
 block discarded – undo
1243 1310
 			$this->error = $hookmanager->error;
1244 1311
 			$this->errors = $hookmanager->errors;
1245 1312
 			return -1;
1246
-		}
1247
-		elseif (empty($reshook))
1313
+		} elseif (empty($reshook))
1248 1314
 		{
1249 1315
 			$this->resprints .= $hookmanager->resprints;
1250
-		}
1251
-		else
1316
+		} else
1252 1317
 		{
1253 1318
 			$this->resprints = $hookmanager->resprints;
1254 1319
 
@@ -1271,14 +1336,16 @@  discard block
 block discarded – undo
1271 1336
 		
1272 1337
 			if((float)DOL_VERSION<=3.6) {
1273 1338
 				return '';
1274
-			}
1275
-			else if((float)DOL_VERSION>=3.8) {
1339
+			} else if((float)DOL_VERSION>=3.8) {
1276 1340
 				return 1;
1277 1341
 			}
1278 1342
 		}
1279 1343
 		
1280
-		if(is_array($parameters)) $i = & $parameters['i'];
1281
-		else $i = (int)$parameters;
1344
+		if(is_array($parameters)) {
1345
+			$i = & $parameters['i'];
1346
+		} else {
1347
+			$i = (int)$parameters;
1348
+		}
1282 1349
 		
1283 1350
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1284 1351
 		{
@@ -1300,14 +1367,16 @@  discard block
 block discarded – undo
1300 1367
 		
1301 1368
 			if((float)DOL_VERSION<=3.6) {
1302 1369
 				return '';
1303
-			}
1304
-			else if((float)DOL_VERSION>=3.8) {
1370
+			} else if((float)DOL_VERSION>=3.8) {
1305 1371
 				return 1;
1306 1372
 			}
1307 1373
 		}
1308 1374
 		
1309
-		if(is_array($parameters)) $i = & $parameters['i'];
1310
-		else $i = (int)$parameters;
1375
+		if(is_array($parameters)) {
1376
+			$i = & $parameters['i'];
1377
+		} else {
1378
+			$i = (int)$parameters;
1379
+		}
1311 1380
 			
1312 1381
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1313 1382
 		{
@@ -1324,8 +1393,11 @@  discard block
 block discarded – undo
1324 1393
 	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1325 1394
 	    global $conf,$hideprices,$hookmanager;
1326 1395
 
1327
-		if(is_array($parameters)) $i = & $parameters['i'];
1328
-		else $i = (int)$parameters;
1396
+		if(is_array($parameters)) {
1397
+			$i = & $parameters['i'];
1398
+		} else {
1399
+			$i = (int)$parameters;
1400
+		}
1329 1401
 
1330 1402
 		if($this->isModSubtotalLine($parameters,$object) ) {
1331 1403
 			$this->resprints = ' ';
@@ -1336,7 +1408,9 @@  discard block
 block discarded – undo
1336 1408
             if(TSubtotal::isSubtotal($line)) {
1337 1409
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1338 1410
 
1339
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1411
+                if(is_object($parentTitle) && empty($parentTitle->array_options)) {
1412
+                	$parentTitle->fetch_optionals();
1413
+                }
1340 1414
                 if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1341 1415
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1342 1416
                     $this->resprints = price($TTotal['total_subprice']);
@@ -1345,8 +1419,7 @@  discard block
 block discarded – undo
1345 1419
 		
1346 1420
 			if((float)DOL_VERSION<=3.6) {
1347 1421
 				return '';
1348
-			}
1349
-			else if((float)DOL_VERSION>=3.8) {
1422
+			} else if((float)DOL_VERSION>=3.8) {
1350 1423
 				return 1;
1351 1424
 			}
1352 1425
 		}
@@ -1391,8 +1464,11 @@  discard block
 block discarded – undo
1391 1464
 	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1392 1465
 	    global $conf,$hideprices,$hookmanager;
1393 1466
 
1394
-        if(is_array($parameters)) $i = & $parameters['i'];
1395
-        else $i = (int) $parameters;
1467
+        if(is_array($parameters)) {
1468
+        	$i = & $parameters['i'];
1469
+        } else {
1470
+        	$i = (int) $parameters;
1471
+        }
1396 1472
 
1397 1473
 		if($this->isModSubtotalLine($parameters,$object) ) {
1398 1474
 			$this->resprints = ' ';
@@ -1403,7 +1479,9 @@  discard block
 block discarded – undo
1403 1479
             if(TSubtotal::isSubtotal($line)) {
1404 1480
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1405 1481
 
1406
-                if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1482
+                if(empty($parentTitle->array_options)) {
1483
+                	$parentTitle->fetch_optionals();
1484
+                }
1407 1485
                 if(! empty($parentTitle->array_options['options_show_reduc'])) {
1408 1486
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1409 1487
                     $this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
@@ -1412,12 +1490,10 @@  discard block
 block discarded – undo
1412 1490
 		
1413 1491
 			if((float)DOL_VERSION<=3.6) {
1414 1492
 				return '';
1415
-			}
1416
-			else if((float)DOL_VERSION>=3.8) {
1493
+			} else if((float)DOL_VERSION>=3.8) {
1417 1494
 				return 1;
1418 1495
 			}
1419
-		}
1420
-		elseif (!empty($hideprices)
1496
+		} elseif (!empty($hideprices)
1421 1497
 		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1422 1498
 		        )
1423 1499
 		    {
@@ -1438,14 +1514,16 @@  discard block
 block discarded – undo
1438 1514
 			$this->resprints = ' ';
1439 1515
 			if((float)DOL_VERSION<=3.6) {
1440 1516
 				return '';
1441
-			}
1442
-			else if((float)DOL_VERSION>=3.8) {
1517
+			} else if((float)DOL_VERSION>=3.8) {
1443 1518
 				return 1;
1444 1519
 			}
1445 1520
 		}
1446 1521
 		
1447
-		if(is_array($parameters)) $i = & $parameters['i'];
1448
-		else $i = (int)$parameters;
1522
+		if(is_array($parameters)) {
1523
+			$i = & $parameters['i'];
1524
+		} else {
1525
+			$i = (int)$parameters;
1526
+		}
1449 1527
 			
1450 1528
 		if (!empty($hideprices)
1451 1529
 				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
@@ -1469,16 +1547,21 @@  discard block
 block discarded – undo
1469 1547
 			
1470 1548
 			if((float)DOL_VERSION<=3.6) {
1471 1549
 				return '';
1472
-			}
1473
-			else if((float)DOL_VERSION>=3.8) {
1550
+			} else if((float)DOL_VERSION>=3.8) {
1474 1551
 				return 1;
1475 1552
 			}
1476 1553
 		}
1477 1554
 		
1478
-		if(is_array($parameters)) $i = & $parameters['i'];
1479
-		else $i = (int)$parameters;
1555
+		if(is_array($parameters)) {
1556
+			$i = & $parameters['i'];
1557
+		} else {
1558
+			$i = (int)$parameters;
1559
+		}
1480 1560
 		
1481
-		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)
1561
+		if (empty($object->lines[$i])) {
1562
+			return 0;
1563
+		}
1564
+		// 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)
1482 1565
 
1483 1566
 		$object->lines[$i]->fetch_optionals();
1484 1567
 		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
@@ -1524,14 +1607,16 @@  discard block
 block discarded – undo
1524 1607
 			$this->resprints = ' ';
1525 1608
 			if((float)DOL_VERSION<=3.6) {
1526 1609
 				return '';
1527
-			}
1528
-			else if((float)DOL_VERSION>=3.8) {
1610
+			} else if((float)DOL_VERSION>=3.8) {
1529 1611
 				return 1;
1530 1612
 			}
1531 1613
 		}
1532 1614
 		
1533
-		if(is_array($parameters)) $i = & $parameters['i'];
1534
-		else $i = (int)$parameters;
1615
+		if(is_array($parameters)) {
1616
+			$i = & $parameters['i'];
1617
+		} else {
1618
+			$i = (int)$parameters;
1619
+		}
1535 1620
 			
1536 1621
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1537 1622
 		{
@@ -1561,7 +1646,9 @@  discard block
 block discarded – undo
1561 1646
 				}
1562 1647
 			}
1563 1648
 			
1564
-			if (!empty($TLineTitle)) $TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1649
+			if (!empty($TLineTitle)) {
1650
+				$TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1651
+			}
1565 1652
 		}
1566 1653
 		
1567 1654
 	}
@@ -1575,8 +1662,12 @@  discard block
 block discarded – undo
1575 1662
 		$j=0;
1576 1663
 		foreach ($TLineTitle as $k => &$line)
1577 1664
 		{
1578
-			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
1579
-			if (!empty($line_reference) && $line->qty <= $line_reference->qty) break;
1665
+			if (!empty($line_reference) && $line->rang <= $line_reference->rang) {
1666
+				continue;
1667
+			}
1668
+			if (!empty($line_reference) && $line->qty <= $line_reference->qty) {
1669
+				break;
1670
+			}
1580 1671
 			
1581 1672
 			if ($line->qty == $level)
1582 1673
 			{
@@ -1610,7 +1701,9 @@  discard block
 block discarded – undo
1610 1701
 		
1611 1702
 		$hidedetails = (int)GETPOST('hidedetails');
1612 1703
 		
1613
-		if(empty($hidedetails)) return false;
1704
+		if(empty($hidedetails)) {
1705
+			return false;
1706
+		}
1614 1707
 		
1615 1708
 		// TODO can't add VAT to document without lines... :-/
1616 1709
 		
@@ -1638,7 +1731,9 @@  discard block
 block discarded – undo
1638 1731
         foreach($object->lines as $k => &$l) {
1639 1732
             if(TSubtotal::isSubtotal($l)) {
1640 1733
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1641
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1734
+                if(is_object($parentTitle) && empty($parentTitle->array_options)) {
1735
+                	$parentTitle->fetch_optionals();
1736
+                }
1642 1737
                 if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_total_ht'])) {
1643 1738
                     $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1644 1739
                 }
@@ -1680,7 +1775,9 @@  discard block
 block discarded – undo
1680 1775
 						*/
1681 1776
 						list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
1682 1777
 						
1683
-						if (TSubtotal::getNiveau($line) == 1) $line->TTotal_tva = $TTotal_tva;
1778
+						if (TSubtotal::getNiveau($line) == 1) {
1779
+							$line->TTotal_tva = $TTotal_tva;
1780
+						}
1684 1781
 						$line->total_ht = $total;
1685 1782
 						$line->total_tva = $total_tva;
1686 1783
 						$line->total = $line->total_ht;
@@ -1744,8 +1841,7 @@  discard block
 block discarded – undo
1744 1841
 				    }
1745 1842
 				    
1746 1843
 					
1747
-				}
1748
-				elseif ($hidedetails)
1844
+				} elseif ($hidedetails)
1749 1845
 				{
1750 1846
 					$TLines[] = $line; //Cas où je cache uniquement les prix des produits	
1751 1847
 				}
@@ -1816,13 +1912,17 @@  discard block
 block discarded – undo
1816 1912
 				
1817 1913
 				if(!empty($hideprices)) {
1818 1914
 					foreach($object->lines as &$line) {
1819
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1915
+						if($line->fk_product_type!=9) {
1916
+							$line->fk_parent_line = -1;
1917
+						}
1820 1918
 					}
1821 1919
 				}
1822 1920
 			
1823 1921
 				$line = &$object->lines[$i];
1824 1922
 
1825
-				if($object->element == 'delivery' && ! empty($object->commande->expeditions[$line->fk_origin_line])) unset($object->commande->expeditions[$line->fk_origin_line]);
1923
+				if($object->element == 'delivery' && ! empty($object->commande->expeditions[$line->fk_origin_line])) {
1924
+					unset($object->commande->expeditions[$line->fk_origin_line]);
1925
+				}
1826 1926
 
1827 1927
 				if($line->info_bits>0) { // PAGE BREAK
1828 1928
 					$pdf->addPage();
@@ -1838,7 +1938,9 @@  discard block
 block discarded – undo
1838 1938
 				}
1839 1939
 
1840 1940
 				if($line->qty>90) {
1841
-					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1941
+					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) {
1942
+						$label .= ' '.$this->getTitle($object, $line);
1943
+					}
1842 1944
 					
1843 1945
 					$pageBefore = $pdf->getPage();
1844 1946
 					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
@@ -1876,8 +1978,7 @@  discard block
 block discarded – undo
1876 1978
 				
1877 1979
 					$posy = $pdf->GetY();
1878 1980
 					return 1;
1879
-				}	
1880
-				else if ($line->qty < 10) {
1981
+				} else if ($line->qty < 10) {
1881 1982
 					$pageBefore = $pdf->getPage();
1882 1983
 
1883 1984
 					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
@@ -1907,8 +2008,7 @@  discard block
 block discarded – undo
1907 2008
 //	if($line->rowid==47) exit;
1908 2009
 			
1909 2010
 			return 0;
1910
-		}
1911
-		elseif (empty($object->lines[$parameters['i']]))
2011
+		} elseif (empty($object->lines[$parameters['i']]))
1912 2012
 		{
1913 2013
 			$this->resprints = -1;
1914 2014
 		}
@@ -1941,7 +2041,9 @@  discard block
 block discarded – undo
1941 2041
 		
1942 2042
 		foreach ($object->lines as $line)
1943 2043
 		{
1944
-			if ($line->id == $currentLine->id) break;
2044
+			if ($line->id == $currentLine->id) {
2045
+				break;
2046
+			}
1945 2047
 			
1946 2048
 			$qty_search = 100 - $currentLine->qty;
1947 2049
 			
@@ -1980,22 +2082,18 @@  discard block
 block discarded – undo
1980 2082
 		{
1981 2083
 			$object->statut = 0; // hack for facture rec
1982 2084
 			$createRight = $user->rights->facture->creer;
1983
-		}
1984
-		elseif($object->element == 'order_supplier' )
2085
+		} elseif($object->element == 'order_supplier' )
1985 2086
 		{
1986 2087
 		    $createRight = $user->rights->fournisseur->commande->creer;
1987
-		}
1988
-		elseif($object->element == 'invoice_supplier' )
2088
+		} elseif($object->element == 'invoice_supplier' )
1989 2089
 		{
1990 2090
 		    $createRight = $user->rights->fournisseur->facture->creer;
1991
-		}
1992
-		elseif($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
2091
+		} elseif($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
1993 2092
 		{
1994 2093
 			// H4cK 4n0nYm0u$-style : $line n'est pas un objet instancié mais provient d'un fetch_object d'une requête SQL
1995 2094
 			$line->id = $line->rowid;
1996 2095
 			$line->product_type = $line->type;
1997
-		}
1998
-		elseif($object->element == 'shipping' || $object->element == 'delivery')
2096
+		} elseif($object->element == 'shipping' || $object->element == 'delivery')
1999 2097
 		{
2000 2098
 			if(empty($line->origin_line_id) && ! empty($line->fk_origin_line))
2001 2099
 			{
@@ -2018,11 +2116,13 @@  discard block
 block discarded – undo
2018 2116
 
2019 2117
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
2020 2118
 			null;
2021
-		}
2022
-		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)) 
2119
+		} 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)) 
2023 2120
         {
2024
-			if($object->element=='facture')$idvar = 'facid';
2025
-			else $idvar='id';
2121
+			if($object->element=='facture') {
2122
+				$idvar = 'facid';
2123
+			} else {
2124
+				$idvar='id';
2125
+			}
2026 2126
 
2027 2127
 			if((float)DOL_VERSION <= 3.4)
2028 2128
 			{
@@ -2048,22 +2148,44 @@  discard block
 block discarded – undo
2048 2148
 				<?php
2049 2149
 			}
2050 2150
 			
2051
-			if(empty($line->description)) $line->description = $line->desc;
2151
+			if(empty($line->description)) {
2152
+				$line->description = $line->desc;
2153
+			}
2052 2154
 			
2053 2155
 			$colspan = 5;
2054
-			if($object->element == 'facturerec' ) $colspan = 3;
2055
-			if($object->element == 'order_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
2056
-			if($object->element == 'invoice_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7;
2057
-			if($object->element == 'supplier_proposal') (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2156
+			if($object->element == 'facturerec' ) {
2157
+				$colspan = 3;
2158
+			}
2159
+			if($object->element == 'order_supplier') {
2160
+				(float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
2161
+			}
2162
+			if($object->element == 'invoice_supplier') {
2163
+				(float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7;
2164
+			}
2165
+			if($object->element == 'supplier_proposal') {
2166
+				(float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2167
+			}
2058 2168
 			if(!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
2059 2169
 				$colspan++; // Colonne PU Devise
2060 2170
 			}
2061
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
2062
-			if(!empty($conf->margin->enabled)) $colspan++;
2063
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
2064
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
2065
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
2066
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
2171
+			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) {
2172
+				$colspan++;
2173
+			}
2174
+			if(!empty($conf->margin->enabled)) {
2175
+				$colspan++;
2176
+			}
2177
+			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) {
2178
+				$colspan++;
2179
+			}
2180
+			if(!empty($conf->global->DISPLAY_MARK_RATES)) {
2181
+				$colspan++;
2182
+			}
2183
+			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) {
2184
+				$colspan++;
2185
+			}
2186
+			if(!empty($conf->global->PRODUCT_USE_UNITS)) {
2187
+				$colspan++;
2188
+			}
2067 2189
 					
2068 2190
 			/* Titre */
2069 2191
 			//var_dump($line);
@@ -2076,23 +2198,36 @@  discard block
 block discarded – undo
2076 2198
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2077 2199
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2078 2200
 					{
2079
-						if($line->qty==99) print 'background:#adadcf';
2080
-						else if($line->qty==98) print 'background:#ddddff;';
2081
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2082
-						else if($line->qty==1) print 'background:#adadcf;';
2083
-						else if($line->qty==2) print 'background:#ddddff;';
2084
-						else if($line->qty==50) print '';
2085
-						else print 'background:#eeeeff;';
2201
+						if($line->qty==99) {
2202
+							print 'background:#adadcf';
2203
+						} else if($line->qty==98) {
2204
+							print 'background:#ddddff;';
2205
+						} else if($line->qty<=97 && $line->qty>=91) {
2206
+							print 'background:#eeeeff;';
2207
+						} else if($line->qty==1) {
2208
+							print 'background:#adadcf;';
2209
+						} else if($line->qty==2) {
2210
+							print 'background:#ddddff;';
2211
+						} else if($line->qty==50) {
2212
+							print '';
2213
+						} else {
2214
+							print 'background:#eeeeff;';
2215
+						}
2086 2216
 
2087 2217
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2088
-					}
2089
-					else 
2218
+					} else 
2090 2219
 					{
2091
-						if($line->qty==99) print 'background:#ddffdd';
2092
-						else if($line->qty==98) print 'background:#ddddff;';
2093
-						else if($line->qty==2) print 'background:#eeeeff; ';
2094
-						else if($line->qty==50) print '';
2095
-						else print 'background:#eeffee;' ;
2220
+						if($line->qty==99) {
2221
+							print 'background:#ddffdd';
2222
+						} else if($line->qty==98) {
2223
+							print 'background:#ddddff;';
2224
+						} else if($line->qty==2) {
2225
+							print 'background:#eeeeff; ';
2226
+						} else if($line->qty==50) {
2227
+							print '';
2228
+						} else {
2229
+							print 'background:#eeffee;' ;
2230
+						}
2096 2231
 					}
2097 2232
 
2098 2233
 			?>;">
@@ -2119,13 +2254,11 @@  discard block
 block discarded – undo
2119 2254
 							$qty_displayed = $line->qty;
2120 2255
 							print img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
2121 2256
 							
2122
-						}
2123
-						else if (TSubtotal::isSubtotal($line))
2257
+						} else if (TSubtotal::isSubtotal($line))
2124 2258
 						{
2125 2259
 							$qty_displayed = 100 - $line->qty;
2126 2260
 							print img_picto('', 'subsubtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
2127
-						}
2128
-						else
2261
+						} else
2129 2262
 						{
2130 2263
 							$isFreeText = true;
2131 2264
 						}
@@ -2146,9 +2279,13 @@  discard block
 block discarded – undo
2146 2279
 						}
2147 2280
 
2148 2281
 						$readonlyForSituation = '';
2149
-						if (!empty($line->fk_prev_id) && $line->fk_prev_id != null) $readonlyForSituation = 'readonly';
2282
+						if (!empty($line->fk_prev_id) && $line->fk_prev_id != null) {
2283
+							$readonlyForSituation = 'readonly';
2284
+						}
2150 2285
 						
2151
-						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2286
+						if (!$isFreeText) {
2287
+							echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2288
+						}
2152 2289
 						
2153 2290
 						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
2154 2291
 						{
@@ -2156,8 +2293,12 @@  discard block
 block discarded – undo
2156 2293
 							for ($j=1; $j<10; $j++)
2157 2294
 							{
2158 2295
 								if (!empty($readonlyForSituation)) {
2159
-									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2160
-								} else $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2296
+									if ($qty_displayed == $j) {
2297
+										$select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2298
+									}
2299
+								} else {
2300
+									$select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2301
+								}
2161 2302
 							}
2162 2303
 							$select .= '</select>&nbsp;';
2163 2304
 
@@ -2177,7 +2318,9 @@  discard block
 block discarded – undo
2177 2318
                             echo '<div>';
2178 2319
                             echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2179 2320
                             echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2180
-                            if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2321
+                            if (empty($readonlyForSituation)) {
2322
+                            	echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2323
+                            }
2181 2324
                             echo '</select>';
2182 2325
                             echo '</div>';
2183 2326
 
@@ -2196,8 +2339,9 @@  discard block
 block discarded – undo
2196 2339
                             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;';
2197 2340
                             echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2198 2341
                             echo '</div>';
2342
+                        } else if ($isFreeText) {
2343
+                        	echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2199 2344
                         }
2200
-                        else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2201 2345
 						echo '</div>';
2202 2346
 
2203 2347
 						if($line->qty<10) {
@@ -2217,8 +2361,7 @@  discard block
 block discarded – undo
2217 2361
 							$doleditor->Create();
2218 2362
 						}
2219 2363
 						
2220
-					}
2221
-					else {
2364
+					} else {
2222 2365
 
2223 2366
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2224 2367
 						 {
@@ -2226,14 +2369,19 @@  discard block
 block discarded – undo
2226 2369
 							{
2227 2370
 								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2228 2371
 								
2229
-								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2230
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2372
+								if (TSubtotal::isTitle($line)) {
2373
+									print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2374
+								} else {
2375
+									print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2376
+								}
2231 2377
 							}
2232
-						 }
2233
-						 else 
2378
+						 } else 
2234 2379
 						 {
2235
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2236
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2380
+							if($line->qty<=1) {
2381
+								print img_picto('', 'subtotal@subtotal');
2382
+							} else if($line->qty==2) {
2383
+								print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2384
+							}
2237 2385
 						 }
2238 2386
 						 
2239 2387
 						 
@@ -2243,21 +2391,26 @@  discard block
 block discarded – undo
2243 2391
 						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2244 2392
 						 
2245 2393
 						 if (empty($line->label)) {
2246
-							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2247
-							else print  $line->description;
2248
-						 } 
2249
-						 else {
2394
+							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2395
+								print  $line->description.' '.$this->getTitle($object, $line);
2396
+							} else {
2397
+								print  $line->description;
2398
+							}
2399
+						 } else {
2250 2400
 
2251 2401
 							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2252 2402
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2253
-							}
2254
-							else{
2403
+							} else{
2255 2404
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
2256 2405
 							}
2257 2406
 
2258 2407
 						 } 
2259
-						if($line->qty>90) print ' : ';
2260
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2408
+						if($line->qty>90) {
2409
+							print ' : ';
2410
+						}
2411
+						if($line->info_bits > 0) {
2412
+							echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2413
+						}
2261 2414
 
2262 2415
 						 
2263 2416
 
@@ -2300,11 +2453,12 @@  discard block
 block discarded – undo
2300 2453
 						</script>
2301 2454
 						<?php
2302 2455
 						
2303
-					}
2304
-					else{
2456
+					} else{
2305 2457
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2306 2458
 						{
2307
-							if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2459
+							if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) {
2460
+								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2461
+							}
2308 2462
 						}
2309 2463
 
2310 2464
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
@@ -2394,7 +2548,9 @@  discard block
 block discarded – undo
2394 2548
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2395 2549
 				
2396 2550
 				$colspan+=3; $mode = 'view';
2397
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2551
+				if($action === 'editline' && $line->rowid == GETPOST('lineid')) {
2552
+					$mode = 'edit';
2553
+				}
2398 2554
 				
2399 2555
 				$ex_element = $line->element;
2400 2556
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
@@ -2453,8 +2609,7 @@  discard block
 block discarded – undo
2453 2609
 			
2454 2610
 			return 1;	
2455 2611
 			
2456
-		}
2457
-		elseif(($object->element == 'commande' && in_array('ordershipmentcard', $contexts)) || (in_array('expeditioncard', $contexts) && $action == 'create'))
2612
+		} elseif(($object->element == 'commande' && in_array('ordershipmentcard', $contexts)) || (in_array('expeditioncard', $contexts) && $action == 'create'))
2458 2613
 		{
2459 2614
 			$colspan = 4;
2460 2615
 
@@ -2464,23 +2619,36 @@  discard block
 block discarded – undo
2464 2619
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2465 2620
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2466 2621
 					{
2467
-						if($line->qty==99) print 'background:#adadcf';
2468
-						else if($line->qty==98) print 'background:#ddddff;';
2469
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2470
-						else if($line->qty==1) print 'background:#adadcf;';
2471
-						else if($line->qty==2) print 'background:#ddddff;';
2472
-						else if($line->qty==50) print '';
2473
-						else print 'background:#eeeeff;';
2622
+						if($line->qty==99) {
2623
+							print 'background:#adadcf';
2624
+						} else if($line->qty==98) {
2625
+							print 'background:#ddddff;';
2626
+						} else if($line->qty<=97 && $line->qty>=91) {
2627
+							print 'background:#eeeeff;';
2628
+						} else if($line->qty==1) {
2629
+							print 'background:#adadcf;';
2630
+						} else if($line->qty==2) {
2631
+							print 'background:#ddddff;';
2632
+						} else if($line->qty==50) {
2633
+							print '';
2634
+						} else {
2635
+							print 'background:#eeeeff;';
2636
+						}
2474 2637
 
2475 2638
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2476
-					}
2477
-					else
2639
+					} else
2478 2640
 					{
2479
-						if($line->qty==99) print 'background:#ddffdd';
2480
-						else if($line->qty==98) print 'background:#ddddff;';
2481
-						else if($line->qty==2) print 'background:#eeeeff; ';
2482
-						else if($line->qty==50) print '';
2483
-						else print 'background:#eeffee;' ;
2641
+						if($line->qty==99) {
2642
+							print 'background:#ddffdd';
2643
+						} else if($line->qty==98) {
2644
+							print 'background:#ddddff;';
2645
+						} else if($line->qty==2) {
2646
+							print 'background:#eeeeff; ';
2647
+						} else if($line->qty==50) {
2648
+							print '';
2649
+						} else {
2650
+							print 'background:#eeffee;' ;
2651
+						}
2484 2652
 					}
2485 2653
 
2486 2654
 			?>;">
@@ -2494,14 +2662,19 @@  discard block
 block discarded – undo
2494 2662
 							{
2495 2663
 								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2496 2664
 
2497
-								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2498
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2665
+								if (TSubtotal::isTitle($line)) {
2666
+									print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2667
+								} else {
2668
+									print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2669
+								}
2499 2670
 							}
2500
-						 }
2501
-						 else
2671
+						 } else
2502 2672
 						 {
2503
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2504
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2673
+							if($line->qty<=1) {
2674
+								print img_picto('', 'subtotal@subtotal');
2675
+							} else if($line->qty==2) {
2676
+								print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2677
+							}
2505 2678
 						 }
2506 2679
 
2507 2680
 
@@ -2511,21 +2684,24 @@  discard block
 block discarded – undo
2511 2684
 						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2512 2685
 
2513 2686
 						 if (empty($line->label)) {
2514
-							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2515
-							else print  $line->description;
2516
-						 }
2517
-						 else {
2687
+							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2688
+								print  $line->description.' '.$this->getTitle($object, $line);
2689
+							} else {
2690
+								print  $line->description;
2691
+							}
2692
+						 } else {
2518 2693
 
2519 2694
 							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2520 2695
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2521
-							}
2522
-							else{
2696
+							} else{
2523 2697
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2524 2698
 							}
2525 2699
 
2526 2700
 						 }
2527 2701
 						//if($line->qty>90) print ' : ';
2528
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2702
+						if($line->info_bits > 0) {
2703
+							echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2704
+						}
2529 2705
 
2530 2706
 			?>
2531 2707
 				</td>
@@ -2548,8 +2724,7 @@  discard block
 block discarded – undo
2548 2724
 			</tr>
2549 2725
 <?php
2550 2726
 			return 1;
2551
-		}
2552
-		elseif ($object->element == 'shipping' || $object->element == 'delivery')
2727
+		} elseif ($object->element == 'shipping' || $object->element == 'delivery')
2553 2728
 		{
2554 2729
 			global $form;
2555 2730
 
@@ -2561,13 +2736,25 @@  discard block
 block discarded – undo
2561 2736
 			$extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2562 2737
 
2563 2738
 			$colspan = 4;
2564
-			if($object->origin && $object->origin_id > 0) $colspan++;
2565
-			if(! empty($conf->stock->enabled)) $colspan++;
2566
-			if(! empty($conf->productbatch->enabled)) $colspan++;
2567
-			if($object->statut == 0) $colspan++;
2568
-			if($object->statut == 0 && empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) $colspan++;
2739
+			if($object->origin && $object->origin_id > 0) {
2740
+				$colspan++;
2741
+			}
2742
+			if(! empty($conf->stock->enabled)) {
2743
+				$colspan++;
2744
+			}
2745
+			if(! empty($conf->productbatch->enabled)) {
2746
+				$colspan++;
2747
+			}
2748
+			if($object->statut == 0) {
2749
+				$colspan++;
2750
+			}
2751
+			if($object->statut == 0 && empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) {
2752
+				$colspan++;
2753
+			}
2569 2754
 
2570
-			if($object->element == 'delivery') $colspan = 2;
2755
+			if($object->element == 'delivery') {
2756
+				$colspan = 2;
2757
+			}
2571 2758
 
2572 2759
 			print '<!-- origin line id = '.$line->origin_line_id.' -->'; // id of order line
2573 2760
 
@@ -2577,23 +2764,36 @@  discard block
 block discarded – undo
2577 2764
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2578 2765
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2579 2766
 					{
2580
-						if($line->qty==99) print 'background:#adadcf';
2581
-						else if($line->qty==98) print 'background:#ddddff;';
2582
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2583
-						else if($line->qty==1) print 'background:#adadcf;';
2584
-						else if($line->qty==2) print 'background:#ddddff;';
2585
-						else if($line->qty==50) print '';
2586
-						else print 'background:#eeeeff;';
2767
+						if($line->qty==99) {
2768
+							print 'background:#adadcf';
2769
+						} else if($line->qty==98) {
2770
+							print 'background:#ddddff;';
2771
+						} else if($line->qty<=97 && $line->qty>=91) {
2772
+							print 'background:#eeeeff;';
2773
+						} else if($line->qty==1) {
2774
+							print 'background:#adadcf;';
2775
+						} else if($line->qty==2) {
2776
+							print 'background:#ddddff;';
2777
+						} else if($line->qty==50) {
2778
+							print '';
2779
+						} else {
2780
+							print 'background:#eeeeff;';
2781
+						}
2587 2782
 
2588 2783
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2589
-					}
2590
-					else 
2784
+					} else 
2591 2785
 					{
2592
-						if($line->qty==99) print 'background:#ddffdd';
2593
-						else if($line->qty==98) print 'background:#ddddff;';
2594
-						else if($line->qty==2) print 'background:#eeeeff; ';
2595
-						else if($line->qty==50) print '';
2596
-						else print 'background:#eeffee;' ;
2786
+						if($line->qty==99) {
2787
+							print 'background:#ddffdd';
2788
+						} else if($line->qty==98) {
2789
+							print 'background:#ddddff;';
2790
+						} else if($line->qty==2) {
2791
+							print 'background:#eeeeff; ';
2792
+						} else if($line->qty==50) {
2793
+							print '';
2794
+						} else {
2795
+							print 'background:#eeffee;' ;
2796
+						}
2597 2797
 					}
2598 2798
 
2599 2799
 			?>;">
@@ -2615,14 +2815,19 @@  discard block
 block discarded – undo
2615 2815
 				{
2616 2816
 					echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2617 2817
 
2618
-					if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2619
-					else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2818
+					if (TSubtotal::isTitle($line)) {
2819
+						print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2820
+					} else {
2821
+						print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2822
+					}
2620 2823
 				}
2621
-			}
2622
-			else
2824
+			} else
2623 2825
 			{
2624
-				if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2625
-				else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2826
+				if($line->qty<=1) {
2827
+					print img_picto('', 'subtotal@subtotal');
2828
+				} else if($line->qty==2) {
2829
+					print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2830
+				}
2626 2831
 			}
2627 2832
 
2628 2833
 
@@ -2632,19 +2837,22 @@  discard block
 block discarded – undo
2632 2837
 			$titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2633 2838
 
2634 2839
 			if (empty($line->label)) {
2635
-				if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2636
-				else print  $line->description;
2637
-			}
2638
-			else {
2840
+				if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2841
+					print  $line->description.' '.$this->getTitle($object, $line);
2842
+				} else {
2843
+					print  $line->description;
2844
+				}
2845
+			} else {
2639 2846
 				if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2640 2847
 					print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2641
-				}
2642
-				else{
2848
+				} else{
2643 2849
 					print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2644 2850
 				}
2645 2851
 			}
2646 2852
 			//if($line->qty>90) print ' : ';
2647
-			if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2853
+			if($line->info_bits > 0) {
2854
+				echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2855
+			}
2648 2856
 
2649 2857
 			?>
2650 2858
 				</td>
@@ -2824,10 +3032,9 @@  discard block
 block discarded – undo
2824 3032
 	    
2825 3033
 	    if(TSubtotal::isTitle($line)){
2826 3034
 	        $ThtmlData['data-issubtotal'] = 'title';
2827
-	    }elseif(TSubtotal::isSubtotal($line)){
3035
+	    } elseif(TSubtotal::isSubtotal($line)){
2828 3036
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2829
-	    }
2830
-	    else{
3037
+	    } else{
2831 3038
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2832 3039
 	    }
2833 3040
 	    
@@ -2837,7 +3044,9 @@  discard block
 block discarded – undo
2837 3044
 	    
2838 3045
 	    // hook 
2839 3046
 	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2840
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
3047
+	    if ($reshook < 0) {
3048
+	    	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
3049
+	    }
2841 3050
 	    if ($reshook>0)
2842 3051
 	    {
2843 3052
 	        $ThtmlData = $hookmanager->resArray;
Please login to merge, or discard this patch.