Completed
Push — master ( b538be...5d7c2c )
by John
23s queued 19s
created
lib/subtotal.lib.php 2 patches
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -41,21 +41,21 @@  discard block
 block discarded – undo
41 41
     $head[$h][2] = 'about';
42 42
     $h++;
43 43
 
44
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'subtotal', $showLabel=false);
44
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'subtotal', $showLabel = false);
45 45
 
46 46
     return $head;
47 47
 }
48 48
 
49
-function getHtmlSelectTitle(&$object, $showLabel=false)
49
+function getHtmlSelectTitle(&$object, $showLabel = false)
50 50
 {
51 51
 	global $langs;
52 52
 	
53
-	require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
53
+	require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
54 54
 	dol_include_once('/subtotal/class/subtotal.class.php');
55 55
 	$TTitle = TSubtotal::getAllTitleFromDocument($object);
56 56
 	$html = '';
57
-	if ($showLabel) $html.= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>';
58
-	$html.= '<select onChange="$(\'select[name=under_title]\').val(this.value);" name="under_title" class="under_title minwidth200"><option value="-1"></option>';
57
+	if ($showLabel) $html .= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>';
58
+	$html .= '<select onChange="$(\'select[name=under_title]\').val(this.value);" name="under_title" class="under_title minwidth200"><option value="-1"></option>';
59 59
 	
60 60
 	$nbsp = '&nbsp;';
61 61
 	foreach ($TTitle as &$line)
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
 function getTFreeText()
72 72
 {
73
-	global $db,$conf;
73
+	global $db, $conf;
74 74
 	
75 75
 	$TFreeText = array();
76 76
 	
@@ -88,19 +88,19 @@  discard block
 block discarded – undo
88 88
 	return $TFreeText;
89 89
 }
90 90
 
91
-function getHtmlSelectFreeText($withEmpty=true)
91
+function getHtmlSelectFreeText($withEmpty = true)
92 92
 {
93 93
 	global $langs;
94 94
 	
95 95
 	$TFreeText = getTFreeText();
96 96
 	$html = '<label for="free_text">'.$langs->trans('subtotalLabelForFreeText').'</label>';
97
-	$html.= '<select onChange="getTFreeText($(this));" name="free_text" class="minwidth200">';
98
-	if ($withEmpty) $html.= '<option value=""></option>';
97
+	$html .= '<select onChange="getTFreeText($(this));" name="free_text" class="minwidth200">';
98
+	if ($withEmpty) $html .= '<option value=""></option>';
99 99
 
100 100
 	$TFreeTextContents = array();
101 101
 	foreach ($TFreeText as $id => $tab)
102 102
 	{
103
-		$html.= '<option value="'.$id.'">'.$tab->label.'</option>';
103
+		$html .= '<option value="'.$id.'">'.$tab->label.'</option>';
104 104
 		$TFreeTextContents[$id] = $tab->content;
105 105
 	}
106 106
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	global $conf;
131 131
 
132 132
 	$label = GETPOST('line-title');
133
-	$description = ($line->qty>90) ? '' : GETPOST('line-description');
133
+	$description = ($line->qty > 90) ? '' : GETPOST('line-description');
134 134
 	$pagebreak = (int) GETPOST('line-pagebreak');
135 135
     $showTotalHT = (int) GETPOST('line-showTotalHT');
136 136
     $showReduc = (int) GETPOST('line-showReduc');
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 
183 183
 function _updateSubtotalBloc($object, $line)
184 184
 {
185
-	global $conf,$langs;
185
+	global $conf, $langs;
186 186
 	
187 187
 	$subtotal_tva_tx = $subtotal_tva_tx_init = GETPOST('subtotal_tva_tx', 'int');
188 188
 	$subtotal_progress = $subtotal_progress_init = GETPOST('subtotal_progress', 'int');
@@ -261,9 +261,9 @@  discard block
 block discarded – undo
261 261
  * @param	$lineid			= title lineid
262 262
  * @param	$subtotal_nc	0 = "Compris" prise en compte des totaux des lignes; 1 = "Non compris" non prise en compte des totaux du bloc; null = update de toutes les lignes 
263 263
  */
264
-function _updateLineNC($element, $elementid, $lineid, $subtotal_nc=null, $notrigger = 0)
264
+function _updateLineNC($element, $elementid, $lineid, $subtotal_nc = null, $notrigger = 0)
265 265
 {
266
-	global $db,$langs,$tmp_object_nc;
266
+	global $db, $langs, $tmp_object_nc;
267 267
 	
268 268
 	$error = 0;
269 269
 	if (empty($element)) $error++;
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 	{
304 304
 		foreach ($object->lines as &$l)
305 305
 		{
306
-			if($l->id == $lineid) {
306
+			if ($l->id == $lineid) {
307 307
 				$line = $l;
308 308
 				break;
309 309
 			}
@@ -313,12 +313,12 @@  discard block
 block discarded – undo
313 313
 		{
314 314
 			$db->begin();
315 315
 			
316
-			if(TSubtotal::isModSubtotalLine($line))
316
+			if (TSubtotal::isModSubtotalLine($line))
317 317
 			{
318
-				if(TSubtotal::isTitle($line)) {
318
+				if (TSubtotal::isTitle($line)) {
319 319
 					// Update le contenu du titre (ainsi que le titre lui même)
320 320
 					$TTitleBlock = TSubtotal::getLinesFromTitleId($object, $lineid, true);
321
-					foreach($TTitleBlock as &$line_block)
321
+					foreach ($TTitleBlock as &$line_block)
322 322
 					{
323 323
 						$res = doUpdate($object, $line_block, $subtotal_nc, $notrigger);
324 324
 					}
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	
353 353
 	if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) return 1;
354 354
 	// Update extrafield et total
355
-	if(! empty($subtotal_nc)) {
355
+	if (!empty($subtotal_nc)) {
356 356
 		$line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = 
357 357
 			$line->multicurrency_total_ht = $line->multicurrency_total_tva = $line->multicurrency_total_ttc = 0;
358 358
 
@@ -362,16 +362,16 @@  discard block
 block discarded – undo
362 362
 		else $res = $line->update($user, $notrigger);
363 363
 	}
364 364
 	else {
365
-	    if(in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
366
-	        if(empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
365
+	    if (in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
366
+	        if (empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
367 367
 	        
368 368
 	        require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
369
-	        $extrafields=new ExtraFields($object->db);
370
-	        $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
371
-	        $line->fetch_optionals($line->id,$extralabels);
369
+	        $extrafields = new ExtraFields($object->db);
370
+	        $extralabels = $extrafields->fetch_name_optionals_label($object->table_element_line, true);
371
+	        $line->fetch_optionals($line->id, $extralabels);
372 372
 	    }
373 373
 		$line->array_options['options_subtotal_nc'] = 0;
374
-		if($object->element == 'order_supplier') $line->update($user);
374
+		if ($object->element == 'order_supplier') $line->update($user);
375 375
 		$res = TSubtotal::doUpdateLine($object, $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->product_type, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $notrigger);
376 376
 	}
377 377
 	
Please login to merge, or discard this patch.
Braces   +70 added lines, -32 removed lines patch added patch discarded remove patch
@@ -54,7 +54,9 @@  discard block
 block discarded – undo
54 54
 	dol_include_once('/subtotal/class/subtotal.class.php');
55 55
 	$TTitle = TSubtotal::getAllTitleFromDocument($object);
56 56
 	$html = '';
57
-	if ($showLabel) $html.= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>';
57
+	if ($showLabel) {
58
+		$html.= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>';
59
+	}
58 60
 	$html.= '<select onChange="$(\'select[name=under_title]\').val(this.value);" name="under_title" class="under_title minwidth200"><option value="-1"></option>';
59 61
 	
60 62
 	$nbsp = '&nbsp;';
@@ -95,7 +97,9 @@  discard block
 block discarded – undo
95 97
 	$TFreeText = getTFreeText();
96 98
 	$html = '<label for="free_text">'.$langs->trans('subtotalLabelForFreeText').'</label>';
97 99
 	$html.= '<select onChange="getTFreeText($(this));" name="free_text" class="minwidth200">';
98
-	if ($withEmpty) $html.= '<option value=""></option>';
100
+	if ($withEmpty) {
101
+		$html.= '<option value=""></option>';
102
+	}
99 103
 
100 104
 	$TFreeTextContents = array();
101 105
 	foreach ($TFreeText as $id => $tab)
@@ -138,8 +142,13 @@  discard block
 block discarded – undo
138 142
 	$level = GETPOST('subtotal_level', 'int');
139 143
 	if (!empty($level))
140 144
 	{
141
-		if ($line->qty > 90) $line->qty = 100 - $level; // Si on edit une ligne sous-total
142
-		else $line->qty = $level;
145
+		if ($line->qty > 90) {
146
+			$line->qty = 100 - $level;
147
+		}
148
+		// Si on edit une ligne sous-total
149
+		else {
150
+			$line->qty = $level;
151
+		}
143 152
 	}
144 153
     $line->array_options['options_show_total_ht'] = $showTotalHT;
145 154
     $line->array_options['options_show_reduc'] = $showReduc;
@@ -147,9 +156,13 @@  discard block
 block discarded – undo
147 156
 	$res = TSubtotal::doUpdateLine($object, $line->id, $description, 0, $line->qty, 0, '', '', 0, 9, 0, 0, 'HT', $pagebreak, 0, 1, null, 0, $label, TSubtotal::$module_number, $line->array_options);
148 157
 
149 158
 	$TKey = null;
150
-	if ($line->element == 'propaldet') $TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_PROPALDET);
151
-	elseif ($line->element == 'commandedet') $TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_COMMANDEDET);
152
-	elseif ($line->element == 'facturedet') $TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_FACTUREDET);
159
+	if ($line->element == 'propaldet') {
160
+		$TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_PROPALDET);
161
+	} elseif ($line->element == 'commandedet') {
162
+		$TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_COMMANDEDET);
163
+	} elseif ($line->element == 'facturedet') {
164
+		$TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_FACTUREDET);
165
+	}
153 166
 	// TODO ajouter la partie fournisseur
154 167
 
155 168
 	// TODO remove "true"
@@ -199,13 +212,18 @@  discard block
 block discarded – undo
199 212
 			{
200 213
 				$subtotal_tva_tx = $subtotal_tva_tx_init; // ré-init car la variable peut évoluer
201 214
 					
202
-				if (!empty($showBlockExtrafields)) $line->array_options = $array_options;
203
-				if ($subtotal_tva_tx == '') $subtotal_tva_tx = $line->tva_tx;
215
+				if (!empty($showBlockExtrafields)) {
216
+					$line->array_options = $array_options;
217
+				}
218
+				if ($subtotal_tva_tx == '') {
219
+					$subtotal_tva_tx = $line->tva_tx;
220
+				}
204 221
 				if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION)
205 222
 				{
206 223
 					$subtotal_progress = $subtotal_progress_init;
207
-					if ($subtotal_progress == '') $subtotal_progress = $line->situation_percent;
208
-					else
224
+					if ($subtotal_progress == '') {
225
+						$subtotal_progress = $line->situation_percent;
226
+					} else
209 227
 					{
210 228
 						$prev_percent = $line->get_prev_progress($object->id);
211 229
 						if ($subtotal_progress < $prev_percent)
@@ -218,14 +236,21 @@  discard block
 block discarded – undo
218 236
 				
219 237
 				$res = TSubtotal::doUpdateLine($object, $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $subtotal_tva_tx, $line->product_type, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $subtotal_progress, $line->fk_unit);
220 238
 
221
-				if ($res > 0) $success_updated_line++;
222
-				else $error_updated_line++;
239
+				if ($res > 0) {
240
+					$success_updated_line++;
241
+				} else {
242
+					$error_updated_line++;
243
+				}
223 244
 			}
224 245
 		}
225 246
 
226
-		if ($nb_progress_not_updated > 0) setEventMessage($langs->trans('subtotal_nb_progress_not_updated', $nb_progress_not_updated), 'warnings');
247
+		if ($nb_progress_not_updated > 0) {
248
+			setEventMessage($langs->trans('subtotal_nb_progress_not_updated', $nb_progress_not_updated), 'warnings');
249
+		}
227 250
 		
228
-		if ($success_updated_line > 0) setEventMessage($langs->trans('subtotal_success_updated_line', $success_updated_line));
251
+		if ($success_updated_line > 0) {
252
+			setEventMessage($langs->trans('subtotal_success_updated_line', $success_updated_line));
253
+		}
229 254
 		if ($error_updated_line > 0)
230 255
 		{
231 256
 			setEventMessage($langs->trans('subtotal_error_updated_line', $error_updated_line), 'errors');
@@ -266,15 +291,16 @@  discard block
 block discarded – undo
266 291
 	global $db,$langs,$tmp_object_nc;
267 292
 	
268 293
 	$error = 0;
269
-	if (empty($element)) $error++;
294
+	if (empty($element)) {
295
+		$error++;
296
+	}
270 297
 	
271 298
 	if (!$error)
272 299
 	{
273 300
 		if (!empty($tmp_object_nc) && $tmp_object_nc->element == $element && $tmp_object_nc->id == $elementid)
274 301
 		{
275 302
 			$object = $tmp_object_nc;
276
-		}
277
-		else
303
+		} else
278 304
 		{
279 305
 			$classname = ucfirst($element);
280 306
 			
@@ -294,8 +320,11 @@  discard block
 block discarded – undo
294 320
 			
295 321
 			$object = new $classname($db); // Propal | Commande | Facture
296 322
 			$res = $object->fetch($elementid);
297
-			if ($res < 0) $error++;
298
-			else $tmp_object_nc = $object;
323
+			if ($res < 0) {
324
+				$error++;
325
+			} else {
326
+				$tmp_object_nc = $object;
327
+			}
299 328
 		}
300 329
 	}
301 330
 	
@@ -323,21 +352,21 @@  discard block
 block discarded – undo
323 352
 						$res = doUpdate($object, $line_block, $subtotal_nc, $notrigger);
324 353
 					}
325 354
 				}
326
-			}
327
-			else
355
+			} else
328 356
 			{
329 357
 				$res = doUpdate($object, $line, $subtotal_nc, $notrigger);
330 358
 			}
331 359
 			
332 360
 			$res = $object->update_price(1);
333
-			if ($res <= 0) $error++;
361
+			if ($res <= 0) {
362
+				$error++;
363
+			}
334 364
 			
335 365
 			if (!$error)
336 366
 			{
337 367
 				setEventMessage($langs->trans('subtotal_update_nc_success'));
338 368
 				$db->commit();
339
-			}
340
-			else
369
+			} else
341 370
 			{
342 371
 				setEventMessage($langs->trans('subtotal_update_nc_error'), 'errors');
343 372
 				$db->rollback();
@@ -350,7 +379,9 @@  discard block
 block discarded – undo
350 379
 {
351 380
 	global $user;
352 381
 	
353
-	if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) return 1;
382
+	if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) {
383
+		return 1;
384
+	}
354 385
 	// Update extrafield et total
355 386
 	if(! empty($subtotal_nc)) {
356 387
 		$line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = 
@@ -358,12 +389,17 @@  discard block
 block discarded – undo
358 389
 
359 390
 		$line->array_options['options_subtotal_nc'] = 1;
360 391
 
361
-		if ($line->element == 'propaldet') $res = $line->update($notrigger);
362
-		else $res = $line->update($user, $notrigger);
363
-	}
364
-	else {
392
+		if ($line->element == 'propaldet') {
393
+			$res = $line->update($notrigger);
394
+		} else {
395
+			$res = $line->update($user, $notrigger);
396
+		}
397
+	} else {
365 398
 	    if(in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
366
-	        if(empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
399
+	        if(empty($line->label)) {
400
+	        	$line->label = $line->description;
401
+	        }
402
+	        // supplier lines don't have the field label
367 403
 	        
368 404
 	        require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
369 405
 	        $extrafields=new ExtraFields($object->db);
@@ -371,7 +407,9 @@  discard block
 block discarded – undo
371 407
 	        $line->fetch_optionals($line->id,$extralabels);
372 408
 	    }
373 409
 		$line->array_options['options_subtotal_nc'] = 0;
374
-		if($object->element == 'order_supplier') $line->update($user);
410
+		if($object->element == 'order_supplier') {
411
+			$line->update($user);
412
+		}
375 413
 		$res = TSubtotal::doUpdateLine($object, $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->product_type, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit, $notrigger);
376 414
 	}
377 415
 	
Please login to merge, or discard this patch.
admin/subtotal_setup.php 3 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 // Dolibarr environment
29 29
 $res = @include("../../main.inc.php"); // From htdocs directory
30 30
 if (! $res) {
31
-    $res = @include("../../../main.inc.php"); // From "custom" directory
31
+	$res = @include("../../../main.inc.php"); // From "custom" directory
32 32
 }
33 33
 
34 34
 // Libraries
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
 // Access control
41 41
 if (! $user->admin) {
42
-    accessforbidden();
42
+	accessforbidden();
43 43
 }
44 44
 
45 45
 // Parameters
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
 // Configuration header
97 97
 $head = subtotalAdminPrepareHead();
98 98
 dol_fiche_head(
99
-    $head,
100
-    'settings',
101
-    $langs->trans("Module104777Name"),
102
-    -1,
103
-    "subtotal@subtotal"
99
+	$head,
100
+	'settings',
101
+	$langs->trans("Module104777Name"),
102
+	-1,
103
+	"subtotal@subtotal"
104 104
 );
105 105
 
106 106
 showParameters();
@@ -169,13 +169,13 @@  discard block
 block discarded – undo
169 169
 	print ajax_constantonoff('SUBTOTAL_ALLOW_DUPLICATE_BLOCK');
170 170
 	print '</td></tr>';
171 171
 
172
-    $var=!$var;
173
-    print '<tr '.$bc[$var].'>';
174
-    print '<td>'.$langs->trans("SUBTOTAL_ALLOW_DUPLICATE_LINE").'</td>';
175
-    print '<td align="center" width="20">&nbsp;</td>';
176
-    print '<td align="center" width="300">';
177
-    print ajax_constantonoff('SUBTOTAL_ALLOW_DUPLICATE_LINE');
178
-    print '</td></tr>';
172
+	$var=!$var;
173
+	print '<tr '.$bc[$var].'>';
174
+	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_DUPLICATE_LINE").'</td>';
175
+	print '<td align="center" width="20">&nbsp;</td>';
176
+	print '<td align="center" width="300">';
177
+	print ajax_constantonoff('SUBTOTAL_ALLOW_DUPLICATE_LINE');
178
+	print '</td></tr>';
179 179
 	
180 180
 	$var=!$var;
181 181
 	print '<tr '.$bc[$var].'>';
@@ -272,12 +272,12 @@  discard block
 block discarded – undo
272 272
 		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
273 273
 		print '<input type="hidden" name="action" value="set_SUBTOTAL_TFIELD_TO_KEEP_WITH_NC">';
274 274
 		$TField = array(
275
-		    'pdf_getlineqty' => $langs->trans('Qty'), 
276
-		    'pdf_getlinevatrate' => $langs->trans('VAT'), 
277
-		    'pdf_getlineupexcltax' => $langs->trans('PriceUHT'), 
278
-		    'pdf_getlinetotalexcltax' => $langs->trans('TotalHT'), 
279
-		    'pdf_getlineunit' => $langs->trans('Unit'),
280
-		    'pdf_getlineremisepercent' => $langs->trans('Discount')
275
+			'pdf_getlineqty' => $langs->trans('Qty'), 
276
+			'pdf_getlinevatrate' => $langs->trans('VAT'), 
277
+			'pdf_getlineupexcltax' => $langs->trans('PriceUHT'), 
278
+			'pdf_getlinetotalexcltax' => $langs->trans('TotalHT'), 
279
+			'pdf_getlineunit' => $langs->trans('Unit'),
280
+			'pdf_getlineremisepercent' => $langs->trans('Discount')
281 281
 		);
282 282
 		print $html->multiselectarray('SUBTOTAL_TFIELD_TO_KEEP_WITH_NC', $TField, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC), 0, 0, '', 0, 0, 'style="min-width:100px"');
283 283
 		print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
Please login to merge, or discard this patch.
Spacing   +46 added lines, -46 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 (in_array($code, array(
63 63
 		'SUBTOTAL_TFIELD_TO_KEEP_WITH_NC'
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
 
89 89
 
90 90
 
91
-llxHeader('','Gestion de sous-total, à propos','');
91
+llxHeader('', 'Gestion de sous-total, à propos', '');
92 92
 
93
-$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
94
-print_fiche_titre('Gestion de subtotal',$linkback,'setup');
93
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
94
+print_fiche_titre('Gestion de subtotal', $linkback, 'setup');
95 95
 
96 96
 // Configuration header
97 97
 $head = subtotalAdminPrepareHead();
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
 showParameters();
107 107
 
108 108
 function showParameters() {
109
-	global $db,$conf,$langs,$bc;
109
+	global $db, $conf, $langs, $bc;
110 110
 	
111
-	$html=new Form($db);
111
+	$html = new Form($db);
112 112
 	
113
-	$var=false;
113
+	$var = false;
114 114
 	print '<table class="noborder" width="100%">';
115 115
 	print '<tr class="liste_titre">';
116 116
 	print '<td>'.$langs->trans("Parameters").'</td>'."\n";
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
119 119
 	print '</tr>';
120 120
 	
121
-	$var=!$var;
121
+	$var = !$var;
122 122
 	print '<tr '.$bc[$var].'>';
123 123
 	print '<td>'.$langs->trans("SUBTOTAL_USE_NEW_FORMAT").'</td>';
124 124
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 	print ajax_constantonoff('SUBTOTAL_USE_NEW_FORMAT');
127 127
 	print '</td></tr>';
128 128
 	
129
-	if((float)DOL_VERSION>=3.8)
129
+	if ((float) DOL_VERSION >= 3.8)
130 130
 	{
131
-		$var=!$var;
131
+		$var = !$var;
132 132
 		print '<tr '.$bc[$var].'>';
133 133
 		print '<td>'.$langs->trans("SUBTOTAL_USE_NUMEROTATION").'</td>';
134 134
 		print '<td align="center" width="20">&nbsp;</td>';
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 		print '</td></tr>';	
138 138
 	}
139 139
 	
140
-	$var=!$var;
140
+	$var = !$var;
141 141
 	print '<tr '.$bc[$var].'>';
142 142
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_ADD_BLOCK").'</td>';
143 143
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 	print ajax_constantonoff('SUBTOTAL_ALLOW_ADD_BLOCK');
146 146
 	print '</td></tr>';
147 147
 	
148
-	$var=!$var;
148
+	$var = !$var;
149 149
 	print '<tr '.$bc[$var].'>';
150 150
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_EDIT_BLOCK").'</td>';
151 151
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	print ajax_constantonoff('SUBTOTAL_ALLOW_EDIT_BLOCK');
154 154
 	print '</td></tr>';
155 155
 	
156
-	$var=!$var;
156
+	$var = !$var;
157 157
 	print '<tr '.$bc[$var].'>';
158 158
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_REMOVE_BLOCK").'</td>';
159 159
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
 	print ajax_constantonoff('SUBTOTAL_ALLOW_REMOVE_BLOCK');
162 162
 	print '</td></tr>';
163 163
 	
164
-	$var=!$var;
164
+	$var = !$var;
165 165
 	print '<tr '.$bc[$var].'>';
166 166
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_DUPLICATE_BLOCK").'</td>';
167 167
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 	print ajax_constantonoff('SUBTOTAL_ALLOW_DUPLICATE_BLOCK');
170 170
 	print '</td></tr>';
171 171
 
172
-    $var=!$var;
172
+    $var = !$var;
173 173
     print '<tr '.$bc[$var].'>';
174 174
     print '<td>'.$langs->trans("SUBTOTAL_ALLOW_DUPLICATE_LINE").'</td>';
175 175
     print '<td align="center" width="20">&nbsp;</td>';
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
     print ajax_constantonoff('SUBTOTAL_ALLOW_DUPLICATE_LINE');
178 178
     print '</td></tr>';
179 179
 	
180
-	$var=!$var;
180
+	$var = !$var;
181 181
 	print '<tr '.$bc[$var].'>';
182 182
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_ADD_LINE_UNDER_TITLE").'</td>';
183 183
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	print ajax_constantonoff('SUBTOTAL_ALLOW_ADD_LINE_UNDER_TITLE');
186 186
 	print '</td></tr>';
187 187
 	
188
-	$var=!$var;
188
+	$var = !$var;
189 189
 	print '<tr '.$bc[$var].'>';
190 190
 	print '<td>'.$langs->trans("SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK").'</td>';
191 191
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	print ajax_constantonoff('SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK');
194 194
 	print '</td></tr>';
195 195
 
196
-	$var=!$var;
196
+	$var = !$var;
197 197
 	print '<tr '.$bc[$var].'>';
198 198
 	print '<td>'.$html->textwithpicto($langs->trans("SUBTOTAL_TEXT_FOR_TITLE_ORDETSTOINVOICE"), $langs->trans("SUBTOTAL_TEXT_FOR_TITLE_ORDETSTOINVOICE_info")).'</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_TITLE_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_SUBTOTAL_STYLE").'</td>';
225 225
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	print '</form>';
233 233
 	print '</td></tr>';
234 234
 	
235
-	$var=!$var;
235
+	$var = !$var;
236 236
 	print '<tr '.$bc[$var].'>';
237 237
 	print '<td>'.$langs->trans("SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES", $langs->transnoentitiesnoconv('HideInnerLines')).'</td>';
238 238
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
 	print ajax_constantonoff('SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES');
241 241
 	print '</td></tr>';
242 242
 	
243
-	$var=!$var;
243
+	$var = !$var;
244 244
 	print '<tr '.$bc[$var].'>';
245 245
 	print '<td>'.$langs->trans("SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES", $langs->transnoentitiesnoconv('HideInnerLines')).'</td>';
246 246
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	
251 251
 	if ((double) DOL_VERSION >= 4.0)
252 252
 	{
253
-		$var=!$var;
253
+		$var = !$var;
254 254
 		print '<tr '.$bc[$var].'>';
255 255
 		print '<td>'.$langs->trans("SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS").'</td>';
256 256
 		print '<td align="center" width="20">&nbsp;</td>';
@@ -258,12 +258,12 @@  discard block
 block discarded – undo
258 258
 		print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
259 259
 		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
260 260
 		print '<input type="hidden" name="action" value="set_SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS">';
261
-		print $html->selectyesno("SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS",$conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS,1);
261
+		print $html->selectyesno("SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS", $conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS, 1);
262 262
 		print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
263 263
 		print '</form>';
264 264
 		print '</td></tr>';
265 265
 		
266
-		$var=!$var;
266
+		$var = !$var;
267 267
 		print '<tr '.$bc[$var].'>';
268 268
 		print '<td>'.$langs->trans("SUBTOTAL_TFIELD_TO_KEEP_WITH_NC").'</td>';
269 269
 		print '<td align="center" width="20">&nbsp;</td>';
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 		print '</td></tr>';
286 286
 	}
287 287
 	
288
-	$var=!$var;
288
+	$var = !$var;
289 289
 	print '<tr '.$bc[$var].'>';
290 290
 	print '<td>'.$langs->trans('SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE').'</td>';
291 291
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 	print ajax_constantonoff('SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE');
294 294
 	print '</td></tr>';
295 295
 	
296
-	$var=!$var;
296
+	$var = !$var;
297 297
 	print '<tr '.$bc[$var].'>';
298 298
 	print '<td>'.$langs->trans('SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE').'</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_ALLOW_EXTRAFIELDS_ON_TITLE');
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_LIST_OF_EXTRAFIELDS_PROPALDET").'</td>';
307 307
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	print '</form>';
317 317
 	print '</td></tr>';
318 318
 
319
-	$var=!$var;
319
+	$var = !$var;
320 320
 	print '<tr '.$bc[$var].'>';
321 321
 	print '<td>'.$langs->trans("SUBTOTAL_LIST_OF_EXTRAFIELDS_COMMANDEDET").'</td>';
322 322
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 	print '</form>';
332 332
 	print '</td></tr>';
333 333
 
334
-	$var=!$var;
334
+	$var = !$var;
335 335
 	print '<tr '.$bc[$var].'>';
336 336
 	print '<td>'.$langs->trans("SUBTOTAL_LIST_OF_EXTRAFIELDS_FACTUREDET").'</td>';
337 337
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	
353 353
 	
354 354
 	
355
-	$var=false;
355
+	$var = false;
356 356
 	print '<table class="noborder" width="100%">';
357 357
 	print '<tr class="liste_titre">';
358 358
 	print '<td>'.$langs->trans("RecapGeneration").'</td>'."\n";
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
361 361
 	print '</tr>';
362 362
 	
363
-	$var=!$var;
363
+	$var = !$var;
364 364
 	print '<tr '.$bc[$var].'>';
365 365
 	print '<td>'.$langs->trans('SUBTOTAL_KEEP_RECAP_FILE').'</td>';
366 366
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 	print ajax_constantonoff('SUBTOTAL_KEEP_RECAP_FILE');
369 369
 	print '</td></tr>';
370 370
 	
371
-	$var=!$var;
371
+	$var = !$var;
372 372
 	print '<tr '.$bc[$var].'>';
373 373
 	print '<td>'.$langs->trans('SUBTOTAL_PROPAL_ADD_RECAP').'</td>';
374 374
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 	print ajax_constantonoff('SUBTOTAL_PROPAL_ADD_RECAP');
377 377
 	print '</td></tr>';
378 378
 	
379
-	$var=!$var;
379
+	$var = !$var;
380 380
 	print '<tr '.$bc[$var].'>';
381 381
 	print '<td>'.$langs->trans('SUBTOTAL_COMMANDE_ADD_RECAP').'</td>';
382 382
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 	print '</td></tr>';
386 386
 	
387 387
 	
388
-	$var=!$var;
388
+	$var = !$var;
389 389
 	print '<tr '.$bc[$var].'>';
390 390
 	print '<td>'.$langs->trans('SUBTOTAL_INVOICE_ADD_RECAP').'</td>';
391 391
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 				<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
418 418
 					<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken'] ?>">
419 419
 					<input type="hidden" name="action" value="set_SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY" />
420
-					<?php echo $html->selectyesno("SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY",$conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY,1); ?>
420
+					<?php echo $html->selectyesno("SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY", $conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY, 1); ?>
421 421
 					<input type="submit" class="button" value="<?php echo $langs->trans("Modify") ?>">
422 422
 				</form>
423 423
 			</td>
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
 				<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
430 430
 					<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken'] ?>">
431 431
 					<input type="hidden" name="action" value="set_SUBTOTAL_HIDE_DOCUMENT_TOTAL" />
432
-					<?php echo $html->selectyesno("SUBTOTAL_HIDE_DOCUMENT_TOTAL",$conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL,1); ?>
432
+					<?php echo $html->selectyesno("SUBTOTAL_HIDE_DOCUMENT_TOTAL", $conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL, 1); ?>
433 433
 					<input type="submit" class="button" value="<?php echo $langs->trans("Modify") ?>">
434 434
 				</form>
435 435
 			</td>				
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
 					<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
443 443
 						<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken'] ?>">
444 444
 						<input type="hidden" name="action" value="set_SUBTOTAL_SHOW_QTY_ON_TITLES" />
445
-						<?php echo $html->selectyesno("SUBTOTAL_SHOW_QTY_ON_TITLES",$conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES,1); ?>
445
+						<?php echo $html->selectyesno("SUBTOTAL_SHOW_QTY_ON_TITLES", $conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES, 1); ?>
446 446
 						<input type="submit" class="button" value="<?php echo $langs->trans("Modify") ?>">
447 447
 					</form>
448 448
 				</td>				
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 					<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
455 455
 						<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken'] ?>">
456 456
 						<input type="hidden" name="action" value="set_SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES" />
457
-						<?php echo $html->selectyesno("SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES",$conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES,1); ?>
457
+						<?php echo $html->selectyesno("SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES", $conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES, 1); ?>
458 458
 						<input type="submit" class="button" value="<?php echo $langs->trans("Modify") ?>">
459 459
 					</form>
460 460
 				</td>				
Please login to merge, or discard this patch.
Braces   +7 added lines, -4 removed lines patch added patch discarded remove patch
@@ -64,16 +64,19 @@
 block discarded – undo
64 64
 		, 'SUBTOTAL_LIST_OF_EXTRAFIELDS_PROPALDET'
65 65
 		, 'SUBTOTAL_LIST_OF_EXTRAFIELDS_COMMANDEDET'
66 66
 		, 'SUBTOTAL_LIST_OF_EXTRAFIELDS_FACTUREDET'
67
-	))) $value = implode(',', $value);
67
+	))) {
68
+		$value = implode(',', $value);
69
+	}
68 70
 
