Passed
Pull Request — master (#124)
by
unknown
02:59
created
lib/subtotal.lib.php 3 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -25,25 +25,25 @@  discard block
 block discarded – undo
25 25
 
26 26
 function subtotalAdminPrepareHead()
27 27
 {
28
-    global $langs, $conf;
28
+	global $langs, $conf;
29 29
 
30
-    $langs->load("subtotal@subtotal");
30
+	$langs->load("subtotal@subtotal");
31 31
 
32
-    $h = 0;
33
-    $head = array();
32
+	$h = 0;
33
+	$head = array();
34 34
 
35
-    $head[$h][0] = dol_buildpath("/subtotal/admin/subtotal_setup.php", 1);
36
-    $head[$h][1] = $langs->trans("Parameters");
37
-    $head[$h][2] = 'settings';
38
-    $h++;
39
-    $head[$h][0] = dol_buildpath("/subtotal/admin/subtotal_about.php", 1);
40
-    $head[$h][1] = $langs->trans("About");
41
-    $head[$h][2] = 'about';
42
-    $h++;
35
+	$head[$h][0] = dol_buildpath("/subtotal/admin/subtotal_setup.php", 1);
36
+	$head[$h][1] = $langs->trans("Parameters");
37
+	$head[$h][2] = 'settings';
38
+	$h++;
39
+	$head[$h][0] = dol_buildpath("/subtotal/admin/subtotal_about.php", 1);
40
+	$head[$h][1] = $langs->trans("About");
41
+	$head[$h][2] = 'about';
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
-    return $head;
46
+	return $head;
47 47
 }
48 48
 
49 49
 function getHtmlSelectTitle(&$object, $showLabel=false)
@@ -130,8 +130,8 @@  discard block
 block discarded – undo
130 130
 	$label = GETPOST('line-title');
131 131
 	$description = ($line->qty>90) ? '' : GETPOST('line-description');
132 132
 	$pagebreak = (int) GETPOST('line-pagebreak');
133
-    $showTotalHT = (int) GETPOST('line-showTotalHT');
134
-    $showReduc = (int) GETPOST('line-showReduc');
133
+	$showTotalHT = (int) GETPOST('line-showTotalHT');
134
+	$showReduc = (int) GETPOST('line-showReduc');
135 135
 
136 136
 	$level = GETPOST('subtotal_level', 'int');
137 137
 	if (!empty($level))
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 		if ($line->qty > 90) $line->qty = 100 - $level; // Si on edit une ligne sous-total
140 140
 		else $line->qty = $level;
141 141
 	}
142
-    $line->array_options['options_show_total_ht'] = $showTotalHT;
143
-    $line->array_options['options_show_reduc'] = $showReduc;
142
+	$line->array_options['options_show_total_ht'] = $showTotalHT;
143
+	$line->array_options['options_show_reduc'] = $showReduc;
144 144
 	
145 145
 	$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);
146 146
 
@@ -246,17 +246,17 @@  discard block
 block discarded – undo
246 246
 			$classname = ucfirst($element);
247 247
 			
248 248
 			switch ($element) {
249
-			    case 'supplier_proposal':
250
-			        $classname = 'SupplierProposal';
251
-			        break;
249
+				case 'supplier_proposal':
250
+					$classname = 'SupplierProposal';
251
+					break;
252 252
 			        
253
-			    case 'order_supplier':
254
-			        $classname = 'CommandeFournisseur';
255
-			        break;
253
+				case 'order_supplier':
254
+					$classname = 'CommandeFournisseur';
255
+					break;
256 256
 			        
257
-			    case 'invoice_supplier':
258
-			        $classname = 'FactureFournisseur';
259
-			        break;
257
+				case 'invoice_supplier':
258
+					$classname = 'FactureFournisseur';
259
+					break;
260 260
 			}
261 261
 			
262 262
 			$object = new $classname($db); // Propal | Commande | Facture
@@ -329,14 +329,14 @@  discard block
 block discarded – undo
329 329
 		else $res = $line->update($user, $notrigger);
330 330
 	}
