Completed
Push — master ( 87d767...d40ffe )
by Alexis
12s queued 11s
created
admin/subtotal_setup.php 1 patch
Spacing   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -27,37 +27,37 @@  discard block
 block discarded – undo
27 27
 // Change this following line to use the correct relative path (../, ../../, etc)
28 28
 // Dolibarr environment
29 29
 $res = @include("../../main.inc.php"); // From htdocs directory
30
-if (! $res) {
30
+if (!$res) {
31 31
     $res = @include("../../../main.inc.php"); // From "custom" directory
32 32
 }
33 33
 
34 34
 // Libraries
35
-require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
35
+require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
36 36
 require_once '../lib/subtotal.lib.php';
37 37
 
38 38
 $langs->load("subtotal@subtotal");
39 39
 
40 40
 // Access control
41
-if (! $user->admin) {
41
+if (!$user->admin) {
42 42
     accessforbidden();
43 43
 }
44 44
 
45 45
 // Parameters
46 46
 $action = GETPOST('action', 'alpha');
47 47
 
48
-if($action=='save') {
48
+if ($action == 'save') {
49 49
 	
50
-	foreach($_REQUEST['TDivers'] as $name=>$param) {
50
+	foreach ($_REQUEST['TDivers'] as $name=>$param) {
51 51
 		
52
-		dolibarr_set_const($db, $name, $param,'chaine', 0, '', $conf->entity);
52
+		dolibarr_set_const($db, $name, $param, 'chaine', 0, '', $conf->entity);
53 53
 		
54 54
 	}
55 55
 	
56 56
 }
57 57
 
58
-if (preg_match('/set_(.*)/',$action,$reg))
58
+if (preg_match('/set_(.*)/', $action, $reg))
59 59
 {
60
-	$code=$reg[1];
60
+	$code = $reg[1];
61 61
 	$value = GETPOST($code);
62 62
 	if ($code == 'SUBTOTAL_TFIELD_TO_KEEP_WITH_NC') $value = implode(',', $value);
63 63
 	
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
 
84 84
 
85 85
 
86
-llxHeader('','Gestion de sous-total, à propos','');
86
+llxHeader('', 'Gestion de sous-total, à propos', '');
87 87
 
88
-$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
89
-print_fiche_titre('Gestion de subtotal',$linkback,'setup');
88
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
89
+print_fiche_titre('Gestion de subtotal', $linkback, 'setup');
90 90
 
91 91
 // Configuration header
92 92
 $head = subtotalAdminPrepareHead();
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 showParameters();
102 102
 
103 103
 function showParameters() {
104
-	global $db,$conf,$langs,$bc;
104
+	global $db, $conf, $langs, $bc;
105 105
 	
106
-	$html=new Form($db);
106
+	$html = new Form($db);
107 107
 	
108
-	$var=false;
108
+	$var = false;
109 109
 	print '<table class="noborder" width="100%">';
110 110
 	print '<tr class="liste_titre">';
111 111
 	print '<td>'.$langs->trans("Parameters").'</td>'."\n";
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
114 114
 	print '</tr>';
115 115
 	
116
-	$var=!$var;
116
+	$var = !$var;
117 117
 	print '<tr '.$bc[$var].'>';
118 118
 	print '<td>'.$langs->trans("SUBTOTAL_USE_NEW_FORMAT").'</td>';
119 119
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 	print ajax_constantonoff('SUBTOTAL_USE_NEW_FORMAT');
122 122
 	print '</td></tr>';
123 123
 	
124
-	if((float)DOL_VERSION>=3.8)
124
+	if ((float) DOL_VERSION >= 3.8)
125 125
 	{
126
-		$var=!$var;
126
+		$var = !$var;
127 127
 		print '<tr '.$bc[$var].'>';
128 128
 		print '<td>'.$langs->trans("SUBTOTAL_USE_NUMEROTATION").'</td>';
129 129
 		print '<td align="center" width="20">&nbsp;</td>';
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 		print '</td></tr>';	
133 133
 	}
134 134
 	
135
-	$var=!$var;
135
+	$var = !$var;
136 136
 	print '<tr '.$bc[$var].'>';
137 137
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_ADD_BLOCK").'</td>';
138 138
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	print ajax_constantonoff('SUBTOTAL_ALLOW_ADD_BLOCK');
141 141
 	print '</td></tr>';
142 142
 	
143
-	$var=!$var;
143
+	$var = !$var;
144 144
 	print '<tr '.$bc[$var].'>';
145 145
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_EDIT_BLOCK").'</td>';
146 146
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	print ajax_constantonoff('SUBTOTAL_ALLOW_EDIT_BLOCK');
149 149
 	print '</td></tr>';
150 150
 	
151
-	$var=!$var;
151
+	$var = !$var;
152 152
 	print '<tr '.$bc[$var].'>';
153 153
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_REMOVE_BLOCK").'</td>';
154 154
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	print ajax_constantonoff('SUBTOTAL_ALLOW_REMOVE_BLOCK');
157 157
 	print '</td></tr>';
158 158
 	
159
-	$var=!$var;
159
+	$var = !$var;
160 160
 	print '<tr '.$bc[$var].'>';
161 161
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_DUPLICATE_BLOCK").'</td>';
162 162
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	print ajax_constantonoff('SUBTOTAL_ALLOW_DUPLICATE_BLOCK');
165 165
 	print '</td></tr>';
166 166
 	
167
-	$var=!$var;
167
+	$var = !$var;
168 168
 	print '<tr '.$bc[$var].'>';
169 169
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_ADD_LINE_UNDER_TITLE").'</td>';
170 170
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	print ajax_constantonoff('SUBTOTAL_ALLOW_ADD_LINE_UNDER_TITLE');
173 173
 	print '</td></tr>';
174 174
 	
175
-	$var=!$var;
175
+	$var = !$var;
176 176
 	print '<tr '.$bc[$var].'>';
177 177
 	print '<td>'.$langs->trans("SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK").'</td>';
178 178
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	print ajax_constantonoff('SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK');
181 181
 	print '</td></tr>';
182 182
 
183
-	$var=!$var;
183
+	$var = !$var;
184 184
 	print '<tr '.$bc[$var].'>';
185 185
 	print '<td>'.$html->textwithpicto($langs->trans("SUBTOTAL_TEXT_FOR_TITLE_ORDETSTOINVOICE"), $langs->trans("SUBTOTAL_TEXT_FOR_TITLE_ORDETSTOINVOICE_info")).'</td>';
186 186
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	print '</form>';
194 194
 	print '</td></tr>';
195 195
 	
196
-	$var=!$var;
196
+	$var = !$var;
197 197
 	print '<tr '.$bc[$var].'>';
198 198
 	print '<td>'.$langs->trans("SUBTOTAL_TITLE_STYLE").'</td>';
199 199
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 	print '</form>';
207 207
 	print '</td></tr>';
208 208
 	
209
-	$var=!$var;
209
+	$var = !$var;
210 210
 	print '<tr '.$bc[$var].'>';
211 211
 	print '<td>'.$langs->trans("SUBTOTAL_SUBTOTAL_STYLE").'</td>';
212 212
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -219,7 +219,7 @@  discard block
 block discarded – undo
219 219
 	print '</form>';
220 220
 	print '</td></tr>';
221 221
 	
222
-	$var=!$var;
222
+	$var = !$var;
223 223
 	print '<tr '.$bc[$var].'>';
224 224
 	print '<td>'.$langs->trans("SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES", $langs->transnoentitiesnoconv('HideInnerLines')).'</td>';
225 225
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	print ajax_constantonoff('SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES');
228 228
 	print '</td></tr>';
229 229
 	
230
-	$var=!$var;
230
+	$var = !$var;
231 231
 	print '<tr '.$bc[$var].'>';
232 232
 	print '<td>'.$langs->trans("SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES", $langs->transnoentitiesnoconv('HideInnerLines')).'</td>';
233 233
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 	
238 238
 	if ((double) DOL_VERSION >= 4.0)
239 239
 	{
240
-		$var=!$var;
240
+		$var = !$var;
241 241
 		print '<tr '.$bc[$var].'>';
242 242
 		print '<td>'.$langs->trans("SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS").'</td>';
243 243
 		print '<td align="center" width="20">&nbsp;</td>';
@@ -245,12 +245,12 @@  discard block
 block discarded – undo
245 245
 		print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
246 246
 		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
247 247
 		print '<input type="hidden" name="action" value="set_SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS">';
248
-		print $html->selectyesno("SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS",$conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS,1);
248
+		print $html->selectyesno("SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS", $conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS, 1);
249 249
 		print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
250 250
 		print '</form>';
251 251
 		print '</td></tr>';
252 252
 		
253
-		$var=!$var;
253
+		$var = !$var;
254 254
 		print '<tr '.$bc[$var].'>';
255 255
 		print '<td>'.$langs->trans("SUBTOTAL_TFIELD_TO_KEEP_WITH_NC").'</td>';
256 256
 		print '<td align="center" width="20">&nbsp;</td>';
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
 		print '</td></tr>';
266 266
 	}
267 267
 	
268
-	$var=!$var;
268
+	$var = !$var;
269 269
 	print '<tr '.$bc[$var].'>';
270 270
 	print '<td>'.$langs->trans('SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE').'</td>';
271 271
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
 	print ajax_constantonoff('SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE');
274 274
 	print '</td></tr>';
275 275
 	
276
-	$var=!$var;
276
+	$var = !$var;
277 277
 	print '<tr '.$bc[$var].'>';
278 278
 	print '<td>'.$langs->trans('SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE').'</td>';
279 279
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	
286 286
 	
287 287
 	
288
-	$var=false;
288
+	$var = false;
289 289
 	print '<table class="noborder" width="100%">';
290 290
 	print '<tr class="liste_titre">';
291 291
 	print '<td>'.$langs->trans("RecapGeneration").'</td>'."\n";
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
294 294
 	print '</tr>';
295 295
 	
296
-	$var=!$var;
296
+	$var = !$var;
297 297
 	print '<tr '.$bc[$var].'>';
298 298
 	print '<td>'.$langs->trans('SUBTOTAL_KEEP_RECAP_FILE').'</td>';
299 299
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 	print ajax_constantonoff('SUBTOTAL_KEEP_RECAP_FILE');
302 302
 	print '</td></tr>';
303 303
 	
304
-	$var=!$var;
304
+	$var = !$var;
305 305
 	print '<tr '.$bc[$var].'>';
306 306
 	print '<td>'.$langs->trans('SUBTOTAL_PROPAL_ADD_RECAP').'</td>';
307 307
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	print ajax_constantonoff('SUBTOTAL_PROPAL_ADD_RECAP');
310 310
 	print '</td></tr>';
311 311
 	
312
-	$var=!$var;
312
+	$var = !$var;
313 313
 	print '<tr '.$bc[$var].'>';
314 314
 	print '<td>'.$langs->trans('SUBTOTAL_COMMANDE_ADD_RECAP').'</td>';
315 315
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 	print '</td></tr>';
319 319
 	
320 320
 	
321
-	$var=!$var;
321
+	$var = !$var;
322 322
 	print '<tr '.$bc[$var].'>';
323 323
 	print '<td>'.$langs->trans('SUBTOTAL_INVOICE_ADD_RECAP').'</td>';
324 324
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
 				<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
351 351
 					<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken'] ?>">
352 352
 					<input type="hidden" name="action" value="set_SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY" />
353
-					<?php echo $html->selectyesno("SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY",$conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY,1); ?>
353
+					<?php echo $html->selectyesno("SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY", $conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY, 1); ?>
354 354
 					<input type="submit" class="button" value="<?php echo $langs->trans("Modify") ?>">
355 355
 				</form>
356 356
 			</td>
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 				<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
363 363
 					<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken'] ?>">
364 364
 					<input type="hidden" name="action" value="set_SUBTOTAL_HIDE_DOCUMENT_TOTAL" />
365
-					<?php echo $html->selectyesno("SUBTOTAL_HIDE_DOCUMENT_TOTAL",$conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL,1); ?>
365
+					<?php echo $html->selectyesno("SUBTOTAL_HIDE_DOCUMENT_TOTAL", $conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL, 1); ?>
366 366
 					<input type="submit" class="button" value="<?php echo $langs->trans("Modify") ?>">
367 367
 				</form>
368 368
 			</td>				
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 					<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
376 376
 						<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken'] ?>">
377 377
 						<input type="hidden" name="action" value="set_SUBTOTAL_SHOW_QTY_ON_TITLES" />
378
-						<?php echo $html->selectyesno("SUBTOTAL_SHOW_QTY_ON_TITLES",$conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES,1); ?>
378
+						<?php echo $html->selectyesno("SUBTOTAL_SHOW_QTY_ON_TITLES", $conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES, 1); ?>
379 379
 						<input type="submit" class="button" value="<?php echo $langs->trans("Modify") ?>">
380 380
 					</form>
381 381
 				</td>				
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 					<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
388 388
 						<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken'] ?>">
389 389
 						<input type="hidden" name="action" value="set_SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES" />
390
-						<?php echo $html->selectyesno("SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES",$conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES,1); ?>
390
+						<?php echo $html->selectyesno("SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES", $conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES, 1); ?>
391 391
 						<input type="submit" class="button" value="<?php echo $langs->trans("Modify") ?>">
392 392
 					</form>
393 393
 				</td>				
Please login to merge, or discard this patch.
class/actions_subtotal.class.php 3 patches
Indentation   +209 added lines, -209 removed lines patch added patch discarded remove patch
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
 	 * @return     void
48 48
 	 */
49 49
     
50
-    var $module_number = 104777;
50
+	var $module_number = 104777;
51 51
     
52
-    function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
53
-    {
54
-      	global $langs,$db,$user, $conf;
52
+	function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
53
+	{
54
+	  	global $langs,$db,$user, $conf;
55 55
 		
56 56
 		$langs->load('subtotal@subtotal');
57 57
 		
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 				$createRight = $user->rights->facture->creer;
67 67
 			} elseif($object->element == 'order_supplier' )
68 68
 			{
69
-			    $createRight = $user->rights->fournisseur->commande->creer;
69
+				$createRight = $user->rights->fournisseur->commande->creer;
70 70
 			} elseif($object->element == 'invoice_supplier' )
71 71
 			{
72
-			    $createRight = $user->rights->fournisseur->facture->creer;
72
+				$createRight = $user->rights->fournisseur->facture->creer;
73 73
 			}
74 74
 			
75 75
 			if ($object->statut == 0  && $createRight) {
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 					
120 120
 					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
121 121
 					
122
-	    			TSubtotal::addSubTotalLine($object, $title, $qty);
122
+					TSubtotal::addSubTotalLine($object, $title, $qty);
123 123
 				}
124 124
 				else if($action==='ask_deleteallline') {
125 125
 						$form=new Form($db);
@@ -341,36 +341,36 @@  discard block
 block discarded – undo
341 341
 		$TContext = explode(':',$parameters['context']);
342 342
 		if (
343 343
 				in_array('invoicecard',$TContext)
344
-		        || in_array('invoicesuppliercard',$TContext)
344
+				|| in_array('invoicesuppliercard',$TContext)
345 345
 				|| in_array('propalcard',$TContext)
346 346
 				|| in_array('ordercard',$TContext)
347
-		        || in_array('ordersuppliercard',$TContext)
347
+				|| in_array('ordersuppliercard',$TContext)
348 348
 				|| in_array('invoicereccard',$TContext)
349 349
 			)
350
-	        {	
350
+			{	
351 351
 				$hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] : 0;
352 352
 				$hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] : 0;
353 353
 				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0;
354 354
 				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] : $hidepricesDefaultConf;
355 355
 				
356 356
 				$var=false;
357
-		     	$out.= '<tr '.$bc[$var].'>
357
+			 	$out.= '<tr '.$bc[$var].'>
358 358
 		     			<td colspan="4" align="right">
359 359
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
360 360
 		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
361 361
 		     			</td>
362 362
 		     			</tr>';
363 363
 				
364
-		     	$var=!$var;
365
-		     	$out.= '<tr '.$bc[$var].'>
364
+			 	$var=!$var;
365
+			 	$out.= '<tr '.$bc[$var].'>
366 366
 		     			<td colspan="4" align="right">
367 367
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
368 368
 		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
369 369
 		     			</td>
370 370
 		     			</tr>';
371 371
 		     	
372
-		     	$var=!$var;
373
-		     	$out.= '<tr '.$bc[$var].'>
372
+			 	$var=!$var;
373
+			 	$out.= '<tr '.$bc[$var].'>
374 374
 		     			<td colspan="4" align="right">
375 375
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidePrice').'</label>
376 376
 		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
@@ -382,9 +382,9 @@  discard block
 block discarded – undo
382 382
 				if ( 
383 383
 					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
384 384
 					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
385
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
385
+					|| (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
386 386
 					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
387
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
387
+					|| (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
388 388
 					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
389 389
 				)
390 390
 				{
@@ -403,19 +403,19 @@  discard block
 block discarded – undo
403 403
 			}
404 404
 			
405 405
 		
406
-        return 1;
406
+		return 1;
407 407
 	} 
408 408
 	 
409
-    function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
410
-    {
409
+	function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
410
+	{
411 411
 		
412
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
413
-        {
412
+		if (in_array('invoicecard',explode(':',$parameters['context'])))
413
+		{
414 414
         	
415
-        }
415
+		}
416 416
 		
417
-        return 0;
418
-    }
417
+		return 0;
418
+	}
419 419
 	
420 420
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
421 421
 		global $conf;
@@ -464,11 +464,11 @@  discard block
 block discarded – undo
464 464
 	
465 465
 		if (
466 466
 				in_array('invoicecard',explode(':',$parameters['context']))
467
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
467
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
468 468
 				|| in_array('propalcard',explode(':',$parameters['context']))
469
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
469
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
470 470
 				|| in_array('ordercard',explode(':',$parameters['context']))
471
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
471
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
472 472
 				|| in_array('invoicereccard',explode(':',$parameters['context']))
473 473
 		) {
474 474
 			
@@ -547,20 +547,20 @@  discard block
 block discarded – undo
547 547
 				in_array('invoicecard',explode(':',$parameters['context']))
548 548
 				|| in_array('propalcard',explode(':',$parameters['context']))
549 549
 				|| in_array('ordercard',explode(':',$parameters['context']))
550
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
551
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
552
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
550
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
551
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
552
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
553 553
 			)
554
-	        {								
554
+			{								
555 555
 				if(in_array('invoicecard',explode(':',$parameters['context']))) {
556 556
 					$sessname = 'subtotal_hideInnerLines_facture';	
557 557
 					$sessname2 = 'subtotal_hidedetails_facture';
558 558
 					$sessname3 = 'subtotal_hideprices_facture';
559 559
 				}
560 560
 				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
561
-				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
562
-				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
563
-				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
561
+					$sessname = 'subtotal_hideInnerLines_facture_fournisseur';
562
+					$sessname2 = 'subtotal_hidedetails_facture_fournisseur';
563
+					$sessname3 = 'subtotal_hideprices_facture_fournisseur';
564 564
 				}
565 565
 				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
566 566
 					$sessname = 'subtotal_hideInnerLines_propal';
@@ -568,9 +568,9 @@  discard block
 block discarded – undo
568 568
 					$sessname3 = 'subtotal_hideprices_propal';
569 569
 				}
570 570
 				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
571
-				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
572
-				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
573
-				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
571
+					$sessname = 'subtotal_hideInnerLines_supplier_proposal';
572
+					$sessname2 = 'subtotal_hidedetails_supplier_proposal';
573
+					$sessname3 = 'subtotal_hideprices_supplier_proposal';
574 574
 				}
575 575
 				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
576 576
 					$sessname = 'subtotal_hideInnerLines_commande';
@@ -578,9 +578,9 @@  discard block
 block discarded – undo
578 578
 					$sessname3 = 'subtotal_hideprices_commande';
579 579
 				}
580 580
 				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
581
-				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
582
-				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
583
-				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
581
+					$sessname = 'subtotal_hideInnerLines_commande_fournisseur';
582
+					$sessname2 = 'subtotal_hidedetails_commande_fournisseur';
583
+					$sessname3 = 'subtotal_hideprices_commande_fournisseur';
584 584
 				}
585 585
 				else {
586 586
 					$sessname = 'subtotal_hideInnerLines_unknown';
@@ -602,17 +602,17 @@  discard block
 block discarded – undo
602 602
 				foreach($object->lines as &$line) {
603 603
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
604 604
 					    
605
-                        if($line->qty>=90) {
606
-                            $line->modsubtotal_total = 1;
607
-                        }
608
-                        else{
609
-                            $line->modsubtotal_title = 1;
610
-                        }
605
+						if($line->qty>=90) {
606
+							$line->modsubtotal_total = 1;
607
+						}
608
+						else{
609
+							$line->modsubtotal_title = 1;
610
+						}
611 611
                         
612 612
 						$line->total_ht = $this->getTotalLineFromObject($object, $line, '');
613 613
 					}
614
-	        	}
615
-	        }
614
+				}
615
+			}
616 616
 			
617 617
 		}
618 618
 		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 				 */
630 630
 				else if($object->element=='invoice_supplier')
631 631
 				{
632
-				    $object->deleteline($idLine);
632
+					$object->deleteline($idLine);
633 633
 				}
634 634
 				/**
635 635
 				 * @var $object Propal
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 				 */
653 653
 				else if($object->element=='order_supplier')
654 654
 				{
655
-				    $object->deleteline($idLine);
655
+					$object->deleteline($idLine);
656 656
 				}
657 657
 				/**
658 658
 				 * @var $object Facturerec
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 		
697 697
 		foreach($object->lines as $l) {
698 698
 		
699
-		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
699
+			$lid = (!empty($l->rowid) ? $l->rowid : $l->id);
700 700
 			if($lid == $lineid) {
701 701
 
702 702
 				$found = true;
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 			
706 706
 			if($found) {
707 707
 				
708
-			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
708
+				$Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
709 709
 				
710 710
 				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
711 711
 					break; // end of story
@@ -784,17 +784,17 @@  discard block
 block discarded – undo
784 784
 			if($l->rang>=$rang) {
785 785
 				return price($total);
786 786
 			}
787
-                        if (TSubtotal::isSubtotal($l)){
788
-                            $total = 0;
789
-                        } else  if ($l->situation_percent > 0 ){
787
+						if (TSubtotal::isSubtotal($l)){
788
+							$total = 0;
789
+						} else  if ($l->situation_percent > 0 ){
790 790
                            
791 791
         	
792 792
 		 	$prev_progress = $l->get_prev_progress($object->id);
793 793
 		 	$progress = ($l->situation_percent - $prev_progress) /100;
794
-                        $total += ($l->total_ht/($l->situation_percent/100)) * $progress;
794
+						$total += ($l->total_ht/($l->situation_percent/100)) * $progress;
795 795
                         
796
-                    }
797
-                }
796
+					}
797
+				}
798 798
                 
799 799
 		return price($total);
800 800
 	}
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
 		if(method_exists('Closure','bind')) {
827 827
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
828 828
 			$sweetsThief = function ($pdf) {
829
-		    		return $pdf->bMargin ;
829
+					return $pdf->bMargin ;
830 830
 			};
831 831
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
832 832
 	
@@ -889,11 +889,11 @@  discard block
 block discarded – undo
889 889
 				else
890 890
 				{
891 891
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
892
-                                        if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
893
-                                                $total_to_print = $this->getTotalToPrintSituation($object, $line);
894
-                                        } else {
895
-                                            	$total_to_print = price($total);
896
-                                        }
892
+										if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
893
+												$total_to_print = $this->getTotalToPrintSituation($object, $line);
894
+										} else {
895
+												$total_to_print = price($total);
896
+										}
897 897
                                             
898 898
 					$line->total_ht = $total;
899 899
 					$line->total = $total;
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 	}
1045 1045
 	
1046 1046
 	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1047
-	    global $conf, $hideprices;
1047
+		global $conf, $hideprices;
1048 1048
 		
1049 1049
 		if($this->isModSubtotalLine($parameters,$object) ){
1050 1050
 			
@@ -1083,33 +1083,33 @@  discard block
 block discarded – undo
1083 1083
 			}
1084 1084
 		}
1085 1085
 		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1086
-		    if(is_array($parameters)) $i = & $parameters['i'];
1087
-		    else $i = (int)$parameters;
1088
-		    $this->resprints = price($object->lines[$i]->total_ht);
1086
+			if(is_array($parameters)) $i = & $parameters['i'];
1087
+			else $i = (int)$parameters;
1088
+			$this->resprints = price($object->lines[$i]->total_ht);
1089 1089
 		}
1090 1090
 		if (!empty($hideprices)
1091
-		    || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1092
-		    )
1091
+			|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1092
+			)
1093 1093
 		{
1094
-		    if (!empty($hideprices))
1095
-		    {
1094
+			if (!empty($hideprices))
1095
+			{
1096 1096
 		        
1097
-		        if(is_array($parameters)) $i = & $parameters['i'];
1098
-		        else $i = (int)$parameters;
1097
+				if(is_array($parameters)) $i = & $parameters['i'];
1098
+				else $i = (int)$parameters;
1099 1099
 		        
1100
-		        // Check if a title exist for this line && if the title have subtotal
1101
-		        $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1102
-		        if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1103
-		        {
1104
-		            $this->resprints = ' ';
1105
-		            return 1;
1106
-		        }
1107
-		    }
1108
-		    elseif (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1109
-		    {
1110
-		        $this->resprints = ' ';
1111
-		        return 1;
1112
-		    }
1100
+				// Check if a title exist for this line && if the title have subtotal
1101
+				$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1102
+				if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1103
+				{
1104
+					$this->resprints = ' ';
1105
+					return 1;
1106
+				}
1107
+			}
1108
+			elseif (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1109
+			{
1110
+				$this->resprints = ' ';
1111
+				return 1;
1112
+			}
1113 1113
 		}
1114 1114
         
1115 1115
 		return 0;
@@ -1389,11 +1389,11 @@  discard block
 block discarded – undo
1389 1389
 		$hidedetails = (int)GETPOST('hidedetails');
1390 1390
 		
1391 1391
 		if ($hideInnerLines) { // si c une ligne de titre
1392
-	    	$fk_parent_line=0;
1392
+			$fk_parent_line=0;
1393 1393
 			$TLines =array();
1394 1394
 		
1395 1395
 			$original_count=count($object->lines);
1396
-		    $TTvas = array(); // tableau de tva
1396
+			$TTvas = array(); // tableau de tva
1397 1397
 		    
1398 1398
 			foreach($object->lines as $k=>&$line) 
1399 1399
 			{
@@ -1423,48 +1423,48 @@  discard block
 block discarded – undo
1423 1423
 			
1424 1424
 				if ($hideInnerLines)
1425 1425
 				{
1426
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1427
-				    {
1428
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1426
+					if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1427
+					{
1428
+						if($line->tva_tx != '0.000' && $line->product_type!=9){
1429 1429
 				            
1430
-    				        // on remplit le tableau de tva pour substituer les lignes cachées
1431
-    				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1432
-    				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1433
-    				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1434
-    				    }
1435
-    					if($line->product_type==9 && $line->rowid>0)
1436
-    					{
1437
-    					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1438
-    					    // génère des lignes d'affichage des montants HT soumis à tva
1439
-    					    $nbtva = count($TTvas);
1440
-    					    if(!empty($nbtva)){
1441
-    					        foreach ($TTvas as $tx =>$val){
1442
-    					            $l = clone $line;
1443
-    					            $l->product_type = 1;
1444
-    					            $l->special_code = '';
1445
-    					            $l->qty = 1;
1446
-    					            $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1447
-    					            $l->tva_tx = $tx;
1448
-    					            $l->total_ht = $val['total_ht'];
1449
-    					            $l->total_tva = $val['total_tva'];
1450
-    					            $l->total = $line->total_ht;
1451
-    					            $l->total_ttc = $val['total_ttc'];
1452
-    					            $TLines[] = $l;
1453
-    					            array_shift($TTvas);
1454
-    					       }
1455
-    					    }
1430
+							// on remplit le tableau de tva pour substituer les lignes cachées
1431
+							$TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1432
+							$TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1433
+							$TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1434
+						}
1435
+						if($line->product_type==9 && $line->rowid>0)
1436
+						{
1437
+							//Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1438
+							// génère des lignes d'affichage des montants HT soumis à tva
1439
+							$nbtva = count($TTvas);
1440
+							if(!empty($nbtva)){
1441
+								foreach ($TTvas as $tx =>$val){
1442
+									$l = clone $line;
1443
+									$l->product_type = 1;
1444
+									$l->special_code = '';
1445
+									$l->qty = 1;
1446
+									$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1447
+									$l->tva_tx = $tx;
1448
+									$l->total_ht = $val['total_ht'];
1449
+									$l->total_tva = $val['total_tva'];
1450
+									$l->total = $line->total_ht;
1451
+									$l->total_ttc = $val['total_ttc'];
1452
+									$TLines[] = $l;
1453
+									array_shift($TTvas);
1454
+							   }
1455
+							}
1456 1456
     					    
1457
-    					    // ajoute la ligne de sous-total
1458
-    					    $TLines[] = $line; 
1459
-    					}
1460
-				    } else {
1457
+							// ajoute la ligne de sous-total
1458
+							$TLines[] = $line; 
1459
+						}
1460
+					} else {
1461 1461
 				        
1462
-				        if($line->product_type==9 && $line->rowid>0)
1463
-				        {
1464
-				            // ajoute la ligne de sous-total
1465
-				            $TLines[] = $line; 
1466
-				        }
1467
-				    }
1462
+						if($line->product_type==9 && $line->rowid>0)
1463
+						{
1464
+							// ajoute la ligne de sous-total
1465
+							$TLines[] = $line; 
1466
+						}
1467
+					}
1468 1468
 				    
1469 1469
 					
1470 1470
 				}
@@ -1489,20 +1489,20 @@  discard block
 block discarded – undo
1489 1489
 			$nbtva = count($TTvas);
1490 1490
 			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1491 1491
 			{
1492
-			    foreach ($TTvas as $tx =>$val){
1493
-			        $l = clone $line;
1494
-			        $l->product_type = 1;
1495
-			        $l->special_code = '';
1496
-			        $l->qty = 1;
1497
-			        $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1498
-			        $l->tva_tx = $tx;
1499
-			        $l->total_ht = $val['total_ht'];
1500
-			        $l->total_tva = $val['total_tva'];
1501
-			        $l->total = $line->total_ht;
1502
-			        $l->total_ttc = $val['total_ttc'];
1503
-			        $TLines[] = $l;
1504
-			        array_shift($TTvas);
1505
-			    }
1492
+				foreach ($TTvas as $tx =>$val){
1493
+					$l = clone $line;
1494
+					$l->product_type = 1;
1495
+					$l->special_code = '';
1496
+					$l->qty = 1;
1497
+					$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1498
+					$l->tva_tx = $tx;
1499
+					$l->total_ht = $val['total_ht'];
1500
+					$l->total_tva = $val['total_tva'];
1501
+					$l->total = $line->total_ht;
1502
+					$l->total_ttc = $val['total_ttc'];
1503
+					$TLines[] = $l;
1504
+					array_shift($TTvas);
1505
+				}
1506 1506
 			}
1507 1507
 			
1508 1508
 			global $nblignes;
@@ -1514,7 +1514,7 @@  discard block
 block discarded – undo
1514 1514
 				$this->resprints = '';
1515 1515
 				return 0;
1516 1516
 			}
1517
-	    }
1517
+		}
1518 1518
 		
1519 1519
 		return 0;
1520 1520
 	}
@@ -1677,18 +1677,18 @@  discard block
 block discarded – undo
1677 1677
 		}
1678 1678
 		elseif($object->element == 'order_supplier' )
1679 1679
 		{
1680
-		    $createRight = $user->rights->fournisseur->commande->creer;
1680
+			$createRight = $user->rights->fournisseur->commande->creer;
1681 1681
 		}
1682 1682
 		elseif($object->element == 'invoice_supplier' )
1683 1683
 		{
1684
-		    $createRight = $user->rights->fournisseur->facture->creer;
1684
+			$createRight = $user->rights->fournisseur->facture->creer;
1685 1685
 		}
1686 1686
 		
1687 1687
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1688 1688
 			null;
1689 1689
 		}	
1690 1690
 		else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) 
1691
-        {
1691
+		{
1692 1692
 			if($object->element=='facture')$idvar = 'facid';
1693 1693
 			else $idvar='id';
1694 1694
 			
@@ -1735,7 +1735,7 @@  discard block
 block discarded – undo
1735 1735
 			//var_dump($line);
1736 1736
             
1737 1737
 			// HTML 5 data for js
1738
-            $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
1738
+			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
1739 1739
             
1740 1740
 			
1741 1741
 			?>
@@ -1793,8 +1793,8 @@  discard block
 block discarded – undo
1793 1793
 						}
1794 1794
 						
1795 1795
 						if ($object->element == 'order_supplier' || $object->element == 'invoice_supplier') {
1796
-						    $line->label = !empty($line->description) ? $line->description : $line->desc;
1797
-						    $line->description = '';
1796
+							$line->label = !empty($line->description) ? $line->description : $line->desc;
1797
+							$line->description = '';
1798 1798
 						}
1799 1799
 						$newlabel = $line->label;
1800 1800
 						if($line->label=='' && !$isFreeText) {
@@ -2085,17 +2085,17 @@  discard block
 block discarded – undo
2085 2085
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2086 2086
 		{
2087 2087
 		    
2088
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2089
-		    {
2090
-		        foreach ($object->lines as $line)
2091
-		        {
2092
-		            // fetch optionals attributes and labels
2093
-		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2094
-		            $extrafields=new ExtraFields($this->db);
2095
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2096
-		            $line->fetch_optionals($line->id,$extralabels);
2097
-		        }
2098
-		    }
2088
+			if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2089
+			{
2090
+				foreach ($object->lines as $line)
2091
+				{
2092
+					// fetch optionals attributes and labels
2093
+					require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2094
+					$extrafields=new ExtraFields($this->db);
2095
+					$extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2096
+					$line->fetch_optionals($line->id,$extralabels);
2097
+				}
2098
+			}
2099 2099
 		    
2100 2100
 			$TSubNc = array();
2101 2101
 			foreach ($object->lines as &$l)
@@ -2186,80 +2186,80 @@  discard block
 block discarded – undo
2186 2186
 	{
2187 2187
 		dol_include_once('/subtotal/class/subtotal.class.php');
2188 2188
 
2189
-	    $line = &$parameters['line'];
2189
+		$line = &$parameters['line'];
2190 2190
 	    
2191
-	    $ThtmlData['data-id']           = $line->id;
2192
-	    $ThtmlData['data-product_type'] = $line->product_type;
2193
-	    $ThtmlData['data-qty']          = 0; //$line->qty;
2194
-	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2191
+		$ThtmlData['data-id']           = $line->id;
2192
+		$ThtmlData['data-product_type'] = $line->product_type;
2193
+		$ThtmlData['data-qty']          = 0; //$line->qty;
2194
+		$ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2195 2195
 	    
2196
-	    if(TSubtotal::isTitle($line)){
2197
-	        $ThtmlData['data-issubtotal'] = 'title';
2198
-	    }elseif(TSubtotal::isSubtotal($line)){
2199
-	        $ThtmlData['data-issubtotal'] = 'subtotal';
2200
-	    }
2201
-	    else{
2202
-	        $ThtmlData['data-issubtotal'] = 'freetext';
2203
-	    }
2196
+		if(TSubtotal::isTitle($line)){
2197
+			$ThtmlData['data-issubtotal'] = 'title';
2198
+		}elseif(TSubtotal::isSubtotal($line)){
2199
+			$ThtmlData['data-issubtotal'] = 'subtotal';
2200
+		}
2201
+		else{
2202
+			$ThtmlData['data-issubtotal'] = 'freetext';
2203
+		}
2204 2204
 	    
2205 2205
 	    
2206
-	    // Change or add data  from hooks
2207
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2206
+		// Change or add data  from hooks
2207
+		$parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2208 2208
 	    
2209
-	    // hook 
2210
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2211
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2212
-	    if ($reshook>0)
2213
-	    {
2214
-	        $ThtmlData = $hookmanager->resArray;
2215
-	    }
2216
-
2217
-	    return $this->implodeHtmlData($ThtmlData);
2209
+		// hook 
2210
+		$reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2211
+		if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2212
+		if ($reshook>0)
2213
+		{
2214
+			$ThtmlData = $hookmanager->resArray;
2215
+		}
2216
+
2217
+		return $this->implodeHtmlData($ThtmlData);
2218 2218
 	
2219 2219
 	}
2220 2220
 	
2221 2221
 	
2222 2222
 	function implodeHtmlData($ThtmlData = array())
2223 2223
 	{
2224
-	    $data = '';
2225
-	    foreach($ThtmlData as $k => $h )
2226
-	    {
2227
-	        if(is_array($h))
2228
-	        {
2229
-	            $h = json_encode($h);
2230
-	        }
2224
+		$data = '';
2225
+		foreach($ThtmlData as $k => $h )
2226
+		{
2227
+			if(is_array($h))
2228
+			{
2229
+				$h = json_encode($h);
2230
+			}
2231 2231
 	        
2232
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2233
-	    }
2232
+			$data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2233
+		}
2234 2234
 	    
2235
-	    return $data;
2235
+		return $data;
2236 2236
 	}
2237 2237
 	
2238 2238
 	function _ajax_block_order_js($object)
2239 2239
 	{
2240
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2240
+		global $conf,$tagidfortablednd,$filepath,$langs;
2241 2241
 	    
2242
-	    /*
2242
+		/*
2243 2243
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2244 2244
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2245 2245
 	     */
2246 2246
 	    
2247
-	    $id=$object->id;
2248
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2249
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2247
+		$id=$object->id;
2248
+		$nboflines=(isset($object->lines)?count($object->lines):0);
2249
+		$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2250 2250
 	    
2251
-	    $id=$object->id;
2252
-	    $fk_element=$object->fk_element;
2253
-	    $table_element_line=$object->table_element_line;
2254
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2255
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2256
-	    $filepath=(empty($filepath)?'':$filepath);
2251
+		$id=$object->id;
2252
+		$fk_element=$object->fk_element;
2253
+		$table_element_line=$object->table_element_line;
2254
+		$nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2255
+		$tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2256
+		$filepath=(empty($filepath)?'':$filepath);
2257 2257
 	    
2258 2258
 	    
2259
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2260
-	    {
2259
+		if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2260
+		{
2261 2261
 	        
2262
-	        ?>
2262
+			?>
2263 2263
 		
2264 2264
 		
2265 2265
 			<script type="text/javascript">
Please login to merge, or discard this patch.
Spacing   +384 added lines, -384 removed lines patch added patch discarded remove patch
@@ -51,43 +51,43 @@  discard block
 block discarded – undo
51 51
     
52 52
     function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
53 53
     {
54
-      	global $langs,$db,$user, $conf;
54
+      	global $langs, $db, $user, $conf;
55 55
 		
56 56
 		$langs->load('subtotal@subtotal');
57 57
 		
58
-		$contexts = explode(':',$parameters['context']);
58
+		$contexts = explode(':', $parameters['context']);
59 59
 		
60
-		if(in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('invoicereccard',$contexts)) {
60
+		if (in_array('ordercard', $contexts) || in_array('ordersuppliercard', $contexts) || in_array('propalcard', $contexts) || in_array('supplier_proposalcard', $contexts) || in_array('invoicecard', $contexts) || in_array('invoicesuppliercard', $contexts) || in_array('invoicereccard', $contexts)) {
61 61
 			
62 62
 			$createRight = $user->rights->{$object->element}->creer;
63
-			if($object->element == 'facturerec' )
63
+			if ($object->element == 'facturerec')
64 64
 			{
65 65
 				$object->statut = 0; // hack for facture rec
66 66
 				$createRight = $user->rights->facture->creer;
67
-			} elseif($object->element == 'order_supplier' )
67
+			} elseif ($object->element == 'order_supplier')
68 68
 			{
69 69
 			    $createRight = $user->rights->fournisseur->commande->creer;
70
-			} elseif($object->element == 'invoice_supplier' )
70
+			} elseif ($object->element == 'invoice_supplier')
71 71
 			{
72 72
 			    $createRight = $user->rights->fournisseur->facture->creer;
73 73
 			}
74 74
 			
75
-			if ($object->statut == 0  && $createRight) {
75
+			if ($object->statut == 0 && $createRight) {
76 76
 			
77 77
 
78
-				if($object->element=='facture')$idvar = 'facid';
79
-				else $idvar='id';
78
+				if ($object->element == 'facture')$idvar = 'facid';
79
+				else $idvar = 'id';
80 80
 				
81
-				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
81
+				if (in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')))
82 82
 				{
83 83
 					$level = GETPOST('level', 'int'); //New avec SUBTOTAL_USE_NEW_FORMAT
84 84
 					
85
-					if($action=='add_title_line') {
85
+					if ($action == 'add_title_line') {
86 86
 						$title = GETPOST('title');
87
-						if(empty($title)) $title = $langs->trans('title');
88
-						$qty = $level<1 ? 1 : $level ;
87
+						if (empty($title)) $title = $langs->trans('title');
88
+						$qty = $level < 1 ? 1 : $level;
89 89
 					}
90
-					else if($action=='add_free_text') {
90
+					else if ($action == 'add_free_text') {
91 91
 						$title = GETPOST('title');
92 92
 
93 93
 						if (empty($title)) {
@@ -99,21 +99,21 @@  discard block
 block discarded – undo
99 99
 								}
100 100
 							}
101 101
 						}
102
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
102
+						if (empty($title)) $title = $langs->trans('subtotalAddLineDescription');
103 103
 						$qty = 50;
104 104
 					}
105
-					else if($action=='add_subtitle_line') {
105
+					else if ($action == 'add_subtitle_line') {
106 106
 						$title = GETPOST('title');
107
-						if(empty($title)) $title = $langs->trans('subtitle');
107
+						if (empty($title)) $title = $langs->trans('subtitle');
108 108
 						$qty = 2;
109 109
 					}
110
-					else if($action=='add_subtotal_line') {
110
+					else if ($action == 'add_subtotal_line') {
111 111
 						$title = $langs->trans('SubSubTotal');
112 112
 						$qty = 98;
113 113
 					}
114 114
 					else {
115 115
 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
116
-						$qty = $level ? 100-$level : 99;
116
+						$qty = $level ? 100 - $level : 99;
117 117
 					}
118 118
 					dol_include_once('/subtotal/class/subtotal.class.php');
119 119
 					
@@ -121,15 +121,15 @@  discard block
 block discarded – undo
121 121
 					
122 122
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
123 123
 				}
124
-				else if($action==='ask_deleteallline') {
125
-						$form=new Form($db);
124
+				else if ($action === 'ask_deleteallline') {
125
+						$form = new Form($db);
126 126
 						
127
-						$lineid = GETPOST('lineid','integer');
127
+						$lineid = GETPOST('lineid', 'integer');
128 128
 						$TIdForGroup = $this->getArrayOfLineForAGroup($object, $lineid);
129 129
 					
130 130
 						$nbLines = count($TIdForGroup);
131 131
 					
132
-						$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines',$nbLines), 'confirm_delete_all_lines','',0,1);
132
+						$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines', $nbLines), 'confirm_delete_all_lines', '', 0, 1);
133 133
 						print $formconfirm;
134 134
 				}
135 135
 
@@ -139,13 +139,13 @@  discard block
 block discarded – undo
139 139
 				}
140 140
 
141 141
 				
142
-				if($action!='editline') {
142
+				if ($action != 'editline') {
143 143
 					// New format is for 3.8
144 144
 					$this->printNewFormat($object, $conf, $langs, $idvar);
145 145
 				}
146 146
 			}
147 147
 		}
148
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
148
+		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice', $contexts))
149 149
 		{
150 150
 			?>
151 151
 			<script type="text/javascript">
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 				$(document).ready(function() {
171 171
 					$('div.fiche div.tabsAction').append('<br />');
172 172
 					
173
-					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_title_line" rel="add_title_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddTitle' )?></a></div>');
173
+					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_title_line" rel="add_title_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddTitle')?></a></div>');
174 174
 					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_total_line" rel="add_total_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddSubTotal')?></a></div>');
175 175
 					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_free_text" rel="add_free_text" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddFreeText')?></a></div>');
176 176
 
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
 						$('body').append(dialog_html);
222 222
 
223 223
 						<?php 
224
-						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME)?'ckeditor':$conf->global->FCKEDITOR_EDITORNAME;
225
-						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
226
-						if($editorConf && in_array($editorTool,array('textarea','ckeditor'))){ 
224
+						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME) ? 'ckeditor' : $conf->global->FCKEDITOR_EDITORNAME;
225
+						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
226
+						if ($editorConf && in_array($editorTool, array('textarea', 'ckeditor'))) { 
227 227
 						?>
228 228
 						if (action == 'addTitle' || action == 'addFreeTxt')
229 229
 						{
@@ -338,62 +338,62 @@  discard block
 block discarded – undo
338 338
 		global $conf, $langs, $bc;
339 339
 			
340 340
 		$action = GETPOST('action');	
341
-		$TContext = explode(':',$parameters['context']);
341
+		$TContext = explode(':', $parameters['context']);
342 342
 		if (
343
-				in_array('invoicecard',$TContext)
344
-		        || in_array('invoicesuppliercard',$TContext)
345
-				|| in_array('propalcard',$TContext)
346
-				|| in_array('ordercard',$TContext)
347
-		        || in_array('ordersuppliercard',$TContext)
348
-				|| in_array('invoicereccard',$TContext)
343
+				in_array('invoicecard', $TContext)
344
+		        || in_array('invoicesuppliercard', $TContext)
345
+				|| in_array('propalcard', $TContext)
346
+				|| in_array('ordercard', $TContext)
347
+		        || in_array('ordersuppliercard', $TContext)
348
+				|| in_array('invoicereccard', $TContext)
349 349
 			)
350 350
 	        {	
351
-				$hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] : 0;
352
-				$hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] : 0;
353
-				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0;
354
-				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] : $hidepricesDefaultConf;
351
+				$hideInnerLines = isset($_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']]) ? $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] : 0;
352
+				$hidedetails = isset($_SESSION['subtotal_hidedetails_'.$parameters['modulepart']]) ? $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] : 0;
353
+				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED) ? $conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED : 0;
354
+				$hideprices = isset($_SESSION['subtotal_hideprices_'.$parameters['modulepart']]) ? $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] : $hidepricesDefaultConf;
355 355
 				
356
-				$var=false;
357
-		     	$out.= '<tr '.$bc[$var].'>
356
+				$var = false;
357
+		     	$out .= '<tr '.$bc[$var].'>
358 358
 		     			<td colspan="4" align="right">
359 359
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
360
-		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
360
+		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(($hideInnerLines) ? 'checked="checked"' : '').' />
361 361
 		     			</td>
362 362
 		     			</tr>';
363 363
 				
364
-		     	$var=!$var;
365
-		     	$out.= '<tr '.$bc[$var].'>
364
+		     	$var = !$var;
365
+		     	$out .= '<tr '.$bc[$var].'>
366 366
 		     			<td colspan="4" align="right">
367 367
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
368
-		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
368
+		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(($hidedetails) ? 'checked="checked"' : '').' />
369 369
 		     			</td>
370 370
 		     			</tr>';
371 371
 		     	
372
-		     	$var=!$var;
373
-		     	$out.= '<tr '.$bc[$var].'>
372
+		     	$var = !$var;
373
+		     	$out .= '<tr '.$bc[$var].'>
374 374
 		     			<td colspan="4" align="right">
375 375
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidePrice').'</label>
376
-		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
376
+		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(($hideprices) ? 'checked="checked"' : '').' />
377 377
 		     			</td>
378 378
 		     			</tr>';
379 379
 		     	
380 380
 		     	
381 381
 				 
382 382
 				if ( 
383
-					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
384
-					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
385
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
386
-					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
387
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
388
-					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
383
+					(in_array('propalcard', $TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
384
+					|| (in_array('ordercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
385
+				    || (in_array('ordersuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
386
+					|| (in_array('invoicecard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
387
+				    || (in_array('invoicesuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
388
+					|| (in_array('invoicereccard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
389 389
 				)
390 390
 				{
391
-					$var=!$var;
392
-					$out.= '
391
+					$var = !$var;
392
+					$out .= '
393 393
 						<tr '.$bc[$var].'>
394 394
 							<td colspan="4" align="right">
395 395
 								<label for="subtotal_add_recap">'.$langs->trans('subtotal_add_recap').'</label>
396
-								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.( GETPOST('subtotal_add_recap') ? 'checked="checked"' : '' ).' />
396
+								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.(GETPOST('subtotal_add_recap') ? 'checked="checked"' : '').' />
397 397
 							</td>
398 398
 						</tr>';
399 399
 				}
@@ -409,7 +409,7 @@  discard block
 block discarded – undo
409 409
     function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
410 410
     {
411 411
 		
412
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
412
+    	if (in_array('invoicecard', explode(':', $parameters['context'])))
413 413
         {
414 414
         	
415 415
         }
@@ -420,13 +420,13 @@  discard block
 block discarded – undo
420 420
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
421 421
 		global $conf;
422 422
 		
423
-		if($action === 'builddoc') {
423
+		if ($action === 'builddoc') {
424 424
 			
425 425
 			$line = &$parameters['line'];
426 426
 			$object = &$parameters['object'];
427 427
 			$substitutionarray = &$parameters['substitutionarray'];
428 428
 			
429
-			if($line->product_type == 9 && $line->special_code == $this->module_number) {
429
+			if ($line->product_type == 9 && $line->special_code == $this->module_number) {
430 430
 				$substitutionarray['line_modsubtotal'] = 1;	
431 431
 				
432 432
 				$substitutionarray['line_price_ht']
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
 					 = $substitutionarray['line_up'] 
438 438
 					 = '';
439 439
 				
440
-				if($line->qty>90) {
440
+				if ($line->qty > 90) {
441 441
 					$substitutionarray['line_modsubtotal_total'] = true;
442 442
 					
443 443
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 				
452 452
 				
453 453
 			}	
454
-			else{
454
+			else {
455 455
 				$substitutionarray['line_not_modsubtotal'] = true;
456 456
 				$substitutionarray['line_modsubtotal'] = 0;
457 457
 			}
@@ -463,29 +463,29 @@  discard block
 block discarded – undo
463 463
 	function createFrom($parameters, &$object, $action, $hookmanager) {
464 464
 	
465 465
 		if (
466
-				in_array('invoicecard',explode(':',$parameters['context']))
467
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
468
-				|| in_array('propalcard',explode(':',$parameters['context']))
469
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
470
-				|| in_array('ordercard',explode(':',$parameters['context']))
471
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
472
-				|| in_array('invoicereccard',explode(':',$parameters['context']))
466
+				in_array('invoicecard', explode(':', $parameters['context']))
467
+		        || in_array('invoicesuppliercard', explode(':', $parameters['context']))
468
+				|| in_array('propalcard', explode(':', $parameters['context']))
469
+		        || in_array('supplier_proposalcard', explode(':', $parameters['context']))
470
+				|| in_array('ordercard', explode(':', $parameters['context']))
471
+		        || in_array('ordersuppliercard', explode(':', $parameters['context']))
472
+				|| in_array('invoicereccard', explode(':', $parameters['context']))
473 473
 		) {
474 474
 			
475 475
 			global $db;
476 476
 			
477 477
 			$objFrom = $parameters['objFrom'];
478 478
 			
479
-			foreach($objFrom->lines as $k=> &$lineOld) {
479
+			foreach ($objFrom->lines as $k=> &$lineOld) {
480 480
 				
481
-					if($lineOld->product_type == 9 && $lineOld->info_bits > 0 ) {
481
+					if ($lineOld->product_type == 9 && $lineOld->info_bits > 0) {
482 482
 							
483 483
 							$line = & $object->lines[$k];
484 484
 				
485 485
 							$idLine = (int) ($line->id ? $line->id : $line->rowid); 
486 486
 				
487 487
 							$db->query("UPDATE ".MAIN_DB_PREFIX.$line->table_element."
488
-							SET info_bits=".(int)$lineOld->info_bits."
488
+							SET info_bits=".(int) $lineOld->info_bits."
489 489
 							WHERE rowid = ".$idLine."
490 490
 							");
491 491
 						
@@ -501,15 +501,15 @@  discard block
 block discarded – undo
501 501
 	
502 502
 	function doActions($parameters, &$object, $action, $hookmanager)
503 503
 	{
504
-		global $db, $conf, $langs,$user;
504
+		global $db, $conf, $langs, $user;
505 505
 		
506 506
 		dol_include_once('/subtotal/class/subtotal.class.php');
507 507
 		dol_include_once('/subtotal/lib/subtotal.lib.php');
508
-		require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
508
+		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
509 509
 		
510 510
 		$showBlockExtrafields = GETPOST('showBlockExtrafields');
511 511
 		
512
-		if($object->element=='facture') $idvar = 'facid';
512
+		if ($object->element == 'facture') $idvar = 'facid';
513 513
 		else $idvar = 'id';
514 514
 			
515 515
 		if ($action == 'updateligne' || $action == 'updateline')
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 				if ($line->id == $lineid && TSubtotal::isModSubtotalLine($line))
523 523
 				{
524 524
 					$found = true;
525
-					if(TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
525
+					if (TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
526 526
 						$extrafieldsline = new ExtraFields($db);
527 527
 						$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
528 528
 						$extrafieldsline->setOptionalsFromPost($extralabelsline, $line);
@@ -541,43 +541,43 @@  discard block
 block discarded – undo
541 541
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
542 542
 			}
543 543
 		}
544
-		else if($action === 'builddoc') {
544
+		else if ($action === 'builddoc') {
545 545
 			
546 546
 			if (
547
-				in_array('invoicecard',explode(':',$parameters['context']))
548
-				|| in_array('propalcard',explode(':',$parameters['context']))
549
-				|| in_array('ordercard',explode(':',$parameters['context']))
550
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
551
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
552
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
547
+				in_array('invoicecard', explode(':', $parameters['context']))
548
+				|| in_array('propalcard', explode(':', $parameters['context']))
549
+				|| in_array('ordercard', explode(':', $parameters['context']))
550
+			    || in_array('ordersuppliercard', explode(':', $parameters['context']))
551
+			    || in_array('invoicesuppliercard', explode(':', $parameters['context']))
552
+			    || in_array('supplier_proposalcard', explode(':', $parameters['context']))
553 553
 			)
554 554
 	        {								
555
-				if(in_array('invoicecard',explode(':',$parameters['context']))) {
555
+				if (in_array('invoicecard', explode(':', $parameters['context']))) {
556 556
 					$sessname = 'subtotal_hideInnerLines_facture';	
557 557
 					$sessname2 = 'subtotal_hidedetails_facture';
558 558
 					$sessname3 = 'subtotal_hideprices_facture';
559 559
 				}
560
-				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
560
+				elseif (in_array('invoicesuppliercard', explode(':', $parameters['context']))) {
561 561
 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
562 562
 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
563 563
 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
564 564
 				}
565
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
565
+				elseif (in_array('propalcard', explode(':', $parameters['context']))) {
566 566
 					$sessname = 'subtotal_hideInnerLines_propal';
567 567
 					$sessname2 = 'subtotal_hidedetails_propal';	
568 568
 					$sessname3 = 'subtotal_hideprices_propal';
569 569
 				}
570
-				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
570
+				elseif (in_array('supplier_proposalcard', explode(':', $parameters['context']))) {
571 571
 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
572 572
 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
573 573
 				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
574 574
 				}
575
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
575
+				elseif (in_array('ordercard', explode(':', $parameters['context']))) {
576 576
 					$sessname = 'subtotal_hideInnerLines_commande';
577 577
 					$sessname2 = 'subtotal_hidedetails_commande';	
578 578
 					$sessname3 = 'subtotal_hideprices_commande';
579 579
 				}
580
-				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
580
+				elseif (in_array('ordersuppliercard', explode(':', $parameters['context']))) {
581 581
 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
582 582
 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
583 583
 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
@@ -590,22 +590,22 @@  discard block
 block discarded – undo
590 590
 					
591 591
 				global $hideprices;
592 592
 				
593
-				$hideInnerLines = (int)GETPOST('hideInnerLines');
593
+				$hideInnerLines = (int) GETPOST('hideInnerLines');
594 594
 				$_SESSION[$sessname] = $hideInnerLines;		
595 595
 				
596
-				$hidedetails= (int)GETPOST('hidedetails');
596
+				$hidedetails = (int) GETPOST('hidedetails');
597 597
 				$_SESSION[$sessname2] = $hidedetails;
598 598
 				
599
-				$hideprices= (int)GETPOST('hideprices');
599
+				$hideprices = (int) GETPOST('hideprices');
600 600
 				$_SESSION[$sessname3] = $hideprices;
601 601
 				
602
-				foreach($object->lines as &$line) {
602
+				foreach ($object->lines as &$line) {
603 603
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
604 604
 					    
605
-                        if($line->qty>=90) {
605
+                        if ($line->qty >= 90) {
606 606
                             $line->modsubtotal_total = 1;
607 607
                         }
608
-                        else{
608
+                        else {
609 609
                             $line->modsubtotal_title = 1;
610 610
                         }
611 611
                         
@@ -615,34 +615,34 @@  discard block
 block discarded – undo
615 615
 	        }
616 616
 			
617 617
 		}
618
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
618
+		else if ($action === 'confirm_delete_all_lines' && GETPOST('confirm') == 'yes') {
619 619
 			
620 620
 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
621 621
 			
622
-			foreach($Tab as $idLine) {
622
+			foreach ($Tab as $idLine) {
623 623
 				/**
624 624
 				 * @var $object Facture
625 625
 				 */
626
-				if($object->element=='facture') $object->deleteline($idLine);
626
+				if ($object->element == 'facture') $object->deleteline($idLine);
627 627
 				/**
628 628
 				 * @var $object Facture fournisseur
629 629
 				 */
630
-				else if($object->element=='invoice_supplier')
630
+				else if ($object->element == 'invoice_supplier')
631 631
 				{
632 632
 				    $object->deleteline($idLine);
633 633
 				}
634 634
 				/**
635 635
 				 * @var $object Propal
636 636
 				 */
637
-				else if($object->element=='propal') $object->deleteline($idLine);
637
+				else if ($object->element == 'propal') $object->deleteline($idLine);
638 638
 				/**
639 639
 				 * @var $object Propal Fournisseur
640 640
 				 */
641
-				else if($object->element=='supplier_proposal') $object->deleteline($idLine);
641
+				else if ($object->element == 'supplier_proposal') $object->deleteline($idLine);
642 642
 				/**
643 643
 				 * @var $object Commande
644 644
 				 */
645
-				else if($object->element=='commande') 
645
+				else if ($object->element == 'commande') 
646 646
 				{
647 647
 					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
648 648
 					else $object->deleteline($idLine);
@@ -650,14 +650,14 @@  discard block
 block discarded – undo
650 650
 				/**
651 651
 				 * @var $object Commande fournisseur
652 652
 				 */
653
-				else if($object->element=='order_supplier')
653
+				else if ($object->element == 'order_supplier')
654 654
 				{
655 655
 				    $object->deleteline($idLine);
656 656
 				}
657 657
 				/**
658 658
 				 * @var $object Facturerec
659 659
 				 */
660
-				else if($object->element=='facturerec') $object->deleteline($idLine);
660
+				else if ($object->element == 'facturerec') $object->deleteline($idLine);
661 661
 			}
662 662
 			
663 663
 			header('location:?id='.$object->id);
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 		return 0;
681 681
 	}
682 682
 	
683
-	function formAddObjectLine ($parameters, &$object, &$action, $hookmanager) {
683
+	function formAddObjectLine($parameters, &$object, &$action, $hookmanager) {
684 684
 		return 0;
685 685
 	}
686 686
 
@@ -692,22 +692,22 @@  discard block
 block discarded – undo
692 692
 		
693 693
 		$found = false;
694 694
 
695
-		$Tab= array();
695
+		$Tab = array();
696 696
 		
697
-		foreach($object->lines as $l) {
697
+		foreach ($object->lines as $l) {
698 698
 		
699 699
 		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
700
-			if($lid == $lineid) {
700
+			if ($lid == $lineid) {
701 701
 
702 702
 				$found = true;
703 703
 				$qty_line = $l->qty;
704 704
 			}
705 705
 			
706
-			if($found) {
706
+			if ($found) {
707 707
 				
708 708
 			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
709 709
 				
710
-				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
710
+				if ($l->special_code == $this->module_number && (($l->qty == 99 && $qty_line == 1) || ($l->qty == 98 && $qty_line == 2))) {
711 711
 					break; // end of story
712 712
 				}
713 713
 			}
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 	 * 
737 737
 	 * @param	$use_level		isn't used anymore
738 738
 	 */
739
-	function getTotalLineFromObject(&$object, &$line, $use_level=false, $return_all=0) {
739
+	function getTotalLineFromObject(&$object, &$line, $use_level = false, $return_all = 0) {
740 740
 		
741 741
 		$rang = $line->rang;
742 742
 		$qty_line = $line->qty;
@@ -747,21 +747,21 @@  discard block
 block discarded – undo
747 747
 		$TTotal_tva = array();
748 748
 		
749 749
 		dol_include_once('/subtotal/class/subtotal.class.php');
750
-		foreach($object->lines as $l) {
750
+		foreach ($object->lines as $l) {
751 751
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
752
-			if($l->rang>=$rang) {
752
+			if ($l->rang >= $rang) {
753 753
 				//echo 'return!<br>';
754 754
 				if (!$return_all) return $total;
755 755
 				else return array($total, $total_tva, $total_ttc, $TTotal_tva);
756 756
 			}
757
-			else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
757
+			else if (TSubtotal::isTitle($l, 100 - $qty_line)) 
758 758
 		  	{
759 759
 				$total = 0;
760 760
 				$total_tva = 0;
761 761
 				$total_ttc = 0;
762 762
 				$TTotal_tva = array();
763 763
 			}
764
-			elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
764
+			elseif (!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
765 765
 				$total += $l->total_ht;
766 766
 				$total_tva += $l->total_tva;
767 767
 				$TTotal_tva[$l->tva_tx] += $l->total_tva;
@@ -780,18 +780,18 @@  discard block
 block discarded – undo
780 780
 		
781 781
 		$rang = $line->rang;
782 782
 		$total = 0;
783
-		foreach($object->lines as $l) {
784
-			if($l->rang>=$rang) {
783
+		foreach ($object->lines as $l) {
784
+			if ($l->rang >= $rang) {
785 785
 				return price($total);
786 786
 			}
787
-                        if (TSubtotal::isSubtotal($l)){
787
+                        if (TSubtotal::isSubtotal($l)) {
788 788
                             $total = 0;
789
-                        } else  if ($l->situation_percent > 0 ){
789
+                        } else  if ($l->situation_percent > 0) {
790 790
                            
791 791
         	
792 792
 		 	$prev_progress = $l->get_prev_progress($object->id);
793
-		 	$progress = ($l->situation_percent - $prev_progress) /100;
794
-                        $total += ($l->total_ht/($l->situation_percent/100)) * $progress;
793
+		 	$progress = ($l->situation_percent - $prev_progress) / 100;
794
+                        $total += ($l->total_ht / ($l->situation_percent / 100)) * $progress;
795 795
                         
796 796
                     }
797 797
                 }
@@ -810,10 +810,10 @@  discard block
 block discarded – undo
810 810
 	 * @param $w            float               width
811 811
 	 * @param $h            float               height
812 812
 	 */
813
-	function pdf_add_total(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
814
-		global $conf,$subtotal_last_title_posy;
813
+	function pdf_add_total(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
814
+		global $conf, $subtotal_last_title_posy;
815 815
 		
816
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
816
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
817 817
 		if (!empty($conf->global->SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES) && $hideInnerLines && !empty($subtotal_last_title_posy))
818 818
 		{
819 819
 			$posy = $subtotal_last_title_posy;
@@ -823,34 +823,34 @@  discard block
 block discarded – undo
823 823
 		$hidePriceOnSubtotalLines = (int) GETPOST('hide_price_on_subtotal_lines');
824 824
 		
825 825
 		$set_pagebreak_margin = false;
826
-		if(method_exists('Closure','bind')) {
826
+		if (method_exists('Closure', 'bind')) {
827 827
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
828
-			$sweetsThief = function ($pdf) {
829
-		    		return $pdf->bMargin ;
828
+			$sweetsThief = function($pdf) {
829
+		    		return $pdf->bMargin;
830 830
 			};
831 831
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
832 832
 	
833
-			$bMargin  = $sweetsThief($pdf);
833
+			$bMargin = $sweetsThief($pdf);
834 834
 	
835
-			$pdf->SetAutoPageBreak( false );
835
+			$pdf->SetAutoPageBreak(false);
836 836
 
837 837
 			$set_pagebreak_margin = true;			
838 838
 		}
839 839
 		
840 840
 			
841
-		if($line->qty==99)
842
-			$pdf->SetFillColor(220,220,220);
843
-		elseif ($line->qty==98)
844
-			$pdf->SetFillColor(230,230,230);
841
+		if ($line->qty == 99)
842
+			$pdf->SetFillColor(220, 220, 220);
843
+		elseif ($line->qty == 98)
844
+			$pdf->SetFillColor(230, 230, 230);
845 845
 		else
846
-			$pdf->SetFillColor(240,240,240);
846
+			$pdf->SetFillColor(240, 240, 240);
847 847
 		
848 848
 		$style = 'B';
849 849
 		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
850 850
 		
851 851
 		$pdf->SetFont('', $style, 9);
852 852
 		
853
-		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R',true);
853
+		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R', true);
854 854
 //		var_dump($bMargin);
855 855
 		$pageAfter = $pdf->getPage();
856 856
 		
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
 				}
876 876
 			}
877 877
 			
878
-			if($total_to_print) {
878
+			if ($total_to_print) {
879 879
 				
880 880
 				if (GETPOST('hideInnerLines'))
881 881
 				{
@@ -889,7 +889,7 @@  discard block
 block discarded – undo
889 889
 				else
890 890
 				{
891 891
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
892
-                                        if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
892
+                                        if (get_class($object) == 'Facture' && $object->type == Facture::TYPE_SITUATION) {//Facture de situation
893 893
                                                 $total_to_print = $this->getTotalToPrintSituation($object, $line);
894 894
                                         } else {
895 895
                                             	$total_to_print = price($total);
@@ -903,11 +903,11 @@  discard block
 block discarded – undo
903 903
 			}
904 904
 
905 905
 			$pdf->SetXY($pdf->postotalht, $posy);
906
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
907
-			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
906
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
907
+			$pdf->MultiCell($pdf->page_largeur - $pdf->marge_droite - $pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
908 908
 		}
909
-		else{
910
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
909
+		else {
910
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
911 911
 		}
912 912
 		
913 913
 		$posy = $posy + $cell_height;
@@ -927,22 +927,22 @@  discard block
 block discarded – undo
927 927
 	 * @param $w            float               width
928 928
 	 * @param $h            float               height
929 929
 	 */
930
-	function pdf_add_title(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
930
+	function pdf_add_title(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
931 931
 		
932
-		global $db,$conf,$subtotal_last_title_posy;
932
+		global $db, $conf, $subtotal_last_title_posy;
933 933
 		
934 934
 		$subtotal_last_title_posy = $posy;
935
-		$pdf->SetXY ($posx, $posy);
935
+		$pdf->SetXY($posx, $posy);
936 936
 		
937
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
937
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
938 938
 		
939 939
 		
940 940
  
941
-		$style = ($line->qty==1) ? 'BU' : 'BUI';
941
+		$style = ($line->qty == 1) ? 'BU' : 'BUI';
942 942
 		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
943 943
 		
944
-		if($hideInnerLines) {
945
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
944
+		if ($hideInnerLines) {
945
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9);
946 946
 			else 
947 947
 			{
948 948
 				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
@@ -951,43 +951,43 @@  discard block
 block discarded – undo
951 951
 		}
952 952
 		else {
953 953
 
954
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
954
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9); //TODO if super utile
955 955
 			else $pdf->SetFont('', $style, 9);
956 956
 			
957 957
 		}
958 958
 		
959 959
 		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) $pdf->MultiCell($w, $h, $label, 0, 'L'); // Pas de HTML dans la chaine
960
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
960
+		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J', true); // et maintenant avec du HTML
961 961
 		
962
-		if($description && !$hidedesc) {
962
+		if ($description && !$hidedesc) {
963 963
 			$posy = $pdf->GetY();
964 964
 			
965 965
 			$pdf->SetFont('', '', 8);
966 966
 			
967
-			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J',true);
967
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J', true);
968 968
 
969 969
 		}
970 970
 		
971 971
 	}
972 972
 
973
-	function pdf_writelinedesc_ref($parameters=array(), &$object, &$action='') {
973
+	function pdf_writelinedesc_ref($parameters = array(), &$object, &$action = '') {
974 974
 	// ultimate PDF hook O_o
975 975
 		
976
-		return $this->pdf_writelinedesc($parameters,$object,$action);
976
+		return $this->pdf_writelinedesc($parameters, $object, $action);
977 977
 		
978 978
 	}
979 979
 
980 980
 	function isModSubtotalLine(&$parameters, &$object) {
981 981
 		
982
-		if(is_array($parameters)) {
982
+		if (is_array($parameters)) {
983 983
 			$i = & $parameters['i'];	
984 984
 		}
985 985
 		else {
986
-			$i = (int)$parameters;
986
+			$i = (int) $parameters;
987 987
 		}
988 988
 		
989 989
 		
990
-		if($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) {
990
+		if ($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) {
991 991
 			return true;
992 992
 		}
993 993
 		
@@ -995,43 +995,43 @@  discard block
 block discarded – undo
995 995
 		
996 996
 	}
997 997
 
998
-	function pdf_getlineqty($parameters=array(), &$object, &$action='') {
999
-		global $conf,$hideprices;
998
+	function pdf_getlineqty($parameters = array(), &$object, &$action = '') {
999
+		global $conf, $hideprices;
1000 1000
 		
1001
-		if($this->isModSubtotalLine($parameters,$object) ){
1001
+		if ($this->isModSubtotalLine($parameters, $object)) {
1002 1002
 			
1003 1003
 			$this->resprints = ' ';
1004 1004
 			
1005
-			if((float)DOL_VERSION<=3.6) {
1005
+			if ((float) DOL_VERSION <= 3.6) {
1006 1006
 				return '';
1007 1007
 			}
1008
-			else if((float)DOL_VERSION>=3.8) {
1008
+			else if ((float) DOL_VERSION >= 3.8) {
1009 1009
 				return 1;
1010 1010
 			}
1011 1011
 			
1012 1012
 		}
1013
-		elseif(!empty($hideprices)) {
1013
+		elseif (!empty($hideprices)) {
1014 1014
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1015 1015
 			return 1;
1016 1016
 		}
1017 1017
 		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1018 1018
 		{
1019
-			$hideInnerLines = (int)GETPOST('hideInnerLines');
1020
-			$hidedetails = (int)GETPOST('hidedetails');
1019
+			$hideInnerLines = (int) GETPOST('hideInnerLines');
1020
+			$hidedetails = (int) GETPOST('hidedetails');
1021 1021
 			if (empty($hideInnerLines) && !empty($hidedetails))
1022 1022
 			{
1023 1023
 				$this->resprints = $object->lines[$parameters['i']]->qty;
1024 1024
 			}
1025 1025
 		}
1026 1026
 		
1027
-		if(is_array($parameters)) $i = & $parameters['i'];
1028
-		else $i = (int)$parameters;
1027
+		if (is_array($parameters)) $i = & $parameters['i'];
1028
+		else $i = (int) $parameters;
1029 1029
 
1030 1030
 		if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1031 1031
 		
1032
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1032
+		if (empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1033 1033
 
1034
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1034
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1035 1035
 		{
1036 1036
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1037 1037
 			{
@@ -1043,25 +1043,25 @@  discard block
 block discarded – undo
1043 1043
 		return 0;
1044 1044
 	}
1045 1045
 	
1046
-	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1046
+	function pdf_getlinetotalexcltax($parameters = array(), &$object, &$action = '') {
1047 1047
 	    global $conf, $hideprices;
1048 1048
 		
1049
-		if($this->isModSubtotalLine($parameters,$object) ){
1049
+		if ($this->isModSubtotalLine($parameters, $object)) {
1050 1050
 			
1051 1051
 			$this->resprints = ' ';
1052 1052
 			
1053
-			if((float)DOL_VERSION<=3.6) {
1053
+			if ((float) DOL_VERSION <= 3.6) {
1054 1054
 				return '';
1055 1055
 			}
1056
-			else if((float)DOL_VERSION>=3.8) {
1056
+			else if ((float) DOL_VERSION >= 3.8) {
1057 1057
 				return 1;
1058 1058
 			}
1059 1059
 			
1060 1060
 		}
1061 1061
 		elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1062 1062
 		{
1063
-			if(is_array($parameters)) $i = & $parameters['i'];
1064
-			else $i = (int)$parameters;
1063
+			if (is_array($parameters)) $i = & $parameters['i'];
1064
+			else $i = (int) $parameters;
1065 1065
 			
1066 1066
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1067 1067
 			{
@@ -1082,24 +1082,24 @@  discard block
 block discarded – undo
1082 1082
 				}
1083 1083
 			}
1084 1084
 		}
1085
-		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1086
-		    if(is_array($parameters)) $i = & $parameters['i'];
1087
-		    else $i = (int)$parameters;
1085
+		if ((int) GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) {
1086
+		    if (is_array($parameters)) $i = & $parameters['i'];
1087
+		    else $i = (int) $parameters;
1088 1088
 		    $this->resprints = price($object->lines[$i]->total_ht);
1089 1089
 		}
1090 1090
 		if (!empty($hideprices)
1091
-		    || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1091
+		    || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1092 1092
 		    )
1093 1093
 		{
1094 1094
 		    if (!empty($hideprices))
1095 1095
 		    {
1096 1096
 		        
1097
-		        if(is_array($parameters)) $i = & $parameters['i'];
1098
-		        else $i = (int)$parameters;
1097
+		        if (is_array($parameters)) $i = & $parameters['i'];
1098
+		        else $i = (int) $parameters;
1099 1099
 		        
1100 1100
 		        // Check if a title exist for this line && if the title have subtotal
1101 1101
 		        $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1102
-		        if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1102
+		        if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1103 1103
 		        {
1104 1104
 		            $this->resprints = ' ';
1105 1105
 		            return 1;
@@ -1115,25 +1115,25 @@  discard block
 block discarded – undo
1115 1115
 		return 0;
1116 1116
 	}
1117 1117
 	
1118
-	function pdf_getlinetotalwithtax($parameters=array(), &$object, &$action='') {
1118
+	function pdf_getlinetotalwithtax($parameters = array(), &$object, &$action = '') {
1119 1119
 		global $conf;
1120 1120
 		
1121
-		if($this->isModSubtotalLine($parameters,$object) ){
1121
+		if ($this->isModSubtotalLine($parameters, $object)) {
1122 1122
 			
1123 1123
 			$this->resprints = ' ';
1124 1124
 		
1125
-			if((float)DOL_VERSION<=3.6) {
1125
+			if ((float) DOL_VERSION <= 3.6) {
1126 1126
 				return '';
1127 1127
 			}
1128
-			else if((float)DOL_VERSION>=3.8) {
1128
+			else if ((float) DOL_VERSION >= 3.8) {
1129 1129
 				return 1;
1130 1130
 			}
1131 1131
 		}
1132 1132
 		
1133
-		if(is_array($parameters)) $i = & $parameters['i'];
1134
-		else $i = (int)$parameters;
1133
+		if (is_array($parameters)) $i = & $parameters['i'];
1134
+		else $i = (int) $parameters;
1135 1135
 		
1136
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1136
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))) 
1137 1137
 		{
1138 1138
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1139 1139
 			{
@@ -1145,24 +1145,24 @@  discard block
 block discarded – undo
1145 1145
 		return 0;
1146 1146
 	}
1147 1147
 	
1148
-	function pdf_getlineunit($parameters=array(), &$object, &$action='') {
1148
+	function pdf_getlineunit($parameters = array(), &$object, &$action = '') {
1149 1149
 		global $conf;
1150 1150
 		
1151
-		if($this->isModSubtotalLine($parameters,$object) ){
1151
+		if ($this->isModSubtotalLine($parameters, $object)) {
1152 1152
 			$this->resprints = ' ';
1153 1153
 		
1154
-			if((float)DOL_VERSION<=3.6) {
1154
+			if ((float) DOL_VERSION <= 3.6) {
1155 1155
 				return '';
1156 1156
 			}
1157
-			else if((float)DOL_VERSION>=3.8) {
1157
+			else if ((float) DOL_VERSION >= 3.8) {
1158 1158
 				return 1;
1159 1159
 			}
1160 1160
 		}
1161 1161
 		
1162
-		if(is_array($parameters)) $i = & $parameters['i'];
1163
-		else $i = (int)$parameters;
1162
+		if (is_array($parameters)) $i = & $parameters['i'];
1163
+		else $i = (int) $parameters;
1164 1164
 			
1165
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1165
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1166 1166
 		{
1167 1167
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1168 1168
 			{
@@ -1174,24 +1174,24 @@  discard block
 block discarded – undo
1174 1174
 		return 0;
1175 1175
 	}
1176 1176
 	
1177
-	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1178
-		global $conf,$hideprices;
1177
+	function pdf_getlineupexcltax($parameters = array(), &$object, &$action = '') {
1178
+		global $conf, $hideprices;
1179 1179
 
1180
-		if($this->isModSubtotalLine($parameters,$object) ){
1180
+		if ($this->isModSubtotalLine($parameters, $object)) {
1181 1181
 			$this->resprints = ' ';
1182 1182
 		
1183
-			if((float)DOL_VERSION<=3.6) {
1183
+			if ((float) DOL_VERSION <= 3.6) {
1184 1184
 				return '';
1185 1185
 			}
1186
-			else if((float)DOL_VERSION>=3.8) {
1186
+			else if ((float) DOL_VERSION >= 3.8) {
1187 1187
 				return 1;
1188 1188
 			}
1189 1189
 		}
1190
-		if(is_array($parameters)) $i = & $parameters['i'];
1191
-		else $i = (int)$parameters;
1190
+		if (is_array($parameters)) $i = & $parameters['i'];
1191
+		else $i = (int) $parameters;
1192 1192
 		
1193 1193
 		if (!empty($hideprices) 
1194
-				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1194
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1195 1195
 		)
1196 1196
 		{
1197 1197
 			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1204,24 +1204,24 @@  discard block
 block discarded – undo
1204 1204
 		return 0;
1205 1205
 	}
1206 1206
 	
1207
-	function pdf_getlineupwithtax($parameters=array(), &$object, &$action='') {
1208
-		global $conf,$hideprices;
1207
+	function pdf_getlineupwithtax($parameters = array(), &$object, &$action = '') {
1208
+		global $conf, $hideprices;
1209 1209
 		
1210
-		if($this->isModSubtotalLine($parameters,$object) ){
1210
+		if ($this->isModSubtotalLine($parameters, $object)) {
1211 1211
 			$this->resprints = ' ';
1212
-			if((float)DOL_VERSION<=3.6) {
1212
+			if ((float) DOL_VERSION <= 3.6) {
1213 1213
 				return '';
1214 1214
 			}
1215
-			else if((float)DOL_VERSION>=3.8) {
1215
+			else if ((float) DOL_VERSION >= 3.8) {
1216 1216
 				return 1;
1217 1217
 			}
1218 1218
 		}
1219 1219
 		
1220
-		if(is_array($parameters)) $i = & $parameters['i'];
1221
-		else $i = (int)$parameters;
1220
+		if (is_array($parameters)) $i = & $parameters['i'];
1221
+		else $i = (int) $parameters;
1222 1222
 			
1223 1223
 		if (!empty($hideprices)
1224
-				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1224
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1225 1225
 		)
1226 1226
 		{
1227 1227
 			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1234,27 +1234,27 @@  discard block
 block discarded – undo
1234 1234
 		return 0;
1235 1235
 	}
1236 1236
 	
1237
-	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
1237
+	function pdf_getlinevatrate($parameters = array(), &$object, &$action = '') {
1238 1238
 		global $conf;
1239 1239
 		
1240
-		if($this->isModSubtotalLine($parameters,$object) ){
1240
+		if ($this->isModSubtotalLine($parameters, $object)) {
1241 1241
 			$this->resprints = ' ';
1242 1242
 			
1243
-			if((float)DOL_VERSION<=3.6) {
1243
+			if ((float) DOL_VERSION <= 3.6) {
1244 1244
 				return '';
1245 1245
 			}
1246
-			else if((float)DOL_VERSION>=3.8) {
1246
+			else if ((float) DOL_VERSION >= 3.8) {
1247 1247
 				return 1;
1248 1248
 			}
1249 1249
 		}
1250 1250
 		
1251
-		if(is_array($parameters)) $i = & $parameters['i'];
1252
-		else $i = (int)$parameters;
1251
+		if (is_array($parameters)) $i = & $parameters['i'];
1252
+		else $i = (int) $parameters;
1253 1253
 		
1254 1254
 		if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1255 1255
 
1256 1256
 		$object->lines[$i]->fetch_optionals();
1257
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1257
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1258 1258
 		{
1259 1259
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1260 1260
 			{
@@ -1266,23 +1266,23 @@  discard block
 block discarded – undo
1266 1266
 		return 0;
1267 1267
 	}
1268 1268
 		
1269
-	function pdf_getlineprogress($parameters=array(), &$object, &$action) {
1269
+	function pdf_getlineprogress($parameters = array(), &$object, &$action) {
1270 1270
 		global $conf;
1271 1271
 		
1272
-		if($this->isModSubtotalLine($parameters,$object) ){
1272
+		if ($this->isModSubtotalLine($parameters, $object)) {
1273 1273
 			$this->resprints = ' ';
1274
-			if((float)DOL_VERSION<=3.6) {
1274
+			if ((float) DOL_VERSION <= 3.6) {
1275 1275
 				return '';
1276 1276
 			}
1277
-			else if((float)DOL_VERSION>=3.8) {
1277
+			else if ((float) DOL_VERSION >= 3.8) {
1278 1278
 				return 1;
1279 1279
 			}
1280 1280
 		}
1281 1281
 		
1282
-		if(is_array($parameters)) $i = & $parameters['i'];
1283
-		else $i = (int)$parameters;
1282
+		if (is_array($parameters)) $i = & $parameters['i'];
1283
+		else $i = (int) $parameters;
1284 1284
 			
1285
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1285
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1286 1286
 		{
1287 1287
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1288 1288
 			{
@@ -1297,12 +1297,12 @@  discard block
 block discarded – undo
1297 1297
 	function add_numerotation(&$object) {
1298 1298
 		global $conf;
1299 1299
 		
1300
-		if(!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1300
+		if (!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1301 1301
 		
1302 1302
 			$TLevelTitre = array();
1303 1303
 			$prevlevel = 0;
1304 1304
 		
1305
-			foreach($object->lines as $k=>&$line) 
1305
+			foreach ($object->lines as $k=>&$line) 
1306 1306
 			{
1307 1307
 				if ($line->id > 0 && $this->isModSubtotalLine($k, $object) && $line->qty <= 10)
1308 1308
 				{
@@ -1316,12 +1316,12 @@  discard block
 block discarded – undo
1316 1316
 	}
1317 1317
 
1318 1318
 	// TODO ne gère pas encore la numération des lignes "Totaux"
1319
-	private function formatNumerotation(&$TLineTitle, $line_reference='', $level=1, $prefix_num=0)
1319
+	private function formatNumerotation(&$TLineTitle, $line_reference = '', $level = 1, $prefix_num = 0)
1320 1320
 	{
1321 1321
 		$TTitle = array();
1322 1322
 		
1323
-		$i=1;
1324
-		$j=0;
1323
+		$i = 1;
1324
+		$j = 0;
1325 1325
 		foreach ($TLineTitle as $k => &$line)
1326 1326
 		{
1327 1327
 			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
@@ -1331,7 +1331,7 @@  discard block
 block discarded – undo
1331 1331
 			{
1332 1332
 				$TTitle[$j]['numerotation'] = ($prefix_num == 0) ? $i : $prefix_num.'.'.$i;
1333 1333
 				//var_dump('Prefix == '.$prefix_num.' // '.$line->desc.' ==> numerotation == '.$TTitle[$j]['numerotation'].'   ###    '.$line->qty .'=='. $level);
1334
-				if (empty($line->label) && (float)DOL_VERSION < 6)
1334
+				if (empty($line->label) && (float) DOL_VERSION < 6)
1335 1335
 				{
1336 1336
 					$line->label = !empty($line->desc) ? $line->desc : $line->description;
1337 1337
 					$line->desc = $line->description = '';
@@ -1357,26 +1357,26 @@  discard block
 block discarded – undo
1357 1357
 	
1358 1358
 	function setDocTVA(&$pdf, &$object) {
1359 1359
 		
1360
-		$hidedetails = (int)GETPOST('hidedetails');
1360
+		$hidedetails = (int) GETPOST('hidedetails');
1361 1361
 		
1362
-		if(empty($hidedetails)) return false;
1362
+		if (empty($hidedetails)) return false;
1363 1363
 		
1364 1364
 		// TODO can't add VAT to document without lines... :-/
1365 1365
 		
1366 1366
 		return true;
1367 1367
 	}
1368 1368
 	
1369
-	function beforePDFCreation($parameters=array(), &$object, &$action)
1369
+	function beforePDFCreation($parameters = array(), &$object, &$action)
1370 1370
 	{
1371 1371
 		/**
1372 1372
 		 * @var $pdf    TCPDF
1373 1373
 		 */
1374
-		global $pdf,$conf, $langs;
1374
+		global $pdf, $conf, $langs;
1375 1375
 
1376 1376
 		// var_dump($object->lines);
1377 1377
 		dol_include_once('/subtotal/class/subtotal.class.php');
1378 1378
 
1379
-		foreach($parameters as $key=>$value) {
1379
+		foreach ($parameters as $key=>$value) {
1380 1380
 			${$key} = $value;
1381 1381
 		}
1382 1382
 		
@@ -1385,25 +1385,25 @@  discard block
 block discarded – undo
1385 1385
 		$this->add_numerotation($object);	
1386 1386
 		
1387 1387
 		
1388
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1389
-		$hidedetails = (int)GETPOST('hidedetails');
1388
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1389
+		$hidedetails = (int) GETPOST('hidedetails');
1390 1390
 		
1391 1391
 		if ($hideInnerLines) { // si c une ligne de titre
1392
-	    	$fk_parent_line=0;
1393
-			$TLines =array();
1392
+	    	$fk_parent_line = 0;
1393
+			$TLines = array();
1394 1394
 		
1395
-			$original_count=count($object->lines);
1395
+			$original_count = count($object->lines);
1396 1396
 		    $TTvas = array(); // tableau de tva
1397 1397
 		    
1398
-			foreach($object->lines as $k=>&$line) 
1398
+			foreach ($object->lines as $k=>&$line) 
1399 1399
 			{
1400 1400
 			    
1401
-				if($line->product_type==9 && $line->rowid>0) 
1401
+				if ($line->product_type == 9 && $line->rowid > 0) 
1402 1402
 				{
1403 1403
 					$fk_parent_line = $line->rowid;
1404 1404
 					
1405 1405
 					// Fix tk7201 - si on cache le détail, la TVA est renseigné au niveau du sous-total, l'erreur c'est s'il y a plusieurs sous-totaux pour les même lignes, ça va faire la somme
1406
-					if(TSubtotal::isSubtotal($line)) 
1406
+					if (TSubtotal::isSubtotal($line)) 
1407 1407
 					{
1408 1408
 						/*$total = $this->getTotalLineFromObject($object, $line, '');
1409 1409
 						
@@ -1423,22 +1423,22 @@  discard block
 block discarded – undo
1423 1423
 			
1424 1424
 				if ($hideInnerLines)
1425 1425
 				{
1426
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1426
+				    if (!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1427 1427
 				    {
1428
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1428
+				        if ($line->tva_tx != '0.000' && $line->product_type != 9) {
1429 1429
 				            
1430 1430
     				        // on remplit le tableau de tva pour substituer les lignes cachées
1431 1431
     				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1432 1432
     				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1433 1433
     				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1434 1434
     				    }
1435
-    					if($line->product_type==9 && $line->rowid>0)
1435
+    					if ($line->product_type == 9 && $line->rowid > 0)
1436 1436
     					{
1437 1437
     					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1438 1438
     					    // génère des lignes d'affichage des montants HT soumis à tva
1439 1439
     					    $nbtva = count($TTvas);
1440
-    					    if(!empty($nbtva)){
1441
-    					        foreach ($TTvas as $tx =>$val){
1440
+    					    if (!empty($nbtva)) {
1441
+    					        foreach ($TTvas as $tx =>$val) {
1442 1442
     					            $l = clone $line;
1443 1443
     					            $l->product_type = 1;
1444 1444
     					            $l->special_code = '';
@@ -1459,7 +1459,7 @@  discard block
 block discarded – undo
1459 1459
     					}
1460 1460
 				    } else {
1461 1461
 				        
1462
-				        if($line->product_type==9 && $line->rowid>0)
1462
+				        if ($line->product_type == 9 && $line->rowid > 0)
1463 1463
 				        {
1464 1464
 				            // ajoute la ligne de sous-total
1465 1465
 				            $TLines[] = $line; 
@@ -1487,9 +1487,9 @@  discard block
 block discarded – undo
1487 1487
 			
1488 1488
 			// cas incongru où il y aurait des produits en dessous du dernier sous-total
1489 1489
 			$nbtva = count($TTvas);
1490
-			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1490
+			if (!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1491 1491
 			{
1492
-			    foreach ($TTvas as $tx =>$val){
1492
+			    foreach ($TTvas as $tx =>$val) {
1493 1493
 			        $l = clone $line;
1494 1494
 			        $l->product_type = 1;
1495 1495
 			        $l->special_code = '';
@@ -1506,11 +1506,11 @@  discard block
 block discarded – undo
1506 1506
 			}
1507 1507
 			
1508 1508
 			global $nblignes;
1509
-			$nblignes=count($TLines);
1509
+			$nblignes = count($TLines);
1510 1510
 
1511 1511
 			$object->lines = $TLines;
1512 1512
 			
1513
-			if($i>count($object->lines)) {
1513
+			if ($i > count($object->lines)) {
1514 1514
 				$this->resprints = '';
1515 1515
 				return 0;
1516 1516
 			}
@@ -1519,59 +1519,59 @@  discard block
 block discarded – undo
1519 1519
 		return 0;
1520 1520
 	}
1521 1521
 
1522
-	function pdf_writelinedesc($parameters=array(), &$object, &$action)
1522
+	function pdf_writelinedesc($parameters = array(), &$object, &$action)
1523 1523
 	{
1524 1524
 		/**
1525 1525
 		 * @var $pdf    TCPDF
1526 1526
 		 */
1527
-		global $pdf,$conf;
1527
+		global $pdf, $conf;
1528 1528
 
1529
-		foreach($parameters as $key=>$value) {
1529
+		foreach ($parameters as $key=>$value) {
1530 1530
 			${$key} = $value;
1531 1531
 		}
1532 1532
 		
1533
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1534
-		$hidedetails = (int)GETPOST('hidedetails');
1533
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1534
+		$hidedetails = (int) GETPOST('hidedetails');
1535 1535
 		
1536
-		if($this->isModSubtotalLine($parameters,$object) ){			
1536
+		if ($this->isModSubtotalLine($parameters, $object)) {			
1537 1537
 		
1538 1538
 				global $hideprices;
1539 1539
 				
1540
-				if(!empty($hideprices)) {
1541
-					foreach($object->lines as &$line) {
1542
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1540
+				if (!empty($hideprices)) {
1541
+					foreach ($object->lines as &$line) {
1542
+						if ($line->fk_product_type != 9) $line->fk_parent_line = -1;	
1543 1543
 					}
1544 1544
 				}
1545 1545
 			
1546 1546
 				$line = &$object->lines[$i];
1547 1547
 				
1548
-				if($line->info_bits>0) { // PAGE BREAK
1548
+				if ($line->info_bits > 0) { // PAGE BREAK
1549 1549
 					$pdf->addPage();
1550 1550
 					$posy = $pdf->GetY();
1551 1551
 				}
1552 1552
 				
1553 1553
 				$label = $line->label;
1554
-				$description= !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1554
+				$description = !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1555 1555
 				
1556
-				if(empty($label)) {
1556
+				if (empty($label)) {
1557 1557
 					$label = $description;
1558
-					$description='';
1558
+					$description = '';
1559 1559
 				}
1560 1560
 				
1561
-				if($line->qty>90) {
1561
+				if ($line->qty > 90) {
1562 1562
 					
1563 1563
 					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1564 1564
 					
1565 1565
 					$pageBefore = $pdf->getPage();
1566
-					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1566
+					$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1567 1567
 					$pageAfter = $pdf->getPage();	
1568 1568
 
1569
-					if($pageAfter>$pageBefore) {
1569
+					if ($pageAfter > $pageBefore) {
1570 1570
 						//print "ST $pageAfter>$pageBefore<br>";
1571 1571
 						$pdf->rollbackTransaction(true);	
1572
-						$pdf->addPage('','', true);
1572
+						$pdf->addPage('', '', true);
1573 1573
 						$posy = $pdf->GetY();
1574
-						$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1574
+						$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1575 1575
 						$posy = $pdf->GetY();
1576 1576
 						//print 'add ST'.$pdf->getPage().'<br />';
1577 1577
 					}
@@ -1582,7 +1582,7 @@  discard block
 block discarded – undo
1582 1582
 				else if ($line->qty < 10) {
1583 1583
 					$pageBefore = $pdf->getPage();
1584 1584
 
1585
-					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
1585
+					$this->pdf_add_title($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h); 
1586 1586
 					$pageAfter = $pdf->getPage();	
1587 1587
 
1588 1588
 					
@@ -1657,9 +1657,9 @@  discard block
 block discarded – undo
1657 1657
 	 * @param $hookmanager  HookManager
1658 1658
 	 * @return int
1659 1659
 	 */
1660
-	function printObjectLine ($parameters, &$object, &$action, $hookmanager){
1660
+	function printObjectLine($parameters, &$object, &$action, $hookmanager) {
1661 1661
 		
1662
-		global $conf,$langs,$user,$db,$bc;
1662
+		global $conf, $langs, $user, $db, $bc;
1663 1663
 		
1664 1664
 		$num = &$parameters['num'];
1665 1665
 		$line = &$parameters['line'];
@@ -1667,32 +1667,32 @@  discard block
 block discarded – undo
1667 1667
 		
1668 1668
 		$var = &$parameters['var'];
1669 1669
 
1670
-		$contexts = explode(':',$parameters['context']);
1670
+		$contexts = explode(':', $parameters['context']);
1671 1671
 
1672 1672
 		$createRight = $user->rights->{$object->element}->creer;
1673
-		if($object->element == 'facturerec' )
1673
+		if ($object->element == 'facturerec')
1674 1674
 		{
1675 1675
 			$object->statut = 0; // hack for facture rec
1676 1676
 			$createRight = $user->rights->facture->creer;
1677 1677
 		}
1678
-		elseif($object->element == 'order_supplier' )
1678
+		elseif ($object->element == 'order_supplier')
1679 1679
 		{
1680 1680
 		    $createRight = $user->rights->fournisseur->commande->creer;
1681 1681
 		}
1682
-		elseif($object->element == 'invoice_supplier' )
1682
+		elseif ($object->element == 'invoice_supplier')
1683 1683
 		{
1684 1684
 		    $createRight = $user->rights->fournisseur->facture->creer;
1685 1685
 		}
1686 1686
 		
1687
-		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1687
+		if ($line->special_code != $this->module_number || $line->product_type != 9) {
1688 1688
 			null;
1689 1689
 		}	
1690
-		else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) 
1690
+		else if (in_array('invoicecard', $contexts) || in_array('invoicesuppliercard', $contexts) || in_array('propalcard', $contexts) || in_array('supplier_proposalcard', $contexts) || in_array('ordercard', $contexts) || in_array('ordersuppliercard', $contexts) || in_array('invoicereccard', $contexts)) 
1691 1691
         {
1692
-			if($object->element=='facture')$idvar = 'facid';
1693
-			else $idvar='id';
1692
+			if ($object->element == 'facture')$idvar = 'facid';
1693
+			else $idvar = 'id';
1694 1694
 			
1695
-			if((float)DOL_VERSION <= 3.4)
1695
+			if ((float) DOL_VERSION <= 3.4)
1696 1696
 			{
1697 1697
 				?>
1698 1698
 				<script type="text/javascript">
@@ -1716,20 +1716,20 @@  discard block
 block discarded – undo
1716 1716
 				<?php
1717 1717
 			}
1718 1718
 			
1719
-			if(empty($line->description)) $line->description = $line->desc;
1719
+			if (empty($line->description)) $line->description = $line->desc;
1720 1720
 			
1721 1721
 			$colspan = 5;
1722
-			if($object->element == 'facturerec' ) $colspan = 3;
1723
-			if($object->element == 'order_supplier') $colspan = 3;
1724
-			if($object->element == 'invoice_supplier') $colspan = 4;
1725
-			if($object->element == 'supplier_proposal') $colspan = 4;
1726
-			if(!empty($conf->multicurrency->enabled)) $colspan+=2;
1727
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1728
-			if(!empty($conf->margin->enabled)) $colspan++;
1729
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1730
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1731
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1732
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
1722
+			if ($object->element == 'facturerec') $colspan = 3;
1723
+			if ($object->element == 'order_supplier') $colspan = 3;
1724
+			if ($object->element == 'invoice_supplier') $colspan = 4;
1725
+			if ($object->element == 'supplier_proposal') $colspan = 4;
1726
+			if (!empty($conf->multicurrency->enabled)) $colspan += 2;
1727
+			if ($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1728
+			if (!empty($conf->margin->enabled)) $colspan++;
1729
+			if (!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1730
+			if (!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1731
+			if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1732
+			if (!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
1733 1733
 					
1734 1734
 			/* Titre */
1735 1735
 			//var_dump($line);
@@ -1739,35 +1739,35 @@  discard block
 block discarded – undo
1739 1739
             
1740 1740
 			
1741 1741
 			?>
1742
-			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
1742
+			<tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
1743 1743
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
1744 1744
 					{
1745
-						if($line->qty==99) print 'background:#adadcf';
1746
-						else if($line->qty==98) print 'background:#ddddff;';
1747
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
1748
-						else if($line->qty==1) print 'background:#adadcf;';
1749
-						else if($line->qty==2) print 'background:#ddddff;';
1750
-						else if($line->qty==50) print '';
1745
+						if ($line->qty == 99) print 'background:#adadcf';
1746
+						else if ($line->qty == 98) print 'background:#ddddff;';
1747
+						else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;';
1748
+						else if ($line->qty == 1) print 'background:#adadcf;';
1749
+						else if ($line->qty == 2) print 'background:#ddddff;';
1750
+						else if ($line->qty == 50) print '';
1751 1751
 						else print 'background:#eeeeff;';
1752 1752
 
1753 1753
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
1754 1754
 					}
1755 1755
 					else 
1756 1756
 					{
1757
-						if($line->qty==99) print 'background:#ddffdd';
1758
-						else if($line->qty==98) print 'background:#ddddff;';
1759
-						else if($line->qty==2) print 'background:#eeeeff; ';
1760
-						else if($line->qty==50) print '';
1761
-						else print 'background:#eeffee;' ;
1757
+						if ($line->qty == 99) print 'background:#ddffdd';
1758
+						else if ($line->qty == 98) print 'background:#ddddff;';
1759
+						else if ($line->qty == 2) print 'background:#eeeeff; ';
1760
+						else if ($line->qty == 50) print '';
1761
+						else print 'background:#eeffee;';
1762 1762
 					}
1763 1763
 
1764 1764
 			?>;">
1765 1765
 			
1766
-				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
1767
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
1766
+				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php
1767
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
1768 1768
 
1769
-						$params=array('line'=>$line);
1770
-						$reshook=$hookmanager->executeHooks('formEditProductOptions',$params,$object,$action);
1769
+						$params = array('line'=>$line);
1770
+						$reshook = $hookmanager->executeHooks('formEditProductOptions', $params, $object, $action);
1771 1771
 						
1772 1772
 						echo '<div id="line_'.$line->id.'"></div>'; // Imitation Dolibarr
1773 1773
 						echo '<input type="hidden" value="'.$line->id.'" name="lineid">';
@@ -1775,7 +1775,7 @@  discard block
 block discarded – undo
1775 1775
 						echo '<input id="product_id" type="hidden" value="'.$line->fk_product.'" name="type">';
1776 1776
 						echo '<input id="special_code" type="hidden" value="'.$line->special_code.'" name="type">';
1777 1777
 
1778
-						$isFreeText=false;
1778
+						$isFreeText = false;
1779 1779
 						if (TSubtotal::isTitle($line))
1780 1780
 						{
1781 1781
 							$qty_displayed = $line->qty;
@@ -1797,13 +1797,13 @@  discard block
 block discarded – undo
1797 1797
 						    $line->description = '';
1798 1798
 						}
1799 1799
 						$newlabel = $line->label;
1800
-						if($line->label=='' && !$isFreeText) {
1801
-							if(TSubtotal::isSubtotal($line)) {
1800
+						if ($line->label == '' && !$isFreeText) {
1801
+							if (TSubtotal::isSubtotal($line)) {
1802 1802
 								$newlabel = $line->description.' '.$this->getTitle($object, $line);
1803
-								$line->description='';
1804
-							} elseif( (float)DOL_VERSION < 6 ) {
1805
-								$newlabel= $line->description;
1806
-								$line->description='';
1803
+								$line->description = '';
1804
+							} elseif ((float) DOL_VERSION < 6) {
1805
+								$newlabel = $line->description;
1806
+								$line->description = '';
1807 1807
 							}
1808 1808
 						}
1809 1809
 
@@ -1812,10 +1812,10 @@  discard block
 block discarded – undo
1812 1812
 						
1813 1813
 						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
1814 1814
 						
1815
-						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
1815
+						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)))
1816 1816
 						{
1817 1817
 							$select = '<select name="subtotal_level">';
1818
-							for ($j=1; $j<10; $j++)
1818
+							for ($j = 1; $j < 10; $j++)
1819 1819
 							{
1820 1820
 								if (!empty($readonlyForSituation)) {
1821 1821
 									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
@@ -1828,7 +1828,7 @@  discard block
 block discarded – undo
1828 1828
 						
1829 1829
 
1830 1830
 						echo '<div class="subtotal_underline" style="margin-left:24px;">';
1831
-							echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label> <input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;&nbsp;';
1831
+							echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label> <input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '').' />&nbsp;&nbsp;';
1832 1832
 
1833 1833
 							if (TSubtotal::isTitle($line))
1834 1834
 							{
@@ -1846,9 +1846,9 @@  discard block
 block discarded – undo
1846 1846
 							else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
1847 1847
 						echo '</div>';
1848 1848
 
1849
-						if($line->qty<10) {
1849
+						if ($line->qty < 10) {
1850 1850
 							// WYSIWYG editor
1851
-							require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
1851
+							require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1852 1852
 							$nbrows = ROWS_2;
1853 1853
 							$cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
1854 1854
 							if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
@@ -1868,25 +1868,25 @@  discard block
 block discarded – undo
1868 1868
 
1869 1869
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
1870 1870
 						 {
1871
-							if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
1871
+							if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
1872 1872
 							{
1873
-								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
1873
+								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
1874 1874
 								
1875 1875
 								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
1876
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
1876
+								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
1877 1877
 							}
1878 1878
 						 }
1879 1879
 						 else 
1880 1880
 						 {
1881
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
1882
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
1881
+							if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal');
1882
+							else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
1883 1883
 						 }
1884 1884
 						 
1885 1885
 						 
1886 1886
 						 // Get display styles and apply them
1887 1887
 						 $titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
1888
-						 $titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
1889
-						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
1888
+						 $titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
1889
+						 $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
1890 1890
 						 
1891 1891
 						 if (empty($line->label)) {
1892 1892
 							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
@@ -1894,16 +1894,16 @@  discard block
 block discarded – undo
1894 1894
 						 } 
1895 1895
 						 else {
1896 1896
 
1897
-							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
1897
+							if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
1898 1898
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
1899 1899
 							}
1900
-							else{
1900
+							else {
1901 1901
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
1902 1902
 							}
1903 1903
 
1904 1904
 						 } 
1905
-						if($line->qty>90) print ' : ';
1906
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
1905
+						if ($line->qty > 90) print ' : ';
1906
+						if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
1907 1907
 
1908 1908
 						 
1909 1909
 
@@ -1912,7 +1912,7 @@  discard block
 block discarded – undo
1912 1912
 			?></td>
1913 1913
 					 
1914 1914
 			<?php
1915
-				if($line->qty>90) {
1915
+				if ($line->qty > 90) {
1916 1916
 					/* Total */
1917 1917
 					$total_line = $this->getTotalLineFromObject($object, $line, '');
1918 1918
 					echo '<td class="nowrap liencolht" align="right" style="font-weight:bold;" rel="subtotal_total">'.price($total_line).'</td>';
@@ -1925,7 +1925,7 @@  discard block
 block discarded – undo
1925 1925
 				<?php
1926 1926
 				if ($action != 'selectlines') {
1927 1927
 				
1928
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
1928
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
1929 1929
 						?>
1930 1930
 						<input id="savelinebutton" class="button" type="submit" name="save" value="<?php echo $langs->trans('Save') ?>" />
1931 1931
 						<br />
@@ -1941,13 +1941,13 @@  discard block
 block discarded – undo
1941 1941
 						<?php
1942 1942
 						
1943 1943
 					}
1944
-					else{
1945
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
1944
+					else {
1945
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
1946 1946
 						{
1947
-							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
1947
+							if (TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref)) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'.img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
1948 1948
 						}
1949 1949
 
1950
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
1950
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
1951 1951
 						{
1952 1952
 							echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=editline&lineid='.$line->id.'">'.img_edit().'</a>';
1953 1953
 						}								
@@ -1962,7 +1962,7 @@  discard block
 block discarded – undo
1962 1962
 				<?php
1963 1963
 
1964 1964
 				if ($action != 'editline' && $action != 'selectlines') {
1965
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
1965
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
1966 1966
 						{
1967 1967
 
1968 1968
 							if ($object->situation_counter == 1 || !$object->situation_cycle_ref)
@@ -1970,7 +1970,7 @@  discard block
 block discarded – undo
1970 1970
 								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteline&lineid='.$line->id.'">'.img_delete().'</a>';
1971 1971
 							}
1972 1972
 
1973
-							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) )
1973
+							if (TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref))
1974 1974
 							{
1975 1975
 								$img_delete = ((float) DOL_VERSION >= 3.8) ? img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal') : img_picto($langs->trans('deleteWithAllLines'), 'delete_all@subtotal');
1976 1976
 								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteallline&lineid='.$line->id.'">'.$img_delete.'</a>';
@@ -1981,7 +1981,7 @@  discard block
 block discarded – undo
1981 1981
 			</td>
1982 1982
 			
1983 1983
 			<?php 
1984
-			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
1984
+			if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
1985 1985
 			{
1986 1986
 				echo '<td class="subtotal_nc">';
1987 1987
 				echo '<input id="subtotal_nc-'.$line->id.'" class="subtotal_nc_chkbx" data-lineid="'.$line->id.'" type="checkbox" name="subtotal_nc" value="1" '.(!empty($line->array_options['options_subtotal_nc']) ? 'checked="checked"' : '').' />';
@@ -1992,11 +1992,11 @@  discard block
 block discarded – undo
1992 1992
 			<td align="center" class="tdlineupdown">
1993 1993
 			</td>
1994 1994
 			<?php } else { ?>
1995
-			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0  && $createRight ))?' class="tdlineupdown"':''); ?>></td>
1995
+			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0 && $createRight)) ? ' class="tdlineupdown"' : ''); ?>></td>
1996 1996
 			<?php } ?>
1997 1997
 
1998
-			<?php  if($action == 'selectlines'){ // dolibarr 8 ?>
1999
-			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
1998
+			<?php  if ($action == 'selectlines') { // dolibarr 8 ?>
1999
+			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i + 1; ?>]" value="<?php echo $line->id; ?>" ></td>
2000 2000
 			<?php } ?>
2001 2001
 
2002 2002
 			</tr>
@@ -2004,29 +2004,29 @@  discard block
 block discarded – undo
2004 2004
 			
2005 2005
 			
2006 2006
 			// Affichage des extrafields à la Dolibarr (car sinon non affiché sur les titres)
2007
-			if(TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2007
+			if (TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2008 2008
 				
2009
-				require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
2009
+				require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
2010 2010
 				
2011 2011
 				// Extrafields
2012 2012
 				$extrafieldsline = new ExtraFields($db);
2013 2013
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2014 2014
 				
2015
-				$colspan+=3; $mode = 'view';
2016
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2015
+				$colspan += 3; $mode = 'view';
2016
+				if ($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2017 2017
 				
2018 2018
 				$ex_element = $line->element;
2019 2019
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
2020
-				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ','colspan'=>$colspan));
2020
+				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ', 'colspan'=>$colspan));
2021 2021
 				$isExtraSelected = false;
2022
-				foreach($line->array_options as $option) {
2023
-					if(!empty($option) && $option != "-1") {
2022
+				foreach ($line->array_options as $option) {
2023
+					if (!empty($option) && $option != "-1") {
2024 2024
 						$isExtraSelected = true;
2025 2025
 						break;
2026 2026
 					}
2027 2027
 				}
2028 2028
 				
2029
-				if($mode === 'edit') {
2029
+				if ($mode === 'edit') {
2030 2030
 					?>
2031 2031
 					<script>
2032 2032
 						$(document).ready(function(){
@@ -2034,7 +2034,7 @@  discard block
 block discarded – undo
2034 2034
 							var all_tr_extrafields = $("tr.tr_extrafield_title");
2035 2035
 							<?php 
2036 2036
 							// Si un extrafield est rempli alors on affiche directement les extrafields
2037
-							if(!$isExtraSelected) {
2037
+							if (!$isExtraSelected) {
2038 2038
 								echo 'all_tr_extrafields.hide();';
2039 2039
 								echo 'var trad = "'.$langs->trans('showExtrafields').'";';
2040 2040
 								echo 'var extra = 0;';
@@ -2080,20 +2080,20 @@  discard block
 block discarded – undo
2080 2080
 
2081 2081
 	
2082 2082
 	function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) {
2083
-		global $conf,$langs;
2083
+		global $conf, $langs;
2084 2084
 		 
2085 2085
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2086 2086
 		{
2087 2087
 		    
2088
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2088
+		    if ($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2089 2089
 		    {
2090 2090
 		        foreach ($object->lines as $line)
2091 2091
 		        {
2092 2092
 		            // fetch optionals attributes and labels
2093 2093
 		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2094
-		            $extrafields=new ExtraFields($this->db);
2095
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2096
-		            $line->fetch_optionals($line->id,$extralabels);
2094
+		            $extrafields = new ExtraFields($this->db);
2095
+		            $extralabels = $extrafields->fetch_name_optionals_label($object->table_element_line, true);
2096
+		            $line->fetch_optionals($line->id, $extralabels);
2097 2097
 		        }
2098 2098
 		    }
2099 2099
 		    
@@ -2193,23 +2193,23 @@  discard block
 block discarded – undo
2193 2193
 	    $ThtmlData['data-qty']          = 0; //$line->qty;
2194 2194
 	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2195 2195
 	    
2196
-	    if(TSubtotal::isTitle($line)){
2196
+	    if (TSubtotal::isTitle($line)) {
2197 2197
 	        $ThtmlData['data-issubtotal'] = 'title';
2198
-	    }elseif(TSubtotal::isSubtotal($line)){
2198
+	    }elseif (TSubtotal::isSubtotal($line)) {
2199 2199
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2200 2200
 	    }
2201
-	    else{
2201
+	    else {
2202 2202
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2203 2203
 	    }
2204 2204
 	    
2205 2205
 	    
2206 2206
 	    // Change or add data  from hooks
2207
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2207
+	    $parameters = array_replace($parameters, array('ThtmlData' => $ThtmlData));
2208 2208
 	    
2209 2209
 	    // hook 
2210
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2210
+	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2211 2211
 	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2212
-	    if ($reshook>0)
2212
+	    if ($reshook > 0)
2213 2213
 	    {
2214 2214
 	        $ThtmlData = $hookmanager->resArray;
2215 2215
 	    }
@@ -2222,14 +2222,14 @@  discard block
 block discarded – undo
2222 2222
 	function implodeHtmlData($ThtmlData = array())
2223 2223
 	{
2224 2224
 	    $data = '';
2225
-	    foreach($ThtmlData as $k => $h )
2225
+	    foreach ($ThtmlData as $k => $h)
2226 2226
 	    {
2227
-	        if(is_array($h))
2227
+	        if (is_array($h))
2228 2228
 	        {
2229 2229
 	            $h = json_encode($h);
2230 2230
 	        }
2231 2231
 	        
2232
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2232
+	        $data .= $k.'="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2233 2233
 	    }
2234 2234
 	    
2235 2235
 	    return $data;
@@ -2237,26 +2237,26 @@  discard block
 block discarded – undo
2237 2237
 	
2238 2238
 	function _ajax_block_order_js($object)
2239 2239
 	{
2240
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2240
+	    global $conf, $tagidfortablednd, $filepath, $langs;
2241 2241
 	    
2242 2242
 	    /*
2243 2243
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2244 2244
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2245 2245
 	     */
2246 2246
 	    
2247
-	    $id=$object->id;
2248
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2249
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2247
+	    $id = $object->id;
2248
+	    $nboflines = (isset($object->lines) ?count($object->lines) : 0);
2249
+	    $forcereloadpage = empty($conf->global->MAIN_FORCE_RELOAD_PAGE) ? 0 : 1;
2250 2250
 	    
2251
-	    $id=$object->id;
2252
-	    $fk_element=$object->fk_element;
2253
-	    $table_element_line=$object->table_element_line;
2254
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2255
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2256
-	    $filepath=(empty($filepath)?'':$filepath);
2251
+	    $id = $object->id;
2252
+	    $fk_element = $object->fk_element;
2253
+	    $table_element_line = $object->table_element_line;
2254
+	    $nboflines = (isset($object->lines) ?count($object->lines) : (empty($nboflines) ? 0 : $nboflines));
2255
+	    $tagidfortablednd = (empty($tagidfortablednd) ? 'tablelines' : $tagidfortablednd);
2256
+	    $filepath = (empty($filepath) ? '' : $filepath);
2257 2257
 	    
2258 2258
 	    
2259
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2259
+	    if (GETPOST('action', 'aZ09') != 'editline' && $nboflines > 1)
2260 2260
 	    {
2261 2261
 	        
2262 2262
 	        ?>
@@ -2274,7 +2274,7 @@  discard block
 block discarded – undo
2274 2274
 				moveBlockCol.disableSelection(); // prevent selection
2275 2275
 <?php if ($object->statut == 0) { ?>
2276 2276
 				// apply some graphical stuff
2277
-				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png',2);  ?>)');
2277
+				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png', 2); ?>)');
2278 2278
 				moveBlockCol.css("background-repeat","no-repeat");
2279 2279
 				moveBlockCol.css("background-position","center center");
2280 2280
 				moveBlockCol.css("cursor","move");
Please login to merge, or discard this patch.
Braces   +353 added lines, -215 removed lines patch added patch discarded remove patch
@@ -75,8 +75,11 @@  discard block
 block discarded – undo
75 75
 			if ($object->statut == 0  && $createRight) {
76 76
 			
77 77
 
78
-				if($object->element=='facture')$idvar = 'facid';
79
-				else $idvar='id';
78
+				if($object->element=='facture') {
79
+					$idvar = 'facid';
80
+				} else {
81
+					$idvar='id';
82
+				}
80 83
 				
81 84
 				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
82 85
 				{
@@ -84,10 +87,11 @@  discard block
 block discarded – undo
84 87
 					
85 88
 					if($action=='add_title_line') {
86 89
 						$title = GETPOST('title');
87
-						if(empty($title)) $title = $langs->trans('title');
90
+						if(empty($title)) {
91
+							$title = $langs->trans('title');
92
+						}
88 93
 						$qty = $level<1 ? 1 : $level ;
89
-					}
90
-					else if($action=='add_free_text') {
94
+					} else if($action=='add_free_text') {
91 95
 						$title = GETPOST('title');
92 96
 
93 97
 						if (empty($title)) {
@@ -99,29 +103,31 @@  discard block
 block discarded – undo
99 103
 								}
100 104
 							}
101 105
 						}
102
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
106
+						if(empty($title)) {
107
+							$title = $langs->trans('subtotalAddLineDescription');
108
+						}
103 109
 						$qty = 50;
104
-					}
105
-					else if($action=='add_subtitle_line') {
110
+					} else if($action=='add_subtitle_line') {
106 111
 						$title = GETPOST('title');
107
-						if(empty($title)) $title = $langs->trans('subtitle');
112
+						if(empty($title)) {
113
+							$title = $langs->trans('subtitle');
114
+						}
108 115
 						$qty = 2;
109
-					}
110
-					else if($action=='add_subtotal_line') {
116
+					} else if($action=='add_subtotal_line') {
111 117
 						$title = $langs->trans('SubSubTotal');
112 118
 						$qty = 98;
113
-					}
114
-					else {
119
+					} else {
115 120
 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
116 121
 						$qty = $level ? 100-$level : 99;
117 122
 					}
118 123
 					dol_include_once('/subtotal/class/subtotal.class.php');
119 124
 					
120
-					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
125
+					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) {
126
+						TSubtotal::addSubtotalMissing($object, $qty);
127
+					}
121 128
 					
122 129
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
123
-				}
124
-				else if($action==='ask_deleteallline') {
130
+				} else if($action==='ask_deleteallline') {
125 131
 						$form=new Form($db);
126 132
 						
127 133
 						$lineid = GETPOST('lineid','integer');
@@ -144,8 +150,7 @@  discard block
 block discarded – undo
144 150
 					$this->printNewFormat($object, $conf, $langs, $idvar);
145 151
 				}
146 152
 			}
147
-		}
148
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
153
+		} elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
149 154
 		{
150 155
 			?>
151 156
 			<script type="text/javascript">
@@ -163,8 +168,13 @@  discard block
 block discarded – undo
163 168
      
164 169
 	function printNewFormat(&$object, &$conf, &$langs, $idvar)
165 170
 	{
166
-		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) return false;
167
-		if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) return false; // Si facture de situation
171
+		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) {
172
+			return false;
173
+		}
174
+		if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) {
175
+			return false;
176
+		}
177
+		// Si facture de situation
168 178
 		?>
169 179
 		 	<script type="text/javascript">
170 180
 				$(document).ready(function() {
@@ -450,8 +460,7 @@  discard block
 block discarded – undo
450 460
 				}
451 461
 				
452 462
 				
453
-			}	
454
-			else{
463
+			} else{
455 464
 				$substitutionarray['line_not_modsubtotal'] = true;
456 465
 				$substitutionarray['line_modsubtotal'] = 0;
457 466
 			}
@@ -509,8 +518,11 @@  discard block
 block discarded – undo
509 518
 		
510 519
 		$showBlockExtrafields = GETPOST('showBlockExtrafields');
511 520
 		
512
-		if($object->element=='facture') $idvar = 'facid';
513
-		else $idvar = 'id';
521
+		if($object->element=='facture') {
522
+			$idvar = 'facid';
523
+		} else {
524
+			$idvar = 'id';
525
+		}
514 526
 			
515 527
 		if ($action == 'updateligne' || $action == 'updateline')
516 528
 		{
@@ -540,8 +552,7 @@  discard block
 block discarded – undo
540 552
 				header('Location: '.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id);
541 553
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
542 554
 			}
543
-		}
544
-		else if($action === 'builddoc') {
555
+		} else if($action === 'builddoc') {
545 556
 			
546 557
 			if (
547 558
 				in_array('invoicecard',explode(':',$parameters['context']))
@@ -556,33 +567,27 @@  discard block
 block discarded – undo
556 567
 					$sessname = 'subtotal_hideInnerLines_facture';	
557 568
 					$sessname2 = 'subtotal_hidedetails_facture';
558 569
 					$sessname3 = 'subtotal_hideprices_facture';
559
-				}
560
-				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
570
+				} elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
561 571
 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
562 572
 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
563 573
 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
564
-				}
565
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
574
+				} elseif(in_array('propalcard',explode(':',$parameters['context']))) {
566 575
 					$sessname = 'subtotal_hideInnerLines_propal';
567 576
 					$sessname2 = 'subtotal_hidedetails_propal';	
568 577
 					$sessname3 = 'subtotal_hideprices_propal';
569
-				}
570
-				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
578
+				} elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
571 579
 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
572 580
 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
573 581
 				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
574
-				}
575
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
582
+				} elseif(in_array('ordercard',explode(':',$parameters['context']))) {
576 583
 					$sessname = 'subtotal_hideInnerLines_commande';
577 584
 					$sessname2 = 'subtotal_hidedetails_commande';	
578 585
 					$sessname3 = 'subtotal_hideprices_commande';
579
-				}
580
-				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
586
+				} elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
581 587
 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
582 588
 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
583 589
 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
584
-				}
585
-				else {
590
+				} else {
586 591
 					$sessname = 'subtotal_hideInnerLines_unknown';
587 592
 					$sessname2 = 'subtotal_hidedetails_unknown';
588 593
 					$sessname3 = 'subtotal_hideprices_unknown';
@@ -604,8 +609,7 @@  discard block
 block discarded – undo
604 609
 					    
605 610
                         if($line->qty>=90) {
606 611
                             $line->modsubtotal_total = 1;
607
-                        }
608
-                        else{
612
+                        } else{
609 613
                             $line->modsubtotal_title = 1;
610 614
                         }
611 615
                         
@@ -614,8 +618,7 @@  discard block
 block discarded – undo
614 618
 	        	}
615 619
 	        }
616 620
 			
617
-		}
618
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
621
+		} else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
619 622
 			
620 623
 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
621 624
 			
@@ -623,7 +626,9 @@  discard block
 block discarded – undo
623 626
 				/**
624 627
 				 * @var $object Facture
625 628
 				 */
626
-				if($object->element=='facture') $object->deleteline($idLine);
629
+				if($object->element=='facture') {
630
+					$object->deleteline($idLine);
631
+				}
627 632
 				/**
628 633
 				 * @var $object Facture fournisseur
629 634
 				 */
@@ -634,18 +639,25 @@  discard block
 block discarded – undo
634 639
 				/**
635 640
 				 * @var $object Propal
636 641
 				 */
637
-				else if($object->element=='propal') $object->deleteline($idLine);
642
+				else if($object->element=='propal') {
643
+					$object->deleteline($idLine);
644
+				}
638 645
 				/**
639 646
 				 * @var $object Propal Fournisseur
640 647
 				 */
641
-				else if($object->element=='supplier_proposal') $object->deleteline($idLine);
648
+				else if($object->element=='supplier_proposal') {
649
+					$object->deleteline($idLine);
650
+				}
642 651
 				/**
643 652
 				 * @var $object Commande
644 653
 				 */
645 654
 				else if($object->element=='commande') 
646 655
 				{
647
-					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
648
-					else $object->deleteline($idLine);
656
+					if ((float) DOL_VERSION >= 5.0) {
657
+						$object->deleteline($user, $idLine);
658
+					} else {
659
+						$object->deleteline($idLine);
660
+					}
649 661
 				}
650 662
 				/**
651 663
 				 * @var $object Commande fournisseur
@@ -657,21 +669,26 @@  discard block
 block discarded – undo
657 669
 				/**
658 670
 				 * @var $object Facturerec
659 671
 				 */
660
-				else if($object->element=='facturerec') $object->deleteline($idLine);
672
+				else if($object->element=='facturerec') {
673
+					$object->deleteline($idLine);
674
+				}
661 675
 			}
662 676
 			
663 677
 			header('location:?id='.$object->id);
664 678
 			exit;
665 679
 			
666
-		}
667
-		else if ($action == 'duplicate')
680
+		} else if ($action == 'duplicate')
668 681
 		{
669 682
 			$lineid = GETPOST('lineid', 'int');
670 683
 			$nbDuplicate = TSubtotal::duplicateLines($object, $lineid, true);
671 684
 			
672
-			if ($nbDuplicate > 0) setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
673
-			elseif ($nbDuplicate == 0) setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
674
-			else setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
685
+			if ($nbDuplicate > 0) {
686
+				setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
687
+			} elseif ($nbDuplicate == 0) {
688
+				setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
689
+			} else {
690
+				setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
691
+			}
675 692
 			
676 693
 			header('Location: ?id='.$object->id);
677 694
 			exit;
@@ -751,17 +768,18 @@  discard block
 block discarded – undo
751 768
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
752 769
 			if($l->rang>=$rang) {
753 770
 				//echo 'return!<br>';
754
-				if (!$return_all) return $total;
755
-				else return array($total, $total_tva, $total_ttc, $TTotal_tva);
756
-			}
757
-			else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
771
+				if (!$return_all) {
772
+					return $total;
773
+				} else {
774
+					return array($total, $total_tva, $total_ttc, $TTotal_tva);
775
+				}
776
+			} else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
758 777
 		  	{
759 778
 				$total = 0;
760 779
 				$total_tva = 0;
761 780
 				$total_ttc = 0;
762 781
 				$TTotal_tva = array();
763
-			}
764
-			elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
782
+			} elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
765 783
 				$total += $l->total_ht;
766 784
 				$total_tva += $l->total_tva;
767 785
 				$TTotal_tva[$l->tva_tx] += $l->total_tva;
@@ -769,8 +787,11 @@  discard block
 block discarded – undo
769 787
 			}
770 788
 			
771 789
 		}
772
-		if (!$return_all) return $total;
773
-		else return array($total, $total_tva, $total_ttc, $TTotal_tva);
790
+		if (!$return_all) {
791
+			return $total;
792
+		} else {
793
+			return array($total, $total_tva, $total_ttc, $TTotal_tva);
794
+		}
774 795
 	}
775 796
 
776 797
 	/*
@@ -838,15 +859,18 @@  discard block
 block discarded – undo
838 859
 		}
839 860
 		
840 861
 			
841
-		if($line->qty==99)
842
-			$pdf->SetFillColor(220,220,220);
843
-		elseif ($line->qty==98)
844
-			$pdf->SetFillColor(230,230,230);
845
-		else
846
-			$pdf->SetFillColor(240,240,240);
862
+		if($line->qty==99) {
863
+					$pdf->SetFillColor(220,220,220);
864
+		} elseif ($line->qty==98) {
865
+					$pdf->SetFillColor(230,230,230);
866
+		} else {
867
+					$pdf->SetFillColor(240,240,240);
868
+		}
847 869
 		
848 870
 		$style = 'B';
849
-		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
871
+		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) {
872
+			$style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
873
+		}
850 874
 		
851 875
 		$pdf->SetFont('', $style, 9);
852 876
 		
@@ -885,8 +909,7 @@  discard block
 block discarded – undo
885 909
 //					$line->total_tva
886 910
 //					$line->total
887 911
 //					$line->total_ttc
888
-				}
889
-				else
912
+				} else
890 913
 				{
891 914
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
892 915
                                         if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
@@ -903,11 +926,14 @@  discard block
 block discarded – undo
903 926
 			}
904 927
 
905 928
 			$pdf->SetXY($pdf->postotalht, $posy);
906
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
929
+			if($set_pagebreak_margin) {
930
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
931
+			}
907 932
 			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
908
-		}
909
-		else{
910
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
933
+		} else{
934
+			if($set_pagebreak_margin) {
935
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
936
+			}
911 937
 		}
912 938
 		
913 939
 		$posy = $posy + $cell_height;
@@ -939,25 +965,40 @@  discard block
 block discarded – undo
939 965
 		
940 966
  
941 967
 		$style = ($line->qty==1) ? 'BU' : 'BUI';
942
-		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
968
+		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) {
969
+			$style = $conf->global->SUBTOTAL_TITLE_STYLE;
970
+		}
943 971
 		
944 972
 		if($hideInnerLines) {
945
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
946
-			else 
973
+			if($line->qty==1) {
974
+				$pdf->SetFont('', $style, 9);
975
+			} else 
947 976
 			{
948
-				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
977
+				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) {
978
+					$style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
979
+				}
949 980
 				$pdf->SetFont('', $style, 9);
950 981
 			}
951
-		}
952
-		else {
982
+		} else {
953 983
 
954
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
955
-			else $pdf->SetFont('', $style, 9);
984
+			if($line->qty==1) {
985
+				$pdf->SetFont('', $style, 9);
986
+			}
987
+			//TODO if super utile
988
+			else {
989
+				$pdf->SetFont('', $style, 9);
990
+			}
956 991
 			
957 992
 		}
958 993
 		
959
-		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) $pdf->MultiCell($w, $h, $label, 0, 'L'); // Pas de HTML dans la chaine
960
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
994
+		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) {
995
+			$pdf->MultiCell($w, $h, $label, 0, 'L');
996
+		}
997
+		// Pas de HTML dans la chaine
998
+		else {
999
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true);
1000
+		}
1001
+		// et maintenant avec du HTML
961 1002
 		
962 1003
 		if($description && !$hidedesc) {
963 1004
 			$posy = $pdf->GetY();
@@ -981,8 +1022,7 @@  discard block
 block discarded – undo
981 1022
 		
982 1023
 		if(is_array($parameters)) {
983 1024
 			$i = & $parameters['i'];	
984
-		}
985
-		else {
1025
+		} else {
986 1026
 			$i = (int)$parameters;
987 1027
 		}
988 1028
 		
@@ -1004,17 +1044,14 @@  discard block
 block discarded – undo
1004 1044
 			
1005 1045
 			if((float)DOL_VERSION<=3.6) {
1006 1046
 				return '';
1007
-			}
1008
-			else if((float)DOL_VERSION>=3.8) {
1047
+			} else if((float)DOL_VERSION>=3.8) {
1009 1048
 				return 1;
1010 1049
 			}
1011 1050
 			
1012
-		}
1013
-		elseif(!empty($hideprices)) {
1051
+		} elseif(!empty($hideprices)) {
1014 1052
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1015 1053
 			return 1;
1016
-		}
1017
-		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1054
+		} elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1018 1055
 		{
1019 1056
 			$hideInnerLines = (int)GETPOST('hideInnerLines');
1020 1057
 			$hidedetails = (int)GETPOST('hidedetails');
@@ -1024,12 +1061,20 @@  discard block
 block discarded – undo
1024 1061
 			}
1025 1062
 		}
1026 1063
 		
1027
-		if(is_array($parameters)) $i = & $parameters['i'];
1028
-		else $i = (int)$parameters;
1064
+		if(is_array($parameters)) {
1065
+			$i = & $parameters['i'];
1066
+		} else {
1067
+			$i = (int)$parameters;
1068
+		}
1029 1069
 
1030
-		if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1070
+		if (empty($object->lines[$i])) {
1071
+			return 0;
1072
+		}
1073
+		// hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1031 1074
 		
1032
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1075
+		if(empty($object->lines[$i]->array_options)) {
1076
+			$object->lines[$i]->fetch_optionals();
1077
+		}
1033 1078
 
1034 1079
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1035 1080
 		{
@@ -1052,16 +1097,17 @@  discard block
 block discarded – undo
1052 1097
 			
1053 1098
 			if((float)DOL_VERSION<=3.6) {
1054 1099
 				return '';
1055
-			}
1056
-			else if((float)DOL_VERSION>=3.8) {
1100
+			} else if((float)DOL_VERSION>=3.8) {
1057 1101
 				return 1;
1058 1102
 			}
1059 1103
 			
1060
-		}
1061
-		elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1104
+		} elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1062 1105
 		{
1063
-			if(is_array($parameters)) $i = & $parameters['i'];
1064
-			else $i = (int)$parameters;
1106
+			if(is_array($parameters)) {
1107
+				$i = & $parameters['i'];
1108
+			} else {
1109
+				$i = (int)$parameters;
1110
+			}
1065 1111
 			
1066 1112
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1067 1113
 			{
@@ -1083,8 +1129,11 @@  discard block
 block discarded – undo
1083 1129
 			}
1084 1130
 		}
1085 1131
 		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1086
-		    if(is_array($parameters)) $i = & $parameters['i'];
1087
-		    else $i = (int)$parameters;
1132
+		    if(is_array($parameters)) {
1133
+		    	$i = & $parameters['i'];
1134
+		    } else {
1135
+		    	$i = (int)$parameters;
1136
+		    }
1088 1137
 		    $this->resprints = price($object->lines[$i]->total_ht);
1089 1138
 		}
1090 1139
 		if (!empty($hideprices)
@@ -1094,8 +1143,11 @@  discard block
 block discarded – undo
1094 1143
 		    if (!empty($hideprices))
1095 1144
 		    {
1096 1145
 		        
1097
-		        if(is_array($parameters)) $i = & $parameters['i'];
1098
-		        else $i = (int)$parameters;
1146
+		        if(is_array($parameters)) {
1147
+		        	$i = & $parameters['i'];
1148
+		        } else {
1149
+		        	$i = (int)$parameters;
1150
+		        }
1099 1151
 		        
1100 1152
 		        // Check if a title exist for this line && if the title have subtotal
1101 1153
 		        $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
@@ -1104,8 +1156,7 @@  discard block
 block discarded – undo
1104 1156
 		            $this->resprints = ' ';
1105 1157
 		            return 1;
1106 1158
 		        }
1107
-		    }
1108
-		    elseif (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1159
+		    } elseif (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1109 1160
 		    {
1110 1161
 		        $this->resprints = ' ';
1111 1162
 		        return 1;
@@ -1124,14 +1175,16 @@  discard block
 block discarded – undo
1124 1175
 		
1125 1176
 			if((float)DOL_VERSION<=3.6) {
1126 1177
 				return '';
1127
-			}
1128
-			else if((float)DOL_VERSION>=3.8) {
1178
+			} else if((float)DOL_VERSION>=3.8) {
1129 1179
 				return 1;
1130 1180
 			}
1131 1181
 		}
1132 1182
 		
1133
-		if(is_array($parameters)) $i = & $parameters['i'];
1134
-		else $i = (int)$parameters;
1183
+		if(is_array($parameters)) {
1184
+			$i = & $parameters['i'];
1185
+		} else {
1186
+			$i = (int)$parameters;
1187
+		}
1135 1188
 		
1136 1189
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1137 1190
 		{
@@ -1153,14 +1206,16 @@  discard block
 block discarded – undo
1153 1206
 		
1154 1207
 			if((float)DOL_VERSION<=3.6) {
1155 1208
 				return '';
1156
-			}
1157
-			else if((float)DOL_VERSION>=3.8) {
1209
+			} else if((float)DOL_VERSION>=3.8) {
1158 1210
 				return 1;
1159 1211
 			}
1160 1212
 		}
1161 1213
 		
1162
-		if(is_array($parameters)) $i = & $parameters['i'];
1163
-		else $i = (int)$parameters;
1214
+		if(is_array($parameters)) {
1215
+			$i = & $parameters['i'];
1216
+		} else {
1217
+			$i = (int)$parameters;
1218
+		}
1164 1219
 			
1165 1220
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1166 1221
 		{
@@ -1182,13 +1237,15 @@  discard block
 block discarded – undo
1182 1237
 		
1183 1238
 			if((float)DOL_VERSION<=3.6) {
1184 1239
 				return '';
1185
-			}
1186
-			else if((float)DOL_VERSION>=3.8) {
1240
+			} else if((float)DOL_VERSION>=3.8) {
1187 1241
 				return 1;
1188 1242
 			}
1189 1243
 		}
1190
-		if(is_array($parameters)) $i = & $parameters['i'];
1191
-		else $i = (int)$parameters;
1244
+		if(is_array($parameters)) {
1245
+			$i = & $parameters['i'];
1246
+		} else {
1247
+			$i = (int)$parameters;
1248
+		}
1192 1249
 		
1193 1250
 		if (!empty($hideprices) 
1194 1251
 				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
@@ -1211,14 +1268,16 @@  discard block
 block discarded – undo
1211 1268
 			$this->resprints = ' ';
1212 1269
 			if((float)DOL_VERSION<=3.6) {
1213 1270
 				return '';
1214
-			}
1215
-			else if((float)DOL_VERSION>=3.8) {
1271
+			} else if((float)DOL_VERSION>=3.8) {
1216 1272
 				return 1;
1217 1273
 			}
1218 1274
 		}
1219 1275
 		
1220
-		if(is_array($parameters)) $i = & $parameters['i'];
1221
-		else $i = (int)$parameters;
1276
+		if(is_array($parameters)) {
1277
+			$i = & $parameters['i'];
1278
+		} else {
1279
+			$i = (int)$parameters;
1280
+		}
1222 1281
 			
1223 1282
 		if (!empty($hideprices)
1224 1283
 				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
@@ -1242,16 +1301,21 @@  discard block
 block discarded – undo
1242 1301
 			
1243 1302
 			if((float)DOL_VERSION<=3.6) {
1244 1303
 				return '';
1245
-			}
1246
-			else if((float)DOL_VERSION>=3.8) {
1304
+			} else if((float)DOL_VERSION>=3.8) {
1247 1305
 				return 1;
1248 1306
 			}
1249 1307
 		}
1250 1308
 		
1251
-		if(is_array($parameters)) $i = & $parameters['i'];
1252
-		else $i = (int)$parameters;
1309
+		if(is_array($parameters)) {
1310
+			$i = & $parameters['i'];
1311
+		} else {
1312
+			$i = (int)$parameters;
1313
+		}
1253 1314
 		
1254
-		if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1315
+		if (empty($object->lines[$i])) {
1316
+			return 0;
1317
+		}
1318
+		// hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1255 1319
 
1256 1320
 		$object->lines[$i]->fetch_optionals();
1257 1321
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
@@ -1273,14 +1337,16 @@  discard block
 block discarded – undo
1273 1337
 			$this->resprints = ' ';
1274 1338
 			if((float)DOL_VERSION<=3.6) {
1275 1339
 				return '';
1276
-			}
1277
-			else if((float)DOL_VERSION>=3.8) {
1340
+			} else if((float)DOL_VERSION>=3.8) {
1278 1341
 				return 1;
1279 1342
 			}
1280 1343
 		}
1281 1344
 		
1282
-		if(is_array($parameters)) $i = & $parameters['i'];
1283
-		else $i = (int)$parameters;
1345
+		if(is_array($parameters)) {
1346
+			$i = & $parameters['i'];
1347
+		} else {
1348
+			$i = (int)$parameters;
1349
+		}
1284 1350
 			
1285 1351
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1286 1352
 		{
@@ -1310,7 +1376,9 @@  discard block
 block discarded – undo
1310 1376
 				}
1311 1377
 			}
1312 1378
 			
1313
-			if (!empty($TLineTitle)) $TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1379
+			if (!empty($TLineTitle)) {
1380
+				$TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1381
+			}
1314 1382
 		}
1315 1383
 		
1316 1384
 	}
@@ -1324,8 +1392,12 @@  discard block
 block discarded – undo
1324 1392
 		$j=0;
1325 1393
 		foreach ($TLineTitle as $k => &$line)
1326 1394
 		{
1327
-			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
1328
-			if (!empty($line_reference) && $line->qty <= $line_reference->qty) break;
1395
+			if (!empty($line_reference) && $line->rang <= $line_reference->rang) {
1396
+				continue;
1397
+			}
1398
+			if (!empty($line_reference) && $line->qty <= $line_reference->qty) {
1399
+				break;
1400
+			}
1329 1401
 			
1330 1402
 			if ($line->qty == $level)
1331 1403
 			{
@@ -1359,7 +1431,9 @@  discard block
 block discarded – undo
1359 1431
 		
1360 1432
 		$hidedetails = (int)GETPOST('hidedetails');
1361 1433
 		
1362
-		if(empty($hidedetails)) return false;
1434
+		if(empty($hidedetails)) {
1435
+			return false;
1436
+		}
1363 1437
 		
1364 1438
 		// TODO can't add VAT to document without lines... :-/
1365 1439
 		
@@ -1412,7 +1486,9 @@  discard block
 block discarded – undo
1412 1486
 						*/
1413 1487
 						list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
1414 1488
 						
1415
-						if (TSubtotal::getNiveau($line) == 1) $line->TTotal_tva = $TTotal_tva;
1489
+						if (TSubtotal::getNiveau($line) == 1) {
1490
+							$line->TTotal_tva = $TTotal_tva;
1491
+						}
1416 1492
 						$line->total_ht = $total;
1417 1493
 						$line->total_tva = $total_tva;
1418 1494
 						$line->total = $line->total_ht;
@@ -1467,8 +1543,7 @@  discard block
 block discarded – undo
1467 1543
 				    }
1468 1544
 				    
1469 1545
 					
1470
-				}
1471
-				elseif ($hidedetails)
1546
+				} elseif ($hidedetails)
1472 1547
 				{
1473 1548
 					$TLines[] = $line; //Cas où je cache uniquement les prix des produits	
1474 1549
 				}
@@ -1539,7 +1614,9 @@  discard block
 block discarded – undo
1539 1614
 				
1540 1615
 				if(!empty($hideprices)) {
1541 1616
 					foreach($object->lines as &$line) {
1542
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1617
+						if($line->fk_product_type!=9) {
1618
+							$line->fk_parent_line = -1;
1619
+						}
1543 1620
 					}
1544 1621
 				}
1545 1622
 			
@@ -1560,7 +1637,9 @@  discard block
 block discarded – undo
1560 1637
 				
1561 1638
 				if($line->qty>90) {
1562 1639
 					
1563
-					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1640
+					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) {
1641
+						$label .= ' '.$this->getTitle($object, $line);
1642
+					}
1564 1643
 					
1565 1644
 					$pageBefore = $pdf->getPage();
1566 1645
 					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
@@ -1578,8 +1657,7 @@  discard block
 block discarded – undo
1578 1657
 				
1579 1658
 					$posy = $pdf->GetY();
1580 1659
 					return 1;
1581
-				}	
1582
-				else if ($line->qty < 10) {
1660
+				} else if ($line->qty < 10) {
1583 1661
 					$pageBefore = $pdf->getPage();
1584 1662
 
1585 1663
 					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
@@ -1603,8 +1681,7 @@  discard block
 block discarded – undo
1603 1681
 //	if($line->rowid==47) exit;
1604 1682
 			
1605 1683
 			return 0;
1606
-		}
1607
-		elseif (empty($object->lines[$parameters['i']]))
1684
+		} elseif (empty($object->lines[$parameters['i']]))
1608 1685
 		{
1609 1686
 			$this->resprints = -1;
1610 1687
 		}
@@ -1637,7 +1714,9 @@  discard block
 block discarded – undo
1637 1714
 		
1638 1715
 		foreach ($object->lines as $line)
1639 1716
 		{
1640
-			if ($line->id == $currentLine->id) break;
1717
+			if ($line->id == $currentLine->id) {
1718
+				break;
1719
+			}
1641 1720
 			
1642 1721
 			$qty_search = 100 - $currentLine->qty;
1643 1722
 			
@@ -1674,23 +1753,23 @@  discard block
 block discarded – undo
1674 1753
 		{
1675 1754
 			$object->statut = 0; // hack for facture rec
1676 1755
 			$createRight = $user->rights->facture->creer;
1677
-		}
1678
-		elseif($object->element == 'order_supplier' )
1756
+		} elseif($object->element == 'order_supplier' )
1679 1757
 		{
1680 1758
 		    $createRight = $user->rights->fournisseur->commande->creer;
1681
-		}
1682
-		elseif($object->element == 'invoice_supplier' )
1759
+		} elseif($object->element == 'invoice_supplier' )
1683 1760
 		{
1684 1761
 		    $createRight = $user->rights->fournisseur->facture->creer;
1685 1762
 		}
1686 1763
 		
1687 1764
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1688 1765
 			null;
1689
-		}	
1690
-		else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) 
1766
+		} else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) 
1691 1767
         {
1692
-			if($object->element=='facture')$idvar = 'facid';
1693
-			else $idvar='id';
1768
+			if($object->element=='facture') {
1769
+				$idvar = 'facid';
1770
+			} else {
1771
+				$idvar='id';
1772
+			}
1694 1773
 			
1695 1774
 			if((float)DOL_VERSION <= 3.4)
1696 1775
 			{
@@ -1716,20 +1795,44 @@  discard block
 block discarded – undo
1716 1795
 				<?php
1717 1796
 			}
1718 1797
 			
1719
-			if(empty($line->description)) $line->description = $line->desc;
1798
+			if(empty($line->description)) {
1799
+				$line->description = $line->desc;
1800
+			}
1720 1801
 			
1721 1802
 			$colspan = 5;
1722
-			if($object->element == 'facturerec' ) $colspan = 3;
1723
-			if($object->element == 'order_supplier') $colspan = 3;
1724
-			if($object->element == 'invoice_supplier') $colspan = 4;
1725
-			if($object->element == 'supplier_proposal') $colspan = 4;
1726
-			if(!empty($conf->multicurrency->enabled)) $colspan+=2;
1727
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1728
-			if(!empty($conf->margin->enabled)) $colspan++;
1729
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1730
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1731
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1732
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
1803
+			if($object->element == 'facturerec' ) {
1804
+				$colspan = 3;
1805
+			}
1806
+			if($object->element == 'order_supplier') {
1807
+				$colspan = 3;
1808
+			}
1809
+			if($object->element == 'invoice_supplier') {
1810
+				$colspan = 4;
1811
+			}
1812
+			if($object->element == 'supplier_proposal') {
1813
+				$colspan = 4;
1814
+			}
1815
+			if(!empty($conf->multicurrency->enabled)) {
1816
+				$colspan+=2;
1817
+			}
1818
+			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) {
1819
+				$colspan++;
1820
+			}
1821
+			if(!empty($conf->margin->enabled)) {
1822
+				$colspan++;
1823
+			}
1824
+			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) {
1825
+				$colspan++;
1826
+			}
1827
+			if(!empty($conf->global->DISPLAY_MARK_RATES)) {
1828
+				$colspan++;
1829
+			}
1830
+			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) {
1831
+				$colspan++;
1832
+			}
1833
+			if(!empty($conf->global->PRODUCT_USE_UNITS)) {
1834
+				$colspan++;
1835
+			}
1733 1836
 					
1734 1837
 			/* Titre */
1735 1838
 			//var_dump($line);
@@ -1742,23 +1845,36 @@  discard block
 block discarded – undo
1742 1845
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
1743 1846
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
1744 1847
 					{
1745
-						if($line->qty==99) print 'background:#adadcf';
1746
-						else if($line->qty==98) print 'background:#ddddff;';
1747
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
1748
-						else if($line->qty==1) print 'background:#adadcf;';
1749
-						else if($line->qty==2) print 'background:#ddddff;';
1750
-						else if($line->qty==50) print '';
1751
-						else print 'background:#eeeeff;';
1848
+						if($line->qty==99) {
1849
+							print 'background:#adadcf';
1850
+						} else if($line->qty==98) {
1851
+							print 'background:#ddddff;';
1852
+						} else if($line->qty<=97 && $line->qty>=91) {
1853
+							print 'background:#eeeeff;';
1854
+						} else if($line->qty==1) {
1855
+							print 'background:#adadcf;';
1856
+						} else if($line->qty==2) {
1857
+							print 'background:#ddddff;';
1858
+						} else if($line->qty==50) {
1859
+							print '';
1860
+						} else {
1861
+							print 'background:#eeeeff;';
1862
+						}
1752 1863
 
1753 1864
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
1754
-					}
1755
-					else 
1865
+					} else 
1756 1866
 					{
1757
-						if($line->qty==99) print 'background:#ddffdd';
1758
-						else if($line->qty==98) print 'background:#ddddff;';
1759
-						else if($line->qty==2) print 'background:#eeeeff; ';
1760
-						else if($line->qty==50) print '';
1761
-						else print 'background:#eeffee;' ;
1867
+						if($line->qty==99) {
1868
+							print 'background:#ddffdd';
1869
+						} else if($line->qty==98) {
1870
+							print 'background:#ddddff;';
1871
+						} else if($line->qty==2) {
1872
+							print 'background:#eeeeff; ';
1873
+						} else if($line->qty==50) {
1874
+							print '';
1875
+						} else {
1876
+							print 'background:#eeffee;' ;
1877
+						}
1762 1878
 					}
1763 1879
 
1764 1880
 			?>;">
@@ -1781,13 +1897,11 @@  discard block
 block discarded – undo
1781 1897
 							$qty_displayed = $line->qty;
1782 1898
 							print img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
1783 1899
 							
1784
-						}
1785
-						else if (TSubtotal::isSubtotal($line))
1900
+						} else if (TSubtotal::isSubtotal($line))
1786 1901
 						{
1787 1902
 							$qty_displayed = 100 - $line->qty;
1788 1903
 							print img_picto('', 'subsubtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
1789
-						}
1790
-						else
1904
+						} else
1791 1905
 						{
1792 1906
 							$isFreeText = true;
1793 1907
 						}
@@ -1808,9 +1922,13 @@  discard block
 block discarded – undo
1808 1922
 						}
1809 1923
 
1810 1924
 						$readonlyForSituation = '';
1811
-						if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) $readonlyForSituation = 'readonly';
1925
+						if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) {
1926
+							$readonlyForSituation = 'readonly';
1927
+						}
1812 1928
 						
1813
-						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
1929
+						if (!$isFreeText) {
1930
+							echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
1931
+						}
1814 1932
 						
1815 1933
 						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
1816 1934
 						{
@@ -1818,8 +1936,12 @@  discard block
 block discarded – undo
1818 1936
 							for ($j=1; $j<10; $j++)
1819 1937
 							{
1820 1938
 								if (!empty($readonlyForSituation)) {
1821
-									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
1822
-								} else $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
1939
+									if ($qty_displayed == $j) {
1940
+										$select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
1941
+									}
1942
+								} else {
1943
+									$select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
1944
+								}
1823 1945
 							}
1824 1946
 							$select .= '</select>&nbsp;';
1825 1947
 
@@ -1835,15 +1957,18 @@  discard block
 block discarded – undo
1835 1957
 								$form = new Form($db);
1836 1958
 								echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
1837 1959
 								echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
1838
-								if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
1960
+								if (empty($readonlyForSituation)) {
1961
+									echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
1962
+								}
1839 1963
 								echo '</select>&nbsp;&nbsp;';
1840 1964
 								
1841 1965
 								if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
1842 1966
 								{
1843 1967
 									echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%';
1844 1968
 								}
1969
+							} else if ($isFreeText) {
1970
+								echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
1845 1971
 							}
1846
-							else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
1847 1972
 						echo '</div>';
1848 1973
 
1849 1974
 						if($line->qty<10) {
@@ -1863,8 +1988,7 @@  discard block
 block discarded – undo
1863 1988
 							$doleditor->Create();
1864 1989
 						}
1865 1990
 						
1866
-					}
1867
-					else {
1991
+					} else {
1868 1992
 
1869 1993
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
1870 1994
 						 {
@@ -1872,14 +1996,19 @@  discard block
 block discarded – undo
1872 1996
 							{
1873 1997
 								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
1874 1998
 								
1875
-								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
1876
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
1999
+								if (TSubtotal::isTitle($line)) {
2000
+									print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2001
+								} else {
2002
+									print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2003
+								}
1877 2004
 							}
1878
-						 }
1879
-						 else 
2005
+						 } else 
1880 2006
 						 {
1881
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
1882
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2007
+							if($line->qty<=1) {
2008
+								print img_picto('', 'subtotal@subtotal');
2009
+							} else if($line->qty==2) {
2010
+								print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2011
+							}
1883 2012
 						 }
1884 2013
 						 
1885 2014
 						 
@@ -1889,21 +2018,26 @@  discard block
 block discarded – undo
1889 2018
 						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
1890 2019
 						 
1891 2020
 						 if (empty($line->label)) {
1892
-							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
1893
-							else print  $line->description;
1894
-						 } 
1895
-						 else {
2021
+							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2022
+								print  $line->description.' '.$this->getTitle($object, $line);
2023
+							} else {
2024
+								print  $line->description;
2025
+							}
2026
+						 } else {
1896 2027
 
1897 2028
 							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
1898 2029
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
1899
-							}
1900
-							else{
2030
+							} else{
1901 2031
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
1902 2032
 							}
1903 2033
 
1904 2034
 						 } 
1905
-						if($line->qty>90) print ' : ';
1906
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2035
+						if($line->qty>90) {
2036
+							print ' : ';
2037
+						}
2038
+						if($line->info_bits > 0) {
2039
+							echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2040
+						}
1907 2041
 
1908 2042
 						 
1909 2043
 
@@ -1940,11 +2074,12 @@  discard block
 block discarded – undo
1940 2074
 						</script>
1941 2075
 						<?php
1942 2076
 						
1943
-					}
1944
-					else{
2077
+					} else{
1945 2078
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
1946 2079
 						{
1947
-							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2080
+							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) {
2081
+								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2082
+							}
1948 2083
 						}
1949 2084
 
1950 2085
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
@@ -2013,7 +2148,9 @@  discard block
 block discarded – undo
2013 2148
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2014 2149
 				
2015 2150
 				$colspan+=3; $mode = 'view';
2016
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2151
+				if($action === 'editline' && $line->rowid == GETPOST('lineid')) {
2152
+					$mode = 'edit';
2153
+				}
2017 2154
 				
2018 2155
 				$ex_element = $line->element;
2019 2156
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
@@ -2195,10 +2332,9 @@  discard block
 block discarded – undo
2195 2332
 	    
2196 2333
 	    if(TSubtotal::isTitle($line)){
2197 2334
 	        $ThtmlData['data-issubtotal'] = 'title';
2198
-	    }elseif(TSubtotal::isSubtotal($line)){
2335
+	    } elseif(TSubtotal::isSubtotal($line)){
2199 2336
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2200
-	    }
2201
-	    else{
2337
+	    } else{
2202 2338
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2203 2339
 	    }
2204 2340
 	    
@@ -2208,7 +2344,9 @@  discard block
 block discarded – undo
2208 2344
 	    
2209 2345
 	    // hook 
2210 2346
 	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2211
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2347
+	    if ($reshook < 0) {
2348
+	    	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2349
+	    }
2212 2350
 	    if ($reshook>0)
2213 2351
 	    {
2214 2352
 	        $ThtmlData = $hookmanager->resArray;
Please login to merge, or discard this patch.