69 71
 	if (dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity) > 0)
70 72
 	{
71
-		if ($code == 'SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS' && $value == 1) _createExtraComprisNonCompris();
73
+		if ($code == 'SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS' && $value == 1) {
74
+			_createExtraComprisNonCompris();
75
+		}
72 76
 		
73 77
 		header("Location: ".$_SERVER["PHP_SELF"]);
74 78
 		exit;
75
-	}
76
-	else
79
+	} else
77 80
 	{
78 81
 		dol_print_error($db);
79 82
 	}
Please login to merge, or discard this patch.
class/actions_subtotal.class.php 3 patches
Indentation   +337 added lines, -337 removed lines patch added patch discarded remove patch
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	 * @return     void
102 102
 	 */
103 103
     
104
-    var $module_number = 104777;
104
+	var $module_number = 104777;
105 105
     
106
-    function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
107
-    {
108
-      	global $langs,$db,$user, $conf;
106
+	function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
107
+	{
108
+	  	global $langs,$db,$user, $conf;
109 109
 		
110 110
 		$langs->load('subtotal@subtotal');
111 111
 		
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
 				$createRight = $user->rights->facture->creer;
121 121
 			} elseif($object->element == 'order_supplier' )
122 122
 			{
123
-			    $createRight = $user->rights->fournisseur->commande->creer;
123
+				$createRight = $user->rights->fournisseur->commande->creer;
124 124
 			} elseif($object->element == 'invoice_supplier' )
125 125
 			{
126
-			    $createRight = $user->rights->fournisseur->facture->creer;
126
+				$createRight = $user->rights->fournisseur->facture->creer;
127 127
 			}
128 128
 			elseif($object->element == 'shipping')
129 129
 			{
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 					
178 178
 					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
179 179
 					
180
-	    			TSubtotal::addSubTotalLine($object, $title, $qty);
180
+					TSubtotal::addSubTotalLine($object, $title, $qty);
181 181
 				}
182 182
 				else if($action==='ask_deleteallline') {
183 183
 						$form=new Form($db);
@@ -399,36 +399,36 @@  discard block
 block discarded – undo
399 399
 		$TContext = explode(':',$parameters['context']);
400 400
 		if (
401 401
 				in_array('invoicecard',$TContext)
402
-		        || in_array('invoicesuppliercard',$TContext)
402
+				|| in_array('invoicesuppliercard',$TContext)
403 403
 				|| in_array('propalcard',$TContext)
404 404
 				|| in_array('ordercard',$TContext)
405
-		        || in_array('ordersuppliercard',$TContext)
405
+				|| in_array('ordersuppliercard',$TContext)
406 406
 				|| in_array('invoicereccard',$TContext)
407 407
 			)
408
-	        {	
409
-	            $hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
410
-	            $hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
408
+			{	
409
+				$hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
410
+				$hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
411 411
 				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0;
412 412
 				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
413 413
 				
414 414
 				$var=false;
415
-		     	$out.= '<tr '.$bc[$var].'>
415
+			 	$out.= '<tr '.$bc[$var].'>
416 416
 		     			<td colspan="4" align="right">
417 417
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
418 418
 		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
419 419
 		     			</td>
420 420
 		     			</tr>';
421 421
 				
422
-		     	$var=!$var;
423
-		     	$out.= '<tr '.$bc[$var].'>
422
+			 	$var=!$var;
423
+			 	$out.= '<tr '.$bc[$var].'>
424 424
 		     			<td colspan="4" align="right">
425 425
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
426 426
 		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
427 427
 		     			</td>
428 428
 		     			</tr>';
429 429
 		     	
430
-		     	$var=!$var;
431
-		     	$out.= '<tr '.$bc[$var].'>
430
+			 	$var=!$var;
431
+			 	$out.= '<tr '.$bc[$var].'>
432 432
 		     			<td colspan="4" align="right">
433 433
 		     				<label for="hideprices">'.$langs->trans('SubTotalhidePrice').'</label>
434 434
 		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
@@ -440,9 +440,9 @@  discard block
 block discarded – undo
440 440
 				if ( 
441 441
 					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
442 442
 					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
443
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
443
+					|| (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
444 444
 					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
445
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
445
+					|| (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
446 446
 					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
447 447
 				)
448 448
 				{
@@ -461,19 +461,19 @@  discard block
 block discarded – undo
461 461
 			}
462 462
 			
463 463
 		
464
-        return 1;
464
+		return 1;
465 465
 	} 
466 466
 	 
467
-    function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
468
-    {
467
+	function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
468
+	{
469 469
 		
470
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
471
-        {
470
+		if (in_array('invoicecard',explode(':',$parameters['context'])))
471
+		{
472 472
         	
473
-        }
473
+		}
474 474
 		
475
-        return 0;
476
-    }
475
+		return 0;
476
+	}
477 477
 	
478 478
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
479 479
 		global $conf;
@@ -484,14 +484,14 @@  discard block
 block discarded – undo
484 484
 			$object = &$parameters['object'];
485 485
 			$substitutionarray = &$parameters['substitutionarray'];
486 486
 			
487
-            $substitutionarray['line_not_modsubtotal'] = true;
488
-            $substitutionarray['line_modsubtotal'] = false;
489
-            $substitutionarray['line_modsubtotal_total'] = false;
490
-            $substitutionarray['line_modsubtotal_title'] = false;
487
+			$substitutionarray['line_not_modsubtotal'] = true;
488
+			$substitutionarray['line_modsubtotal'] = false;
489
+			$substitutionarray['line_modsubtotal_total'] = false;
490
+			$substitutionarray['line_modsubtotal_title'] = false;
491 491
 
492 492
 			if($line->product_type == 9 && $line->special_code == $this->module_number) {
493 493
 				$substitutionarray['line_modsubtotal'] = 1;	
494
-                $substitutionarray['line_not_modsubtotal'] = false;
494
+				$substitutionarray['line_not_modsubtotal'] = false;
495 495
 				
496 496
 				$substitutionarray['line_price_ht']
497 497
 					 = $substitutionarray['line_price_vat'] 
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 					$substitutionarray['line_modsubtotal_total'] = true;
506 506
 					
507 507
 					//list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
508
-                    $TInfo = $this->getTotalLineFromObject($object, $line, '', 1);
508
+					$TInfo = $this->getTotalLineFromObject($object, $line, '', 1);
509 509
 
510 510
 					$substitutionarray['line_price_ht'] = price($TInfo[0]);
511 511
 					$substitutionarray['line_price_vat'] = price($TInfo[1]);
@@ -529,11 +529,11 @@  discard block
 block discarded – undo
529 529
 	
530 530
 		if (
531 531
 				in_array('invoicecard',explode(':',$parameters['context']))
532
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
532
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
533 533
 				|| in_array('propalcard',explode(':',$parameters['context']))
534
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
534
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
535 535
 				|| in_array('ordercard',explode(':',$parameters['context']))
536
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
536
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
537 537
 				|| in_array('invoicereccard',explode(':',$parameters['context']))
538 538
 		) {
539 539
 			
@@ -612,20 +612,20 @@  discard block
 block discarded – undo
612 612
 				in_array('invoicecard',explode(':',$parameters['context']))
613 613
 				|| in_array('propalcard',explode(':',$parameters['context']))
614 614
 				|| in_array('ordercard',explode(':',$parameters['context']))
615
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
616
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
617
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
615
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
616
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
617
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
618 618
 			)
619
-	        {								
619
+			{								
620 620
 				if(in_array('invoicecard',explode(':',$parameters['context']))) {
621 621
 					$sessname = 'subtotal_hideInnerLines_facture';	
622 622
 					$sessname2 = 'subtotal_hidedetails_facture';
623 623
 					$sessname3 = 'subtotal_hideprices_facture';
624 624
 				}
625 625
 				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
626
-				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
627
-				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
628
-				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
626
+					$sessname = 'subtotal_hideInnerLines_facture_fournisseur';
627
+					$sessname2 = 'subtotal_hidedetails_facture_fournisseur';
628
+					$sessname3 = 'subtotal_hideprices_facture_fournisseur';
629 629
 				}
630 630
 				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
631 631
 					$sessname = 'subtotal_hideInnerLines_propal';
@@ -633,9 +633,9 @@  discard block
 block discarded – undo
633 633
 					$sessname3 = 'subtotal_hideprices_propal';
634 634
 				}
635 635
 				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
636
-				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
637
-				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
638
-				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
636
+					$sessname = 'subtotal_hideInnerLines_supplier_proposal';
637
+					$sessname2 = 'subtotal_hidedetails_supplier_proposal';
638
+					$sessname3 = 'subtotal_hideprices_supplier_proposal';
639 639
 				}
640 640
 				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
641 641
 					$sessname = 'subtotal_hideInnerLines_commande';
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
 					$sessname3 = 'subtotal_hideprices_commande';
644 644
 				}
645 645
 				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
646
-				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
647
-				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
648
-				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
646
+					$sessname = 'subtotal_hideInnerLines_commande_fournisseur';
647
+					$sessname2 = 'subtotal_hidedetails_commande_fournisseur';
648
+					$sessname3 = 'subtotal_hideprices_commande_fournisseur';
649 649
 				}
650 650
 				else {
651 651
 					$sessname = 'subtotal_hideInnerLines_unknown';
@@ -670,17 +670,17 @@  discard block
 block discarded – undo
670 670
 				foreach($object->lines as &$line) {
671 671
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
672 672
 					    
673
-                        if($line->qty>=90) {
674
-                            $line->modsubtotal_total = 1;
675
-                        }
676
-                        else{
677
-                            $line->modsubtotal_title = 1;
678
-                        }
673
+						if($line->qty>=90) {
674
+							$line->modsubtotal_total = 1;
675
+						}
676
+						else{
677
+							$line->modsubtotal_title = 1;
678
+						}
679 679
                         
680 680
 						$line->total_ht = $this->getTotalLineFromObject($object, $line, '');
681 681
 					}
682
-	        	}
683
-	        }
682
+				}
683
+			}
684 684
 			
685 685
 		}
686 686
 		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 				 */
698 698
 				else if($object->element=='invoice_supplier')
699 699
 				{
700
-				    $object->deleteline($idLine);
700
+					$object->deleteline($idLine);
701 701
 				}
702 702
 				/**
703 703
 				 * @var $object Propal
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
 				 */
721 721
 				else if($object->element=='order_supplier')
722 722
 				{
723
-				    $object->deleteline($idLine);
723
+					$object->deleteline($idLine);
724 724
 				}
725 725
 				/**
726 726
 				 * @var $object Facturerec
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 		
796 796
 		foreach($object->lines as $l) {
797 797
 		
798
-		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
798
+			$lid = (!empty($l->rowid) ? $l->rowid : $l->id);
799 799
 			if($lid == $lineid) {
800 800
 
801 801
 				$found = true;
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 			
805 805
 			if($found) {
806 806
 				
807
-			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
807
+				$Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
808 808
 				
809 809
 				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
810 810
 					break; // end of story
@@ -845,39 +845,39 @@  discard block
 block discarded – undo
845 845
 		foreach($TLineReverse as $l)
846 846
 		{
847 847
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
848
-            if ($l->rang>=$rang) continue;
849
-            if (!empty($title_break) && $title_break->id == $l->id) break;
850
-            elseif (!TSubtotal::isModSubtotalLine($l))
851
-            {
852
-                // TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF
853
-                if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION)
854
-                {
855
-                    if ($l->situation_percent > 0)
856
-                    {
857
-                        $prev_progress = 0;
858
-                        $progress = 1;
859
-                        if (method_exists($l, 'get_prev_progress'))
860
-                        {
861
-                            $prev_progress = $l->get_prev_progress($object->id);
862
-                            $progress = ($l->situation_percent - $prev_progress) / 100;
863
-                        }
864
-
865
-                        $result = $sign * ($l->total_ht / ($l->situation_percent / 100)) * $progress;
866
-                        $total+= $result;
867
-                        // TODO check si les 3 lignes du dessous sont corrects
868
-                        $total_tva += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
869
-                        $TTotal_tva[$l->tva_tx] += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
870
-                        $total_ttc += $sign * ($l->total_tva / ($l->total_ttc / 100)) * $progress;
871
-                    }
872
-                }
873
-                else
874
-                {
875
-                    $total += $l->total_ht;
876
-                    $total_tva += $l->total_tva;
877
-                    $TTotal_tva[$l->tva_tx] += $l->total_tva;
878
-                    $total_ttc += $l->total_ttc;
879
-                }
880
-            }
848
+			if ($l->rang>=$rang) continue;
849
+			if (!empty($title_break) && $title_break->id == $l->id) break;
850
+			elseif (!TSubtotal::isModSubtotalLine($l))
851
+			{
852
+				// TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF
853
+				if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION)
854
+				{
855
+					if ($l->situation_percent > 0)
856
+					{
857
+						$prev_progress = 0;
858
+						$progress = 1;
859
+						if (method_exists($l, 'get_prev_progress'))
860
+						{
861
+							$prev_progress = $l->get_prev_progress($object->id);
862
+							$progress = ($l->situation_percent - $prev_progress) / 100;
863
+						}
864
+
865
+						$result = $sign * ($l->total_ht / ($l->situation_percent / 100)) * $progress;
866
+						$total+= $result;
867
+						// TODO check si les 3 lignes du dessous sont corrects
868
+						$total_tva += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
869
+						$TTotal_tva[$l->tva_tx] += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
870
+						$total_ttc += $sign * ($l->total_tva / ($l->total_ttc / 100)) * $progress;
871
+					}
872
+				}
873
+				else
874
+				{
875
+					$total += $l->total_ht;
876
+					$total_tva += $l->total_tva;
877
+					$TTotal_tva[$l->tva_tx] += $l->total_tva;
878
+					$total_ttc += $l->total_ttc;
879
+				}
880
+			}
881 881
 		}
882 882
 		if (!$return_all) return $total;
883 883
 		else return array($total, $total_tva, $total_ttc, $TTotal_tva);
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
 		if(method_exists('Closure','bind')) {
916 916
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
917 917
 			$sweetsThief = function ($pdf) {
918
-		    		return $pdf->bMargin ;
918
+					return $pdf->bMargin ;
919 919
 			};
920 920
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
921 921
 	
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
 					$TTotal_tva = $TInfo[3];
987 987
 					$total_to_print = price($TInfo[0]);
988 988
 
989
-                    $line->total_ht = $TInfo[0];
989
+					$line->total_ht = $TInfo[0];
990 990
 					$line->total = $TInfo[0];
991 991
 					if (!TSubtotal::isModSubtotalLine($line)) $line->total_tva = $TInfo[1];
992 992
 					$line->total_ttc = $TInfo[2];
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
 	}
1144 1144
 	
1145 1145
 	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1146
-	    global $conf, $hideprices, $hookmanager;
1146
+		global $conf, $hideprices, $hookmanager;
1147 1147
 		
1148 1148
 		if(is_array($parameters)) $i = & $parameters['i'];
1149 1149
 		else $i = (int)$parameters;
@@ -1182,7 +1182,7 @@  discard block
 block discarded – undo
1182 1182
 			}
1183 1183
 		}
1184 1184
 		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1185
-		    $this->resprints = price($object->lines[$i]->total_ht);
1185
+			$this->resprints = price($object->lines[$i]->total_ht);
1186 1186
 		}
1187 1187
 		
1188 1188
 		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
@@ -1311,7 +1311,7 @@  discard block
 block discarded – undo
1311 1311
 	}
1312 1312
 	
1313 1313
 	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1314
-	    global $conf,$hideprices,$hookmanager;
1314
+		global $conf,$hideprices,$hookmanager;
1315 1315
 
1316 1316
 		if(is_array($parameters)) $i = & $parameters['i'];
1317 1317
 		else $i = (int)$parameters;
@@ -1319,18 +1319,18 @@  discard block
 block discarded – undo
1319 1319
 		if($this->isModSubtotalLine($parameters,$object) ) {
1320 1320
 			$this->resprints = ' ';
1321 1321
 
1322
-            $line = $object->lines[$i];
1322
+			$line = $object->lines[$i];
1323 1323
 
1324
-            // On récupère les montants du bloc pour les afficher dans la ligne de sous-total
1325
-            if(TSubtotal::isSubtotal($line)) {
1326
-                $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1324
+			// On récupère les montants du bloc pour les afficher dans la ligne de sous-total
1325
+			if(TSubtotal::isSubtotal($line)) {
1326
+				$parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1327 1327
 
1328
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1329
-                if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1330
-                    $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1331
-                    $this->resprints = price($TTotal['total_unit_subprice']);
1332
-                }
1333
-            }
1328
+				if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1329
+				if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1330
+					$TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1331
+					$this->resprints = price($TTotal['total_unit_subprice']);
1332
+				}
1333
+			}
1334 1334
 		
1335 1335
 			if((float)DOL_VERSION<=3.6) {
1336 1336
 				return '';
@@ -1346,58 +1346,58 @@  discard block
 block discarded – undo
1346 1346
 		(!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))
1347 1347
 		)
1348 1348
 		{
1349
-		    // alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1350
-		    if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1351
-		    {
1352
-		        $this->resprints = ' ';
1349
+			// alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1350
+			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1351
+			{
1352
+				$this->resprints = ' ';
1353 1353
 		        
1354
-		        // currentcontext à modifier celon l'appel
1355
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1356
-		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1354
+				// currentcontext à modifier celon l'appel
1355
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1356
+				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1357 1357
 		        
1358
-		    }
1358
+			}
1359 1359
 		}
1360 1360
 		// Cache le prix pour les lignes standards dolibarr qui sont dans un ensemble
1361 1361
 		else if (!empty($hideprices))
1362 1362
 		{
1363 1363
 		    
1364
-		    // Check if a title exist for this line && if the title have subtotal
1365
-		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1366
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1367
-		    {
1364
+			// Check if a title exist for this line && if the title have subtotal
1365
+			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1366
+			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1367
+			{
1368 1368
 		        
1369
-		        $this->resprints = ' ';
1369
+				$this->resprints = ' ';
1370 1370
 		        
1371
-		        // currentcontext à modifier celon l'appel
1372
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1373
-		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1374
-		    }
1371
+				// currentcontext à modifier celon l'appel
1372
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1373
+				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1374
+			}
1375 1375
 		}
1376 1376
 		
1377 1377
 		return 0;
1378 1378
 	}
1379 1379
 	
1380 1380
 	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1381
-	    global $conf,$hideprices,$hookmanager;
1381
+		global $conf,$hideprices,$hookmanager;
1382 1382
 
1383
-        if(is_array($parameters)) $i = & $parameters['i'];
1384
-        else $i = (int) $parameters;
1383
+		if(is_array($parameters)) $i = & $parameters['i'];
1384
+		else $i = (int) $parameters;
1385 1385
 
1386 1386
 		if($this->isModSubtotalLine($parameters,$object) ) {
1387 1387
 			$this->resprints = ' ';
1388 1388
 
1389
-            $line = $object->lines[$i];
1389
+			$line = $object->lines[$i];
1390 1390
 
1391
-            // Affichage de la remise 
1392
-            if(TSubtotal::isSubtotal($line)) {
1393
-                $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1391
+			// Affichage de la remise 
1392
+			if(TSubtotal::isSubtotal($line)) {
1393
+				$parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1394 1394
 
1395
-                if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1396
-                if(! empty($parentTitle->array_options['options_show_reduc'])) {
1397
-                    $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1398
-                    $this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
1399
-                }
1400
-            }
1395
+				if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1396
+				if(! empty($parentTitle->array_options['options_show_reduc'])) {
1397
+					$TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1398
+					$this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
1399
+				}
1400
+			}
1401 1401
 		
1402 1402
 			if((float)DOL_VERSION<=3.6) {
1403 1403
 				return '';
@@ -1407,15 +1407,15 @@  discard block
 block discarded – undo
1407 1407
 			}
1408 1408
 		}
1409 1409
 		elseif (!empty($hideprices)
1410
-		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1411
-		        )
1412
-		    {
1413
-		        if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1414
-		        {
1415
-		            $this->resprints = ' ';
1416
-		            return 1;
1417
-		        }
1418
-		    }
1410
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1411
+				)
1412
+			{
1413
+				if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1414
+				{
1415
+					$this->resprints = ' ';
1416
+					return 1;
1417
+				}
1418
+			}
1419 1419
 		
1420 1420
 		return 0;
1421 1421
 	}
@@ -1451,7 +1451,7 @@  discard block
 block discarded – undo
1451 1451
 	}
1452 1452
 	
1453 1453
 	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
1454
-	    global $conf,$hideprices,$hookmanager;
1454
+		global $conf,$hideprices,$hookmanager;
1455 1455
 	    
1456 1456
 		if($this->isModSubtotalLine($parameters,$object) ){
1457 1457
 			$this->resprints = ' ';
@@ -1476,31 +1476,31 @@  discard block
 block discarded – undo
1476 1476
 		(!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))
1477 1477
 		)
1478 1478
 		{
1479
-		    // alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1480
-		    if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1481
-		    {
1482
-		        $this->resprints = ' ';
1479
+			// alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1480
+			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1481
+			{
1482
+				$this->resprints = ' ';
1483 1483
 		        
1484
-		        // currentcontext à modifier celon l'appel
1485
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1486
-		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1487
-		    }
1484
+				// currentcontext à modifier celon l'appel
1485
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1486
+				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1487
+			}
1488 1488
 		}
1489 1489
 		// Cache le prix pour les lignes standards dolibarr qui sont dans un ensemble
1490 1490
 		else if (!empty($hideprices))
1491 1491
 		{
1492 1492
 		    
1493
-		    // Check if a title exist for this line && if the title have subtotal
1494
-		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1495
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1496
-		    {
1493
+			// Check if a title exist for this line && if the title have subtotal
1494
+			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1495
+			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1496
+			{
1497 1497
 		        
1498
-		        $this->resprints = ' ';
1498
+				$this->resprints = ' ';
1499 1499
 		        
1500
-		        // currentcontext à modifier celon l'appel
1501
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1502
-		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1503
-		    }
1500
+				// currentcontext à modifier celon l'appel
1501
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1502
+				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1503
+			}
1504 1504
 		}
1505 1505
 		
1506 1506
 		return 0;
@@ -1624,33 +1624,33 @@  discard block
 block discarded – undo
1624 1624
 		
1625 1625
 		$this->add_numerotation($object);	
1626 1626
 		
1627
-        foreach($object->lines as $k => &$l) {
1628
-            if(TSubtotal::isSubtotal($l)) {
1629
-                $parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1630
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1631
-                if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_reduc'])) {
1632
-                    $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1633
-                }
1634
-            }
1627
+		foreach($object->lines as $k => &$l) {
1628
+			if(TSubtotal::isSubtotal($l)) {
1629
+				$parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1630
+				if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1631
+				if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_reduc'])) {
1632
+					$l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1633
+				}
1634
+			}
1635 1635
 
1636 1636
 
1637
-            // Pas de hook sur les colonnes du PDF expédition, on unset les bonnes variables
1638
-            if(($object->element == 'shipping' || $object->element == 'delivery') && $this->isModSubtotalLine($k, $object))
1637
+			// Pas de hook sur les colonnes du PDF expédition, on unset les bonnes variables
1638
+			if(($object->element == 'shipping' || $object->element == 'delivery') && $this->isModSubtotalLine($k, $object))
1639 1639
 			{
1640 1640
 				$l->qty = $l->qty_asked;
1641 1641
 				unset($l->qty_asked, $l->qty_shipped, $l->volume, $l->weight);
1642 1642
 			}
1643
-        }
1643
+		}
1644 1644
 
1645 1645
 		$hideInnerLines = (int)GETPOST('hideInnerLines');
1646 1646
 		$hidedetails = (int)GETPOST('hidedetails');
1647 1647
 
1648 1648
 		if ($hideInnerLines) { // si c une ligne de titre
1649
-	    	$fk_parent_line=0;
1649
+			$fk_parent_line=0;
1650 1650
 			$TLines =array();
1651 1651
 		
1652 1652
 			$original_count=count($object->lines);
1653
-		    $TTvas = array(); // tableau de tva
1653
+			$TTvas = array(); // tableau de tva
1654 1654
 		    
1655 1655
 			foreach($object->lines as $k=>&$line) 
1656 1656
 			{
@@ -1691,48 +1691,48 @@  discard block
 block discarded – undo
1691 1691
 			
1692 1692
 				if ($hideInnerLines)
1693 1693
 				{
1694
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1695
-				    {
1696
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1694
+					if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1695
+					{
1696
+						if($line->tva_tx != '0.000' && $line->product_type!=9){
1697 1697
 				            
1698
-    				        // on remplit le tableau de tva pour substituer les lignes cachées
1699
-    				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1700
-    				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1701
-    				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1702
-    				    }
1703
-    					if($line->product_type==9 && $line->rowid>0)
1704
-    					{
1705
-    					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1706
-    					    // génère des lignes d'affichage des montants HT soumis à tva
1707
-    					    $nbtva = count($TTvas);
1708
-    					    if(!empty($nbtva)){
1709
-    					        foreach ($TTvas as $tx =>$val){
1710
-    					            $l = clone $line;
1711
-    					            $l->product_type = 1;
1712
-    					            $l->special_code = '';
1713
-    					            $l->qty = 1;
1714
-    					            $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1715
-    					            $l->tva_tx = $tx;
1716
-    					            $l->total_ht = $val['total_ht'];
1717
-    					            $l->total_tva = $val['total_tva'];
1718
-    					            $l->total = $line->total_ht;
1719
-    					            $l->total_ttc = $val['total_ttc'];
1720
-    					            $TLines[] = $l;
1721
-    					            array_shift($TTvas);
1722
-    					       }
1723
-    					    }
1698
+							// on remplit le tableau de tva pour substituer les lignes cachées
1699
+							$TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1700
+							$TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1701
+							$TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1702
+						}
1703
+						if($line->product_type==9 && $line->rowid>0)
1704
+						{
1705
+							//Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1706
+							// génère des lignes d'affichage des montants HT soumis à tva
1707
+							$nbtva = count($TTvas);
1708
+							if(!empty($nbtva)){
1709
+								foreach ($TTvas as $tx =>$val){
1710
+									$l = clone $line;
1711
+									$l->product_type = 1;
1712
+									$l->special_code = '';
1713
+									$l->qty = 1;
1714
+									$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1715
+									$l->tva_tx = $tx;
1716
+									$l->total_ht = $val['total_ht'];
1717
+									$l->total_tva = $val['total_tva'];
1718
+									$l->total = $line->total_ht;
1719
+									$l->total_ttc = $val['total_ttc'];
1720
+									$TLines[] = $l;
1721
+									array_shift($TTvas);
1722
+							   }
1723
+							}
1724 1724
     					    
1725
-    					    // ajoute la ligne de sous-total
1726
-    					    $TLines[] = $line; 
1727
-    					}
1728
-				    } else {
1725
+							// ajoute la ligne de sous-total
1726
+							$TLines[] = $line; 
1727
+						}
1728
+					} else {
1729 1729
 				        
1730
-				        if($line->product_type==9 && $line->rowid>0)
1731
-				        {
1732
-				            // ajoute la ligne de sous-total
1733
-				            $TLines[] = $line; 
1734
-				        }
1735
-				    }
1730
+						if($line->product_type==9 && $line->rowid>0)
1731
+						{
1732
+							// ajoute la ligne de sous-total
1733
+							$TLines[] = $line; 
1734
+						}
1735
+					}
1736 1736
 				    
1737 1737
 					
1738 1738
 				}
@@ -1757,20 +1757,20 @@  discard block
 block discarded – undo
1757 1757
 			$nbtva = count($TTvas);
1758 1758
 			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1759 1759
 			{
1760
-			    foreach ($TTvas as $tx =>$val){
1761
-			        $l = clone $line;
1762
-			        $l->product_type = 1;
1763
-			        $l->special_code = '';
1764
-			        $l->qty = 1;
1765
-			        $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1766
-			        $l->tva_tx = $tx;
1767
-			        $l->total_ht = $val['total_ht'];
1768
-			        $l->total_tva = $val['total_tva'];
1769
-			        $l->total = $line->total_ht;
1770
-			        $l->total_ttc = $val['total_ttc'];
1771
-			        $TLines[] = $l;
1772
-			        array_shift($TTvas);
1773
-			    }
1760
+				foreach ($TTvas as $tx =>$val){
1761
+					$l = clone $line;
1762
+					$l->product_type = 1;
1763
+					$l->special_code = '';
1764
+					$l->qty = 1;
1765
+					$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1766
+					$l->tva_tx = $tx;
1767
+					$l->total_ht = $val['total_ht'];
1768
+					$l->total_tva = $val['total_tva'];
1769
+					$l->total = $line->total_ht;
1770
+					$l->total_ttc = $val['total_ttc'];
1771
+					$TLines[] = $l;
1772
+					array_shift($TTvas);
1773
+				}
1774 1774
 			}
1775 1775
 			
1776 1776
 			global $nblignes;
@@ -1782,7 +1782,7 @@  discard block
 block discarded – undo
1782 1782
 				$this->resprints = '';
1783 1783
 				return 0;
1784 1784
 			}
1785
-	    }
1785
+		}
1786 1786
 		
1787 1787
 		return 0;
1788 1788
 	}
@@ -1974,11 +1974,11 @@  discard block
 block discarded – undo
1974 1974
 		}
1975 1975
 		elseif($object->element == 'order_supplier' )
1976 1976
 		{
1977
-		    $createRight = $user->rights->fournisseur->commande->creer;
1977
+			$createRight = $user->rights->fournisseur->commande->creer;
1978 1978
 		}
1979 1979
 		elseif($object->element == 'invoice_supplier' )
1980 1980
 		{
1981
-		    $createRight = $user->rights->fournisseur->facture->creer;
1981
+			$createRight = $user->rights->fournisseur->facture->creer;
1982 1982
 		}
1983 1983
 		elseif($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
1984 1984
 		{
@@ -2007,27 +2007,27 @@  discard block
 block discarded – undo
2007 2007
 			$line = $originline;
2008 2008
 		}
2009 2009
  		if($object->element=='facture')$idvar = 'facid';
2010
-        else $idvar='id';
2010
+		else $idvar='id';
2011 2011
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
2012 2012
 			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE) && $object->element !== 'invoice_supplier')
2013
-            {
2014
-                if(!(TSubtotal::isModSubtotalLine($line)) && ( $line->fk_prev_id === null ) && !($action == "editline" && GETPOST('lineid') == $line->id)) {
2015
-                    echo '<a name="duplicate-'.$line->id.'" href="' . $_SERVER['PHP_SELF'] . '?' . $idvar . '=' . $object->id . '&action=duplicate&lineid=' . $line->id . '"><i class="fa fa-clone" aria-hidden="true"></i></a>';
2013
+			{
2014
+				if(!(TSubtotal::isModSubtotalLine($line)) && ( $line->fk_prev_id === null ) && !($action == "editline" && GETPOST('lineid') == $line->id)) {
2015
+					echo '<a name="duplicate-'.$line->id.'" href="' . $_SERVER['PHP_SELF'] . '?' . $idvar . '=' . $object->id . '&action=duplicate&lineid=' . $line->id . '"><i class="fa fa-clone" aria-hidden="true"></i></a>';
2016 2016
 
2017
-                    ?>
2017
+					?>
2018 2018
                         <script type="text/javascript">
2019 2019
                             $(document).ready(function() {
2020 2020
                                 $("a[name='duplicate-<?php echo $line->id; ?>']").prependTo($('#row-<?php echo $line->id; ?>').find('.linecoledit'));
2021 2021
                             });
2022 2022
                         </script>
2023 2023
                     <?php
2024
-                }
2024
+				}
2025 2025
 
2026
-            }
2026
+			}
2027 2027
 			return 0;
2028 2028
 		}
2029 2029
 		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)) 
2030
-        {
2030
+		{
2031 2031
 
2032 2032
 
2033 2033
 			if((float)DOL_VERSION <= 3.4)
@@ -2075,7 +2075,7 @@  discard block
 block discarded – undo
2075 2075
 			//var_dump($line);
2076 2076
             
2077 2077
 			// HTML 5 data for js
2078
-            $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2078
+			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2079 2079
             
2080 2080
 			
2081 2081
 			?>
@@ -2137,8 +2137,8 @@  discard block
 block discarded – undo
2137 2137
 						}
2138 2138
 						
2139 2139
 						if ($object->element == 'order_supplier' || $object->element == 'invoice_supplier') {
2140
-						    $line->label = !empty($line->description) ? $line->description : $line->desc;
2141
-						    $line->description = '';
2140
+							$line->label = !empty($line->description) ? $line->description : $line->desc;
2141
+							$line->description = '';
2142 2142
 						}
2143 2143
 						$newlabel = $line->label;
2144 2144
 						if($line->label=='' && !$isFreeText) {
@@ -2172,38 +2172,38 @@  discard block
 block discarded – undo
2172 2172
 						
2173 2173
 
2174 2174
 						echo '<div class="subtotal_underline" style="margin-left:24px; line-height: 25px;">';
2175
-                        echo '<div>';
2176
-                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2177
-                        echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2178
-                        echo '</div>';
2179
-
2180
-                        if (TSubtotal::isTitle($line))
2181
-                        {
2182
-                            $form = new Form($db);
2183
-                            echo '<div>';
2184
-                            echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2185
-                            echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2186
-                            if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2187
-                            echo '</select>';
2188
-                            echo '</div>';
2189
-
2190
-                            if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
2191
-                            {
2192
-                                echo '<div>';
2193
-                                echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%';
2194
-                                echo '</div>';
2195
-                            }
2196
-                            echo '<div>';
2197
-                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showTotalHT" id="subtotal-showTotalHT" value="9" '.(($line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2198
-                            echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2199
-                            echo '</div>';
2200
-
2201
-                            echo '<div>';
2202
-                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2203
-                            echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2204
-                            echo '</div>';
2205
-                        }
2206
-                        else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2175
+						echo '<div>';
2176
+						echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2177
+						echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2178
+						echo '</div>';
2179
+
2180
+						if (TSubtotal::isTitle($line))
2181
+						{
2182
+							$form = new Form($db);
2183
+							echo '<div>';
2184
+							echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2185
+							echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2186
+							if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2187
+							echo '</select>';
2188
+							echo '</div>';
2189
+
2190
+							if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
2191
+							{
2192
+								echo '<div>';
2193
+								echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%';
2194
+								echo '</div>';
2195
+							}
2196
+							echo '<div>';
2197
+							echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showTotalHT" id="subtotal-showTotalHT" value="9" '.(($line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2198
+							echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2199
+							echo '</div>';
2200
+
2201
+							echo '<div>';
2202
+							echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2203
+							echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2204
+							echo '</div>';
2205
+						}
2206
+						else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2207 2207
 						echo '</div>';
2208 2208
 
2209 2209
 						if (TSubtotal::isTitle($line))
@@ -2743,17 +2743,17 @@  discard block
 block discarded – undo
2743 2743
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2744 2744
 		{
2745 2745
 		    
2746
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2747
-		    {
2748
-		        foreach ($object->lines as $line)
2749
-		        {
2750
-		            // fetch optionals attributes and labels
2751
-		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2752
-		            $extrafields=new ExtraFields($this->db);
2753
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2754
-		            $line->fetch_optionals($line->id,$extralabels);
2755
-		        }
2756
-		    }
2746
+			if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2747
+			{
2748
+				foreach ($object->lines as $line)
2749
+				{
2750
+					// fetch optionals attributes and labels
2751
+					require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2752
+					$extrafields=new ExtraFields($this->db);
2753
+					$extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2754
+					$line->fetch_optionals($line->id,$extralabels);
2755
+				}
2756
+			}
2757 2757
 		    
2758 2758
 			$TSubNc = array();
2759 2759
 			foreach ($object->lines as &$l)
@@ -2844,80 +2844,80 @@  discard block
 block discarded – undo
2844 2844
 	{
2845 2845
 		dol_include_once('/subtotal/class/subtotal.class.php');
2846 2846
 
2847
-	    $line = &$parameters['line'];
2847
+		$line = &$parameters['line'];
2848 2848
 	    
2849
-	    $ThtmlData['data-id']           = $line->id;
2850
-	    $ThtmlData['data-product_type'] = $line->product_type;
2851
-	    $ThtmlData['data-qty']          = 0; //$line->qty;
2852
-	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2849
+		$ThtmlData['data-id']           = $line->id;
2850
+		$ThtmlData['data-product_type'] = $line->product_type;
2851
+		$ThtmlData['data-qty']          = 0; //$line->qty;
2852
+		$ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2853 2853
 	    
2854
-	    if(TSubtotal::isTitle($line)){
2855
-	        $ThtmlData['data-issubtotal'] = 'title';
2856
-	    }elseif(TSubtotal::isSubtotal($line)){
2857
-	        $ThtmlData['data-issubtotal'] = 'subtotal';
2858
-	    }
2859
-	    else{
2860
-	        $ThtmlData['data-issubtotal'] = 'freetext';
2861
-	    }
2854
+		if(TSubtotal::isTitle($line)){
2855
+			$ThtmlData['data-issubtotal'] = 'title';
2856
+		}elseif(TSubtotal::isSubtotal($line)){
2857
+			$ThtmlData['data-issubtotal'] = 'subtotal';
2858
+		}
2859
+		else{
2860
+			$ThtmlData['data-issubtotal'] = 'freetext';
2861
+		}
2862 2862
 	    
2863 2863
 	    
2864
-	    // Change or add data  from hooks
2865
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2864
+		// Change or add data  from hooks
2865
+		$parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2866 2866
 	    
2867
-	    // hook 
2868
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2869
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2870
-	    if ($reshook>0)
2871
-	    {
2872
-	        $ThtmlData = $hookmanager->resArray;
2873
-	    }
2874
-
2875
-	    return $this->implodeHtmlData($ThtmlData);
2867
+		// hook 
2868
+		$reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2869
+		if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2870
+		if ($reshook>0)
2871
+		{
2872
+			$ThtmlData = $hookmanager->resArray;
2873
+		}
2874
+
2875
+		return $this->implodeHtmlData($ThtmlData);
2876 2876
 	
2877 2877
 	}
2878 2878
 	
2879 2879
 	
2880 2880
 	function implodeHtmlData($ThtmlData = array())
2881 2881
 	{
2882
-	    $data = '';
2883
-	    foreach($ThtmlData as $k => $h )
2884
-	    {
2885
-	        if(is_array($h))
2886
-	        {
2887
-	            $h = json_encode($h);
2888
-	        }
2882
+		$data = '';
2883
+		foreach($ThtmlData as $k => $h )
2884
+		{
2885
+			if(is_array($h))
2886
+			{
2887
+				$h = json_encode($h);
2888
+			}
2889 2889
 	        
2890
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2891
-	    }
2890
+			$data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2891
+		}
2892 2892
 	    
2893
-	    return $data;
2893
+		return $data;
2894 2894
 	}
2895 2895
 	
2896 2896
 	function _ajax_block_order_js($object)
2897 2897
 	{
2898
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2898
+		global $conf,$tagidfortablednd,$filepath,$langs;
2899 2899
 	    
2900
-	    /*
2900
+		/*
2901 2901
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2902 2902
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2903 2903
 	     */