331 331
 	else {
332
-	    if(in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
333
-	        if(empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
332
+		if(in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
333
+			if(empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
334 334
 	        
335
-	        require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
336
-	        $extrafields=new ExtraFields($object->db);
337
-	        $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
338
-	        $line->fetch_optionals($line->id,$extralabels);
339
-	    }
335
+			require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
336
+			$extrafields=new ExtraFields($object->db);
337
+			$extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
338
+			$line->fetch_optionals($line->id,$extralabels);
339
+		}
340 340
 		$line->array_options['options_subtotal_nc'] = 0;
341 341
 		if($object->element == 'order_supplier') $line->update($user);
342 342
 		$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);
Please login to merge, or discard this patch.
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
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 function _updateSubtotalLine(&$object, &$line)
129 129
 {
130 130
 	$label = GETPOST('line-title');
131
-	$description = ($line->qty>90) ? '' : GETPOST('line-description');
131
+	$description = ($line->qty > 90) ? '' : GETPOST('line-description');
132 132
 	$pagebreak = (int) GETPOST('line-pagebreak');
133 133
     $showTotalHT = (int) GETPOST('line-showTotalHT');
134 134
     $showReduc = (int) GETPOST('line-showReduc');
@@ -149,7 +149,7 @@  discard block
 block discarded – undo
149 149
 
150 150
 function _updateSubtotalBloc($object, $line)
151 151
 {
152
-	global $conf,$langs;
152
+	global $conf, $langs;
153 153
 	
154 154
 	$subtotal_tva_tx = $subtotal_tva_tx_init = GETPOST('subtotal_tva_tx', 'int');
155 155
 	$subtotal_progress = $subtotal_progress_init = GETPOST('subtotal_progress', 'int');
@@ -228,9 +228,9 @@  discard block
 block discarded – undo
228 228
  * @param	$lineid			= title lineid
229 229
  * @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 
230 230
  */
231
-function _updateLineNC($element, $elementid, $lineid, $subtotal_nc=null, $notrigger = 0)
231
+function _updateLineNC($element, $elementid, $lineid, $subtotal_nc = null, $notrigger = 0)
232 232
 {
233
-	global $db,$langs,$tmp_object_nc;
233
+	global $db, $langs, $tmp_object_nc;
234 234
 	
235 235
 	$error = 0;
236 236
 	if (empty($element)) $error++;
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	{
271 271
 		foreach ($object->lines as &$l)
272 272
 		{
273
-			if($l->id == $lineid) {
273
+			if ($l->id == $lineid) {
274 274
 				$line = $l;
275 275
 				break;
276 276
 			}
@@ -280,12 +280,12 @@  discard block
 block discarded – undo
280 280
 		{
281 281
 			$db->begin();
282 282
 			
283
-			if(TSubtotal::isModSubtotalLine($line))
283
+			if (TSubtotal::isModSubtotalLine($line))
284 284
 			{
285
-				if(TSubtotal::isTitle($line)) {
285
+				if (TSubtotal::isTitle($line)) {
286 286
 					// Update le contenu du titre (ainsi que le titre lui même)
287 287
 					$TTitleBlock = TSubtotal::getLinesFromTitleId($object, $lineid, true);
288
-					foreach($TTitleBlock as &$line_block)
288
+					foreach ($TTitleBlock as &$line_block)
289 289
 					{
290 290
 						$res = doUpdate($object, $line_block, $subtotal_nc, $notrigger);
291 291
 					}
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	
320 320
 	if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) return 1;
321 321
 	// Update extrafield et total
322
-	if(! empty($subtotal_nc)) {
322
+	if (!empty($subtotal_nc)) {
323 323
 		$line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = 
324 324
 			$line->multicurrency_total_ht = $line->multicurrency_total_tva = $line->multicurrency_total_ttc = 0;
325 325
 
@@ -329,16 +329,16 @@  discard block
 block discarded – undo
329 329
 		else $res = $line->update($user, $notrigger);
330 330
 	}
331 331
 	else {
332
-	    if(in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
333
-	        if(empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
332
+	    if (in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
333
+	        if (empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
334 334
 	        
335 335
 	        require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
336
-	        $extrafields=new ExtraFields($object->db);
337
-	        $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
338
-	        $line->fetch_optionals($line->id,$extralabels);
336
+	        $extrafields = new ExtraFields($object->db);
337
+	        $extralabels = $extrafields->fetch_name_optionals_label($object->table_element_line, true);
338
+	        $line->fetch_optionals($line->id, $extralabels);
339 339
 	    }
340 340
 		$line->array_options['options_subtotal_nc'] = 0;
341
-		if($object->element == 'order_supplier') $line->update($user);
341
+		if ($object->element == 'order_supplier') $line->update($user);
342 342
 		$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);
343 343
 	}
344 344
 	
Please login to merge, or discard this patch.
Braces   +63 added lines, -29 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)
@@ -136,8 +140,13 @@  discard block
 block discarded – undo
136 140
 	$level = GETPOST('subtotal_level', 'int');
137 141
 	if (!empty($level))
138 142
 	{
139
-		if ($line->qty > 90) $line->qty = 100 - $level; // Si on edit une ligne sous-total
140
-		else $line->qty = $level;
143
+		if ($line->qty > 90) {
144
+			$line->qty = 100 - $level;
145
+		}
146
+		// Si on edit une ligne sous-total
147
+		else {
148
+			$line->qty = $level;
149
+		}
141 150
 	}
142 151
     $line->array_options['options_show_total_ht'] = $showTotalHT;
143 152
     $line->array_options['options_show_reduc'] = $showReduc;
@@ -166,13 +175,18 @@  discard block
 block discarded – undo
166 175
 			{
167 176
 				$subtotal_tva_tx = $subtotal_tva_tx_init; // ré-init car la variable peut évoluer
168 177
 					
169
-				if (!empty($showBlockExtrafields)) $line->array_options = $array_options;
170
-				if ($subtotal_tva_tx == '') $subtotal_tva_tx = $line->tva_tx;
178
+				if (!empty($showBlockExtrafields)) {
179
+					$line->array_options = $array_options;
180
+				}
181
+				if ($subtotal_tva_tx == '') {
182
+					$subtotal_tva_tx = $line->tva_tx;
183
+				}
171 184
 				if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION)
172 185
 				{
173 186
 					$subtotal_progress = $subtotal_progress_init;
174
-					if ($subtotal_progress == '') $subtotal_progress = $line->situation_percent;
175
-					else
187
+					if ($subtotal_progress == '') {
188
+						$subtotal_progress = $line->situation_percent;
189
+					} else
176 190
 					{
177 191
 						$prev_percent = $line->get_prev_progress($object->id);
178 192
 						if ($subtotal_progress < $prev_percent)
@@ -185,14 +199,21 @@  discard block
 block discarded – undo
185 199
 				
186 200
 				$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);
187 201
 
188
-				if ($res > 0) $success_updated_line++;
189
-				else $error_updated_line++;
202
+				if ($res > 0) {
203
+					$success_updated_line++;
204
+				} else {
205
+					$error_updated_line++;
206
+				}
190 207
 			}
191 208
 		}
192 209
 
193
-		if ($nb_progress_not_updated > 0) setEventMessage($langs->trans('subtotal_nb_progress_not_updated', $nb_progress_not_updated), 'warnings');
210
+		if ($nb_progress_not_updated > 0) {
211
+			setEventMessage($langs->trans('subtotal_nb_progress_not_updated', $nb_progress_not_updated), 'warnings');
212
+		}
194 213
 		
195
-		if ($success_updated_line > 0) setEventMessage($langs->trans('subtotal_success_updated_line', $success_updated_line));
214
+		if ($success_updated_line > 0) {
215
+			setEventMessage($langs->trans('subtotal_success_updated_line', $success_updated_line));
216
+		}
196 217
 		if ($error_updated_line > 0)
197 218
 		{
198 219
 			setEventMessage($langs->trans('subtotal_error_updated_line', $error_updated_line), 'errors');
@@ -233,15 +254,16 @@  discard block
 block discarded – undo
233 254
 	global $db,$langs,$tmp_object_nc;
234 255
 	
235 256
 	$error = 0;
236
-	if (empty($element)) $error++;
257
+	if (empty($element)) {
258
+		$error++;
259
+	}
237 260
 	
238 261
 	if (!$error)
239 262
 	{
240 263
 		if (!empty($tmp_object_nc) && $tmp_object_nc->element == $element && $tmp_object_nc->id == $elementid)
241 264
 		{
242 265
 			$object = $tmp_object_nc;
243
-		}
244
-		else
266
+		} else
245 267
 		{
246 268
 			$classname = ucfirst($element);
247 269
 			
@@ -261,8 +283,11 @@  discard block
 block discarded – undo
261 283
 			
262 284
 			$object = new $classname($db); // Propal | Commande | Facture
263 285
 			$res = $object->fetch($elementid);
264
-			if ($res < 0) $error++;
265
-			else $tmp_object_nc = $object;
286
+			if ($res < 0) {
287
+				$error++;
288
+			} else {
289
+				$tmp_object_nc = $object;
290
+			}
266 291
 		}
267 292
 	}
268 293
 	
@@ -290,21 +315,21 @@  discard block
 block discarded – undo
290 315
 						$res = doUpdate($object, $line_block, $subtotal_nc, $notrigger);
291 316
 					}
292 317
 				}
293
-			}
294
-			else
318
+			} else
295 319
 			{
296 320
 				$res = doUpdate($object, $line, $subtotal_nc, $notrigger);
297 321
 			}
298 322
 			
299 323
 			$res = $object->update_price(1);
300
-			if ($res <= 0) $error++;
324
+			if ($res <= 0) {
325
+				$error++;
326
+			}
301 327
 			
302 328
 			if (!$error)
303 329
 			{
304 330
 				setEventMessage($langs->trans('subtotal_update_nc_success'));
305 331
 				$db->commit();
306
-			}
307
-			else
332
+			} else
308 333
 			{
309 334
 				setEventMessage($langs->trans('subtotal_update_nc_error'), 'errors');
310 335
 				$db->rollback();
@@ -317,7 +342,9 @@  discard block
 block discarded – undo
317 342
 {
318 343
 	global $user;
319 344
 	
320
-	if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) return 1;
345
+	if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) {
346
+		return 1;
347
+	}
321 348
 	// Update extrafield et total
322 349
 	if(! empty($subtotal_nc)) {
323 350
 		$line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = 
@@ -325,12 +352,17 @@  discard block
 block discarded – undo
325 352
 
326 353
 		$line->array_options['options_subtotal_nc'] = 1;
327 354
 
328
-		if ($line->element == 'propaldet') $res = $line->update($notrigger);
329
-		else $res = $line->update($user, $notrigger);
330
-	}
331
-	else {
355
+		if ($line->element == 'propaldet') {
356
+			$res = $line->update($notrigger);
357
+		} else {
358
+			$res = $line->update($user, $notrigger);
359
+		}
360
+	} else {
332 361
 	    if(in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
333
-	        if(empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
362
+	        if(empty($line->label)) {
363
+	        	$line->label = $line->description;
364
+	        }
365
+	        // supplier lines don't have the field label
334 366
 	        
335 367
 	        require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
336 368
 	        $extrafields=new ExtraFields($object->db);
@@ -338,7 +370,9 @@  discard block
 block discarded – undo
338 370
 	        $line->fetch_optionals($line->id,$extralabels);
339 371
 	    }
340 372
 		$line->array_options['options_subtotal_nc'] = 0;
341
-		if($object->element == 'order_supplier') $line->update($user);
373
+		if($object->element == 'order_supplier') {
374
+			$line->update($user);
375
+		}
342 376
 		$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);
343 377
 	}
344 378
 	
Please login to merge, or discard this patch.
class/actions_subtotal.class.php 3 patches
Indentation   +288 added lines, -288 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
 			
129 129
 			if ($object->statut == 0  && $createRight) {
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 					
174 174
 					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
175 175
 					
176
-	    			TSubtotal::addSubTotalLine($object, $title, $qty);
176
+					TSubtotal::addSubTotalLine($object, $title, $qty);
177 177
 				}
178 178
 				else if($action==='ask_deleteallline') {
179 179
 						$form=new Form($db);
@@ -395,36 +395,36 @@  discard block
 block discarded – undo
395 395
 		$TContext = explode(':',$parameters['context']);
396 396
 		if (
397 397
 				in_array('invoicecard',$TContext)
398
-		        || in_array('invoicesuppliercard',$TContext)
398
+				|| in_array('invoicesuppliercard',$TContext)
399 399
 				|| in_array('propalcard',$TContext)
400 400
 				|| in_array('ordercard',$TContext)
401
-		        || in_array('ordersuppliercard',$TContext)
401
+				|| in_array('ordersuppliercard',$TContext)
402 402
 				|| in_array('invoicereccard',$TContext)
403 403
 			)
404
-	        {	
405
-	            $hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
406
-	            $hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
404
+			{	
405
+				$hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
406
+				$hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
407 407
 				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0;
408 408
 				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
409 409
 				
410 410
 				$var=false;
411
-		     	$out.= '<tr '.$bc[$var].'>
411
+			 	$out.= '<tr '.$bc[$var].'>
412 412
 		     			<td colspan="4" align="right">
413 413
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
414 414
 		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
415 415
 		     			</td>
416 416
 		     			</tr>';
417 417
 				
418
-		     	$var=!$var;
419
-		     	$out.= '<tr '.$bc[$var].'>
418
+			 	$var=!$var;
419
+			 	$out.= '<tr '.$bc[$var].'>
420 420
 		     			<td colspan="4" align="right">
421 421
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
422 422
 		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
423 423
 		     			</td>
424 424
 		     			</tr>';
425 425
 		     	
426
-		     	$var=!$var;
427
-		     	$out.= '<tr '.$bc[$var].'>
426
+			 	$var=!$var;
427
+			 	$out.= '<tr '.$bc[$var].'>
428 428
 		     			<td colspan="4" align="right">
429 429
 		     				<label for="hideprices">'.$langs->trans('SubTotalhidePrice').'</label>
430 430
 		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
@@ -436,9 +436,9 @@  discard block
 block discarded – undo
436 436
 				if ( 
437 437
 					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
438 438
 					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
439
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
439
+					|| (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
440 440
 					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
441
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
441
+					|| (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
442 442
 					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
443 443
 				)
444 444
 				{
@@ -457,19 +457,19 @@  discard block
 block discarded – undo
457 457
 			}
458 458
 			
459 459
 		
460
-        return 1;
460
+		return 1;
461 461
 	} 
462 462
 	 
463
-    function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
464
-    {
463
+	function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
464
+	{
465 465
 		
466
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
467
-        {
466
+		if (in_array('invoicecard',explode(':',$parameters['context'])))
467
+		{
468 468
         	
469
-        }
469
+		}
470 470
 		
471
-        return 0;
472
-    }
471
+		return 0;
472
+	}
473 473
 	
474 474
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
475 475
 		global $conf;
@@ -518,11 +518,11 @@  discard block
 block discarded – undo
518 518
 	
519 519
 		if (
520 520
 				in_array('invoicecard',explode(':',$parameters['context']))
521
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
521
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
522 522
 				|| in_array('propalcard',explode(':',$parameters['context']))
523
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
523
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
524 524
 				|| in_array('ordercard',explode(':',$parameters['context']))
525
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
525
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
526 526
 				|| in_array('invoicereccard',explode(':',$parameters['context']))
527 527
 		) {
528 528
 			
@@ -601,20 +601,20 @@  discard block
 block discarded – undo
601 601
 				in_array('invoicecard',explode(':',$parameters['context']))
602 602
 				|| in_array('propalcard',explode(':',$parameters['context']))
603 603
 				|| in_array('ordercard',explode(':',$parameters['context']))
604
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
605
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
606
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
604
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
605
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
606
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
607 607
 			)
608
-	        {								
608
+			{								
609 609
 				if(in_array('invoicecard',explode(':',$parameters['context']))) {
610 610
 					$sessname = 'subtotal_hideInnerLines_facture';	
611 611
 					$sessname2 = 'subtotal_hidedetails_facture';
612 612
 					$sessname3 = 'subtotal_hideprices_facture';
613 613
 				}
614 614
 				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
615
-				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
616
-				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
617
-				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
615
+					$sessname = 'subtotal_hideInnerLines_facture_fournisseur';
616
+					$sessname2 = 'subtotal_hidedetails_facture_fournisseur';
617
+					$sessname3 = 'subtotal_hideprices_facture_fournisseur';
618 618
 				}
619 619
 				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
620 620
 					$sessname = 'subtotal_hideInnerLines_propal';
@@ -622,9 +622,9 @@  discard block
 block discarded – undo
622 622
 					$sessname3 = 'subtotal_hideprices_propal';
623 623
 				}
624 624
 				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
625
-				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
626
-				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
627
-				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
625
+					$sessname = 'subtotal_hideInnerLines_supplier_proposal';
626
+					$sessname2 = 'subtotal_hidedetails_supplier_proposal';
627
+					$sessname3 = 'subtotal_hideprices_supplier_proposal';
628 628
 				}
629 629
 				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
630 630
 					$sessname = 'subtotal_hideInnerLines_commande';
@@ -632,9 +632,9 @@  discard block
 block discarded – undo
632 632
 					$sessname3 = 'subtotal_hideprices_commande';
633 633
 				}
634 634
 				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
635
-				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
636
-				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
637
-				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
635
+					$sessname = 'subtotal_hideInnerLines_commande_fournisseur';
636
+					$sessname2 = 'subtotal_hidedetails_commande_fournisseur';
637
+					$sessname3 = 'subtotal_hideprices_commande_fournisseur';
638 638
 				}
639 639
 				else {
640 640
 					$sessname = 'subtotal_hideInnerLines_unknown';
@@ -659,17 +659,17 @@  discard block
 block discarded – undo
659 659
 				foreach($object->lines as &$line) {
660 660
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
661 661
 					    
662
-                        if($line->qty>=90) {
663
-                            $line->modsubtotal_total = 1;
664
-                        }
665
-                        else{
666
-                            $line->modsubtotal_title = 1;
667
-                        }
662
+						if($line->qty>=90) {
663
+							$line->modsubtotal_total = 1;
664
+						}
665
+						else{
666
+							$line->modsubtotal_title = 1;
667
+						}
668 668
                         
669 669
 						$line->total_ht = $this->getTotalLineFromObject($object, $line, '');
670 670
 					}
671
-	        	}
672
-	        }
671
+				}
672
+			}
673 673
 			
674 674
 		}
675 675
 		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 				 */
687 687
 				else if($object->element=='invoice_supplier')
688 688
 				{
689
-				    $object->deleteline($idLine);
689
+					$object->deleteline($idLine);
690 690
 				}
691 691
 				/**
692 692
 				 * @var $object Propal
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 				 */
710 710
 				else if($object->element=='order_supplier')
711 711
 				{
712
-				    $object->deleteline($idLine);
712
+					$object->deleteline($idLine);
713 713
 				}
714 714
 				/**
715 715
 				 * @var $object Facturerec
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 		
781 781
 		foreach($object->lines as $l) {
782 782
 		
783
-		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
783
+			$lid = (!empty($l->rowid) ? $l->rowid : $l->id);
784 784
 			if($lid == $lineid) {
785 785
 
786 786
 				$found = true;
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 			
790 790
 			if($found) {
791 791
 				
792
-			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
792
+				$Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
793 793
 				
794 794
 				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
795 795
 					break; // end of story
@@ -868,17 +868,17 @@  discard block
 block discarded – undo
868 868
 			if($l->rang>=$rang) {
869 869
 				return price($total);
870 870
 			}
871
-                        if (TSubtotal::isSubtotal($l)){
872
-                            $total = 0;
873
-                        } else  if ($l->situation_percent > 0 ){
871
+						if (TSubtotal::isSubtotal($l)){
872
+							$total = 0;
873
+						} else  if ($l->situation_percent > 0 ){
874 874
                            
875 875
         	
876 876
 		 	$prev_progress = $l->get_prev_progress($object->id);
877 877
 		 	$progress = ($l->situation_percent - $prev_progress) /100;
878
-                        $total += ($l->total_ht/($l->situation_percent/100)) * $progress;
878
+						$total += ($l->total_ht/($l->situation_percent/100)) * $progress;
879 879
                         
880
-                    }
881
-                }
880
+					}
881
+				}
882 882
                 
883 883
 		return price($total);
884 884
 	}
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
 		if(method_exists('Closure','bind')) {
911 911
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
912 912
 			$sweetsThief = function ($pdf) {
913
-		    		return $pdf->bMargin ;
913
+					return $pdf->bMargin ;
914 914
 			};
915 915
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
916 916
 	
@@ -973,11 +973,11 @@  discard block
 block discarded – undo
973 973
 				else
974 974
 				{
975 975
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
976
-                                        if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
977
-                                                $total_to_print = $this->getTotalToPrintSituation($object, $line);
978
-                                        } else {
979
-                                            	$total_to_print = price($total);
980
-                                        }
976
+										if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
977
+												$total_to_print = $this->getTotalToPrintSituation($object, $line);
978
+										} else {
979
+												$total_to_print = price($total);
980
+										}
981 981
                                             
982 982
 					$line->total_ht = $total;
983 983
 					$line->total = $total;
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
 	}
1129 1129
 	
1130 1130
 	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1131
-	    global $conf, $hideprices, $hookmanager;
1131
+		global $conf, $hideprices, $hookmanager;
1132 1132
 		
1133 1133
 		if(is_array($parameters)) $i = & $parameters['i'];
1134 1134
 		else $i = (int)$parameters;
@@ -1167,7 +1167,7 @@  discard block
 block discarded – undo
1167 1167
 			}
1168 1168
 		}
1169 1169
 		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1170
-		    $this->resprints = price($object->lines[$i]->total_ht);
1170
+			$this->resprints = price($object->lines[$i]->total_ht);
1171 1171
 		}
1172 1172
 		
1173 1173
 		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
@@ -1296,7 +1296,7 @@  discard block
 block discarded – undo
1296 1296
 	}
1297 1297
 	
1298 1298
 	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1299
-	    global $conf,$hideprices,$hookmanager, $TTotal, $show_reduc;
1299
+		global $conf,$hideprices,$hookmanager, $TTotal, $show_reduc;
1300 1300
 
1301 1301
 		if(is_array($parameters)) $i = & $parameters['i'];
1302 1302
 		else $i = (int)$parameters;
@@ -1304,22 +1304,22 @@  discard block
 block discarded – undo
1304 1304
 		if($this->isModSubtotalLine($parameters,$object) ) {
1305 1305
 			$this->resprints = ' ';
1306 1306
 
1307
-            $line = $object->lines[$i];
1307
+			$line = $object->lines[$i];
1308 1308
 
1309
-            // On récupère les montants du bloc...
1310
-            if(TSubtotal::isTitle($line)) {
1309
+			// On récupère les montants du bloc...
1310
+			if(TSubtotal::isTitle($line)) {
1311 1311
 //                $show_reduc = $line->array_options['options_show_reduc'];
1312
-                if(! empty($line->array_options['options_show_total_ht'])) $TTotal = TSubtotal::getTotalBlockFromTitle($object, $line);
1312
+				if(! empty($line->array_options['options_show_total_ht'])) $TTotal = TSubtotal::getTotalBlockFromTitle($object, $line);
1313 1313
 //                if(! empty($show_reduc)) $object->lines[$i]->remise_percent = 1;
1314
-            }
1314
+			}
1315 1315
 
1316
-            // ... pour les afficher dans la ligne de sous-total
1317
-            if(TSubtotal::isSubtotal($line) && ! empty($TTotal['total_subprice'])) {
1316
+			// ... pour les afficher dans la ligne de sous-total
1317
+			if(TSubtotal::isSubtotal($line) && ! empty($TTotal['total_subprice'])) {
1318 1318
 //                if(! empty($show_reduc)) $object->lines[$i]->remise_percent = 1;
1319
-                $this->resprints = price($TTotal['total_subprice']);
1320
-                $TTotal = array();
1321
-                $show_reduc = 0;
1322
-            }
1319
+				$this->resprints = price($TTotal['total_subprice']);
1320
+				$TTotal = array();
1321
+				$show_reduc = 0;
1322
+			}
1323 1323
 		
1324 1324
 			if((float)DOL_VERSION<=3.6) {
1325 1325
 				return '';
@@ -1335,56 +1335,56 @@  discard block
 block discarded – undo
1335 1335
 		(!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))
1336 1336
 		)
1337 1337
 		{
1338
-		    // alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1339
-		    if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1340
-		    {
1341
-		        $this->resprints = ' ';
1338
+			// alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1339
+			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1340
+			{
1341
+				$this->resprints = ' ';
1342 1342
 		        
1343
-		        // currentcontext à modifier celon l'appel
1344
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1345
-		        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)
1343
+				// currentcontext à modifier celon l'appel
1344
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1345
+				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)
1346 1346
 		        
1347
-		    }
1347
+			}
1348 1348
 		}
1349 1349
 		// Cache le prix pour les lignes standards dolibarr qui sont dans un ensemble
1350 1350
 		else if (!empty($hideprices))
1351 1351
 		{
1352 1352
 		    
1353
-		    // Check if a title exist for this line && if the title have subtotal
1354
-		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1355
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1356
-		    {
1353
+			// Check if a title exist for this line && if the title have subtotal
1354
+			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1355
+			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1356
+			{
1357 1357
 		        
1358
-		        $this->resprints = ' ';
1358
+				$this->resprints = ' ';
1359 1359
 		        
1360
-		        // currentcontext à modifier celon l'appel
1361
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1362
-		        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)
1363
-		    }
1360
+				// currentcontext à modifier celon l'appel
1361
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1362
+				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)
1363
+			}
1364 1364
 		}
1365 1365
 		
1366 1366
 		return 0;
1367 1367
 	}
1368 1368
 	
1369 1369
 	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1370
-	    global $conf,$hideprices,$hookmanager, $TTotal;
1370
+		global $conf,$hideprices,$hookmanager, $TTotal;
1371 1371
 
1372
-        if(is_array($parameters)) $i = & $parameters['i'];
1373
-        else $i = (int) $parameters;
1372
+		if(is_array($parameters)) $i = & $parameters['i'];
1373
+		else $i = (int) $parameters;
1374 1374
 
1375 1375
 		if($this->isModSubtotalLine($parameters,$object) ) {
1376 1376
 			$this->resprints = ' ';
1377 1377
 
1378
-            $line = $object->lines[$i];
1378
+			$line = $object->lines[$i];
1379 1379
 
1380
-            // Affichage de la remise 
1381
-            if(TSubtotal::isSubtotal($line)) {
1382
-                $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1383
-                $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1380
+			// Affichage de la remise 
1381
+			if(TSubtotal::isSubtotal($line)) {
1382
+				$parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1383
+				$TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1384 1384
 
1385
-                if(! empty($parentTitle->array_options['options_show_reduc'])) $this->resprints = price($TTotal['total_ht'] / $TTotal['total_subprice']*100, 0, '', 1, 2, 2).'%';
1386
-                $TTotal = array();
1387
-            }
1385
+				if(! empty($parentTitle->array_options['options_show_reduc'])) $this->resprints = price($TTotal['total_ht'] / $TTotal['total_subprice']*100, 0, '', 1, 2, 2).'%';
1386
+				$TTotal = array();
1387
+			}
1388 1388
 		
1389 1389
 			if((float)DOL_VERSION<=3.6) {
1390 1390
 				return '';
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
 	}
1429 1429
 	
1430 1430
 	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
1431
-	    global $conf,$hideprices,$hookmanager;
1431
+		global $conf,$hideprices,$hookmanager;
1432 1432
 	    
1433 1433
 		if($this->isModSubtotalLine($parameters,$object) ){
1434 1434
 			$this->resprints = ' ';
@@ -1453,31 +1453,31 @@  discard block
 block discarded – undo
1453 1453
 		(!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))
1454 1454
 		)
1455 1455
 		{
1456
-		    // alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1457
-		    if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1458
-		    {
1459
-		        $this->resprints = ' ';
1456
+			// alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1457
+			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1458
+			{
1459
+				$this->resprints = ' ';
1460 1460
 		        
1461
-		        // currentcontext à modifier celon l'appel
1462
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1463
-		        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)
1464
-		    }
1461
+				// currentcontext à modifier celon l'appel
1462
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1463
+				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)
1464
+			}
1465 1465
 		}
1466 1466
 		// Cache le prix pour les lignes standards dolibarr qui sont dans un ensemble
1467 1467
 		else if (!empty($hideprices))
1468 1468
 		{
1469 1469
 		    
1470
-		    // Check if a title exist for this line && if the title have subtotal
1471
-		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1472
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1473
-		    {
1470
+			// Check if a title exist for this line && if the title have subtotal
1471
+			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1472
+			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1473
+			{
1474 1474
 		        
1475
-		        $this->resprints = ' ';
1475
+				$this->resprints = ' ';
1476 1476
 		        
1477
-		        // currentcontext à modifier celon l'appel
1478
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1479
-		        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)
1480
-		    }
1477
+				// currentcontext à modifier celon l'appel
1478
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1479
+				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)
1480
+			}
1481 1481
 		}
1482 1482
 		
1483 1483
 		return 0;
@@ -1601,24 +1601,24 @@  discard block
 block discarded – undo
1601 1601
 		
1602 1602
 		$this->add_numerotation($object);	
1603 1603
 		
1604
-        foreach($object->lines as $k => &$l) {
1605
-            if(TSubtotal::isSubtotal($l)) {
1606
-                $parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1607
-                if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_total_ht'])) {
1608
-                    $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1609
-                }
1610
-            }
1611
-        }
1604
+		foreach($object->lines as $k => &$l) {
1605
+			if(TSubtotal::isSubtotal($l)) {
1606
+				$parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1607
+				if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_total_ht'])) {
1608
+					$l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1609
+				}
1610
+			}
1611
+		}
1612 1612
 
1613 1613
 		$hideInnerLines = (int)GETPOST('hideInnerLines');
1614 1614
 		$hidedetails = (int)GETPOST('hidedetails');
1615 1615
 
1616 1616
 		if ($hideInnerLines) { // si c une ligne de titre
1617
-	    	$fk_parent_line=0;
1617
+			$fk_parent_line=0;
1618 1618
 			$TLines =array();
1619 1619
 		
1620 1620
 			$original_count=count($object->lines);
1621
-		    $TTvas = array(); // tableau de tva
1621
+			$TTvas = array(); // tableau de tva
1622 1622
 		    
1623 1623
 			foreach($object->lines as $k=>&$line) 
1624 1624
 			{
@@ -1657,48 +1657,48 @@  discard block
 block discarded – undo
1657 1657
 			
1658 1658
 				if ($hideInnerLines)
1659 1659
 				{
1660
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1661
-				    {
1662
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1660
+					if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1661
+					{
1662
+						if($line->tva_tx != '0.000' && $line->product_type!=9){
1663 1663
 				            
1664
-    				        // on remplit le tableau de tva pour substituer les lignes cachées
1665
-    				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1666
-    				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1667
-    				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1668
-    				    }
1669
-    					if($line->product_type==9 && $line->rowid>0)
1670
-    					{
1671
-    					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1672
-    					    // génère des lignes d'affichage des montants HT soumis à tva
1673
-    					    $nbtva = count($TTvas);
1674
-    					    if(!empty($nbtva)){
1675
-    					        foreach ($TTvas as $tx =>$val){
1676
-    					            $l = clone $line;
1677
-    					            $l->product_type = 1;
1678
-    					            $l->special_code = '';
1679
-    					            $l->qty = 1;
1680
-    					            $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1681
-    					            $l->tva_tx = $tx;
1682
-    					            $l->total_ht = $val['total_ht'];
1683
-    					            $l->total_tva = $val['total_tva'];
1684
-    					            $l->total = $line->total_ht;
1685
-    					            $l->total_ttc = $val['total_ttc'];
1686
-    					            $TLines[] = $l;
1687
-    					            array_shift($TTvas);
1688
-    					       }
1689
-    					    }
1664
+							// on remplit le tableau de tva pour substituer les lignes cachées
1665
+							$TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1666
+							$TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1667
+							$TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1668
+						}
1669
+						if($line->product_type==9 && $line->rowid>0)
1670
+						{
1671
+							//Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1672
+							// génère des lignes d'affichage des montants HT soumis à tva
1673
+							$nbtva = count($TTvas);
1674
+							if(!empty($nbtva)){
1675
+								foreach ($TTvas as $tx =>$val){
1676
+									$l = clone $line;
1677
+									$l->product_type = 1;
1678
+									$l->special_code = '';
1679
+									$l->qty = 1;
1680
+									$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1681
+									$l->tva_tx = $tx;
1682
+									$l->total_ht = $val['total_ht'];
1683
+									$l->total_tva = $val['total_tva'];
1684
+									$l->total = $line->total_ht;
1685
+									$l->total_ttc = $val['total_ttc'];
1686
+									$TLines[] = $l;
1687
+									array_shift($TTvas);
1688
+							   }
1689
+							}
1690 1690
     					    
1691
-    					    // ajoute la ligne de sous-total
1692
-    					    $TLines[] = $line; 
1693
-    					}
1694
-				    } else {
1691
+							// ajoute la ligne de sous-total
1692
+							$TLines[] = $line; 
1693
+						}
1694
+					} else {
1695 1695
 				        
1696
-				        if($line->product_type==9 && $line->rowid>0)
1697
-				        {
1698
-				            // ajoute la ligne de sous-total
1699
-				            $TLines[] = $line; 
1700
-				        }
1701
-				    }
1696
+						if($line->product_type==9 && $line->rowid>0)
1697
+						{
1698
+							// ajoute la ligne de sous-total
1699
+							$TLines[] = $line; 
1700
+						}
1701
+					}
1702 1702
 				    
1703 1703
 					
1704 1704
 				}
@@ -1723,20 +1723,20 @@  discard block
 block discarded – undo
1723 1723
 			$nbtva = count($TTvas);
1724 1724
 			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1725 1725
 			{
1726
-			    foreach ($TTvas as $tx =>$val){
1727
-			        $l = clone $line;
1728
-			        $l->product_type = 1;
1729
-			        $l->special_code = '';
1730
-			        $l->qty = 1;
1731
-			        $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1732
-			        $l->tva_tx = $tx;
1733
-			        $l->total_ht = $val['total_ht'];
1734
-			        $l->total_tva = $val['total_tva'];
1735
-			        $l->total = $line->total_ht;
1736
-			        $l->total_ttc = $val['total_ttc'];
1737
-			        $TLines[] = $l;
1738
-			        array_shift($TTvas);
1739
-			    }
1726
+				foreach ($TTvas as $tx =>$val){
1727
+					$l = clone $line;
1728
+					$l->product_type = 1;
1729
+					$l->special_code = '';
1730
+					$l->qty = 1;
1731
+					$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1732
+					$l->tva_tx = $tx;
1733
+					$l->total_ht = $val['total_ht'];
1734
+					$l->total_tva = $val['total_tva'];
1735
+					$l->total = $line->total_ht;
1736
+					$l->total_ttc = $val['total_ttc'];
1737
+					$TLines[] = $l;
1738
+					array_shift($TTvas);
1739
+				}
1740 1740
 			}
1741 1741
 			
1742 1742
 			global $nblignes;
@@ -1748,7 +1748,7 @@  discard block
 block discarded – undo
1748 1748
 				$this->resprints = '';
1749 1749
 				return 0;
1750 1750
 			}
1751
-	    }
1751
+		}
1752 1752
 		
1753 1753
 		return 0;
1754 1754
 	}
@@ -1911,18 +1911,18 @@  discard block
 block discarded – undo
1911 1911
 		}
1912 1912
 		elseif($object->element == 'order_supplier' )
1913 1913
 		{
1914
-		    $createRight = $user->rights->fournisseur->commande->creer;
1914
+			$createRight = $user->rights->fournisseur->commande->creer;
1915 1915
 		}
1916 1916
 		elseif($object->element == 'invoice_supplier' )
1917 1917
 		{
1918
-		    $createRight = $user->rights->fournisseur->facture->creer;
1918
+			$createRight = $user->rights->fournisseur->facture->creer;
1919 1919
 		}
1920 1920
 		
1921 1921
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1922 1922
 			null;
1923 1923
 		}	
1924 1924
 		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)) 
1925
-        {
1925
+		{
1926 1926
 			if($object->element=='facture')$idvar = 'facid';
1927 1927
 			else $idvar='id';
1928 1928
 			
@@ -1969,7 +1969,7 @@  discard block
 block discarded – undo
1969 1969
 			//var_dump($line);
1970 1970
             
1971 1971
 			// HTML 5 data for js
1972
-            $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
1972
+			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
1973 1973
             
1974 1974
 			
1975 1975
 			?>
@@ -2027,8 +2027,8 @@  discard block
 block discarded – undo
2027 2027
 						}
2028 2028
 						
2029 2029
 						if ($object->element == 'order_supplier' || $object->element == 'invoice_supplier') {
2030
-						    $line->label = !empty($line->description) ? $line->description : $line->desc;
2031
-						    $line->description = '';
2030
+							$line->label = !empty($line->description) ? $line->description : $line->desc;
2031
+							$line->description = '';
2032 2032
 						}
2033 2033
 						$newlabel = $line->label;
2034 2034
 						if($line->label=='' && !$isFreeText) {
@@ -2062,38 +2062,38 @@  discard block
 block discarded – undo
2062 2062
 						
2063 2063
 
2064 2064
 						echo '<div class="subtotal_underline" style="margin-left:24px; line-height: 25px;">';
2065
-                        echo '<div>';
2066
-                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2067
-                        echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2068
-                        echo '</div>';
2069
-
2070
-                        if (TSubtotal::isTitle($line))
2071
-                        {
2072
-                            $form = new Form($db);
2073
-                            echo '<div>';
2074
-                            echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2075
-                            echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2076
-                            if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2077
-                            echo '</select>';
2078
-                            echo '</div>';
2079
-
2080
-                            if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
2081
-                            {
2082
-                                echo '<div>';
2083
-                                echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%';
2084
-                                echo '</div>';
2085
-                            }
2086
-                            echo '<div>';
2087
-                            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;';
2088
-                            echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2089
-                            echo '</div>';
2090
-
2091
-                            echo '<div>';
2092
-                            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;';
2093
-                            echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2094
-                            echo '</div>';
2095
-                        }
2096
-                        else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2065
+						echo '<div>';
2066
+						echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2067
+						echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2068
+						echo '</div>';
2069
+
2070
+						if (TSubtotal::isTitle($line))
2071
+						{
2072
+							$form = new Form($db);
2073
+							echo '<div>';
2074
+							echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2075
+							echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2076
+							if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2077
+							echo '</select>';
2078
+							echo '</div>';
2079
+
2080
+							if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
2081
+							{
2082
+								echo '<div>';
2083
+								echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%';
2084
+								echo '</div>';
2085
+							}
2086
+							echo '<div>';
2087
+							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;';
2088
+							echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2089
+							echo '</div>';
2090
+
2091
+							echo '<div>';
2092
+							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;';
2093
+							echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2094
+							echo '</div>';
2095
+						}
2096
+						else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2097 2097
 						echo '</div>';
2098 2098
 
2099 2099
 						if($line->qty<10) {
@@ -2335,17 +2335,17 @@  discard block
 block discarded – undo
2335 2335
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2336 2336
 		{
2337 2337
 		    
2338
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2339
-		    {
2340
-		        foreach ($object->lines as $line)
2341
-		        {
2342
-		            // fetch optionals attributes and labels
2343
-		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2344
-		            $extrafields=new ExtraFields($this->db);
2345
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2346
-		            $line->fetch_optionals($line->id,$extralabels);
2347
-		        }
2348
-		    }
2338
+			if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2339
+			{
2340
+				foreach ($object->lines as $line)
2341
+				{
2342
+					// fetch optionals attributes and labels
2343
+					require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2344
+					$extrafields=new ExtraFields($this->db);
2345
+					$extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2346
+					$line->fetch_optionals($line->id,$extralabels);
2347
+				}
2348
+			}
2349 2349
 		    
2350 2350
 			$TSubNc = array();
2351 2351
 			foreach ($object->lines as &$l)
@@ -2436,80 +2436,80 @@  discard block
 block discarded – undo
2436 2436
 	{
2437 2437
 		dol_include_once('/subtotal/class/subtotal.class.php');
2438 2438
 
2439
-	    $line = &$parameters['line'];
2439
+		$line = &$parameters['line'];
2440 2440
 	    
2441
-	    $ThtmlData['data-id']           = $line->id;
2442
-	    $ThtmlData['data-product_type'] = $line->product_type;
2443
-	    $ThtmlData['data-qty']          = 0; //$line->qty;
2444
-	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2441
+		$ThtmlData['data-id']           = $line->id;
2442
+		$ThtmlData['data-product_type'] = $line->product_type;
2443
+		$ThtmlData['data-qty']          = 0; //$line->qty;
2444
+		$ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2445 2445
 	    
2446
-	    if(TSubtotal::isTitle($line)){
2447
-	        $ThtmlData['data-issubtotal'] = 'title';
2448
-	    }elseif(TSubtotal::isSubtotal($line)){
2449
-	        $ThtmlData['data-issubtotal'] = 'subtotal';
2450
-	    }
2451
-	    else{
2452
-	        $ThtmlData['data-issubtotal'] = 'freetext';
2453
-	    }
2446
+		if(TSubtotal::isTitle($line)){
2447
+			$ThtmlData['data-issubtotal'] = 'title';
2448
+		}elseif(TSubtotal::isSubtotal($line)){
2449
+			$ThtmlData['data-issubtotal'] = 'subtotal';
2450
+		}
2451
+		else{
2452
+			$ThtmlData['data-issubtotal'] = 'freetext';
2453
+		}
2454 2454
 	    
2455 2455
 	    
2456
-	    // Change or add data  from hooks
2457
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2456
+		// Change or add data  from hooks
2457
+		$parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2458 2458
 	    
2459
-	    // hook 
2460
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2461
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2462
-	    if ($reshook>0)
2463
-	    {
2464
-	        $ThtmlData = $hookmanager->resArray;
2465
-	    }
2466
-
2467
-	    return $this->implodeHtmlData($ThtmlData);
2459
+		// hook 
2460
+		$reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2461
+		if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2462
+		if ($reshook>0)
2463
+		{
2464
+			$ThtmlData = $hookmanager->resArray;
2465
+		}
2466
+
2467
+		return $this->implodeHtmlData($ThtmlData);
2468 2468
 	
2469 2469
 	}
2470 2470
 	
2471 2471
 	
2472 2472
 	function implodeHtmlData($ThtmlData = array())
2473 2473
 	{
2474
-	    $data = '';
2475
-	    foreach($ThtmlData as $k => $h )
2476
-	    {
2477
-	        if(is_array($h))
2478
-	        {
2479
-	            $h = json_encode($h);
2480
-	        }
2474
+		$data = '';
2475
+		foreach($ThtmlData as $k => $h )
2476
+		{
2477
+			if(is_array($h))
2478
+			{
2479
+				$h = json_encode($h);
2480
+			}
2481 2481
 	        
2482
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2483
-	    }
2482
+			$data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2483
+		}
2484 2484
 	    
2485
-	    return $data;
2485
+		return $data;
2486 2486
 	}
2487 2487
 	
2488 2488
 	function _ajax_block_order_js($object)
2489 2489
 	{
2490
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2490
+		global $conf,$tagidfortablednd,$filepath,$langs;
2491 2491
 	    
2492
-	    /*
2492
+		/*
2493 2493
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2494 2494
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2495 2495
 	     */
2496 2496
 	    
2497
-	    $id=$object->id;
2498
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2499
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2497
+		$id=$object->id;
2498
+		$nboflines=(isset($object->lines)?count($object->lines):0);
2499
+		$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2500 2500
 	    
2501
-	    $id=$object->id;
2502
-	    $fk_element=$object->fk_element;
2503
-	    $table_element_line=$object->table_element_line;
2504
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2505
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2506
-	    $filepath=(empty($filepath)?'':$filepath);
2501
+		$id=$object->id;
2502
+		$fk_element=$object->fk_element;
2503
+		$table_element_line=$object->table_element_line;
2504
+		$nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2505
+		$tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2506
+		$filepath=(empty($filepath)?'':$filepath);
2507 2507
 	    
2508 2508
 	    
2509
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2510
-	    {
2509
+		if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2510
+		{
2511 2511
 	        
2512
-	        ?>
2512
+			?>
2513 2513
 		
2514 2514
 		
2515 2515
 			<script type="text/javascript">
Please login to merge, or discard this patch.
Spacing   +409 added lines, -409 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,43 +105,43 @@  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)) {
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)) {
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 128
 			
129
-			if ($object->statut == 0  && $createRight) {
129
+			if ($object->statut == 0 && $createRight) {
130 130
 			
131 131
 
132
-				if($object->element=='facture')$idvar = 'facid';
133
-				else $idvar='id';
132
+				if ($object->element == 'facture')$idvar = 'facid';
133
+				else $idvar = 'id';
134 134
 				
135
-				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
135
+				if (in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')))
136 136
 				{
137 137
 					$level = GETPOST('level', 'int'); //New avec SUBTOTAL_USE_NEW_FORMAT
138 138
 					
139
-					if($action=='add_title_line') {
139
+					if ($action == 'add_title_line') {
140 140
 						$title = GETPOST('title');
141
-						if(empty($title)) $title = $langs->trans('title');
142
-						$qty = $level<1 ? 1 : $level ;
141
+						if (empty($title)) $title = $langs->trans('title');
142
+						$qty = $level < 1 ? 1 : $level;
143 143
 					}
144
-					else if($action=='add_free_text') {
144
+					else if ($action == 'add_free_text') {
145 145
 						$title = GETPOST('title');
146 146
 
147 147
 						if (empty($title)) {
@@ -153,21 +153,21 @@  discard block
 block discarded – undo
153 153
 								}
154 154
 							}
155 155
 						}
156
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
156
+						if (empty($title)) $title = $langs->trans('subtotalAddLineDescription');
157 157
 						$qty = 50;
158 158
 					}
159
-					else if($action=='add_subtitle_line') {
159
+					else if ($action == 'add_subtitle_line') {
160 160
 						$title = GETPOST('title');
161
-						if(empty($title)) $title = $langs->trans('subtitle');
161
+						if (empty($title)) $title = $langs->trans('subtitle');
162 162
 						$qty = 2;
163 163
 					}
164
-					else if($action=='add_subtotal_line') {
164
+					else if ($action == 'add_subtotal_line') {
165 165
 						$title = $langs->trans('SubSubTotal');
166 166
 						$qty = 98;
167 167
 					}
168 168
 					else {
169 169
 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
170
-						$qty = $level ? 100-$level : 99;
170
+						$qty = $level ? 100 - $level : 99;
171 171
 					}
172 172
 					dol_include_once('/subtotal/class/subtotal.class.php');
173 173
 					
@@ -175,15 +175,15 @@  discard block
 block discarded – undo
175 175
 					
176 176
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
177 177
 				}
178
-				else if($action==='ask_deleteallline') {
179
-						$form=new Form($db);
178
+				else if ($action === 'ask_deleteallline') {
179
+						$form = new Form($db);
180 180
 						
181
-						$lineid = GETPOST('lineid','integer');
181
+						$lineid = GETPOST('lineid', 'integer');
182 182
 						$TIdForGroup = $this->getArrayOfLineForAGroup($object, $lineid);
183 183
 					
184 184
 						$nbLines = count($TIdForGroup);
185 185
 					
186
-						$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines',$nbLines), 'confirm_delete_all_lines','',0,1);
186
+						$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines', $nbLines), 'confirm_delete_all_lines', '', 0, 1);
187 187
 						print $formconfirm;
188 188
 				}
189 189
 
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
 				}
194 194
 
195 195
 				
196
-				if($action!='editline') {
196
+				if ($action != 'editline') {
197 197
 					// New format is for 3.8
198 198
 					$this->printNewFormat($object, $conf, $langs, $idvar);
199 199
 				}
200 200
 			}
201 201
 		}
202
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
202
+		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice', $contexts))
203 203
 		{
204 204
 			?>
205 205
 			<script type="text/javascript">
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 				$(document).ready(function() {
225 225
 					$('div.fiche div.tabsAction').append('<br />');
226 226
 					
227
-					$('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>');
227
+					$('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>');
228 228
 					$('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>');
229 229
 					$('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>');
230 230
 
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 						$('body').append(dialog_html);
276 276
 
277 277
 						<?php 
278
-						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME)?'ckeditor':$conf->global->FCKEDITOR_EDITORNAME;
279
-						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
280
-						if($editorConf && in_array($editorTool,array('textarea','ckeditor'))){ 
278
+						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME) ? 'ckeditor' : $conf->global->FCKEDITOR_EDITORNAME;
279
+						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
280
+						if ($editorConf && in_array($editorTool, array('textarea', 'ckeditor'))) { 
281 281
 						?>
282 282
 						if (action == 'addTitle' || action == 'addFreeTxt')
283 283
 						{
@@ -392,62 +392,62 @@  discard block
 block discarded – undo
392 392
 		global $conf, $langs, $bc;
393 393
 			
394 394
 		$action = GETPOST('action');	
395
-		$TContext = explode(':',$parameters['context']);
395
+		$TContext = explode(':', $parameters['context']);
396 396
 		if (
397
-				in_array('invoicecard',$TContext)
398
-		        || in_array('invoicesuppliercard',$TContext)
399
-				|| in_array('propalcard',$TContext)
400
-				|| in_array('ordercard',$TContext)
401
-		        || in_array('ordersuppliercard',$TContext)
402
-				|| in_array('invoicereccard',$TContext)
397
+				in_array('invoicecard', $TContext)
398
+		        || in_array('invoicesuppliercard', $TContext)
399
+				|| in_array('propalcard', $TContext)
400
+				|| in_array('ordercard', $TContext)
401
+		        || in_array('ordersuppliercard', $TContext)
402
+				|| in_array('invoicereccard', $TContext)
403 403
 			)
404 404
 	        {	
405
-	            $hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
406
-	            $hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
407
-				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0;
408
-				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
405
+	            $hideInnerLines = isset($_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
406
+	            $hidedetails = isset($_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
407
+				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED) ? $conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED : 0;
408
+				$hideprices = isset($_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
409 409
 				
410
-				$var=false;
411
-		     	$out.= '<tr '.$bc[$var].'>
410
+				$var = false;
411
+		     	$out .= '<tr '.$bc[$var].'>
412 412
 		     			<td colspan="4" align="right">
413 413
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
414
-		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
414
+		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(($hideInnerLines) ? 'checked="checked"' : '').' />
415 415
 		     			</td>
416 416
 		     			</tr>';
417 417
 				
418
-		     	$var=!$var;
419
-		     	$out.= '<tr '.$bc[$var].'>
418
+		     	$var = !$var;
419
+		     	$out .= '<tr '.$bc[$var].'>
420 420
 		     			<td colspan="4" align="right">
421 421
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
422
-		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
422
+		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(($hidedetails) ? 'checked="checked"' : '').' />
423 423
 		     			</td>
424 424
 		     			</tr>';
425 425
 		     	
426
-		     	$var=!$var;
427
-		     	$out.= '<tr '.$bc[$var].'>
426
+		     	$var = !$var;
427
+		     	$out .= '<tr '.$bc[$var].'>
428 428
 		     			<td colspan="4" align="right">
429 429
 		     				<label for="hideprices">'.$langs->trans('SubTotalhidePrice').'</label>
430
-		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
430
+		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(($hideprices) ? 'checked="checked"' : '').' />
431 431
 		     			</td>
432 432
 		     			</tr>';
433 433
 		     	
434 434
 		     	
435 435
 				 
436 436
 				if ( 
437
-					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
438
-					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
439
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
440
-					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
441
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
442
-					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
437
+					(in_array('propalcard', $TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
438
+					|| (in_array('ordercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
439
+				    || (in_array('ordersuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
440
+					|| (in_array('invoicecard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
441
+				    || (in_array('invoicesuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
442
+					|| (in_array('invoicereccard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
443 443
 				)
444 444
 				{
445
-					$var=!$var;
446
-					$out.= '
445
+					$var = !$var;
446
+					$out .= '
447 447
 						<tr '.$bc[$var].'>
448 448
 							<td colspan="4" align="right">
449 449
 								<label for="subtotal_add_recap">'.$langs->trans('subtotal_add_recap').'</label>
450
-								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.( GETPOST('subtotal_add_recap') ? 'checked="checked"' : '' ).' />
450
+								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.(GETPOST('subtotal_add_recap') ? 'checked="checked"' : '').' />
451 451
 							</td>
452 452
 						</tr>';
453 453
 				}
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
     function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
464 464
     {
465 465
 		
466
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
466
+    	if (in_array('invoicecard', explode(':', $parameters['context'])))
467 467
         {
468 468
         	
469 469
         }
@@ -474,13 +474,13 @@  discard block
 block discarded – undo
474 474
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
475 475
 		global $conf;
476 476
 		
477
-		if($action === 'builddoc') {
477
+		if ($action === 'builddoc') {
478 478
 			
479 479
 			$line = &$parameters['line'];
480 480
 			$object = &$parameters['object'];
481 481
 			$substitutionarray = &$parameters['substitutionarray'];
482 482
 			
483
-			if($line->product_type == 9 && $line->special_code == $this->module_number) {
483
+			if ($line->product_type == 9 && $line->special_code == $this->module_number) {
484 484
 				$substitutionarray['line_modsubtotal'] = 1;	
485 485
 				
486 486
 				$substitutionarray['line_price_ht']
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 					 = $substitutionarray['line_up'] 
492 492
 					 = '';
493 493
 				
494
-				if($line->qty>90) {
494
+				if ($line->qty > 90) {
495 495
 					$substitutionarray['line_modsubtotal_total'] = true;
496 496
 					
497 497
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 				
506 506
 				
507 507
 			}	
508
-			else{
508
+			else {
509 509
 				$substitutionarray['line_not_modsubtotal'] = true;
510 510
 				$substitutionarray['line_modsubtotal'] = 0;
511 511
 			}
@@ -517,29 +517,29 @@  discard block
 block discarded – undo
517 517
 	function createFrom($parameters, &$object, $action, $hookmanager) {
518 518
 	
519 519
 		if (
520
-				in_array('invoicecard',explode(':',$parameters['context']))
521
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
522
-				|| in_array('propalcard',explode(':',$parameters['context']))
523
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
524
-				|| in_array('ordercard',explode(':',$parameters['context']))
525
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
526
-				|| in_array('invoicereccard',explode(':',$parameters['context']))
520
+				in_array('invoicecard', explode(':', $parameters['context']))
521
+		        || in_array('invoicesuppliercard', explode(':', $parameters['context']))
522
+				|| in_array('propalcard', explode(':', $parameters['context']))
523
+		        || in_array('supplier_proposalcard', explode(':', $parameters['context']))
524
+				|| in_array('ordercard', explode(':', $parameters['context']))
525
+		        || in_array('ordersuppliercard', explode(':', $parameters['context']))
526
+				|| in_array('invoicereccard', explode(':', $parameters['context']))
527 527
 		) {
528 528
 			
529 529
 			global $db;
530 530
 			
531 531
 			$objFrom = $parameters['objFrom'];
532 532
 			
533
-			foreach($objFrom->lines as $k=> &$lineOld) {
533
+			foreach ($objFrom->lines as $k=> &$lineOld) {
534 534
 				
535
-					if($lineOld->product_type == 9 && $lineOld->info_bits > 0 ) {
535
+					if ($lineOld->product_type == 9 && $lineOld->info_bits > 0) {
536 536
 							
537 537
 							$line = & $object->lines[$k];
538 538
 				
539 539
 							$idLine = (int) ($line->id ? $line->id : $line->rowid); 
540 540
 				
541 541
 							$db->query("UPDATE ".MAIN_DB_PREFIX.$line->table_element."
542
-							SET info_bits=".(int)$lineOld->info_bits."
542
+							SET info_bits=".(int) $lineOld->info_bits."
543 543
 							WHERE rowid = ".$idLine."
544 544
 							");
545 545
 						
@@ -555,15 +555,15 @@  discard block
 block discarded – undo
555 555
 	
556 556
 	function doActions($parameters, &$object, $action, $hookmanager)
557 557
 	{
558
-		global $db, $conf, $langs,$user;
558
+		global $db, $conf, $langs, $user;
559 559
 		
560 560
 		dol_include_once('/subtotal/class/subtotal.class.php');
561 561
 		dol_include_once('/subtotal/lib/subtotal.lib.php');
562
-		require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
562
+		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
563 563
 		
564 564
 		$showBlockExtrafields = GETPOST('showBlockExtrafields');
565 565
 		
566
-		if($object->element=='facture') $idvar = 'facid';
566
+		if ($object->element == 'facture') $idvar = 'facid';
567 567
 		else $idvar = 'id';
568 568
 			
569 569
 		if ($action == 'updateligne' || $action == 'updateline')
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 				if ($line->id == $lineid && TSubtotal::isModSubtotalLine($line))
577 577
 				{
578 578
 					$found = true;
579
-					if(TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
579
+					if (TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
580 580
 						$extrafieldsline = new ExtraFields($db);
581 581
 						$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
582 582
 						$extrafieldsline->setOptionalsFromPost($extralabelsline, $line);
@@ -595,43 +595,43 @@  discard block
 block discarded – undo
595 595
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
596 596
 			}
597 597
 		}
598
-		else if($action === 'builddoc') {
598
+		else if ($action === 'builddoc') {
599 599
 			
600 600
 			if (
601
-				in_array('invoicecard',explode(':',$parameters['context']))
602
-				|| in_array('propalcard',explode(':',$parameters['context']))
603
-				|| in_array('ordercard',explode(':',$parameters['context']))
604
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
605
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
606
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
601
+				in_array('invoicecard', explode(':', $parameters['context']))
602
+				|| in_array('propalcard', explode(':', $parameters['context']))
603
+				|| in_array('ordercard', explode(':', $parameters['context']))
604
+			    || in_array('ordersuppliercard', explode(':', $parameters['context']))
605
+			    || in_array('invoicesuppliercard', explode(':', $parameters['context']))
606
+			    || in_array('supplier_proposalcard', explode(':', $parameters['context']))
607 607
 			)
608 608
 	        {								
609
-				if(in_array('invoicecard',explode(':',$parameters['context']))) {
609
+				if (in_array('invoicecard', explode(':', $parameters['context']))) {
610 610
 					$sessname = 'subtotal_hideInnerLines_facture';	
611 611
 					$sessname2 = 'subtotal_hidedetails_facture';
612 612
 					$sessname3 = 'subtotal_hideprices_facture';
613 613
 				}
614
-				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
614
+				elseif (in_array('invoicesuppliercard', explode(':', $parameters['context']))) {
615 615
 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
616 616
 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
617 617
 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
618 618
 				}
619
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
619
+				elseif (in_array('propalcard', explode(':', $parameters['context']))) {
620 620
 					$sessname = 'subtotal_hideInnerLines_propal';
621 621
 					$sessname2 = 'subtotal_hidedetails_propal';	
622 622
 					$sessname3 = 'subtotal_hideprices_propal';
623 623
 				}
624
-				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
624
+				elseif (in_array('supplier_proposalcard', explode(':', $parameters['context']))) {
625 625
 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
626 626
 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
627 627
 				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
628 628
 				}
629
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
629
+				elseif (in_array('ordercard', explode(':', $parameters['context']))) {
630 630
 					$sessname = 'subtotal_hideInnerLines_commande';
631 631
 					$sessname2 = 'subtotal_hidedetails_commande';	
632 632
 					$sessname3 = 'subtotal_hideprices_commande';
633 633
 				}
634
-				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
634
+				elseif (in_array('ordersuppliercard', explode(':', $parameters['context']))) {
635 635
 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
636 636
 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
637 637
 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
@@ -644,25 +644,25 @@  discard block
 block discarded – undo
644 644
 					
645 645
 				global $hideprices;
646 646
 				
647
-				$hideInnerLines = (int)GETPOST('hideInnerLines');
648
-				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) $_SESSION[$sessname] = array(); // prevent old system
647
+				$hideInnerLines = (int) GETPOST('hideInnerLines');
648
+				if (!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id])) $_SESSION[$sessname] = array(); // prevent old system
649 649
 				$_SESSION[$sessname][$object->id] = $hideInnerLines;		
650 650
 				
651
-				$hidedetails= (int)GETPOST('hidedetails');
652
-				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) $_SESSION[$sessname2] = array(); // prevent old system
651
+				$hidedetails = (int) GETPOST('hidedetails');
652
+				if (!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id])) $_SESSION[$sessname2] = array(); // prevent old system
653 653
 				$_SESSION[$sessname2][$object->id] = $hidedetails;
654 654
 				
655
-				$hideprices= (int)GETPOST('hideprices');
656
-				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) $_SESSION[$sessname3] = array(); // prevent old system
655
+				$hideprices = (int) GETPOST('hideprices');
656
+				if (!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id])) $_SESSION[$sessname3] = array(); // prevent old system
657 657
 				$_SESSION[$sessname3][$object->id] = $hideprices;
658 658
 				
659
-				foreach($object->lines as &$line) {
659
+				foreach ($object->lines as &$line) {
660 660
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
661 661
 					    
662
-                        if($line->qty>=90) {
662
+                        if ($line->qty >= 90) {
663 663
                             $line->modsubtotal_total = 1;
664 664
                         }
665
-                        else{
665
+                        else {
666 666
                             $line->modsubtotal_title = 1;
667 667
                         }
668 668
                         
@@ -672,34 +672,34 @@  discard block
 block discarded – undo
672 672
 	        }
673 673
 			
674 674
 		}
675
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
675
+		else if ($action === 'confirm_delete_all_lines' && GETPOST('confirm') == 'yes') {
676 676
 			
677 677
 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
678 678
 			
679
-			foreach($Tab as $idLine) {
679
+			foreach ($Tab as $idLine) {
680 680
 				/**
681 681
 				 * @var $object Facture
682 682
 				 */
683
-				if($object->element=='facture') $object->deleteline($idLine);
683
+				if ($object->element == 'facture') $object->deleteline($idLine);
684 684
 				/**
685 685
 				 * @var $object Facture fournisseur
686 686
 				 */
687
-				else if($object->element=='invoice_supplier')
687
+				else if ($object->element == 'invoice_supplier')
688 688
 				{
689 689
 				    $object->deleteline($idLine);
690 690
 				}
691 691
 				/**
692 692
 				 * @var $object Propal
693 693
 				 */
694
-				else if($object->element=='propal') $object->deleteline($idLine);
694
+				else if ($object->element == 'propal') $object->deleteline($idLine);
695 695
 				/**
696 696
 				 * @var $object Propal Fournisseur
697 697
 				 */
698
-				else if($object->element=='supplier_proposal') $object->deleteline($idLine);
698
+				else if ($object->element == 'supplier_proposal') $object->deleteline($idLine);
699 699
 				/**
700 700
 				 * @var $object Commande
701 701
 				 */
702
-				else if($object->element=='commande') 
702
+				else if ($object->element == 'commande') 
703 703
 				{
704 704
 					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
705 705
 					else $object->deleteline($idLine);
@@ -707,14 +707,14 @@  discard block
 block discarded – undo
707 707
 				/**
708 708
 				 * @var $object Commande fournisseur
709 709
 				 */
710
-				else if($object->element=='order_supplier')
710
+				else if ($object->element == 'order_supplier')
711 711
 				{
712 712
 				    $object->deleteline($idLine);
713 713
 				}
714 714
 				/**
715 715
 				 * @var $object Facturerec
716 716
 				 */
717
-				else if($object->element=='facturerec') $object->deleteline($idLine);
717
+				else if ($object->element == 'facturerec') $object->deleteline($idLine);
718 718
 			}
719 719
 			
720 720
 			header('location:?id='.$object->id);
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 		return 0;
738 738
 	}
739 739
 	
740
-	function formAddObjectLine ($parameters, &$object, &$action, $hookmanager) {
740
+	function formAddObjectLine($parameters, &$object, &$action, $hookmanager) {
741 741
 		return 0;
742 742
 	}
743 743
 	
@@ -755,8 +755,8 @@  discard block
 block discarded – undo
755 755
 			if (!empty($parameters['fk_element']))
756 756
 			{
757 757
 				
758
-				if($obj->fetch($parameters['fk_element'])){
759
-					$obj->id= $obj->rowid;
758
+				if ($obj->fetch($parameters['fk_element'])) {
759
+					$obj->id = $obj->rowid;
760 760
 					if (empty($obj->array_options))
761 761
 						$obj->fetch_optionals();
762 762
 					if (!empty($obj->array_options['options_subtotal_nc']))
@@ -776,22 +776,22 @@  discard block
 block discarded – undo
776 776
 		
777 777
 		$found = false;
778 778
 
779
-		$Tab= array();
779
+		$Tab = array();
780 780
 		
781
-		foreach($object->lines as $l) {
781
+		foreach ($object->lines as $l) {
782 782
 		
783 783
 		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
784
-			if($lid == $lineid) {
784
+			if ($lid == $lineid) {
785 785
 
786 786
 				$found = true;
787 787
 				$qty_line = $l->qty;
788 788
 			}
789 789
 			
790
-			if($found) {
790
+			if ($found) {
791 791
 				
792 792
 			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
793 793
 				
794
-				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
794
+				if ($l->special_code == $this->module_number && (($l->qty == 99 && $qty_line == 1) || ($l->qty == 98 && $qty_line == 2))) {
795 795
 					break; // end of story
796 796
 				}
797 797
 			}
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
 	 * 
821 821
 	 * @param	$use_level		isn't used anymore
822 822
 	 */
823
-	function getTotalLineFromObject(&$object, &$line, $use_level=false, $return_all=0) {
823
+	function getTotalLineFromObject(&$object, &$line, $use_level = false, $return_all = 0) {
824 824
 		
825 825
 		$rang = $line->rang;
826 826
 		$qty_line = $line->qty;
@@ -831,21 +831,21 @@  discard block
 block discarded – undo
831 831
 		$TTotal_tva = array();
832 832
 		
833 833
 		dol_include_once('/subtotal/class/subtotal.class.php');
834
-		foreach($object->lines as $l) {
834
+		foreach ($object->lines as $l) {
835 835
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
836
-			if($l->rang>=$rang) {
836
+			if ($l->rang >= $rang) {
837 837
 				//echo 'return!<br>';
838 838
 				if (!$return_all) return $total;
839 839
 				else return array($total, $total_tva, $total_ttc, $TTotal_tva);
840 840
 			}
841
-			else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
841
+			else if (TSubtotal::isTitle($l, 100 - $qty_line)) 
842 842
 		  	{
843 843
 				$total = 0;
844 844
 				$total_tva = 0;
845 845
 				$total_ttc = 0;
846 846
 				$TTotal_tva = array();
847 847
 			}
848
-			elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
848
+			elseif (!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
849 849
 				$total += $l->total_ht;
850 850
 				$total_tva += $l->total_tva;
851 851
 				$TTotal_tva[$l->tva_tx] += $l->total_tva;
@@ -864,18 +864,18 @@  discard block
 block discarded – undo
864 864
 		
865 865
 		$rang = $line->rang;
866 866
 		$total = 0;
867
-		foreach($object->lines as $l) {
868
-			if($l->rang>=$rang) {
867
+		foreach ($object->lines as $l) {
868
+			if ($l->rang >= $rang) {
869 869
 				return price($total);
870 870
 			}
871
-                        if (TSubtotal::isSubtotal($l)){
871
+                        if (TSubtotal::isSubtotal($l)) {
872 872
                             $total = 0;
873
-                        } else  if ($l->situation_percent > 0 ){
873
+                        } else  if ($l->situation_percent > 0) {
874 874
                            
875 875
         	
876 876
 		 	$prev_progress = $l->get_prev_progress($object->id);
877
-		 	$progress = ($l->situation_percent - $prev_progress) /100;
878
-                        $total += ($l->total_ht/($l->situation_percent/100)) * $progress;
877
+		 	$progress = ($l->situation_percent - $prev_progress) / 100;
878
+                        $total += ($l->total_ht / ($l->situation_percent / 100)) * $progress;
879 879
                         
880 880
                     }
881 881
                 }
@@ -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;
@@ -907,34 +907,34 @@  discard block
 block discarded – undo
907 907
 		$hidePriceOnSubtotalLines = (int) GETPOST('hide_price_on_subtotal_lines');
908 908
 		
909 909
 		$set_pagebreak_margin = false;
910
-		if(method_exists('Closure','bind')) {
910
+		if (method_exists('Closure', 'bind')) {
911 911
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
912
-			$sweetsThief = function ($pdf) {
913
-		    		return $pdf->bMargin ;
912
+			$sweetsThief = function($pdf) {
913
+		    		return $pdf->bMargin;
914 914
 			};
915 915
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
916 916
 	
917
-			$bMargin  = $sweetsThief($pdf);
917
+			$bMargin = $sweetsThief($pdf);
918 918
 	
919
-			$pdf->SetAutoPageBreak( false );
919
+			$pdf->SetAutoPageBreak(false);
920 920
 
921 921
 			$set_pagebreak_margin = true;			
922 922
 		}
923 923
 		
924 924
 			
925
-		if($line->qty==99)
926
-			$pdf->SetFillColor(220,220,220);
927
-		elseif ($line->qty==98)
928
-			$pdf->SetFillColor(230,230,230);
925
+		if ($line->qty == 99)
926
+			$pdf->SetFillColor(220, 220, 220);
927
+		elseif ($line->qty == 98)
928
+			$pdf->SetFillColor(230, 230, 230);
929 929
 		else
930
-			$pdf->SetFillColor(240,240,240);
930
+			$pdf->SetFillColor(240, 240, 240);
931 931
 		
932 932
 		$style = 'B';
933 933
 		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
934 934
 		
935 935
 		$pdf->SetFont('', $style, 9);
936 936
 		
937
-		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R',true);
937
+		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R', true);
938 938
 //		var_dump($bMargin);
939 939
 		$pageAfter = $pdf->getPage();
940 940
 		
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 				}
960 960
 			}
961 961
 			
962
-			if($total_to_print !== '') {
962
+			if ($total_to_print !== '') {
963 963
 				
964 964
 				if (GETPOST('hideInnerLines'))
965 965
 				{
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
 				else
974 974
 				{
975 975
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
976
-                                        if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
976
+                                        if (get_class($object) == 'Facture' && $object->type == Facture::TYPE_SITUATION) {//Facture de situation
977 977
                                                 $total_to_print = $this->getTotalToPrintSituation($object, $line);
978 978
                                         } else {
979 979
                                             	$total_to_print = price($total);
@@ -987,11 +987,11 @@  discard block
 block discarded – undo
987 987
 			}
988 988
 
989 989
 			$pdf->SetXY($pdf->postotalht, $posy);
990
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
991
-			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
990
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
991
+			$pdf->MultiCell($pdf->page_largeur - $pdf->marge_droite - $pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
992 992
 		}
993
-		else{
994
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
993
+		else {
994
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
995 995
 		}
996 996
 		
997 997
 		$posy = $posy + $cell_height;
@@ -1011,22 +1011,22 @@  discard block
 block discarded – undo
1011 1011
 	 * @param $w            float               width
1012 1012
 	 * @param $h            float               height
1013 1013
 	 */
1014
-	function pdf_add_title(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
1014
+	function pdf_add_title(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
1015 1015
 		
1016
-		global $db,$conf,$subtotal_last_title_posy;
1016
+		global $db, $conf, $subtotal_last_title_posy;
1017 1017
 		
1018 1018
 		$subtotal_last_title_posy = $posy;
1019
-		$pdf->SetXY ($posx, $posy);
1019
+		$pdf->SetXY($posx, $posy);
1020 1020
 		
1021
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1021
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1022 1022
 		
1023 1023
 		
1024 1024
  
1025
-		$style = ($line->qty==1) ? 'BU' : 'BUI';
1025
+		$style = ($line->qty == 1) ? 'BU' : 'BUI';
1026 1026
 		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
1027 1027
 		
1028
-		if($hideInnerLines) {
1029
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
1028
+		if ($hideInnerLines) {
1029
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9);
1030 1030
 			else 
1031 1031
 			{
1032 1032
 				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
@@ -1035,43 +1035,43 @@  discard block
 block discarded – undo
1035 1035
 		}
1036 1036
 		else {
1037 1037
 
1038
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
1038
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9); //TODO if super utile
1039 1039
 			else $pdf->SetFont('', $style, 9);
1040 1040
 			
1041 1041
 		}
1042 1042
 		
1043 1043
 		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) $pdf->MultiCell($w, $h, $label, 0, 'L'); // Pas de HTML dans la chaine
1044
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
1044
+		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J', true); // et maintenant avec du HTML
1045 1045
 		
1046
-		if($description && !$hidedesc) {
1046
+		if ($description && !$hidedesc) {
1047 1047
 			$posy = $pdf->GetY();
1048 1048
 			
1049 1049
 			$pdf->SetFont('', '', 8);
1050 1050
 			
1051
-			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J',true);
1051
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J', true);
1052 1052
 
1053 1053
 		}
1054 1054
 		
1055 1055
 	}
1056 1056
 
1057
-	function pdf_writelinedesc_ref($parameters=array(), &$object, &$action='') {
1057
+	function pdf_writelinedesc_ref($parameters = array(), &$object, &$action = '') {
1058 1058
 	// ultimate PDF hook O_o
1059 1059
 		
1060
-		return $this->pdf_writelinedesc($parameters,$object,$action);
1060
+		return $this->pdf_writelinedesc($parameters, $object, $action);
1061 1061
 		
1062 1062
 	}
1063 1063
 
1064 1064
 	function isModSubtotalLine(&$parameters, &$object) {
1065 1065
 		
1066
-		if(is_array($parameters)) {
1066
+		if (is_array($parameters)) {
1067 1067
 			$i = & $parameters['i'];	
1068 1068
 		}
1069 1069
 		else {
1070
-			$i = (int)$parameters;
1070
+			$i = (int) $parameters;
1071 1071
 		}
1072 1072
 		
1073 1073
 		
1074
-		if($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) {
1074
+		if ($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) {
1075 1075
 			return true;
1076 1076
 		}
1077 1077
 		
@@ -1079,43 +1079,43 @@  discard block
 block discarded – undo
1079 1079
 		
1080 1080
 	}
1081 1081
 
1082
-	function pdf_getlineqty($parameters=array(), &$object, &$action='') {
1083
-		global $conf,$hideprices;
1082
+	function pdf_getlineqty($parameters = array(), &$object, &$action = '') {
1083
+		global $conf, $hideprices;
1084 1084
 		
1085
-		if($this->isModSubtotalLine($parameters,$object) ){
1085
+		if ($this->isModSubtotalLine($parameters, $object)) {
1086 1086
 			
1087 1087
 			$this->resprints = ' ';
1088 1088
 			
1089
-			if((float)DOL_VERSION<=3.6) {
1089
+			if ((float) DOL_VERSION <= 3.6) {
1090 1090
 				return '';
1091 1091
 			}
1092
-			else if((float)DOL_VERSION>=3.8) {
1092
+			else if ((float) DOL_VERSION >= 3.8) {
1093 1093
 				return 1;
1094 1094
 			}
1095 1095
 			
1096 1096
 		}
1097
-		elseif(!empty($hideprices)) {
1097
+		elseif (!empty($hideprices)) {
1098 1098
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1099 1099
 			return 1;
1100 1100
 		}
1101 1101
 		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1102 1102
 		{
1103
-			$hideInnerLines = (int)GETPOST('hideInnerLines');
1104
-			$hidedetails = (int)GETPOST('hidedetails');
1103
+			$hideInnerLines = (int) GETPOST('hideInnerLines');
1104
+			$hidedetails = (int) GETPOST('hidedetails');
1105 1105
 			if (empty($hideInnerLines) && !empty($hidedetails))
1106 1106
 			{
1107 1107
 				$this->resprints = $object->lines[$parameters['i']]->qty;
1108 1108
 			}
1109 1109
 		}
1110 1110
 		
1111
-		if(is_array($parameters)) $i = & $parameters['i'];
1112
-		else $i = (int)$parameters;
1111
+		if (is_array($parameters)) $i = & $parameters['i'];
1112
+		else $i = (int) $parameters;
1113 1113
 
1114 1114
 		if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1115 1115
 		
1116
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1116
+		if (empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1117 1117
 
1118
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1118
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1119 1119
 		{
1120 1120
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1121 1121
 			{
@@ -1127,20 +1127,20 @@  discard block
 block discarded – undo
1127 1127
 		return 0;
1128 1128
 	}
1129 1129
 	
1130
-	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1130
+	function pdf_getlinetotalexcltax($parameters = array(), &$object, &$action = '') {
1131 1131
 	    global $conf, $hideprices, $hookmanager;
1132 1132
 		
1133
-		if(is_array($parameters)) $i = & $parameters['i'];
1134
-		else $i = (int)$parameters;
1133
+		if (is_array($parameters)) $i = & $parameters['i'];
1134
+		else $i = (int) $parameters;
1135 1135
 			
1136
-		if($this->isModSubtotalLine($parameters,$object) ){
1136
+		if ($this->isModSubtotalLine($parameters, $object)) {
1137 1137
 			
1138 1138
 			$this->resprints = ' ';
1139 1139
 			
1140
-			if((float)DOL_VERSION<=3.6) {
1140
+			if ((float) DOL_VERSION <= 3.6) {
1141 1141
 				return '';
1142 1142
 			}
1143
-			else if((float)DOL_VERSION>=3.8) {
1143
+			else if ((float) DOL_VERSION >= 3.8) {
1144 1144
 				return 1;
1145 1145
 			}
1146 1146
 			
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 				}
1167 1167
 			}
1168 1168
 		}
1169
-		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1169
+		if ((int) GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) {
1170 1170
 		    $this->resprints = price($object->lines[$i]->total_ht);
1171 1171
 		}
1172 1172
 		
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
 		{
1192 1192
 			// Check if a title exist for this line && if the title have subtotal
1193 1193
 			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1194
-			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1194
+			if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1195 1195
 			{
1196 1196
 
1197 1197
 				$this->resprints = ' ';
@@ -1211,7 +1211,7 @@  discard block
 block discarded – undo
1211 1211
 	 */
1212 1212
 	private function callHook(&$object, &$hookmanager, $action, $params, $defaultReturn = 1)
1213 1213
 	{
1214
-		$reshook=$hookmanager->executeHooks('subtotalHidePrices',$params, $object, $action);
1214
+		$reshook = $hookmanager->executeHooks('subtotalHidePrices', $params, $object, $action);
1215 1215
 		if ($reshook < 0)
1216 1216
 		{
1217 1217
 			$this->error = $hookmanager->error;
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
 			$this->resprints = $hookmanager->resprints;
1228 1228
 
1229 1229
 			// override return (use  $this->results['overrideReturn'] or $this->resArray['overrideReturn'] in other module action_xxxx.class.php )
1230
-			if(isset($hookmanager->resArray['overrideReturn']))
1230
+			if (isset($hookmanager->resArray['overrideReturn']))
1231 1231
 			{
1232 1232
 				return $hookmanager->resArray['overrideReturn'];
1233 1233
 			}
@@ -1236,25 +1236,25 @@  discard block
 block discarded – undo
1236 1236
 		return $defaultReturn;
1237 1237
 	}
1238 1238
 	
1239
-	function pdf_getlinetotalwithtax($parameters=array(), &$object, &$action='') {
1239
+	function pdf_getlinetotalwithtax($parameters = array(), &$object, &$action = '') {
1240 1240
 		global $conf;
1241 1241
 		
1242
-		if($this->isModSubtotalLine($parameters,$object) ){
1242
+		if ($this->isModSubtotalLine($parameters, $object)) {
1243 1243
 			
1244 1244
 			$this->resprints = ' ';
1245 1245
 		
1246
-			if((float)DOL_VERSION<=3.6) {
1246
+			if ((float) DOL_VERSION <= 3.6) {
1247 1247
 				return '';
1248 1248
 			}
1249
-			else if((float)DOL_VERSION>=3.8) {
1249
+			else if ((float) DOL_VERSION >= 3.8) {
1250 1250
 				return 1;
1251 1251
 			}
1252 1252
 		}
1253 1253
 		
1254
-		if(is_array($parameters)) $i = & $parameters['i'];
1255
-		else $i = (int)$parameters;
1254
+		if (is_array($parameters)) $i = & $parameters['i'];
1255
+		else $i = (int) $parameters;
1256 1256
 		
1257
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1257
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))) 
1258 1258
 		{
1259 1259
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1260 1260
 			{
@@ -1266,24 +1266,24 @@  discard block
 block discarded – undo
1266 1266
 		return 0;
1267 1267
 	}
1268 1268
 	
1269
-	function pdf_getlineunit($parameters=array(), &$object, &$action='') {
1269
+	function pdf_getlineunit($parameters = array(), &$object, &$action = '') {
1270 1270
 		global $conf;
1271 1271
 		
1272
-		if($this->isModSubtotalLine($parameters,$object) ){
1272
+		if ($this->isModSubtotalLine($parameters, $object)) {
1273 1273
 			$this->resprints = ' ';
1274 1274
 		
1275
-			if((float)DOL_VERSION<=3.6) {
1275
+			if ((float) DOL_VERSION <= 3.6) {
1276 1276
 				return '';
1277 1277
 			}
1278
-			else if((float)DOL_VERSION>=3.8) {
1278
+			else if ((float) DOL_VERSION >= 3.8) {
1279 1279
 				return 1;
1280 1280
 			}
1281 1281
 		}
1282 1282
 		
1283
-		if(is_array($parameters)) $i = & $parameters['i'];
1284
-		else $i = (int)$parameters;
1283
+		if (is_array($parameters)) $i = & $parameters['i'];
1284
+		else $i = (int) $parameters;
1285 1285
 			
1286
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1286
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1287 1287
 		{
1288 1288
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1289 1289
 			{
@@ -1295,36 +1295,36 @@  discard block
 block discarded – undo
1295 1295
 		return 0;
1296 1296
 	}
1297 1297
 	
1298
-	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1299
-	    global $conf,$hideprices,$hookmanager, $TTotal, $show_reduc;
1298
+	function pdf_getlineupexcltax($parameters = array(), &$object, &$action = '') {
1299
+	    global $conf, $hideprices, $hookmanager, $TTotal, $show_reduc;
1300 1300
 
1301
-		if(is_array($parameters)) $i = & $parameters['i'];
1302
-		else $i = (int)$parameters;
1301
+		if (is_array($parameters)) $i = & $parameters['i'];
1302
+		else $i = (int) $parameters;
1303 1303
 
1304
-		if($this->isModSubtotalLine($parameters,$object) ) {
1304
+		if ($this->isModSubtotalLine($parameters, $object)) {
1305 1305
 			$this->resprints = ' ';
1306 1306
 
1307 1307
             $line = $object->lines[$i];
1308 1308
 
1309 1309
             // On récupère les montants du bloc...
1310
-            if(TSubtotal::isTitle($line)) {
1310
+            if (TSubtotal::isTitle($line)) {
1311 1311
 //                $show_reduc = $line->array_options['options_show_reduc'];
1312
-                if(! empty($line->array_options['options_show_total_ht'])) $TTotal = TSubtotal::getTotalBlockFromTitle($object, $line);
1312
+                if (!empty($line->array_options['options_show_total_ht'])) $TTotal = TSubtotal::getTotalBlockFromTitle($object, $line);
1313 1313
 //                if(! empty($show_reduc)) $object->lines[$i]->remise_percent = 1;
1314 1314
             }
1315 1315
 
1316 1316
             // ... pour les afficher dans la ligne de sous-total
1317
-            if(TSubtotal::isSubtotal($line) && ! empty($TTotal['total_subprice'])) {
1317
+            if (TSubtotal::isSubtotal($line) && !empty($TTotal['total_subprice'])) {
1318 1318
 //                if(! empty($show_reduc)) $object->lines[$i]->remise_percent = 1;
1319 1319
                 $this->resprints = price($TTotal['total_subprice']);
1320 1320
                 $TTotal = array();
1321 1321
                 $show_reduc = 0;
1322 1322
             }
1323 1323
 		
1324
-			if((float)DOL_VERSION<=3.6) {
1324
+			if ((float) DOL_VERSION <= 3.6) {
1325 1325
 				return '';
1326 1326
 			}
1327
-			else if((float)DOL_VERSION>=3.8) {
1327
+			else if ((float) DOL_VERSION >= 3.8) {
1328 1328
 				return 1;
1329 1329
 			}
1330 1330
 		}
@@ -1352,7 +1352,7 @@  discard block
 block discarded – undo
1352 1352
 		    
1353 1353
 		    // Check if a title exist for this line && if the title have subtotal
1354 1354
 		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1355
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1355
+		    if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1356 1356
 		    {
1357 1357
 		        
1358 1358
 		        $this->resprints = ' ';
@@ -1366,30 +1366,30 @@  discard block
 block discarded – undo
1366 1366
 		return 0;
1367 1367
 	}
1368 1368
 	
1369
-	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1370
-	    global $conf,$hideprices,$hookmanager, $TTotal;
1369
+	function pdf_getlineremisepercent($parameters = array(), &$object, &$action = '') {
1370
+	    global $conf, $hideprices, $hookmanager, $TTotal;
1371 1371
 
1372
-        if(is_array($parameters)) $i = & $parameters['i'];
1372
+        if (is_array($parameters)) $i = & $parameters['i'];
1373 1373
         else $i = (int) $parameters;
1374 1374
 
1375
-		if($this->isModSubtotalLine($parameters,$object) ) {
1375
+		if ($this->isModSubtotalLine($parameters, $object)) {
1376 1376
 			$this->resprints = ' ';
1377 1377
 
1378 1378
             $line = $object->lines[$i];
1379 1379
 
1380 1380
             // Affichage de la remise 
1381
-            if(TSubtotal::isSubtotal($line)) {
1381
+            if (TSubtotal::isSubtotal($line)) {
1382 1382
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1383 1383
                 $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1384 1384
 
1385
-                if(! empty($parentTitle->array_options['options_show_reduc'])) $this->resprints = price($TTotal['total_ht'] / $TTotal['total_subprice']*100, 0, '', 1, 2, 2).'%';
1385
+                if (!empty($parentTitle->array_options['options_show_reduc'])) $this->resprints = price($TTotal['total_ht'] / $TTotal['total_subprice'] * 100, 0, '', 1, 2, 2).'%';
1386 1386
                 $TTotal = array();
1387 1387
             }
1388 1388
 		
1389
-			if((float)DOL_VERSION<=3.6) {
1389
+			if ((float) DOL_VERSION <= 3.6) {
1390 1390
 				return '';
1391 1391
 			}
1392
-			else if((float)DOL_VERSION>=3.8) {
1392
+			else if ((float) DOL_VERSION >= 3.8) {
1393 1393
 				return 1;
1394 1394
 			}
1395 1395
 		}
@@ -1397,24 +1397,24 @@  discard block
 block discarded – undo
1397 1397
 		return 0;
1398 1398
 	}
1399 1399
 	
1400
-	function pdf_getlineupwithtax($parameters=array(), &$object, &$action='') {
1401
-		global $conf,$hideprices;
1400
+	function pdf_getlineupwithtax($parameters = array(), &$object, &$action = '') {
1401
+		global $conf, $hideprices;
1402 1402
 		
1403
-		if($this->isModSubtotalLine($parameters,$object) ){
1403
+		if ($this->isModSubtotalLine($parameters, $object)) {
1404 1404
 			$this->resprints = ' ';
1405
-			if((float)DOL_VERSION<=3.6) {
1405
+			if ((float) DOL_VERSION <= 3.6) {
1406 1406
 				return '';
1407 1407
 			}
1408
-			else if((float)DOL_VERSION>=3.8) {
1408
+			else if ((float) DOL_VERSION >= 3.8) {
1409 1409
 				return 1;
1410 1410
 			}
1411 1411
 		}
1412 1412
 		
1413
-		if(is_array($parameters)) $i = & $parameters['i'];
1414
-		else $i = (int)$parameters;
1413
+		if (is_array($parameters)) $i = & $parameters['i'];
1414
+		else $i = (int) $parameters;
1415 1415
 			
1416 1416
 		if (!empty($hideprices)
1417
-				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1417
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1418 1418
 		)
1419 1419
 		{
1420 1420
 			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1427,22 +1427,22 @@  discard block
 block discarded – undo
1427 1427
 		return 0;
1428 1428
 	}
1429 1429
 	
1430
-	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
1431
-	    global $conf,$hideprices,$hookmanager;
1430
+	function pdf_getlinevatrate($parameters = array(), &$object, &$action = '') {
1431
+	    global $conf, $hideprices, $hookmanager;
1432 1432
 	    
1433
-		if($this->isModSubtotalLine($parameters,$object) ){
1433
+		if ($this->isModSubtotalLine($parameters, $object)) {
1434 1434
 			$this->resprints = ' ';
1435 1435
 			
1436
-			if((float)DOL_VERSION<=3.6) {
1436
+			if ((float) DOL_VERSION <= 3.6) {
1437 1437
 				return '';
1438 1438
 			}
1439
-			else if((float)DOL_VERSION>=3.8) {
1439
+			else if ((float) DOL_VERSION >= 3.8) {
1440 1440
 				return 1;
1441 1441
 			}
1442 1442
 		}
1443 1443
 		
1444
-		if(is_array($parameters)) $i = & $parameters['i'];
1445
-		else $i = (int)$parameters;
1444
+		if (is_array($parameters)) $i = & $parameters['i'];
1445
+		else $i = (int) $parameters;
1446 1446
 		
1447 1447
 		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)
1448 1448
 
@@ -1469,7 +1469,7 @@  discard block
 block discarded – undo
1469 1469
 		    
1470 1470
 		    // Check if a title exist for this line && if the title have subtotal
1471 1471
 		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1472
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1472
+		    if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1473 1473
 		    {
1474 1474
 		        
1475 1475
 		        $this->resprints = ' ';
@@ -1483,23 +1483,23 @@  discard block
 block discarded – undo
1483 1483
 		return 0;
1484 1484
 	}
1485 1485
 		
1486
-	function pdf_getlineprogress($parameters=array(), &$object, &$action) {
1486
+	function pdf_getlineprogress($parameters = array(), &$object, &$action) {
1487 1487
 		global $conf;
1488 1488
 		
1489
-		if($this->isModSubtotalLine($parameters,$object) ){
1489
+		if ($this->isModSubtotalLine($parameters, $object)) {
1490 1490
 			$this->resprints = ' ';
1491
-			if((float)DOL_VERSION<=3.6) {
1491
+			if ((float) DOL_VERSION <= 3.6) {
1492 1492
 				return '';
1493 1493
 			}
1494
-			else if((float)DOL_VERSION>=3.8) {
1494
+			else if ((float) DOL_VERSION >= 3.8) {
1495 1495
 				return 1;
1496 1496
 			}
1497 1497
 		}
1498 1498
 		
1499
-		if(is_array($parameters)) $i = & $parameters['i'];
1500
-		else $i = (int)$parameters;
1499
+		if (is_array($parameters)) $i = & $parameters['i'];
1500
+		else $i = (int) $parameters;
1501 1501
 			
1502
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1502
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1503 1503
 		{
1504 1504
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1505 1505
 			{
@@ -1514,12 +1514,12 @@  discard block
 block discarded – undo
1514 1514
 	function add_numerotation(&$object) {
1515 1515
 		global $conf;
1516 1516
 		
1517
-		if(!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1517
+		if (!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1518 1518
 		
1519 1519
 			$TLevelTitre = array();
1520 1520
 			$prevlevel = 0;
1521 1521
 		
1522
-			foreach($object->lines as $k=>&$line) 
1522
+			foreach ($object->lines as $k=>&$line) 
1523 1523
 			{
1524 1524
 				if ($line->id > 0 && $this->isModSubtotalLine($k, $object) && $line->qty <= 10)
1525 1525
 				{
@@ -1533,12 +1533,12 @@  discard block
 block discarded – undo
1533 1533
 	}
1534 1534
 
1535 1535
 	// TODO ne gère pas encore la numération des lignes "Totaux"
1536
-	private function formatNumerotation(&$TLineTitle, $line_reference='', $level=1, $prefix_num=0)
1536
+	private function formatNumerotation(&$TLineTitle, $line_reference = '', $level = 1, $prefix_num = 0)
1537 1537
 	{
1538 1538
 		$TTitle = array();
1539 1539
 		
1540
-		$i=1;
1541
-		$j=0;
1540
+		$i = 1;
1541
+		$j = 0;
1542 1542
 		foreach ($TLineTitle as $k => &$line)
1543 1543
 		{
1544 1544
 			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
@@ -1548,7 +1548,7 @@  discard block
 block discarded – undo
1548 1548
 			{
1549 1549
 				$TTitle[$j]['numerotation'] = ($prefix_num == 0) ? $i : $prefix_num.'.'.$i;
1550 1550
 				//var_dump('Prefix == '.$prefix_num.' // '.$line->desc.' ==> numerotation == '.$TTitle[$j]['numerotation'].'   ###    '.$line->qty .'=='. $level);
1551
-				if (empty($line->label) && (float)DOL_VERSION < 6)
1551
+				if (empty($line->label) && (float) DOL_VERSION < 6)
1552 1552
 				{
1553 1553
 					$line->label = !empty($line->desc) ? $line->desc : $line->description;
1554 1554
 					$line->desc = $line->description = '';
@@ -1574,26 +1574,26 @@  discard block
 block discarded – undo
1574 1574
 	
1575 1575
 	function setDocTVA(&$pdf, &$object) {
1576 1576
 		
1577
-		$hidedetails = (int)GETPOST('hidedetails');
1577
+		$hidedetails = (int) GETPOST('hidedetails');
1578 1578
 		
1579
-		if(empty($hidedetails)) return false;
1579
+		if (empty($hidedetails)) return false;
1580 1580
 		
1581 1581
 		// TODO can't add VAT to document without lines... :-/
1582 1582
 		
1583 1583
 		return true;
1584 1584
 	}
1585 1585
 	
1586
-	function beforePDFCreation($parameters=array(), &$object, &$action)
1586
+	function beforePDFCreation($parameters = array(), &$object, &$action)
1587 1587
 	{
1588 1588
 		/**
1589 1589
 		 * @var $pdf    TCPDF
1590 1590
 		 */
1591
-		global $pdf,$conf, $langs;
1591
+		global $pdf, $conf, $langs;
1592 1592
 
1593 1593
 		// var_dump($object->lines);
1594 1594
 		dol_include_once('/subtotal/class/subtotal.class.php');
1595 1595
 
1596
-		foreach($parameters as $key=>$value) {
1596
+		foreach ($parameters as $key=>$value) {
1597 1597
 			${$key} = $value;
1598 1598
 		}
1599 1599
 		
@@ -1601,34 +1601,34 @@  discard block
 block discarded – undo
1601 1601
 		
1602 1602
 		$this->add_numerotation($object);	
1603 1603
 		
1604
-        foreach($object->lines as $k => &$l) {
1605
-            if(TSubtotal::isSubtotal($l)) {
1604
+        foreach ($object->lines as $k => &$l) {
1605
+            if (TSubtotal::isSubtotal($l)) {
1606 1606
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1607
-                if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_total_ht'])) {
1608
-                    $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1607
+                if (!empty($parentTitle->id) && !empty($parentTitle->array_options['options_show_total_ht'])) {
1608
+                    $l->remise_percent = 100; // Affichage de la réduction sur la ligne de sous-total
1609 1609
                 }
1610 1610
             }
1611 1611
         }
1612 1612
 
1613
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1614
-		$hidedetails = (int)GETPOST('hidedetails');
1613
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1614
+		$hidedetails = (int) GETPOST('hidedetails');
1615 1615
 
1616 1616
 		if ($hideInnerLines) { // si c une ligne de titre
1617
-	    	$fk_parent_line=0;
1618
-			$TLines =array();
1617
+	    	$fk_parent_line = 0;
1618
+			$TLines = array();
1619 1619
 		
1620
-			$original_count=count($object->lines);
1620
+			$original_count = count($object->lines);
1621 1621
 		    $TTvas = array(); // tableau de tva
1622 1622
 		    
1623
-			foreach($object->lines as $k=>&$line) 
1623
+			foreach ($object->lines as $k=>&$line) 
1624 1624
 			{
1625 1625
 			    
1626
-				if($line->product_type==9 && $line->rowid>0) 
1626
+				if ($line->product_type == 9 && $line->rowid > 0) 
1627 1627
 				{
1628 1628
 					$fk_parent_line = $line->rowid;
1629 1629
 					
1630 1630
 					// 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
1631
-					if(TSubtotal::isSubtotal($line)) 
1631
+					if (TSubtotal::isSubtotal($line)) 
1632 1632
 					{
1633 1633
 						/*$total = $this->getTotalLineFromObject($object, $line, '');
1634 1634
 						
@@ -1657,22 +1657,22 @@  discard block
 block discarded – undo
1657 1657
 			
1658 1658
 				if ($hideInnerLines)
1659 1659
 				{
1660
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1660
+				    if (!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1661 1661
 				    {
1662
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1662
+				        if ($line->tva_tx != '0.000' && $line->product_type != 9) {
1663 1663
 				            
1664 1664
     				        // on remplit le tableau de tva pour substituer les lignes cachées
1665 1665
     				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1666 1666
     				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1667 1667
     				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1668 1668
     				    }
1669
-    					if($line->product_type==9 && $line->rowid>0)
1669
+    					if ($line->product_type == 9 && $line->rowid > 0)
1670 1670
     					{
1671 1671
     					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1672 1672
     					    // génère des lignes d'affichage des montants HT soumis à tva
1673 1673
     					    $nbtva = count($TTvas);
1674
-    					    if(!empty($nbtva)){
1675
-    					        foreach ($TTvas as $tx =>$val){
1674
+    					    if (!empty($nbtva)) {
1675
+    					        foreach ($TTvas as $tx =>$val) {
1676 1676
     					            $l = clone $line;
1677 1677
     					            $l->product_type = 1;
1678 1678
     					            $l->special_code = '';
@@ -1693,7 +1693,7 @@  discard block
 block discarded – undo
1693 1693
     					}
1694 1694
 				    } else {
1695 1695
 				        
1696
-				        if($line->product_type==9 && $line->rowid>0)
1696
+				        if ($line->product_type == 9 && $line->rowid > 0)
1697 1697
 				        {
1698 1698
 				            // ajoute la ligne de sous-total
1699 1699
 				            $TLines[] = $line; 
@@ -1721,9 +1721,9 @@  discard block
 block discarded – undo
1721 1721
 			
1722 1722
 			// cas incongru où il y aurait des produits en dessous du dernier sous-total
1723 1723
 			$nbtva = count($TTvas);
1724
-			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1724
+			if (!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1725 1725
 			{
1726
-			    foreach ($TTvas as $tx =>$val){
1726
+			    foreach ($TTvas as $tx =>$val) {
1727 1727
 			        $l = clone $line;
1728 1728
 			        $l->product_type = 1;
1729 1729
 			        $l->special_code = '';
@@ -1740,11 +1740,11 @@  discard block
 block discarded – undo
1740 1740
 			}
1741 1741
 			
1742 1742
 			global $nblignes;
1743
-			$nblignes=count($TLines);
1743
+			$nblignes = count($TLines);
1744 1744
 
1745 1745
 			$object->lines = $TLines;
1746 1746
 			
1747
-			if($i>count($object->lines)) {
1747
+			if ($i > count($object->lines)) {
1748 1748
 				$this->resprints = '';
1749 1749
 				return 0;
1750 1750
 			}
@@ -1753,59 +1753,59 @@  discard block
 block discarded – undo
1753 1753
 		return 0;
1754 1754
 	}
1755 1755
 
1756
-	function pdf_writelinedesc($parameters=array(), &$object, &$action)
1756
+	function pdf_writelinedesc($parameters = array(), &$object, &$action)
1757 1757
 	{
1758 1758
 		/**
1759 1759
 		 * @var $pdf    TCPDF
1760 1760
 		 */
1761
-		global $pdf,$conf;
1761
+		global $pdf, $conf;
1762 1762
 
1763
-		foreach($parameters as $key=>$value) {
1763
+		foreach ($parameters as $key=>$value) {
1764 1764
 			${$key} = $value;
1765 1765
 		}
1766 1766
 		
1767
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1768
-		$hidedetails = (int)GETPOST('hidedetails');
1767
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1768
+		$hidedetails = (int) GETPOST('hidedetails');
1769 1769
 		
1770
-		if($this->isModSubtotalLine($parameters,$object) ){			
1770
+		if ($this->isModSubtotalLine($parameters, $object)) {			
1771 1771
 		
1772 1772
 				global $hideprices;
1773 1773
 				
1774
-				if(!empty($hideprices)) {
1775
-					foreach($object->lines as &$line) {
1776
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1774
+				if (!empty($hideprices)) {
1775
+					foreach ($object->lines as &$line) {
1776
+						if ($line->fk_product_type != 9) $line->fk_parent_line = -1;	
1777 1777
 					}
1778 1778
 				}
1779 1779
 			
1780 1780
 				$line = &$object->lines[$i];
1781 1781
 				
1782
-				if($line->info_bits>0) { // PAGE BREAK
1782
+				if ($line->info_bits > 0) { // PAGE BREAK
1783 1783
 					$pdf->addPage();
1784 1784
 					$posy = $pdf->GetY();
1785 1785
 				}
1786 1786
 				
1787 1787
 				$label = $line->label;
1788
-				$description= !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1788
+				$description = !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1789 1789
 				
1790
-				if(empty($label)) {
1790
+				if (empty($label)) {
1791 1791
 					$label = $description;
1792
-					$description='';
1792
+					$description = '';
1793 1793
 				}
1794 1794
 				
1795
-				if($line->qty>90) {
1795
+				if ($line->qty > 90) {
1796 1796
 					
1797 1797
 					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1798 1798
 					
1799 1799
 					$pageBefore = $pdf->getPage();
1800
-					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1800
+					$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1801 1801
 					$pageAfter = $pdf->getPage();	
1802 1802
 
1803
-					if($pageAfter>$pageBefore) {
1803
+					if ($pageAfter > $pageBefore) {
1804 1804
 						//print "ST $pageAfter>$pageBefore<br>";
1805 1805
 						$pdf->rollbackTransaction(true);	
1806
-						$pdf->addPage('','', true);
1806
+						$pdf->addPage('', '', true);
1807 1807
 						$posy = $pdf->GetY();
1808
-						$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1808
+						$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1809 1809
 						$posy = $pdf->GetY();
1810 1810
 						//print 'add ST'.$pdf->getPage().'<br />';
1811 1811
 					}
@@ -1816,7 +1816,7 @@  discard block
 block discarded – undo
1816 1816
 				else if ($line->qty < 10) {
1817 1817
 					$pageBefore = $pdf->getPage();
1818 1818
 
1819
-					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
1819
+					$this->pdf_add_title($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h); 
1820 1820
 					$pageAfter = $pdf->getPage();	
1821 1821
 
1822 1822
 					
@@ -1891,9 +1891,9 @@  discard block
 block discarded – undo
1891 1891
 	 * @param $hookmanager  HookManager
1892 1892
 	 * @return int
1893 1893
 	 */
1894
-	function printObjectLine ($parameters, &$object, &$action, $hookmanager){
1894
+	function printObjectLine($parameters, &$object, &$action, $hookmanager) {
1895 1895
 		
1896
-		global $conf,$langs,$user,$db,$bc;
1896
+		global $conf, $langs, $user, $db, $bc;
1897 1897
 		
1898 1898
 		$num = &$parameters['num'];
1899 1899
 		$line = &$parameters['line'];
@@ -1901,32 +1901,32 @@  discard block
 block discarded – undo
1901 1901
 		
1902 1902
 		$var = &$parameters['var'];
1903 1903
 
1904
-		$contexts = explode(':',$parameters['context']);
1904
+		$contexts = explode(':', $parameters['context']);
1905 1905
 
1906 1906
 		$createRight = $user->rights->{$object->element}->creer;
1907
-		if($object->element == 'facturerec' )
1907
+		if ($object->element == 'facturerec')
1908 1908
 		{
1909 1909
 			$object->statut = 0; // hack for facture rec
1910 1910
 			$createRight = $user->rights->facture->creer;
1911 1911
 		}
1912
-		elseif($object->element == 'order_supplier' )
1912
+		elseif ($object->element == 'order_supplier')
1913 1913
 		{
1914 1914
 		    $createRight = $user->rights->fournisseur->commande->creer;
1915 1915
 		}
1916
-		elseif($object->element == 'invoice_supplier' )
1916
+		elseif ($object->element == 'invoice_supplier')
1917 1917
 		{
1918 1918
 		    $createRight = $user->rights->fournisseur->facture->creer;
1919 1919
 		}
1920 1920
 		
1921
-		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1921
+		if ($line->special_code != $this->module_number || $line->product_type != 9) {
1922 1922
 			null;
1923 1923
 		}	
1924
-		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)) 
1924
+		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)) 
1925 1925
         {
1926
-			if($object->element=='facture')$idvar = 'facid';
1927
-			else $idvar='id';
1926
+			if ($object->element == 'facture')$idvar = 'facid';
1927
+			else $idvar = 'id';
1928 1928
 			
1929
-			if((float)DOL_VERSION <= 3.4)
1929
+			if ((float) DOL_VERSION <= 3.4)
1930 1930
 			{
1931 1931
 				?>
1932 1932
 				<script type="text/javascript">
@@ -1950,20 +1950,20 @@  discard block
 block discarded – undo
1950 1950
 				<?php
1951 1951
 			}
1952 1952
 			
1953
-			if(empty($line->description)) $line->description = $line->desc;
1953
+			if (empty($line->description)) $line->description = $line->desc;
1954 1954
 			
1955 1955
 			$colspan = 5;
1956
-			if($object->element == 'facturerec' ) $colspan = 3;
1957
-			if($object->element == 'order_supplier') $colspan = 3;
1958
-			if($object->element == 'invoice_supplier') $colspan = 4;
1959
-			if($object->element == 'supplier_proposal') $colspan = 4;
1960
-			if(!empty($conf->multicurrency->enabled)) $colspan+=2;
1961
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1962
-			if(!empty($conf->margin->enabled)) $colspan++;
1963
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1964
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1965
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1966
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
1956
+			if ($object->element == 'facturerec') $colspan = 3;
1957
+			if ($object->element == 'order_supplier') $colspan = 3;
1958
+			if ($object->element == 'invoice_supplier') $colspan = 4;
1959
+			if ($object->element == 'supplier_proposal') $colspan = 4;
1960
+			if (!empty($conf->multicurrency->enabled)) $colspan += 2;
1961
+			if ($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1962
+			if (!empty($conf->margin->enabled)) $colspan++;
1963
+			if (!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1964
+			if (!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1965
+			if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1966
+			if (!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
1967 1967
 					
1968 1968
 			/* Titre */
1969 1969
 			//var_dump($line);
@@ -1973,35 +1973,35 @@  discard block
 block discarded – undo
1973 1973
             
1974 1974
 			
1975 1975
 			?>
1976
-			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
1976
+			<tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
1977 1977
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
1978 1978
 					{
1979
-						if($line->qty==99) print 'background:#adadcf';
1980
-						else if($line->qty==98) print 'background:#ddddff;';
1981
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
1982
-						else if($line->qty==1) print 'background:#adadcf;';
1983
-						else if($line->qty==2) print 'background:#ddddff;';
1984
-						else if($line->qty==50) print '';
1979
+						if ($line->qty == 99) print 'background:#adadcf';
1980
+						else if ($line->qty == 98) print 'background:#ddddff;';
1981
+						else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;';
1982
+						else if ($line->qty == 1) print 'background:#adadcf;';
1983
+						else if ($line->qty == 2) print 'background:#ddddff;';
1984
+						else if ($line->qty == 50) print '';
1985 1985
 						else print 'background:#eeeeff;';
1986 1986
 
1987 1987
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
1988 1988
 					}
1989 1989
 					else 
1990 1990
 					{
1991
-						if($line->qty==99) print 'background:#ddffdd';
1992
-						else if($line->qty==98) print 'background:#ddddff;';
1993
-						else if($line->qty==2) print 'background:#eeeeff; ';
1994
-						else if($line->qty==50) print '';
1995
-						else print 'background:#eeffee;' ;
1991
+						if ($line->qty == 99) print 'background:#ddffdd';
1992
+						else if ($line->qty == 98) print 'background:#ddddff;';
1993
+						else if ($line->qty == 2) print 'background:#eeeeff; ';
1994
+						else if ($line->qty == 50) print '';
1995
+						else print 'background:#eeffee;';
1996 1996
 					}
1997 1997
 
1998 1998
 			?>;">
1999 1999
 			
2000
-				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
2001
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
2000
+				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php
2001
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
2002 2002
 
2003
-						$params=array('line'=>$line);
2004
-						$reshook=$hookmanager->executeHooks('formEditProductOptions',$params,$object,$action);
2003
+						$params = array('line'=>$line);
2004
+						$reshook = $hookmanager->executeHooks('formEditProductOptions', $params, $object, $action);
2005 2005
 						
2006 2006
 						echo '<div id="line_'.$line->id.'"></div>'; // Imitation Dolibarr
2007 2007
 						echo '<input type="hidden" value="'.$line->id.'" name="lineid">';
@@ -2009,7 +2009,7 @@  discard block
 block discarded – undo
2009 2009
 						echo '<input id="product_id" type="hidden" value="'.$line->fk_product.'" name="type">';
2010 2010
 						echo '<input id="special_code" type="hidden" value="'.$line->special_code.'" name="type">';
2011 2011
 
2012
-						$isFreeText=false;
2012
+						$isFreeText = false;
2013 2013
 						if (TSubtotal::isTitle($line))
2014 2014
 						{
2015 2015
 							$qty_displayed = $line->qty;
@@ -2031,13 +2031,13 @@  discard block
 block discarded – undo
2031 2031
 						    $line->description = '';
2032 2032
 						}
2033 2033
 						$newlabel = $line->label;
2034
-						if($line->label=='' && !$isFreeText) {
2035
-							if(TSubtotal::isSubtotal($line)) {
2034
+						if ($line->label == '' && !$isFreeText) {
2035
+							if (TSubtotal::isSubtotal($line)) {
2036 2036
 								$newlabel = $line->description.' '.$this->getTitle($object, $line);
2037
-								$line->description='';
2038
-							} elseif( (float)DOL_VERSION < 6 ) {
2039
-								$newlabel= $line->description;
2040
-								$line->description='';
2037
+								$line->description = '';
2038
+							} elseif ((float) DOL_VERSION < 6) {
2039
+								$newlabel = $line->description;
2040
+								$line->description = '';
2041 2041
 							}
2042 2042
 						}
2043 2043
 
@@ -2046,10 +2046,10 @@  discard block
 block discarded – undo
2046 2046
 						
2047 2047
 						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2048 2048
 						
2049
-						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
2049
+						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)))
2050 2050
 						{
2051 2051
 							$select = '<select name="subtotal_level">';
2052
-							for ($j=1; $j<10; $j++)
2052
+							for ($j = 1; $j < 10; $j++)
2053 2053
 							{
2054 2054
 								if (!empty($readonlyForSituation)) {
2055 2055
 									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
@@ -2063,7 +2063,7 @@  discard block
 block discarded – undo
2063 2063
 
2064 2064
 						echo '<div class="subtotal_underline" style="margin-left:24px; line-height: 25px;">';
2065 2065
                         echo '<div>';
2066
-                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2066
+                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '').' />&nbsp;';
2067 2067
                         echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2068 2068
                         echo '</div>';
2069 2069
 
@@ -2084,21 +2084,21 @@  discard block
 block discarded – undo
2084 2084
                                 echo '</div>';
2085 2085
                             }
2086 2086
                             echo '<div>';
2087
-                            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;';
2087
+                            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;';
2088 2088
                             echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2089 2089
                             echo '</div>';
2090 2090
 
2091 2091
                             echo '<div>';
2092
-                            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;';
2092
+                            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;';
2093 2093
                             echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2094 2094
                             echo '</div>';
2095 2095
                         }
2096 2096
                         else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2097 2097
 						echo '</div>';
2098 2098
 
2099
-						if($line->qty<10) {
2099
+						if ($line->qty < 10) {
2100 2100
 							// WYSIWYG editor
2101
-							require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
2101
+							require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
2102 2102
 							$nbrows = ROWS_2;
2103 2103
 							$cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
2104 2104
 							if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
@@ -2118,25 +2118,25 @@  discard block
 block discarded – undo
2118 2118
 
2119 2119
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2120 2120
 						 {
2121
-							if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
2121
+							if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
2122 2122
 							{
2123
-								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2123
+								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
2124 2124
 								
2125 2125
 								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2126
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2126
+								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
2127 2127
 							}
2128 2128
 						 }
2129 2129
 						 else 
2130 2130
 						 {
2131
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2132
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2131
+							if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal');
2132
+							else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2133 2133
 						 }
2134 2134
 						 
2135 2135
 						 
2136 2136
 						 // Get display styles and apply them
2137 2137
 						 $titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
2138
-						 $titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2139
-						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2138
+						 $titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2139
+						 $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2140 2140
 						 
2141 2141
 						 if (empty($line->label)) {
2142 2142
 							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
@@ -2144,16 +2144,16 @@  discard block
 block discarded – undo
2144 2144
 						 } 
2145 2145
 						 else {
2146 2146
 
2147
-							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2147
+							if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2148 2148
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2149 2149
 							}
2150
-							else{
2150
+							else {
2151 2151
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
2152 2152
 							}
2153 2153
 
2154 2154
 						 } 
2155
-						if($line->qty>90) print ' : ';
2156
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2155
+						if ($line->qty > 90) print ' : ';
2156
+						if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2157 2157
 
2158 2158
 						 
2159 2159
 
@@ -2162,7 +2162,7 @@  discard block
 block discarded – undo
2162 2162
 			?></td>
2163 2163
 					 
2164 2164
 			<?php
2165
-				if($line->qty>90) {
2165
+				if ($line->qty > 90) {
2166 2166
 					/* Total */
2167 2167
 					$total_line = $this->getTotalLineFromObject($object, $line, '');
2168 2168
 					echo '<td class="nowrap liencolht" align="right" style="font-weight:bold;" rel="subtotal_total">'.price($total_line).'</td>';
@@ -2175,7 +2175,7 @@  discard block
 block discarded – undo
2175 2175
 				<?php
2176 2176
 				if ($action != 'selectlines') {
2177 2177
 				
2178
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
2178
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
2179 2179
 						?>
2180 2180
 						<input id="savelinebutton" class="button" type="submit" name="save" value="<?php echo $langs->trans('Save') ?>" />
2181 2181
 						<br />
@@ -2191,13 +2191,13 @@  discard block
 block discarded – undo
2191 2191
 						<?php
2192 2192
 						
2193 2193
 					}
2194
-					else{
2195
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2194
+					else {
2195
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2196 2196
 						{
2197
-							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2197
+							if (TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref)) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'.img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2198 2198
 						}
2199 2199
 
2200
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
2200
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
2201 2201
 						{
2202 2202
 							echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=editline&lineid='.$line->id.'">'.img_edit().'</a>';
2203 2203
 						}								
@@ -2212,7 +2212,7 @@  discard block
 block discarded – undo
2212 2212
 				<?php
2213 2213
 
2214 2214
 				if ($action != 'editline' && $action != 'selectlines') {
2215
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2215
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2216 2216
 						{
2217 2217
 
2218 2218
 							if ($object->situation_counter == 1 || !$object->situation_cycle_ref)
@@ -2220,7 +2220,7 @@  discard block
 block discarded – undo
2220 2220
 								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteline&lineid='.$line->id.'">'.img_delete().'</a>';
2221 2221
 							}
2222 2222
 
2223
-							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) )
2223
+							if (TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref))
2224 2224
 							{
2225 2225
 								$img_delete = ((float) DOL_VERSION >= 3.8) ? img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal') : img_picto($langs->trans('deleteWithAllLines'), 'delete_all@subtotal');
2226 2226
 								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteallline&lineid='.$line->id.'">'.$img_delete.'</a>';
@@ -2231,7 +2231,7 @@  discard block
 block discarded – undo
2231 2231
 			</td>
2232 2232
 			
2233 2233
 			<?php 
2234
-			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
2234
+			if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
2235 2235
 			{
2236 2236
 				echo '<td class="subtotal_nc">';
2237 2237
 				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"' : '').' />';
@@ -2242,11 +2242,11 @@  discard block
 block discarded – undo
2242 2242
 			<td align="center" class="tdlineupdown">
2243 2243
 			</td>
2244 2244
 			<?php } else { ?>
2245
-			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0  && $createRight ))?' class="tdlineupdown"':''); ?>></td>
2245
+			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0 && $createRight)) ? ' class="tdlineupdown"' : ''); ?>></td>
2246 2246
 			<?php } ?>
2247 2247
 
2248
-			<?php  if($action == 'selectlines'){ // dolibarr 8 ?>
2249
-			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
2248
+			<?php  if ($action == 'selectlines') { // dolibarr 8 ?>
2249
+			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i + 1; ?>]" value="<?php echo $line->id; ?>" ></td>
2250 2250
 			<?php } ?>
2251 2251
 
2252 2252
 			</tr>
@@ -2254,29 +2254,29 @@  discard block
 block discarded – undo
2254 2254
 			
2255 2255
 			
2256 2256
 			// Affichage des extrafields à la Dolibarr (car sinon non affiché sur les titres)
2257
-			if(TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2257
+			if (TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2258 2258
 				
2259
-				require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
2259
+				require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
2260 2260
 				
2261 2261
 				// Extrafields
2262 2262
 				$extrafieldsline = new ExtraFields($db);
2263 2263
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2264 2264
 				
2265
-				$colspan+=3; $mode = 'view';
2266
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2265
+				$colspan += 3; $mode = 'view';
2266
+				if ($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2267 2267
 				
2268 2268
 				$ex_element = $line->element;
2269 2269
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
2270
-				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ','colspan'=>$colspan));
2270
+				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ', 'colspan'=>$colspan));
2271 2271
 				$isExtraSelected = false;
2272
-				foreach($line->array_options as $option) {
2273
-					if(!empty($option) && $option != "-1") {
2272
+				foreach ($line->array_options as $option) {
2273
+					if (!empty($option) && $option != "-1") {
2274 2274
 						$isExtraSelected = true;
2275 2275
 						break;
2276 2276
 					}
2277 2277
 				}
2278 2278
 				
2279
-				if($mode === 'edit') {
2279
+				if ($mode === 'edit') {
2280 2280
 					?>
2281 2281
 					<script>
2282 2282
 						$(document).ready(function(){
@@ -2284,7 +2284,7 @@  discard block
 block discarded – undo
2284 2284
 							var all_tr_extrafields = $("tr.tr_extrafield_title");
2285 2285
 							<?php 
2286 2286
 							// Si un extrafield est rempli alors on affiche directement les extrafields
2287
-							if(!$isExtraSelected) {
2287
+							if (!$isExtraSelected) {
2288 2288
 								echo 'all_tr_extrafields.hide();';
2289 2289
 								echo 'var trad = "'.$langs->trans('showExtrafields').'";';
2290 2290
 								echo 'var extra = 0;';
@@ -2330,20 +2330,20 @@  discard block
 block discarded – undo
2330 2330
 
2331 2331
 	
2332 2332
 	function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) {
2333
-		global $conf,$langs;
2333
+		global $conf, $langs;
2334 2334
 		 
2335 2335
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2336 2336
 		{
2337 2337
 		    
2338
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2338
+		    if ($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2339 2339
 		    {
2340 2340
 		        foreach ($object->lines as $line)
2341 2341
 		        {
2342 2342
 		            // fetch optionals attributes and labels
2343 2343
 		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2344
-		            $extrafields=new ExtraFields($this->db);
2345
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2346
-		            $line->fetch_optionals($line->id,$extralabels);
2344
+		            $extrafields = new ExtraFields($this->db);
2345
+		            $extralabels = $extrafields->fetch_name_optionals_label($object->table_element_line, true);
2346
+		            $line->fetch_optionals($line->id, $extralabels);
2347 2347
 		        }
2348 2348
 		    }
2349 2349
 		    
@@ -2443,23 +2443,23 @@  discard block
 block discarded – undo
2443 2443
 	    $ThtmlData['data-qty']          = 0; //$line->qty;
2444 2444
 	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2445 2445
 	    
2446
-	    if(TSubtotal::isTitle($line)){
2446
+	    if (TSubtotal::isTitle($line)) {
2447 2447
 	        $ThtmlData['data-issubtotal'] = 'title';
2448
-	    }elseif(TSubtotal::isSubtotal($line)){
2448
+	    }elseif (TSubtotal::isSubtotal($line)) {
2449 2449
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2450 2450
 	    }
2451
-	    else{
2451
+	    else {
2452 2452
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2453 2453
 	    }
2454 2454
 	    
2455 2455
 	    
2456 2456
 	    // Change or add data  from hooks
2457
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2457
+	    $parameters = array_replace($parameters, array('ThtmlData' => $ThtmlData));
2458 2458
 	    
2459 2459
 	    // hook 
2460
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2460
+	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2461 2461
 	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2462
-	    if ($reshook>0)
2462
+	    if ($reshook > 0)
2463 2463
 	    {
2464 2464
 	        $ThtmlData = $hookmanager->resArray;
2465 2465
 	    }
@@ -2472,14 +2472,14 @@  discard block
 block discarded – undo
2472 2472
 	function implodeHtmlData($ThtmlData = array())
2473 2473
 	{
2474 2474
 	    $data = '';
2475
-	    foreach($ThtmlData as $k => $h )
2475
+	    foreach ($ThtmlData as $k => $h)
2476 2476
 	    {
2477
-	        if(is_array($h))
2477
+	        if (is_array($h))
2478 2478
 	        {
2479 2479
 	            $h = json_encode($h);
2480 2480
 	        }
2481 2481
 	        
2482
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2482
+	        $data .= $k.'="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2483 2483
 	    }
2484 2484
 	    
2485 2485
 	    return $data;
@@ -2487,26 +2487,26 @@  discard block
 block discarded – undo
2487 2487
 	
2488 2488
 	function _ajax_block_order_js($object)
2489 2489
 	{
2490
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2490
+	    global $conf, $tagidfortablednd, $filepath, $langs;
2491 2491
 	    
2492 2492
 	    /*
2493 2493
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2494 2494
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2495 2495
 	     */
2496 2496
 	    
2497
-	    $id=$object->id;
2498
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2499
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2497
+	    $id = $object->id;
2498
+	    $nboflines = (isset($object->lines) ?count($object->lines) : 0);
2499
+	    $forcereloadpage = empty($conf->global->MAIN_FORCE_RELOAD_PAGE) ? 0 : 1;
2500 2500
 	    
2501
-	    $id=$object->id;
2502
-	    $fk_element=$object->fk_element;
2503
-	    $table_element_line=$object->table_element_line;
2504
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2505
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2506
-	    $filepath=(empty($filepath)?'':$filepath);
2501
+	    $id = $object->id;
2502
+	    $fk_element = $object->fk_element;
2503
+	    $table_element_line = $object->table_element_line;
2504
+	    $nboflines = (isset($object->lines) ?count($object->lines) : (empty($nboflines) ? 0 : $nboflines));
2505
+	    $tagidfortablednd = (empty($tagidfortablednd) ? 'tablelines' : $tagidfortablednd);
2506
+	    $filepath = (empty($filepath) ? '' : $filepath);
2507 2507
 	    
2508 2508
 	    
2509
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2509
+	    if (GETPOST('action', 'aZ09') != 'editline' && $nboflines > 1)
2510 2510
 	    {
2511 2511
 	        
2512 2512
 	        ?>
@@ -2524,7 +2524,7 @@  discard block
 block discarded – undo
2524 2524
 				moveBlockCol.disableSelection(); // prevent selection
2525 2525
 <?php if ($object->statut == 0) { ?>
2526 2526
 				// apply some graphical stuff
2527
-				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png',2);  ?>)');
2527
+				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png', 2); ?>)');
2528 2528
 				moveBlockCol.css("background-repeat","no-repeat");
2529 2529
 				moveBlockCol.css("background-position","center center");
2530 2530
 				moveBlockCol.css("cursor","move");
Please login to merge, or discard this patch.
Braces   +387 added lines, -234 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@  discard block
 block discarded – undo
45 45
 				$value = '';
46 46
 				$sql = 'SELECT content FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text WHERE rowid = '.GETPOST('rowid');
47 47
 				$resql = $this->db->query($sql);
48
-				if ($resql && ($obj = $this->db->fetch_object($resql))) $value = $obj->content;
48
+				if ($resql && ($obj = $this->db->fetch_object($resql))) {
49
+					$value = $obj->content;
50
+				}
49 51
 			}
50 52
 			
51 53
 			?>
@@ -129,8 +131,11 @@  discard block
 block discarded – undo
129 131
 			if ($object->statut == 0  && $createRight) {
130 132
 			
131 133
 
132
-				if($object->element=='facture')$idvar = 'facid';
133
-				else $idvar='id';
134
+				if($object->element=='facture') {
135
+					$idvar = 'facid';
136
+				} else {
137
+					$idvar='id';
138
+				}
134 139
 				
135 140
 				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
136 141
 				{
@@ -138,10 +143,11 @@  discard block
 block discarded – undo
138 143
 					
139 144
 					if($action=='add_title_line') {
140 145
 						$title = GETPOST('title');
141
-						if(empty($title)) $title = $langs->trans('title');
146
+						if(empty($title)) {
147
+							$title = $langs->trans('title');
148
+						}
142 149
 						$qty = $level<1 ? 1 : $level ;
143
-					}
144
-					else if($action=='add_free_text') {
150
+					} else if($action=='add_free_text') {
145 151
 						$title = GETPOST('title');
146 152
 
147 153
 						if (empty($title)) {
@@ -153,29 +159,31 @@  discard block
 block discarded – undo
153 159
 								}
154 160
 							}
155 161
 						}
156
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
162
+						if(empty($title)) {
163
+							$title = $langs->trans('subtotalAddLineDescription');
164
+						}
157 165
 						$qty = 50;
158
-					}
159
-					else if($action=='add_subtitle_line') {
166
+					} else if($action=='add_subtitle_line') {
160 167
 						$title = GETPOST('title');
161
-						if(empty($title)) $title = $langs->trans('subtitle');
168
+						if(empty($title)) {
169
+							$title = $langs->trans('subtitle');
170
+						}
162 171
 						$qty = 2;
163
-					}
164
-					else if($action=='add_subtotal_line') {
172
+					} else if($action=='add_subtotal_line') {
165 173
 						$title = $langs->trans('SubSubTotal');
166 174
 						$qty = 98;
167
-					}
168
-					else {
175
+					} else {
169 176
 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
170 177
 						$qty = $level ? 100-$level : 99;
171 178
 					}
172 179
 					dol_include_once('/subtotal/class/subtotal.class.php');
173 180
 					
174
-					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
181
+					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) {
182
+						TSubtotal::addSubtotalMissing($object, $qty);
183
+					}
175 184
 					
176 185
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
177
-				}
178
-				else if($action==='ask_deleteallline') {
186
+				} else if($action==='ask_deleteallline') {
179 187
 						$form=new Form($db);
180 188
 						
181 189
 						$lineid = GETPOST('lineid','integer');
@@ -198,8 +206,7 @@  discard block
 block discarded – undo
198 206
 					$this->printNewFormat($object, $conf, $langs, $idvar);
199 207
 				}
200 208
 			}
201
-		}
202
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
209
+		} elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
203 210
 		{
204 211
 			?>
205 212
 			<script type="text/javascript">
@@ -217,8 +224,13 @@  discard block
 block discarded – undo
217 224
      
218 225
 	function printNewFormat(&$object, &$conf, &$langs, $idvar)
219 226
 	{
220
-		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) return false;
221
-		if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) return false; // Si facture de situation
227
+		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) {
228
+			return false;
229
+		}
230
+		if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) {
231
+			return false;
232
+		}
233
+		// Si facture de situation
222 234
 		?>
223 235
 		 	<script type="text/javascript">
224 236
 				$(document).ready(function() {
@@ -504,8 +516,7 @@  discard block
 block discarded – undo
504 516
 				}
505 517
 				
506 518
 				
507
-			}	
508
-			else{
519
+			} else{
509 520
 				$substitutionarray['line_not_modsubtotal'] = true;
510 521
 				$substitutionarray['line_modsubtotal'] = 0;
511 522
 			}
@@ -563,8 +574,11 @@  discard block
 block discarded – undo
563 574
 		
564 575
 		$showBlockExtrafields = GETPOST('showBlockExtrafields');
565 576
 		
566
-		if($object->element=='facture') $idvar = 'facid';
567
-		else $idvar = 'id';
577
+		if($object->element=='facture') {
578
+			$idvar = 'facid';
579
+		} else {
580
+			$idvar = 'id';
581
+		}
568 582
 			
569 583
 		if ($action == 'updateligne' || $action == 'updateline')
570 584
 		{
@@ -594,8 +608,7 @@  discard block
 block discarded – undo
594 608
 				header('Location: '.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id);
595 609
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
596 610
 			}
597
-		}
598
-		else if($action === 'builddoc') {
611
+		} else if($action === 'builddoc') {
599 612
 			
600 613
 			if (
601 614
 				in_array('invoicecard',explode(':',$parameters['context']))
@@ -610,33 +623,27 @@  discard block
 block discarded – undo
610 623
 					$sessname = 'subtotal_hideInnerLines_facture';	
611 624
 					$sessname2 = 'subtotal_hidedetails_facture';
612 625
 					$sessname3 = 'subtotal_hideprices_facture';
613
-				}
614
-				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
626
+				} elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
615 627
 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
616 628
 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
617 629
 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
618
-				}
619
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
630
+				} elseif(in_array('propalcard',explode(':',$parameters['context']))) {
620 631
 					$sessname = 'subtotal_hideInnerLines_propal';
621 632
 					$sessname2 = 'subtotal_hidedetails_propal';	
622 633
 					$sessname3 = 'subtotal_hideprices_propal';
623
-				}
624
-				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
634
+				} elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
625 635
 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
626 636
 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
627 637
 				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
628
-				}
629
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
638
+				} elseif(in_array('ordercard',explode(':',$parameters['context']))) {
630 639
 					$sessname = 'subtotal_hideInnerLines_commande';
631 640
 					$sessname2 = 'subtotal_hidedetails_commande';	
632 641
 					$sessname3 = 'subtotal_hideprices_commande';
633
-				}
634
-				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
642
+				} elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
635 643
 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
636 644
 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
637 645
 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
638
-				}
639
-				else {
646
+				} else {
640 647
 					$sessname = 'subtotal_hideInnerLines_unknown';
641 648
 					$sessname2 = 'subtotal_hidedetails_unknown';
642 649
 					$sessname3 = 'subtotal_hideprices_unknown';
@@ -645,15 +652,24 @@  discard block
 block discarded – undo
645 652
 				global $hideprices;
646 653
 				
647 654
 				$hideInnerLines = (int)GETPOST('hideInnerLines');
648
-				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) $_SESSION[$sessname] = array(); // prevent old system
655
+				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) {
656
+					$_SESSION[$sessname] = array();
657
+				}
658
+				// prevent old system
649 659
 				$_SESSION[$sessname][$object->id] = $hideInnerLines;		
650 660
 				
651 661
 				$hidedetails= (int)GETPOST('hidedetails');
652
-				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) $_SESSION[$sessname2] = array(); // prevent old system
662
+				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) {
663
+					$_SESSION[$sessname2] = array();
664
+				}
665
+				// prevent old system
653 666
 				$_SESSION[$sessname2][$object->id] = $hidedetails;
654 667
 				
655 668
 				$hideprices= (int)GETPOST('hideprices');
656
-				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) $_SESSION[$sessname3] = array(); // prevent old system
669
+				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) {
670
+					$_SESSION[$sessname3] = array();
671
+				}
672
+				// prevent old system
657 673
 				$_SESSION[$sessname3][$object->id] = $hideprices;
658 674
 				
659 675
 				foreach($object->lines as &$line) {
@@ -661,8 +677,7 @@  discard block
 block discarded – undo
661 677
 					    
662 678
                         if($line->qty>=90) {
663 679
                             $line->modsubtotal_total = 1;
664
-                        }
665
-                        else{
680
+                        } else{
666 681
                             $line->modsubtotal_title = 1;
667 682
                         }
668 683
                         
@@ -671,8 +686,7 @@  discard block
 block discarded – undo
671 686
 	        	}
672 687
 	        }
673 688
 			
674
-		}
675
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
689
+		} else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
676 690
 			
677 691
 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
678 692
 			
@@ -680,7 +694,9 @@  discard block
 block discarded – undo
680 694
 				/**
681 695
 				 * @var $object Facture
682 696
 				 */
683
-				if($object->element=='facture') $object->deleteline($idLine);
697
+				if($object->element=='facture') {
698
+					$object->deleteline($idLine);
699
+				}
684 700
 				/**
685 701
 				 * @var $object Facture fournisseur
686 702
 				 */
@@ -691,18 +707,25 @@  discard block
 block discarded – undo
691 707
 				/**
692 708
 				 * @var $object Propal
693 709
 				 */
694
-				else if($object->element=='propal') $object->deleteline($idLine);
710
+				else if($object->element=='propal') {
711
+					$object->deleteline($idLine);
712
+				}
695 713
 				/**
696 714
 				 * @var $object Propal Fournisseur
697 715
 				 */
698
-				else if($object->element=='supplier_proposal') $object->deleteline($idLine);
716
+				else if($object->element=='supplier_proposal') {
717
+					$object->deleteline($idLine);
718
+				}
699 719
 				/**
700 720
 				 * @var $object Commande
701 721
 				 */
702 722
 				else if($object->element=='commande') 
703 723
 				{
704
-					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
705
-					else $object->deleteline($idLine);
724
+					if ((float) DOL_VERSION >= 5.0) {
725
+						$object->deleteline($user, $idLine);
726
+					} else {
727
+						$object->deleteline($idLine);
728
+					}
706 729
 				}
707 730
 				/**
708 731
 				 * @var $object Commande fournisseur
@@ -714,21 +737,26 @@  discard block
 block discarded – undo
714 737
 				/**
715 738
 				 * @var $object Facturerec
716 739
 				 */
717
-				else if($object->element=='facturerec') $object->deleteline($idLine);
740
+				else if($object->element=='facturerec') {
741
+					$object->deleteline($idLine);
742
+				}
718 743
 			}
719 744
 			
720 745
 			header('location:?id='.$object->id);
721 746
 			exit;
722 747
 			
723
-		}
724
-		else if ($action == 'duplicate')
748
+		} else if ($action == 'duplicate')
725 749
 		{
726 750
 			$lineid = GETPOST('lineid', 'int');
727 751
 			$nbDuplicate = TSubtotal::duplicateLines($object, $lineid, true);
728 752
 			
729
-			if ($nbDuplicate > 0) setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
730
-			elseif ($nbDuplicate == 0) setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
731
-			else setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
753
+			if ($nbDuplicate > 0) {
754
+				setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
755
+			} elseif ($nbDuplicate == 0) {
756
+				setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
757
+			} else {
758
+				setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
759
+			}
732 760
 			
733 761
 			header('Location: ?id='.$object->id);
734 762
 			exit;
@@ -746,21 +774,26 @@  discard block
 block discarded – undo
746 774
 		global $conf;
747 775
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && !empty($object->table_element_line) && in_array($object->element, array('commande', 'facture', 'propal')))
748 776
 		{
749
-			if ($object->element == 'commande')
750
-				$obj = new OrderLine($object->db);
751
-			if ($object->element == 'propal')
752
-				$obj = new PropaleLigne($object->db);
753
-			if ($object->element == 'facture')
754
-				$obj = new FactureLigne($object->db);
777
+			if ($object->element == 'commande') {
778
+							$obj = new OrderLine($object->db);
779
+			}
780
+			if ($object->element == 'propal') {
781
+							$obj = new PropaleLigne($object->db);
782
+			}
783
+			if ($object->element == 'facture') {
784
+							$obj = new FactureLigne($object->db);
785
+			}
755 786
 			if (!empty($parameters['fk_element']))
756 787
 			{
757 788
 				
758 789
 				if($obj->fetch($parameters['fk_element'])){
759 790
 					$obj->id= $obj->rowid;
760
-					if (empty($obj->array_options))
761
-						$obj->fetch_optionals();
762
-					if (!empty($obj->array_options['options_subtotal_nc']))
763
-						return 1;
791
+					if (empty($obj->array_options)) {
792
+											$obj->fetch_optionals();
793
+					}
794
+					if (!empty($obj->array_options['options_subtotal_nc'])) {
795
+											return 1;
796
+					}
764 797
 				}
765 798
 			}
766 799
 		}
@@ -835,17 +868,18 @@  discard block
 block discarded – undo
835 868
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
836 869
 			if($l->rang>=$rang) {
837 870
 				//echo 'return!<br>';
838
-				if (!$return_all) return $total;
839
-				else return array($total, $total_tva, $total_ttc, $TTotal_tva);
840
-			}
841
-			else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
871
+				if (!$return_all) {
872
+					return $total;
873
+				} else {
874
+					return array($total, $total_tva, $total_ttc, $TTotal_tva);
875
+				}
876
+			} else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
842 877
 		  	{
843 878
 				$total = 0;
844 879
 				$total_tva = 0;
845 880
 				$total_ttc = 0;
846 881
 				$TTotal_tva = array();
847
-			}
848
-			elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
882
+			} elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
849 883
 				$total += $l->total_ht;
850 884
 				$total_tva += $l->total_tva;
851 885
 				$TTotal_tva[$l->tva_tx] += $l->total_tva;
@@ -853,8 +887,11 @@  discard block
 block discarded – undo
853 887
 			}
854 888
 			
855 889
 		}
856
-		if (!$return_all) return $total;
857
-		else return array($total, $total_tva, $total_ttc, $TTotal_tva);
890
+		if (!$return_all) {
891
+			return $total;
892
+		} else {
893
+			return array($total, $total_tva, $total_ttc, $TTotal_tva);
894
+		}
858 895
 	}
859 896
 
860 897
 	/*
@@ -922,15 +959,18 @@  discard block
 block discarded – undo
922 959
 		}
923 960
 		
924 961
 			
925
-		if($line->qty==99)
926
-			$pdf->SetFillColor(220,220,220);
927
-		elseif ($line->qty==98)
928
-			$pdf->SetFillColor(230,230,230);
929
-		else
930
-			$pdf->SetFillColor(240,240,240);
962
+		if($line->qty==99) {
963
+					$pdf->SetFillColor(220,220,220);
964
+		} elseif ($line->qty==98) {
965
+					$pdf->SetFillColor(230,230,230);
966
+		} else {
967
+					$pdf->SetFillColor(240,240,240);
968
+		}
931 969
 		
932 970
 		$style = 'B';
933
-		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
971
+		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) {
972
+			$style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
973
+		}
934 974
 		
935 975
 		$pdf->SetFont('', $style, 9);
936 976
 		
@@ -969,8 +1009,7 @@  discard block
 block discarded – undo
969 1009
 //					$line->total_tva
970 1010
 //					$line->total
971 1011
 //					$line->total_ttc
972
-				}
973
-				else
1012
+				} else
974 1013
 				{
975 1014
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
976 1015
                                         if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
@@ -987,11 +1026,14 @@  discard block
 block discarded – undo
987 1026
 			}
988 1027
 
989 1028
 			$pdf->SetXY($pdf->postotalht, $posy);
990
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1029
+			if($set_pagebreak_margin) {
1030
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1031
+			}
991 1032
 			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
992
-		}
993
-		else{
994
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1033
+		} else{
1034
+			if($set_pagebreak_margin) {
1035
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1036
+			}
995 1037
 		}
996 1038
 		
997 1039
 		$posy = $posy + $cell_height;
@@ -1023,25 +1065,40 @@  discard block
 block discarded – undo
1023 1065
 		
1024 1066
  
1025 1067
 		$style = ($line->qty==1) ? 'BU' : 'BUI';
1026
-		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
1068
+		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) {
1069
+			$style = $conf->global->SUBTOTAL_TITLE_STYLE;
1070
+		}
1027 1071
 		
1028 1072
 		if($hideInnerLines) {
1029
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
1030
-			else 
1073
+			if($line->qty==1) {
1074
+				$pdf->SetFont('', $style, 9);
1075
+			} else 
1031 1076
 			{
1032
-				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
1077
+				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) {
1078
+					$style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
1079
+				}
1033 1080
 				$pdf->SetFont('', $style, 9);
1034 1081
 			}
1035
-		}
1036
-		else {
1082
+		} else {
1037 1083
 
1038
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
1039
-			else $pdf->SetFont('', $style, 9);
1084
+			if($line->qty==1) {
1085
+				$pdf->SetFont('', $style, 9);
1086
+			}
1087
+			//TODO if super utile
1088
+			else {
1089
+				$pdf->SetFont('', $style, 9);
1090
+			}
1040 1091
 			
1041 1092
 		}
1042 1093
 		
1043
-		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) $pdf->MultiCell($w, $h, $label, 0, 'L'); // Pas de HTML dans la chaine
1044
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
1094
+		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) {
1095
+			$pdf->MultiCell($w, $h, $label, 0, 'L');
1096
+		}
1097
+		// Pas de HTML dans la chaine
1098
+		else {
1099
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true);
1100
+		}
1101
+		// et maintenant avec du HTML
1045 1102
 		
1046 1103
 		if($description && !$hidedesc) {
1047 1104
 			$posy = $pdf->GetY();
@@ -1065,8 +1122,7 @@  discard block
 block discarded – undo
1065 1122
 		
1066 1123
 		if(is_array($parameters)) {
1067 1124
 			$i = & $parameters['i'];	
1068
-		}
1069
-		else {
1125
+		} else {
1070 1126
 			$i = (int)$parameters;
1071 1127
 		}
1072 1128
 		
@@ -1088,17 +1144,14 @@  discard block
 block discarded – undo
1088 1144
 			
1089 1145
 			if((float)DOL_VERSION<=3.6) {
1090 1146
 				return '';
1091
-			}
1092
-			else if((float)DOL_VERSION>=3.8) {
1147
+			} else if((float)DOL_VERSION>=3.8) {
1093 1148
 				return 1;
1094 1149
 			}
1095 1150
 			
1096
-		}
1097
-		elseif(!empty($hideprices)) {
1151
+		} elseif(!empty($hideprices)) {
1098 1152
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1099 1153
 			return 1;
1100
-		}
1101
-		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1154
+		} elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1102 1155
 		{
1103 1156
 			$hideInnerLines = (int)GETPOST('hideInnerLines');
1104 1157
 			$hidedetails = (int)GETPOST('hidedetails');
@@ -1108,12 +1161,20 @@  discard block
 block discarded – undo
1108 1161
 			}
1109 1162
 		}
1110 1163
 		
1111
-		if(is_array($parameters)) $i = & $parameters['i'];
1112
-		else $i = (int)$parameters;
1164
+		if(is_array($parameters)) {
1165
+			$i = & $parameters['i'];
1166
+		} else {
1167
+			$i = (int)$parameters;
1168
+		}
1113 1169
 
1114
-		if (empty($object->lines[$i])) return 0; // hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1170
+		if (empty($object->lines[$i])) {
1171
+			return 0;
1172
+		}
1173
+		// hideInnerLines => override $object->lines et Dolibarr ne nous permet pas de mettre à jour la variable qui conditionne la boucle sur les lignes (PR faite pour 6.0)
1115 1174
 		
1116
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1175
+		if(empty($object->lines[$i]->array_options)) {
1176
+			$object->lines[$i]->fetch_optionals();
1177
+		}
1117 1178
 
1118 1179
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1119 1180
 		{
@@ -1130,8 +1191,11 @@  discard block
 block discarded – undo
1130 1191
 	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1131 1192
 	    global $conf, $hideprices, $hookmanager;
1132 1193
 		
1133
-		if(is_array($parameters)) $i = & $parameters['i'];
1134
-		else $i = (int)$parameters;
1194
+		if(is_array($parameters)) {
1195
+			$i = & $parameters['i'];
1196
+		} else {
1197
+			$i = (int)$parameters;
1198
+		}
1135 1199
 			
1136 1200
 		if($this->isModSubtotalLine($parameters,$object) ){
1137 1201
 			
@@ -1139,13 +1203,11 @@  discard block
 block discarded – undo
1139 1203
 			
1140 1204
 			if((float)DOL_VERSION<=3.6) {
1141 1205
 				return '';
1142
-			}
1143
-			else if((float)DOL_VERSION>=3.8) {
1206
+			} else if((float)DOL_VERSION>=3.8) {
1144 1207
 				return 1;
1145 1208
 			}
1146 1209
 			
1147
-		}
1148
-		elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1210
+		} elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1149 1211
 		{
1150 1212
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1151 1213
 			{
@@ -1217,12 +1279,10 @@  discard block
 block discarded – undo
1217 1279
 			$this->error = $hookmanager->error;
1218 1280
 			$this->errors = $hookmanager->errors;
1219 1281
 			return -1;
1220
-		}
1221
-		elseif (empty($reshook))
1282
+		} elseif (empty($reshook))
1222 1283
 		{
1223 1284
 			$this->resprints .= $hookmanager->resprints;
1224
-		}
1225
-		else
1285
+		} else
1226 1286
 		{
1227 1287
 			$this->resprints = $hookmanager->resprints;
1228 1288
 
@@ -1245,14 +1305,16 @@  discard block
 block discarded – undo
1245 1305
 		
1246 1306
 			if((float)DOL_VERSION<=3.6) {
1247 1307
 				return '';
1248
-			}
1249
-			else if((float)DOL_VERSION>=3.8) {
1308
+			} else if((float)DOL_VERSION>=3.8) {
1250 1309
 				return 1;
1251 1310
 			}
1252 1311
 		}
1253 1312
 		
1254
-		if(is_array($parameters)) $i = & $parameters['i'];
1255
-		else $i = (int)$parameters;
1313
+		if(is_array($parameters)) {
1314
+			$i = & $parameters['i'];
1315
+		} else {
1316
+			$i = (int)$parameters;
1317
+		}
1256 1318
 		
1257 1319
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1258 1320
 		{
@@ -1274,14 +1336,16 @@  discard block
 block discarded – undo
1274 1336
 		
1275 1337
 			if((float)DOL_VERSION<=3.6) {
1276 1338
 				return '';
1277
-			}
1278
-			else if((float)DOL_VERSION>=3.8) {
1339
+			} else if((float)DOL_VERSION>=3.8) {
1279 1340
 				return 1;
1280 1341
 			}
1281 1342
 		}
1282 1343
 		
1283
-		if(is_array($parameters)) $i = & $parameters['i'];
1284
-		else $i = (int)$parameters;
1344
+		if(is_array($parameters)) {
1345
+			$i = & $parameters['i'];
1346
+		} else {
1347
+			$i = (int)$parameters;
1348
+		}
1285 1349
 			
1286 1350
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1287 1351
 		{
@@ -1298,8 +1362,11 @@  discard block
 block discarded – undo
1298 1362
 	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1299 1363
 	    global $conf,$hideprices,$hookmanager, $TTotal, $show_reduc;
1300 1364
 
1301
-		if(is_array($parameters)) $i = & $parameters['i'];
1302
-		else $i = (int)$parameters;
1365
+		if(is_array($parameters)) {
1366
+			$i = & $parameters['i'];
1367
+		} else {
1368
+			$i = (int)$parameters;
1369
+		}
1303 1370
 
1304 1371
 		if($this->isModSubtotalLine($parameters,$object) ) {
1305 1372
 			$this->resprints = ' ';
@@ -1309,8 +1376,10 @@  discard block
 block discarded – undo
1309 1376
             // On récupère les montants du bloc...
1310 1377
             if(TSubtotal::isTitle($line)) {
1311 1378
 //                $show_reduc = $line->array_options['options_show_reduc'];
1312
-                if(! empty($line->array_options['options_show_total_ht'])) $TTotal = TSubtotal::getTotalBlockFromTitle($object, $line);
1313
-//                if(! empty($show_reduc)) $object->lines[$i]->remise_percent = 1;
1379
+                if(! empty($line->array_options['options_show_total_ht'])) {
1380
+                	$TTotal = TSubtotal::getTotalBlockFromTitle($object, $line);
1381
+                }
1382
+                //                if(! empty($show_reduc)) $object->lines[$i]->remise_percent = 1;
1314 1383
             }
1315 1384
 
1316 1385
             // ... pour les afficher dans la ligne de sous-total
@@ -1323,8 +1392,7 @@  discard block
 block discarded – undo
1323 1392
 		
1324 1393
 			if((float)DOL_VERSION<=3.6) {
1325 1394
 				return '';
1326
-			}
1327
-			else if((float)DOL_VERSION>=3.8) {
1395
+			} else if((float)DOL_VERSION>=3.8) {
1328 1396
 				return 1;
1329 1397
 			}
1330 1398
 		}
@@ -1369,8 +1437,11 @@  discard block
 block discarded – undo
1369 1437
 	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1370 1438
 	    global $conf,$hideprices,$hookmanager, $TTotal;
1371 1439
 
1372
-        if(is_array($parameters)) $i = & $parameters['i'];
1373
-        else $i = (int) $parameters;
1440
+        if(is_array($parameters)) {
1441
+        	$i = & $parameters['i'];
1442
+        } else {
1443
+        	$i = (int) $parameters;
1444
+        }
1374 1445
 
1375 1446
 		if($this->isModSubtotalLine($parameters,$object) ) {
1376 1447
 			$this->resprints = ' ';
@@ -1382,14 +1453,15 @@  discard block
 block discarded – undo
1382 1453
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1383 1454
                 $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1384 1455
 
1385
-                if(! empty($parentTitle->array_options['options_show_reduc'])) $this->resprints = price($TTotal['total_ht'] / $TTotal['total_subprice']*100, 0, '', 1, 2, 2).'%';
1456
+                if(! empty($parentTitle->array_options['options_show_reduc'])) {
1457
+                	$this->resprints = price($TTotal['total_ht'] / $TTotal['total_subprice']*100, 0, '', 1, 2, 2).'%';
1458
+                }
1386 1459
                 $TTotal = array();
1387 1460
             }
1388 1461
 		
1389 1462
 			if((float)DOL_VERSION<=3.6) {
1390 1463
 				return '';
1391
-			}
1392
-			else if((float)DOL_VERSION>=3.8) {
1464
+			} else if((float)DOL_VERSION>=3.8) {
1393 1465
 				return 1;
1394 1466
 			}
1395 1467
 		}
@@ -1404,14 +1476,16 @@  discard block
 block discarded – undo
1404 1476
 			$this->resprints = ' ';
1405 1477
 			if((float)DOL_VERSION<=3.6) {
1406 1478
 				return '';
1407
-			}
1408
-			else if((float)DOL_VERSION>=3.8) {
1479
+			} else if((float)DOL_VERSION>=3.8) {
1409 1480
 				return 1;
1410 1481
 			}
1411 1482
 		}
1412 1483
 		
1413
-		if(is_array($parameters)) $i = & $parameters['i'];
1414
-		else $i = (int)$parameters;
1484
+		if(is_array($parameters)) {
1485
+			$i = & $parameters['i'];
1486
+		} else {
1487
+			$i = (int)$parameters;
1488
+		}
1415 1489
 			
1416 1490
 		if (!empty($hideprices)
1417 1491
 				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
@@ -1435,16 +1509,21 @@  discard block
 block discarded – undo
1435 1509
 			
1436 1510
 			if((float)DOL_VERSION<=3.6) {
1437 1511
 				return '';
1438
-			}
1439
-			else if((float)DOL_VERSION>=3.8) {
1512
+			} else if((float)DOL_VERSION>=3.8) {
1440 1513
 				return 1;
1441 1514
 			}
1442 1515
 		}
1443 1516
 		
1444
-		if(is_array($parameters)) $i = & $parameters['i'];
1445
-		else $i = (int)$parameters;
1517
+		if(is_array($parameters)) {
1518
+			$i = & $parameters['i'];
1519
+		} else {
1520
+			$i = (int)$parameters;
1521
+		}
1446 1522
 		
1447
-		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)
1523
+		if (empty($object->lines[$i])) {
1524
+			return 0;
1525
+		}
1526
+		// 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)
1448 1527
 
1449 1528
 		$object->lines[$i]->fetch_optionals();
1450 1529
 		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
@@ -1490,14 +1569,16 @@  discard block
 block discarded – undo
1490 1569
 			$this->resprints = ' ';
1491 1570
 			if((float)DOL_VERSION<=3.6) {
1492 1571
 				return '';
1493
-			}
1494
-			else if((float)DOL_VERSION>=3.8) {
1572
+			} else if((float)DOL_VERSION>=3.8) {
1495 1573
 				return 1;
1496 1574
 			}
1497 1575
 		}
1498 1576
 		
1499
-		if(is_array($parameters)) $i = & $parameters['i'];
1500
-		else $i = (int)$parameters;
1577
+		if(is_array($parameters)) {
1578
+			$i = & $parameters['i'];
1579
+		} else {
1580
+			$i = (int)$parameters;
1581
+		}
1501 1582
 			
1502 1583
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1503 1584
 		{
@@ -1527,7 +1608,9 @@  discard block
 block discarded – undo
1527 1608
 				}
1528 1609
 			}
1529 1610
 			
1530
-			if (!empty($TLineTitle)) $TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1611
+			if (!empty($TLineTitle)) {
1612
+				$TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1613
+			}
1531 1614
 		}
1532 1615
 		
1533 1616
 	}
@@ -1541,8 +1624,12 @@  discard block
 block discarded – undo
1541 1624
 		$j=0;
1542 1625
 		foreach ($TLineTitle as $k => &$line)
1543 1626
 		{
1544
-			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
1545
-			if (!empty($line_reference) && $line->qty <= $line_reference->qty) break;
1627
+			if (!empty($line_reference) && $line->rang <= $line_reference->rang) {
1628
+				continue;
1629
+			}
1630
+			if (!empty($line_reference) && $line->qty <= $line_reference->qty) {
1631
+				break;
1632
+			}
1546 1633
 			
1547 1634
 			if ($line->qty == $level)
1548 1635
 			{
@@ -1576,7 +1663,9 @@  discard block
 block discarded – undo
1576 1663
 		
1577 1664
 		$hidedetails = (int)GETPOST('hidedetails');
1578 1665
 		
1579
-		if(empty($hidedetails)) return false;
1666
+		if(empty($hidedetails)) {
1667
+			return false;
1668
+		}
1580 1669
 		
1581 1670
 		// TODO can't add VAT to document without lines... :-/
1582 1671
 		
@@ -1637,7 +1726,9 @@  discard block
 block discarded – undo
1637 1726
 						*/
1638 1727
 						list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
1639 1728
 						
1640
-						if (TSubtotal::getNiveau($line) == 1) $line->TTotal_tva = $TTotal_tva;
1729
+						if (TSubtotal::getNiveau($line) == 1) {
1730
+							$line->TTotal_tva = $TTotal_tva;
1731
+						}
1641 1732
 						$line->total_ht = $total;
1642 1733
 						$line->total_tva = $total_tva;
1643 1734
 						$line->total = $line->total_ht;
@@ -1701,8 +1792,7 @@  discard block
 block discarded – undo
1701 1792
 				    }
1702 1793
 				    
1703 1794
 					
1704
-				}
1705
-				elseif ($hidedetails)
1795
+				} elseif ($hidedetails)
1706 1796
 				{
1707 1797
 					$TLines[] = $line; //Cas où je cache uniquement les prix des produits	
1708 1798
 				}
@@ -1773,7 +1863,9 @@  discard block
 block discarded – undo
1773 1863
 				
1774 1864
 				if(!empty($hideprices)) {
1775 1865
 					foreach($object->lines as &$line) {
1776
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1866
+						if($line->fk_product_type!=9) {
1867
+							$line->fk_parent_line = -1;
1868
+						}
1777 1869
 					}
1778 1870
 				}
1779 1871
 			
@@ -1794,7 +1886,9 @@  discard block
 block discarded – undo
1794 1886
 				
1795 1887
 				if($line->qty>90) {
1796 1888
 					
1797
-					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1889
+					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) {
1890
+						$label .= ' '.$this->getTitle($object, $line);
1891
+					}
1798 1892
 					
1799 1893
 					$pageBefore = $pdf->getPage();
1800 1894
 					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
@@ -1812,8 +1906,7 @@  discard block
 block discarded – undo
1812 1906
 				
1813 1907
 					$posy = $pdf->GetY();
1814 1908
 					return 1;
1815
-				}	
1816
-				else if ($line->qty < 10) {
1909
+				} else if ($line->qty < 10) {
1817 1910
 					$pageBefore = $pdf->getPage();
1818 1911
 
1819 1912
 					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
@@ -1837,8 +1930,7 @@  discard block
 block discarded – undo
1837 1930
 //	if($line->rowid==47) exit;
1838 1931
 			
1839 1932
 			return 0;
1840
-		}
1841
-		elseif (empty($object->lines[$parameters['i']]))
1933
+		} elseif (empty($object->lines[$parameters['i']]))
1842 1934
 		{
1843 1935
 			$this->resprints = -1;
1844 1936
 		}
@@ -1871,7 +1963,9 @@  discard block
 block discarded – undo
1871 1963
 		
1872 1964
 		foreach ($object->lines as $line)
1873 1965
 		{
1874
-			if ($line->id == $currentLine->id) break;
1966
+			if ($line->id == $currentLine->id) {
1967
+				break;
1968
+			}
1875 1969
 			
1876 1970
 			$qty_search = 100 - $currentLine->qty;
1877 1971
 			
@@ -1908,23 +2002,23 @@  discard block
 block discarded – undo
1908 2002
 		{
1909 2003
 			$object->statut = 0; // hack for facture rec
1910 2004
 			$createRight = $user->rights->facture->creer;
1911
-		}
1912
-		elseif($object->element == 'order_supplier' )
2005
+		} elseif($object->element == 'order_supplier' )
1913 2006
 		{
1914 2007
 		    $createRight = $user->rights->fournisseur->commande->creer;
1915
-		}
1916
-		elseif($object->element == 'invoice_supplier' )
2008
+		} elseif($object->element == 'invoice_supplier' )
1917 2009
 		{
1918 2010
 		    $createRight = $user->rights->fournisseur->facture->creer;
1919 2011
 		}
1920 2012
 		
1921 2013
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1922 2014
 			null;
1923
-		}	
1924
-		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)) 
2015
+		} 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)) 
1925 2016
         {
1926
-			if($object->element=='facture')$idvar = 'facid';
1927
-			else $idvar='id';
2017
+			if($object->element=='facture') {
2018
+				$idvar = 'facid';
2019
+			} else {
2020
+				$idvar='id';
2021
+			}
1928 2022
 			
1929 2023
 			if((float)DOL_VERSION <= 3.4)
1930 2024
 			{
@@ -1950,20 +2044,44 @@  discard block
 block discarded – undo
1950 2044
 				<?php
1951 2045
 			}
1952 2046
 			
1953
-			if(empty($line->description)) $line->description = $line->desc;
2047
+			if(empty($line->description)) {
2048
+				$line->description = $line->desc;
2049
+			}
1954 2050
 			
1955 2051
 			$colspan = 5;
1956
-			if($object->element == 'facturerec' ) $colspan = 3;
1957
-			if($object->element == 'order_supplier') $colspan = 3;
1958
-			if($object->element == 'invoice_supplier') $colspan = 4;
1959
-			if($object->element == 'supplier_proposal') $colspan = 4;
1960
-			if(!empty($conf->multicurrency->enabled)) $colspan+=2;
1961
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1962
-			if(!empty($conf->margin->enabled)) $colspan++;
1963
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1964
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1965
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1966
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
2052
+			if($object->element == 'facturerec' ) {
2053
+				$colspan = 3;
2054
+			}
2055
+			if($object->element == 'order_supplier') {
2056
+				$colspan = 3;
2057
+			}
2058
+			if($object->element == 'invoice_supplier') {
2059
+				$colspan = 4;
2060
+			}
2061
+			if($object->element == 'supplier_proposal') {
2062
+				$colspan = 4;
2063
+			}
2064
+			if(!empty($conf->multicurrency->enabled)) {
2065
+				$colspan+=2;
2066
+			}
2067
+			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) {
2068
+				$colspan++;
2069
+			}
2070
+			if(!empty($conf->margin->enabled)) {
2071
+				$colspan++;
2072
+			}
2073
+			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) {
2074
+				$colspan++;
2075
+			}
2076
+			if(!empty($conf->global->DISPLAY_MARK_RATES)) {
2077
+				$colspan++;
2078
+			}
2079
+			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) {
2080
+				$colspan++;
2081
+			}
2082
+			if(!empty($conf->global->PRODUCT_USE_UNITS)) {
2083
+				$colspan++;
2084
+			}
1967 2085
 					
1968 2086
 			/* Titre */
1969 2087
 			//var_dump($line);
@@ -1976,23 +2094,36 @@  discard block
 block discarded – undo
1976 2094
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
1977 2095
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
1978 2096
 					{
1979
-						if($line->qty==99) print 'background:#adadcf';
1980
-						else if($line->qty==98) print 'background:#ddddff;';
1981
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
1982
-						else if($line->qty==1) print 'background:#adadcf;';
1983
-						else if($line->qty==2) print 'background:#ddddff;';
1984
-						else if($line->qty==50) print '';
1985
-						else print 'background:#eeeeff;';
2097
+						if($line->qty==99) {
2098
+							print 'background:#adadcf';
2099
+						} else if($line->qty==98) {
2100
+							print 'background:#ddddff;';
2101
+						} else if($line->qty<=97 && $line->qty>=91) {
2102
+							print 'background:#eeeeff;';
2103
+						} else if($line->qty==1) {
2104
+							print 'background:#adadcf;';
2105
+						} else if($line->qty==2) {
2106
+							print 'background:#ddddff;';
2107
+						} else if($line->qty==50) {
2108
+							print '';
2109
+						} else {
2110
+							print 'background:#eeeeff;';
2111
+						}
1986 2112
 
1987 2113
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
1988
-					}
1989
-					else 
2114
+					} else 
1990 2115
 					{
1991
-						if($line->qty==99) print 'background:#ddffdd';
1992
-						else if($line->qty==98) print 'background:#ddddff;';
1993
-						else if($line->qty==2) print 'background:#eeeeff; ';
1994
-						else if($line->qty==50) print '';
1995
-						else print 'background:#eeffee;' ;
2116
+						if($line->qty==99) {
2117
+							print 'background:#ddffdd';
2118
+						} else if($line->qty==98) {
2119
+							print 'background:#ddddff;';
2120
+						} else if($line->qty==2) {
2121
+							print 'background:#eeeeff; ';
2122
+						} else if($line->qty==50) {
2123
+							print '';
2124
+						} else {
2125
+							print 'background:#eeffee;' ;
2126
+						}
1996 2127
 					}
1997 2128
 
1998 2129
 			?>;">
@@ -2015,13 +2146,11 @@  discard block
 block discarded – undo
2015 2146
 							$qty_displayed = $line->qty;
2016 2147
 							print img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
2017 2148
 							
2018
-						}
2019
-						else if (TSubtotal::isSubtotal($line))
2149
+						} else if (TSubtotal::isSubtotal($line))
2020 2150
 						{
2021 2151
 							$qty_displayed = 100 - $line->qty;
2022 2152
 							print img_picto('', 'subsubtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
2023
-						}
2024
-						else
2153
+						} else
2025 2154
 						{
2026 2155
 							$isFreeText = true;
2027 2156
 						}
@@ -2042,9 +2171,13 @@  discard block
 block discarded – undo
2042 2171
 						}
2043 2172
 
2044 2173
 						$readonlyForSituation = '';
2045
-						if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) $readonlyForSituation = 'readonly';
2174
+						if (!empty($object->situation_cycle_ref) && $object->situation_counter > 1) {
2175
+							$readonlyForSituation = 'readonly';
2176
+						}
2046 2177
 						
2047
-						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2178
+						if (!$isFreeText) {
2179
+							echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2180
+						}
2048 2181
 						
2049 2182
 						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
2050 2183
 						{
@@ -2052,8 +2185,12 @@  discard block
 block discarded – undo
2052 2185
 							for ($j=1; $j<10; $j++)
2053 2186
 							{
2054 2187
 								if (!empty($readonlyForSituation)) {
2055
-									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2056
-								} else $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2188
+									if ($qty_displayed == $j) {
2189
+										$select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2190
+									}
2191
+								} else {
2192
+									$select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2193
+								}
2057 2194
 							}
2058 2195
 							$select .= '</select>&nbsp;';
2059 2196
 
@@ -2073,7 +2210,9 @@  discard block
 block discarded – undo
2073 2210
                             echo '<div>';
2074 2211
                             echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2075 2212
                             echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2076
-                            if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2213
+                            if (empty($readonlyForSituation)) {
2214
+                            	echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2215
+                            }
2077 2216
                             echo '</select>';
2078 2217
                             echo '</div>';
2079 2218
 
@@ -2092,8 +2231,9 @@  discard block
 block discarded – undo
2092 2231
                             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;';
2093 2232
                             echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2094 2233
                             echo '</div>';
2234
+                        } else if ($isFreeText) {
2235
+                        	echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2095 2236
                         }
2096
-                        else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2097 2237
 						echo '</div>';
2098 2238
 
2099 2239
 						if($line->qty<10) {
@@ -2113,8 +2253,7 @@  discard block
 block discarded – undo
2113 2253
 							$doleditor->Create();
2114 2254
 						}
2115 2255
 						
2116
-					}
2117
-					else {
2256
+					} else {
2118 2257
 
2119 2258
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2120 2259
 						 {
@@ -2122,14 +2261,19 @@  discard block
 block discarded – undo
2122 2261
 							{
2123 2262
 								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2124 2263
 								
2125
-								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2126
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2264
+								if (TSubtotal::isTitle($line)) {
2265
+									print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2266
+								} else {
2267
+									print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2268
+								}
2127 2269
 							}
2128
-						 }
2129
-						 else 
2270
+						 } else 
2130 2271
 						 {
2131
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2132
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2272
+							if($line->qty<=1) {
2273
+								print img_picto('', 'subtotal@subtotal');
2274
+							} else if($line->qty==2) {
2275
+								print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2276
+							}
2133 2277
 						 }
2134 2278
 						 
2135 2279
 						 
@@ -2139,21 +2283,26 @@  discard block
 block discarded – undo
2139 2283
 						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2140 2284
 						 
2141 2285
 						 if (empty($line->label)) {
2142
-							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2143
-							else print  $line->description;
2144
-						 } 
2145
-						 else {
2286
+							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2287
+								print  $line->description.' '.$this->getTitle($object, $line);
2288
+							} else {
2289
+								print  $line->description;
2290
+							}
2291
+						 } else {
2146 2292
 
2147 2293
 							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2148 2294
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2149
-							}
2150
-							else{
2295
+							} else{
2151 2296
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
2152 2297
 							}
2153 2298
 
2154 2299
 						 } 
2155
-						if($line->qty>90) print ' : ';
2156
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2300
+						if($line->qty>90) {
2301
+							print ' : ';
2302
+						}
2303
+						if($line->info_bits > 0) {
2304
+							echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2305
+						}
2157 2306
 
2158 2307
 						 
2159 2308
 
@@ -2190,11 +2339,12 @@  discard block
 block discarded – undo
2190 2339
 						</script>
2191 2340
 						<?php
2192 2341
 						
2193
-					}
2194
-					else{
2342
+					} else{
2195 2343
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2196 2344
 						{
2197
-							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2345
+							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) {
2346
+								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2347
+							}
2198 2348
 						}
2199 2349
 
2200 2350
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
@@ -2263,7 +2413,9 @@  discard block
 block discarded – undo
2263 2413
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2264 2414
 				
2265 2415
 				$colspan+=3; $mode = 'view';
2266
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2416
+				if($action === 'editline' && $line->rowid == GETPOST('lineid')) {
2417
+					$mode = 'edit';
2418
+				}
2267 2419
 				
2268 2420
 				$ex_element = $line->element;
2269 2421
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
@@ -2445,10 +2597,9 @@  discard block
 block discarded – undo
2445 2597
 	    
2446 2598
 	    if(TSubtotal::isTitle($line)){
2447 2599
 	        $ThtmlData['data-issubtotal'] = 'title';
2448
-	    }elseif(TSubtotal::isSubtotal($line)){
2600
+	    } elseif(TSubtotal::isSubtotal($line)){
2449 2601
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2450
-	    }
2451
-	    else{
2602
+	    } else{
2452 2603
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2453 2604
 	    }
2454 2605
 	    
@@ -2458,7 +2609,9 @@  discard block
 block discarded – undo
2458 2609
 	    
2459 2610
 	    // hook 
2460 2611
 	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2461
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2612
+	    if ($reshook < 0) {
2613
+	    	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2614
+	    }
2462 2615
 	    if ($reshook>0)
2463 2616
 	    {
2464 2617
 	        $ThtmlData = $hookmanager->resArray;
Please login to merge, or discard this patch.
class/subtotal.class.php 1 patch
Braces   +279 added lines, -136 removed lines patch added patch discarded remove patch
@@ -13,18 +13,23 @@  discard block
 block discarded – undo
13 13
 			/**
14 14
 			 * @var $object Facture
15 15
 			 */
16
-			if($object->element=='facture') $res =  $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number);
16
+			if($object->element=='facture') {
17
+				$res =  $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number);
18
+			}
17 19
 			/**
18 20
 			 * @var $object Propal
19 21
 			 */
20
-			else if($object->element=='propal') $res =  $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number);
22
+			else if($object->element=='propal') {
23
+				$res =  $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number);
24
+			}
21 25
 			/**
22 26
 			 * @var $object Commande
23 27
 			 */
24
-			else if($object->element=='commande') $res =  $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number);
28
+			else if($object->element=='commande') {
29
+				$res =  $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number);
30
+			}
25 31
 
26
-		}
27
-		else {
32
+		} else {
28 33
 			$desc = '';
29 34
 			if ((float) DOL_VERSION < 6  || $qty==50) {
30 35
 				$desc = $label;
@@ -34,29 +39,40 @@  discard block
 block discarded – undo
34 39
 			/**
35 40
 			 * @var $object Facture
36 41
 			 */
37
-			if($object->element=='facture') $res =  $object->addline($desc, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,$rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label);
42
+			if($object->element=='facture') {
43
+				$res =  $object->addline($desc, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,$rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label);
44
+			}
38 45
 			/**
39 46
 			 * @var $object Facture fournisseur
40 47
 			 */
41 48
 			else if($object->element=='invoice_supplier') {
42 49
 			    $object->special_code = TSubtotal::$module_number;
43 50
 			    $rang = $object->line_max() + 1;
44
-			    if($qty==50) $res = $object->addline($desc,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
45
-			    else $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
51
+			    if($qty==50) {
52
+			    	$res = $object->addline($desc,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
53
+			    } else {
54
+			    	$res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
55
+			    }
46 56
 			}
47 57
 			/**
48 58
 			 * @var $object Propal
49 59
 			 */
50
-			else if($object->element=='propal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
60
+			else if($object->element=='propal') {
61
+				$res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
62
+			}
51 63
 			/**
52 64
 			 * @var $object Propal Fournisseur
53 65
 			 */
54
-			else if($object->element=='supplier_proposal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
66
+			else if($object->element=='supplier_proposal') {
67
+				$res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
68
+			}
55 69
 			
56 70
 			/**
57 71
 			 * @var $object Commande
58 72
 			 */
59
-			else if($object->element=='commande') $res =  $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label);
73
+			else if($object->element=='commande') {
74
+				$res =  $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label);
75
+			}
60 76
 			/**
61 77
 			 * @var $object Commande fournisseur
62 78
 			 */
@@ -67,7 +83,9 @@  discard block
 block discarded – undo
67 83
 			/**
68 84
 			 * @var $object Facturerec
69 85
 			 */
70
-			else if($object->element=='facturerec') $res =  $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label); 
86
+			else if($object->element=='facturerec') {
87
+				$res =  $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label);
88
+			}
71 89
 			
72 90
 		}
73 91
 	
@@ -89,8 +107,9 @@  discard block
 block discarded – undo
89 107
 			// Define output language
90 108
 			$outputlangs = $langs;
91 109
 			$newlang = GETPOST('lang_id', 'alpha');
92
-			if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
93
-				$newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang;
110
+			if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
111
+							$newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang;
112
+			}
94 113
 			if (! empty($newlang)) {
95 114
 				$outputlangs = new Translate("", $conf);
96 115
 				$outputlangs->setDefaultLang($newlang);
@@ -99,13 +118,18 @@  discard block
 block discarded – undo
99 118
 			$ret = $object->fetch($object->id); // Reload to get new records
100 119
 			if ((float) DOL_VERSION <= 3.6)
101 120
 			{
102
-				if ($object->element == 'propal') propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
103
-				elseif ($object->element == 'commande') commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
104
-				elseif ($object->element == 'facture') facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
105
-			}
106
-			else
121
+				if ($object->element == 'propal') {
122
+					propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
123
+				} elseif ($object->element == 'commande') {
124
+					commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
125
+				} elseif ($object->element == 'facture') {
126
+					facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
127
+				}
128
+			} else
107 129
 			{
108
-				if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
130
+				if ($object->element!= 'facturerec') {
131
+					$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
132
+				}
109 133
 			}
110 134
 		}
111 135
 	}
@@ -119,7 +143,9 @@  discard block
 block discarded – undo
119 143
 	 */
120 144
 	public static function updateRang(&$object, $rang_start, $move_to=1)
121 145
 	{
122
-		if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
146
+		if (!class_exists('GenericObject')) {
147
+			require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
148
+		}
123 149
 		
124 150
 		$row=new GenericObject($object->db);
125 151
 		$row->table_element_line = $object->table_element_line;
@@ -128,7 +154,9 @@  discard block
 block discarded – undo
128 154
 		
129 155
 		foreach ($object->lines as &$line)
130 156
 		{
131
-			if ($line->rang < $rang_start) continue;
157
+			if ($line->rang < $rang_start) {
158
+				continue;
159
+			}
132 160
 			
133 161
 			$row->updateRangOfLine($line->id, $line->rang+$move_to);
134 162
 		}
@@ -151,21 +179,28 @@  discard block
 block discarded – undo
151 179
 		foreach ($TTitle_reverse as $k => $title_line)
152 180
 		{
153 181
 			$title_niveau = self::getNiveau($title_line);
154
-			if ($title_niveau < $level_new_title) break;
182
+			if ($title_niveau < $level_new_title) {
183
+				break;
184
+			}
155 185
 			
156 186
 			$rang_to_add = self::titleHasTotalLine($object, $title_line, true, true);
157 187
 			
158 188
 			if (is_numeric($rang_to_add)) 
159 189
 			{
160
-				if ($rang_to_add != -1) self::updateRang($object, $rang_to_add);
190
+				if ($rang_to_add != -1) {
191
+					self::updateRang($object, $rang_to_add);
192
+				}
161 193
 				
162 194
 				self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add);
163 195
 				
164 196
 				$object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas)
165 197
 				if ($rang_to_add != -1) 
166 198
 				{
167
-					if (method_exists($object, 'fetch_lines')) $object->fetch_lines();
168
-					else $object->fetch($object->id);
199
+					if (method_exists($object, 'fetch_lines')) {
200
+						$object->fetch_lines();
201
+					} else {
202
+						$object->fetch($object->id);
203
+					}
169 204
 				}
170 205
 			}
171 206
 		}
@@ -195,7 +230,9 @@  discard block
 block discarded – undo
195 230
 		
196 231
 		foreach ($TTitle as $k => $title_line)
197 232
 		{
198
-			if (self::titleHasTotalLine($object, $title_line)) unset($TTitle[$k]);
233
+			if (self::titleHasTotalLine($object, $title_line)) {
234
+				unset($TTitle[$k]);
235
+			}
199 236
 		}
200 237
 		
201 238
 		return $TTitle;
@@ -212,23 +249,41 @@  discard block
 block discarded – undo
212 249
 	 */
213 250
 	public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false)
214 251
 	{
215
-		if (empty($object->lines) || !is_array($object->lines)) return false;
252
+		if (empty($object->lines) || !is_array($object->lines)) {
253
+			return false;
254
+		}
216 255
 		
217 256
 		$title_niveau = self::getNiveau($title_line);
218 257
 		foreach ($object->lines as &$line)
219 258
 		{
220
-			if ($line->rang <= $title_line->rang) continue;
221
-			if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) return false; // Oups on croise un titre d'un niveau inférieur ou égale (exemple : je croise un titre niveau 2 alors que je suis sur un titre de niveau 3) pas lieu de continuer car un nouveau bloc commence
222
-			if (!self::isSubtotal($line)) continue;
259
+			if ($line->rang <= $title_line->rang) {
260
+				continue;
261
+			}
262
+			if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) {
263
+				return false;
264
+			}
265
+			// Oups on croise un titre d'un niveau inférieur ou égale (exemple : je croise un titre niveau 2 alors que je suis sur un titre de niveau 3) pas lieu de continuer car un nouveau bloc commence
266
+			if (!self::isSubtotal($line)) {
267
+				continue;
268
+			}
223 269
 			
224 270
 			$subtotal_niveau = self::getNiveau($line);
225 271
 			
226 272
 			// Comparaison du niveau de la ligne de sous-total avec celui du titre
227
-			if ($subtotal_niveau == $title_niveau) return true; // niveau égale => Ok mon titre a un sous-total
228
-			elseif ($subtotal_niveau < $title_niveau) // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3)
273
+			if ($subtotal_niveau == $title_niveau) {
274
+				return true;
275
+			}
276
+			// niveau égale => Ok mon titre a un sous-total
277
+			elseif ($subtotal_niveau < $title_niveau) {
278
+				// niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3)
229 279
 			{
230
-				if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; // mode strict niveau pas égale donc faux
231
-				else return true; // mode libre => OK je considère que mon titre à un sous-total
280
+				if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false;
281
+			}
282
+			// mode strict niveau pas égale donc faux
283
+				else {
284
+					return true;
285
+				}
286
+				// mode libre => OK je considère que mon titre à un sous-total
232 287
 			}
233 288
 		}
234 289
 		
@@ -276,16 +331,19 @@  discard block
 block discarded – undo
276 331
 		
277 332
 		foreach ($object->lines as &$l)
278 333
 		{
279
-			if ($l->rang <= $line->rang) continue;
280
-			elseif (self::isSubtotal($l) && self::getNiveau($l) == $line->qty) break;
281
-			elseif (self::isModSubtotalLine($l)) continue;
334
+			if ($l->rang <= $line->rang) {
335
+				continue;
336
+			} elseif (self::isSubtotal($l) && self::getNiveau($l) == $line->qty) {
337
+				break;
338
+			} elseif (self::isModSubtotalLine($l)) {
339
+				continue;
340
+			}
282 341
 			
283 342
 			if (!empty($l->array_options['options_subtotal_nc']))
284 343
 			{
285 344
 				$tabprice = calcul_price_total($l->qty, $l->subprice, $l->remise_percent, $l->tva_tx, $l->localtax1_tx, $l->localtax2_tx, 0, 'HT', $l->info_bits, $l->product_type);
286 345
 				$TTot['total_options'] += $tabprice[0]; // total ht
287
-			}
288
-			else
346
+			} else
289 347
 			{
290 348
 				$TTot['total_pa_ht'] += $l->pa_ht * $l->qty;
291 349
 				$TTot['total_subprice'] += $l->subprice * $l->qty;
@@ -305,29 +363,41 @@  discard block
 block discarded – undo
305 363
 
306 364
 	public static function getOrderIdFromLineId(&$db, $fk_commandedet)
307 365
 	{
308
-		if (empty($fk_commandedet)) return false;
366
+		if (empty($fk_commandedet)) {
367
+			return false;
368
+		}
309 369
 		
310 370
 		$sql = 'SELECT fk_commande FROM '.MAIN_DB_PREFIX.'commandedet WHERE rowid = '.$fk_commandedet;
311 371
 		$resql = $db->query($sql);
312 372
 		
313
-		if ($resql && ($row = $db->fetch_object($resql))) return $row->fk_commande;
314
-		else return false;
373
+		if ($resql && ($row = $db->fetch_object($resql))) {
374
+			return $row->fk_commande;
375
+		} else {
376
+			return false;
377
+		}
315 378
 	}
316 379
 	
317 380
 	public static function getLastLineOrderId(&$db, $fk_commande)
318 381
 	{
319
-		if (empty($fk_commande)) return false;
382
+		if (empty($fk_commande)) {
383
+			return false;
384
+		}
320 385
 		
321 386
 		$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'commandedet WHERE fk_commande = '.$fk_commande.' ORDER BY rang DESC LIMIT 1';
322 387
 		$resql = $db->query($sql);
323 388
 		
324
-		if ($resql && ($row = $db->fetch_object($resql))) return $row->rowid;
325
-		else return false;
389
+		if ($resql && ($row = $db->fetch_object($resql))) {
390
+			return $row->rowid;
391
+		} else {
392
+			return false;
393
+		}
326 394
 	}
327 395
 	
328 396
 	public static function getParentTitleOfLine(&$object, $i)
329 397
 	{
330
-		if ($i <= 0) return false;
398
+		if ($i <= 0) {
399
+			return false;
400
+		}
331 401
 		
332 402
 		$skip_title = 0;
333 403
 		// Je parcours les lignes précédentes
@@ -346,8 +416,7 @@  discard block
 block discarded – undo
346 416
 				//@INFO J'ai ma ligne titre qui contient ma ligne, par contre je check pas s'il y a un sous-total
347 417
 				return $line;
348 418
 				break;
349
-			}
350
-			elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99)
419
+			} elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99)
351 420
 			{
352 421
 				// Il s'agit d'un sous-total, ça veut dire que le prochain titre théoriquement doit être ignorer (je travail avec un incrément au cas ou je croise plusieurs sous-totaux)
353 422
 				$skip_title++;
@@ -362,7 +431,9 @@  discard block
 block discarded – undo
362 431
 		$res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty <= 9;
363 432
 		if($res && $level > -1) {
364 433
 			return $line->qty == $level;
365
-		} else return $res;
434
+		} else {
435
+			return $res;
436
+		}
366 437
 		
367 438
 	}
368 439
 	
@@ -389,10 +460,14 @@  discard block
 block discarded – undo
389 460
 		// editeur wysiwyg
390 461
 		require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
391 462
 		$nbrows=ROWS_2;
392
-		if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
463
+		if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
464
+			$nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
465
+		}
393 466
 		$enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
394 467
 		$toolbarname='dolibarr_details';
395
-		if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes';
468
+		if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) {
469
+			$toolbarname='dolibarr_notes';
470
+		}
396 471
 		$text = !empty($line->description)?$line->description:$line->label;
397 472
 		$doleditor=new DolEditor('line-description',$text,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%', $readonly);
398 473
 		return $doleditor->Create(1);
@@ -407,12 +482,10 @@  discard block
 block discarded – undo
407 482
 		{
408 483
 		    $object->statut = 0; // hack for facture rec
409 484
 		    $createRight = $user->rights->facture->creer;
410
-		}
411
-		elseif($object->element == 'order_supplier' )
485
+		} elseif($object->element == 'order_supplier' )
412 486
 		{
413 487
 		    $createRight = $user->rights->fournisseur->commande->creer;
414
-		}
415
-		elseif($object->element == 'invoice_supplier' )
488
+		} elseif($object->element == 'invoice_supplier' )
416 489
 		{
417 490
 		    $createRight = $user->rights->fournisseur->facture->creer;
418 491
 		}
@@ -485,8 +558,9 @@  discard block
 block discarded – undo
485 558
 
486 559
 					$TLineAdded[] = $object->line;
487 560
 					// Error from addline
488
-					if ($res <= 0) break;
489
-					else
561
+					if ($res <= 0) {
562
+						break;
563
+					} else
490 564
 					{
491 565
 						$object->line_from = $line;
492 566
 						// Call trigger
@@ -508,8 +582,7 @@  discard block
 block discarded – undo
508 582
 					    _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']);
509 583
 					}
510 584
 					return count($TLineAdded);
511
-				}
512
-				else
585
+				} else
513 586
 				{
514 587
 					$object->db->rollback();
515 588
 					return -1;
@@ -525,10 +598,14 @@  discard block
 block discarded – undo
525 598
 		global $langs;
526 599
 		
527 600
 		// Besoin de comparer sur les 2 formes d'écriture
528
-		if (!$key_is_id) $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad));
601
+		if (!$key_is_id) {
602
+			$TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad));
603
+		}
529 604
 		
530 605
 		$TTitle_under_search = array();
531
-		if (!empty($under_title)) $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title));
606
+		if (!empty($under_title)) {
607
+			$TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title));
608
+		}
532 609
 		
533 610
 		$TLine = array();
534 611
 		$add_line = false;
@@ -538,28 +615,37 @@  discard block
 block discarded – undo
538 615
 		{
539 616
 			if (!$under_title_found && !empty($TTitle_under_search))
540 617
 			{
541
-				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true;
542
-			}
543
-			else
618
+				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) {
619
+					$under_title_found = true;
620
+				}
621
+			} else
544 622
 			{
545 623
 				if ( ($key_is_id && $line->id == $key_trad) || (!$key_is_id && $line->product_type == 9 && $line->qty == $level && (in_array($line->desc, $TTitle_search) || in_array($line->label, $TTitle_search) )))
546 624
 				{
547
-					if ($key_is_id) $level = $line->qty;
625
+					if ($key_is_id) {
626
+						$level = $line->qty;
627
+					}
548 628
 					
549 629
 					$add_line = true;
550
-					if ($withBlockLine) $TLine[] = $line;
630
+					if ($withBlockLine) {
631
+						$TLine[] = $line;
632
+					}
551 633
 					continue;
552
-				}
553
-				elseif ($add_line && $line->product_type == 9 && (100 - $line->qty == $level) ) // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre
634
+				} elseif ($add_line && $line->product_type == 9 && (100 - $line->qty == $level) ) {
635
+					// Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre
554 636
 				{
555 637
 					if ($withBlockLine) $TLine[] = $line;
638
+				}
556 639
 					break;
557 640
 				}
558 641
 				
559 642
 				if ($add_line)
560 643
 				{
561
-					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue;
562
-					else $TLine[] = $line;
644
+					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) {
645
+						continue;
646
+					} else {
647
+						$TLine[] = $line;
648
+					}
563 649
 				}
564 650
 			}
565 651
 		}
@@ -593,7 +679,9 @@  discard block
 block discarded – undo
593 679
 				
594 680
 			case 'order_supplier':
595 681
 			    $object->special_code = SELF::$module_number;
596
-			    if (empty($desc)) $desc = $label;
682
+			    if (empty($desc)) {
683
+			    	$desc = $label;
684
+			    }
597 685
 			    $res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, 0, $date_start, $date_end, $array_options, $fk_unit);
598 686
 			    break;
599 687
 			
@@ -603,7 +691,9 @@  discard block
 block discarded – undo
603 691
 				
604 692
 			case 'invoice_supplier':
605 693
 			    $object->special_code = SELF::$module_number;
606
-			    if (empty($desc)) $desc = $label;
694
+			    if (empty($desc)) {
695
+			    	$desc = $label;
696
+			    }
607 697
 			    $res = $object->updateline($rowid, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, 0, $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $fk_unit);
608 698
 			    break;
609 699
 				
@@ -620,8 +710,11 @@  discard block
 block discarded – undo
620 710
 				break;
621 711
 		}
622 712
 		
623
-		if ($res <= 0) $object->db->rollback();
624
-		else $object->db->commit();
713
+		if ($res <= 0) {
714
+			$object->db->rollback();
715
+		} else {
716
+			$object->db->commit();
717
+		}
625 718
 		
626 719
 		return $res;
627 720
 	}
@@ -631,24 +724,20 @@  discard block
 block discarded – undo
631 724
 		global $db, $object;
632 725
 		
633 726
 		$TTitle = array();
634
-		if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {}
635
-		else {
727
+		if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} else {
636 728
 			if ($origin_line->element == 'propaldet')
637 729
 			{
638 730
 				$object = new Propal($db);
639 731
 				$object->fetch($origin_line->fk_propal);
640
-			}
641
-			else if ($origin_line->element == 'commandedet')
732
+			} else if ($origin_line->element == 'commandedet')
642 733
 			{
643 734
 				$object = new Commande($db);
644 735
 				$object->fetch($origin_line->fk_commande);
645
-			}
646
-			else if ($origin_line->element == 'facturedet')
736
+			} else if ($origin_line->element == 'facturedet')
647 737
 			{
648 738
 				$object = new Facture($db);
649 739
 				$object->fetch($origin_line->fk_facture);
650
-			}
651
-			else
740
+			} else
652 741
 			{
653 742
 				return $TTitle;
654 743
 			}
@@ -658,8 +747,11 @@  discard block
 block discarded – undo
658 747
 		$i = 0;
659 748
 		foreach ($object->lines as &$line)
660 749
 		{
661
-			if ($origin_line->id == $line->id) break;
662
-			else $i++;
750
+			if ($origin_line->id == $line->id) {
751
+				break;
752
+			} else {
753
+				$i++;
754
+			}
663 755
 		}
664 756
 		
665 757
 		$i--; // Skip la ligne d'origine
@@ -674,35 +766,43 @@  discard block
 block discarded – undo
674 766
 				if (self::isSubtotal($object->lines[$y]))
675 767
 				{
676 768
 					$next_title_lvl_to_skip = self::getNiveau($object->lines[$y]);
677
-				}
678
-				elseif (self::isTitle($object->lines[$y]))
769
+				} elseif (self::isTitle($object->lines[$y]))
679 770
 				{
680 771
 					if ($object->lines[$y]->qty == $next_title_lvl_to_skip)
681 772
 					{
682 773
 						$next_title_lvl_to_skip = 0;
683 774
 						continue;
684
-					}
685
-					else
775
+					} else
686 776
 					{
687
-						if (empty($object->lines[$y]->array_options)) $object->lines[$y]->fetch_optionals();
777
+						if (empty($object->lines[$y]->array_options)) {
778
+							$object->lines[$y]->fetch_optionals();
779
+						}
688 780
 						$TTitle[$object->lines[$y]->id] = $object->lines[$y];
689 781
 						
690
-						if ($object->lines[$y]->qty == 1) break;
782
+						if ($object->lines[$y]->qty == 1) {
783
+							break;
784
+						}
691 785
 					}
692 786
 				}
693 787
 			}
694 788
 		}
695 789
 		
696
-		if ($reverse) $TTitle = array_reverse($TTitle, true);
790
+		if ($reverse) {
791
+			$TTitle = array_reverse($TTitle, true);
792
+		}
697 793
 		
698 794
 		return $TTitle;
699 795
 	}
700 796
 	
701 797
 	public static function getNiveau(&$line)
702 798
 	{
703
-		if (self::isTitle($line)) return $line->qty;
704
-		elseif (self::isSubtotal($line)) return 100 - $line->qty;
705
-		else return 0;
799
+		if (self::isTitle($line)) {
800
+			return $line->qty;
801
+		} elseif (self::isSubtotal($line)) {
802
+			return 100 - $line->qty;
803
+		} else {
804
+			return 0;
805
+		}
706 806
 	}
707 807
 	
708 808
 	/**
@@ -727,10 +827,16 @@  discard block
 block discarded – undo
727 827
 		$objmarge->marge_droite = 10;
728 828
 		
729 829
 		$objectref = dol_sanitizeFileName($object->ref);
730
-		if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref;
731
-		elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref;
732
-		elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref;
733
-		elseif ($object->element == 'facturerec') return; // no PDF for facturerec
830
+		if ($object->element == 'propal') {
831
+			$dir = $conf->propal->dir_output . '/' . $objectref;
832
+		} elseif ($object->element == 'commande') {
833
+			$dir = $conf->commande->dir_output . '/' . $objectref;
834
+		} elseif ($object->element == 'facture') {
835
+			$dir = $conf->facture->dir_output . '/' . $objectref;
836
+		} elseif ($object->element == 'facturerec') {
837
+			return;
838
+		}
839
+		// no PDF for facturerec
734 840
 		else
735 841
 		{
736 842
 			setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings');
@@ -765,7 +871,9 @@  discard block
 block discarded – undo
765 871
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
766 872
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
767 873
 		$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
768
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
874
+		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
875
+			$pdf->SetCompression(false);
876
+		}
769 877
 
770 878
 		$pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite);   // Left, Top, Right
771 879
 
@@ -775,7 +883,9 @@  discard block
 block discarded – undo
775 883
 			
776 884
 		// New page
777 885
 		$pdf->AddPage();
778
-		if (! empty($tplidx)) $pdf->useTemplate($tplidx);
886
+		if (! empty($tplidx)) {
887
+			$pdf->useTemplate($tplidx);
888
+		}
779 889
 		$pagenb++;
780 890
 		
781 891
 		
@@ -831,8 +941,10 @@  discard block
 block discarded – undo
831 941
 					{
832 942
 						$TTot['TTotal_tva_multicurrency'][$tx] += $amount;
833 943
 					}	
944
+				} else {
945
+					$pdf->SetFont('','', $default_font_size - 1);
834 946
 				}
835
-				else $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
947
+				// Into loop to work with multipage
836 948
 				
837 949
 				$pdf->SetTextColor(0,0,0);
838 950
 				
@@ -854,9 +966,11 @@  discard block
 block discarded – undo
854 966
 				$pdf->startTransaction();
855 967
 				$pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true);
856 968
 				$pageposafter=$pdf->getPage();
857
-				if ($pageposafter > $pageposbefore)	// There is a pagebreak
969
+				if ($pageposafter > $pageposbefore) {
970
+					// There is a pagebreak
858 971
 				{
859 972
 					$pdf->rollbackTransaction(true);
973
+				}
860 974
 					$pageposafter=$pageposbefore;
861 975
 					//print $pageposafter.'-'.$pageposbefore;exit;
862 976
 					$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -865,23 +979,27 @@  discard block
 block discarded – undo
865 979
 					$pageposafter=$pdf->getPage();
866 980
 					$posyafter=$pdf->GetY();
867 981
 					//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
868
-					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot)))	// There is no space left for total+free text
982
+					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) {
983
+						// There is no space left for total+free text
869 984
 					{
870 985
 						if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
871 986
 						{
872 987
 							$pdf->AddPage('','',true);
873
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
874
-							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
988
+					}
989
+							if (! empty($tplidx)) {
990
+								$pdf->useTemplate($tplidx);
991
+							}
992
+							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
993
+								self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
994
+							}
875 995
 							$pdf->setPage($pageposafter+1);
876 996
 						}
877
-					}
878
-					else
997
+					} else
879 998
 					{
880 999
 						// We found a page break
881 1000
 						$showpricebeforepagebreak=0;
882 1001
 					}
883
-				}
884
-				else	// No pagebreak
1002
+				} else	// No pagebreak
885 1003
 				{
886 1004
 					$pdf->commitTransaction();
887 1005
 				}
@@ -921,8 +1039,7 @@  discard block
 block discarded – undo
921 1039
 					if ($pagenb == 1)
922 1040
 					{
923 1041
 						self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $objmarge->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
924
-					}
925
-					else
1042
+					} else
926 1043
 					{
927 1044
 						self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top_newpage, $objmarge->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
928 1045
 					}
@@ -930,7 +1047,9 @@  discard block
 block discarded – undo
930 1047
 					$pagenb++;
931 1048
 					$pdf->setPage($pagenb);
932 1049
 					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
933
-					if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
1050
+					if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
1051
+						self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
1052
+					}
934 1053
 				}
935 1054
 			}
936 1055
 		}
@@ -940,8 +1059,7 @@  discard block
 block discarded – undo
940 1059
 		{
941 1060
 			self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $objmarge->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
942 1061
 			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
943
-		}
944
-		else
1062
+		} else
945 1063
 		{
946 1064
 			self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top_newpage, $objmarge->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
947 1065
 			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
@@ -955,7 +1073,9 @@  discard block
 block discarded – undo
955 1073
 		
956 1074
 		$pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file);
957 1075
 		
958
-		if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) unlink($file);
1076
+		if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) {
1077
+			unlink($file);
1078
+		}
959 1079
 	}
960 1080
 	
961 1081
 	private static function printLevel($objmarge, $pdf, $line, $curY, $posx_designation)
@@ -998,8 +1118,7 @@  discard block
 block discarded – undo
998 1118
 			{
999 1119
 			    $height=pdf_getHeightForLogo($logo);
1000 1120
 			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1001
-			}
1002
-			else
1121
+			} else
1003 1122
 			{
1004 1123
 				$pdf->SetTextColor(200,0,0);
1005 1124
 				$pdf->SetFont('','B',$default_font_size - 2);
@@ -1008,8 +1127,7 @@  discard block
 block discarded – undo
1008 1127
 			}
1009 1128
 			
1010 1129
 			$posy+=35;
1011
-		}
1012
-		else
1130
+		} else
1013 1131
 		{
1014 1132
 			$text=$mysoc->name;
1015 1133
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1023,9 +1141,13 @@  discard block
 block discarded – undo
1023 1141
 		$pdf->SetXY($objmarge->marge_gauche,$posy);
1024 1142
 		
1025 1143
 		$key = 'subtotalPropalTitle';
1026
-		if ($object->element == 'commande') $key = 'subtotalCommandeTitle';
1027
-		elseif ($object->element == 'facture') $key = 'subtotalInvoiceTitle';
1028
-		elseif ($object->element == 'facturerec') $key = 'subtotalInvoiceTitle';
1144
+		if ($object->element == 'commande') {
1145
+			$key = 'subtotalCommandeTitle';
1146
+		} elseif ($object->element == 'facture') {
1147
+			$key = 'subtotalInvoiceTitle';
1148
+		} elseif ($object->element == 'facturerec') {
1149
+			$key = 'subtotalInvoiceTitle';
1150
+		}
1029 1151
 		
1030 1152
 		$pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L');
1031 1153
 		
@@ -1060,7 +1182,9 @@  discard block
 block discarded – undo
1060 1182
 		
1061 1183
 		// Force to disable hidetop and hidebottom
1062 1184
 		$hidebottom=0;
1063
-		if ($hidetop) $hidetop=-1;
1185
+		if ($hidetop) {
1186
+			$hidetop=-1;
1187
+		}
1064 1188
 
1065 1189
 		$currency = !empty($currency) ? $currency : $conf->currency;
1066 1190
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1075,7 +1199,9 @@  discard block
 block discarded – undo
1075 1199
 			$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5);
1076 1200
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1077 1201
 			
1078
-			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite-$objmarge->marge_gauche, 8, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1202
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1203
+				$pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite-$objmarge->marge_gauche, 8, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1204
+			}
1079 1205
 			
1080 1206
 			
1081 1207
 			$pdf->line($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top);	// line prend une position y en 2eme param et 4eme param
@@ -1088,8 +1214,7 @@  discard block
 block discarded – undo
1088 1214
 			$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R');
1089 1215
 			
1090 1216
 			$pdf->line($objmarge->marge_gauche, $tab_top+8, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top+8);	// line prend une position y en 2eme param et 4eme param
1091
-		}
1092
-		else
1217
+		} else
1093 1218
 		{
1094 1219
 			$pdf->line($objmarge->marge_gauche, $tab_top-2, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top-2);	// line prend une position y en 2eme param et 4eme param
1095 1220
 		}
@@ -1110,10 +1235,12 @@  discard block
 block discarded – undo
1110 1235
 
1111 1236
 		// Tableau total
1112 1237
 		$col1x = 120; $col2x = 170;
1113
-		if ($objmarge->page_largeur < 210) // To work with US executive format
1238
+		if ($objmarge->page_largeur < 210) {
1239
+			// To work with US executive format
1114 1240
 		{
1115 1241
 			$col2x-=20;
1116 1242
 		}
1243
+		}
1117 1244
 		$largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x);
1118 1245
 
1119 1246
 		$useborder=0;
@@ -1135,9 +1262,11 @@  discard block
 block discarded – undo
1135 1262
 		$atleastoneratenotnull=0;
1136 1263
 		foreach($TTot['TTotal_tva'] as $tvakey => $tvaval)
1137 1264
 		{
1138
-			if ($tvakey != 0)    // On affiche pas taux 0
1265
+			if ($tvakey != 0) {
1266
+				// On affiche pas taux 0
1139 1267
 			{
1140 1268
 				$atleastoneratenotnull++;
1269
+			}
1141 1270
 
1142 1271
 				$index++;
1143 1272
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -1190,9 +1319,13 @@  discard block
 block discarded – undo
1190 1319
 	 */
1191 1320
     private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1192 1321
     {
1193
-	    if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1322
+	    if (empty($hidetop) || $hidetop==-1) {
1323
+	    	$pdf->line($x, $y, $x+$l, $y);
1324
+	    }
1194 1325
 	    $pdf->line($x+$l, $y, $x+$l, $y+$h);
1195
-	    if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1326
+	    if (empty($hidebottom)) {
1327
+	    	$pdf->line($x+$l, $y+$h, $x, $y+$h);
1328
+	    }
1196 1329
 	    $pdf->line($x, $y+$h, $x, $y);
1197 1330
     }
1198 1331
 	
@@ -1201,7 +1334,9 @@  discard block
 block discarded – undo
1201 1334
 	{
1202 1335
 		global $conf;
1203 1336
 		
1204
-		if (empty($fileoutput)) $fileoutput = $file[0];
1337
+		if (empty($fileoutput)) {
1338
+			$fileoutput = $file[0];
1339
+		}
1205 1340
 		
1206 1341
 		$pdf=pdf_getInstance();
1207 1342
         if (class_exists('TCPDF'))
@@ -1211,7 +1346,9 @@  discard block
 block discarded – undo
1211 1346
         }
1212 1347
         $pdf->SetFont(pdf_getPDFFont($outputlangs));
1213 1348
 
1214
-        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1349
+        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
1350
+        	$pdf->SetCompression(false);
1351
+        }
1215 1352
 
1216 1353
 		
1217 1354
 		foreach($files as $file)
@@ -1227,7 +1364,9 @@  discard block
 block discarded – undo
1227 1364
 		}
1228 1365
 		
1229 1366
 		$pdf->Output($fileoutput,'F');
1230
-		if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK));
1367
+		if (! empty($conf->global->MAIN_UMASK)) {
1368
+			@chmod($file, octdec($conf->global->MAIN_UMASK));
1369
+		}
1231 1370
 
1232 1371
 		return $pagecount;
1233 1372
 	}
@@ -1240,7 +1379,9 @@  discard block
 block discarded – undo
1240 1379
 	 */
1241 1380
 	public static function hasNcTitle(&$line)
1242 1381
 	{
1243
-		if(isset($line->has_nc_title)) return $line->has_nc_title;
1382
+		if(isset($line->has_nc_title)) {
1383
+			return $line->has_nc_title;
1384
+		}
1244 1385
 
1245 1386
 		$TTitle = self::getAllTitleFromLine($line);
1246 1387
 		foreach ($TTitle as &$line_title)
@@ -1265,7 +1406,9 @@  discard block
 block discarded – undo
1265 1406
 	public static function getTitleLabel($line)
1266 1407
 	{
1267 1408
 		$title = $line->label;
1268
-		if (empty($title)) $title = !empty($line->description) ? $line->description : $line->desc;
1409
+		if (empty($title)) {
1410
+			$title = !empty($line->description) ? $line->description : $line->desc;
1411
+		}
1269 1412
 		return $title;
1270 1413
 	}
1271 1414
 }
Please login to merge, or discard this patch.
core/modules/modSubtotal.class.php 2 patches
Indentation   +387 added lines, -387 removed lines patch added patch discarded remove patch
@@ -31,170 +31,170 @@  discard block
 block discarded – undo
31 31
 class modSubtotal extends DolibarrModules
32 32
 {
33 33
 
34
-    /**
35
-     * 	Constructor. Define names, constants, directories, boxes, permissions
36
-     *
37
-     * 	@param	DoliDB		$db	Database handler
38
-     */
34
+	/**
35
+	 * 	Constructor. Define names, constants, directories, boxes, permissions
36
+	 *
37
+	 * 	@param	DoliDB		$db	Database handler
38
+	 */
39 39
      
40
-    public function __construct($db)
41
-    {
42
-        global $langs, $conf;
40
+	public function __construct($db)
41
+	{
42
+		global $langs, $conf;
43 43
 
44
-        $this->db = $db;
44
+		$this->db = $db;
45 45
 
46 46
 		$this->editor_name = 'ATM-Consulting';
47
-        // Id for module (must be unique).
48
-        // Use a free id here
49
-        // (See in Home -> System information -> Dolibarr for list of used modules id).
50
-        $this->numero = 104777; // 104000 to 104999 for ATM CONSULTING
51
-        // Key text used to identify module (for permissions, menus, etc...)
52
-        $this->rights_class = 'subtotal';
47
+		// Id for module (must be unique).
48
+		// Use a free id here
49
+		// (See in Home -> System information -> Dolibarr for list of used modules id).
50
+		$this->numero = 104777; // 104000 to 104999 for ATM CONSULTING
51
+		// Key text used to identify module (for permissions, menus, etc...)
52
+		$this->rights_class = 'subtotal';
53 53
 
54
-        // Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
55
-        // It is used to group modules in module setup page
56
-        $this->family = "technic";
57
-        // Module label (no space allowed)
58
-        // used if translation string 'ModuleXXXName' not found
59
-        // (where XXX is value of numeric property 'numero' of module)
60
-        $this->name = preg_replace('/^mod/i', '', get_class($this));
61
-        // Module description
62
-        // used if translation string 'ModuleXXXDesc' not found
63
-        // (where XXX is value of numeric property 'numero' of module)
64
-        $this->description = "Module permettant l'ajout de sous-totaux et sous-totaux intermédiaires et le déplacement d'une ligne aisée de l'un dans l'autre";
65
-        // Possible values for version are: 'development', 'experimental' or version
66
-        $this->version = '3.1.1';
67
-        // Key used in llx_const table to save module status enabled/disabled
68
-        // (where MYMODULE is value of property name of module in uppercase)
69
-        $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
70
-        // Where to store the module in setup page
71
-        // (0=common,1=interface,2=others,3=very specific)
72
-        $this->special = 2;
73
-        // Name of image file used for this module.
74
-        // If file is in theme/yourtheme/img directory under name object_pictovalue.png
75
-        // use this->picto='pictovalue'
76
-        // If file is in module/img directory under name object_pictovalue.png
77
-        // use this->picto='pictovalue@module'
78
-        $this->picto = 'subtotal@subtotal'; // mypicto@titre
79
-        // Defined all module parts (triggers, login, substitutions, menus, css, etc...)
80
-        // for default path (eg: /titre/core/xxxxx) (0=disable, 1=enable)
81
-        // for specific path of parts (eg: /titre/core/modules/barcode)
82
-        // for specific css file (eg: /titre/css/titre.css.php)
83
-        $this->module_parts = array(
84
-            // Set this to 1 if module has its own trigger directory
85
-            'triggers' => 1,
86
-            // Set this to 1 if module has its own login method directory
87
-            //'login' => 0,
88
-            // Set this to 1 if module has its own substitution function file
89
-            //'substitutions' => 0,
90
-            // Set this to 1 if module has its own menus handler directory
91
-            //'menus' => 0,
92
-            // Set this to 1 if module has its own barcode directory
93
-            //'barcode' => 0,
94
-            // Set this to 1 if module has its own models directory
95
-            'models' => 1,
96
-            // Set this to relative path of css if module has its own css file
97
-            //'css' => '/titre/css/mycss.css.php',
98
-            // Set here all hooks context managed by module
99
-            'hooks' => array('invoicecard', 'invoicesuppliercard','propalcard', 'supplier_proposalcard', 'ordercard', 'ordersuppliercard','odtgeneration','orderstoinvoice','admin','invoicereccard','consumptionthirdparty')
100
-            // Set here all workflow context managed by module
101
-            //'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE'))
102
-        );
54
+		// Family can be 'crm','financial','hr','projects','products','ecm','technic','other'
55
+		// It is used to group modules in module setup page
56
+		$this->family = "technic";
57
+		// Module label (no space allowed)
58
+		// used if translation string 'ModuleXXXName' not found
59
+		// (where XXX is value of numeric property 'numero' of module)
60
+		$this->name = preg_replace('/^mod/i', '', get_class($this));
61
+		// Module description
62
+		// used if translation string 'ModuleXXXDesc' not found
63
+		// (where XXX is value of numeric property 'numero' of module)
64
+		$this->description = "Module permettant l'ajout de sous-totaux et sous-totaux intermédiaires et le déplacement d'une ligne aisée de l'un dans l'autre";
65
+		// Possible values for version are: 'development', 'experimental' or version
66
+		$this->version = '3.1.1';
67
+		// Key used in llx_const table to save module status enabled/disabled
68
+		// (where MYMODULE is value of property name of module in uppercase)
69
+		$this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
70
+		// Where to store the module in setup page
71
+		// (0=common,1=interface,2=others,3=very specific)
72
+		$this->special = 2;
73
+		// Name of image file used for this module.
74
+		// If file is in theme/yourtheme/img directory under name object_pictovalue.png
75
+		// use this->picto='pictovalue'
76
+		// If file is in module/img directory under name object_pictovalue.png
77
+		// use this->picto='pictovalue@module'
78
+		$this->picto = 'subtotal@subtotal'; // mypicto@titre
79
+		// Defined all module parts (triggers, login, substitutions, menus, css, etc...)
80
+		// for default path (eg: /titre/core/xxxxx) (0=disable, 1=enable)
81
+		// for specific path of parts (eg: /titre/core/modules/barcode)
82
+		// for specific css file (eg: /titre/css/titre.css.php)
83
+		$this->module_parts = array(
84
+			// Set this to 1 if module has its own trigger directory
85
+			'triggers' => 1,
86
+			// Set this to 1 if module has its own login method directory
87
+			//'login' => 0,
88
+			// Set this to 1 if module has its own substitution function file
89
+			//'substitutions' => 0,
90
+			// Set this to 1 if module has its own menus handler directory
91
+			//'menus' => 0,
92
+			// Set this to 1 if module has its own barcode directory
93
+			//'barcode' => 0,
94
+			// Set this to 1 if module has its own models directory
95
+			'models' => 1,
96
+			// Set this to relative path of css if module has its own css file
97
+			//'css' => '/titre/css/mycss.css.php',
98
+			// Set here all hooks context managed by module
99
+			'hooks' => array('invoicecard', 'invoicesuppliercard','propalcard', 'supplier_proposalcard', 'ordercard', 'ordersuppliercard','odtgeneration','orderstoinvoice','admin','invoicereccard','consumptionthirdparty')
100
+			// Set here all workflow context managed by module
101
+			//'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE'))
102
+		);
103 103
 
104
-        // Data directories to create when module is enabled.
105
-        // Example: this->dirs = array("/titre/temp");
106
-        $this->dirs = array();
104
+		// Data directories to create when module is enabled.
105
+		// Example: this->dirs = array("/titre/temp");
106
+		$this->dirs = array();
107 107
 
108
-        // Config pages. Put here list of php pages
109
-        // stored into titre/admin directory, used to setup module.
110
-        $this->config_page_url = array("subtotal_setup.php@subtotal");
108
+		// Config pages. Put here list of php pages
109
+		// stored into titre/admin directory, used to setup module.
110
+		$this->config_page_url = array("subtotal_setup.php@subtotal");
111 111
 
112
-        // Dependencies
113
-        // List of modules id that must be enabled if this module is enabled
114
-        $this->depends = array();
112
+		// Dependencies
113
+		// List of modules id that must be enabled if this module is enabled
114
+		$this->depends = array();
115 115
 
116 116
 		$this->conflictwith=array('modMilestone');
117
-        // List of modules id to disable if this one is disabled
118
-        $this->requiredby = array();
119
-        // Minimum version of PHP required by module
120
-        $this->phpmin = array(5, 3);
121
-        // Minimum version of Dolibarr required by module
122
-        $this->need_dolibarr_version = array(3, 2);
123
-        $this->langfiles = array("subtotal@subtotal"); // langfiles@titre
124
-        // Constants
125
-        // List of particular constants to add when module is enabled
126
-        // (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
127
-        // Example:
128
-        $this->const = array(
129
-            	0=>array(
130
-            		'SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES',
131
-            		'chaine',
132
-            		'I',
133
-            		'Définit le style (B : gras, I : Italique, U : Souligné) des sous titres lorsque le détail des lignes et des ensembles est caché',
134
-            		1
135
-            	)
117
+		// List of modules id to disable if this one is disabled
118
+		$this->requiredby = array();
119
+		// Minimum version of PHP required by module
120
+		$this->phpmin = array(5, 3);
121
+		// Minimum version of Dolibarr required by module
122
+		$this->need_dolibarr_version = array(3, 2);
123
+		$this->langfiles = array("subtotal@subtotal"); // langfiles@titre
124
+		// Constants
125
+		// List of particular constants to add when module is enabled
126
+		// (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
127
+		// Example:
128
+		$this->const = array(
129
+				0=>array(
130
+					'SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES',
131
+					'chaine',
132
+					'I',
133
+					'Définit le style (B : gras, I : Italique, U : Souligné) des sous titres lorsque le détail des lignes et des ensembles est caché',
134
+					1
135
+				)
136 136
 				,1=>array('SUBTOTAL_ALLOW_ADD_BLOCK', 'chaine', '1', 'Permet l\'ajout de titres et sous-totaux')
137 137
 				,2=>array('SUBTOTAL_ALLOW_EDIT_BLOCK', 'chaine', '1', 'Permet de modifier titres et sous-totaux')
138 138
 				,3=>array('SUBTOTAL_ALLOW_REMOVE_BLOCK', 'chaine', '1', 'Permet de supprimer les titres et sous-totaux')
139 139
 				,4=>array('SUBTOTAL_TITLE_STYLE', 'chaine', 'BU')
140 140
 				,5=>array('SUBTOTAL_SUBTOTAL_STYLE', 'chaine', 'B')
141
-            //	1=>array(
142
-            //		'MYMODULE_MYNEWCONST2',
143
-            //		'chaine',
144
-            //		'myvalue',
145
-            //		'This is another constant to add',
146
-            //		0
147
-            //	)
148
-        );
141
+			//	1=>array(
142
+			//		'MYMODULE_MYNEWCONST2',
143
+			//		'chaine',
144
+			//		'myvalue',
145
+			//		'This is another constant to add',
146
+			//		0
147
+			//	)
148
+		);
149 149
 		
150 150
 
151 151
 
152 152
 
153
-        // Array to add new pages in new tabs
154
-        // Example:
155
-        $this->tabs = array(
156
-            //	// To add a new tab identified by code tabname1
157
-            //	'objecttype:+tabname1:Title1:langfile@titre:$user->rights->titre->read:/titre/mynewtab1.php?id=__ID__',
158
-            //	// To add another new tab identified by code tabname2
159
-            //	'objecttype:+tabname2:Title2:langfile@titre:$user->rights->othermodule->read:/titre/mynewtab2.php?id=__ID__',
160
-            //	// To remove an existing tab identified by code tabname
161
-            //	'objecttype:-tabname'
162
-        );
163
-        // where objecttype can be
164
-        // 'thirdparty'			to add a tab in third party view
165
-        // 'intervention'		to add a tab in intervention view
166
-        // 'order_supplier'		to add a tab in supplier order view
167
-        // 'invoice_supplier'	to add a tab in supplier invoice view
168
-        // 'invoice'			to add a tab in customer invoice view
169
-        // 'order'				to add a tab in customer order view
170
-        // 'product'			to add a tab in product view
171
-        // 'stock'				to add a tab in stock view
172
-        // 'propal'				to add a tab in propal view
173
-        // 'member'				to add a tab in fundation member view
174
-        // 'contract'			to add a tab in contract view
175
-        // 'user'				to add a tab in user view
176
-        // 'group'				to add a tab in group view
177
-        // 'contact'			to add a tab in contact view
178
-        // 'categories_x'		to add a tab in category view
179
-        // (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
180
-        // Dictionnaries
181
-        if (! isset($conf->subtotal->enabled)) {
182
-            $conf->subtotal=new stdClass();
183
-            $conf->subtotal->enabled = 0;
184
-        }
185
-        $this->dictionaries = array(
153
+		// Array to add new pages in new tabs
154
+		// Example:
155
+		$this->tabs = array(
156
+			//	// To add a new tab identified by code tabname1
157
+			//	'objecttype:+tabname1:Title1:langfile@titre:$user->rights->titre->read:/titre/mynewtab1.php?id=__ID__',
158
+			//	// To add another new tab identified by code tabname2
159
+			//	'objecttype:+tabname2:Title2:langfile@titre:$user->rights->othermodule->read:/titre/mynewtab2.php?id=__ID__',
160
+			//	// To remove an existing tab identified by code tabname
161
+			//	'objecttype:-tabname'
162
+		);
163
+		// where objecttype can be
164
+		// 'thirdparty'			to add a tab in third party view
165
+		// 'intervention'		to add a tab in intervention view
166
+		// 'order_supplier'		to add a tab in supplier order view
167
+		// 'invoice_supplier'	to add a tab in supplier invoice view
168
+		// 'invoice'			to add a tab in customer invoice view
169
+		// 'order'				to add a tab in customer order view
170
+		// 'product'			to add a tab in product view
171
+		// 'stock'				to add a tab in stock view
172
+		// 'propal'				to add a tab in propal view
173
+		// 'member'				to add a tab in fundation member view
174
+		// 'contract'			to add a tab in contract view
175
+		// 'user'				to add a tab in user view
176
+		// 'group'				to add a tab in group view
177
+		// 'contact'			to add a tab in contact view
178
+		// 'categories_x'		to add a tab in category view
179
+		// (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
180
+		// Dictionnaries
181
+		if (! isset($conf->subtotal->enabled)) {
182
+			$conf->subtotal=new stdClass();
183
+			$conf->subtotal->enabled = 0;
184
+		}
185
+		$this->dictionaries = array(
186 186
 			'langs'=>'subtotal@subtotal',
187
-            'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'),		// List of tables we want to see into dictonnary editor
188
-            'tablib'=>array($langs->trans('subtotalFreeLineDictionary')),													// Label of tables
189
-            'tabsql'=>array('SELECT f.rowid as rowid, f.label, f.content, f.entity, f.active FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text as f WHERE f.entity='.$conf->entity),	// Request to select fields
190
-            'tabsqlsort'=>array('label ASC'),																					// Sort order
191
-            'tabfield'=>array('label,content'),							// List of fields (result of select to show dictionary)
192
-            'tabfieldvalue'=>array('label,content'),						// List of fields (list of fields to edit a record)
193
-            'tabfieldinsert'=>array('label,content,entity'),					// List of fields (list of fields for insert)
194
-            'tabrowid'=>array('rowid'),											// Name of columns with primary key (try to always name it 'rowid')
195
-            'tabcond'=>array($conf->subtotal->enabled)	
187
+			'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'),		// List of tables we want to see into dictonnary editor
188
+			'tablib'=>array($langs->trans('subtotalFreeLineDictionary')),													// Label of tables
189
+			'tabsql'=>array('SELECT f.rowid as rowid, f.label, f.content, f.entity, f.active FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text as f WHERE f.entity='.$conf->entity),	// Request to select fields
190
+			'tabsqlsort'=>array('label ASC'),																					// Sort order
191
+			'tabfield'=>array('label,content'),							// List of fields (result of select to show dictionary)
192
+			'tabfieldvalue'=>array('label,content'),						// List of fields (list of fields to edit a record)
193
+			'tabfieldinsert'=>array('label,content,entity'),					// List of fields (list of fields for insert)
194
+			'tabrowid'=>array('rowid'),											// Name of columns with primary key (try to always name it 'rowid')
195
+			'tabcond'=>array($conf->subtotal->enabled)	
196 196
 		);
197
-        /* Example:
197
+		/* Example:
198 198
           // This is to avoid warnings
199 199
           if (! isset($conf->titre->enabled)) $conf->titre->enabled=0;
200 200
           $this->dictionnaries=array(
@@ -235,223 +235,223 @@  discard block
 block discarded – undo
235 235
           );
236 236
          */
237 237
 
238
-        // Boxes
239
-        // Add here list of php file(s) stored in core/boxes that contains class to show a box.
240
-        $this->boxes = array(); // Boxes list
238
+		// Boxes
239
+		// Add here list of php file(s) stored in core/boxes that contains class to show a box.
240
+		$this->boxes = array(); // Boxes list
241 241
        
242
-        /*
242
+		/*
243 243
           $this->boxes[$r][1] = "myboxb.php";
244 244
           $r++;
245 245
          */
246 246
 
247
-        // Permissions
248
-        $this->rights = array(); // Permission array used by this module
249
-        $r = 0;
247
+		// Permissions
248
+		$this->rights = array(); // Permission array used by this module
249
+		$r = 0;
250 250
 
251
-        // Add here list of permission defined by
252
-        // an id, a label, a boolean and two constant strings.
253
-        // Example:
254
-        //// Permission id (must not be already used)
255
-        //$this->rights[$r][0] = 2000;
256
-        //// Permission label
257
-        //$this->rights[$r][1] = 'Permision label';
258
-        //// Permission by default for new user (0/1)
259
-        //$this->rights[$r][3] = 1;
260
-        //// In php code, permission will be checked by test
261
-        //// if ($user->rights->permkey->level1->level2)
262
-        //$this->rights[$r][4] = 'level1';
263
-        //// In php code, permission will be checked by test
264
-        //// if ($user->rights->permkey->level1->level2)
265
-        //$this->rights[$r][5] = 'level2';
266
-        //$r++;
267
-        // Main menu entries
268
-        $this->menus = array(); // List of menus to add
269
-        $r = 0;
251
+		// Add here list of permission defined by
252
+		// an id, a label, a boolean and two constant strings.
253
+		// Example:
254
+		//// Permission id (must not be already used)
255
+		//$this->rights[$r][0] = 2000;
256
+		//// Permission label
257
+		//$this->rights[$r][1] = 'Permision label';
258
+		//// Permission by default for new user (0/1)
259
+		//$this->rights[$r][3] = 1;
260
+		//// In php code, permission will be checked by test
261
+		//// if ($user->rights->permkey->level1->level2)
262
+		//$this->rights[$r][4] = 'level1';
263
+		//// In php code, permission will be checked by test
264
+		//// if ($user->rights->permkey->level1->level2)
265
+		//$this->rights[$r][5] = 'level2';
266
+		//$r++;
267
+		// Main menu entries
268
+		$this->menus = array(); // List of menus to add
269
+		$r = 0;
270 270
 
271
-        // Add here entries to declare new menus
272
-        //
273
-        // Example to declare a new Top Menu entry and its Left menu entry:
274
-        //$this->menu[$r]=array(
275
-        //	// Put 0 if this is a top menu
276
-        //	'fk_menu'=>0,
277
-        //	// This is a Top menu entry
278
-        //	'type'=>'top',
279
-        //	'titre'=>'titre top menu',
280
-        //	'mainmenu'=>'titre',
281
-        //	'leftmenu'=>'titre',
282
-        //	'url'=>'/titre/pagetop.php',
283
-        //	// Lang file to use (without .lang) by module.
284
-        //	// File must be in langs/code_CODE/ directory.
285
-        //	'langs'=>'mylangfile',
286
-        //	'position'=>100,
287
-        //	// Define condition to show or hide menu entry.
288
-        //	// Use '$conf->titre->enabled' if entry must be visible if module is enabled.
289
-        //	'enabled'=>'$conf->titre->enabled',
290
-        //	// Use 'perms'=>'$user->rights->titre->level1->level2'
291
-        //	// if you want your menu with a permission rules
292
-        //	'perms'=>'1',
293
-        //	'target'=>'',
294
-        //	// 0=Menu for internal users, 1=external users, 2=both
295
-        //	'user'=>2
296
-        //);
297
-        //$r++;
298
-        //$this->menu[$r]=array(
299
-        //	// Use r=value where r is index key used for the parent menu entry
300
-        //	// (higher parent must be a top menu entry)
301
-        //	'fk_menu'=>'r=0',
302
-        //	// This is a Left menu entry
303
-        //	'type'=>'left',
304
-        //	'titre'=>'titre left menu',
305
-        //	'mainmenu'=>'titre',
306
-        //	'leftmenu'=>'titre',
307
-        //	'url'=>'/titre/pagelevel1.php',
308
-        //	// Lang file to use (without .lang) by module.
309
-        //	// File must be in langs/code_CODE/ directory.
310
-        //	'langs'=>'mylangfile',
311
-        //	'position'=>100,
312
-        //	// Define condition to show or hide menu entry.
313
-        //	// Use '$conf->titre->enabled' if entry must be visible if module is enabled.
314
-        //	'enabled'=>'$conf->titre->enabled',
315
-        //	// Use 'perms'=>'$user->rights->titre->level1->level2'
316
-        //	// if you want your menu with a permission rules
317
-        //	'perms'=>'1',
318
-        //	'target'=>'',
319
-        //	// 0=Menu for internal users, 1=external users, 2=both
320
-        //	'user'=>2
321
-        //);
322
-        //$r++;
323
-        //
324
-        // Example to declare a Left Menu entry into an existing Top menu entry:
325
-        //$this->menu[$r]=array(
326
-        //	// Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy'
327
-        //	'fk_menu'=>'fk_mainmenu=mainmenucode',
328
-        //	// This is a Left menu entry
329
-        //	'type'=>'left',
330
-        //	'titre'=>'titre left menu',
331
-        //	'mainmenu'=>'mainmenucode',
332
-        //	'leftmenu'=>'titre',
333
-        //	'url'=>'/titre/pagelevel2.php',
334
-        //	// Lang file to use (without .lang) by module.
335
-        //	// File must be in langs/code_CODE/ directory.
336
-        //	'langs'=>'mylangfile',
337
-        //	'position'=>100,
338
-        //	// Define condition to show or hide menu entry.
339
-        //	// Use '$conf->titre->enabled' if entry must be visible if module is enabled.
340
-        //	// Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
341
-        //	'enabled'=>'$conf->titre->enabled',
342
-        //	// Use 'perms'=>'$user->rights->titre->level1->level2'
343
-        //	// if you want your menu with a permission rules
344
-        //	'perms'=>'1',
345
-        //	'target'=>'',
346
-        //	// 0=Menu for internal users, 1=external users, 2=both
347
-        //	'user'=>2
348
-        //);
349
-        //$r++;
350
-        // Exports
351
-        $r = 1;
271
+		// Add here entries to declare new menus
272
+		//
273
+		// Example to declare a new Top Menu entry and its Left menu entry:
274
+		//$this->menu[$r]=array(
275
+		//	// Put 0 if this is a top menu
276
+		//	'fk_menu'=>0,
277
+		//	// This is a Top menu entry
278
+		//	'type'=>'top',
279
+		//	'titre'=>'titre top menu',
280
+		//	'mainmenu'=>'titre',
281
+		//	'leftmenu'=>'titre',
282
+		//	'url'=>'/titre/pagetop.php',
283
+		//	// Lang file to use (without .lang) by module.
284
+		//	// File must be in langs/code_CODE/ directory.
285
+		//	'langs'=>'mylangfile',
286
+		//	'position'=>100,
287
+		//	// Define condition to show or hide menu entry.
288
+		//	// Use '$conf->titre->enabled' if entry must be visible if module is enabled.
289
+		//	'enabled'=>'$conf->titre->enabled',
290
+		//	// Use 'perms'=>'$user->rights->titre->level1->level2'
291
+		//	// if you want your menu with a permission rules
292
+		//	'perms'=>'1',
293
+		//	'target'=>'',
294
+		//	// 0=Menu for internal users, 1=external users, 2=both
295
+		//	'user'=>2
296
+		//);
297
+		//$r++;
298
+		//$this->menu[$r]=array(
299
+		//	// Use r=value where r is index key used for the parent menu entry
300
+		//	// (higher parent must be a top menu entry)
301
+		//	'fk_menu'=>'r=0',
302
+		//	// This is a Left menu entry
303
+		//	'type'=>'left',
304
+		//	'titre'=>'titre left menu',
305
+		//	'mainmenu'=>'titre',
306
+		//	'leftmenu'=>'titre',
307
+		//	'url'=>'/titre/pagelevel1.php',
308
+		//	// Lang file to use (without .lang) by module.
309
+		//	// File must be in langs/code_CODE/ directory.
310
+		//	'langs'=>'mylangfile',
311
+		//	'position'=>100,
312
+		//	// Define condition to show or hide menu entry.
313
+		//	// Use '$conf->titre->enabled' if entry must be visible if module is enabled.
314
+		//	'enabled'=>'$conf->titre->enabled',
315
+		//	// Use 'perms'=>'$user->rights->titre->level1->level2'
316
+		//	// if you want your menu with a permission rules
317
+		//	'perms'=>'1',
318
+		//	'target'=>'',
319
+		//	// 0=Menu for internal users, 1=external users, 2=both
320
+		//	'user'=>2
321
+		//);
322
+		//$r++;
323
+		//
324
+		// Example to declare a Left Menu entry into an existing Top menu entry:
325
+		//$this->menu[$r]=array(
326
+		//	// Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy'
327
+		//	'fk_menu'=>'fk_mainmenu=mainmenucode',
328
+		//	// This is a Left menu entry
329
+		//	'type'=>'left',
330
+		//	'titre'=>'titre left menu',
331
+		//	'mainmenu'=>'mainmenucode',
332
+		//	'leftmenu'=>'titre',
333
+		//	'url'=>'/titre/pagelevel2.php',
334
+		//	// Lang file to use (without .lang) by module.
335
+		//	// File must be in langs/code_CODE/ directory.
336
+		//	'langs'=>'mylangfile',
337
+		//	'position'=>100,
338
+		//	// Define condition to show or hide menu entry.
339
+		//	// Use '$conf->titre->enabled' if entry must be visible if module is enabled.
340
+		//	// Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
341
+		//	'enabled'=>'$conf->titre->enabled',
342
+		//	// Use 'perms'=>'$user->rights->titre->level1->level2'
343
+		//	// if you want your menu with a permission rules
344
+		//	'perms'=>'1',
345
+		//	'target'=>'',
346
+		//	// 0=Menu for internal users, 1=external users, 2=both
347
+		//	'user'=>2
348
+		//);
349
+		//$r++;
350
+		// Exports
351
+		$r = 1;
352 352
 
353
-        // Example:
354
-        //$this->export_code[$r]=$this->rights_class.'_'.$r;
355
-        //// Translation key (used only if key ExportDataset_xxx_z not found)
356
-        //$this->export_label[$r]='CustomersInvoicesAndInvoiceLines';
357
-        //// Condition to show export in list (ie: '$user->id==3').
358
-        //// Set to 1 to always show when module is enabled.
359
-        //$this->export_enabled[$r]='1';
360
-        //$this->export_permission[$r]=array(array("facture","facture","export"));
361
-        //$this->export_fields_array[$r]=array(
362
-        //	's.rowid'=>"IdCompany",
363
-        //	's.nom'=>'CompanyName',
364
-        //	's.address'=>'Address',
365
-        //	's.cp'=>'Zip',
366
-        //	's.ville'=>'Town',
367
-        //	's.fk_pays'=>'Country',
368
-        //	's.tel'=>'Phone',
369
-        //	's.siren'=>'ProfId1',
370
-        //	's.siret'=>'ProfId2',
371
-        //	's.ape'=>'ProfId3',
372
-        //	's.idprof4'=>'ProfId4',
373
-        //	's.code_compta'=>'CustomerAccountancyCode',
374
-        //	's.code_compta_fournisseur'=>'SupplierAccountancyCode',
375
-        //	'f.rowid'=>"InvoiceId",
376
-        //	'f.facnumber'=>"InvoiceRef",
377
-        //	'f.datec'=>"InvoiceDateCreation",
378
-        //	'f.datef'=>"DateInvoice",
379
-        //	'f.total'=>"TotalHT",
380
-        //	'f.total_ttc'=>"TotalTTC",
381
-        //	'f.tva'=>"TotalVAT",
382
-        //	'f.paye'=>"InvoicePaid",
383
-        //	'f.fk_statut'=>'InvoiceStatus',
384
-        //	'f.note'=>"InvoiceNote",
385
-        //	'fd.rowid'=>'LineId',
386
-        //	'fd.description'=>"LineDescription",
387
-        //	'fd.price'=>"LineUnitPrice",
388
-        //	'fd.tva_tx'=>"LineVATRate",
389
-        //	'fd.qty'=>"LineQty",
390
-        //	'fd.total_ht'=>"LineTotalHT",
391
-        //	'fd.total_tva'=>"LineTotalTVA",
392
-        //	'fd.total_ttc'=>"LineTotalTTC",
393
-        //	'fd.date_start'=>"DateStart",
394
-        //	'fd.date_end'=>"DateEnd",
395
-        //	'fd.fk_product'=>'ProductId',
396
-        //	'p.ref'=>'ProductRef'
397
-        //);
398
-        //$this->export_entities_array[$r]=array('s.rowid'=>"company",
399
-        //	's.nom'=>'company',
400
-        //	's.address'=>'company',
401
-        //	's.cp'=>'company',
402
-        //	's.ville'=>'company',
403
-        //	's.fk_pays'=>'company',
404
-        //	's.tel'=>'company',
405
-        //	's.siren'=>'company',
406
-        //	's.siret'=>'company',
407
-        //	's.ape'=>'company',
408
-        //	's.idprof4'=>'company',
409
-        //	's.code_compta'=>'company',
410
-        //	's.code_compta_fournisseur'=>'company',
411
-        //	'f.rowid'=>"invoice",
412
-        //	'f.facnumber'=>"invoice",
413
-        //	'f.datec'=>"invoice",
414
-        //	'f.datef'=>"invoice",
415
-        //	'f.total'=>"invoice",
416
-        //	'f.total_ttc'=>"invoice",
417
-        //	'f.tva'=>"invoice",
418
-        //	'f.paye'=>"invoice",
419
-        //	'f.fk_statut'=>'invoice',
420
-        //	'f.note'=>"invoice",
421
-        //	'fd.rowid'=>'invoice_line',
422
-        //	'fd.description'=>"invoice_line",
423
-        //	'fd.price'=>"invoice_line",
424
-        //	'fd.total_ht'=>"invoice_line",
425
-        //	'fd.total_tva'=>"invoice_line",
426
-        //	'fd.total_ttc'=>"invoice_line",
427
-        //	'fd.tva_tx'=>"invoice_line",
428
-        //	'fd.qty'=>"invoice_line",
429
-        //	'fd.date_start'=>"invoice_line",
430
-        //	'fd.date_end'=>"invoice_line",
431
-        //	'fd.fk_product'=>'product',
432
-        //	'p.ref'=>'product'
433
-        //);
434
-        //$this->export_sql_start[$r] = 'SELECT DISTINCT ';
435
-        //$this->export_sql_end[$r] = ' FROM (' . MAIN_DB_PREFIX . 'facture as f, '
436
-        //	. MAIN_DB_PREFIX . 'facturedet as fd, ' . MAIN_DB_PREFIX . 'societe as s)';
437
-        //$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX
438
-        //	. 'product as p on (fd.fk_product = p.rowid)';
439
-        //$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid '
440
-        //	. 'AND f.rowid = fd.fk_facture';
441
-        //$r++;
442
-    }
353
+		// Example:
354
+		//$this->export_code[$r]=$this->rights_class.'_'.$r;
355
+		//// Translation key (used only if key ExportDataset_xxx_z not found)
356
+		//$this->export_label[$r]='CustomersInvoicesAndInvoiceLines';
357
+		//// Condition to show export in list (ie: '$user->id==3').
358
+		//// Set to 1 to always show when module is enabled.
359
+		//$this->export_enabled[$r]='1';
360
+		//$this->export_permission[$r]=array(array("facture","facture","export"));
361
+		//$this->export_fields_array[$r]=array(
362
+		//	's.rowid'=>"IdCompany",
363
+		//	's.nom'=>'CompanyName',
364
+		//	's.address'=>'Address',
365
+		//	's.cp'=>'Zip',
366
+		//	's.ville'=>'Town',
367
+		//	's.fk_pays'=>'Country',
368
+		//	's.tel'=>'Phone',
369
+		//	's.siren'=>'ProfId1',
370
+		//	's.siret'=>'ProfId2',
371
+		//	's.ape'=>'ProfId3',
372
+		//	's.idprof4'=>'ProfId4',
373
+		//	's.code_compta'=>'CustomerAccountancyCode',
374
+		//	's.code_compta_fournisseur'=>'SupplierAccountancyCode',
375
+		//	'f.rowid'=>"InvoiceId",
376
+		//	'f.facnumber'=>"InvoiceRef",
377
+		//	'f.datec'=>"InvoiceDateCreation",
378
+		//	'f.datef'=>"DateInvoice",
379
+		//	'f.total'=>"TotalHT",
380
+		//	'f.total_ttc'=>"TotalTTC",
381
+		//	'f.tva'=>"TotalVAT",
382
+		//	'f.paye'=>"InvoicePaid",
383
+		//	'f.fk_statut'=>'InvoiceStatus',
384
+		//	'f.note'=>"InvoiceNote",
385
+		//	'fd.rowid'=>'LineId',
386
+		//	'fd.description'=>"LineDescription",
387
+		//	'fd.price'=>"LineUnitPrice",
388
+		//	'fd.tva_tx'=>"LineVATRate",
389
+		//	'fd.qty'=>"LineQty",
390
+		//	'fd.total_ht'=>"LineTotalHT",
391
+		//	'fd.total_tva'=>"LineTotalTVA",
392
+		//	'fd.total_ttc'=>"LineTotalTTC",
393
+		//	'fd.date_start'=>"DateStart",
394
+		//	'fd.date_end'=>"DateEnd",
395
+		//	'fd.fk_product'=>'ProductId',
396
+		//	'p.ref'=>'ProductRef'
397
+		//);
398
+		//$this->export_entities_array[$r]=array('s.rowid'=>"company",
399
+		//	's.nom'=>'company',
400
+		//	's.address'=>'company',
401
+		//	's.cp'=>'company',
402
+		//	's.ville'=>'company',
403
+		//	's.fk_pays'=>'company',
404
+		//	's.tel'=>'company',
405
+		//	's.siren'=>'company',
406
+		//	's.siret'=>'company',
407
+		//	's.ape'=>'company',
408
+		//	's.idprof4'=>'company',
409
+		//	's.code_compta'=>'company',
410
+		//	's.code_compta_fournisseur'=>'company',
411
+		//	'f.rowid'=>"invoice",
412
+		//	'f.facnumber'=>"invoice",
413
+		//	'f.datec'=>"invoice",
414
+		//	'f.datef'=>"invoice",
415
+		//	'f.total'=>"invoice",
416
+		//	'f.total_ttc'=>"invoice",
417
+		//	'f.tva'=>"invoice",
418
+		//	'f.paye'=>"invoice",
419
+		//	'f.fk_statut'=>'invoice',
420
+		//	'f.note'=>"invoice",
421
+		//	'fd.rowid'=>'invoice_line',
422
+		//	'fd.description'=>"invoice_line",
423
+		//	'fd.price'=>"invoice_line",
424
+		//	'fd.total_ht'=>"invoice_line",
425
+		//	'fd.total_tva'=>"invoice_line",
426
+		//	'fd.total_ttc'=>"invoice_line",
427
+		//	'fd.tva_tx'=>"invoice_line",
428
+		//	'fd.qty'=>"invoice_line",
429
+		//	'fd.date_start'=>"invoice_line",
430
+		//	'fd.date_end'=>"invoice_line",
431
+		//	'fd.fk_product'=>'product',
432
+		//	'p.ref'=>'product'
433
+		//);
434
+		//$this->export_sql_start[$r] = 'SELECT DISTINCT ';
435
+		//$this->export_sql_end[$r] = ' FROM (' . MAIN_DB_PREFIX . 'facture as f, '
436
+		//	. MAIN_DB_PREFIX . 'facturedet as fd, ' . MAIN_DB_PREFIX . 'societe as s)';
437
+		//$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX
438
+		//	. 'product as p on (fd.fk_product = p.rowid)';
439
+		//$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid '
440
+		//	. 'AND f.rowid = fd.fk_facture';
441
+		//$r++;
442
+	}
443 443
 
444
-    /**
445
-     * Function called when module is enabled.
446
-     * The init function add constants, boxes, permissions and menus
447
-     * (defined in constructor) into Dolibarr database.
448
-     * It also creates data directories
449
-     *
450
-     * 	@param		string	$options	Options when enabling module ('', 'noboxes')
451
-     * 	@return		int					1 if OK, 0 if KO
452
-     */
453
-    public function init($options = '')
454
-    {
444
+	/**
445
+	 * Function called when module is enabled.
446
+	 * The init function add constants, boxes, permissions and menus
447
+	 * (defined in constructor) into Dolibarr database.
448
+	 * It also creates data directories
449
+	 *
450
+	 * 	@param		string	$options	Options when enabling module ('', 'noboxes')
451
+	 * 	@return		int					1 if OK, 0 if KO
452
+	 */
453
+	public function init($options = '')
454
+	{
455 455
 	  	global $conf, $db;
456 456
 		
457 457
 		
@@ -459,46 +459,46 @@  discard block
 block discarded – undo
459 459
 			exit("Attention, ce module rentre ne conflit avec le module Jalon/Milestones. Merci de le désactiver auparavant.");
460 460
 		}
461 461
       */
462
-	    $sql = array();
462
+		$sql = array();
463 463
 
464
-        $result = $this->loadTables();
465
-        dol_include_once('/core/class/extrafields.class.php');
464
+		$result = $this->loadTables();
465
+		dol_include_once('/core/class/extrafields.class.php');
466 466
 	
467
-        $extra = new ExtraFields($db); // propaldet, commandedet, facturedet
468
-        $TElementType = array('propaldet', 'commandedet', 'facturedet', 'supplier_proposaldet', 'commande_fournisseurdet', 'facture_fourn_det');
469
-        foreach($TElementType as $element_type) {
470
-            $extra->addExtraField('show_total_ht', 'Afficher le Total HT sur le sous-total', 'int', 0, 10, $element_type, 0, 0, '', unserialize('a:1:{s:7:"options";a:1:{s:0:"";N;}}'), 0, '', 0, 1);
471
-            $extra->addExtraField('show_reduc', 'Afficher la réduction sur le sous-total', 'int', 0, 10, $element_type, 0, 0, '', unserialize('a:1:{s:7:"options";a:1:{s:0:"";N;}}'), 0, '', 0, 1);
472
-        }
467
+		$extra = new ExtraFields($db); // propaldet, commandedet, facturedet
468
+		$TElementType = array('propaldet', 'commandedet', 'facturedet', 'supplier_proposaldet', 'commande_fournisseurdet', 'facture_fourn_det');
469
+		foreach($TElementType as $element_type) {
470
+			$extra->addExtraField('show_total_ht', 'Afficher le Total HT sur le sous-total', 'int', 0, 10, $element_type, 0, 0, '', unserialize('a:1:{s:7:"options";a:1:{s:0:"";N;}}'), 0, '', 0, 1);
471
+			$extra->addExtraField('show_reduc', 'Afficher la réduction sur le sous-total', 'int', 0, 10, $element_type, 0, 0, '', unserialize('a:1:{s:7:"options";a:1:{s:0:"";N;}}'), 0, '', 0, 1);
472
+		}
473 473
 		
474
-        return $this->_init($sql, $options);
475
-    }
474
+		return $this->_init($sql, $options);
475
+	}
476 476
 
477
-    /**
478
-     * Function called when module is disabled.
479
-     * Remove from database constants, boxes and permissions from Dolibarr database.
480
-     * Data directories are not deleted
481
-     *
482
-     * 	@param		string	$options	Options when enabling module ('', 'noboxes')
483
-     * 	@return		int					1 if OK, 0 if KO
484
-     */
485
-    public function remove($options = '')
486
-    {
487
-        $sql = array();
477
+	/**
478
+	 * Function called when module is disabled.
479
+	 * Remove from database constants, boxes and permissions from Dolibarr database.
480
+	 * Data directories are not deleted
481
+	 *
482
+	 * 	@param		string	$options	Options when enabling module ('', 'noboxes')
483
+	 * 	@return		int					1 if OK, 0 if KO
484
+	 */
485
+	public function remove($options = '')
486
+	{
487
+		$sql = array();
488 488
 
489
-        return $this->_remove($sql, $options);
490
-    }
489
+		return $this->_remove($sql, $options);
490
+	}
491 491
 
492
-    /**
493
-     * Create tables, keys and data required by module
494
-     * Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys
495
-     * and create data commands must be stored in directory /titre/sql/
496
-     * This function is called by this->init
497
-     *
498
-     * 	@return		int		<=0 if KO, >0 if OK
499
-     */
500
-    private function loadTables()
501
-    {
502
-        return $this->_load_tables('/subtotal/sql/');
503
-    }
492
+	/**
493
+	 * Create tables, keys and data required by module
494
+	 * Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys
495
+	 * and create data commands must be stored in directory /titre/sql/
496
+	 * This function is called by this->init
497
+	 *
498
+	 * 	@return		int		<=0 if KO, >0 if OK
499
+	 */
500
+	private function loadTables()
501
+	{
502
+		return $this->_load_tables('/subtotal/sql/');
503
+	}
504 504
 }
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * 	\ingroup	titre
24 24
  * 	\brief		Description and activation file for module titre
25 25
  */
26
-include_once DOL_DOCUMENT_ROOT . "/core/modules/DolibarrModules.class.php";
26
+include_once DOL_DOCUMENT_ROOT."/core/modules/DolibarrModules.class.php";
27 27
 
28 28
 /**
29 29
  * Description and activation class for module titre
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $this->version = '3.1.1';
67 67
         // Key used in llx_const table to save module status enabled/disabled
68 68
         // (where MYMODULE is value of property name of module in uppercase)
69
-        $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
69
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
70 70
         // Where to store the module in setup page
71 71
         // (0=common,1=interface,2=others,3=very specific)
72 72
         $this->special = 2;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
             // Set this to relative path of css if module has its own css file
97 97
             //'css' => '/titre/css/mycss.css.php',
98 98
             // Set here all hooks context managed by module
99
-            'hooks' => array('invoicecard', 'invoicesuppliercard','propalcard', 'supplier_proposalcard', 'ordercard', 'ordersuppliercard','odtgeneration','orderstoinvoice','admin','invoicereccard','consumptionthirdparty')
99
+            'hooks' => array('invoicecard', 'invoicesuppliercard', 'propalcard', 'supplier_proposalcard', 'ordercard', 'ordersuppliercard', 'odtgeneration', 'orderstoinvoice', 'admin', 'invoicereccard', 'consumptionthirdparty')
100 100
             // Set here all workflow context managed by module
101 101
             //'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE'))
102 102
         );
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
         // List of modules id that must be enabled if this module is enabled
114 114
         $this->depends = array();
115 115
 
116
-		$this->conflictwith=array('modMilestone');
116
+		$this->conflictwith = array('modMilestone');
117 117
         // List of modules id to disable if this one is disabled
118 118
         $this->requiredby = array();
119 119
         // Minimum version of PHP required by module
@@ -178,20 +178,20 @@  discard block
 block discarded – undo
178 178
         // 'categories_x'		to add a tab in category view
179 179
         // (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
180 180
         // Dictionnaries
181
-        if (! isset($conf->subtotal->enabled)) {
182
-            $conf->subtotal=new stdClass();
181
+        if (!isset($conf->subtotal->enabled)) {
182
+            $conf->subtotal = new stdClass();
183 183
             $conf->subtotal->enabled = 0;
184 184
         }
185 185
         $this->dictionaries = array(
186 186
 			'langs'=>'subtotal@subtotal',
187
-            'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'),		// List of tables we want to see into dictonnary editor
188
-            'tablib'=>array($langs->trans('subtotalFreeLineDictionary')),													// Label of tables
189
-            'tabsql'=>array('SELECT f.rowid as rowid, f.label, f.content, f.entity, f.active FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text as f WHERE f.entity='.$conf->entity),	// Request to select fields
190
-            'tabsqlsort'=>array('label ASC'),																					// Sort order
191
-            'tabfield'=>array('label,content'),							// List of fields (result of select to show dictionary)
192
-            'tabfieldvalue'=>array('label,content'),						// List of fields (list of fields to edit a record)
193
-            'tabfieldinsert'=>array('label,content,entity'),					// List of fields (list of fields for insert)
194
-            'tabrowid'=>array('rowid'),											// Name of columns with primary key (try to always name it 'rowid')
187
+            'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'), // List of tables we want to see into dictonnary editor
188
+            'tablib'=>array($langs->trans('subtotalFreeLineDictionary')), // Label of tables
189
+            'tabsql'=>array('SELECT f.rowid as rowid, f.label, f.content, f.entity, f.active FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text as f WHERE f.entity='.$conf->entity), // Request to select fields
190
+            'tabsqlsort'=>array('label ASC'), // Sort order
191
+            'tabfield'=>array('label,content'), // List of fields (result of select to show dictionary)
192
+            'tabfieldvalue'=>array('label,content'), // List of fields (list of fields to edit a record)
193
+            'tabfieldinsert'=>array('label,content,entity'), // List of fields (list of fields for insert)
194
+            'tabrowid'=>array('rowid'), // Name of columns with primary key (try to always name it 'rowid')
195 195
             'tabcond'=>array($conf->subtotal->enabled)	
196 196
 		);
197 197
         /* Example:
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	
467 467
         $extra = new ExtraFields($db); // propaldet, commandedet, facturedet
468 468
         $TElementType = array('propaldet', 'commandedet', 'facturedet', 'supplier_proposaldet', 'commande_fournisseurdet', 'facture_fourn_det');
469
-        foreach($TElementType as $element_type) {
469
+        foreach ($TElementType as $element_type) {
470 470
             $extra->addExtraField('show_total_ht', 'Afficher le Total HT sur le sous-total', 'int', 0, 10, $element_type, 0, 0, '', unserialize('a:1:{s:7:"options";a:1:{s:0:"";N;}}'), 0, '', 0, 1);
471 471
             $extra->addExtraField('show_reduc', 'Afficher la réduction sur le sous-total', 'int', 0, 10, $element_type, 0, 0, '', unserialize('a:1:{s:7:"options";a:1:{s:0:"";N;}}'), 0, '', 0, 1);
472 472
         }
Please login to merge, or discard this patch.