2904 2904
 	    
2905
-	    $id=$object->id;
2906
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2907
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2905
+		$id=$object->id;
2906
+		$nboflines=(isset($object->lines)?count($object->lines):0);
2907
+		$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2908 2908
 	    
2909
-	    $id=$object->id;
2910
-	    $fk_element=$object->fk_element;
2911
-	    $table_element_line=$object->table_element_line;
2912
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2913
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2914
-	    $filepath=(empty($filepath)?'':$filepath);
2909
+		$id=$object->id;
2910
+		$fk_element=$object->fk_element;
2911
+		$table_element_line=$object->table_element_line;
2912
+		$nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2913
+		$tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2914
+		$filepath=(empty($filepath)?'':$filepath);
2915 2915
 	    
2916 2916
 	    
2917
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2918
-	    {
2917
+		if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2918
+		{
2919 2919
 	        
2920
-	        ?>
2920
+			?>
2921 2921
 		
2922 2922
 		
2923 2923
 			<script type="text/javascript">
Please login to merge, or discard this patch.
Spacing   +490 added lines, -490 removed lines patch added patch discarded remove patch
@@ -16,17 +16,17 @@  discard block
 block discarded – undo
16 16
 		
17 17
 		global $type_element, $where;
18 18
 		
19
-		$contexts = explode(':',$parameters['context']);
19
+		$contexts = explode(':', $parameters['context']);
20 20
 		
21
-		if(in_array('consumptionthirdparty',$contexts) && in_array($type_element, array('propal', 'order', 'invoice', 'supplier_order', 'supplier_invoice', 'supplier_proposal'))) {
21
+		if (in_array('consumptionthirdparty', $contexts) && in_array($type_element, array('propal', 'order', 'invoice', 'supplier_order', 'supplier_invoice', 'supplier_proposal'))) {
22 22
 			$mod_num = TSubtotal::$module_number;
23 23
 			
24 24
 			// Not a title (can't use TSubtotal class methods in sql)
25
-			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty > 9)';
25
+			$where .= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty > 9)';
26 26
 			// Not a subtotal (can't use TSubtotal class methods in sql)
27
-			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty < 90)';
27
+			$where .= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty < 90)';
28 28
 			// Not a free line text (can't use TSubtotal class methods in sql)
29
-			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty != 50)';
29
+			$where .= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty != 50)';
30 30
 			
31 31
 		}
32 32
 		
@@ -105,47 +105,47 @@  discard block
 block discarded – undo
105 105
     
106 106
     function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
107 107
     {
108
-      	global $langs,$db,$user, $conf;
108
+      	global $langs, $db, $user, $conf;
109 109
 		
110 110
 		$langs->load('subtotal@subtotal');
111 111
 		
112
-		$contexts = explode(':',$parameters['context']);
112
+		$contexts = explode(':', $parameters['context']);
113 113
 		
114
-		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) || in_array('expeditioncard',$contexts)) {
114
+		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) || in_array('expeditioncard', $contexts)) {
115 115
 			
116 116
 			$createRight = $user->rights->{$object->element}->creer;
117
-			if($object->element == 'facturerec' )
117
+			if ($object->element == 'facturerec')
118 118
 			{
119 119
 				$object->statut = 0; // hack for facture rec
120 120
 				$createRight = $user->rights->facture->creer;
121
-			} elseif($object->element == 'order_supplier' )
121
+			} elseif ($object->element == 'order_supplier')
122 122
 			{
123 123
 			    $createRight = $user->rights->fournisseur->commande->creer;
124
-			} elseif($object->element == 'invoice_supplier' )
124
+			} elseif ($object->element == 'invoice_supplier')
125 125
 			{
126 126
 			    $createRight = $user->rights->fournisseur->facture->creer;
127 127
 			}
128
-			elseif($object->element == 'shipping')
128
+			elseif ($object->element == 'shipping')
129 129
 			{
130 130
 				$createRight = true; // No rights management for shipments
131 131
 			}
132 132
 			
133
-			if ($object->statut == 0  && $createRight) {
133
+			if ($object->statut == 0 && $createRight) {
134 134
 			
135 135
 
136
-				if($object->element=='facture')$idvar = 'facid';
137
-				else $idvar='id';
136
+				if ($object->element == 'facture')$idvar = 'facid';
137
+				else $idvar = 'id';
138 138
 				
139
-				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
139
+				if (in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')))
140 140
 				{
141 141
 					$level = GETPOST('level', 'int'); //New avec SUBTOTAL_USE_NEW_FORMAT
142 142
 					
143
-					if($action=='add_title_line') {
143
+					if ($action == 'add_title_line') {
144 144
 						$title = GETPOST('title');
145
-						if(empty($title)) $title = $langs->trans('title');
146
-						$qty = $level<1 ? 1 : $level ;
145
+						if (empty($title)) $title = $langs->trans('title');
146
+						$qty = $level < 1 ? 1 : $level;
147 147
 					}
148
-					else if($action=='add_free_text') {
148
+					else if ($action == 'add_free_text') {
149 149
 						$title = GETPOST('title');
150 150
 
151 151
 						if (empty($title)) {
@@ -157,21 +157,21 @@  discard block
 block discarded – undo
157 157
 								}
158 158
 							}
159 159
 						}
160
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
160
+						if (empty($title)) $title = $langs->trans('subtotalAddLineDescription');
161 161
 						$qty = 50;
162 162
 					}
163
-					else if($action=='add_subtitle_line') {
163
+					else if ($action == 'add_subtitle_line') {
164 164
 						$title = GETPOST('title');
165
-						if(empty($title)) $title = $langs->trans('subtitle');
165
+						if (empty($title)) $title = $langs->trans('subtitle');
166 166
 						$qty = 2;
167 167
 					}
168
-					else if($action=='add_subtotal_line') {
168
+					else if ($action == 'add_subtotal_line') {
169 169
 						$title = $langs->trans('SubSubTotal');
170 170
 						$qty = 98;
171 171
 					}
172 172
 					else {
173 173
 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
174
-						$qty = $level ? 100-$level : 99;
174
+						$qty = $level ? 100 - $level : 99;
175 175
 					}
176 176
 					dol_include_once('/subtotal/class/subtotal.class.php');
177 177
 					
@@ -179,15 +179,15 @@  discard block
 block discarded – undo
179 179
 					
180 180
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
181 181
 				}
182
-				else if($action==='ask_deleteallline') {
183
-						$form=new Form($db);
182
+				else if ($action === 'ask_deleteallline') {
183
+						$form = new Form($db);
184 184
 
185
-						$lineid = GETPOST('lineid','integer');
185
+						$lineid = GETPOST('lineid', 'integer');
186 186
 						$TIdForGroup = $this->getArrayOfLineForAGroup($object, $lineid);
187 187
 					
188 188
 						$nbLines = count($TIdForGroup);
189 189
 					
190
-						$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines',$nbLines), 'confirm_delete_all_lines','',0,1);
190
+						$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines', $nbLines), 'confirm_delete_all_lines', '', 0, 1);
191 191
 						print $formconfirm;
192 192
 				}
193 193
 
@@ -197,13 +197,13 @@  discard block
 block discarded – undo
197 197
 				}
198 198
 
199 199
 				
200
-				if($object->element != 'shipping' && $action!='editline') {
200
+				if ($object->element != 'shipping' && $action != 'editline') {
201 201
 					// New format is for 3.8
202 202
 					$this->printNewFormat($object, $conf, $langs, $idvar);
203 203
 				}
204 204
 			}
205 205
 		}
206
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts) || in_array('orderstoinvoicesupplier',$contexts))
206
+		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice', $contexts) || in_array('orderstoinvoicesupplier', $contexts))
207 207
 		{
208 208
 			?>
209 209
 			<script type="text/javascript">
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 				$(document).ready(function() {
229 229
 					$('div.fiche div.tabsAction').append('<br />');
230 230
 					
231
-					$('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>');
231
+					$('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>');
232 232
 					$('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>');
233 233
 					$('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>');
234 234
 
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
 						$('body').append(dialog_html);
280 280
 
281 281
 						<?php 
282
-						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME)?'ckeditor':$conf->global->FCKEDITOR_EDITORNAME;
283
-						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
284
-						if($editorConf && in_array($editorTool,array('textarea','ckeditor'))){ 
282
+						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME) ? 'ckeditor' : $conf->global->FCKEDITOR_EDITORNAME;
283
+						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
284
+						if ($editorConf && in_array($editorTool, array('textarea', 'ckeditor'))) { 
285 285
 						?>
286 286
 						if (action == 'addTitle' || action == 'addFreeTxt')
287 287
 						{
@@ -396,62 +396,62 @@  discard block
 block discarded – undo
396 396
 		global $conf, $langs, $bc;
397 397
 			
398 398
 		$action = GETPOST('action');	
399
-		$TContext = explode(':',$parameters['context']);
399
+		$TContext = explode(':', $parameters['context']);
400 400
 		if (
401
-				in_array('invoicecard',$TContext)
402
-		        || in_array('invoicesuppliercard',$TContext)
403
-				|| in_array('propalcard',$TContext)
404
-				|| in_array('ordercard',$TContext)
405
-		        || in_array('ordersuppliercard',$TContext)
406
-				|| in_array('invoicereccard',$TContext)
401
+				in_array('invoicecard', $TContext)
402
+		        || in_array('invoicesuppliercard', $TContext)
403
+				|| in_array('propalcard', $TContext)
404
+				|| in_array('ordercard', $TContext)
405
+		        || in_array('ordersuppliercard', $TContext)
406
+				|| in_array('invoicereccard', $TContext)
407 407
 			)
408 408
 	        {	
409
-	            $hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
410
-	            $hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
411
-				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0;
412
-				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
409
+	            $hideInnerLines = isset($_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
410
+	            $hidedetails = isset($_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
411
+				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED) ? $conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED : 0;
412
+				$hideprices = isset($_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
413 413
 				
414
-				$var=false;
415
-		     	$out.= '<tr '.$bc[$var].'>
414
+				$var = false;
415
+		     	$out .= '<tr '.$bc[$var].'>
416 416
 		     			<td colspan="4" align="right">
417 417
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
418
-		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
418
+		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(($hideInnerLines) ? 'checked="checked"' : '').' />
419 419
 		     			</td>
420 420
 		     			</tr>';
421 421
 				
422
-		     	$var=!$var;
423
-		     	$out.= '<tr '.$bc[$var].'>
422
+		     	$var = !$var;
423
+		     	$out .= '<tr '.$bc[$var].'>
424 424
 		     			<td colspan="4" align="right">
425 425
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
426
-		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
426
+		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(($hidedetails) ? 'checked="checked"' : '').' />
427 427
 		     			</td>
428 428
 		     			</tr>';
429 429
 		     	
430
-		     	$var=!$var;
431
-		     	$out.= '<tr '.$bc[$var].'>
430
+		     	$var = !$var;
431
+		     	$out .= '<tr '.$bc[$var].'>
432 432
 		     			<td colspan="4" align="right">
433 433
 		     				<label for="hideprices">'.$langs->trans('SubTotalhidePrice').'</label>
434
-		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
434
+		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(($hideprices) ? 'checked="checked"' : '').' />
435 435
 		     			</td>
436 436
 		     			</tr>';
437 437
 		     	
438 438
 		     	
439 439
 				 
440 440
 				if ( 
441
-					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
442
-					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
443
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
444
-					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
445
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
446
-					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
441
+					(in_array('propalcard', $TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
442
+					|| (in_array('ordercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
443
+				    || (in_array('ordersuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
444
+					|| (in_array('invoicecard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
445
+				    || (in_array('invoicesuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
446
+					|| (in_array('invoicereccard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
447 447
 				)
448 448
 				{
449
-					$var=!$var;
450
-					$out.= '
449
+					$var = !$var;
450
+					$out .= '
451 451
 						<tr '.$bc[$var].'>
452 452
 							<td colspan="4" align="right">
453 453
 								<label for="subtotal_add_recap">'.$langs->trans('subtotal_add_recap').'</label>
454
-								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.( GETPOST('subtotal_add_recap') ? 'checked="checked"' : '' ).' />
454
+								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.(GETPOST('subtotal_add_recap') ? 'checked="checked"' : '').' />
455 455
 							</td>
456 456
 						</tr>';
457 457
 				}
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
     function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
468 468
     {
469 469
 		
470
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
470
+    	if (in_array('invoicecard', explode(':', $parameters['context'])))
471 471
         {
472 472
         	
473 473
         }
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
479 479
 		global $conf;
480 480
 		
481
-		if($action === 'builddoc') {
481
+		if ($action === 'builddoc') {
482 482
 			
483 483
 			$line = &$parameters['line'];
484 484
 			$object = &$parameters['object'];
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
             $substitutionarray['line_modsubtotal_total'] = false;
490 490
             $substitutionarray['line_modsubtotal_title'] = false;
491 491
 
492
-			if($line->product_type == 9 && $line->special_code == $this->module_number) {
492
+			if ($line->product_type == 9 && $line->special_code == $this->module_number) {
493 493
 				$substitutionarray['line_modsubtotal'] = 1;	
494 494
                 $substitutionarray['line_not_modsubtotal'] = false;
495 495
 				
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 					 = $substitutionarray['line_up'] 
502 502
 					 = '';
503 503
 				
504
-				if($line->qty>90) {
504
+				if ($line->qty > 90) {
505 505
 					$substitutionarray['line_modsubtotal_total'] = true;
506 506
 					
507 507
 					//list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 				
517 517
 				
518 518
 			}	
519
-			else{
519
+			else {
520 520
 				$substitutionarray['line_not_modsubtotal'] = true;
521 521
 				$substitutionarray['line_modsubtotal'] = 0;
522 522
 			}
@@ -528,29 +528,29 @@  discard block
 block discarded – undo
528 528
 	function createFrom($parameters, &$object, $action, $hookmanager) {
529 529
 	
530 530
 		if (
531
-				in_array('invoicecard',explode(':',$parameters['context']))
532
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
533
-				|| in_array('propalcard',explode(':',$parameters['context']))
534
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
535
-				|| in_array('ordercard',explode(':',$parameters['context']))
536
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
537
-				|| in_array('invoicereccard',explode(':',$parameters['context']))
531
+				in_array('invoicecard', explode(':', $parameters['context']))
532
+		        || in_array('invoicesuppliercard', explode(':', $parameters['context']))
533
+				|| in_array('propalcard', explode(':', $parameters['context']))
534
+		        || in_array('supplier_proposalcard', explode(':', $parameters['context']))
535
+				|| in_array('ordercard', explode(':', $parameters['context']))
536
+		        || in_array('ordersuppliercard', explode(':', $parameters['context']))
537
+				|| in_array('invoicereccard', explode(':', $parameters['context']))
538 538
 		) {
539 539
 			
540 540
 			global $db;
541 541
 			
542 542
 			$objFrom = $parameters['objFrom'];
543 543
 			
544
-			foreach($objFrom->lines as $k=> &$lineOld) {
544
+			foreach ($objFrom->lines as $k=> &$lineOld) {
545 545
 				
546
-					if($lineOld->product_type == 9 && $lineOld->info_bits > 0 ) {
546
+					if ($lineOld->product_type == 9 && $lineOld->info_bits > 0) {
547 547
 							
548 548
 							$line = & $object->lines[$k];
549 549
 				
550 550
 							$idLine = (int) ($line->id ? $line->id : $line->rowid); 
551 551
 				
552 552
 							$db->query("UPDATE ".MAIN_DB_PREFIX.$line->table_element."
553
-							SET info_bits=".(int)$lineOld->info_bits."
553
+							SET info_bits=".(int) $lineOld->info_bits."
554 554
 							WHERE rowid = ".$idLine."
555 555
 							");
556 556
 						
@@ -566,15 +566,15 @@  discard block
 block discarded – undo
566 566
 	
567 567
 	function doActions($parameters, &$object, $action, $hookmanager)
568 568
 	{
569
-		global $db, $conf, $langs,$user;
569
+		global $db, $conf, $langs, $user;
570 570
 		
571 571
 		dol_include_once('/subtotal/class/subtotal.class.php');
572 572
 		dol_include_once('/subtotal/lib/subtotal.lib.php');
573
-		require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
573
+		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
574 574
 		
575 575
 		$showBlockExtrafields = GETPOST('showBlockExtrafields');
576 576
 		
577
-		if($object->element=='facture') $idvar = 'facid';
577
+		if ($object->element == 'facture') $idvar = 'facid';
578 578
 		else $idvar = 'id';
579 579
 			
580 580
 		if ($action == 'updateligne' || $action == 'updateline')
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 				if ($line->id == $lineid && TSubtotal::isModSubtotalLine($line))
588 588
 				{
589 589
 					$found = true;
590
-					if(TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
590
+					if (TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
591 591
 						$extrafieldsline = new ExtraFields($db);
592 592
 						$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
593 593
 						$extrafieldsline->setOptionalsFromPost($extralabelsline, $line);
@@ -606,43 +606,43 @@  discard block
 block discarded – undo
606 606
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
607 607
 			}
608 608
 		}
609
-		else if($action === 'builddoc') {
609
+		else if ($action === 'builddoc') {
610 610
 			
611 611
 			if (
612
-				in_array('invoicecard',explode(':',$parameters['context']))
613
-				|| in_array('propalcard',explode(':',$parameters['context']))
614
-				|| in_array('ordercard',explode(':',$parameters['context']))
615
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
616
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
617
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
612
+				in_array('invoicecard', explode(':', $parameters['context']))
613
+				|| in_array('propalcard', explode(':', $parameters['context']))
614
+				|| in_array('ordercard', explode(':', $parameters['context']))
615
+			    || in_array('ordersuppliercard', explode(':', $parameters['context']))
616
+			    || in_array('invoicesuppliercard', explode(':', $parameters['context']))
617
+			    || in_array('supplier_proposalcard', explode(':', $parameters['context']))
618 618
 			)
619 619
 	        {								
620
-				if(in_array('invoicecard',explode(':',$parameters['context']))) {
620
+				if (in_array('invoicecard', explode(':', $parameters['context']))) {
621 621
 					$sessname = 'subtotal_hideInnerLines_facture';	
622 622
 					$sessname2 = 'subtotal_hidedetails_facture';
623 623
 					$sessname3 = 'subtotal_hideprices_facture';
624 624
 				}
625
-				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
625
+				elseif (in_array('invoicesuppliercard', explode(':', $parameters['context']))) {
626 626
 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
627 627
 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
628 628
 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
629 629
 				}
630
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
630
+				elseif (in_array('propalcard', explode(':', $parameters['context']))) {
631 631
 					$sessname = 'subtotal_hideInnerLines_propal';
632 632
 					$sessname2 = 'subtotal_hidedetails_propal';	
633 633
 					$sessname3 = 'subtotal_hideprices_propal';
634 634
 				}
635
-				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
635
+				elseif (in_array('supplier_proposalcard', explode(':', $parameters['context']))) {
636 636
 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
637 637
 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
638 638
 				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
639 639
 				}
640
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
640
+				elseif (in_array('ordercard', explode(':', $parameters['context']))) {
641 641
 					$sessname = 'subtotal_hideInnerLines_commande';
642 642
 					$sessname2 = 'subtotal_hidedetails_commande';	
643 643
 					$sessname3 = 'subtotal_hideprices_commande';
644 644
 				}
645
-				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
645
+				elseif (in_array('ordersuppliercard', explode(':', $parameters['context']))) {
646 646
 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
647 647
 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
648 648
 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
@@ -655,25 +655,25 @@  discard block
 block discarded – undo
655 655
 					
656 656
 				global $hideprices;
657 657
 				
658
-				$hideInnerLines = (int)GETPOST('hideInnerLines');
659
-				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) $_SESSION[$sessname] = array(); // prevent old system
658
+				$hideInnerLines = (int) GETPOST('hideInnerLines');
659
+				if (!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id])) $_SESSION[$sessname] = array(); // prevent old system
660 660
 				$_SESSION[$sessname][$object->id] = $hideInnerLines;		
661 661
 				
662
-				$hidedetails= (int)GETPOST('hidedetails');
663
-				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) $_SESSION[$sessname2] = array(); // prevent old system
662
+				$hidedetails = (int) GETPOST('hidedetails');
663
+				if (!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id])) $_SESSION[$sessname2] = array(); // prevent old system
664 664
 				$_SESSION[$sessname2][$object->id] = $hidedetails;
665 665
 				
666
-				$hideprices= (int)GETPOST('hideprices');
667
-				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) $_SESSION[$sessname3] = array(); // prevent old system
666
+				$hideprices = (int) GETPOST('hideprices');
667
+				if (!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id])) $_SESSION[$sessname3] = array(); // prevent old system
668 668
 				$_SESSION[$sessname3][$object->id] = $hideprices;
669 669
 				
670
-				foreach($object->lines as &$line) {
670
+				foreach ($object->lines as &$line) {
671 671
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
672 672
 					    
673
-                        if($line->qty>=90) {
673
+                        if ($line->qty >= 90) {
674 674
                             $line->modsubtotal_total = 1;
675 675
                         }
676
-                        else{
676
+                        else {
677 677
                             $line->modsubtotal_title = 1;
678 678
                         }
679 679
                         
@@ -683,34 +683,34 @@  discard block
 block discarded – undo
683 683
 	        }
684 684
 			
685 685
 		}
686
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
686
+		else if ($action === 'confirm_delete_all_lines' && GETPOST('confirm') == 'yes') {
687 687
 			
688 688
 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
689 689
 			
690
-			foreach($Tab as $idLine) {
690
+			foreach ($Tab as $idLine) {
691 691
 				/**
692 692
 				 * @var $object Facture
693 693
 				 */
694
-				if($object->element=='facture') $object->deleteline($idLine);
694
+				if ($object->element == 'facture') $object->deleteline($idLine);
695 695
 				/**
696 696
 				 * @var $object Facture fournisseur
697 697
 				 */
698
-				else if($object->element=='invoice_supplier')
698
+				else if ($object->element == 'invoice_supplier')
699 699
 				{
700 700
 				    $object->deleteline($idLine);
701 701
 				}
702 702
 				/**
703 703
 				 * @var $object Propal
704 704
 				 */
705
-				else if($object->element=='propal') $object->deleteline($idLine);
705
+				else if ($object->element == 'propal') $object->deleteline($idLine);
706 706
 				/**
707 707
 				 * @var $object Propal Fournisseur
708 708
 				 */
709
-				else if($object->element=='supplier_proposal') $object->deleteline($idLine);
709
+				else if ($object->element == 'supplier_proposal') $object->deleteline($idLine);
710 710
 				/**
711 711
 				 * @var $object Commande
712 712
 				 */
713
-				else if($object->element=='commande') 
713
+				else if ($object->element == 'commande') 
714 714
 				{
715 715
 					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
716 716
 					else $object->deleteline($idLine);
@@ -718,18 +718,18 @@  discard block
 block discarded – undo
718 718
 				/**
719 719
 				 * @var $object Commande fournisseur
720 720
 				 */
721
-				else if($object->element=='order_supplier')
721
+				else if ($object->element == 'order_supplier')
722 722
 				{
723 723
 				    $object->deleteline($idLine);
724 724
 				}
725 725
 				/**
726 726
 				 * @var $object Facturerec
727 727
 				 */
728
-				else if($object->element=='facturerec') $object->deleteline($idLine);
728
+				else if ($object->element == 'facturerec') $object->deleteline($idLine);
729 729
 				/**
730 730
 				 * @var $object Expedition
731 731
 				 */
732
-				else if($object->element=='shipping') $object->deleteline($user, $idLine);
732
+				else if ($object->element == 'shipping') $object->deleteline($user, $idLine);
733 733
 			}
734 734
 			
735 735
 			header('location:?id='.$object->id);
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 		return 0;
753 753
 	}
754 754
 	
755
-	function formAddObjectLine ($parameters, &$object, &$action, $hookmanager) {
755
+	function formAddObjectLine($parameters, &$object, &$action, $hookmanager) {
756 756
 		return 0;
757 757
 	}
758 758
 	
@@ -770,8 +770,8 @@  discard block
 block discarded – undo
770 770
 			if (!empty($parameters['fk_element']))
771 771
 			{
772 772
 				
773
-				if($obj->fetch($parameters['fk_element'])){
774
-					$obj->id= $obj->rowid;
773
+				if ($obj->fetch($parameters['fk_element'])) {
774
+					$obj->id = $obj->rowid;
775 775
 					if (empty($obj->array_options))
776 776
 						$obj->fetch_optionals();
777 777
 					if (!empty($obj->array_options['options_subtotal_nc']))
@@ -791,22 +791,22 @@  discard block
 block discarded – undo
791 791
 		
792 792
 		$found = false;
793 793
 
794
-		$Tab= array();
794
+		$Tab = array();
795 795
 		
796
-		foreach($object->lines as $l) {
796
+		foreach ($object->lines as $l) {
797 797
 		
798 798
 		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
799
-			if($lid == $lineid) {
799
+			if ($lid == $lineid) {
800 800
 
801 801
 				$found = true;
802 802
 				$qty_line = $l->qty;
803 803
 			}
804 804
 			
805
-			if($found) {
805
+			if ($found) {
806 806
 				
807 807
 			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
808 808
 				
809
-				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
809
+				if ($l->special_code == $this->module_number && (($l->qty == 99 && $qty_line == 1) || ($l->qty == 98 && $qty_line == 2))) {
810 810
 					break; // end of story
811 811
 				}
812 812
 			}
@@ -819,7 +819,7 @@  discard block
 block discarded – undo
819 819
 		
820 820
 	}
821 821
 
822
-	function getTotalLineFromObject(&$object, &$line, $use_level=false, $return_all=0) {
822
+	function getTotalLineFromObject(&$object, &$line, $use_level = false, $return_all = 0) {
823 823
 		global $conf;
824 824
 
825 825
 		$rang = $line->rang;
@@ -832,8 +832,8 @@  discard block
 block discarded – undo
832 832
 		$total_ttc = 0;
833 833
 		$TTotal_tva = array();
834 834
 		
835
-		$sign=1;
836
-		if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
835
+		$sign = 1;
836
+		if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
837 837
 		
838 838
 		if (GETPOST('action') == 'builddoc') $builddoc = true;
839 839
 		else $builddoc = false;
@@ -842,15 +842,15 @@  discard block
 block discarded – undo
842 842
 
843 843
 		$TLineReverse = array_reverse($object->lines);
844 844
 
845
-		foreach($TLineReverse as $l)
845
+		foreach ($TLineReverse as $l)
846 846
 		{
847 847
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
848
-            if ($l->rang>=$rang) continue;
848
+            if ($l->rang >= $rang) continue;
849 849
             if (!empty($title_break) && $title_break->id == $l->id) break;
850 850
             elseif (!TSubtotal::isModSubtotalLine($l))
851 851
             {
852 852
                 // TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF
853
-                if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION)
853
+                if ($builddoc && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
854 854
                 {
855 855
                     if ($l->situation_percent > 0)
856 856
                     {
@@ -863,7 +863,7 @@  discard block
 block discarded – undo
863 863
                         }
864 864
 
865 865
                         $result = $sign * ($l->total_ht / ($l->situation_percent / 100)) * $progress;
866
-                        $total+= $result;
866
+                        $total += $result;
867 867
                         // TODO check si les 3 lignes du dessous sont corrects
868 868
                         $total_tva += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
869 869
                         $TTotal_tva[$l->tva_tx] += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
@@ -894,10 +894,10 @@  discard block
 block discarded – undo
894 894
 	 * @param $w            float               width
895 895
 	 * @param $h            float               height
896 896
 	 */
897
-	function pdf_add_total(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
898
-		global $conf,$subtotal_last_title_posy;
897
+	function pdf_add_total(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
898
+		global $conf, $subtotal_last_title_posy;
899 899
 
900
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
900
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
901 901
 		if (!empty($conf->global->SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES) && $hideInnerLines && !empty($subtotal_last_title_posy))
902 902
 		{
903 903
 			$posy = $subtotal_last_title_posy;
@@ -906,40 +906,40 @@  discard block
 block discarded – undo
906 906
 		
907 907
 		$hidePriceOnSubtotalLines = (int) GETPOST('hide_price_on_subtotal_lines');
908 908
 
909
-		if($object->element == 'shipping' || $object->element == 'delivery')
909
+		if ($object->element == 'shipping' || $object->element == 'delivery')
910 910
 		{
911 911
 			$hidePriceOnSubtotalLines = 1;
912 912
 		}
913 913
 		
914 914
 		$set_pagebreak_margin = false;
915
-		if(method_exists('Closure','bind')) {
915
+		if (method_exists('Closure', 'bind')) {
916 916
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
917
-			$sweetsThief = function ($pdf) {
918
-		    		return $pdf->bMargin ;
917
+			$sweetsThief = function($pdf) {
918
+		    		return $pdf->bMargin;
919 919
 			};
920 920
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
921 921
 	
922
-			$bMargin  = $sweetsThief($pdf);
922
+			$bMargin = $sweetsThief($pdf);
923 923
 	
924
-			$pdf->SetAutoPageBreak( false );
924
+			$pdf->SetAutoPageBreak(false);
925 925
 
926 926
 			$set_pagebreak_margin = true;			
927 927
 		}
928 928
 		
929 929
 			
930
-		if($line->qty==99)
931
-			$pdf->SetFillColor(220,220,220);
932
-		elseif ($line->qty==98)
933
-			$pdf->SetFillColor(230,230,230);
930
+		if ($line->qty == 99)
931
+			$pdf->SetFillColor(220, 220, 220);
932
+		elseif ($line->qty == 98)
933
+			$pdf->SetFillColor(230, 230, 230);
934 934
 		else
935
-			$pdf->SetFillColor(240,240,240);
935
+			$pdf->SetFillColor(240, 240, 240);
936 936
 		
937 937
 		$style = 'B';
938 938
 		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
939 939
 		
940 940
 		$pdf->SetFont('', $style, 9);
941 941
 		
942
-		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R',true);
942
+		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R', true);
943 943
 //		var_dump($bMargin);
944 944
 		$pageAfter = $pdf->getPage();
945 945
 		
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
 			
968 968
 			
969 969
 			
970
-			if($total_to_print !== '') {
970
+			if ($total_to_print !== '') {
971 971
 				
972 972
 				if (GETPOST('hideInnerLines'))
973 973
 				{
@@ -994,11 +994,11 @@  discard block
 block discarded – undo
994 994
 			}
995 995
 
996 996
 			$pdf->SetXY($pdf->postotalht, $posy);
997
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
998
-			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
997
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
998
+			$pdf->MultiCell($pdf->page_largeur - $pdf->marge_droite - $pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
999 999
 		}
1000
-		else{
1001
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1000
+		else {
1001
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
1002 1002
 		}
1003 1003
 		
1004 1004
 		$posy = $posy + $cell_height;
@@ -1018,22 +1018,22 @@  discard block
 block discarded – undo
1018 1018
 	 * @param $w            float               width
1019 1019
 	 * @param $h            float               height
1020 1020
 	 */
1021
-	function pdf_add_title(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
1021
+	function pdf_add_title(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
1022 1022
 		
1023
-		global $db,$conf,$subtotal_last_title_posy;
1023
+		global $db, $conf, $subtotal_last_title_posy;
1024 1024
 		
1025 1025
 		$subtotal_last_title_posy = $posy;
1026
-		$pdf->SetXY ($posx, $posy);
1026
+		$pdf->SetXY($posx, $posy);
1027 1027
 		
1028
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1028
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1029 1029
 		
1030 1030
 		
1031 1031
  
1032
-		$style = ($line->qty==1) ? 'BU' : 'BUI';
1032
+		$style = ($line->qty == 1) ? 'BU' : 'BUI';
1033 1033
 		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
1034 1034
 		
1035
-		if($hideInnerLines) {
1036
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
1035
+		if ($hideInnerLines) {
1036
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9);
1037 1037
 			else 
1038 1038
 			{
1039 1039
 				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
@@ -1042,44 +1042,44 @@  discard block
 block discarded – undo
1042 1042
 		}
1043 1043
 		else {
1044 1044
 
1045
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
1045
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9); //TODO if super utile
1046 1046
 			else $pdf->SetFont('', $style, 9);
1047 1047
 			
1048 1048
 		}
1049 1049
 		
1050 1050
 		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
1051
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
1051
+		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J', true); // et maintenant avec du HTML
1052 1052
 		
1053
-		if($description && !$hidedesc) {
1053
+		if ($description && !$hidedesc) {
1054 1054
 			$posy = $pdf->GetY();
1055 1055
 			
1056 1056
 			$pdf->SetFont('', '', 8);
1057 1057
 			
1058
-			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J',true);
1058
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J', true);
1059 1059
 
1060 1060
 		}
1061 1061
 		
1062 1062
 	}
1063 1063
 
1064
-	function pdf_writelinedesc_ref($parameters=array(), &$object, &$action='') {
1064
+	function pdf_writelinedesc_ref($parameters = array(), &$object, &$action = '') {
1065 1065
 	// ultimate PDF hook O_o
1066 1066
 		
1067
-		return $this->pdf_writelinedesc($parameters,$object,$action);
1067
+		return $this->pdf_writelinedesc($parameters, $object, $action);
1068 1068
 		
1069 1069
 	}
1070 1070
 
1071 1071
 	function isModSubtotalLine(&$parameters, &$object) {
1072 1072
 		
1073
-		if(is_array($parameters)) {
1073
+		if (is_array($parameters)) {
1074 1074
 			$i = & $parameters['i'];	
1075 1075
 		}
1076 1076
 		else {
1077
-			$i = (int)$parameters;
1077
+			$i = (int) $parameters;
1078 1078
 		}
1079 1079
 
1080 1080
 		$line = $object->lines[$i];
1081 1081
 
1082
-		if($object->element == 'shipping' || $object->element == 'delivery')
1082
+		if ($object->element == 'shipping' || $object->element == 'delivery')
1083 1083
 		{
1084 1084
 			dol_include_once('/commande/class/commande.class.php');
1085 1085
 			$line = new OrderLine($object->db);
@@ -1087,7 +1087,7 @@  discard block
 block discarded – undo
1087 1087
 		}
1088 1088
 		
1089 1089
 
1090
-		if($line->special_code == $this->module_number && $line->product_type == 9) {
1090
+		if ($line->special_code == $this->module_number && $line->product_type == 9) {
1091 1091
 			return true;
1092 1092
 		}
1093 1093
 		
@@ -1095,42 +1095,42 @@  discard block
 block discarded – undo
1095 1095
 		
1096 1096
 	}
1097 1097
 
1098
-	function pdf_getlineqty($parameters=array(), &$object, &$action='') {
1099
-		global $conf,$hideprices;
1098
+	function pdf_getlineqty($parameters = array(), &$object, &$action = '') {
1099
+		global $conf, $hideprices;
1100 1100
 
1101
-		if($this->isModSubtotalLine($parameters,$object) ){
1101
+		if ($this->isModSubtotalLine($parameters, $object)) {
1102 1102
 			$this->resprints = ' ';
1103 1103
 			
1104
-			if((float)DOL_VERSION<=3.6) {
1104
+			if ((float) DOL_VERSION <= 3.6) {
1105 1105
 				return '';
1106 1106
 			}
1107
-			else if((float)DOL_VERSION>=3.8) {
1107
+			else if ((float) DOL_VERSION >= 3.8) {
1108 1108
 				return 1;
1109 1109
 			}
1110 1110
 			
1111 1111
 		}
1112
-		elseif(!empty($hideprices)) {
1112
+		elseif (!empty($hideprices)) {
1113 1113
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1114 1114
 			return 1;
1115 1115
 		}
1116 1116
 		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1117 1117
 		{
1118
-			$hideInnerLines = (int)GETPOST('hideInnerLines');
1119
-			$hidedetails = (int)GETPOST('hidedetails');
1118
+			$hideInnerLines = (int) GETPOST('hideInnerLines');
1119
+			$hidedetails = (int) GETPOST('hidedetails');
1120 1120
 			if (empty($hideInnerLines) && !empty($hidedetails))
1121 1121
 			{
1122 1122
 				$this->resprints = $object->lines[$parameters['i']]->qty;
1123 1123
 			}
1124 1124
 		}
1125 1125
 		
1126
-		if(is_array($parameters)) $i = & $parameters['i'];
1127
-		else $i = (int)$parameters;
1126
+		if (is_array($parameters)) $i = & $parameters['i'];
1127
+		else $i = (int) $parameters;
1128 1128
 
1129 1129
 		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)
1130 1130
 		
1131
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1131
+		if (empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1132 1132
 
1133
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1133
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1134 1134
 		{
1135 1135
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1136 1136
 			{
@@ -1142,20 +1142,20 @@  discard block
 block discarded – undo
1142 1142
 		return 0;
1143 1143
 	}
1144 1144
 	
1145
-	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1145
+	function pdf_getlinetotalexcltax($parameters = array(), &$object, &$action = '') {
1146 1146
 	    global $conf, $hideprices, $hookmanager;
1147 1147
 		
1148
-		if(is_array($parameters)) $i = & $parameters['i'];
1149
-		else $i = (int)$parameters;
1148
+		if (is_array($parameters)) $i = & $parameters['i'];
1149
+		else $i = (int) $parameters;
1150 1150
 			
1151
-		if($this->isModSubtotalLine($parameters,$object) ){
1151
+		if ($this->isModSubtotalLine($parameters, $object)) {
1152 1152
 			
1153 1153
 			$this->resprints = ' ';
1154 1154
 			
1155
-			if((float)DOL_VERSION<=3.6) {
1155
+			if ((float) DOL_VERSION <= 3.6) {
1156 1156
 				return '';
1157 1157
 			}
1158
-			else if((float)DOL_VERSION>=3.8) {
1158
+			else if ((float) DOL_VERSION >= 3.8) {
1159 1159
 				return 1;
1160 1160
 			}
1161 1161
 			
@@ -1181,7 +1181,7 @@  discard block
 block discarded – undo
1181 1181
 				}
1182 1182
 			}
1183 1183
 		}
1184
-		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1184
+		if ((int) GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) {
1185 1185
 		    $this->resprints = price($object->lines[$i]->total_ht);
1186 1186
 		}
1187 1187
 		
@@ -1206,7 +1206,7 @@  discard block
 block discarded – undo
1206 1206
 		{
1207 1207
 			// Check if a title exist for this line && if the title have subtotal
1208 1208
 			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1209
-			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1209
+			if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1210 1210
 			{
1211 1211
 
1212 1212
 				$this->resprints = ' ';
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
 	 */
1227 1227
 	private function callHook(&$object, &$hookmanager, $action, $params, $defaultReturn = 1)
1228 1228
 	{
1229
-		$reshook=$hookmanager->executeHooks('subtotalHidePrices',$params, $object, $action);
1229
+		$reshook = $hookmanager->executeHooks('subtotalHidePrices', $params, $object, $action);
1230 1230
 		if ($reshook < 0)
1231 1231
 		{
1232 1232
 			$this->error = $hookmanager->error;
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
 			$this->resprints = $hookmanager->resprints;
1243 1243
 
1244 1244
 			// override return (use  $this->results['overrideReturn'] or $this->resArray['overrideReturn'] in other module action_xxxx.class.php )
1245
-			if(isset($hookmanager->resArray['overrideReturn']))
1245
+			if (isset($hookmanager->resArray['overrideReturn']))
1246 1246
 			{
1247 1247
 				return $hookmanager->resArray['overrideReturn'];
1248 1248
 			}
@@ -1251,25 +1251,25 @@  discard block
 block discarded – undo
1251 1251
 		return $defaultReturn;
1252 1252
 	}
1253 1253
 	
1254
-	function pdf_getlinetotalwithtax($parameters=array(), &$object, &$action='') {
1254
+	function pdf_getlinetotalwithtax($parameters = array(), &$object, &$action = '') {
1255 1255
 		global $conf;
1256 1256
 		
1257
-		if($this->isModSubtotalLine($parameters,$object) ){
1257
+		if ($this->isModSubtotalLine($parameters, $object)) {
1258 1258
 			
1259 1259
 			$this->resprints = ' ';
1260 1260
 		
1261
-			if((float)DOL_VERSION<=3.6) {
1261
+			if ((float) DOL_VERSION <= 3.6) {
1262 1262
 				return '';
1263 1263
 			}
1264
-			else if((float)DOL_VERSION>=3.8) {
1264
+			else if ((float) DOL_VERSION >= 3.8) {
1265 1265
 				return 1;
1266 1266
 			}
1267 1267
 		}
1268 1268
 		
1269
-		if(is_array($parameters)) $i = & $parameters['i'];
1270
-		else $i = (int)$parameters;
1269
+		if (is_array($parameters)) $i = & $parameters['i'];
1270
+		else $i = (int) $parameters;
1271 1271
 		
1272
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1272
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))) 
1273 1273
 		{
1274 1274
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1275 1275
 			{
@@ -1281,24 +1281,24 @@  discard block
 block discarded – undo
1281 1281
 		return 0;
1282 1282
 	}
1283 1283
 	
1284
-	function pdf_getlineunit($parameters=array(), &$object, &$action='') {
1284
+	function pdf_getlineunit($parameters = array(), &$object, &$action = '') {
1285 1285
 		global $conf;
1286 1286
 		
1287
-		if($this->isModSubtotalLine($parameters,$object) ){
1287
+		if ($this->isModSubtotalLine($parameters, $object)) {
1288 1288
 			$this->resprints = ' ';
1289 1289
 		
1290
-			if((float)DOL_VERSION<=3.6) {
1290
+			if ((float) DOL_VERSION <= 3.6) {
1291 1291
 				return '';
1292 1292
 			}
1293
-			else if((float)DOL_VERSION>=3.8) {
1293
+			else if ((float) DOL_VERSION >= 3.8) {
1294 1294
 				return 1;
1295 1295
 			}
1296 1296
 		}
1297 1297
 		
1298
-		if(is_array($parameters)) $i = & $parameters['i'];
1299
-		else $i = (int)$parameters;
1298
+		if (is_array($parameters)) $i = & $parameters['i'];
1299
+		else $i = (int) $parameters;
1300 1300
 			
1301
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1301
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1302 1302
 		{
1303 1303
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1304 1304
 			{
@@ -1310,32 +1310,32 @@  discard block
 block discarded – undo
1310 1310
 		return 0;
1311 1311
 	}
1312 1312
 	
1313
-	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1314
-	    global $conf,$hideprices,$hookmanager;
1313
+	function pdf_getlineupexcltax($parameters = array(), &$object, &$action = '') {
1314
+	    global $conf, $hideprices, $hookmanager;
1315 1315
 
1316
-		if(is_array($parameters)) $i = & $parameters['i'];
1317
-		else $i = (int)$parameters;
1316
+		if (is_array($parameters)) $i = & $parameters['i'];
1317
+		else $i = (int) $parameters;
1318 1318
 
1319
-		if($this->isModSubtotalLine($parameters,$object) ) {
1319
+		if ($this->isModSubtotalLine($parameters, $object)) {
1320 1320
 			$this->resprints = ' ';
1321 1321
 
1322 1322
             $line = $object->lines[$i];
1323 1323
 
1324 1324
             // On récupère les montants du bloc pour les afficher dans la ligne de sous-total
1325
-            if(TSubtotal::isSubtotal($line)) {
1325
+            if (TSubtotal::isSubtotal($line)) {
1326 1326
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1327 1327
 
1328
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1329
-                if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1328
+                if (is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1329
+                if (!empty($parentTitle->array_options['options_show_total_ht'])) {
1330 1330
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1331 1331
                     $this->resprints = price($TTotal['total_unit_subprice']);
1332 1332
                 }
1333 1333
             }
1334 1334
 		
1335
-			if((float)DOL_VERSION<=3.6) {
1335
+			if ((float) DOL_VERSION <= 3.6) {
1336 1336
 				return '';
1337 1337
 			}
1338
-			else if((float)DOL_VERSION>=3.8) {
1338
+			else if ((float) DOL_VERSION >= 3.8) {
1339 1339
 				return 1;
1340 1340
 			}
1341 1341
 		}
@@ -1363,7 +1363,7 @@  discard block
 block discarded – undo
1363 1363
 		    
1364 1364
 		    // Check if a title exist for this line && if the title have subtotal
1365 1365
 		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1366
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1366
+		    if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1367 1367
 		    {
1368 1368
 		        
1369 1369
 		        $this->resprints = ' ';
@@ -1377,37 +1377,37 @@  discard block
 block discarded – undo
1377 1377
 		return 0;
1378 1378
 	}
1379 1379
 	
1380
-	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1381
-	    global $conf,$hideprices,$hookmanager;
1380
+	function pdf_getlineremisepercent($parameters = array(), &$object, &$action = '') {
1381
+	    global $conf, $hideprices, $hookmanager;
1382 1382
 
1383
-        if(is_array($parameters)) $i = & $parameters['i'];
1383
+        if (is_array($parameters)) $i = & $parameters['i'];
1384 1384
         else $i = (int) $parameters;
1385 1385
 
1386
-		if($this->isModSubtotalLine($parameters,$object) ) {
1386
+		if ($this->isModSubtotalLine($parameters, $object)) {
1387 1387
 			$this->resprints = ' ';
1388 1388
 
1389 1389
             $line = $object->lines[$i];
1390 1390
 
1391 1391
             // Affichage de la remise 
1392
-            if(TSubtotal::isSubtotal($line)) {
1392
+            if (TSubtotal::isSubtotal($line)) {
1393 1393
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1394 1394
 
1395
-                if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1396
-                if(! empty($parentTitle->array_options['options_show_reduc'])) {
1395
+                if (empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1396
+                if (!empty($parentTitle->array_options['options_show_reduc'])) {
1397 1397
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1398
-                    $this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
1398
+                    $this->resprints = price((1 - $TTotal['total_ht'] / $TTotal['total_subprice']) * 100, 0, '', 1, 2, 2).'%';
1399 1399
                 }
1400 1400
             }
1401 1401
 		
1402
-			if((float)DOL_VERSION<=3.6) {
1402
+			if ((float) DOL_VERSION <= 3.6) {
1403 1403
 				return '';
1404 1404
 			}
1405
-			else if((float)DOL_VERSION>=3.8) {
1405
+			else if ((float) DOL_VERSION >= 3.8) {
1406 1406
 				return 1;
1407 1407
 			}
1408 1408
 		}
1409 1409
 		elseif (!empty($hideprices)
1410
-		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1410
+		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1411 1411
 		        )
1412 1412
 		    {
1413 1413
 		        if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1420,24 +1420,24 @@  discard block
 block discarded – undo
1420 1420
 		return 0;
1421 1421
 	}
1422 1422
 	
1423
-	function pdf_getlineupwithtax($parameters=array(), &$object, &$action='') {
1424
-		global $conf,$hideprices;
1423
+	function pdf_getlineupwithtax($parameters = array(), &$object, &$action = '') {
1424
+		global $conf, $hideprices;
1425 1425
 		
1426
-		if($this->isModSubtotalLine($parameters,$object) ){
1426
+		if ($this->isModSubtotalLine($parameters, $object)) {
1427 1427
 			$this->resprints = ' ';
1428
-			if((float)DOL_VERSION<=3.6) {
1428
+			if ((float) DOL_VERSION <= 3.6) {
1429 1429
 				return '';
1430 1430
 			}
1431
-			else if((float)DOL_VERSION>=3.8) {
1431
+			else if ((float) DOL_VERSION >= 3.8) {
1432 1432
 				return 1;
1433 1433
 			}
1434 1434
 		}
1435 1435
 		
1436
-		if(is_array($parameters)) $i = & $parameters['i'];
1437
-		else $i = (int)$parameters;
1436
+		if (is_array($parameters)) $i = & $parameters['i'];
1437
+		else $i = (int) $parameters;
1438 1438
 			
1439 1439
 		if (!empty($hideprices)
1440
-				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1440
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1441 1441
 		)
1442 1442
 		{
1443 1443
 			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1450,22 +1450,22 @@  discard block
 block discarded – undo
1450 1450
 		return 0;
1451 1451
 	}
1452 1452
 	
1453
-	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
1454
-	    global $conf,$hideprices,$hookmanager;
1453
+	function pdf_getlinevatrate($parameters = array(), &$object, &$action = '') {
1454
+	    global $conf, $hideprices, $hookmanager;
1455 1455
 	    
1456
-		if($this->isModSubtotalLine($parameters,$object) ){
1456
+		if ($this->isModSubtotalLine($parameters, $object)) {
1457 1457
 			$this->resprints = ' ';
1458 1458
 			
1459
-			if((float)DOL_VERSION<=3.6) {
1459
+			if ((float) DOL_VERSION <= 3.6) {
1460 1460
 				return '';
1461 1461
 			}
1462
-			else if((float)DOL_VERSION>=3.8) {
1462
+			else if ((float) DOL_VERSION >= 3.8) {
1463 1463
 				return 1;
1464 1464
 			}
1465 1465
 		}
1466 1466
 		
1467
-		if(is_array($parameters)) $i = & $parameters['i'];
1468
-		else $i = (int)$parameters;
1467
+		if (is_array($parameters)) $i = & $parameters['i'];
1468
+		else $i = (int) $parameters;
1469 1469
 		
1470 1470
 		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)
1471 1471
 
@@ -1492,7 +1492,7 @@  discard block
 block discarded – undo
1492 1492
 		    
1493 1493
 		    // Check if a title exist for this line && if the title have subtotal
1494 1494
 		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1495
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1495
+		    if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1496 1496
 		    {
1497 1497
 		        
1498 1498
 		        $this->resprints = ' ';
@@ -1506,23 +1506,23 @@  discard block
 block discarded – undo
1506 1506
 		return 0;
1507 1507
 	}
1508 1508
 		
1509
-	function pdf_getlineprogress($parameters=array(), &$object, &$action) {
1509
+	function pdf_getlineprogress($parameters = array(), &$object, &$action) {
1510 1510
 		global $conf;
1511 1511
 		
1512
-		if($this->isModSubtotalLine($parameters,$object) ){
1512
+		if ($this->isModSubtotalLine($parameters, $object)) {
1513 1513
 			$this->resprints = ' ';
1514
-			if((float)DOL_VERSION<=3.6) {
1514
+			if ((float) DOL_VERSION <= 3.6) {
1515 1515
 				return '';
1516 1516
 			}
1517
-			else if((float)DOL_VERSION>=3.8) {
1517
+			else if ((float) DOL_VERSION >= 3.8) {
1518 1518
 				return 1;
1519 1519
 			}
1520 1520
 		}
1521 1521
 		
1522
-		if(is_array($parameters)) $i = & $parameters['i'];
1523
-		else $i = (int)$parameters;
1522
+		if (is_array($parameters)) $i = & $parameters['i'];
1523
+		else $i = (int) $parameters;
1524 1524
 			
1525
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1525
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1526 1526
 		{
1527 1527
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1528 1528
 			{
@@ -1537,12 +1537,12 @@  discard block
 block discarded – undo
1537 1537
 	function add_numerotation(&$object) {
1538 1538
 		global $conf;
1539 1539
 		
1540
-		if(!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1540
+		if (!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1541 1541
 		
1542 1542
 			$TLevelTitre = array();
1543 1543
 			$prevlevel = 0;
1544 1544
 		
1545
-			foreach($object->lines as $k=>&$line) 
1545
+			foreach ($object->lines as $k=>&$line) 
1546 1546
 			{
1547 1547
 				if ($line->id > 0 && $this->isModSubtotalLine($k, $object) && $line->qty <= 10)
1548 1548
 				{
@@ -1556,12 +1556,12 @@  discard block
 block discarded – undo
1556 1556
 	}
1557 1557
 
1558 1558
 	// TODO ne gère pas encore la numération des lignes "Totaux"
1559
-	private function formatNumerotation(&$TLineTitle, $line_reference='', $level=1, $prefix_num=0)
1559
+	private function formatNumerotation(&$TLineTitle, $line_reference = '', $level = 1, $prefix_num = 0)
1560 1560
 	{
1561 1561
 		$TTitle = array();
1562 1562
 		
1563
-		$i=1;
1564
-		$j=0;
1563
+		$i = 1;
1564
+		$j = 0;
1565 1565
 		foreach ($TLineTitle as $k => &$line)
1566 1566
 		{
1567 1567
 			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
@@ -1571,7 +1571,7 @@  discard block
 block discarded – undo
1571 1571
 			{
1572 1572
 				$TTitle[$j]['numerotation'] = ($prefix_num == 0) ? $i : $prefix_num.'.'.$i;
1573 1573
 				//var_dump('Prefix == '.$prefix_num.' // '.$line->desc.' ==> numerotation == '.$TTitle[$j]['numerotation'].'   ###    '.$line->qty .'=='. $level);
1574
-				if (empty($line->label) && (float)DOL_VERSION < 6)
1574
+				if (empty($line->label) && (float) DOL_VERSION < 6)
1575 1575
 				{
1576 1576
 					$line->label = !empty($line->desc) ? $line->desc : $line->description;
1577 1577
 					$line->desc = $line->description = '';
@@ -1597,26 +1597,26 @@  discard block
 block discarded – undo
1597 1597
 	
1598 1598
 	function setDocTVA(&$pdf, &$object) {
1599 1599
 		
1600
-		$hidedetails = (int)GETPOST('hidedetails');
1600
+		$hidedetails = (int) GETPOST('hidedetails');
1601 1601
 		
1602
-		if(empty($hidedetails)) return false;
1602
+		if (empty($hidedetails)) return false;
1603 1603
 		
1604 1604
 		// TODO can't add VAT to document without lines... :-/
1605 1605
 		
1606 1606
 		return true;
1607 1607
 	}
1608 1608
 	
1609
-	function beforePDFCreation($parameters=array(), &$object, &$action)
1609
+	function beforePDFCreation($parameters = array(), &$object, &$action)
1610 1610
 	{
1611 1611
 		/**
1612 1612
 		 * @var $pdf    TCPDF
1613 1613
 		 */
1614
-		global $pdf,$conf, $langs;
1614
+		global $pdf, $conf, $langs;
1615 1615
 
1616 1616
 		// var_dump($object->lines);
1617 1617
 		dol_include_once('/subtotal/class/subtotal.class.php');
1618 1618
 
1619
-		foreach($parameters as $key=>$value) {
1619
+		foreach ($parameters as $key=>$value) {
1620 1620
 			${$key} = $value;
1621 1621
 		}
1622 1622
 		
@@ -1624,43 +1624,43 @@  discard block
 block discarded – undo
1624 1624
 		
1625 1625
 		$this->add_numerotation($object);	
1626 1626
 		
1627
-        foreach($object->lines as $k => &$l) {
1628
-            if(TSubtotal::isSubtotal($l)) {
1627
+        foreach ($object->lines as $k => &$l) {
1628
+            if (TSubtotal::isSubtotal($l)) {
1629 1629
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1630
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1631
-                if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_reduc'])) {
1632
-                    $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1630
+                if (is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1631
+                if (!empty($parentTitle->id) && !empty($parentTitle->array_options['options_show_reduc'])) {
1632
+                    $l->remise_percent = 100; // Affichage de la réduction sur la ligne de sous-total
1633 1633
                 }
1634 1634
             }
1635 1635
 
1636 1636
 
1637 1637
             // Pas de hook sur les colonnes du PDF expédition, on unset les bonnes variables
1638
-            if(($object->element == 'shipping' || $object->element == 'delivery') && $this->isModSubtotalLine($k, $object))
1638
+            if (($object->element == 'shipping' || $object->element == 'delivery') && $this->isModSubtotalLine($k, $object))
1639 1639
 			{
1640 1640
 				$l->qty = $l->qty_asked;
1641 1641
 				unset($l->qty_asked, $l->qty_shipped, $l->volume, $l->weight);
1642 1642
 			}
1643 1643
         }
1644 1644
 
1645
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1646
-		$hidedetails = (int)GETPOST('hidedetails');
1645
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1646
+		$hidedetails = (int) GETPOST('hidedetails');
1647 1647
 
1648 1648
 		if ($hideInnerLines) { // si c une ligne de titre
1649
-	    	$fk_parent_line=0;
1650
-			$TLines =array();
1649
+	    	$fk_parent_line = 0;
1650
+			$TLines = array();
1651 1651
 		
1652
-			$original_count=count($object->lines);
1652
+			$original_count = count($object->lines);
1653 1653
 		    $TTvas = array(); // tableau de tva
1654 1654
 		    
1655
-			foreach($object->lines as $k=>&$line) 
1655
+			foreach ($object->lines as $k=>&$line) 
1656 1656
 			{
1657 1657
 			    
1658
-				if($line->product_type==9 && $line->rowid>0) 
1658
+				if ($line->product_type == 9 && $line->rowid > 0) 
1659 1659
 				{
1660 1660
 					$fk_parent_line = $line->rowid;
1661 1661
 					
1662 1662
 					// 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
1663
-					if(TSubtotal::isSubtotal($line)) 
1663
+					if (TSubtotal::isSubtotal($line)) 
1664 1664
 					{
1665 1665
 						/*$total = $this->getTotalLineFromObject($object, $line, '');
1666 1666
 						
@@ -1691,22 +1691,22 @@  discard block
 block discarded – undo
1691 1691
 			
1692 1692
 				if ($hideInnerLines)
1693 1693
 				{
1694
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1694
+				    if (!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1695 1695
 				    {
1696
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1696
+				        if ($line->tva_tx != '0.000' && $line->product_type != 9) {
1697 1697
 				            
1698 1698
     				        // on remplit le tableau de tva pour substituer les lignes cachées
1699 1699
     				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1700 1700
     				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1701 1701
     				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1702 1702
     				    }
1703
-    					if($line->product_type==9 && $line->rowid>0)
1703
+    					if ($line->product_type == 9 && $line->rowid > 0)
1704 1704
     					{
1705 1705
     					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1706 1706
     					    // génère des lignes d'affichage des montants HT soumis à tva
1707 1707
     					    $nbtva = count($TTvas);
1708
-    					    if(!empty($nbtva)){
1709
-    					        foreach ($TTvas as $tx =>$val){
1708
+    					    if (!empty($nbtva)) {
1709
+    					        foreach ($TTvas as $tx =>$val) {
1710 1710
     					            $l = clone $line;
1711 1711
     					            $l->product_type = 1;
1712 1712
     					            $l->special_code = '';
@@ -1727,7 +1727,7 @@  discard block
 block discarded – undo
1727 1727
     					}
1728 1728
 				    } else {
1729 1729
 				        
1730
-				        if($line->product_type==9 && $line->rowid>0)
1730
+				        if ($line->product_type == 9 && $line->rowid > 0)
1731 1731
 				        {
1732 1732
 				            // ajoute la ligne de sous-total
1733 1733
 				            $TLines[] = $line; 
@@ -1755,9 +1755,9 @@  discard block
 block discarded – undo
1755 1755
 			
1756 1756
 			// cas incongru où il y aurait des produits en dessous du dernier sous-total
1757 1757
 			$nbtva = count($TTvas);
1758
-			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1758
+			if (!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1759 1759
 			{
1760
-			    foreach ($TTvas as $tx =>$val){
1760
+			    foreach ($TTvas as $tx =>$val) {
1761 1761
 			        $l = clone $line;
1762 1762
 			        $l->product_type = 1;
1763 1763
 			        $l->special_code = '';
@@ -1774,11 +1774,11 @@  discard block
 block discarded – undo
1774 1774
 			}
1775 1775
 			
1776 1776
 			global $nblignes;
1777
-			$nblignes=count($TLines);
1777
+			$nblignes = count($TLines);
1778 1778
 
1779 1779
 			$object->lines = $TLines;
1780 1780
 			
1781
-			if($i>count($object->lines)) {
1781
+			if ($i > count($object->lines)) {
1782 1782
 				$this->resprints = '';
1783 1783
 				return 0;
1784 1784
 			}
@@ -1787,55 +1787,55 @@  discard block
 block discarded – undo
1787 1787
 		return 0;
1788 1788
 	}
1789 1789
 
1790
-	function pdf_writelinedesc($parameters=array(), &$object, &$action)
1790
+	function pdf_writelinedesc($parameters = array(), &$object, &$action)
1791 1791
 	{
1792 1792
 		/**
1793 1793
 		 * @var $pdf    TCPDF
1794 1794
 		 */
1795
-		global $pdf,$conf;
1795
+		global $pdf, $conf;
1796 1796
 
1797
-		foreach($parameters as $key=>$value) {
1797
+		foreach ($parameters as $key=>$value) {
1798 1798
 			${$key} = $value;
1799 1799
 		}
1800 1800
 		
1801
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1802
-		$hidedetails = (int)GETPOST('hidedetails');
1801
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1802
+		$hidedetails = (int) GETPOST('hidedetails');
1803 1803
 		
1804
-		if($this->isModSubtotalLine($parameters,$object) ){			
1804
+		if ($this->isModSubtotalLine($parameters, $object)) {			
1805 1805
 		
1806 1806
 				global $hideprices;
1807 1807
 				
1808
-				if(!empty($hideprices)) {
1809
-					foreach($object->lines as &$line) {
1810
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1808
+				if (!empty($hideprices)) {
1809
+					foreach ($object->lines as &$line) {
1810
+						if ($line->fk_product_type != 9) $line->fk_parent_line = -1;	
1811 1811
 					}
1812 1812
 				}
1813 1813
 			
1814 1814
 				$line = &$object->lines[$i];
1815 1815
 
1816
-				if($object->element == 'delivery' && ! empty($object->commande->expeditions[$line->fk_origin_line])) unset($object->commande->expeditions[$line->fk_origin_line]);
1816
+				if ($object->element == 'delivery' && !empty($object->commande->expeditions[$line->fk_origin_line])) unset($object->commande->expeditions[$line->fk_origin_line]);
1817 1817
 
1818
-				if($line->info_bits>0) { // PAGE BREAK
1818
+				if ($line->info_bits > 0) { // PAGE BREAK
1819 1819
 					$pdf->addPage();
1820 1820
 					$posy = $pdf->GetY();
1821 1821
 				}
1822 1822
 				
1823 1823
 				$label = $line->label;
1824
-				$description= !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1824
+				$description = !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1825 1825
 				
1826
-				if(empty($label)) {
1826
+				if (empty($label)) {
1827 1827
 					$label = $description;
1828
-					$description='';
1828
+					$description = '';
1829 1829
 				}
1830 1830
 
1831
-				if($line->qty>90) {
1831
+				if ($line->qty > 90) {
1832 1832
 					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1833 1833
 					
1834 1834
 					$pageBefore = $pdf->getPage();
1835
-					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1835
+					$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1836 1836
 					$pageAfter = $pdf->getPage();	
1837 1837
 
1838
-					if($pageAfter>$pageBefore) {
1838
+					if ($pageAfter > $pageBefore) {
1839 1839
 						//print "ST $pageAfter>$pageBefore<br>";
1840 1840
 						$pdf->rollbackTransaction(true);
1841 1841
 						$pdf->addPage('', '', true);
@@ -1846,9 +1846,9 @@  discard block
 block discarded – undo
1846 1846
 					}
1847 1847
 
1848 1848
 					// On delivery PDF, we don't want quantities to appear and there are no hooks => setting text color to background color;
1849
-					if($object->element == 'delivery')
1849
+					if ($object->element == 'delivery')
1850 1850
 					{
1851
-						switch($line->qty)
1851
+						switch ($line->qty)
1852 1852
 						{
1853 1853
 							case 99:
1854 1854
 								$grey = 220;
@@ -1871,7 +1871,7 @@  discard block
 block discarded – undo
1871 1871
 				else if ($line->qty < 10) {
1872 1872
 					$pageBefore = $pdf->getPage();
1873 1873
 
1874
-					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
1874
+					$this->pdf_add_title($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h); 
1875 1875
 					$pageAfter = $pdf->getPage();	
1876 1876
 
1877 1877
 					
@@ -1887,9 +1887,9 @@  discard block
 block discarded – undo
1887 1887
 					}
1888 1888
 				*/
1889 1889
 
1890
-					if($object->element == 'delivery')
1890
+					if ($object->element == 'delivery')
1891 1891
 					{
1892
-						$pdf->SetTextColor(255,255,255);
1892
+						$pdf->SetTextColor(255, 255, 255);
1893 1893
 					}
1894 1894
 
1895 1895
 					$posy = $pdf->GetY();
@@ -1952,9 +1952,9 @@  discard block
 block discarded – undo
1952 1952
 	 * @param $hookmanager  HookManager
1953 1953
 	 * @return int
1954 1954
 	 */
1955
-	function printObjectLine ($parameters, &$object, &$action, $hookmanager){
1955
+	function printObjectLine($parameters, &$object, &$action, $hookmanager) {
1956 1956
 		
1957
-		global $conf,$langs,$user,$db,$bc;
1957
+		global $conf, $langs, $user, $db, $bc;
1958 1958
 		
1959 1959
 		$num = &$parameters['num'];
1960 1960
 		$line = &$parameters['line'];
@@ -1962,33 +1962,33 @@  discard block
 block discarded – undo
1962 1962
 		
1963 1963
 		$var = &$parameters['var'];
1964 1964
 
1965
-		$contexts = explode(':',$parameters['context']);
1966
-		if($parameters['currentcontext'] === 'paiementcard') return 0;
1965
+		$contexts = explode(':', $parameters['context']);
1966
+		if ($parameters['currentcontext'] === 'paiementcard') return 0;
1967 1967
 		$originline = null;
1968 1968
 
1969 1969
 		$createRight = $user->rights->{$object->element}->creer;
1970
-		if($object->element == 'facturerec' )
1970
+		if ($object->element == 'facturerec')
1971 1971
 		{
1972 1972
 			$object->statut = 0; // hack for facture rec
1973 1973
 			$createRight = $user->rights->facture->creer;
1974 1974
 		}
1975
-		elseif($object->element == 'order_supplier' )
1975
+		elseif ($object->element == 'order_supplier')
1976 1976
 		{
1977 1977
 		    $createRight = $user->rights->fournisseur->commande->creer;
1978 1978
 		}
1979
-		elseif($object->element == 'invoice_supplier' )
1979
+		elseif ($object->element == 'invoice_supplier')
1980 1980
 		{
1981 1981
 		    $createRight = $user->rights->fournisseur->facture->creer;
1982 1982
 		}
1983
-		elseif($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
1983
+		elseif ($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
1984 1984
 		{
1985 1985
 			// H4cK 4n0nYm0u$-style : $line n'est pas un objet instancié mais provient d'un fetch_object d'une requête SQL
1986 1986
 			$line->id = $line->rowid;
1987 1987
 			$line->product_type = $line->type;
1988 1988
 		}
1989
-		elseif($object->element == 'shipping' || $object->element == 'delivery')
1989
+		elseif ($object->element == 'shipping' || $object->element == 'delivery')
1990 1990
 		{
1991
-			if(empty($line->origin_line_id) && ! empty($line->fk_origin_line))
1991
+			if (empty($line->origin_line_id) && !empty($line->fk_origin_line))
1992 1992
 			{
1993 1993
 				$line->origin_line_id = $line->fk_origin_line;
1994 1994
 			}
@@ -1996,9 +1996,9 @@  discard block
 block discarded – undo
1996 1996
 			$originline = new OrderLine($db);
1997 1997
 			$originline->fetch($line->fk_origin_line);
1998 1998
 
1999
-			foreach(get_object_vars($line) as $property => $value)
1999
+			foreach (get_object_vars($line) as $property => $value)
2000 2000
 			{
2001
-				if(empty($originline->{ $property }))
2001
+				if (empty($originline->{ $property }))
2002 2002
 				{
2003 2003
 					$originline->{ $property } = $value;
2004 2004
 				}
@@ -2006,13 +2006,13 @@  discard block
 block discarded – undo
2006 2006
 
2007 2007
 			$line = $originline;
2008 2008
 		}
2009
- 		if($object->element=='facture')$idvar = 'facid';
2010
-        else $idvar='id';
2011
-		if($line->special_code!=$this->module_number || $line->product_type!=9) {
2012
-			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE) && $object->element !== 'invoice_supplier')
2009
+ 		if ($object->element == 'facture')$idvar = 'facid';
2010
+        else $idvar = 'id';
2011
+		if ($line->special_code != $this->module_number || $line->product_type != 9) {
2012
+			if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE) && $object->element !== 'invoice_supplier')
2013 2013
             {
2014
-                if(!(TSubtotal::isModSubtotalLine($line)) && ( $line->fk_prev_id === null ) && !($action == "editline" && GETPOST('lineid') == $line->id)) {
2015
-                    echo '<a name="duplicate-'.$line->id.'" href="' . $_SERVER['PHP_SELF'] . '?' . $idvar . '=' . $object->id . '&action=duplicate&lineid=' . $line->id . '"><i class="fa fa-clone" aria-hidden="true"></i></a>';
2014
+                if (!(TSubtotal::isModSubtotalLine($line)) && ($line->fk_prev_id === null) && !($action == "editline" && GETPOST('lineid') == $line->id)) {
2015
+                    echo '<a name="duplicate-'.$line->id.'" href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'"><i class="fa fa-clone" aria-hidden="true"></i></a>';
2016 2016
 
2017 2017
                     ?>
2018 2018
                         <script type="text/javascript">
@@ -2026,11 +2026,11 @@  discard block
 block discarded – undo
2026 2026
             }
2027 2027
 			return 0;
2028 2028
 		}
2029
-		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)) 
2029
+		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)) 
2030 2030
         {
2031 2031
 
2032 2032
 
2033
-			if((float)DOL_VERSION <= 3.4)
2033
+			if ((float) DOL_VERSION <= 3.4)
2034 2034
 			{
2035 2035
 				?>
2036 2036
 				<script type="text/javascript">
@@ -2054,22 +2054,22 @@  discard block
 block discarded – undo
2054 2054
 				<?php
2055 2055
 			}
2056 2056
 			
2057
-			if(empty($line->description)) $line->description = $line->desc;
2057
+			if (empty($line->description)) $line->description = $line->desc;
2058 2058
 			
2059 2059
 			$colspan = 5;
2060
-			if($object->element == 'facturerec' ) $colspan = 3;
2061
-			if($object->element == 'order_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
2062
-			if($object->element == 'invoice_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7;
2063
-			if($object->element == 'supplier_proposal') (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2064
-			if(!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
2060
+			if ($object->element == 'facturerec') $colspan = 3;
2061
+			if ($object->element == 'order_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
2062
+			if ($object->element == 'invoice_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 4 : $colspan = 7;
2063
+			if ($object->element == 'supplier_proposal') (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2064
+			if (!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
2065 2065
 				$colspan++; // Colonne PU Devise
2066 2066
 			}
2067
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
2068
-			if(!empty($conf->margin->enabled)) $colspan++;
2069
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
2070
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
2071
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
2072
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
2067
+			if ($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
2068
+			if (!empty($conf->margin->enabled)) $colspan++;
2069
+			if (!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
2070
+			if (!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
2071
+			if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
2072
+			if (!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
2073 2073
 					
2074 2074
 			/* Titre */
2075 2075
 			//var_dump($line);
@@ -2079,39 +2079,39 @@  discard block
 block discarded – undo
2079 2079
             
2080 2080
 			
2081 2081
 			?>
2082
-			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2082
+			<tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2083 2083
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2084 2084
 					{
2085
-						if($line->qty==99) print 'background:#adadcf';
2086
-						else if($line->qty==98) print 'background:#ddddff;';
2087
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2088
-						else if($line->qty==1) print 'background:#adadcf;';
2089
-						else if($line->qty==2) print 'background:#ddddff;';
2090
-						else if($line->qty==50) print '';
2085
+						if ($line->qty == 99) print 'background:#adadcf';
2086
+						else if ($line->qty == 98) print 'background:#ddddff;';
2087
+						else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;';
2088
+						else if ($line->qty == 1) print 'background:#adadcf;';
2089
+						else if ($line->qty == 2) print 'background:#ddddff;';
2090
+						else if ($line->qty == 50) print '';
2091 2091
 						else print 'background:#eeeeff;';
2092 2092
 
2093 2093
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2094 2094
 					}
2095 2095
 					else 
2096 2096
 					{
2097
-						if($line->qty==99) print 'background:#ddffdd';
2098
-						else if($line->qty==98) print 'background:#ddddff;';
2099
-						else if($line->qty==2) print 'background:#eeeeff; ';
2100
-						else if($line->qty==50) print '';
2101
-						else print 'background:#eeffee;' ;
2097
+						if ($line->qty == 99) print 'background:#ddffdd';
2098
+						else if ($line->qty == 98) print 'background:#ddddff;';
2099
+						else if ($line->qty == 2) print 'background:#eeeeff; ';
2100
+						else if ($line->qty == 50) print '';
2101
+						else print 'background:#eeffee;';
2102 2102
 					}
2103 2103
 
2104 2104
 			?>;">
2105 2105
 
2106
-				<?php if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
2106
+				<?php if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
2107 2107
 				<td class="linecolnum"><?php echo $i + 1; ?></td>
2108 2108
 				<?php } ?>
2109 2109
 
2110
-				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
2111
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
2110
+				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php
2111
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
2112 2112
 
2113
-						$params=array('line'=>$line);
2114
-						$reshook=$hookmanager->executeHooks('formEditProductOptions',$params,$object,$action);
2113
+						$params = array('line'=>$line);
2114
+						$reshook = $hookmanager->executeHooks('formEditProductOptions', $params, $object, $action);
2115 2115
 						
2116 2116
 						echo '<div id="line_'.$line->id.'"></div>'; // Imitation Dolibarr
2117 2117
 						echo '<input type="hidden" value="'.$line->id.'" name="lineid">';
@@ -2119,7 +2119,7 @@  discard block
 block discarded – undo
2119 2119
 						echo '<input id="product_id" type="hidden" value="'.$line->fk_product.'" name="type">';
2120 2120
 						echo '<input id="special_code" type="hidden" value="'.$line->special_code.'" name="type">';
2121 2121
 
2122
-						$isFreeText=false;
2122
+						$isFreeText = false;
2123 2123
 						if (TSubtotal::isTitle($line))
2124 2124
 						{
2125 2125
 							$qty_displayed = $line->qty;
@@ -2141,13 +2141,13 @@  discard block
 block discarded – undo
2141 2141
 						    $line->description = '';
2142 2142
 						}
2143 2143
 						$newlabel = $line->label;
2144
-						if($line->label=='' && !$isFreeText) {
2145
-							if(TSubtotal::isSubtotal($line)) {
2144
+						if ($line->label == '' && !$isFreeText) {
2145
+							if (TSubtotal::isSubtotal($line)) {
2146 2146
 								$newlabel = $line->description.' '.$this->getTitle($object, $line);
2147
-								$line->description='';
2148
-							} elseif( (float)DOL_VERSION < 6 ) {
2149
-								$newlabel= $line->description;
2150
-								$line->description='';
2147
+								$line->description = '';
2148
+							} elseif ((float) DOL_VERSION < 6) {
2149
+								$newlabel = $line->description;
2150
+								$line->description = '';
2151 2151
 							}
2152 2152
 						}
2153 2153
 
@@ -2156,10 +2156,10 @@  discard block
 block discarded – undo
2156 2156
 						
2157 2157
 						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2158 2158
 						
2159
-						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
2159
+						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)))
2160 2160
 						{
2161 2161
 							$select = '<select name="subtotal_level">';
2162
-							for ($j=1; $j<10; $j++)
2162
+							for ($j = 1; $j < 10; $j++)
2163 2163
 							{
2164 2164
 								if (!empty($readonlyForSituation)) {
2165 2165
 									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
@@ -2173,7 +2173,7 @@  discard block
 block discarded – undo
2173 2173
 
2174 2174
 						echo '<div class="subtotal_underline" style="margin-left:24px; line-height: 25px;">';
2175 2175
                         echo '<div>';
2176
-                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2176
+                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '').' />&nbsp;';
2177 2177
                         echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2178 2178
                         echo '</div>';
2179 2179
 
@@ -2194,12 +2194,12 @@  discard block
 block discarded – undo
2194 2194
                                 echo '</div>';
2195 2195
                             }
2196 2196
                             echo '<div>';
2197
-                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showTotalHT" id="subtotal-showTotalHT" value="9" '.(($line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2197
+                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showTotalHT" id="subtotal-showTotalHT" value="9" '.(($line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '').' />&nbsp;';
2198 2198
                             echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2199 2199
                             echo '</div>';
2200 2200
 
2201 2201
                             echo '<div>';
2202
-                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2202
+                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '').' />&nbsp;';
2203 2203
                             echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2204 2204
                             echo '</div>';
2205 2205
                         }
@@ -2209,7 +2209,7 @@  discard block
 block discarded – undo
2209 2209
 						if (TSubtotal::isTitle($line))
2210 2210
 						{
2211 2211
 							// WYSIWYG editor
2212
-							require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
2212
+							require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
2213 2213
 							$nbrows = ROWS_2;
2214 2214
 							$cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
2215 2215
 							if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
@@ -2251,25 +2251,25 @@  discard block
 block discarded – undo
2251 2251
 
2252 2252
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2253 2253
 						 {
2254
-							if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
2254
+							if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
2255 2255
 							{
2256
-								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2256
+								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
2257 2257
 								
2258 2258
 								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2259
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2259
+								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
2260 2260
 							}
2261 2261
 						 }
2262 2262
 						 else 
2263 2263
 						 {
2264
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2265
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2264
+							if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal');
2265
+							else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2266 2266
 						 }
2267 2267
 						 
2268 2268
 						 
2269 2269
 						 // Get display styles and apply them
2270 2270
 						 $titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
2271
-						 $titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2272
-						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2271
+						 $titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2272
+						 $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2273 2273
 						 
2274 2274
 						 if (empty($line->label)) {
2275 2275
 							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
@@ -2277,16 +2277,16 @@  discard block
 block discarded – undo
2277 2277
 						 } 
2278 2278
 						 else {
2279 2279
 
2280
-							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2280
+							if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2281 2281
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2282 2282
 							}
2283
-							else{
2283
+							else {
2284 2284
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
2285 2285
 							}
2286 2286
 
2287 2287
 						 } 
2288
-						if($line->qty>90) print ' : ';
2289
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2288
+						if ($line->qty > 90) print ' : ';
2289
+						if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2290 2290
 
2291 2291
 						 
2292 2292
 
@@ -2295,7 +2295,7 @@  discard block
 block discarded – undo
2295 2295
 			?></td>
2296 2296
 					 
2297 2297
 			<?php
2298
-				if($line->qty>90) {
2298
+				if ($line->qty > 90) {
2299 2299
 					/* Total */
2300 2300
 					$total_line = $this->getTotalLineFromObject($object, $line, '');
2301 2301
 					echo '<td class="linecolht nowrap" align="right" style="font-weight:bold;" rel="subtotal_total">'.price($total_line).'</td>';
@@ -2314,7 +2314,7 @@  discard block
 block discarded – undo
2314 2314
 				<?php
2315 2315
 				if ($action != 'selectlines') {
2316 2316
 				
2317
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
2317
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
2318 2318
 						?>
2319 2319
 						<input id="savelinebutton" class="button" type="submit" name="save" value="<?php echo $langs->trans('Save') ?>" />
2320 2320
 						<br />
@@ -2330,13 +2330,13 @@  discard block
 block discarded – undo
2330 2330
 						<?php
2331 2331
 						
2332 2332
 					}
2333
-					else{
2334
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2333
+					else {
2334
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2335 2335
 						{
2336
-							if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2336
+							if (TSubtotal::isTitle($line) && ($line->fk_prev_id === null)) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'.img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2337 2337
 						}
2338 2338
 
2339
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
2339
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
2340 2340
 						{
2341 2341
 							echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=editline&lineid='.$line->id.'">'.img_edit().'</a>';
2342 2342
 						}								
@@ -2351,7 +2351,7 @@  discard block
 block discarded – undo
2351 2351
 				<?php
2352 2352
 
2353 2353
 				if ($action != 'editline' && $action != 'selectlines') {
2354
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2354
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2355 2355
 						{
2356 2356
 
2357 2357
 							if ($line->fk_prev_id === null)
@@ -2359,12 +2359,12 @@  discard block
 block discarded – undo
2359 2359
 								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteline&lineid='.$line->id.'">'.img_delete().'</a>';
2360 2360
 							}
2361 2361
 
2362
-							if(TSubtotal::isTitle($line) && ($line->fk_prev_id === null) )
2362
+							if (TSubtotal::isTitle($line) && ($line->fk_prev_id === null))
2363 2363
 							{
2364 2364
 								if ((float) DOL_VERSION >= 8.0) {
2365 2365
 									$img_delete = img_delete($langs->trans('deleteWithAllLines'), ' class="pictodelete pictodeleteallline"');
2366 2366
 								} elseif ((float) DOL_VERSION >= 3.8) {
2367
-									$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal',' class="pictodelete" ');
2367
+									$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal', ' class="pictodelete" ');
2368 2368
 								} else {
2369 2369
 									$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all@subtotal');
2370 2370
 								}
@@ -2374,7 +2374,7 @@  discard block
 block discarded – undo
2374 2374
 								/* Depuis la 8.0, les icônes "standard" utilisent FontAwesome et sont préconfigurées selon la clé de l'image
2375 2375
 								 * Impossible d'en customiser par exemple la couleur, même en utilisant img_picto() directement
2376 2376
 								 */
2377
-								if((float) DOL_VERSION >= 8.0) {
2377
+								if ((float) DOL_VERSION >= 8.0) {
2378 2378
 								?>
2379 2379
 								<script>
2380 2380
 									$(document).ready(function () {
@@ -2390,7 +2390,7 @@  discard block
 block discarded – undo
2390 2390
 			</td>
2391 2391
 			
2392 2392
 			<?php 
2393
-			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
2393
+			if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
2394 2394
 			{
2395 2395
 				echo '<td class="subtotal_nc">';
2396 2396
 				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"' : '').' />';
@@ -2401,12 +2401,12 @@  discard block
 block discarded – undo
2401 2401
 			<td align="center" class="linecolmove tdlineupdown">
2402 2402
 			</td>
2403 2403
 			<?php } else { ?>
2404
-			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0  && $createRight ))?' class="tdlineupdown"':''); ?>></td>
2404
+			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0 && $createRight)) ? ' class="tdlineupdown"' : ''); ?>></td>
2405 2405
 			<?php } ?>
2406 2406
 
2407 2407
 
2408
-			<?php  if($action == 'selectlines'){ // dolibarr 8 ?>
2409
-			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
2408
+			<?php  if ($action == 'selectlines') { // dolibarr 8 ?>
2409
+			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i + 1; ?>]" value="<?php echo $line->id; ?>" ></td>
2410 2410
 			<?php } ?>
2411 2411
 
2412 2412
 			</tr>
@@ -2414,29 +2414,29 @@  discard block
 block discarded – undo
2414 2414
 			
2415 2415
 			
2416 2416
 			// Affichage des extrafields à la Dolibarr (car sinon non affiché sur les titres)
2417
-			if(TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2417
+			if (TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2418 2418
 				
2419
-				require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
2419
+				require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
2420 2420
 				
2421 2421
 				// Extrafields
2422 2422
 				$extrafieldsline = new ExtraFields($db);
2423 2423
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2424 2424
 				
2425
-				$colspan+=3; $mode = 'view';
2426
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2425
+				$colspan += 3; $mode = 'view';
2426
+				if ($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2427 2427
 				
2428 2428
 				$ex_element = $line->element;
2429 2429
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
2430
-				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ','colspan'=>$colspan));
2430
+				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ', 'colspan'=>$colspan));
2431 2431
 				$isExtraSelected = false;
2432
-				foreach($line->array_options as $option) {
2433
-					if(!empty($option) && $option != "-1") {
2432
+				foreach ($line->array_options as $option) {
2433
+					if (!empty($option) && $option != "-1") {
2434 2434
 						$isExtraSelected = true;
2435 2435
 						break;
2436 2436
 					}
2437 2437
 				}
2438 2438
 				
2439
-				if($mode === 'edit') {
2439
+				if ($mode === 'edit') {
2440 2440
 					?>
2441 2441
 					<script>
2442 2442
 						$(document).ready(function(){
@@ -2444,7 +2444,7 @@  discard block
 block discarded – undo
2444 2444
 							var all_tr_extrafields = $("tr.tr_extrafield_title");
2445 2445
 							<?php 
2446 2446
 							// Si un extrafield est rempli alors on affiche directement les extrafields
2447
-							if(!$isExtraSelected) {
2447
+							if (!$isExtraSelected) {
2448 2448
 								echo 'all_tr_extrafields.hide();';
2449 2449
 								echo 'var trad = "'.$langs->trans('showExtrafields').'";';
2450 2450
 								echo 'var extra = 0;';
@@ -2483,61 +2483,61 @@  discard block
 block discarded – undo
2483 2483
 			return 1;	
2484 2484
 			
2485 2485
 		}
2486
-		elseif(($object->element == 'commande' && in_array('ordershipmentcard', $contexts)) || (in_array('expeditioncard', $contexts) && $action == 'create'))
2486
+		elseif (($object->element == 'commande' && in_array('ordershipmentcard', $contexts)) || (in_array('expeditioncard', $contexts) && $action == 'create'))
2487 2487
 		{
2488 2488
 			$colspan = 4;
2489 2489
 
2490 2490
 			// HTML 5 data for js
2491 2491
 			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2492 2492
 ?>
2493
-			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2493
+			<tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2494 2494
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2495 2495
 					{
2496
-						if($line->qty==99) print 'background:#adadcf';
2497
-						else if($line->qty==98) print 'background:#ddddff;';
2498
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2499
-						else if($line->qty==1) print 'background:#adadcf;';
2500
-						else if($line->qty==2) print 'background:#ddddff;';
2501
-						else if($line->qty==50) print '';
2496
+						if ($line->qty == 99) print 'background:#adadcf';
2497
+						else if ($line->qty == 98) print 'background:#ddddff;';
2498
+						else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;';
2499
+						else if ($line->qty == 1) print 'background:#adadcf;';
2500
+						else if ($line->qty == 2) print 'background:#ddddff;';
2501
+						else if ($line->qty == 50) print '';
2502 2502
 						else print 'background:#eeeeff;';
2503 2503
 
2504 2504
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2505 2505
 					}
2506 2506
 					else
2507 2507
 					{
2508
-						if($line->qty==99) print 'background:#ddffdd';
2509
-						else if($line->qty==98) print 'background:#ddddff;';
2510
-						else if($line->qty==2) print 'background:#eeeeff; ';
2511
-						else if($line->qty==50) print '';
2512
-						else print 'background:#eeffee;' ;
2508
+						if ($line->qty == 99) print 'background:#ddffdd';
2509
+						else if ($line->qty == 98) print 'background:#ddddff;';
2510
+						else if ($line->qty == 2) print 'background:#eeeeff; ';
2511
+						else if ($line->qty == 50) print '';
2512
+						else print 'background:#eeffee;';
2513 2513
 					}
2514 2514
 
2515 2515
 			?>;">
2516 2516
 
2517
-				<td style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
2517
+				<td style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php
2518 2518
 
2519 2519
 
2520 2520
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2521 2521
 						 {
2522
-							if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2522
+							if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2523 2523
 							{
2524
-								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2524
+								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
2525 2525
 
2526 2526
 								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2527
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2527
+								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
2528 2528
 							}
2529 2529
 						 }
2530 2530
 						 else
2531 2531
 						 {
2532
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2533
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2532
+							if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal');
2533
+							else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2534 2534
 						 }
2535 2535
 
2536 2536
 
2537 2537
 						 // Get display styles and apply them
2538 2538
 						 $titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
2539
-						 $titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2540
-						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2539
+						 $titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2540
+						 $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2541 2541
 
2542 2542
 						 if (empty($line->label)) {
2543 2543
 							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
@@ -2545,22 +2545,22 @@  discard block
 block discarded – undo
2545 2545
 						 }
2546 2546
 						 else {
2547 2547
 
2548
-							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2548
+							if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2549 2549
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2550 2550
 							}
2551
-							else{
2551
+							else {
2552 2552
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2553 2553
 							}
2554 2554
 
2555 2555
 						 }
2556 2556
 						//if($line->qty>90) print ' : ';
2557
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2557
+						if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2558 2558
 
2559 2559
 			?>
2560 2560
 				</td>
2561 2561
 				 <td colspan="<?php echo $colspan; ?>">
2562 2562
 <?php
2563
-						if(in_array('expeditioncard', $contexts) && $action == 'create')
2563
+						if (in_array('expeditioncard', $contexts) && $action == 'create')
2564 2564
 						{
2565 2565
 							$fk_entrepot = GETPOST('entrepot_id', 'int');
2566 2566
 ?>
@@ -2587,100 +2587,100 @@  discard block
 block discarded – undo
2587 2587
 			$shipment_static = new Expedition($db);
2588 2588
 			$warehousestatic = new Entrepot($db);
2589 2589
 			$extrafieldsline = new ExtraFields($db);
2590
-			$extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2590
+			$extralabelslines = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2591 2591
 
2592 2592
 			$colspan = 4;
2593
-			if($object->origin && $object->origin_id > 0) $colspan++;
2594
-			if(! empty($conf->stock->enabled)) $colspan++;
2595
-			if(! empty($conf->productbatch->enabled)) $colspan++;
2596
-			if($object->statut == 0) $colspan++;
2597
-			if($object->statut == 0 && empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) $colspan++;
2593
+			if ($object->origin && $object->origin_id > 0) $colspan++;
2594
+			if (!empty($conf->stock->enabled)) $colspan++;
2595
+			if (!empty($conf->productbatch->enabled)) $colspan++;
2596
+			if ($object->statut == 0) $colspan++;
2597
+			if ($object->statut == 0 && empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) $colspan++;
2598 2598
 
2599
-			if($object->element == 'delivery') $colspan = 2;
2599
+			if ($object->element == 'delivery') $colspan = 2;
2600 2600
 
2601 2601
 			print '<!-- origin line id = '.$line->origin_line_id.' -->'; // id of order line
2602 2602
 
2603 2603
 			// HTML 5 data for js
2604 2604
 			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2605 2605
 			?>
2606
-			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2606
+			<tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2607 2607
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2608 2608
 					{
2609
-						if($line->qty==99) print 'background:#adadcf';
2610
-						else if($line->qty==98) print 'background:#ddddff;';
2611
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2612
-						else if($line->qty==1) print 'background:#adadcf;';
2613
-						else if($line->qty==2) print 'background:#ddddff;';
2614
-						else if($line->qty==50) print '';
2609
+						if ($line->qty == 99) print 'background:#adadcf';
2610
+						else if ($line->qty == 98) print 'background:#ddddff;';
2611
+						else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;';
2612
+						else if ($line->qty == 1) print 'background:#adadcf;';
2613
+						else if ($line->qty == 2) print 'background:#ddddff;';
2614
+						else if ($line->qty == 50) print '';
2615 2615
 						else print 'background:#eeeeff;';
2616 2616
 
2617 2617
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2618 2618
 					}
2619 2619
 					else 
2620 2620
 					{
2621
-						if($line->qty==99) print 'background:#ddffdd';
2622
-						else if($line->qty==98) print 'background:#ddddff;';
2623
-						else if($line->qty==2) print 'background:#eeeeff; ';
2624
-						else if($line->qty==50) print '';
2625
-						else print 'background:#eeffee;' ;
2621
+						if ($line->qty == 99) print 'background:#ddffdd';
2622
+						else if ($line->qty == 98) print 'background:#ddddff;';
2623
+						else if ($line->qty == 2) print 'background:#eeeeff; ';
2624
+						else if ($line->qty == 50) print '';
2625
+						else print 'background:#eeffee;';
2626 2626
 					}
2627 2627
 
2628 2628
 			?>;">
2629 2629
 
2630 2630
 			<?php
2631 2631
 			// #
2632
-			if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
2632
+			if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER))
2633 2633
 			{
2634
-				print '<td align="center">'.($i+1).'</td>';
2634
+				print '<td align="center">'.($i + 1).'</td>';
2635 2635
 			}
2636 2636
 			?>
2637 2637
 
2638
-			<td style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
2638
+			<td style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php
2639 2639
 
2640 2640
 
2641 2641
 			if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2642 2642
 			{
2643
-				if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2643
+				if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2644 2644
 				{
2645
-					echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2645
+					echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
2646 2646
 
2647 2647
 					if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2648
-					else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2648
+					else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
2649 2649
 				}
2650 2650
 			}
2651 2651
 			else
2652 2652
 			{
2653
-				if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2654
-				else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2653
+				if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal');
2654
+				else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2655 2655
 			}
2656 2656
 
2657 2657
 
2658 2658
 			// Get display styles and apply them
2659 2659
 			$titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
2660
-			$titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2661
-			$titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2660
+			$titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2661
+			$titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2662 2662
 
2663 2663
 			if (empty($line->label)) {
2664 2664
 				if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2665 2665
 				else print  $line->description;
2666 2666
 			}
2667 2667
 			else {
2668
-				if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2668
+				if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2669 2669
 					print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2670 2670
 				}
2671
-				else{
2671
+				else {
2672 2672
 					print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2673 2673
 				}
2674 2674
 			}
2675 2675
 			//if($line->qty>90) print ' : ';
2676
-			if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2676
+			if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2677 2677
 
2678 2678
 			?>
2679 2679
 				</td>
2680 2680
 				<td colspan="<?php echo $colspan; ?>">&nbsp;</td>
2681 2681
 			<?php
2682 2682
 
2683
-			if ($object->element == 'shipping' && $object->statut == 0 && ! empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2683
+			if ($object->element == 'shipping' && $object->statut == 0 && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2684 2684
 			{
2685 2685
 				print '<td class="linecoldelete nowrap" width="10">';
2686 2686
 
@@ -2689,12 +2689,12 @@  discard block
 block discarded – undo
2689 2689
 					echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=deleteline&amp;lineid='.$line->id.'">'.img_delete().'</a>';
2690 2690
 				}
2691 2691
 
2692
-				if(TSubtotal::isTitle($line) && ($line->fk_prev_id === null) )
2692
+				if (TSubtotal::isTitle($line) && ($line->fk_prev_id === null))
2693 2693
 				{
2694 2694
 					if ((float) DOL_VERSION >= 8.0) {
2695 2695
 						$img_delete = img_delete($langs->trans('deleteWithAllLines'), ' class="pictodelete pictodeleteallline"');
2696 2696
 					} elseif ((float) DOL_VERSION >= 3.8) {
2697
-						$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal',' class="pictodelete" ');
2697
+						$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal', ' class="pictodelete" ');
2698 2698
 					} else {
2699 2699
 						$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all@subtotal');
2700 2700
 					}
@@ -2704,7 +2704,7 @@  discard block
 block discarded – undo
2704 2704
 					/* Depuis la 8.0, les icônes "standard" utilisent FontAwesome et sont préconfigurées selon la clé de l'image
2705 2705
 					 * Impossible d'en customiser par exemple la couleur, même en utilisant img_picto() directement
2706 2706
 					 */
2707
-					if((float) DOL_VERSION >= 8.0) {
2707
+					if ((float) DOL_VERSION >= 8.0) {
2708 2708
 						?>
2709 2709
 							<script>
2710 2710
 								$(document).ready(function () {
@@ -2722,11 +2722,11 @@  discard block
 block discarded – undo
2722 2722
 			print "</tr>";
2723 2723
 
2724 2724
 			// Display lines extrafields
2725
-			if ($object->element == 'shipping' && ! empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE) && is_array($extralabelslines) && count($extralabelslines)>0) {
2725
+			if ($object->element == 'shipping' && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE) && is_array($extralabelslines) && count($extralabelslines) > 0) {
2726 2726
 				$line = new ExpeditionLigne($db);
2727 2727
 				$line->fetch_optionals($line->id);
2728 2728
 				print '<tr class="oddeven">';
2729
-				print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan),$i);
2729
+				print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan), $i);
2730 2730
 			}
2731 2731
 
2732 2732
 			return 1;
@@ -2738,20 +2738,20 @@  discard block
 block discarded – undo
2738 2738
 
2739 2739
 	
2740 2740
 	function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) {
2741
-		global $conf,$langs;
2741
+		global $conf, $langs;
2742 2742
 		 
2743 2743
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2744 2744
 		{
2745 2745
 		    
2746
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2746
+		    if ($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2747 2747
 		    {
2748 2748
 		        foreach ($object->lines as $line)
2749 2749
 		        {
2750 2750
 		            // fetch optionals attributes and labels
2751 2751
 		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2752
-		            $extrafields=new ExtraFields($this->db);
2753
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2754
-		            $line->fetch_optionals($line->id,$extralabels);
2752
+		            $extrafields = new ExtraFields($this->db);
2753
+		            $extralabels = $extrafields->fetch_name_optionals_label($object->table_element_line, true);
2754
+		            $line->fetch_optionals($line->id, $extralabels);
2755 2755
 		        }
2756 2756
 		    }
2757 2757
 		    
@@ -2851,23 +2851,23 @@  discard block
 block discarded – undo
2851 2851
 	    $ThtmlData['data-qty']          = 0; //$line->qty;
2852 2852
 	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2853 2853
 	    
2854
-	    if(TSubtotal::isTitle($line)){
2854
+	    if (TSubtotal::isTitle($line)) {
2855 2855
 	        $ThtmlData['data-issubtotal'] = 'title';
2856
-	    }elseif(TSubtotal::isSubtotal($line)){
2856
+	    }elseif (TSubtotal::isSubtotal($line)) {
2857 2857
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2858 2858
 	    }
2859
-	    else{
2859
+	    else {
2860 2860
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2861 2861
 	    }
2862 2862
 	    
2863 2863
 	    
2864 2864
 	    // Change or add data  from hooks
2865
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2865
+	    $parameters = array_replace($parameters, array('ThtmlData' => $ThtmlData));
2866 2866
 	    
2867 2867
 	    // hook 
2868
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2868
+	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2869 2869
 	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2870
-	    if ($reshook>0)
2870
+	    if ($reshook > 0)
2871 2871
 	    {
2872 2872
 	        $ThtmlData = $hookmanager->resArray;
2873 2873
 	    }
@@ -2880,14 +2880,14 @@  discard block
 block discarded – undo
2880 2880
 	function implodeHtmlData($ThtmlData = array())
2881 2881
 	{
2882 2882
 	    $data = '';
2883
-	    foreach($ThtmlData as $k => $h )
2883
+	    foreach ($ThtmlData as $k => $h)
2884 2884
 	    {
2885
-	        if(is_array($h))
2885
+	        if (is_array($h))
2886 2886
 	        {
2887 2887
 	            $h = json_encode($h);
2888 2888
 	        }
2889 2889
 	        
2890
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2890
+	        $data .= $k.'="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2891 2891
 	    }
2892 2892
 	    
2893 2893
 	    return $data;
@@ -2895,26 +2895,26 @@  discard block
 block discarded – undo
2895 2895
 	
2896 2896
 	function _ajax_block_order_js($object)
2897 2897
 	{
2898
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2898
+	    global $conf, $tagidfortablednd, $filepath, $langs;
2899 2899
 	    
2900 2900
 	    /*
2901 2901
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2902 2902
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2903 2903
 	     */
2904 2904
 	    
2905
-	    $id=$object->id;
2906
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2907
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2905
+	    $id = $object->id;
2906
+	    $nboflines = (isset($object->lines) ?count($object->lines) : 0);
2907
+	    $forcereloadpage = empty($conf->global->MAIN_FORCE_RELOAD_PAGE) ? 0 : 1;
2908 2908
 	    
2909
-	    $id=$object->id;
2910
-	    $fk_element=$object->fk_element;
2911
-	    $table_element_line=$object->table_element_line;
2912
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2913
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2914
-	    $filepath=(empty($filepath)?'':$filepath);
2909
+	    $id = $object->id;
2910
+	    $fk_element = $object->fk_element;
2911
+	    $table_element_line = $object->table_element_line;
2912
+	    $nboflines = (isset($object->lines) ?count($object->lines) : (empty($nboflines) ? 0 : $nboflines));
2913
+	    $tagidfortablednd = (empty($tagidfortablednd) ? 'tablelines' : $tagidfortablednd);
2914
+	    $filepath = (empty($filepath) ? '' : $filepath);
2915 2915
 	    
2916 2916
 	    
2917
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2917
+	    if (GETPOST('action', 'aZ09') != 'editline' && $nboflines > 1)
2918 2918
 	    {
2919 2919
 	        
2920 2920
 	        ?>
@@ -2932,7 +2932,7 @@  discard block
 block discarded – undo
2932 2932
 				moveBlockCol.disableSelection(); // prevent selection
2933 2933
 <?php if ($object->statut == 0) { ?>
2934 2934
 				// apply some graphical stuff
2935
-				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png',2);  ?>)');
2935
+				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png', 2); ?>)');
2936 2936
 				moveBlockCol.css("background-repeat","no-repeat");
2937 2937
 				moveBlockCol.css("background-position","center center");
2938 2938
 				moveBlockCol.css("cursor","move");
Please login to merge, or discard this patch.
Braces   +533 added lines, -314 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@  discard block
 block discarded – undo
45 45
 				$value = '';
46 46
 				$sql = 'SELECT content FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text WHERE rowid = '.GETPOST('rowid');
47 47
 				$resql = $this->db->query($sql);
48
-				if ($resql && ($obj = $this->db->fetch_object($resql))) $value = $obj->content;
48
+				if ($resql && ($obj = $this->db->fetch_object($resql))) {
49
+					$value = $obj->content;
50
+				}
49 51
 			}
50 52
 			
51 53
 			?>
@@ -124,8 +126,7 @@  discard block
 block discarded – undo
124 126
 			} elseif($object->element == 'invoice_supplier' )
125 127
 			{
126 128
 			    $createRight = $user->rights->fournisseur->facture->creer;
127
-			}
128
-			elseif($object->element == 'shipping')
129
+			} elseif($object->element == 'shipping')
129 130
 			{
130 131
 				$createRight = true; // No rights management for shipments
131 132
 			}
@@ -133,8 +134,11 @@  discard block
 block discarded – undo
133 134
 			if ($object->statut == 0  && $createRight) {
134 135
 			
135 136
 
136
-				if($object->element=='facture')$idvar = 'facid';
137
-				else $idvar='id';
137
+				if($object->element=='facture') {
138
+					$idvar = 'facid';
139
+				} else {
140
+					$idvar='id';
141
+				}
138 142
 				
139 143
 				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
140 144
 				{
@@ -142,10 +146,11 @@  discard block
 block discarded – undo
142 146
 					
143 147
 					if($action=='add_title_line') {
144 148
 						$title = GETPOST('title');
145
-						if(empty($title)) $title = $langs->trans('title');
149
+						if(empty($title)) {
150
+							$title = $langs->trans('title');
151
+						}
146 152
 						$qty = $level<1 ? 1 : $level ;
147
-					}
148
-					else if($action=='add_free_text') {
153
+					} else if($action=='add_free_text') {
149 154
 						$title = GETPOST('title');
150 155
 
151 156
 						if (empty($title)) {
@@ -157,29 +162,31 @@  discard block
 block discarded – undo
157 162
 								}
158 163
 							}
159 164
 						}
160
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
165
+						if(empty($title)) {
166
+							$title = $langs->trans('subtotalAddLineDescription');
167
+						}
161 168
 						$qty = 50;
162
-					}
163
-					else if($action=='add_subtitle_line') {
169
+					} else if($action=='add_subtitle_line') {
164 170
 						$title = GETPOST('title');
165
-						if(empty($title)) $title = $langs->trans('subtitle');
171
+						if(empty($title)) {
172
+							$title = $langs->trans('subtitle');
173
+						}
166 174
 						$qty = 2;
167
-					}
168
-					else if($action=='add_subtotal_line') {
175
+					} else if($action=='add_subtotal_line') {
169 176
 						$title = $langs->trans('SubSubTotal');
170 177
 						$qty = 98;
171
-					}
172
-					else {
178
+					} else {
173 179
 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
174 180
 						$qty = $level ? 100-$level : 99;
175 181
 					}
176 182
 					dol_include_once('/subtotal/class/subtotal.class.php');
177 183
 					
178
-					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
184
+					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) {
185
+						TSubtotal::addSubtotalMissing($object, $qty);
186
+					}
179 187
 					
180 188
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
181
-				}
182
-				else if($action==='ask_deleteallline') {
189
+				} else if($action==='ask_deleteallline') {
183 190
 						$form=new Form($db);
184 191
 
185 192
 						$lineid = GETPOST('lineid','integer');
@@ -202,8 +209,7 @@  discard block
 block discarded – undo
202 209
 					$this->printNewFormat($object, $conf, $langs, $idvar);
203 210
 				}
204 211
 			}
205
-		}
206
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts) || in_array('orderstoinvoicesupplier',$contexts))
212
+		} elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts) || in_array('orderstoinvoicesupplier',$contexts))
207 213
 		{
208 214
 			?>
209 215
 			<script type="text/javascript">
@@ -221,8 +227,13 @@  discard block
 block discarded – undo
221 227
      
222 228
 	function printNewFormat(&$object, &$conf, &$langs, $idvar)
223 229
 	{
224
-		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) return false;
225
-		if ($line->fk_prev_id != null && !empty($line->fk_prev_id)) return false; // Si facture de situation
230
+		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) {
231
+			return false;
232
+		}
233
+		if ($line->fk_prev_id != null && !empty($line->fk_prev_id)) {
234
+			return false;
235
+		}
236
+		// Si facture de situation
226 237
 		?>
227 238
 		 	<script type="text/javascript">
228 239
 				$(document).ready(function() {
@@ -515,8 +526,7 @@  discard block
 block discarded – undo
515 526
 				}
516 527
 				
517 528
 				
518
-			}	
519
-			else{
529
+			} else{
520 530
 				$substitutionarray['line_not_modsubtotal'] = true;
521 531
 				$substitutionarray['line_modsubtotal'] = 0;
522 532
 			}
@@ -574,8 +584,11 @@  discard block
 block discarded – undo
574 584
 		
575 585
 		$showBlockExtrafields = GETPOST('showBlockExtrafields');
576 586
 		
577
-		if($object->element=='facture') $idvar = 'facid';
578
-		else $idvar = 'id';
587
+		if($object->element=='facture') {
588
+			$idvar = 'facid';
589
+		} else {
590
+			$idvar = 'id';
591
+		}
579 592
 			
580 593
 		if ($action == 'updateligne' || $action == 'updateline')
581 594
 		{
@@ -605,8 +618,7 @@  discard block
 block discarded – undo
605 618
 				header('Location: '.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id);
606 619
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
607 620
 			}
608
-		}
609
-		else if($action === 'builddoc') {
621
+		} else if($action === 'builddoc') {
610 622
 			
611 623
 			if (
612 624
 				in_array('invoicecard',explode(':',$parameters['context']))
@@ -621,33 +633,27 @@  discard block
 block discarded – undo
621 633
 					$sessname = 'subtotal_hideInnerLines_facture';	
622 634
 					$sessname2 = 'subtotal_hidedetails_facture';
623 635
 					$sessname3 = 'subtotal_hideprices_facture';
624
-				}
625
-				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
636
+				} elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
626 637
 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
627 638
 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
628 639
 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
629
-				}
630
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
640
+				} elseif(in_array('propalcard',explode(':',$parameters['context']))) {
631 641
 					$sessname = 'subtotal_hideInnerLines_propal';
632 642
 					$sessname2 = 'subtotal_hidedetails_propal';	
633 643
 					$sessname3 = 'subtotal_hideprices_propal';
634
-				}
635
-				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
644
+				} elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
636 645
 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
637 646
 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
638 647
 				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
639
-				}
640
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
648
+				} elseif(in_array('ordercard',explode(':',$parameters['context']))) {
641 649
 					$sessname = 'subtotal_hideInnerLines_commande';
642 650
 					$sessname2 = 'subtotal_hidedetails_commande';	
643 651
 					$sessname3 = 'subtotal_hideprices_commande';
644
-				}
645
-				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
652
+				} elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
646 653
 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
647 654
 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
648 655
 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
649
-				}
650
-				else {
656
+				} else {
651 657
 					$sessname = 'subtotal_hideInnerLines_unknown';
652 658
 					$sessname2 = 'subtotal_hidedetails_unknown';
653 659
 					$sessname3 = 'subtotal_hideprices_unknown';
@@ -656,15 +662,24 @@  discard block
 block discarded – undo
656 662
 				global $hideprices;
657 663
 				
658 664
 				$hideInnerLines = (int)GETPOST('hideInnerLines');
659
-				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) $_SESSION[$sessname] = array(); // prevent old system
665
+				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) {
666
+					$_SESSION[$sessname] = array();
667
+				}
668
+				// prevent old system
660 669
 				$_SESSION[$sessname][$object->id] = $hideInnerLines;		
661 670
 				
662 671
 				$hidedetails= (int)GETPOST('hidedetails');
663
-				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) $_SESSION[$sessname2] = array(); // prevent old system
672
+				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) {
673
+					$_SESSION[$sessname2] = array();
674
+				}
675
+				// prevent old system
664 676
 				$_SESSION[$sessname2][$object->id] = $hidedetails;
665 677
 				
666 678
 				$hideprices= (int)GETPOST('hideprices');
667
-				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) $_SESSION[$sessname3] = array(); // prevent old system
679
+				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) {
680
+					$_SESSION[$sessname3] = array();
681
+				}
682
+				// prevent old system
668 683
 				$_SESSION[$sessname3][$object->id] = $hideprices;
669 684
 				
670 685
 				foreach($object->lines as &$line) {
@@ -672,8 +687,7 @@  discard block
 block discarded – undo
672 687
 					    
673 688
                         if($line->qty>=90) {
674 689
                             $line->modsubtotal_total = 1;
675
-                        }
676
-                        else{
690
+                        } else{
677 691
                             $line->modsubtotal_title = 1;
678 692
                         }
679 693
                         
@@ -682,8 +696,7 @@  discard block
 block discarded – undo
682 696
 	        	}
683 697
 	        }
684 698
 			
685
-		}
686
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
699
+		} else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
687 700
 			
688 701
 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
689 702
 			
@@ -691,7 +704,9 @@  discard block
 block discarded – undo
691 704
 				/**
692 705
 				 * @var $object Facture
693 706
 				 */
694
-				if($object->element=='facture') $object->deleteline($idLine);
707
+				if($object->element=='facture') {
708
+					$object->deleteline($idLine);
709
+				}
695 710
 				/**
696 711
 				 * @var $object Facture fournisseur
697 712
 				 */
@@ -702,18 +717,25 @@  discard block
 block discarded – undo
702 717
 				/**
703 718
 				 * @var $object Propal
704 719
 				 */
705
-				else if($object->element=='propal') $object->deleteline($idLine);
720
+				else if($object->element=='propal') {
721
+					$object->deleteline($idLine);
722
+				}
706 723
 				/**
707 724
 				 * @var $object Propal Fournisseur
708 725
 				 */
709
-				else if($object->element=='supplier_proposal') $object->deleteline($idLine);
726
+				else if($object->element=='supplier_proposal') {
727
+					$object->deleteline($idLine);
728
+				}
710 729
 				/**
711 730
 				 * @var $object Commande
712 731
 				 */
713 732
 				else if($object->element=='commande') 
714 733
 				{
715
-					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
716
-					else $object->deleteline($idLine);
734
+					if ((float) DOL_VERSION >= 5.0) {
735
+						$object->deleteline($user, $idLine);
736
+					} else {
737
+						$object->deleteline($idLine);
738
+					}
717 739
 				}
718 740
 				/**
719 741
 				 * @var $object Commande fournisseur
@@ -725,25 +747,32 @@  discard block
 block discarded – undo
725 747
 				/**
726 748
 				 * @var $object Facturerec
727 749
 				 */
728
-				else if($object->element=='facturerec') $object->deleteline($idLine);
750
+				else if($object->element=='facturerec') {
751
+					$object->deleteline($idLine);
752
+				}
729 753
 				/**
730 754
 				 * @var $object Expedition
731 755
 				 */
732
-				else if($object->element=='shipping') $object->deleteline($user, $idLine);
756
+				else if($object->element=='shipping') {
757
+					$object->deleteline($user, $idLine);
758
+				}
733 759
 			}
734 760
 			
735 761
 			header('location:?id='.$object->id);
736 762
 			exit;
737 763
 			
738
-		}
739
-		else if ($action == 'duplicate')
764
+		} else if ($action == 'duplicate')
740 765
 		{
741 766
 			$lineid = GETPOST('lineid', 'int');
742 767
 			$nbDuplicate = TSubtotal::duplicateLines($object, $lineid, true);
743 768
 			
744
-			if ($nbDuplicate > 0) setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
745
-			elseif ($nbDuplicate == 0) setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
746
-			else setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
769
+			if ($nbDuplicate > 0) {
770
+				setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
771
+			} elseif ($nbDuplicate == 0) {
772
+				setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
773
+			} else {
774
+				setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
775
+			}
747 776
 			
748 777
 			header('Location: ?id='.$object->id);
749 778
 			exit;
@@ -761,21 +790,26 @@  discard block
 block discarded – undo
761 790
 		global $conf;
762 791
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && !empty($object->table_element_line) && in_array($object->element, array('commande', 'facture', 'propal')))
763 792
 		{
764
-			if ($object->element == 'commande')
765
-				$obj = new OrderLine($object->db);
766
-			if ($object->element == 'propal')
767
-				$obj = new PropaleLigne($object->db);
768
-			if ($object->element == 'facture')
769
-				$obj = new FactureLigne($object->db);
793
+			if ($object->element == 'commande') {
794
+							$obj = new OrderLine($object->db);
795
+			}
796
+			if ($object->element == 'propal') {
797
+							$obj = new PropaleLigne($object->db);
798
+			}
799
+			if ($object->element == 'facture') {
800
+							$obj = new FactureLigne($object->db);
801
+			}
770 802
 			if (!empty($parameters['fk_element']))
771 803
 			{
772 804
 				
773 805
 				if($obj->fetch($parameters['fk_element'])){
774 806
 					$obj->id= $obj->rowid;
775
-					if (empty($obj->array_options))
776
-						$obj->fetch_optionals();
777
-					if (!empty($obj->array_options['options_subtotal_nc']))
778
-						return 1;
807
+					if (empty($obj->array_options)) {
808
+											$obj->fetch_optionals();
809
+					}
810
+					if (!empty($obj->array_options['options_subtotal_nc'])) {
811
+											return 1;
812
+					}
779 813
 				}
780 814
 			}
781 815
 		}
@@ -833,10 +867,15 @@  discard block
 block discarded – undo
833 867
 		$TTotal_tva = array();
834 868
 		
835 869
 		$sign=1;
836
-		if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
870
+		if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
871
+			$sign=-1;
872
+		}
837 873
 		
838
-		if (GETPOST('action') == 'builddoc') $builddoc = true;
839
-		else $builddoc = false;
874
+		if (GETPOST('action') == 'builddoc') {
875
+			$builddoc = true;
876
+		} else {
877
+			$builddoc = false;
878
+		}
840 879
 		
841 880
 		dol_include_once('/subtotal/class/subtotal.class.php');
842 881
 
@@ -845,9 +884,12 @@  discard block
 block discarded – undo
845 884
 		foreach($TLineReverse as $l)
846 885
 		{
847 886
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
848
-            if ($l->rang>=$rang) continue;
849
-            if (!empty($title_break) && $title_break->id == $l->id) break;
850
-            elseif (!TSubtotal::isModSubtotalLine($l))
887
+            if ($l->rang>=$rang) {
888
+            	continue;
889
+            }
890
+            if (!empty($title_break) && $title_break->id == $l->id) {
891
+            	break;
892
+            } elseif (!TSubtotal::isModSubtotalLine($l))
851 893
             {
852 894
                 // TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF
853 895
                 if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION)
@@ -869,8 +911,7 @@  discard block
 block discarded – undo
869 911
                         $TTotal_tva[$l->tva_tx] += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
870 912
                         $total_ttc += $sign * ($l->total_tva / ($l->total_ttc / 100)) * $progress;
871 913
                     }
872
-                }
873
-                else
914
+                } else
874 915
                 {
875 916
                     $total += $l->total_ht;
876 917
                     $total_tva += $l->total_tva;
@@ -879,8 +920,11 @@  discard block
 block discarded – undo
879 920
                 }
880 921
             }
881 922
 		}
882
-		if (!$return_all) return $total;
883
-		else return array($total, $total_tva, $total_ttc, $TTotal_tva);
923
+		if (!$return_all) {
924
+			return $total;
925
+		} else {
926
+			return array($total, $total_tva, $total_ttc, $TTotal_tva);
927
+		}
884 928
 	}
885 929
 
886 930
 	/**
@@ -927,15 +971,18 @@  discard block
 block discarded – undo
927 971
 		}
928 972
 		
929 973
 			
930
-		if($line->qty==99)
931
-			$pdf->SetFillColor(220,220,220);
932
-		elseif ($line->qty==98)
933
-			$pdf->SetFillColor(230,230,230);
934
-		else
935
-			$pdf->SetFillColor(240,240,240);
974
+		if($line->qty==99) {
975
+					$pdf->SetFillColor(220,220,220);
976
+		} elseif ($line->qty==98) {
977
+					$pdf->SetFillColor(230,230,230);
978
+		} else {
979
+					$pdf->SetFillColor(240,240,240);
980
+		}
936 981
 		
937 982
 		$style = 'B';
938
-		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
983
+		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) {
984
+			$style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
985
+		}
939 986
 		
940 987
 		$pdf->SetFont('', $style, 9);
941 988
 		
@@ -977,8 +1024,7 @@  discard block
 block discarded – undo
977 1024
 //					$line->total_tva
978 1025
 //					$line->total
979 1026
 //					$line->total_ttc
980
-				}
981
-				else
1027
+				} else
982 1028
 				{
983 1029
 					//					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
984 1030
 					
@@ -988,17 +1034,22 @@  discard block
 block discarded – undo
988 1034
 
989 1035
                     $line->total_ht = $TInfo[0];
990 1036
 					$line->total = $TInfo[0];
991
-					if (!TSubtotal::isModSubtotalLine($line)) $line->total_tva = $TInfo[1];
1037
+					if (!TSubtotal::isModSubtotalLine($line)) {
1038
+						$line->total_tva = $TInfo[1];
1039
+					}
992 1040
 					$line->total_ttc = $TInfo[2];
993 1041
 				}
994 1042
 			}
995 1043
 
996 1044
 			$pdf->SetXY($pdf->postotalht, $posy);
997
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1045
+			if($set_pagebreak_margin) {
1046
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1047
+			}
998 1048
 			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
999
-		}
1000
-		else{
1001
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1049
+		} else{
1050
+			if($set_pagebreak_margin) {
1051
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1052
+			}
1002 1053
 		}
1003 1054
 		
1004 1055
 		$posy = $posy + $cell_height;
@@ -1030,25 +1081,40 @@  discard block
 block discarded – undo
1030 1081
 		
1031 1082
  
1032 1083
 		$style = ($line->qty==1) ? 'BU' : 'BUI';
1033
-		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
1084
+		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) {
1085
+			$style = $conf->global->SUBTOTAL_TITLE_STYLE;
1086
+		}
1034 1087
 		
1035 1088
 		if($hideInnerLines) {
1036
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
1037
-			else 
1089
+			if($line->qty==1) {
1090
+				$pdf->SetFont('', $style, 9);
1091
+			} else 
1038 1092
 			{
1039
-				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
1093
+				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) {
1094
+					$style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
1095
+				}
1040 1096
 				$pdf->SetFont('', $style, 9);
1041 1097
 			}
1042
-		}
1043
-		else {
1098
+		} else {
1044 1099
 
1045
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
1046
-			else $pdf->SetFont('', $style, 9);
1100
+			if($line->qty==1) {
1101
+				$pdf->SetFont('', $style, 9);
1102
+			}
1103
+			//TODO if super utile
1104
+			else {
1105
+				$pdf->SetFont('', $style, 9);
1106
+			}
1047 1107
 			
1048 1108
 		}
1049 1109
 		
1050
-		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
1051
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
1110
+		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) {
1111
+			$pdf->MultiCell($w, $h, $label, 0, 'L');
1112
+		}
1113
+		// Pas de HTML dans la chaine
1114
+		else {
1115
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true);
1116
+		}
1117
+		// et maintenant avec du HTML
1052 1118
 		
1053 1119
 		if($description && !$hidedesc) {
1054 1120
 			$posy = $pdf->GetY();
@@ -1072,8 +1138,7 @@  discard block
 block discarded – undo
1072 1138
 		
1073 1139
 		if(is_array($parameters)) {
1074 1140
 			$i = & $parameters['i'];	
1075
-		}
1076
-		else {
1141
+		} else {
1077 1142
 			$i = (int)$parameters;
1078 1143
 		}
1079 1144
 
@@ -1103,17 +1168,14 @@  discard block
 block discarded – undo
1103 1168
 			
1104 1169
 			if((float)DOL_VERSION<=3.6) {
1105 1170
 				return '';
1106
-			}
1107
-			else if((float)DOL_VERSION>=3.8) {
1171
+			} else if((float)DOL_VERSION>=3.8) {
1108 1172
 				return 1;
1109 1173
 			}
1110 1174
 			
1111
-		}
1112
-		elseif(!empty($hideprices)) {
1175
+		} elseif(!empty($hideprices)) {
1113 1176
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1114 1177
 			return 1;
1115
-		}
1116
-		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1178
+		} elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1117 1179
 		{
1118 1180
 			$hideInnerLines = (int)GETPOST('hideInnerLines');
1119 1181
 			$hidedetails = (int)GETPOST('hidedetails');
@@ -1123,12 +1185,20 @@  discard block
 block discarded – undo
1123 1185
 			}
1124 1186
 		}
1125 1187
 		
1126
-		if(is_array($parameters)) $i = & $parameters['i'];
1127
-		else $i = (int)$parameters;
1188
+		if(is_array($parameters)) {
1189
+			$i = & $parameters['i'];
1190
+		} else {
1191
+			$i = (int)$parameters;
1192
+		}
1128 1193
 
1129
-		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)
1194
+		if (empty($object->lines[$i])) {
1195
+			return 0;
1196
+		}
1197
+		// 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)
1130 1198
 		
1131
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1199
+		if(empty($object->lines[$i]->array_options)) {
1200
+			$object->lines[$i]->fetch_optionals();
1201
+		}
1132 1202
 
1133 1203
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1134 1204
 		{
@@ -1145,8 +1215,11 @@  discard block
 block discarded – undo
1145 1215
 	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1146 1216
 	    global $conf, $hideprices, $hookmanager;
1147 1217
 		
1148
-		if(is_array($parameters)) $i = & $parameters['i'];
1149
-		else $i = (int)$parameters;
1218
+		if(is_array($parameters)) {
1219
+			$i = & $parameters['i'];
1220
+		} else {
1221
+			$i = (int)$parameters;
1222
+		}
1150 1223
 			
1151 1224
 		if($this->isModSubtotalLine($parameters,$object) ){
1152 1225
 			
@@ -1154,13 +1227,11 @@  discard block
 block discarded – undo
1154 1227
 			
1155 1228
 			if((float)DOL_VERSION<=3.6) {
1156 1229
 				return '';
1157
-			}
1158
-			else if((float)DOL_VERSION>=3.8) {
1230
+			} else if((float)DOL_VERSION>=3.8) {
1159 1231
 				return 1;
1160 1232
 			}
1161 1233
 			
1162
-		}
1163
-		elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1234
+		} elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1164 1235
 		{
1165 1236
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1166 1237
 			{
@@ -1232,12 +1303,10 @@  discard block
 block discarded – undo
1232 1303
 			$this->error = $hookmanager->error;
1233 1304
 			$this->errors = $hookmanager->errors;
1234 1305
 			return -1;
1235
-		}
1236
-		elseif (empty($reshook))
1306
+		} elseif (empty($reshook))
1237 1307
 		{
1238 1308
 			$this->resprints .= $hookmanager->resprints;
1239
-		}
1240
-		else
1309
+		} else
1241 1310
 		{
1242 1311
 			$this->resprints = $hookmanager->resprints;
1243 1312
 
@@ -1260,14 +1329,16 @@  discard block
 block discarded – undo
1260 1329
 		
1261 1330
 			if((float)DOL_VERSION<=3.6) {
1262 1331
 				return '';
1263
-			}
1264
-			else if((float)DOL_VERSION>=3.8) {
1332
+			} else if((float)DOL_VERSION>=3.8) {
1265 1333
 				return 1;
1266 1334
 			}
1267 1335
 		}
1268 1336
 		
1269
-		if(is_array($parameters)) $i = & $parameters['i'];
1270
-		else $i = (int)$parameters;
1337
+		if(is_array($parameters)) {
1338
+			$i = & $parameters['i'];
1339
+		} else {
1340
+			$i = (int)$parameters;
1341
+		}
1271 1342
 		
1272 1343
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1273 1344
 		{
@@ -1289,14 +1360,16 @@  discard block
 block discarded – undo
1289 1360
 		
1290 1361
 			if((float)DOL_VERSION<=3.6) {
1291 1362
 				return '';
1292
-			}
1293
-			else if((float)DOL_VERSION>=3.8) {
1363
+			} else if((float)DOL_VERSION>=3.8) {
1294 1364
 				return 1;
1295 1365
 			}
1296 1366
 		}
1297 1367
 		
1298
-		if(is_array($parameters)) $i = & $parameters['i'];
1299
-		else $i = (int)$parameters;
1368
+		if(is_array($parameters)) {
1369
+			$i = & $parameters['i'];
1370
+		} else {
1371
+			$i = (int)$parameters;
1372
+		}
1300 1373
 			
1301 1374
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1302 1375
 		{
@@ -1313,8 +1386,11 @@  discard block
 block discarded – undo
1313 1386
 	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1314 1387
 	    global $conf,$hideprices,$hookmanager;
1315 1388
 
1316
-		if(is_array($parameters)) $i = & $parameters['i'];
1317
-		else $i = (int)$parameters;
1389
+		if(is_array($parameters)) {
1390
+			$i = & $parameters['i'];
1391
+		} else {
1392
+			$i = (int)$parameters;
1393
+		}
1318 1394
 
1319 1395
 		if($this->isModSubtotalLine($parameters,$object) ) {
1320 1396
 			$this->resprints = ' ';
@@ -1325,7 +1401,9 @@  discard block
 block discarded – undo
1325 1401
             if(TSubtotal::isSubtotal($line)) {
1326 1402
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1327 1403
 
1328
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1404
+                if(is_object($parentTitle) && empty($parentTitle->array_options)) {
1405
+                	$parentTitle->fetch_optionals();
1406
+                }
1329 1407
                 if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1330 1408
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1331 1409
                     $this->resprints = price($TTotal['total_unit_subprice']);
@@ -1334,8 +1412,7 @@  discard block
 block discarded – undo
1334 1412
 		
1335 1413
 			if((float)DOL_VERSION<=3.6) {
1336 1414
 				return '';
1337
-			}
1338
-			else if((float)DOL_VERSION>=3.8) {
1415
+			} else if((float)DOL_VERSION>=3.8) {
1339 1416
 				return 1;
1340 1417
 			}
1341 1418
 		}
@@ -1380,8 +1457,11 @@  discard block
 block discarded – undo
1380 1457
 	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1381 1458
 	    global $conf,$hideprices,$hookmanager;
1382 1459
 
1383
-        if(is_array($parameters)) $i = & $parameters['i'];
1384
-        else $i = (int) $parameters;
1460
+        if(is_array($parameters)) {
1461
+        	$i = & $parameters['i'];
1462
+        } else {
1463
+        	$i = (int) $parameters;
1464
+        }
1385 1465
 
1386 1466
 		if($this->isModSubtotalLine($parameters,$object) ) {
1387 1467
 			$this->resprints = ' ';
@@ -1392,7 +1472,9 @@  discard block
 block discarded – undo
1392 1472
             if(TSubtotal::isSubtotal($line)) {
1393 1473
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1394 1474
 
1395
-                if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1475
+                if(empty($parentTitle->array_options)) {
1476
+                	$parentTitle->fetch_optionals();
1477
+                }
1396 1478
                 if(! empty($parentTitle->array_options['options_show_reduc'])) {
1397 1479
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1398 1480
                     $this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
@@ -1401,12 +1483,10 @@  discard block
 block discarded – undo
1401 1483
 		
1402 1484
 			if((float)DOL_VERSION<=3.6) {
1403 1485
 				return '';
1404
-			}
1405
-			else if((float)DOL_VERSION>=3.8) {
1486
+			} else if((float)DOL_VERSION>=3.8) {
1406 1487
 				return 1;
1407 1488
 			}
1408
-		}
1409
-		elseif (!empty($hideprices)
1489
+		} elseif (!empty($hideprices)
1410 1490
 		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1411 1491
 		        )
1412 1492
 		    {
@@ -1427,14 +1507,16 @@  discard block
 block discarded – undo
1427 1507
 			$this->resprints = ' ';
1428 1508
 			if((float)DOL_VERSION<=3.6) {
1429 1509
 				return '';
1430
-			}
1431
-			else if((float)DOL_VERSION>=3.8) {
1510
+			} else if((float)DOL_VERSION>=3.8) {
1432 1511
 				return 1;
1433 1512
 			}
1434 1513
 		}
1435 1514
 		
1436
-		if(is_array($parameters)) $i = & $parameters['i'];
1437
-		else $i = (int)$parameters;
1515
+		if(is_array($parameters)) {
1516
+			$i = & $parameters['i'];
1517
+		} else {
1518
+			$i = (int)$parameters;
1519
+		}
1438 1520
 			
1439 1521
 		if (!empty($hideprices)
1440 1522
 				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
@@ -1458,16 +1540,21 @@  discard block
 block discarded – undo
1458 1540
 			
1459 1541
 			if((float)DOL_VERSION<=3.6) {
1460 1542
 				return '';
1461
-			}
1462
-			else if((float)DOL_VERSION>=3.8) {
1543
+			} else if((float)DOL_VERSION>=3.8) {
1463 1544
 				return 1;
1464 1545
 			}
1465 1546
 		}
1466 1547
 		
1467
-		if(is_array($parameters)) $i = & $parameters['i'];
1468
-		else $i = (int)$parameters;
1548
+		if(is_array($parameters)) {
1549
+			$i = & $parameters['i'];
1550
+		} else {
1551
+			$i = (int)$parameters;
1552
+		}
1469 1553
 		
1470
-		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)
1554
+		if (empty($object->lines[$i])) {
1555
+			return 0;
1556
+		}
1557
+		// 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)
1471 1558
 
1472 1559
 		$object->lines[$i]->fetch_optionals();
1473 1560
 		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
@@ -1513,14 +1600,16 @@  discard block
 block discarded – undo
1513 1600
 			$this->resprints = ' ';
1514 1601
 			if((float)DOL_VERSION<=3.6) {
1515 1602
 				return '';
1516
-			}
1517
-			else if((float)DOL_VERSION>=3.8) {
1603
+			} else if((float)DOL_VERSION>=3.8) {
1518 1604
 				return 1;
1519 1605
 			}
1520 1606
 		}
1521 1607
 		
1522
-		if(is_array($parameters)) $i = & $parameters['i'];
1523
-		else $i = (int)$parameters;
1608
+		if(is_array($parameters)) {
1609
+			$i = & $parameters['i'];
1610
+		} else {
1611
+			$i = (int)$parameters;
1612
+		}
1524 1613
 			
1525 1614
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1526 1615
 		{
@@ -1550,7 +1639,9 @@  discard block
 block discarded – undo
1550 1639
 				}
1551 1640
 			}
1552 1641
 			
1553
-			if (!empty($TLineTitle)) $TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1642
+			if (!empty($TLineTitle)) {
1643
+				$TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1644
+			}
1554 1645
 		}
1555 1646
 		
1556 1647
 	}
@@ -1564,8 +1655,12 @@  discard block
 block discarded – undo
1564 1655
 		$j=0;
1565 1656
 		foreach ($TLineTitle as $k => &$line)
1566 1657
 		{
1567
-			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
1568
-			if (!empty($line_reference) && $line->qty <= $line_reference->qty) break;
1658
+			if (!empty($line_reference) && $line->rang <= $line_reference->rang) {
1659
+				continue;
1660
+			}
1661
+			if (!empty($line_reference) && $line->qty <= $line_reference->qty) {
1662
+				break;
1663
+			}
1569 1664
 			
1570 1665
 			if ($line->qty == $level)
1571 1666
 			{
@@ -1599,7 +1694,9 @@  discard block
 block discarded – undo
1599 1694
 		
1600 1695
 		$hidedetails = (int)GETPOST('hidedetails');
1601 1696
 		
1602
-		if(empty($hidedetails)) return false;
1697
+		if(empty($hidedetails)) {
1698
+			return false;
1699
+		}
1603 1700
 		
1604 1701
 		// TODO can't add VAT to document without lines... :-/
1605 1702
 		
@@ -1627,7 +1724,9 @@  discard block
 block discarded – undo
1627 1724
         foreach($object->lines as $k => &$l) {
1628 1725
             if(TSubtotal::isSubtotal($l)) {
1629 1726
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1630
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1727
+                if(is_object($parentTitle) && empty($parentTitle->array_options)) {
1728
+                	$parentTitle->fetch_optionals();
1729
+                }
1631 1730
                 if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_reduc'])) {
1632 1731
                     $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1633 1732
                 }
@@ -1671,7 +1770,9 @@  discard block
 block discarded – undo
1671 1770
 						
1672 1771
 						$TInfo = $this->getTotalLineFromObject($object, $line, '', 1);
1673 1772
 
1674
-						if (TSubtotal::getNiveau($line) == 1) $line->TTotal_tva = $TInfo[3];
1773
+						if (TSubtotal::getNiveau($line) == 1) {
1774
+							$line->TTotal_tva = $TInfo[3];
1775
+						}
1675 1776
 						$line->total_ht = $TInfo[0];
1676 1777
 						$line->total_tva = $TInfo[1];
1677 1778
 						$line->total = $line->total_ht;
@@ -1735,8 +1836,7 @@  discard block
 block discarded – undo
1735 1836
 				    }
1736 1837
 				    
1737 1838
 					
1738
-				}
1739
-				elseif ($hidedetails)
1839
+				} elseif ($hidedetails)
1740 1840
 				{
1741 1841
 					$TLines[] = $line; //Cas où je cache uniquement les prix des produits	
1742 1842
 				}
@@ -1807,13 +1907,17 @@  discard block
 block discarded – undo
1807 1907
 				
1808 1908
 				if(!empty($hideprices)) {
1809 1909
 					foreach($object->lines as &$line) {
1810
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1910
+						if($line->fk_product_type!=9) {
1911
+							$line->fk_parent_line = -1;
1912
+						}
1811 1913
 					}
1812 1914
 				}
1813 1915
 			
1814 1916
 				$line = &$object->lines[$i];
1815 1917
 
1816
-				if($object->element == 'delivery' && ! empty($object->commande->expeditions[$line->fk_origin_line])) unset($object->commande->expeditions[$line->fk_origin_line]);
1918
+				if($object->element == 'delivery' && ! empty($object->commande->expeditions[$line->fk_origin_line])) {
1919
+					unset($object->commande->expeditions[$line->fk_origin_line]);
1920
+				}
1817 1921
 
1818 1922
 				if($line->info_bits>0) { // PAGE BREAK
1819 1923
 					$pdf->addPage();
@@ -1829,7 +1933,9 @@  discard block
 block discarded – undo
1829 1933
 				}
1830 1934
 
1831 1935
 				if($line->qty>90) {
1832
-					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1936
+					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) {
1937
+						$label .= ' '.$this->getTitle($object, $line);
1938
+					}
1833 1939
 					
1834 1940
 					$pageBefore = $pdf->getPage();
1835 1941
 					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
@@ -1867,8 +1973,7 @@  discard block
 block discarded – undo
1867 1973
 				
1868 1974
 					$posy = $pdf->GetY();
1869 1975
 					return 1;
1870
-				}	
1871
-				else if ($line->qty < 10) {
1976
+				} else if ($line->qty < 10) {
1872 1977
 					$pageBefore = $pdf->getPage();
1873 1978
 
1874 1979
 					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
@@ -1898,8 +2003,7 @@  discard block
 block discarded – undo
1898 2003
 //	if($line->rowid==47) exit;
1899 2004
 			
1900 2005
 			return 0;
1901
-		}
1902
-		elseif (empty($object->lines[$parameters['i']]))
2006
+		} elseif (empty($object->lines[$parameters['i']]))
1903 2007
 		{
1904 2008
 			$this->resprints = -1;
1905 2009
 		}
@@ -1932,7 +2036,9 @@  discard block
 block discarded – undo
1932 2036
 		
1933 2037
 		foreach ($object->lines as $line)
1934 2038
 		{
1935
-			if ($line->id == $currentLine->id) break;
2039
+			if ($line->id == $currentLine->id) {
2040
+				break;
2041
+			}
1936 2042
 			
1937 2043
 			$qty_search = 100 - $currentLine->qty;
1938 2044
 			
@@ -1963,7 +2069,9 @@  discard block
 block discarded – undo
1963 2069
 		$var = &$parameters['var'];
1964 2070
 
1965 2071
 		$contexts = explode(':',$parameters['context']);
1966
-		if($parameters['currentcontext'] === 'paiementcard') return 0;
2072
+		if($parameters['currentcontext'] === 'paiementcard') {
2073
+			return 0;
2074
+		}
1967 2075
 		$originline = null;
1968 2076
 
1969 2077
 		$createRight = $user->rights->{$object->element}->creer;
@@ -1971,22 +2079,18 @@  discard block
 block discarded – undo
1971 2079
 		{
1972 2080
 			$object->statut = 0; // hack for facture rec
1973 2081
 			$createRight = $user->rights->facture->creer;
1974
-		}
1975
-		elseif($object->element == 'order_supplier' )
2082
+		} elseif($object->element == 'order_supplier' )
1976 2083
 		{
1977 2084
 		    $createRight = $user->rights->fournisseur->commande->creer;
1978
-		}
1979
-		elseif($object->element == 'invoice_supplier' )
2085
+		} elseif($object->element == 'invoice_supplier' )
1980 2086
 		{
1981 2087
 		    $createRight = $user->rights->fournisseur->facture->creer;
1982
-		}
1983
-		elseif($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
2088
+		} elseif($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
1984 2089
 		{
1985 2090
 			// H4cK 4n0nYm0u$-style : $line n'est pas un objet instancié mais provient d'un fetch_object d'une requête SQL
1986 2091
 			$line->id = $line->rowid;
1987 2092
 			$line->product_type = $line->type;
1988
-		}
1989
-		elseif($object->element == 'shipping' || $object->element == 'delivery')
2093
+		} elseif($object->element == 'shipping' || $object->element == 'delivery')
1990 2094
 		{
1991 2095
 			if(empty($line->origin_line_id) && ! empty($line->fk_origin_line))
1992 2096
 			{
@@ -2006,8 +2110,11 @@  discard block
 block discarded – undo
2006 2110
 
2007 2111
 			$line = $originline;
2008 2112
 		}
2009
- 		if($object->element=='facture')$idvar = 'facid';
2010
-        else $idvar='id';
2113
+ 		if($object->element=='facture') {
2114
+ 			$idvar = 'facid';
2115
+ 		} else {
2116
+        	$idvar='id';
2117
+        }
2011 2118
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
2012 2119
 			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE) && $object->element !== 'invoice_supplier')
2013 2120
             {
@@ -2025,8 +2132,7 @@  discard block
 block discarded – undo
2025 2132
 
2026 2133
             }
2027 2134
 			return 0;
2028
-		}
2029
-		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)) 
2135
+		} 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)) 
2030 2136
         {
2031 2137
 
2032 2138
 
@@ -2054,22 +2160,44 @@  discard block
 block discarded – undo
2054 2160
 				<?php
2055 2161
 			}
2056 2162
 			
2057
-			if(empty($line->description)) $line->description = $line->desc;
2163
+			if(empty($line->description)) {
2164
+				$line->description = $line->desc;
2165
+			}
2058 2166
 			
2059 2167
 			$colspan = 5;
2060
-			if($object->element == 'facturerec' ) $colspan = 3;
2061
-			if($object->element == 'order_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
2062
-			if($object->element == 'invoice_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7;
2063
-			if($object->element == 'supplier_proposal') (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2168
+			if($object->element == 'facturerec' ) {
2169
+				$colspan = 3;
2170
+			}
2171
+			if($object->element == 'order_supplier') {
2172
+				(float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
2173
+			}
2174
+			if($object->element == 'invoice_supplier') {
2175
+				(float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7;
2176
+			}
2177
+			if($object->element == 'supplier_proposal') {
2178
+				(float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2179
+			}
2064 2180
 			if(!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
2065 2181
 				$colspan++; // Colonne PU Devise
2066 2182
 			}
2067
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
2068
-			if(!empty($conf->margin->enabled)) $colspan++;
2069
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
2070
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
2071
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
2072
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
2183
+			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) {
2184
+				$colspan++;
2185
+			}
2186
+			if(!empty($conf->margin->enabled)) {
2187
+				$colspan++;
2188
+			}
2189
+			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) {
2190
+				$colspan++;
2191
+			}
2192
+			if(!empty($conf->global->DISPLAY_MARK_RATES)) {
2193
+				$colspan++;
2194
+			}
2195
+			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) {
2196
+				$colspan++;
2197
+			}
2198
+			if(!empty($conf->global->PRODUCT_USE_UNITS)) {
2199
+				$colspan++;
2200
+			}
2073 2201
 					
2074 2202
 			/* Titre */
2075 2203
 			//var_dump($line);
@@ -2082,23 +2210,36 @@  discard block
 block discarded – undo
2082 2210
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2083 2211
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2084 2212
 					{
2085
-						if($line->qty==99) print 'background:#adadcf';
2086
-						else if($line->qty==98) print 'background:#ddddff;';
2087
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2088
-						else if($line->qty==1) print 'background:#adadcf;';
2089
-						else if($line->qty==2) print 'background:#ddddff;';
2090
-						else if($line->qty==50) print '';
2091
-						else print 'background:#eeeeff;';
2213
+						if($line->qty==99) {
2214
+							print 'background:#adadcf';
2215
+						} else if($line->qty==98) {
2216
+							print 'background:#ddddff;';
2217
+						} else if($line->qty<=97 && $line->qty>=91) {
2218
+							print 'background:#eeeeff;';
2219
+						} else if($line->qty==1) {
2220
+							print 'background:#adadcf;';
2221
+						} else if($line->qty==2) {
2222
+							print 'background:#ddddff;';
2223
+						} else if($line->qty==50) {
2224
+							print '';
2225
+						} else {
2226
+							print 'background:#eeeeff;';
2227
+						}
2092 2228
 
2093 2229
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2094
-					}
2095
-					else 
2230
+					} else 
2096 2231
 					{
2097
-						if($line->qty==99) print 'background:#ddffdd';
2098
-						else if($line->qty==98) print 'background:#ddddff;';
2099
-						else if($line->qty==2) print 'background:#eeeeff; ';
2100
-						else if($line->qty==50) print '';
2101
-						else print 'background:#eeffee;' ;
2232
+						if($line->qty==99) {
2233
+							print 'background:#ddffdd';
2234
+						} else if($line->qty==98) {
2235
+							print 'background:#ddddff;';
2236
+						} else if($line->qty==2) {
2237
+							print 'background:#eeeeff; ';
2238
+						} else if($line->qty==50) {
2239
+							print '';
2240
+						} else {
2241
+							print 'background:#eeffee;' ;
2242
+						}
2102 2243
 					}
2103 2244
 
2104 2245
 			?>;">
@@ -2125,13 +2266,11 @@  discard block
 block discarded – undo
2125 2266
 							$qty_displayed = $line->qty;
2126 2267
 							print img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
2127 2268
 							
2128
-						}
2129
-						else if (TSubtotal::isSubtotal($line))
2269
+						} else if (TSubtotal::isSubtotal($line))
2130 2270
 						{
2131 2271
 							$qty_displayed = 100 - $line->qty;
2132 2272
 							print img_picto('', 'subsubtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
2133
-						}
2134
-						else
2273
+						} else
2135 2274
 						{
2136 2275
 							$isFreeText = true;
2137 2276
 						}
@@ -2152,9 +2291,13 @@  discard block
 block discarded – undo
2152 2291
 						}
2153 2292
 
2154 2293
 						$readonlyForSituation = '';
2155
-						if (!empty($line->fk_prev_id) && $line->fk_prev_id != null) $readonlyForSituation = 'readonly';
2294
+						if (!empty($line->fk_prev_id) && $line->fk_prev_id != null) {
2295
+							$readonlyForSituation = 'readonly';
2296
+						}
2156 2297
 						
2157
-						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2298
+						if (!$isFreeText) {
2299
+							echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2300
+						}
2158 2301
 						
2159 2302
 						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
2160 2303
 						{
@@ -2162,8 +2305,12 @@  discard block
 block discarded – undo
2162 2305
 							for ($j=1; $j<10; $j++)
2163 2306
 							{
2164 2307
 								if (!empty($readonlyForSituation)) {
2165
-									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2166
-								} else $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2308
+									if ($qty_displayed == $j) {
2309
+										$select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2310
+									}
2311
+								} else {
2312
+									$select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2313
+								}
2167 2314
 							}
2168 2315
 							$select .= '</select>&nbsp;';
2169 2316
 
@@ -2183,7 +2330,9 @@  discard block
 block discarded – undo
2183 2330
                             echo '<div>';
2184 2331
                             echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2185 2332
                             echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2186
-                            if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2333
+                            if (empty($readonlyForSituation)) {
2334
+                            	echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2335
+                            }
2187 2336
                             echo '</select>';
2188 2337
                             echo '</div>';
2189 2338
 
@@ -2202,8 +2351,9 @@  discard block
 block discarded – undo
2202 2351
                             echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2203 2352
                             echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2204 2353
                             echo '</div>';
2354
+                        } else if ($isFreeText) {
2355
+                        	echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2205 2356
                         }
2206
-                        else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2207 2357
 						echo '</div>';
2208 2358
 
2209 2359
 						if (TSubtotal::isTitle($line))
@@ -2224,9 +2374,13 @@  discard block
 block discarded – undo
2224 2374
 							$doleditor->Create();
2225 2375
 
2226 2376
 							$TKey = null;
2227
-							if ($line->element == 'propaldet') $TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_PROPALDET);
2228
-							elseif ($line->element == 'commandedet') $TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_COMMANDEDET);
2229
-							elseif ($line->element == 'facturedet') $TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_FACTUREDET);
2377
+							if ($line->element == 'propaldet') {
2378
+								$TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_PROPALDET);
2379
+							} elseif ($line->element == 'commandedet') {
2380
+								$TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_COMMANDEDET);
2381
+							} elseif ($line->element == 'facturedet') {
2382
+								$TKey = explode(',', $conf->global->SUBTOTAL_LIST_OF_EXTRAFIELDS_FACTUREDET);
2383
+							}
2230 2384
 							// TODO ajouter la partie fournisseur
2231 2385
 
2232 2386
 							if (!empty($TKey))
@@ -2246,8 +2400,7 @@  discard block
 block discarded – undo
2246 2400
 							}
2247 2401
 						}
2248 2402
 						
2249
-					}
2250
-					else {
2403
+					} else {
2251 2404
 
2252 2405
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2253 2406
 						 {
@@ -2255,14 +2408,19 @@  discard block
 block discarded – undo
2255 2408
 							{
2256 2409
 								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2257 2410
 								
2258
-								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2259
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2411
+								if (TSubtotal::isTitle($line)) {
2412
+									print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2413
+								} else {
2414
+									print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2415
+								}
2260 2416
 							}
2261
-						 }
2262
-						 else 
2417
+						 } else 
2263 2418
 						 {
2264
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2265
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2419
+							if($line->qty<=1) {
2420
+								print img_picto('', 'subtotal@subtotal');
2421
+							} else if($line->qty==2) {
2422
+								print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2423
+							}
2266 2424
 						 }
2267 2425
 						 
2268 2426
 						 
@@ -2272,21 +2430,26 @@  discard block
 block discarded – undo
2272 2430
 						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2273 2431
 						 
2274 2432
 						 if (empty($line->label)) {
2275
-							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2276
-							else print  $line->description;
2277
-						 } 
2278
-						 else {
2433
+							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2434
+								print  $line->description.' '.$this->getTitle($object, $line);
2435
+							} else {
2436
+								print  $line->description;
2437
+							}
2438
+						 } else {
2279 2439
 
2280 2440
 							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2281 2441
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2282
-							}
2283
-							else{
2442
+							} else{
2284 2443
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
2285 2444
 							}
2286 2445
 
2287 2446
 						 } 
2288
-						if($line->qty>90) print ' : ';
2289
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2447
+						if($line->qty>90) {
2448
+							print ' : ';
2449
+						}
2450
+						if($line->info_bits > 0) {
2451
+							echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2452
+						}
2290 2453
 
2291 2454
 						 
2292 2455
 
@@ -2329,11 +2492,12 @@  discard block
 block discarded – undo
2329 2492
 						</script>
2330 2493
 						<?php
2331 2494
 						
2332
-					}
2333
-					else{
2495
+					} else{
2334 2496
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2335 2497
 						{
2336
-							if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2498
+							if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) {
2499
+								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2500
+							}
2337 2501
 						}
2338 2502
 
2339 2503
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
@@ -2423,7 +2587,9 @@  discard block
 block discarded – undo
2423 2587
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2424 2588
 				
2425 2589
 				$colspan+=3; $mode = 'view';
2426
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2590
+				if($action === 'editline' && $line->rowid == GETPOST('lineid')) {
2591
+					$mode = 'edit';
2592
+				}
2427 2593
 				
2428 2594
 				$ex_element = $line->element;
2429 2595
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
@@ -2482,8 +2648,7 @@  discard block
 block discarded – undo
2482 2648
 			
2483 2649
 			return 1;	
2484 2650
 			
2485
-		}
2486
-		elseif(($object->element == 'commande' && in_array('ordershipmentcard', $contexts)) || (in_array('expeditioncard', $contexts) && $action == 'create'))
2651
+		} elseif(($object->element == 'commande' && in_array('ordershipmentcard', $contexts)) || (in_array('expeditioncard', $contexts) && $action == 'create'))
2487 2652
 		{
2488 2653
 			$colspan = 4;
2489 2654
 
@@ -2493,23 +2658,36 @@  discard block
 block discarded – undo
2493 2658
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2494 2659
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2495 2660
 					{
2496
-						if($line->qty==99) print 'background:#adadcf';
2497
-						else if($line->qty==98) print 'background:#ddddff;';
2498
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2499
-						else if($line->qty==1) print 'background:#adadcf;';
2500
-						else if($line->qty==2) print 'background:#ddddff;';
2501
-						else if($line->qty==50) print '';
2502
-						else print 'background:#eeeeff;';
2661
+						if($line->qty==99) {
2662
+							print 'background:#adadcf';
2663
+						} else if($line->qty==98) {
2664
+							print 'background:#ddddff;';
2665
+						} else if($line->qty<=97 && $line->qty>=91) {
2666
+							print 'background:#eeeeff;';
2667
+						} else if($line->qty==1) {
2668
+							print 'background:#adadcf;';
2669
+						} else if($line->qty==2) {
2670
+							print 'background:#ddddff;';
2671
+						} else if($line->qty==50) {
2672
+							print '';
2673
+						} else {
2674
+							print 'background:#eeeeff;';
2675
+						}
2503 2676
 
2504 2677
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2505
-					}
2506
-					else
2678
+					} else
2507 2679
 					{
2508
-						if($line->qty==99) print 'background:#ddffdd';
2509
-						else if($line->qty==98) print 'background:#ddddff;';
2510
-						else if($line->qty==2) print 'background:#eeeeff; ';
2511
-						else if($line->qty==50) print '';
2512
-						else print 'background:#eeffee;' ;
2680
+						if($line->qty==99) {
2681
+							print 'background:#ddffdd';
2682
+						} else if($line->qty==98) {
2683
+							print 'background:#ddddff;';
2684
+						} else if($line->qty==2) {
2685
+							print 'background:#eeeeff; ';
2686
+						} else if($line->qty==50) {
2687
+							print '';
2688
+						} else {
2689
+							print 'background:#eeffee;' ;
2690
+						}
2513 2691
 					}
2514 2692
 
2515 2693
 			?>;">
@@ -2523,14 +2701,19 @@  discard block
 block discarded – undo
2523 2701
 							{
2524 2702
 								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2525 2703
 
2526
-								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2527
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2704
+								if (TSubtotal::isTitle($line)) {
2705
+									print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2706
+								} else {
2707
+									print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2708
+								}
2528 2709
 							}
2529
-						 }
2530
-						 else
2710
+						 } else
2531 2711
 						 {
2532
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2533
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2712
+							if($line->qty<=1) {
2713
+								print img_picto('', 'subtotal@subtotal');
2714
+							} else if($line->qty==2) {
2715
+								print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2716
+							}
2534 2717
 						 }
2535 2718
 
2536 2719
 
@@ -2540,21 +2723,24 @@  discard block
 block discarded – undo
2540 2723
 						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2541 2724
 
2542 2725
 						 if (empty($line->label)) {
2543
-							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2544
-							else print  $line->description;
2545
-						 }
2546
-						 else {
2726
+							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2727
+								print  $line->description.' '.$this->getTitle($object, $line);
2728
+							} else {
2729
+								print  $line->description;
2730
+							}
2731
+						 } else {
2547 2732
 
2548 2733
 							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2549 2734
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2550
-							}
2551
-							else{
2735
+							} else{
2552 2736
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2553 2737
 							}
2554 2738
 
2555 2739
 						 }
2556 2740
 						//if($line->qty>90) print ' : ';
2557
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2741
+						if($line->info_bits > 0) {
2742
+							echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2743
+						}
2558 2744
 
2559 2745
 			?>
2560 2746
 				</td>
@@ -2577,8 +2763,7 @@  discard block
 block discarded – undo
2577 2763
 			</tr>
2578 2764
 <?php
2579 2765
 			return 1;
2580
-		}
2581
-		elseif ($object->element == 'shipping' || $object->element == 'delivery')
2766
+		} elseif ($object->element == 'shipping' || $object->element == 'delivery')
2582 2767
 		{
2583 2768
 			global $form;
2584 2769
 
@@ -2590,13 +2775,25 @@  discard block
 block discarded – undo
2590 2775
 			$extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2591 2776
 
2592 2777
 			$colspan = 4;
2593
-			if($object->origin && $object->origin_id > 0) $colspan++;
2594
-			if(! empty($conf->stock->enabled)) $colspan++;
2595
-			if(! empty($conf->productbatch->enabled)) $colspan++;
2596
-			if($object->statut == 0) $colspan++;
2597
-			if($object->statut == 0 && empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) $colspan++;
2778
+			if($object->origin && $object->origin_id > 0) {
2779
+				$colspan++;
2780
+			}
2781
+			if(! empty($conf->stock->enabled)) {
2782
+				$colspan++;
2783
+			}
2784
+			if(! empty($conf->productbatch->enabled)) {
2785
+				$colspan++;
2786
+			}
2787
+			if($object->statut == 0) {
2788
+				$colspan++;
2789
+			}
2790
+			if($object->statut == 0 && empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) {
2791
+				$colspan++;
2792
+			}
2598 2793
 
2599
-			if($object->element == 'delivery') $colspan = 2;
2794
+			if($object->element == 'delivery') {
2795
+				$colspan = 2;
2796
+			}
2600 2797
 
2601 2798
 			print '<!-- origin line id = '.$line->origin_line_id.' -->'; // id of order line
2602 2799
 
@@ -2606,23 +2803,36 @@  discard block
 block discarded – undo
2606 2803
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2607 2804
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2608 2805
 					{
2609
-						if($line->qty==99) print 'background:#adadcf';
2610
-						else if($line->qty==98) print 'background:#ddddff;';
2611
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2612
-						else if($line->qty==1) print 'background:#adadcf;';
2613
-						else if($line->qty==2) print 'background:#ddddff;';
2614
-						else if($line->qty==50) print '';
2615
-						else print 'background:#eeeeff;';
2806
+						if($line->qty==99) {
2807
+							print 'background:#adadcf';
2808
+						} else if($line->qty==98) {
2809
+							print 'background:#ddddff;';
2810
+						} else if($line->qty<=97 && $line->qty>=91) {
2811
+							print 'background:#eeeeff;';
2812
+						} else if($line->qty==1) {
2813
+							print 'background:#adadcf;';
2814
+						} else if($line->qty==2) {
2815
+							print 'background:#ddddff;';
2816
+						} else if($line->qty==50) {
2817
+							print '';
2818
+						} else {
2819
+							print 'background:#eeeeff;';
2820
+						}
2616 2821
 
2617 2822
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2618
-					}
2619
-					else 
2823
+					} else 
2620 2824
 					{
2621
-						if($line->qty==99) print 'background:#ddffdd';
2622
-						else if($line->qty==98) print 'background:#ddddff;';
2623
-						else if($line->qty==2) print 'background:#eeeeff; ';
2624
-						else if($line->qty==50) print '';
2625
-						else print 'background:#eeffee;' ;
2825
+						if($line->qty==99) {
2826
+							print 'background:#ddffdd';
2827
+						} else if($line->qty==98) {
2828
+							print 'background:#ddddff;';
2829
+						} else if($line->qty==2) {
2830
+							print 'background:#eeeeff; ';
2831
+						} else if($line->qty==50) {
2832
+							print '';
2833
+						} else {
2834
+							print 'background:#eeffee;' ;
2835
+						}
2626 2836
 					}
2627 2837
 
2628 2838
 			?>;">
@@ -2644,14 +2854,19 @@  discard block
 block discarded – undo
2644 2854
 				{
2645 2855
 					echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2646 2856
 
2647
-					if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2648
-					else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2857
+					if (TSubtotal::isTitle($line)) {
2858
+						print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2859
+					} else {
2860
+						print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2861
+					}
2649 2862
 				}
2650
-			}
2651
-			else
2863
+			} else
2652 2864
 			{
2653
-				if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2654
-				else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2865
+				if($line->qty<=1) {
2866
+					print img_picto('', 'subtotal@subtotal');
2867
+				} else if($line->qty==2) {
2868
+					print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2869
+				}
2655 2870
 			}
2656 2871
 
2657 2872
 
@@ -2661,19 +2876,22 @@  discard block
 block discarded – undo
2661 2876
 			$titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2662 2877
 
2663 2878
 			if (empty($line->label)) {
2664
-				if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2665
-				else print  $line->description;
2666
-			}
2667
-			else {
2879
+				if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2880
+					print  $line->description.' '.$this->getTitle($object, $line);
2881
+				} else {
2882
+					print  $line->description;
2883
+				}
2884
+			} else {
2668 2885
 				if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2669 2886
 					print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2670
-				}
2671
-				else{
2887
+				} else{
2672 2888
 					print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2673 2889
 				}
2674 2890
 			}
2675 2891
 			//if($line->qty>90) print ' : ';
2676
-			if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2892
+			if($line->info_bits > 0) {
2893
+				echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2894
+			}
2677 2895
 
2678 2896
 			?>
2679 2897
 				</td>
@@ -2853,10 +3071,9 @@  discard block
 block discarded – undo
2853 3071
 	    
2854 3072
 	    if(TSubtotal::isTitle($line)){
2855 3073
 	        $ThtmlData['data-issubtotal'] = 'title';
2856
-	    }elseif(TSubtotal::isSubtotal($line)){
3074
+	    } elseif(TSubtotal::isSubtotal($line)){
2857 3075
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2858
-	    }
2859
-	    else{
3076
+	    } else{
2860 3077
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2861 3078
 	    }
2862 3079
 	    
@@ -2866,7 +3083,9 @@  discard block
 block discarded – undo
2866 3083
 	    
2867 3084
 	    // hook 
2868 3085
 	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2869
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
3086
+	    if ($reshook < 0) {
3087
+	    	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
3088
+	    }
2870 3089
 	    if ($reshook>0)
2871 3090
 	    {
2872 3091
 	        $ThtmlData = $hookmanager->resArray;
Please login to merge, or discard this patch.