Completed
Push — master ( 06978a...0fa0cf )
by
unknown
13s queued 11s
created
class/actions_subtotal.class.php 2 patches
Spacing   +493 added lines, -493 removed lines patch added patch discarded remove patch
@@ -16,17 +16,17 @@  discard block
 block discarded – undo
16 16
 		
17 17
 		global $type_element, $where;
18 18
 		
19
-		$contexts = explode(':',$parameters['context']);
19
+		$contexts = explode(':', $parameters['context']);
20 20
 		
21
-		if(in_array('consumptionthirdparty',$contexts) && in_array($type_element, array('propal', 'order', 'invoice', 'supplier_order', 'supplier_invoice', 'supplier_proposal'))) {
21
+		if (in_array('consumptionthirdparty', $contexts) && in_array($type_element, array('propal', 'order', 'invoice', 'supplier_order', 'supplier_invoice', 'supplier_proposal'))) {
22 22
 			$mod_num = TSubtotal::$module_number;
23 23
 			
24 24
 			// Not a title (can't use TSubtotal class methods in sql)
25
-			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty > 9)';
25
+			$where .= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty > 9)';
26 26
 			// Not a subtotal (can't use TSubtotal class methods in sql)
27
-			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty < 90)';
27
+			$where .= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty < 90)';
28 28
 			// Not a free line text (can't use TSubtotal class methods in sql)
29
-			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty != 50)';
29
+			$where .= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty != 50)';
30 30
 			
31 31
 		}
32 32
 		
@@ -105,47 +105,47 @@  discard block
 block discarded – undo
105 105
     
106 106
     function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
107 107
     {
108
-      	global $langs,$db,$user, $conf;
108
+      	global $langs, $db, $user, $conf;
109 109
 		
110 110
 		$langs->load('subtotal@subtotal');
111 111
 		
112
-		$contexts = explode(':',$parameters['context']);
112
+		$contexts = explode(':', $parameters['context']);
113 113
 		
114
-		if(in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('invoicereccard',$contexts) || in_array('expeditioncard',$contexts)) {
114
+		if (in_array('ordercard', $contexts) || in_array('ordersuppliercard', $contexts) || in_array('propalcard', $contexts) || in_array('supplier_proposalcard', $contexts) || in_array('invoicecard', $contexts) || in_array('invoicesuppliercard', $contexts) || in_array('invoicereccard', $contexts) || in_array('expeditioncard', $contexts)) {
115 115
 			
116 116
 			$createRight = $user->rights->{$object->element}->creer;
117
-			if($object->element == 'facturerec' )
117
+			if ($object->element == 'facturerec')
118 118
 			{
119 119
 				$object->statut = 0; // hack for facture rec
120 120
 				$createRight = $user->rights->facture->creer;
121
-			} elseif($object->element == 'order_supplier' )
121
+			} elseif ($object->element == 'order_supplier')
122 122
 			{
123 123
 			    $createRight = $user->rights->fournisseur->commande->creer;
124
-			} elseif($object->element == 'invoice_supplier' )
124
+			} elseif ($object->element == 'invoice_supplier')
125 125
 			{
126 126
 			    $createRight = $user->rights->fournisseur->facture->creer;
127 127
 			}
128
-			elseif($object->element == 'shipping')
128
+			elseif ($object->element == 'shipping')
129 129
 			{
130 130
 				$createRight = true; // No rights management for shipments
131 131
 			}
132 132
 			
133
-			if ($object->statut == 0  && $createRight) {
133
+			if ($object->statut == 0 && $createRight) {
134 134
 			
135 135
 
136
-				if($object->element=='facture')$idvar = 'facid';
137
-				else $idvar='id';
136
+				if ($object->element == 'facture')$idvar = 'facid';
137
+				else $idvar = 'id';
138 138
 				
139
-				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
139
+				if (in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')))
140 140
 				{
141 141
 					$level = GETPOST('level', 'int'); //New avec SUBTOTAL_USE_NEW_FORMAT
142 142
 					
143
-					if($action=='add_title_line') {
143
+					if ($action == 'add_title_line') {
144 144
 						$title = GETPOST('title');
145
-						if(empty($title)) $title = $langs->trans('title');
146
-						$qty = $level<1 ? 1 : $level ;
145
+						if (empty($title)) $title = $langs->trans('title');
146
+						$qty = $level < 1 ? 1 : $level;
147 147
 					}
148
-					else if($action=='add_free_text') {
148
+					else if ($action == 'add_free_text') {
149 149
 						$title = GETPOST('title');
150 150
 
151 151
 						if (empty($title)) {
@@ -157,21 +157,21 @@  discard block
 block discarded – undo
157 157
 								}
158 158
 							}
159 159
 						}
160
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
160
+						if (empty($title)) $title = $langs->trans('subtotalAddLineDescription');
161 161
 						$qty = 50;
162 162
 					}
163
-					else if($action=='add_subtitle_line') {
163
+					else if ($action == 'add_subtitle_line') {
164 164
 						$title = GETPOST('title');
165
-						if(empty($title)) $title = $langs->trans('subtitle');
165
+						if (empty($title)) $title = $langs->trans('subtitle');
166 166
 						$qty = 2;
167 167
 					}
168
-					else if($action=='add_subtotal_line') {
168
+					else if ($action == 'add_subtotal_line') {
169 169
 						$title = $langs->trans('SubSubTotal');
170 170
 						$qty = 98;
171 171
 					}
172 172
 					else {
173 173
 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
174
-						$qty = $level ? 100-$level : 99;
174
+						$qty = $level ? 100 - $level : 99;
175 175
 					}
176 176
 					dol_include_once('/subtotal/class/subtotal.class.php');
177 177
 					
@@ -179,15 +179,15 @@  discard block
 block discarded – undo
179 179
 					
180 180
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
181 181
 				}
182
-				else if($action==='ask_deleteallline') {
183
-						$form=new Form($db);
182
+				else if ($action === 'ask_deleteallline') {
183
+						$form = new Form($db);
184 184
 
185
-						$lineid = GETPOST('lineid','integer');
185
+						$lineid = GETPOST('lineid', 'integer');
186 186
 						$TIdForGroup = $this->getArrayOfLineForAGroup($object, $lineid);
187 187
 					
188 188
 						$nbLines = count($TIdForGroup);
189 189
 					
190
-						$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines',$nbLines), 'confirm_delete_all_lines','',0,1);
190
+						$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines', $nbLines), 'confirm_delete_all_lines', '', 0, 1);
191 191
 						print $formconfirm;
192 192
 				}
193 193
 
@@ -197,13 +197,13 @@  discard block
 block discarded – undo
197 197
 				}
198 198
 
199 199
 				
200
-				if($object->element != 'shipping' && $action!='editline') {
200
+				if ($object->element != 'shipping' && $action != 'editline') {
201 201
 					// New format is for 3.8
202 202
 					$this->printNewFormat($object, $conf, $langs, $idvar);
203 203
 				}
204 204
 			}
205 205
 		}
206
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts) || in_array('orderstoinvoicesupplier',$contexts))
206
+		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice', $contexts) || in_array('orderstoinvoicesupplier', $contexts))
207 207
 		{
208 208
 			?>
209 209
 			<script type="text/javascript">
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 				$(document).ready(function() {
229 229
 					$('div.fiche div.tabsAction').append('<br />');
230 230
 					
231
-					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_title_line" rel="add_title_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddTitle' )?></a></div>');
231
+					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_title_line" rel="add_title_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddTitle')?></a></div>');
232 232
 					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_total_line" rel="add_total_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddSubTotal')?></a></div>');
233 233
 					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_free_text" rel="add_free_text" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddFreeText')?></a></div>');
234 234
 
@@ -279,9 +279,9 @@  discard block
 block discarded – undo
279 279
 						$('body').append(dialog_html);
280 280
 
281 281
 						<?php 
282
-						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME)?'ckeditor':$conf->global->FCKEDITOR_EDITORNAME;
283
-						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
284
-						if($editorConf && in_array($editorTool,array('textarea','ckeditor'))){ 
282
+						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME) ? 'ckeditor' : $conf->global->FCKEDITOR_EDITORNAME;
283
+						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
284
+						if ($editorConf && in_array($editorTool, array('textarea', 'ckeditor'))) { 
285 285
 						?>
286 286
 						if (action == 'addTitle' || action == 'addFreeTxt')
287 287
 						{
@@ -396,62 +396,62 @@  discard block
 block discarded – undo
396 396
 		global $conf, $langs, $bc;
397 397
 			
398 398
 		$action = GETPOST('action');	
399
-		$TContext = explode(':',$parameters['context']);
399
+		$TContext = explode(':', $parameters['context']);
400 400
 		if (
401
-				in_array('invoicecard',$TContext)
402
-		        || in_array('invoicesuppliercard',$TContext)
403
-				|| in_array('propalcard',$TContext)
404
-				|| in_array('ordercard',$TContext)
405
-		        || in_array('ordersuppliercard',$TContext)
406
-				|| in_array('invoicereccard',$TContext)
401
+				in_array('invoicecard', $TContext)
402
+		        || in_array('invoicesuppliercard', $TContext)
403
+				|| in_array('propalcard', $TContext)
404
+				|| in_array('ordercard', $TContext)
405
+		        || in_array('ordersuppliercard', $TContext)
406
+				|| in_array('invoicereccard', $TContext)
407 407
 			)
408 408
 	        {	
409
-	            $hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
410
-	            $hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
411
-				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0;
412
-				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
409
+	            $hideInnerLines = isset($_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
410
+	            $hidedetails = isset($_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
411
+				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED) ? $conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED : 0;
412
+				$hideprices = isset($_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
413 413
 				
414
-				$var=false;
415
-		     	$out.= '<tr '.$bc[$var].'>
414
+				$var = false;
415
+		     	$out .= '<tr '.$bc[$var].'>
416 416
 		     			<td colspan="4" align="right">
417 417
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
418
-		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
418
+		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(($hideInnerLines) ? 'checked="checked"' : '').' />
419 419
 		     			</td>
420 420
 		     			</tr>';
421 421
 				
422
-		     	$var=!$var;
423
-		     	$out.= '<tr '.$bc[$var].'>
422
+		     	$var = !$var;
423
+		     	$out .= '<tr '.$bc[$var].'>
424 424
 		     			<td colspan="4" align="right">
425 425
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
426
-		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
426
+		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(($hidedetails) ? 'checked="checked"' : '').' />
427 427
 		     			</td>
428 428
 		     			</tr>';
429 429
 		     	
430
-		     	$var=!$var;
431
-		     	$out.= '<tr '.$bc[$var].'>
430
+		     	$var = !$var;
431
+		     	$out .= '<tr '.$bc[$var].'>
432 432
 		     			<td colspan="4" align="right">
433 433
 		     				<label for="hideprices">'.$langs->trans('SubTotalhidePrice').'</label>
434
-		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
434
+		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(($hideprices) ? 'checked="checked"' : '').' />
435 435
 		     			</td>
436 436
 		     			</tr>';
437 437
 		     	
438 438
 		     	
439 439
 				 
440 440
 				if ( 
441
-					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
442
-					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
443
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
444
-					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
445
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
446
-					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
441
+					(in_array('propalcard', $TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
442
+					|| (in_array('ordercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
443
+				    || (in_array('ordersuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
444
+					|| (in_array('invoicecard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
445
+				    || (in_array('invoicesuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
446
+					|| (in_array('invoicereccard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
447 447
 				)
448 448
 				{
449
-					$var=!$var;
450
-					$out.= '
449
+					$var = !$var;
450
+					$out .= '
451 451
 						<tr '.$bc[$var].'>
452 452
 							<td colspan="4" align="right">
453 453
 								<label for="subtotal_add_recap">'.$langs->trans('subtotal_add_recap').'</label>
454
-								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.( GETPOST('subtotal_add_recap') ? 'checked="checked"' : '' ).' />
454
+								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.(GETPOST('subtotal_add_recap') ? 'checked="checked"' : '').' />
455 455
 							</td>
456 456
 						</tr>';
457 457
 				}
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
     function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
468 468
     {
469 469
 		
470
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
470
+    	if (in_array('invoicecard', explode(':', $parameters['context'])))
471 471
         {
472 472
         	
473 473
         }
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
479 479
 		global $conf;
480 480
 		
481
-		if($action === 'builddoc') {
481
+		if ($action === 'builddoc') {
482 482
 			
483 483
 			$line = &$parameters['line'];
484 484
 			$object = &$parameters['object'];
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
             $substitutionarray['line_modsubtotal_total'] = false;
490 490
             $substitutionarray['line_modsubtotal_title'] = false;
491 491
 
492
-			if($line->product_type == 9 && $line->special_code == $this->module_number) {
492
+			if ($line->product_type == 9 && $line->special_code == $this->module_number) {
493 493
 				$substitutionarray['line_modsubtotal'] = 1;	
494 494
                 $substitutionarray['line_not_modsubtotal'] = false;
495 495
 				
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 					 = $substitutionarray['line_up'] 
502 502
 					 = '';
503 503
 				
504
-				if($line->qty>90) {
504
+				if ($line->qty > 90) {
505 505
 					$substitutionarray['line_modsubtotal_total'] = true;
506 506
 					
507 507
 					//list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
 				
517 517
 				
518 518
 			}	
519
-			else{
519
+			else {
520 520
 				$substitutionarray['line_not_modsubtotal'] = true;
521 521
 				$substitutionarray['line_modsubtotal'] = 0;
522 522
 			}
@@ -528,29 +528,29 @@  discard block
 block discarded – undo
528 528
 	function createFrom($parameters, &$object, $action, $hookmanager) {
529 529
 	
530 530
 		if (
531
-				in_array('invoicecard',explode(':',$parameters['context']))
532
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
533
-				|| in_array('propalcard',explode(':',$parameters['context']))
534
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
535
-				|| in_array('ordercard',explode(':',$parameters['context']))
536
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
537
-				|| in_array('invoicereccard',explode(':',$parameters['context']))
531
+				in_array('invoicecard', explode(':', $parameters['context']))
532
+		        || in_array('invoicesuppliercard', explode(':', $parameters['context']))
533
+				|| in_array('propalcard', explode(':', $parameters['context']))
534
+		        || in_array('supplier_proposalcard', explode(':', $parameters['context']))
535
+				|| in_array('ordercard', explode(':', $parameters['context']))
536
+		        || in_array('ordersuppliercard', explode(':', $parameters['context']))
537
+				|| in_array('invoicereccard', explode(':', $parameters['context']))
538 538
 		) {
539 539
 			
540 540
 			global $db;
541 541
 			
542 542
 			$objFrom = $parameters['objFrom'];
543 543
 			
544
-			foreach($objFrom->lines as $k=> &$lineOld) {
544
+			foreach ($objFrom->lines as $k=> &$lineOld) {
545 545
 				
546
-					if($lineOld->product_type == 9 && $lineOld->info_bits > 0 ) {
546
+					if ($lineOld->product_type == 9 && $lineOld->info_bits > 0) {
547 547
 							
548 548
 							$line = & $object->lines[$k];
549 549
 				
550 550
 							$idLine = (int) ($line->id ? $line->id : $line->rowid); 
551 551
 				
552 552
 							$db->query("UPDATE ".MAIN_DB_PREFIX.$line->table_element."
553
-							SET info_bits=".(int)$lineOld->info_bits."
553
+							SET info_bits=".(int) $lineOld->info_bits."
554 554
 							WHERE rowid = ".$idLine."
555 555
 							");
556 556
 						
@@ -566,15 +566,15 @@  discard block
 block discarded – undo
566 566
 	
567 567
 	function doActions($parameters, &$object, $action, $hookmanager)
568 568
 	{
569
-		global $db, $conf, $langs,$user;
569
+		global $db, $conf, $langs, $user;
570 570
 		
571 571
 		dol_include_once('/subtotal/class/subtotal.class.php');
572 572
 		dol_include_once('/subtotal/lib/subtotal.lib.php');
573
-		require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
573
+		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
574 574
 		
575 575
 		$showBlockExtrafields = GETPOST('showBlockExtrafields');
576 576
 		
577
-		if($object->element=='facture') $idvar = 'facid';
577
+		if ($object->element == 'facture') $idvar = 'facid';
578 578
 		else $idvar = 'id';
579 579
 			
580 580
 		if ($action == 'updateligne' || $action == 'updateline')
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 				if ($line->id == $lineid && TSubtotal::isModSubtotalLine($line))
588 588
 				{
589 589
 					$found = true;
590
-					if(TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
590
+					if (TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
591 591
 						$extrafieldsline = new ExtraFields($db);
592 592
 						$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
593 593
 						$extrafieldsline->setOptionalsFromPost($extralabelsline, $line);
@@ -606,43 +606,43 @@  discard block
 block discarded – undo
606 606
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
607 607
 			}
608 608
 		}
609
-		else if($action === 'builddoc') {
609
+		else if ($action === 'builddoc') {
610 610
 			
611 611
 			if (
612
-				in_array('invoicecard',explode(':',$parameters['context']))
613
-				|| in_array('propalcard',explode(':',$parameters['context']))
614
-				|| in_array('ordercard',explode(':',$parameters['context']))
615
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
616
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
617
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
612
+				in_array('invoicecard', explode(':', $parameters['context']))
613
+				|| in_array('propalcard', explode(':', $parameters['context']))
614
+				|| in_array('ordercard', explode(':', $parameters['context']))
615
+			    || in_array('ordersuppliercard', explode(':', $parameters['context']))
616
+			    || in_array('invoicesuppliercard', explode(':', $parameters['context']))
617
+			    || in_array('supplier_proposalcard', explode(':', $parameters['context']))
618 618
 			)
619 619
 	        {								
620
-				if(in_array('invoicecard',explode(':',$parameters['context']))) {
620
+				if (in_array('invoicecard', explode(':', $parameters['context']))) {
621 621
 					$sessname = 'subtotal_hideInnerLines_facture';	
622 622
 					$sessname2 = 'subtotal_hidedetails_facture';
623 623
 					$sessname3 = 'subtotal_hideprices_facture';
624 624
 				}
625
-				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
625
+				elseif (in_array('invoicesuppliercard', explode(':', $parameters['context']))) {
626 626
 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
627 627
 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
628 628
 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
629 629
 				}
630
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
630
+				elseif (in_array('propalcard', explode(':', $parameters['context']))) {
631 631
 					$sessname = 'subtotal_hideInnerLines_propal';
632 632
 					$sessname2 = 'subtotal_hidedetails_propal';	
633 633
 					$sessname3 = 'subtotal_hideprices_propal';
634 634
 				}
635
-				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
635
+				elseif (in_array('supplier_proposalcard', explode(':', $parameters['context']))) {
636 636
 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
637 637
 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
638 638
 				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
639 639
 				}
640
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
640
+				elseif (in_array('ordercard', explode(':', $parameters['context']))) {
641 641
 					$sessname = 'subtotal_hideInnerLines_commande';
642 642
 					$sessname2 = 'subtotal_hidedetails_commande';	
643 643
 					$sessname3 = 'subtotal_hideprices_commande';
644 644
 				}
645
-				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
645
+				elseif (in_array('ordersuppliercard', explode(':', $parameters['context']))) {
646 646
 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
647 647
 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
648 648
 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
@@ -655,25 +655,25 @@  discard block
 block discarded – undo
655 655
 					
656 656
 				global $hideprices;
657 657
 				
658
-				$hideInnerLines = (int)GETPOST('hideInnerLines');
659
-				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) $_SESSION[$sessname] = array(); // prevent old system
658
+				$hideInnerLines = (int) GETPOST('hideInnerLines');
659
+				if (!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id])) $_SESSION[$sessname] = array(); // prevent old system
660 660
 				$_SESSION[$sessname][$object->id] = $hideInnerLines;		
661 661
 				
662
-				$hidedetails= (int)GETPOST('hidedetails');
663
-				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) $_SESSION[$sessname2] = array(); // prevent old system
662
+				$hidedetails = (int) GETPOST('hidedetails');
663
+				if (!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id])) $_SESSION[$sessname2] = array(); // prevent old system
664 664
 				$_SESSION[$sessname2][$object->id] = $hidedetails;
665 665
 				
666
-				$hideprices= (int)GETPOST('hideprices');
667
-				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) $_SESSION[$sessname3] = array(); // prevent old system
666
+				$hideprices = (int) GETPOST('hideprices');
667
+				if (!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id])) $_SESSION[$sessname3] = array(); // prevent old system
668 668
 				$_SESSION[$sessname3][$object->id] = $hideprices;
669 669
 				
670
-				foreach($object->lines as &$line) {
670
+				foreach ($object->lines as &$line) {
671 671
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
672 672
 					    
673
-                        if($line->qty>=90) {
673
+                        if ($line->qty >= 90) {
674 674
                             $line->modsubtotal_total = 1;
675 675
                         }
676
-                        else{
676
+                        else {
677 677
                             $line->modsubtotal_title = 1;
678 678
                         }
679 679
                         
@@ -683,34 +683,34 @@  discard block
 block discarded – undo
683 683
 	        }
684 684
 			
685 685
 		}
686
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
686
+		else if ($action === 'confirm_delete_all_lines' && GETPOST('confirm') == 'yes') {
687 687
 			
688 688
 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
689 689
 			
690
-			foreach($Tab as $idLine) {
690
+			foreach ($Tab as $idLine) {
691 691
 				/**
692 692
 				 * @var $object Facture
693 693
 				 */
694
-				if($object->element=='facture') $object->deleteline($idLine);
694
+				if ($object->element == 'facture') $object->deleteline($idLine);
695 695
 				/**
696 696
 				 * @var $object Facture fournisseur
697 697
 				 */
698
-				else if($object->element=='invoice_supplier')
698
+				else if ($object->element == 'invoice_supplier')
699 699
 				{
700 700
 				    $object->deleteline($idLine);
701 701
 				}
702 702
 				/**
703 703
 				 * @var $object Propal
704 704
 				 */
705
-				else if($object->element=='propal') $object->deleteline($idLine);
705
+				else if ($object->element == 'propal') $object->deleteline($idLine);
706 706
 				/**
707 707
 				 * @var $object Propal Fournisseur
708 708
 				 */
709
-				else if($object->element=='supplier_proposal') $object->deleteline($idLine);
709
+				else if ($object->element == 'supplier_proposal') $object->deleteline($idLine);
710 710
 				/**
711 711
 				 * @var $object Commande
712 712
 				 */
713
-				else if($object->element=='commande') 
713
+				else if ($object->element == 'commande') 
714 714
 				{
715 715
 					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
716 716
 					else $object->deleteline($idLine);
@@ -718,18 +718,18 @@  discard block
 block discarded – undo
718 718
 				/**
719 719
 				 * @var $object Commande fournisseur
720 720
 				 */
721
-				else if($object->element=='order_supplier')
721
+				else if ($object->element == 'order_supplier')
722 722
 				{
723 723
 				    $object->deleteline($idLine);
724 724
 				}
725 725
 				/**
726 726
 				 * @var $object Facturerec
727 727
 				 */
728
-				else if($object->element=='facturerec') $object->deleteline($idLine);
728
+				else if ($object->element == 'facturerec') $object->deleteline($idLine);
729 729
 				/**
730 730
 				 * @var $object Expedition
731 731
 				 */
732
-				else if($object->element=='shipping') $object->deleteline($user, $idLine);
732
+				else if ($object->element == 'shipping') $object->deleteline($user, $idLine);
733 733
 			}
734 734
 			
735 735
 			header('location:?id='.$object->id);
@@ -752,7 +752,7 @@  discard block
 block discarded – undo
752 752
 		return 0;
753 753
 	}
754 754
 	
755
-	function formAddObjectLine ($parameters, &$object, &$action, $hookmanager) {
755
+	function formAddObjectLine($parameters, &$object, &$action, $hookmanager) {
756 756
 		return 0;
757 757
 	}
758 758
 	
@@ -770,8 +770,8 @@  discard block
 block discarded – undo
770 770
 			if (!empty($parameters['fk_element']))
771 771
 			{
772 772
 				
773
-				if($obj->fetch($parameters['fk_element'])){
774
-					$obj->id= $obj->rowid;
773
+				if ($obj->fetch($parameters['fk_element'])) {
774
+					$obj->id = $obj->rowid;
775 775
 					if (empty($obj->array_options))
776 776
 						$obj->fetch_optionals();
777 777
 					if (!empty($obj->array_options['options_subtotal_nc']))
@@ -791,22 +791,22 @@  discard block
 block discarded – undo
791 791
 		
792 792
 		$found = false;
793 793
 
794
-		$Tab= array();
794
+		$Tab = array();
795 795
 		
796
-		foreach($object->lines as $l) {
796
+		foreach ($object->lines as $l) {
797 797
 		
798 798
 		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
799
-			if($lid == $lineid) {
799
+			if ($lid == $lineid) {
800 800
 
801 801
 				$found = true;
802 802
 				$qty_line = $l->qty;
803 803
 			}
804 804
 			
805
-			if($found) {
805
+			if ($found) {
806 806
 				
807 807
 			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
808 808
 				
809
-				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
809
+				if ($l->special_code == $this->module_number && (($l->qty == 99 && $qty_line == 1) || ($l->qty == 98 && $qty_line == 2))) {
810 810
 					break; // end of story
811 811
 				}
812 812
 			}
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
 	 * 
836 836
 	 * @param	$use_level		isn't used anymore
837 837
 	 */
838
-	function getTotalLineFromObject(&$object, &$line, $use_level=false, $return_all=0) {
838
+	function getTotalLineFromObject(&$object, &$line, $use_level = false, $return_all = 0) {
839 839
 		global $conf;
840 840
 		
841 841
 		$rang = $line->rang;
@@ -846,31 +846,31 @@  discard block
 block discarded – undo
846 846
 		$total_ttc = 0;
847 847
 		$TTotal_tva = array();
848 848
 		
849
-		$sign=1;
850
-		if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
849
+		$sign = 1;
850
+		if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
851 851
 		
852 852
 		if (GETPOST('action') == 'builddoc') $builddoc = true;
853 853
 		else $builddoc = false;
854 854
 		
855 855
 		dol_include_once('/subtotal/class/subtotal.class.php');
856
-		foreach($object->lines as $l) {
856
+		foreach ($object->lines as $l) {
857 857
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
858
-			if($l->rang>=$rang) {
858
+			if ($l->rang >= $rang) {
859 859
 				//echo 'return!<br>';
860 860
 				if (!$return_all) return $total;
861 861
 				else return array($total, $total_tva, $total_ttc, $TTotal_tva);
862 862
 			}
863
-			else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
863
+			else if (TSubtotal::isTitle($l, 100 - $qty_line)) 
864 864
 		  	{
865 865
 				$total = 0;
866 866
 				$total_tva = 0;
867 867
 				$total_ttc = 0;
868 868
 				$TTotal_tva = array();
869 869
 			}
870
-			elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
870
+			elseif (!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
871 871
 				
872 872
 				// TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF
873
-				if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION)
873
+				if ($builddoc && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
874 874
 				{
875 875
 					if ($l->situation_percent > 0)
876 876
 					{
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
 						}
884 884
 						
885 885
 						$result = $sign * ($l->total_ht / ($l->situation_percent / 100)) * $progress;
886
-						$total+= $result;
886
+						$total += $result;
887 887
 						// TODO check si les 3 lignes du dessous sont corrects
888 888
 						$total_tva += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
889 889
 						$TTotal_tva[$l->tva_tx] += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
@@ -915,10 +915,10 @@  discard block
 block discarded – undo
915 915
 	 * @param $w            float               width
916 916
 	 * @param $h            float               height
917 917
 	 */
918
-	function pdf_add_total(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
919
-		global $conf,$subtotal_last_title_posy;
918
+	function pdf_add_total(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
919
+		global $conf, $subtotal_last_title_posy;
920 920
 
921
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
921
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
922 922
 		if (!empty($conf->global->SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES) && $hideInnerLines && !empty($subtotal_last_title_posy))
923 923
 		{
924 924
 			$posy = $subtotal_last_title_posy;
@@ -927,40 +927,40 @@  discard block
 block discarded – undo
927 927
 		
928 928
 		$hidePriceOnSubtotalLines = (int) GETPOST('hide_price_on_subtotal_lines');
929 929
 
930
-		if($object->element == 'shipping' || $object->element == 'delivery')
930
+		if ($object->element == 'shipping' || $object->element == 'delivery')
931 931
 		{
932 932
 			$hidePriceOnSubtotalLines = 1;
933 933
 		}
934 934
 		
935 935
 		$set_pagebreak_margin = false;
936
-		if(method_exists('Closure','bind')) {
936
+		if (method_exists('Closure', 'bind')) {
937 937
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
938
-			$sweetsThief = function ($pdf) {
939
-		    		return $pdf->bMargin ;
938
+			$sweetsThief = function($pdf) {
939
+		    		return $pdf->bMargin;
940 940
 			};
941 941
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
942 942
 	
943
-			$bMargin  = $sweetsThief($pdf);
943
+			$bMargin = $sweetsThief($pdf);
944 944
 	
945
-			$pdf->SetAutoPageBreak( false );
945
+			$pdf->SetAutoPageBreak(false);
946 946
 
947 947
 			$set_pagebreak_margin = true;			
948 948
 		}
949 949
 		
950 950
 			
951
-		if($line->qty==99)
952
-			$pdf->SetFillColor(220,220,220);
953
-		elseif ($line->qty==98)
954
-			$pdf->SetFillColor(230,230,230);
951
+		if ($line->qty == 99)
952
+			$pdf->SetFillColor(220, 220, 220);
953
+		elseif ($line->qty == 98)
954
+			$pdf->SetFillColor(230, 230, 230);
955 955
 		else
956
-			$pdf->SetFillColor(240,240,240);
956
+			$pdf->SetFillColor(240, 240, 240);
957 957
 		
958 958
 		$style = 'B';
959 959
 		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
960 960
 		
961 961
 		$pdf->SetFont('', $style, 9);
962 962
 		
963
-		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R',true);
963
+		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R', true);
964 964
 //		var_dump($bMargin);
965 965
 		$pageAfter = $pdf->getPage();
966 966
 		
@@ -988,7 +988,7 @@  discard block
 block discarded – undo
988 988
 			
989 989
 			
990 990
 			
991
-			if($total_to_print !== '') {
991
+			if ($total_to_print !== '') {
992 992
 				
993 993
 				if (GETPOST('hideInnerLines'))
994 994
 				{
@@ -1015,11 +1015,11 @@  discard block
 block discarded – undo
1015 1015
 			}
1016 1016
 
1017 1017
 			$pdf->SetXY($pdf->postotalht, $posy);
1018
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1019
-			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
1018
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
1019
+			$pdf->MultiCell($pdf->page_largeur - $pdf->marge_droite - $pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
1020 1020
 		}
1021
-		else{
1022
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1021
+		else {
1022
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
1023 1023
 		}
1024 1024
 		
1025 1025
 		$posy = $posy + $cell_height;
@@ -1039,22 +1039,22 @@  discard block
 block discarded – undo
1039 1039
 	 * @param $w            float               width
1040 1040
 	 * @param $h            float               height
1041 1041
 	 */
1042
-	function pdf_add_title(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
1042
+	function pdf_add_title(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
1043 1043
 		
1044
-		global $db,$conf,$subtotal_last_title_posy;
1044
+		global $db, $conf, $subtotal_last_title_posy;
1045 1045
 		
1046 1046
 		$subtotal_last_title_posy = $posy;
1047
-		$pdf->SetXY ($posx, $posy);
1047
+		$pdf->SetXY($posx, $posy);
1048 1048
 		
1049
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1049
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1050 1050
 		
1051 1051
 		
1052 1052
  
1053
-		$style = ($line->qty==1) ? 'BU' : 'BUI';
1053
+		$style = ($line->qty == 1) ? 'BU' : 'BUI';
1054 1054
 		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
1055 1055
 		
1056
-		if($hideInnerLines) {
1057
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
1056
+		if ($hideInnerLines) {
1057
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9);
1058 1058
 			else 
1059 1059
 			{
1060 1060
 				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
@@ -1063,44 +1063,44 @@  discard block
 block discarded – undo
1063 1063
 		}
1064 1064
 		else {
1065 1065
 
1066
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
1066
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9); //TODO if super utile
1067 1067
 			else $pdf->SetFont('', $style, 9);
1068 1068
 			
1069 1069
 		}
1070 1070
 		
1071 1071
 		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
1072
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
1072
+		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J', true); // et maintenant avec du HTML
1073 1073
 		
1074
-		if($description && !$hidedesc) {
1074
+		if ($description && !$hidedesc) {
1075 1075
 			$posy = $pdf->GetY();
1076 1076
 			
1077 1077
 			$pdf->SetFont('', '', 8);
1078 1078
 			
1079
-			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J',true);
1079
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J', true);
1080 1080
 
1081 1081
 		}
1082 1082
 		
1083 1083
 	}
1084 1084
 
1085
-	function pdf_writelinedesc_ref($parameters=array(), &$object, &$action='') {
1085
+	function pdf_writelinedesc_ref($parameters = array(), &$object, &$action = '') {
1086 1086
 	// ultimate PDF hook O_o
1087 1087
 		
1088
-		return $this->pdf_writelinedesc($parameters,$object,$action);
1088
+		return $this->pdf_writelinedesc($parameters, $object, $action);
1089 1089
 		
1090 1090
 	}
1091 1091
 
1092 1092
 	function isModSubtotalLine(&$parameters, &$object) {
1093 1093
 		
1094
-		if(is_array($parameters)) {
1094
+		if (is_array($parameters)) {
1095 1095
 			$i = & $parameters['i'];	
1096 1096
 		}
1097 1097
 		else {
1098
-			$i = (int)$parameters;
1098
+			$i = (int) $parameters;
1099 1099
 		}
1100 1100
 
1101 1101
 		$line = $object->lines[$i];
1102 1102
 
1103
-		if($object->element == 'shipping' || $object->element == 'delivery')
1103
+		if ($object->element == 'shipping' || $object->element == 'delivery')
1104 1104
 		{
1105 1105
 			dol_include_once('/commande/class/commande.class.php');
1106 1106
 			$line = new OrderLine($object->db);
@@ -1108,7 +1108,7 @@  discard block
 block discarded – undo
1108 1108
 		}
1109 1109
 		
1110 1110
 
1111
-		if($line->special_code == $this->module_number && $line->product_type == 9) {
1111
+		if ($line->special_code == $this->module_number && $line->product_type == 9) {
1112 1112
 			return true;
1113 1113
 		}
1114 1114
 		
@@ -1116,42 +1116,42 @@  discard block
 block discarded – undo
1116 1116
 		
1117 1117
 	}
1118 1118
 
1119
-	function pdf_getlineqty($parameters=array(), &$object, &$action='') {
1120
-		global $conf,$hideprices;
1119
+	function pdf_getlineqty($parameters = array(), &$object, &$action = '') {
1120
+		global $conf, $hideprices;
1121 1121
 
1122
-		if($this->isModSubtotalLine($parameters,$object) ){
1122
+		if ($this->isModSubtotalLine($parameters, $object)) {
1123 1123
 			$this->resprints = ' ';
1124 1124
 			
1125
-			if((float)DOL_VERSION<=3.6) {
1125
+			if ((float) DOL_VERSION <= 3.6) {
1126 1126
 				return '';
1127 1127
 			}
1128
-			else if((float)DOL_VERSION>=3.8) {
1128
+			else if ((float) DOL_VERSION >= 3.8) {
1129 1129
 				return 1;
1130 1130
 			}
1131 1131
 			
1132 1132
 		}
1133
-		elseif(!empty($hideprices)) {
1133
+		elseif (!empty($hideprices)) {
1134 1134
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1135 1135
 			return 1;
1136 1136
 		}
1137 1137
 		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1138 1138
 		{
1139
-			$hideInnerLines = (int)GETPOST('hideInnerLines');
1140
-			$hidedetails = (int)GETPOST('hidedetails');
1139
+			$hideInnerLines = (int) GETPOST('hideInnerLines');
1140
+			$hidedetails = (int) GETPOST('hidedetails');
1141 1141
 			if (empty($hideInnerLines) && !empty($hidedetails))
1142 1142
 			{
1143 1143
 				$this->resprints = $object->lines[$parameters['i']]->qty;
1144 1144
 			}
1145 1145
 		}
1146 1146
 		
1147
-		if(is_array($parameters)) $i = & $parameters['i'];
1148
-		else $i = (int)$parameters;
1147
+		if (is_array($parameters)) $i = & $parameters['i'];
1148
+		else $i = (int) $parameters;
1149 1149
 
1150 1150
 		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)
1151 1151
 		
1152
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1152
+		if (empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1153 1153
 
1154
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1154
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1155 1155
 		{
1156 1156
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1157 1157
 			{
@@ -1163,20 +1163,20 @@  discard block
 block discarded – undo
1163 1163
 		return 0;
1164 1164
 	}
1165 1165
 	
1166
-	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1166
+	function pdf_getlinetotalexcltax($parameters = array(), &$object, &$action = '') {
1167 1167
 	    global $conf, $hideprices, $hookmanager;
1168 1168
 		
1169
-		if(is_array($parameters)) $i = & $parameters['i'];
1170
-		else $i = (int)$parameters;
1169
+		if (is_array($parameters)) $i = & $parameters['i'];
1170
+		else $i = (int) $parameters;
1171 1171
 			
1172
-		if($this->isModSubtotalLine($parameters,$object) ){
1172
+		if ($this->isModSubtotalLine($parameters, $object)) {
1173 1173
 			
1174 1174
 			$this->resprints = ' ';
1175 1175
 			
1176
-			if((float)DOL_VERSION<=3.6) {
1176
+			if ((float) DOL_VERSION <= 3.6) {
1177 1177
 				return '';
1178 1178
 			}
1179
-			else if((float)DOL_VERSION>=3.8) {
1179
+			else if ((float) DOL_VERSION >= 3.8) {
1180 1180
 				return 1;
1181 1181
 			}
1182 1182
 			
@@ -1202,7 +1202,7 @@  discard block
 block discarded – undo
1202 1202
 				}
1203 1203
 			}
1204 1204
 		}
1205
-		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1205
+		if ((int) GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) {
1206 1206
 		    $this->resprints = price($object->lines[$i]->total_ht);
1207 1207
 		}
1208 1208
 		
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
 		{
1228 1228
 			// Check if a title exist for this line && if the title have subtotal
1229 1229
 			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1230
-			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1230
+			if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1231 1231
 			{
1232 1232
 
1233 1233
 				$this->resprints = ' ';
@@ -1247,7 +1247,7 @@  discard block
 block discarded – undo
1247 1247
 	 */
1248 1248
 	private function callHook(&$object, &$hookmanager, $action, $params, $defaultReturn = 1)
1249 1249
 	{
1250
-		$reshook=$hookmanager->executeHooks('subtotalHidePrices',$params, $object, $action);
1250
+		$reshook = $hookmanager->executeHooks('subtotalHidePrices', $params, $object, $action);
1251 1251
 		if ($reshook < 0)
1252 1252
 		{
1253 1253
 			$this->error = $hookmanager->error;
@@ -1263,7 +1263,7 @@  discard block
 block discarded – undo
1263 1263
 			$this->resprints = $hookmanager->resprints;
1264 1264
 
1265 1265
 			// override return (use  $this->results['overrideReturn'] or $this->resArray['overrideReturn'] in other module action_xxxx.class.php )
1266
-			if(isset($hookmanager->resArray['overrideReturn']))
1266
+			if (isset($hookmanager->resArray['overrideReturn']))
1267 1267
 			{
1268 1268
 				return $hookmanager->resArray['overrideReturn'];
1269 1269
 			}
@@ -1272,25 +1272,25 @@  discard block
 block discarded – undo
1272 1272
 		return $defaultReturn;
1273 1273
 	}
1274 1274
 	
1275
-	function pdf_getlinetotalwithtax($parameters=array(), &$object, &$action='') {
1275
+	function pdf_getlinetotalwithtax($parameters = array(), &$object, &$action = '') {
1276 1276
 		global $conf;
1277 1277
 		
1278
-		if($this->isModSubtotalLine($parameters,$object) ){
1278
+		if ($this->isModSubtotalLine($parameters, $object)) {
1279 1279
 			
1280 1280
 			$this->resprints = ' ';
1281 1281
 		
1282
-			if((float)DOL_VERSION<=3.6) {
1282
+			if ((float) DOL_VERSION <= 3.6) {
1283 1283
 				return '';
1284 1284
 			}
1285
-			else if((float)DOL_VERSION>=3.8) {
1285
+			else if ((float) DOL_VERSION >= 3.8) {
1286 1286
 				return 1;
1287 1287
 			}
1288 1288
 		}
1289 1289
 		
1290
-		if(is_array($parameters)) $i = & $parameters['i'];
1291
-		else $i = (int)$parameters;
1290
+		if (is_array($parameters)) $i = & $parameters['i'];
1291
+		else $i = (int) $parameters;
1292 1292
 		
1293
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1293
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))) 
1294 1294
 		{
1295 1295
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1296 1296
 			{
@@ -1302,24 +1302,24 @@  discard block
 block discarded – undo
1302 1302
 		return 0;
1303 1303
 	}
1304 1304
 	
1305
-	function pdf_getlineunit($parameters=array(), &$object, &$action='') {
1305
+	function pdf_getlineunit($parameters = array(), &$object, &$action = '') {
1306 1306
 		global $conf;
1307 1307
 		
1308
-		if($this->isModSubtotalLine($parameters,$object) ){
1308
+		if ($this->isModSubtotalLine($parameters, $object)) {
1309 1309
 			$this->resprints = ' ';
1310 1310
 		
1311
-			if((float)DOL_VERSION<=3.6) {
1311
+			if ((float) DOL_VERSION <= 3.6) {
1312 1312
 				return '';
1313 1313
 			}
1314
-			else if((float)DOL_VERSION>=3.8) {
1314
+			else if ((float) DOL_VERSION >= 3.8) {
1315 1315
 				return 1;
1316 1316
 			}
1317 1317
 		}
1318 1318
 		
1319
-		if(is_array($parameters)) $i = & $parameters['i'];
1320
-		else $i = (int)$parameters;
1319
+		if (is_array($parameters)) $i = & $parameters['i'];
1320
+		else $i = (int) $parameters;
1321 1321
 			
1322
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1322
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1323 1323
 		{
1324 1324
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1325 1325
 			{
@@ -1331,32 +1331,32 @@  discard block
 block discarded – undo
1331 1331
 		return 0;
1332 1332
 	}
1333 1333
 	
1334
-	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1335
-	    global $conf,$hideprices,$hookmanager;
1334
+	function pdf_getlineupexcltax($parameters = array(), &$object, &$action = '') {
1335
+	    global $conf, $hideprices, $hookmanager;
1336 1336
 
1337
-		if(is_array($parameters)) $i = & $parameters['i'];
1338
-		else $i = (int)$parameters;
1337
+		if (is_array($parameters)) $i = & $parameters['i'];
1338
+		else $i = (int) $parameters;
1339 1339
 
1340
-		if($this->isModSubtotalLine($parameters,$object) ) {
1340
+		if ($this->isModSubtotalLine($parameters, $object)) {
1341 1341
 			$this->resprints = ' ';
1342 1342
 
1343 1343
             $line = $object->lines[$i];
1344 1344
 
1345 1345
             // On récupère les montants du bloc pour les afficher dans la ligne de sous-total
1346
-            if(TSubtotal::isSubtotal($line)) {
1346
+            if (TSubtotal::isSubtotal($line)) {
1347 1347
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1348 1348
 
1349
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1350
-                if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1349
+                if (is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1350
+                if (!empty($parentTitle->array_options['options_show_total_ht'])) {
1351 1351
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1352 1352
                     $this->resprints = price($TTotal['total_unit_subprice']);
1353 1353
                 }
1354 1354
             }
1355 1355
 		
1356
-			if((float)DOL_VERSION<=3.6) {
1356
+			if ((float) DOL_VERSION <= 3.6) {
1357 1357
 				return '';
1358 1358
 			}
1359
-			else if((float)DOL_VERSION>=3.8) {
1359
+			else if ((float) DOL_VERSION >= 3.8) {
1360 1360
 				return 1;
1361 1361
 			}
1362 1362
 		}
@@ -1384,7 +1384,7 @@  discard block
 block discarded – undo
1384 1384
 		    
1385 1385
 		    // Check if a title exist for this line && if the title have subtotal
1386 1386
 		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1387
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1387
+		    if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1388 1388
 		    {
1389 1389
 		        
1390 1390
 		        $this->resprints = ' ';
@@ -1398,37 +1398,37 @@  discard block
 block discarded – undo
1398 1398
 		return 0;
1399 1399
 	}
1400 1400
 	
1401
-	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1402
-	    global $conf,$hideprices,$hookmanager;
1401
+	function pdf_getlineremisepercent($parameters = array(), &$object, &$action = '') {
1402
+	    global $conf, $hideprices, $hookmanager;
1403 1403
 
1404
-        if(is_array($parameters)) $i = & $parameters['i'];
1404
+        if (is_array($parameters)) $i = & $parameters['i'];
1405 1405
         else $i = (int) $parameters;
1406 1406
 
1407
-		if($this->isModSubtotalLine($parameters,$object) ) {
1407
+		if ($this->isModSubtotalLine($parameters, $object)) {
1408 1408
 			$this->resprints = ' ';
1409 1409
 
1410 1410
             $line = $object->lines[$i];
1411 1411
 
1412 1412
             // Affichage de la remise 
1413
-            if(TSubtotal::isSubtotal($line)) {
1413
+            if (TSubtotal::isSubtotal($line)) {
1414 1414
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1415 1415
 
1416
-                if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1417
-                if(! empty($parentTitle->array_options['options_show_reduc'])) {
1416
+                if (empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1417
+                if (!empty($parentTitle->array_options['options_show_reduc'])) {
1418 1418
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1419
-                    $this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
1419
+                    $this->resprints = price((1 - $TTotal['total_ht'] / $TTotal['total_subprice']) * 100, 0, '', 1, 2, 2).'%';
1420 1420
                 }
1421 1421
             }
1422 1422
 		
1423
-			if((float)DOL_VERSION<=3.6) {
1423
+			if ((float) DOL_VERSION <= 3.6) {
1424 1424
 				return '';
1425 1425
 			}
1426
-			else if((float)DOL_VERSION>=3.8) {
1426
+			else if ((float) DOL_VERSION >= 3.8) {
1427 1427
 				return 1;
1428 1428
 			}
1429 1429
 		}
1430 1430
 		elseif (!empty($hideprices)
1431
-		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1431
+		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1432 1432
 		        )
1433 1433
 		    {
1434 1434
 		        if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1441,24 +1441,24 @@  discard block
 block discarded – undo
1441 1441
 		return 0;
1442 1442
 	}
1443 1443
 	
1444
-	function pdf_getlineupwithtax($parameters=array(), &$object, &$action='') {
1445
-		global $conf,$hideprices;
1444
+	function pdf_getlineupwithtax($parameters = array(), &$object, &$action = '') {
1445
+		global $conf, $hideprices;
1446 1446
 		
1447
-		if($this->isModSubtotalLine($parameters,$object) ){
1447
+		if ($this->isModSubtotalLine($parameters, $object)) {
1448 1448
 			$this->resprints = ' ';
1449
-			if((float)DOL_VERSION<=3.6) {
1449
+			if ((float) DOL_VERSION <= 3.6) {
1450 1450
 				return '';
1451 1451
 			}
1452
-			else if((float)DOL_VERSION>=3.8) {
1452
+			else if ((float) DOL_VERSION >= 3.8) {
1453 1453
 				return 1;
1454 1454
 			}
1455 1455
 		}
1456 1456
 		
1457
-		if(is_array($parameters)) $i = & $parameters['i'];
1458
-		else $i = (int)$parameters;
1457
+		if (is_array($parameters)) $i = & $parameters['i'];
1458
+		else $i = (int) $parameters;
1459 1459
 			
1460 1460
 		if (!empty($hideprices)
1461
-				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1461
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1462 1462
 		)
1463 1463
 		{
1464 1464
 			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1471,22 +1471,22 @@  discard block
 block discarded – undo
1471 1471
 		return 0;
1472 1472
 	}
1473 1473
 	
1474
-	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
1475
-	    global $conf,$hideprices,$hookmanager;
1474
+	function pdf_getlinevatrate($parameters = array(), &$object, &$action = '') {
1475
+	    global $conf, $hideprices, $hookmanager;
1476 1476
 	    
1477
-		if($this->isModSubtotalLine($parameters,$object) ){
1477
+		if ($this->isModSubtotalLine($parameters, $object)) {
1478 1478
 			$this->resprints = ' ';
1479 1479
 			
1480
-			if((float)DOL_VERSION<=3.6) {
1480
+			if ((float) DOL_VERSION <= 3.6) {
1481 1481
 				return '';
1482 1482
 			}
1483
-			else if((float)DOL_VERSION>=3.8) {
1483
+			else if ((float) DOL_VERSION >= 3.8) {
1484 1484
 				return 1;
1485 1485
 			}
1486 1486
 		}
1487 1487
 		
1488
-		if(is_array($parameters)) $i = & $parameters['i'];
1489
-		else $i = (int)$parameters;
1488
+		if (is_array($parameters)) $i = & $parameters['i'];
1489
+		else $i = (int) $parameters;
1490 1490
 		
1491 1491
 		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)
1492 1492
 
@@ -1513,7 +1513,7 @@  discard block
 block discarded – undo
1513 1513
 		    
1514 1514
 		    // Check if a title exist for this line && if the title have subtotal
1515 1515
 		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1516
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1516
+		    if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1517 1517
 		    {
1518 1518
 		        
1519 1519
 		        $this->resprints = ' ';
@@ -1527,23 +1527,23 @@  discard block
 block discarded – undo
1527 1527
 		return 0;
1528 1528
 	}
1529 1529
 		
1530
-	function pdf_getlineprogress($parameters=array(), &$object, &$action) {
1530
+	function pdf_getlineprogress($parameters = array(), &$object, &$action) {
1531 1531
 		global $conf;
1532 1532
 		
1533
-		if($this->isModSubtotalLine($parameters,$object) ){
1533
+		if ($this->isModSubtotalLine($parameters, $object)) {
1534 1534
 			$this->resprints = ' ';
1535
-			if((float)DOL_VERSION<=3.6) {
1535
+			if ((float) DOL_VERSION <= 3.6) {
1536 1536
 				return '';
1537 1537
 			}
1538
-			else if((float)DOL_VERSION>=3.8) {
1538
+			else if ((float) DOL_VERSION >= 3.8) {
1539 1539
 				return 1;
1540 1540
 			}
1541 1541
 		}
1542 1542
 		
1543
-		if(is_array($parameters)) $i = & $parameters['i'];
1544
-		else $i = (int)$parameters;
1543
+		if (is_array($parameters)) $i = & $parameters['i'];
1544
+		else $i = (int) $parameters;
1545 1545
 			
1546
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1546
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1547 1547
 		{
1548 1548
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1549 1549
 			{
@@ -1558,12 +1558,12 @@  discard block
 block discarded – undo
1558 1558
 	function add_numerotation(&$object) {
1559 1559
 		global $conf;
1560 1560
 		
1561
-		if(!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1561
+		if (!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1562 1562
 		
1563 1563
 			$TLevelTitre = array();
1564 1564
 			$prevlevel = 0;
1565 1565
 		
1566
-			foreach($object->lines as $k=>&$line) 
1566
+			foreach ($object->lines as $k=>&$line) 
1567 1567
 			{
1568 1568
 				if ($line->id > 0 && $this->isModSubtotalLine($k, $object) && $line->qty <= 10)
1569 1569
 				{
@@ -1577,12 +1577,12 @@  discard block
 block discarded – undo
1577 1577
 	}
1578 1578
 
1579 1579
 	// TODO ne gère pas encore la numération des lignes "Totaux"
1580
-	private function formatNumerotation(&$TLineTitle, $line_reference='', $level=1, $prefix_num=0)
1580
+	private function formatNumerotation(&$TLineTitle, $line_reference = '', $level = 1, $prefix_num = 0)
1581 1581
 	{
1582 1582
 		$TTitle = array();
1583 1583
 		
1584
-		$i=1;
1585
-		$j=0;
1584
+		$i = 1;
1585
+		$j = 0;
1586 1586
 		foreach ($TLineTitle as $k => &$line)
1587 1587
 		{
1588 1588
 			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
@@ -1592,7 +1592,7 @@  discard block
 block discarded – undo
1592 1592
 			{
1593 1593
 				$TTitle[$j]['numerotation'] = ($prefix_num == 0) ? $i : $prefix_num.'.'.$i;
1594 1594
 				//var_dump('Prefix == '.$prefix_num.' // '.$line->desc.' ==> numerotation == '.$TTitle[$j]['numerotation'].'   ###    '.$line->qty .'=='. $level);
1595
-				if (empty($line->label) && (float)DOL_VERSION < 6)
1595
+				if (empty($line->label) && (float) DOL_VERSION < 6)
1596 1596
 				{
1597 1597
 					$line->label = !empty($line->desc) ? $line->desc : $line->description;
1598 1598
 					$line->desc = $line->description = '';
@@ -1618,26 +1618,26 @@  discard block
 block discarded – undo
1618 1618
 	
1619 1619
 	function setDocTVA(&$pdf, &$object) {
1620 1620
 		
1621
-		$hidedetails = (int)GETPOST('hidedetails');
1621
+		$hidedetails = (int) GETPOST('hidedetails');
1622 1622
 		
1623
-		if(empty($hidedetails)) return false;
1623
+		if (empty($hidedetails)) return false;
1624 1624
 		
1625 1625
 		// TODO can't add VAT to document without lines... :-/
1626 1626
 		
1627 1627
 		return true;
1628 1628
 	}
1629 1629
 	
1630
-	function beforePDFCreation($parameters=array(), &$object, &$action)
1630
+	function beforePDFCreation($parameters = array(), &$object, &$action)
1631 1631
 	{
1632 1632
 		/**
1633 1633
 		 * @var $pdf    TCPDF
1634 1634
 		 */
1635
-		global $pdf,$conf, $langs;
1635
+		global $pdf, $conf, $langs;
1636 1636
 
1637 1637
 		// var_dump($object->lines);
1638 1638
 		dol_include_once('/subtotal/class/subtotal.class.php');
1639 1639
 
1640
-		foreach($parameters as $key=>$value) {
1640
+		foreach ($parameters as $key=>$value) {
1641 1641
 			${$key} = $value;
1642 1642
 		}
1643 1643
 		
@@ -1645,43 +1645,43 @@  discard block
 block discarded – undo
1645 1645
 		
1646 1646
 		$this->add_numerotation($object);	
1647 1647
 		
1648
-        foreach($object->lines as $k => &$l) {
1649
-            if(TSubtotal::isSubtotal($l)) {
1648
+        foreach ($object->lines as $k => &$l) {
1649
+            if (TSubtotal::isSubtotal($l)) {
1650 1650
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1651
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1652
-                if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_reduc'])) {
1653
-                    $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1651
+                if (is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1652
+                if (!empty($parentTitle->id) && !empty($parentTitle->array_options['options_show_reduc'])) {
1653
+                    $l->remise_percent = 100; // Affichage de la réduction sur la ligne de sous-total
1654 1654
                 }
1655 1655
             }
1656 1656
 
1657 1657
 
1658 1658
             // Pas de hook sur les colonnes du PDF expédition, on unset les bonnes variables
1659
-            if(($object->element == 'shipping' || $object->element == 'delivery') && $this->isModSubtotalLine($k, $object))
1659
+            if (($object->element == 'shipping' || $object->element == 'delivery') && $this->isModSubtotalLine($k, $object))
1660 1660
 			{
1661 1661
 				$l->qty = $l->qty_asked;
1662 1662
 				unset($l->qty_asked, $l->qty_shipped, $l->volume, $l->weight);
1663 1663
 			}
1664 1664
         }
1665 1665
 
1666
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1667
-		$hidedetails = (int)GETPOST('hidedetails');
1666
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1667
+		$hidedetails = (int) GETPOST('hidedetails');
1668 1668
 
1669 1669
 		if ($hideInnerLines) { // si c une ligne de titre
1670
-	    	$fk_parent_line=0;
1671
-			$TLines =array();
1670
+	    	$fk_parent_line = 0;
1671
+			$TLines = array();
1672 1672
 		
1673
-			$original_count=count($object->lines);
1673
+			$original_count = count($object->lines);
1674 1674
 		    $TTvas = array(); // tableau de tva
1675 1675
 		    
1676
-			foreach($object->lines as $k=>&$line) 
1676
+			foreach ($object->lines as $k=>&$line) 
1677 1677
 			{
1678 1678
 			    
1679
-				if($line->product_type==9 && $line->rowid>0) 
1679
+				if ($line->product_type == 9 && $line->rowid > 0) 
1680 1680
 				{
1681 1681
 					$fk_parent_line = $line->rowid;
1682 1682
 					
1683 1683
 					// 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
1684
-					if(TSubtotal::isSubtotal($line)) 
1684
+					if (TSubtotal::isSubtotal($line)) 
1685 1685
 					{
1686 1686
 						/*$total = $this->getTotalLineFromObject($object, $line, '');
1687 1687
 						
@@ -1712,22 +1712,22 @@  discard block
 block discarded – undo
1712 1712
 			
1713 1713
 				if ($hideInnerLines)
1714 1714
 				{
1715
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1715
+				    if (!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1716 1716
 				    {
1717
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1717
+				        if ($line->tva_tx != '0.000' && $line->product_type != 9) {
1718 1718
 				            
1719 1719
     				        // on remplit le tableau de tva pour substituer les lignes cachées
1720 1720
     				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1721 1721
     				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1722 1722
     				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1723 1723
     				    }
1724
-    					if($line->product_type==9 && $line->rowid>0)
1724
+    					if ($line->product_type == 9 && $line->rowid > 0)
1725 1725
     					{
1726 1726
     					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1727 1727
     					    // génère des lignes d'affichage des montants HT soumis à tva
1728 1728
     					    $nbtva = count($TTvas);
1729
-    					    if(!empty($nbtva)){
1730
-    					        foreach ($TTvas as $tx =>$val){
1729
+    					    if (!empty($nbtva)) {
1730
+    					        foreach ($TTvas as $tx =>$val) {
1731 1731
     					            $l = clone $line;
1732 1732
     					            $l->product_type = 1;
1733 1733
     					            $l->special_code = '';
@@ -1748,7 +1748,7 @@  discard block
 block discarded – undo
1748 1748
     					}
1749 1749
 				    } else {
1750 1750
 				        
1751
-				        if($line->product_type==9 && $line->rowid>0)
1751
+				        if ($line->product_type == 9 && $line->rowid > 0)
1752 1752
 				        {
1753 1753
 				            // ajoute la ligne de sous-total
1754 1754
 				            $TLines[] = $line; 
@@ -1776,9 +1776,9 @@  discard block
 block discarded – undo
1776 1776
 			
1777 1777
 			// cas incongru où il y aurait des produits en dessous du dernier sous-total
1778 1778
 			$nbtva = count($TTvas);
1779
-			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1779
+			if (!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1780 1780
 			{
1781
-			    foreach ($TTvas as $tx =>$val){
1781
+			    foreach ($TTvas as $tx =>$val) {
1782 1782
 			        $l = clone $line;
1783 1783
 			        $l->product_type = 1;
1784 1784
 			        $l->special_code = '';
@@ -1795,11 +1795,11 @@  discard block
 block discarded – undo
1795 1795
 			}
1796 1796
 			
1797 1797
 			global $nblignes;
1798
-			$nblignes=count($TLines);
1798
+			$nblignes = count($TLines);
1799 1799
 
1800 1800
 			$object->lines = $TLines;
1801 1801
 			
1802
-			if($i>count($object->lines)) {
1802
+			if ($i > count($object->lines)) {
1803 1803
 				$this->resprints = '';
1804 1804
 				return 0;
1805 1805
 			}
@@ -1808,55 +1808,55 @@  discard block
 block discarded – undo
1808 1808
 		return 0;
1809 1809
 	}
1810 1810
 
1811
-	function pdf_writelinedesc($parameters=array(), &$object, &$action)
1811
+	function pdf_writelinedesc($parameters = array(), &$object, &$action)
1812 1812
 	{
1813 1813
 		/**
1814 1814
 		 * @var $pdf    TCPDF
1815 1815
 		 */
1816
-		global $pdf,$conf;
1816
+		global $pdf, $conf;
1817 1817
 
1818
-		foreach($parameters as $key=>$value) {
1818
+		foreach ($parameters as $key=>$value) {
1819 1819
 			${$key} = $value;
1820 1820
 		}
1821 1821
 		
1822
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1823
-		$hidedetails = (int)GETPOST('hidedetails');
1822
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1823
+		$hidedetails = (int) GETPOST('hidedetails');
1824 1824
 		
1825
-		if($this->isModSubtotalLine($parameters,$object) ){			
1825
+		if ($this->isModSubtotalLine($parameters, $object)) {			
1826 1826
 		
1827 1827
 				global $hideprices;
1828 1828
 				
1829
-				if(!empty($hideprices)) {
1830
-					foreach($object->lines as &$line) {
1831
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1829
+				if (!empty($hideprices)) {
1830
+					foreach ($object->lines as &$line) {
1831
+						if ($line->fk_product_type != 9) $line->fk_parent_line = -1;	
1832 1832
 					}
1833 1833
 				}
1834 1834
 			
1835 1835
 				$line = &$object->lines[$i];
1836 1836
 
1837
-				if($object->element == 'delivery' && ! empty($object->commande->expeditions[$line->fk_origin_line])) unset($object->commande->expeditions[$line->fk_origin_line]);
1837
+				if ($object->element == 'delivery' && !empty($object->commande->expeditions[$line->fk_origin_line])) unset($object->commande->expeditions[$line->fk_origin_line]);
1838 1838
 
1839
-				if($line->info_bits>0) { // PAGE BREAK
1839
+				if ($line->info_bits > 0) { // PAGE BREAK
1840 1840
 					$pdf->addPage();
1841 1841
 					$posy = $pdf->GetY();
1842 1842
 				}
1843 1843
 				
1844 1844
 				$label = $line->label;
1845
-				$description= !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1845
+				$description = !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1846 1846
 				
1847
-				if(empty($label)) {
1847
+				if (empty($label)) {
1848 1848
 					$label = $description;
1849
-					$description='';
1849
+					$description = '';
1850 1850
 				}
1851 1851
 
1852
-				if($line->qty>90) {
1852
+				if ($line->qty > 90) {
1853 1853
 					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1854 1854
 					
1855 1855
 					$pageBefore = $pdf->getPage();
1856
-					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1856
+					$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1857 1857
 					$pageAfter = $pdf->getPage();	
1858 1858
 
1859
-					if($pageAfter>$pageBefore) {
1859
+					if ($pageAfter > $pageBefore) {
1860 1860
 						//print "ST $pageAfter>$pageBefore<br>";
1861 1861
 						$pdf->rollbackTransaction(true);
1862 1862
 						$pdf->addPage('', '', true);
@@ -1867,9 +1867,9 @@  discard block
 block discarded – undo
1867 1867
 					}
1868 1868
 
1869 1869
 					// On delivery PDF, we don't want quantities to appear and there are no hooks => setting text color to background color;
1870
-					if($object->element == 'delivery')
1870
+					if ($object->element == 'delivery')
1871 1871
 					{
1872
-						switch($line->qty)
1872
+						switch ($line->qty)
1873 1873
 						{
1874 1874
 							case 99:
1875 1875
 								$grey = 220;
@@ -1892,7 +1892,7 @@  discard block
 block discarded – undo
1892 1892
 				else if ($line->qty < 10) {
1893 1893
 					$pageBefore = $pdf->getPage();
1894 1894
 
1895
-					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
1895
+					$this->pdf_add_title($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h); 
1896 1896
 					$pageAfter = $pdf->getPage();	
1897 1897
 
1898 1898
 					
@@ -1908,9 +1908,9 @@  discard block
 block discarded – undo
1908 1908
 					}
1909 1909
 				*/
1910 1910
 
1911
-					if($object->element == 'delivery')
1911
+					if ($object->element == 'delivery')
1912 1912
 					{
1913
-						$pdf->SetTextColor(255,255,255);
1913
+						$pdf->SetTextColor(255, 255, 255);
1914 1914
 					}
1915 1915
 
1916 1916
 					$posy = $pdf->GetY();
@@ -1973,9 +1973,9 @@  discard block
 block discarded – undo
1973 1973
 	 * @param $hookmanager  HookManager
1974 1974
 	 * @return int
1975 1975
 	 */
1976
-	function printObjectLine ($parameters, &$object, &$action, $hookmanager){
1976
+	function printObjectLine($parameters, &$object, &$action, $hookmanager) {
1977 1977
 		
1978
-		global $conf,$langs,$user,$db,$bc;
1978
+		global $conf, $langs, $user, $db, $bc;
1979 1979
 		
1980 1980
 		$num = &$parameters['num'];
1981 1981
 		$line = &$parameters['line'];
@@ -1983,33 +1983,33 @@  discard block
 block discarded – undo
1983 1983
 		
1984 1984
 		$var = &$parameters['var'];
1985 1985
 
1986
-		$contexts = explode(':',$parameters['context']);
1987
-		if($parameters['currentcontext'] === 'paiementcard') return 0;
1986
+		$contexts = explode(':', $parameters['context']);
1987
+		if ($parameters['currentcontext'] === 'paiementcard') return 0;
1988 1988
 		$originline = null;
1989 1989
 
1990 1990
 		$createRight = $user->rights->{$object->element}->creer;
1991
-		if($object->element == 'facturerec' )
1991
+		if ($object->element == 'facturerec')
1992 1992
 		{
1993 1993
 			$object->statut = 0; // hack for facture rec
1994 1994
 			$createRight = $user->rights->facture->creer;
1995 1995
 		}
1996
-		elseif($object->element == 'order_supplier' )
1996
+		elseif ($object->element == 'order_supplier')
1997 1997
 		{
1998 1998
 		    $createRight = $user->rights->fournisseur->commande->creer;
1999 1999
 		}
2000
-		elseif($object->element == 'invoice_supplier' )
2000
+		elseif ($object->element == 'invoice_supplier')
2001 2001
 		{
2002 2002
 		    $createRight = $user->rights->fournisseur->facture->creer;
2003 2003
 		}
2004
-		elseif($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
2004
+		elseif ($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
2005 2005
 		{
2006 2006
 			// H4cK 4n0nYm0u$-style : $line n'est pas un objet instancié mais provient d'un fetch_object d'une requête SQL
2007 2007
 			$line->id = $line->rowid;
2008 2008
 			$line->product_type = $line->type;
2009 2009
 		}
2010
-		elseif($object->element == 'shipping' || $object->element == 'delivery')
2010
+		elseif ($object->element == 'shipping' || $object->element == 'delivery')
2011 2011
 		{
2012
-			if(empty($line->origin_line_id) && ! empty($line->fk_origin_line))
2012
+			if (empty($line->origin_line_id) && !empty($line->fk_origin_line))
2013 2013
 			{
2014 2014
 				$line->origin_line_id = $line->fk_origin_line;
2015 2015
 			}
@@ -2017,9 +2017,9 @@  discard block
 block discarded – undo
2017 2017
 			$originline = new OrderLine($db);
2018 2018
 			$originline->fetch($line->fk_origin_line);
2019 2019
 
2020
-			foreach(get_object_vars($line) as $property => $value)
2020
+			foreach (get_object_vars($line) as $property => $value)
2021 2021
 			{
2022
-				if(empty($originline->{ $property }))
2022
+				if (empty($originline->{ $property }))
2023 2023
 				{
2024 2024
 					$originline->{ $property } = $value;
2025 2025
 				}
@@ -2027,13 +2027,13 @@  discard block
 block discarded – undo
2027 2027
 
2028 2028
 			$line = $originline;
2029 2029
 		}
2030
- 		if($object->element=='facture')$idvar = 'facid';
2031
-        else $idvar='id';
2032
-		if($line->special_code!=$this->module_number || $line->product_type!=9) {
2033
-			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE) && $object->element !== 'invoice_supplier')
2030
+ 		if ($object->element == 'facture')$idvar = 'facid';
2031
+        else $idvar = 'id';
2032
+		if ($line->special_code != $this->module_number || $line->product_type != 9) {
2033
+			if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE) && $object->element !== 'invoice_supplier')
2034 2034
             {
2035
-                if(!(TSubtotal::isModSubtotalLine($line)) && ( $line->fk_prev_id === null ) && !($action == "editline" && GETPOST('lineid') == $line->id)) {
2036
-                    echo '<a name="duplicate-'.$line->id.'" href="' . $_SERVER['PHP_SELF'] . '?' . $idvar . '=' . $object->id . '&action=duplicate&lineid=' . $line->id . '"><i class="fa fa-clone" aria-hidden="true"></i></a>';
2035
+                if (!(TSubtotal::isModSubtotalLine($line)) && ($line->fk_prev_id === null) && !($action == "editline" && GETPOST('lineid') == $line->id)) {
2036
+                    echo '<a name="duplicate-'.$line->id.'" href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'"><i class="fa fa-clone" aria-hidden="true"></i></a>';
2037 2037
 
2038 2038
                     ?>
2039 2039
                         <script type="text/javascript">
@@ -2047,11 +2047,11 @@  discard block
 block discarded – undo
2047 2047
             }
2048 2048
 			return 0;
2049 2049
 		}
2050
-		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)) 
2050
+		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)) 
2051 2051
         {
2052 2052
 
2053 2053
 
2054
-			if((float)DOL_VERSION <= 3.4)
2054
+			if ((float) DOL_VERSION <= 3.4)
2055 2055
 			{
2056 2056
 				?>
2057 2057
 				<script type="text/javascript">
@@ -2075,22 +2075,22 @@  discard block
 block discarded – undo
2075 2075
 				<?php
2076 2076
 			}
2077 2077
 			
2078
-			if(empty($line->description)) $line->description = $line->desc;
2078
+			if (empty($line->description)) $line->description = $line->desc;
2079 2079
 			
2080 2080
 			$colspan = 5;
2081
-			if($object->element == 'facturerec' ) $colspan = 3;
2082
-			if($object->element == 'order_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
2083
-			if($object->element == 'invoice_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7;
2084
-			if($object->element == 'supplier_proposal') (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2085
-			if(!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
2081
+			if ($object->element == 'facturerec') $colspan = 3;
2082
+			if ($object->element == 'order_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
2083
+			if ($object->element == 'invoice_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 4 : $colspan = 7;
2084
+			if ($object->element == 'supplier_proposal') (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2085
+			if (!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
2086 2086
 				$colspan++; // Colonne PU Devise
2087 2087
 			}
2088
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
2089
-			if(!empty($conf->margin->enabled)) $colspan++;
2090
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
2091
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
2092
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
2093
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
2088
+			if ($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
2089
+			if (!empty($conf->margin->enabled)) $colspan++;
2090
+			if (!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
2091
+			if (!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
2092
+			if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
2093
+			if (!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
2094 2094
 					
2095 2095
 			/* Titre */
2096 2096
 			//var_dump($line);
@@ -2100,39 +2100,39 @@  discard block
 block discarded – undo
2100 2100
             
2101 2101
 			
2102 2102
 			?>
2103
-			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2103
+			<tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2104 2104
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2105 2105
 					{
2106
-						if($line->qty==99) print 'background:#adadcf';
2107
-						else if($line->qty==98) print 'background:#ddddff;';
2108
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2109
-						else if($line->qty==1) print 'background:#adadcf;';
2110
-						else if($line->qty==2) print 'background:#ddddff;';
2111
-						else if($line->qty==50) print '';
2106
+						if ($line->qty == 99) print 'background:#adadcf';
2107
+						else if ($line->qty == 98) print 'background:#ddddff;';
2108
+						else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;';
2109
+						else if ($line->qty == 1) print 'background:#adadcf;';
2110
+						else if ($line->qty == 2) print 'background:#ddddff;';
2111
+						else if ($line->qty == 50) print '';
2112 2112
 						else print 'background:#eeeeff;';
2113 2113
 
2114 2114
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2115 2115
 					}
2116 2116
 					else 
2117 2117
 					{
2118
-						if($line->qty==99) print 'background:#ddffdd';
2119
-						else if($line->qty==98) print 'background:#ddddff;';
2120
-						else if($line->qty==2) print 'background:#eeeeff; ';
2121
-						else if($line->qty==50) print '';
2122
-						else print 'background:#eeffee;' ;
2118
+						if ($line->qty == 99) print 'background:#ddffdd';
2119
+						else if ($line->qty == 98) print 'background:#ddddff;';
2120
+						else if ($line->qty == 2) print 'background:#eeeeff; ';
2121
+						else if ($line->qty == 50) print '';
2122
+						else print 'background:#eeffee;';
2123 2123
 					}
2124 2124
 
2125 2125
 			?>;">
2126 2126
 
2127
-				<?php if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
2127
+				<?php if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
2128 2128
 				<td class="linecolnum"><?php echo $i + 1; ?></td>
2129 2129
 				<?php } ?>
2130 2130
 
2131
-				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
2132
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
2131
+				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php
2132
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
2133 2133
 
2134
-						$params=array('line'=>$line);
2135
-						$reshook=$hookmanager->executeHooks('formEditProductOptions',$params,$object,$action);
2134
+						$params = array('line'=>$line);
2135
+						$reshook = $hookmanager->executeHooks('formEditProductOptions', $params, $object, $action);
2136 2136
 						
2137 2137
 						echo '<div id="line_'.$line->id.'"></div>'; // Imitation Dolibarr
2138 2138
 						echo '<input type="hidden" value="'.$line->id.'" name="lineid">';
@@ -2140,7 +2140,7 @@  discard block
 block discarded – undo
2140 2140
 						echo '<input id="product_id" type="hidden" value="'.$line->fk_product.'" name="type">';
2141 2141
 						echo '<input id="special_code" type="hidden" value="'.$line->special_code.'" name="type">';
2142 2142
 
2143
-						$isFreeText=false;
2143
+						$isFreeText = false;
2144 2144
 						if (TSubtotal::isTitle($line))
2145 2145
 						{
2146 2146
 							$qty_displayed = $line->qty;
@@ -2162,13 +2162,13 @@  discard block
 block discarded – undo
2162 2162
 						    $line->description = '';
2163 2163
 						}
2164 2164
 						$newlabel = $line->label;
2165
-						if($line->label=='' && !$isFreeText) {
2166
-							if(TSubtotal::isSubtotal($line)) {
2165
+						if ($line->label == '' && !$isFreeText) {
2166
+							if (TSubtotal::isSubtotal($line)) {
2167 2167
 								$newlabel = $line->description.' '.$this->getTitle($object, $line);
2168
-								$line->description='';
2169
-							} elseif( (float)DOL_VERSION < 6 ) {
2170
-								$newlabel= $line->description;
2171
-								$line->description='';
2168
+								$line->description = '';
2169
+							} elseif ((float) DOL_VERSION < 6) {
2170
+								$newlabel = $line->description;
2171
+								$line->description = '';
2172 2172
 							}
2173 2173
 						}
2174 2174
 
@@ -2177,10 +2177,10 @@  discard block
 block discarded – undo
2177 2177
 						
2178 2178
 						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2179 2179
 						
2180
-						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
2180
+						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)))
2181 2181
 						{
2182 2182
 							$select = '<select name="subtotal_level">';
2183
-							for ($j=1; $j<10; $j++)
2183
+							for ($j = 1; $j < 10; $j++)
2184 2184
 							{
2185 2185
 								if (!empty($readonlyForSituation)) {
2186 2186
 									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
@@ -2194,7 +2194,7 @@  discard block
 block discarded – undo
2194 2194
 
2195 2195
 						echo '<div class="subtotal_underline" style="margin-left:24px; line-height: 25px;">';
2196 2196
                         echo '<div>';
2197
-                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2197
+                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '').' />&nbsp;';
2198 2198
                         echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2199 2199
                         echo '</div>';
2200 2200
 
@@ -2215,21 +2215,21 @@  discard block
 block discarded – undo
2215 2215
                                 echo '</div>';
2216 2216
                             }
2217 2217
                             echo '<div>';
2218
-                            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;';
2218
+                            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;';
2219 2219
                             echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2220 2220
                             echo '</div>';
2221 2221
 
2222 2222
                             echo '<div>';
2223
-                            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;';
2223
+                            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;';
2224 2224
                             echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2225 2225
                             echo '</div>';
2226 2226
                         }
2227 2227
                         else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2228 2228
 						echo '</div>';
2229 2229
 
2230
-						if($line->qty<10) {
2230
+						if ($line->qty < 10) {
2231 2231
 							// WYSIWYG editor
2232
-							require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
2232
+							require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
2233 2233
 							$nbrows = ROWS_2;
2234 2234
 							$cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
2235 2235
 							if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
@@ -2249,25 +2249,25 @@  discard block
 block discarded – undo
2249 2249
 
2250 2250
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2251 2251
 						 {
2252
-							if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
2252
+							if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
2253 2253
 							{
2254
-								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2254
+								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
2255 2255
 								
2256 2256
 								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2257
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2257
+								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
2258 2258
 							}
2259 2259
 						 }
2260 2260
 						 else 
2261 2261
 						 {
2262
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2263
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2262
+							if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal');
2263
+							else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2264 2264
 						 }
2265 2265
 						 
2266 2266
 						 
2267 2267
 						 // Get display styles and apply them
2268 2268
 						 $titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
2269
-						 $titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2270
-						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2269
+						 $titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2270
+						 $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2271 2271
 						 
2272 2272
 						 if (empty($line->label)) {
2273 2273
 							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
@@ -2275,16 +2275,16 @@  discard block
 block discarded – undo
2275 2275
 						 } 
2276 2276
 						 else {
2277 2277
 
2278
-							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2278
+							if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2279 2279
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2280 2280
 							}
2281
-							else{
2281
+							else {
2282 2282
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
2283 2283
 							}
2284 2284
 
2285 2285
 						 } 
2286
-						if($line->qty>90) print ' : ';
2287
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2286
+						if ($line->qty > 90) print ' : ';
2287
+						if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2288 2288
 
2289 2289
 						 
2290 2290
 
@@ -2293,7 +2293,7 @@  discard block
 block discarded – undo
2293 2293
 			?></td>
2294 2294
 					 
2295 2295
 			<?php
2296
-				if($line->qty>90) {
2296
+				if ($line->qty > 90) {
2297 2297
 					/* Total */
2298 2298
 					$total_line = $this->getTotalLineFromObject($object, $line, '');
2299 2299
 					echo '<td class="linecolht nowrap" align="right" style="font-weight:bold;" rel="subtotal_total">'.price($total_line).'</td>';
@@ -2312,7 +2312,7 @@  discard block
 block discarded – undo
2312 2312
 				<?php
2313 2313
 				if ($action != 'selectlines') {
2314 2314
 				
2315
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
2315
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
2316 2316
 						?>
2317 2317
 						<input id="savelinebutton" class="button" type="submit" name="save" value="<?php echo $langs->trans('Save') ?>" />
2318 2318
 						<br />
@@ -2328,13 +2328,13 @@  discard block
 block discarded – undo
2328 2328
 						<?php
2329 2329
 						
2330 2330
 					}
2331
-					else{
2332
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2331
+					else {
2332
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2333 2333
 						{
2334
-							if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2334
+							if (TSubtotal::isTitle($line) && ($line->fk_prev_id === null)) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'.img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2335 2335
 						}
2336 2336
 
2337
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
2337
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
2338 2338
 						{
2339 2339
 							echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=editline&lineid='.$line->id.'">'.img_edit().'</a>';
2340 2340
 						}								
@@ -2349,7 +2349,7 @@  discard block
 block discarded – undo
2349 2349
 				<?php
2350 2350
 
2351 2351
 				if ($action != 'editline' && $action != 'selectlines') {
2352
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2352
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2353 2353
 						{
2354 2354
 
2355 2355
 							if ($line->fk_prev_id === null)
@@ -2357,12 +2357,12 @@  discard block
 block discarded – undo
2357 2357
 								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteline&lineid='.$line->id.'">'.img_delete().'</a>';
2358 2358
 							}
2359 2359
 
2360
-							if(TSubtotal::isTitle($line) && ($line->fk_prev_id === null) )
2360
+							if (TSubtotal::isTitle($line) && ($line->fk_prev_id === null))
2361 2361
 							{
2362 2362
 								if ((float) DOL_VERSION >= 8.0) {
2363 2363
 									$img_delete = img_delete($langs->trans('deleteWithAllLines'), ' class="pictodelete pictodeleteallline"');
2364 2364
 								} elseif ((float) DOL_VERSION >= 3.8) {
2365
-									$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal',' class="pictodelete" ');
2365
+									$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal', ' class="pictodelete" ');
2366 2366
 								} else {
2367 2367
 									$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all@subtotal');
2368 2368
 								}
@@ -2372,7 +2372,7 @@  discard block
 block discarded – undo
2372 2372
 								/* Depuis la 8.0, les icônes "standard" utilisent FontAwesome et sont préconfigurées selon la clé de l'image
2373 2373
 								 * Impossible d'en customiser par exemple la couleur, même en utilisant img_picto() directement
2374 2374
 								 */
2375
-								if((float) DOL_VERSION >= 8.0) {
2375
+								if ((float) DOL_VERSION >= 8.0) {
2376 2376
 								?>
2377 2377
 								<script>
2378 2378
 									$(document).ready(function () {
@@ -2388,7 +2388,7 @@  discard block
 block discarded – undo
2388 2388
 			</td>
2389 2389
 			
2390 2390
 			<?php 
2391
-			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
2391
+			if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
2392 2392
 			{
2393 2393
 				echo '<td class="subtotal_nc">';
2394 2394
 				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"' : '').' />';
@@ -2399,12 +2399,12 @@  discard block
 block discarded – undo
2399 2399
 			<td align="center" class="linecolmove tdlineupdown">
2400 2400
 			</td>
2401 2401
 			<?php } else { ?>
2402
-			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0  && $createRight ))?' class="tdlineupdown"':''); ?>></td>
2402
+			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0 && $createRight)) ? ' class="tdlineupdown"' : ''); ?>></td>
2403 2403
 			<?php } ?>
2404 2404
 
2405 2405
 
2406
-			<?php  if($action == 'selectlines'){ // dolibarr 8 ?>
2407
-			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
2406
+			<?php  if ($action == 'selectlines') { // dolibarr 8 ?>
2407
+			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i + 1; ?>]" value="<?php echo $line->id; ?>" ></td>
2408 2408
 			<?php } ?>
2409 2409
 
2410 2410
 			</tr>
@@ -2412,29 +2412,29 @@  discard block
 block discarded – undo
2412 2412
 			
2413 2413
 			
2414 2414
 			// Affichage des extrafields à la Dolibarr (car sinon non affiché sur les titres)
2415
-			if(TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2415
+			if (TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2416 2416
 				
2417
-				require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
2417
+				require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
2418 2418
 				
2419 2419
 				// Extrafields
2420 2420
 				$extrafieldsline = new ExtraFields($db);
2421 2421
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2422 2422
 				
2423
-				$colspan+=3; $mode = 'view';
2424
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2423
+				$colspan += 3; $mode = 'view';
2424
+				if ($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2425 2425
 				
2426 2426
 				$ex_element = $line->element;
2427 2427
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
2428
-				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ','colspan'=>$colspan));
2428
+				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ', 'colspan'=>$colspan));
2429 2429
 				$isExtraSelected = false;
2430
-				foreach($line->array_options as $option) {
2431
-					if(!empty($option) && $option != "-1") {
2430
+				foreach ($line->array_options as $option) {
2431
+					if (!empty($option) && $option != "-1") {
2432 2432
 						$isExtraSelected = true;
2433 2433
 						break;
2434 2434
 					}
2435 2435
 				}
2436 2436
 				
2437
-				if($mode === 'edit') {
2437
+				if ($mode === 'edit') {
2438 2438
 					?>
2439 2439
 					<script>
2440 2440
 						$(document).ready(function(){
@@ -2442,7 +2442,7 @@  discard block
 block discarded – undo
2442 2442
 							var all_tr_extrafields = $("tr.tr_extrafield_title");
2443 2443
 							<?php 
2444 2444
 							// Si un extrafield est rempli alors on affiche directement les extrafields
2445
-							if(!$isExtraSelected) {
2445
+							if (!$isExtraSelected) {
2446 2446
 								echo 'all_tr_extrafields.hide();';
2447 2447
 								echo 'var trad = "'.$langs->trans('showExtrafields').'";';
2448 2448
 								echo 'var extra = 0;';
@@ -2481,61 +2481,61 @@  discard block
 block discarded – undo
2481 2481
 			return 1;	
2482 2482
 			
2483 2483
 		}
2484
-		elseif(($object->element == 'commande' && in_array('ordershipmentcard', $contexts)) || (in_array('expeditioncard', $contexts) && $action == 'create'))
2484
+		elseif (($object->element == 'commande' && in_array('ordershipmentcard', $contexts)) || (in_array('expeditioncard', $contexts) && $action == 'create'))
2485 2485
 		{
2486 2486
 			$colspan = 4;
2487 2487
 
2488 2488
 			// HTML 5 data for js
2489 2489
 			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2490 2490
 ?>
2491
-			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2491
+			<tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2492 2492
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2493 2493
 					{
2494
-						if($line->qty==99) print 'background:#adadcf';
2495
-						else if($line->qty==98) print 'background:#ddddff;';
2496
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2497
-						else if($line->qty==1) print 'background:#adadcf;';
2498
-						else if($line->qty==2) print 'background:#ddddff;';
2499
-						else if($line->qty==50) print '';
2494
+						if ($line->qty == 99) print 'background:#adadcf';
2495
+						else if ($line->qty == 98) print 'background:#ddddff;';
2496
+						else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;';
2497
+						else if ($line->qty == 1) print 'background:#adadcf;';
2498
+						else if ($line->qty == 2) print 'background:#ddddff;';
2499
+						else if ($line->qty == 50) print '';
2500 2500
 						else print 'background:#eeeeff;';
2501 2501
 
2502 2502
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2503 2503
 					}
2504 2504
 					else
2505 2505
 					{
2506
-						if($line->qty==99) print 'background:#ddffdd';
2507
-						else if($line->qty==98) print 'background:#ddddff;';
2508
-						else if($line->qty==2) print 'background:#eeeeff; ';
2509
-						else if($line->qty==50) print '';
2510
-						else print 'background:#eeffee;' ;
2506
+						if ($line->qty == 99) print 'background:#ddffdd';
2507
+						else if ($line->qty == 98) print 'background:#ddddff;';
2508
+						else if ($line->qty == 2) print 'background:#eeeeff; ';
2509
+						else if ($line->qty == 50) print '';
2510
+						else print 'background:#eeffee;';
2511 2511
 					}
2512 2512
 
2513 2513
 			?>;">
2514 2514
 
2515
-				<td style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
2515
+				<td style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php
2516 2516
 
2517 2517
 
2518 2518
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2519 2519
 						 {
2520
-							if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2520
+							if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2521 2521
 							{
2522
-								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2522
+								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
2523 2523
 
2524 2524
 								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2525
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2525
+								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
2526 2526
 							}
2527 2527
 						 }
2528 2528
 						 else
2529 2529
 						 {
2530
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2531
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2530
+							if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal');
2531
+							else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2532 2532
 						 }
2533 2533
 
2534 2534
 
2535 2535
 						 // Get display styles and apply them
2536 2536
 						 $titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
2537
-						 $titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2538
-						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2537
+						 $titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2538
+						 $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2539 2539
 
2540 2540
 						 if (empty($line->label)) {
2541 2541
 							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
@@ -2543,22 +2543,22 @@  discard block
 block discarded – undo
2543 2543
 						 }
2544 2544
 						 else {
2545 2545
 
2546
-							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2546
+							if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2547 2547
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2548 2548
 							}
2549
-							else{
2549
+							else {
2550 2550
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2551 2551
 							}
2552 2552
 
2553 2553
 						 }
2554 2554
 						//if($line->qty>90) print ' : ';
2555
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2555
+						if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2556 2556
 
2557 2557
 			?>
2558 2558
 				</td>
2559 2559
 				 <td colspan="<?php echo $colspan; ?>">
2560 2560
 <?php
2561
-						if(in_array('expeditioncard', $contexts) && $action == 'create')
2561
+						if (in_array('expeditioncard', $contexts) && $action == 'create')
2562 2562
 						{
2563 2563
 							$fk_entrepot = GETPOST('entrepot_id', 'int');
2564 2564
 ?>
@@ -2585,100 +2585,100 @@  discard block
 block discarded – undo
2585 2585
 			$shipment_static = new Expedition($db);
2586 2586
 			$warehousestatic = new Entrepot($db);
2587 2587
 			$extrafieldsline = new ExtraFields($db);
2588
-			$extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2588
+			$extralabelslines = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2589 2589
 
2590 2590
 			$colspan = 4;
2591
-			if($object->origin && $object->origin_id > 0) $colspan++;
2592
-			if(! empty($conf->stock->enabled)) $colspan++;
2593
-			if(! empty($conf->productbatch->enabled)) $colspan++;
2594
-			if($object->statut == 0) $colspan++;
2595
-			if($object->statut == 0 && empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) $colspan++;
2591
+			if ($object->origin && $object->origin_id > 0) $colspan++;
2592
+			if (!empty($conf->stock->enabled)) $colspan++;
2593
+			if (!empty($conf->productbatch->enabled)) $colspan++;
2594
+			if ($object->statut == 0) $colspan++;
2595
+			if ($object->statut == 0 && empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) $colspan++;
2596 2596
 
2597
-			if($object->element == 'delivery') $colspan = 2;
2597
+			if ($object->element == 'delivery') $colspan = 2;
2598 2598
 
2599 2599
 			print '<!-- origin line id = '.$line->origin_line_id.' -->'; // id of order line
2600 2600
 
2601 2601
 			// HTML 5 data for js
2602 2602
 			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2603 2603
 			?>
2604
-			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2604
+			<tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2605 2605
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2606 2606
 					{
2607
-						if($line->qty==99) print 'background:#adadcf';
2608
-						else if($line->qty==98) print 'background:#ddddff;';
2609
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2610
-						else if($line->qty==1) print 'background:#adadcf;';
2611
-						else if($line->qty==2) print 'background:#ddddff;';
2612
-						else if($line->qty==50) print '';
2607
+						if ($line->qty == 99) print 'background:#adadcf';
2608
+						else if ($line->qty == 98) print 'background:#ddddff;';
2609
+						else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;';
2610
+						else if ($line->qty == 1) print 'background:#adadcf;';
2611
+						else if ($line->qty == 2) print 'background:#ddddff;';
2612
+						else if ($line->qty == 50) print '';
2613 2613
 						else print 'background:#eeeeff;';
2614 2614
 
2615 2615
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2616 2616
 					}
2617 2617
 					else 
2618 2618
 					{
2619
-						if($line->qty==99) print 'background:#ddffdd';
2620
-						else if($line->qty==98) print 'background:#ddddff;';
2621
-						else if($line->qty==2) print 'background:#eeeeff; ';
2622
-						else if($line->qty==50) print '';
2623
-						else print 'background:#eeffee;' ;
2619
+						if ($line->qty == 99) print 'background:#ddffdd';
2620
+						else if ($line->qty == 98) print 'background:#ddddff;';
2621
+						else if ($line->qty == 2) print 'background:#eeeeff; ';
2622
+						else if ($line->qty == 50) print '';
2623
+						else print 'background:#eeffee;';
2624 2624
 					}
2625 2625
 
2626 2626
 			?>;">
2627 2627
 
2628 2628
 			<?php
2629 2629
 			// #
2630
-			if (! empty($conf->global->MAIN_VIEW_LINE_NUMBER))
2630
+			if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER))
2631 2631
 			{
2632
-				print '<td align="center">'.($i+1).'</td>';
2632
+				print '<td align="center">'.($i + 1).'</td>';
2633 2633
 			}
2634 2634
 			?>
2635 2635
 
2636
-			<td style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
2636
+			<td style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php
2637 2637
 
2638 2638
 
2639 2639
 			if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2640 2640
 			{
2641
-				if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2641
+				if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line))
2642 2642
 				{
2643
-					echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2643
+					echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
2644 2644
 
2645 2645
 					if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2646
-					else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2646
+					else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
2647 2647
 				}
2648 2648
 			}
2649 2649
 			else
2650 2650
 			{
2651
-				if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2652
-				else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2651
+				if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal');
2652
+				else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2653 2653
 			}
2654 2654
 
2655 2655
 
2656 2656
 			// Get display styles and apply them
2657 2657
 			$titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
2658
-			$titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2659
-			$titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2658
+			$titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2659
+			$titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2660 2660
 
2661 2661
 			if (empty($line->label)) {
2662 2662
 				if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2663 2663
 				else print  $line->description;
2664 2664
 			}
2665 2665
 			else {
2666
-				if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2666
+				if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2667 2667
 					print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2668 2668
 				}
2669
-				else{
2669
+				else {
2670 2670
 					print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2671 2671
 				}
2672 2672
 			}
2673 2673
 			//if($line->qty>90) print ' : ';
2674
-			if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2674
+			if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2675 2675
 
2676 2676
 			?>
2677 2677
 				</td>
2678 2678
 				<td colspan="<?php echo $colspan; ?>">&nbsp;</td>
2679 2679
 			<?php
2680 2680
 
2681
-			if ($object->element == 'shipping' && $object->statut == 0 && ! empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2681
+			if ($object->element == 'shipping' && $object->statut == 0 && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2682 2682
 			{
2683 2683
 				print '<td class="linecoldelete nowrap" width="10">';
2684 2684
 
@@ -2687,12 +2687,12 @@  discard block
 block discarded – undo
2687 2687
 					echo '<a href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&amp;action=deleteline&amp;lineid='.$line->id.'">'.img_delete().'</a>';
2688 2688
 				}
2689 2689
 
2690
-				if(TSubtotal::isTitle($line) && ($line->fk_prev_id === null) )
2690
+				if (TSubtotal::isTitle($line) && ($line->fk_prev_id === null))
2691 2691
 				{
2692 2692
 					if ((float) DOL_VERSION >= 8.0) {
2693 2693
 						$img_delete = img_delete($langs->trans('deleteWithAllLines'), ' class="pictodelete pictodeleteallline"');
2694 2694
 					} elseif ((float) DOL_VERSION >= 3.8) {
2695
-						$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal',' class="pictodelete" ');
2695
+						$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal', ' class="pictodelete" ');
2696 2696
 					} else {
2697 2697
 						$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all@subtotal');
2698 2698
 					}
@@ -2702,7 +2702,7 @@  discard block
 block discarded – undo
2702 2702
 					/* Depuis la 8.0, les icônes "standard" utilisent FontAwesome et sont préconfigurées selon la clé de l'image
2703 2703
 					 * Impossible d'en customiser par exemple la couleur, même en utilisant img_picto() directement
2704 2704
 					 */
2705
-					if((float) DOL_VERSION >= 8.0) {
2705
+					if ((float) DOL_VERSION >= 8.0) {
2706 2706
 						?>
2707 2707
 							<script>
2708 2708
 								$(document).ready(function () {
@@ -2720,11 +2720,11 @@  discard block
 block discarded – undo
2720 2720
 			print "</tr>";
2721 2721
 
2722 2722
 			// Display lines extrafields
2723
-			if ($object->element == 'shipping' && ! empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE) && is_array($extralabelslines) && count($extralabelslines)>0) {
2723
+			if ($object->element == 'shipping' && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE) && is_array($extralabelslines) && count($extralabelslines) > 0) {
2724 2724
 				$line = new ExpeditionLigne($db);
2725 2725
 				$line->fetch_optionals($line->id);
2726 2726
 				print '<tr class="oddeven">';
2727
-				print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan),$i);
2727
+				print $line->showOptionals($extrafieldsline, 'view', array('style'=>$bc[$var], 'colspan'=>$colspan), $i);
2728 2728
 			}
2729 2729
 
2730 2730
 			return 1;
@@ -2736,20 +2736,20 @@  discard block
 block discarded – undo
2736 2736
 
2737 2737
 	
2738 2738
 	function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) {
2739
-		global $conf,$langs;
2739
+		global $conf, $langs;
2740 2740
 		 
2741 2741
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2742 2742
 		{
2743 2743
 		    
2744
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2744
+		    if ($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2745 2745
 		    {
2746 2746
 		        foreach ($object->lines as $line)
2747 2747
 		        {
2748 2748
 		            // fetch optionals attributes and labels
2749 2749
 		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2750
-		            $extrafields=new ExtraFields($this->db);
2751
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2752
-		            $line->fetch_optionals($line->id,$extralabels);
2750
+		            $extrafields = new ExtraFields($this->db);
2751
+		            $extralabels = $extrafields->fetch_name_optionals_label($object->table_element_line, true);
2752
+		            $line->fetch_optionals($line->id, $extralabels);
2753 2753
 		        }
2754 2754
 		    }
2755 2755
 		    
@@ -2849,23 +2849,23 @@  discard block
 block discarded – undo
2849 2849
 	    $ThtmlData['data-qty']          = 0; //$line->qty;
2850 2850
 	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2851 2851
 	    
2852
-	    if(TSubtotal::isTitle($line)){
2852
+	    if (TSubtotal::isTitle($line)) {
2853 2853
 	        $ThtmlData['data-issubtotal'] = 'title';
2854
-	    }elseif(TSubtotal::isSubtotal($line)){
2854
+	    }elseif (TSubtotal::isSubtotal($line)) {
2855 2855
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2856 2856
 	    }
2857
-	    else{
2857
+	    else {
2858 2858
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2859 2859
 	    }
2860 2860
 	    
2861 2861
 	    
2862 2862
 	    // Change or add data  from hooks
2863
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2863
+	    $parameters = array_replace($parameters, array('ThtmlData' => $ThtmlData));
2864 2864
 	    
2865 2865
 	    // hook 
2866
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2866
+	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2867 2867
 	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2868
-	    if ($reshook>0)
2868
+	    if ($reshook > 0)
2869 2869
 	    {
2870 2870
 	        $ThtmlData = $hookmanager->resArray;
2871 2871
 	    }
@@ -2878,14 +2878,14 @@  discard block
 block discarded – undo
2878 2878
 	function implodeHtmlData($ThtmlData = array())
2879 2879
 	{
2880 2880
 	    $data = '';
2881
-	    foreach($ThtmlData as $k => $h )
2881
+	    foreach ($ThtmlData as $k => $h)
2882 2882
 	    {
2883
-	        if(is_array($h))
2883
+	        if (is_array($h))
2884 2884
 	        {
2885 2885
 	            $h = json_encode($h);
2886 2886
 	        }
2887 2887
 	        
2888
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2888
+	        $data .= $k.'="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2889 2889
 	    }
2890 2890
 	    
2891 2891
 	    return $data;
@@ -2893,26 +2893,26 @@  discard block
 block discarded – undo
2893 2893
 	
2894 2894
 	function _ajax_block_order_js($object)
2895 2895
 	{
2896
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2896
+	    global $conf, $tagidfortablednd, $filepath, $langs;
2897 2897
 	    
2898 2898
 	    /*
2899 2899
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2900 2900
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2901 2901
 	     */
2902 2902
 	    
2903
-	    $id=$object->id;
2904
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2905
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2903
+	    $id = $object->id;
2904
+	    $nboflines = (isset($object->lines) ?count($object->lines) : 0);
2905
+	    $forcereloadpage = empty($conf->global->MAIN_FORCE_RELOAD_PAGE) ? 0 : 1;
2906 2906
 	    
2907
-	    $id=$object->id;
2908
-	    $fk_element=$object->fk_element;
2909
-	    $table_element_line=$object->table_element_line;
2910
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2911
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2912
-	    $filepath=(empty($filepath)?'':$filepath);
2907
+	    $id = $object->id;
2908
+	    $fk_element = $object->fk_element;
2909
+	    $table_element_line = $object->table_element_line;
2910
+	    $nboflines = (isset($object->lines) ?count($object->lines) : (empty($nboflines) ? 0 : $nboflines));
2911
+	    $tagidfortablednd = (empty($tagidfortablednd) ? 'tablelines' : $tagidfortablednd);
2912
+	    $filepath = (empty($filepath) ? '' : $filepath);
2913 2913
 	    
2914 2914
 	    
2915
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2915
+	    if (GETPOST('action', 'aZ09') != 'editline' && $nboflines > 1)
2916 2916
 	    {
2917 2917
 	        
2918 2918
 	        ?>
@@ -2930,7 +2930,7 @@  discard block
 block discarded – undo
2930 2930
 				moveBlockCol.disableSelection(); // prevent selection
2931 2931
 <?php if ($object->statut == 0) { ?>
2932 2932
 				// apply some graphical stuff
2933
-				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png',2);  ?>)');
2933
+				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png', 2); ?>)');
2934 2934
 				moveBlockCol.css("background-repeat","no-repeat");
2935 2935
 				moveBlockCol.css("background-position","center center");
2936 2936
 				moveBlockCol.css("cursor","move");
Please login to merge, or discard this patch.
Braces   +527 added lines, -314 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@  discard block
 block discarded – undo
45 45
 				$value = '';
46 46
 				$sql = 'SELECT content FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text WHERE rowid = '.GETPOST('rowid');
47 47
 				$resql = $this->db->query($sql);
48
-				if ($resql && ($obj = $this->db->fetch_object($resql))) $value = $obj->content;
48
+				if ($resql && ($obj = $this->db->fetch_object($resql))) {
49
+					$value = $obj->content;
50
+				}
49 51
 			}
50 52
 			
51 53
 			?>
@@ -124,8 +126,7 @@  discard block
 block discarded – undo
124 126
 			} elseif($object->element == 'invoice_supplier' )
125 127
 			{
126 128
 			    $createRight = $user->rights->fournisseur->facture->creer;
127
-			}
128
-			elseif($object->element == 'shipping')
129
+			} elseif($object->element == 'shipping')
129 130
 			{
130 131
 				$createRight = true; // No rights management for shipments
131 132
 			}
@@ -133,8 +134,11 @@  discard block
 block discarded – undo
133 134
 			if ($object->statut == 0  && $createRight) {
134 135
 			
135 136
 
136
-				if($object->element=='facture')$idvar = 'facid';
137
-				else $idvar='id';
137
+				if($object->element=='facture') {
138
+					$idvar = 'facid';
139
+				} else {
140
+					$idvar='id';
141
+				}
138 142
 				
139 143
 				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
140 144
 				{
@@ -142,10 +146,11 @@  discard block
 block discarded – undo
142 146
 					
143 147
 					if($action=='add_title_line') {
144 148
 						$title = GETPOST('title');
145
-						if(empty($title)) $title = $langs->trans('title');
149
+						if(empty($title)) {
150
+							$title = $langs->trans('title');
151
+						}
146 152
 						$qty = $level<1 ? 1 : $level ;
147
-					}
148
-					else if($action=='add_free_text') {
153
+					} else if($action=='add_free_text') {
149 154
 						$title = GETPOST('title');
150 155
 
151 156
 						if (empty($title)) {
@@ -157,29 +162,31 @@  discard block
 block discarded – undo
157 162
 								}
158 163
 							}
159 164
 						}
160
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
165
+						if(empty($title)) {
166
+							$title = $langs->trans('subtotalAddLineDescription');
167
+						}
161 168
 						$qty = 50;
162
-					}
163
-					else if($action=='add_subtitle_line') {
169
+					} else if($action=='add_subtitle_line') {
164 170
 						$title = GETPOST('title');
165
-						if(empty($title)) $title = $langs->trans('subtitle');
171
+						if(empty($title)) {
172
+							$title = $langs->trans('subtitle');
173
+						}
166 174
 						$qty = 2;
167
-					}
168
-					else if($action=='add_subtotal_line') {
175
+					} else if($action=='add_subtotal_line') {
169 176
 						$title = $langs->trans('SubSubTotal');
170 177
 						$qty = 98;
171
-					}
172
-					else {
178
+					} else {
173 179
 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
174 180
 						$qty = $level ? 100-$level : 99;
175 181
 					}
176 182
 					dol_include_once('/subtotal/class/subtotal.class.php');
177 183
 					
178
-					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
184
+					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) {
185
+						TSubtotal::addSubtotalMissing($object, $qty);
186
+					}
179 187
 					
180 188
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
181
-				}
182
-				else if($action==='ask_deleteallline') {
189
+				} else if($action==='ask_deleteallline') {
183 190
 						$form=new Form($db);
184 191
 
185 192
 						$lineid = GETPOST('lineid','integer');
@@ -202,8 +209,7 @@  discard block
 block discarded – undo
202 209
 					$this->printNewFormat($object, $conf, $langs, $idvar);
203 210
 				}
204 211
 			}
205
-		}
206
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts) || in_array('orderstoinvoicesupplier',$contexts))
212
+		} elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts) || in_array('orderstoinvoicesupplier',$contexts))
207 213
 		{
208 214
 			?>
209 215
 			<script type="text/javascript">
@@ -221,8 +227,13 @@  discard block
 block discarded – undo
221 227
      
222 228
 	function printNewFormat(&$object, &$conf, &$langs, $idvar)
223 229
 	{
224
-		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) return false;
225
-		if ($line->fk_prev_id != null && !empty($line->fk_prev_id)) return false; // Si facture de situation
230
+		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) {
231
+			return false;
232
+		}
233
+		if ($line->fk_prev_id != null && !empty($line->fk_prev_id)) {
234
+			return false;
235
+		}
236
+		// Si facture de situation
226 237
 		?>
227 238
 		 	<script type="text/javascript">
228 239
 				$(document).ready(function() {
@@ -515,8 +526,7 @@  discard block
 block discarded – undo
515 526
 				}
516 527
 				
517 528
 				
518
-			}	
519
-			else{
529
+			} else{
520 530
 				$substitutionarray['line_not_modsubtotal'] = true;
521 531
 				$substitutionarray['line_modsubtotal'] = 0;
522 532
 			}
@@ -574,8 +584,11 @@  discard block
 block discarded – undo
574 584
 		
575 585
 		$showBlockExtrafields = GETPOST('showBlockExtrafields');
576 586
 		
577
-		if($object->element=='facture') $idvar = 'facid';
578
-		else $idvar = 'id';
587
+		if($object->element=='facture') {
588
+			$idvar = 'facid';
589
+		} else {
590
+			$idvar = 'id';
591
+		}
579 592
 			
580 593
 		if ($action == 'updateligne' || $action == 'updateline')
581 594
 		{
@@ -605,8 +618,7 @@  discard block
 block discarded – undo
605 618
 				header('Location: '.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id);
606 619
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
607 620
 			}
608
-		}
609
-		else if($action === 'builddoc') {
621
+		} else if($action === 'builddoc') {
610 622
 			
611 623
 			if (
612 624
 				in_array('invoicecard',explode(':',$parameters['context']))
@@ -621,33 +633,27 @@  discard block
 block discarded – undo
621 633
 					$sessname = 'subtotal_hideInnerLines_facture';	
622 634
 					$sessname2 = 'subtotal_hidedetails_facture';
623 635
 					$sessname3 = 'subtotal_hideprices_facture';
624
-				}
625
-				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
636
+				} elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
626 637
 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
627 638
 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
628 639
 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
629
-				}
630
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
640
+				} elseif(in_array('propalcard',explode(':',$parameters['context']))) {
631 641
 					$sessname = 'subtotal_hideInnerLines_propal';
632 642
 					$sessname2 = 'subtotal_hidedetails_propal';	
633 643
 					$sessname3 = 'subtotal_hideprices_propal';
634
-				}
635
-				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
644
+				} elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
636 645
 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
637 646
 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
638 647
 				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
639
-				}
640
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
648
+				} elseif(in_array('ordercard',explode(':',$parameters['context']))) {
641 649
 					$sessname = 'subtotal_hideInnerLines_commande';
642 650
 					$sessname2 = 'subtotal_hidedetails_commande';	
643 651
 					$sessname3 = 'subtotal_hideprices_commande';
644
-				}
645
-				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
652
+				} elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
646 653
 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
647 654
 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
648 655
 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
649
-				}
650
-				else {
656
+				} else {
651 657
 					$sessname = 'subtotal_hideInnerLines_unknown';
652 658
 					$sessname2 = 'subtotal_hidedetails_unknown';
653 659
 					$sessname3 = 'subtotal_hideprices_unknown';
@@ -656,15 +662,24 @@  discard block
 block discarded – undo
656 662
 				global $hideprices;
657 663
 				
658 664
 				$hideInnerLines = (int)GETPOST('hideInnerLines');
659
-				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) $_SESSION[$sessname] = array(); // prevent old system
665
+				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) {
666
+					$_SESSION[$sessname] = array();
667
+				}
668
+				// prevent old system
660 669
 				$_SESSION[$sessname][$object->id] = $hideInnerLines;		
661 670
 				
662 671
 				$hidedetails= (int)GETPOST('hidedetails');
663
-				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) $_SESSION[$sessname2] = array(); // prevent old system
672
+				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) {
673
+					$_SESSION[$sessname2] = array();
674
+				}
675
+				// prevent old system
664 676
 				$_SESSION[$sessname2][$object->id] = $hidedetails;
665 677
 				
666 678
 				$hideprices= (int)GETPOST('hideprices');
667
-				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) $_SESSION[$sessname3] = array(); // prevent old system
679
+				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) {
680
+					$_SESSION[$sessname3] = array();
681
+				}
682
+				// prevent old system
668 683
 				$_SESSION[$sessname3][$object->id] = $hideprices;
669 684
 				
670 685
 				foreach($object->lines as &$line) {
@@ -672,8 +687,7 @@  discard block
 block discarded – undo
672 687
 					    
673 688
                         if($line->qty>=90) {
674 689
                             $line->modsubtotal_total = 1;
675
-                        }
676
-                        else{
690
+                        } else{
677 691
                             $line->modsubtotal_title = 1;
678 692
                         }
679 693
                         
@@ -682,8 +696,7 @@  discard block
 block discarded – undo
682 696
 	        	}
683 697
 	        }
684 698
 			
685
-		}
686
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
699
+		} else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
687 700
 			
688 701
 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
689 702
 			
@@ -691,7 +704,9 @@  discard block
 block discarded – undo
691 704
 				/**
692 705
 				 * @var $object Facture
693 706
 				 */
694
-				if($object->element=='facture') $object->deleteline($idLine);
707
+				if($object->element=='facture') {
708
+					$object->deleteline($idLine);
709
+				}
695 710
 				/**
696 711
 				 * @var $object Facture fournisseur
697 712
 				 */
@@ -702,18 +717,25 @@  discard block
 block discarded – undo
702 717
 				/**
703 718
 				 * @var $object Propal
704 719
 				 */
705
-				else if($object->element=='propal') $object->deleteline($idLine);
720
+				else if($object->element=='propal') {
721
+					$object->deleteline($idLine);
722
+				}
706 723
 				/**
707 724
 				 * @var $object Propal Fournisseur
708 725
 				 */
709
-				else if($object->element=='supplier_proposal') $object->deleteline($idLine);
726
+				else if($object->element=='supplier_proposal') {
727
+					$object->deleteline($idLine);
728
+				}
710 729
 				/**
711 730
 				 * @var $object Commande
712 731
 				 */
713 732
 				else if($object->element=='commande') 
714 733
 				{
715
-					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
716
-					else $object->deleteline($idLine);
734
+					if ((float) DOL_VERSION >= 5.0) {
735
+						$object->deleteline($user, $idLine);
736
+					} else {
737
+						$object->deleteline($idLine);
738
+					}
717 739
 				}
718 740
 				/**
719 741
 				 * @var $object Commande fournisseur
@@ -725,25 +747,32 @@  discard block
 block discarded – undo
725 747
 				/**
726 748
 				 * @var $object Facturerec
727 749
 				 */
728
-				else if($object->element=='facturerec') $object->deleteline($idLine);
750
+				else if($object->element=='facturerec') {
751
+					$object->deleteline($idLine);
752
+				}
729 753
 				/**
730 754
 				 * @var $object Expedition
731 755
 				 */
732
-				else if($object->element=='shipping') $object->deleteline($user, $idLine);
756
+				else if($object->element=='shipping') {
757
+					$object->deleteline($user, $idLine);
758
+				}
733 759
 			}
734 760
 			
735 761
 			header('location:?id='.$object->id);
736 762
 			exit;
737 763
 			
738
-		}
739
-		else if ($action == 'duplicate')
764
+		} else if ($action == 'duplicate')
740 765
 		{
741 766
 			$lineid = GETPOST('lineid', 'int');
742 767
 			$nbDuplicate = TSubtotal::duplicateLines($object, $lineid, true);
743 768
 			
744
-			if ($nbDuplicate > 0) setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
745
-			elseif ($nbDuplicate == 0) setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
746
-			else setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
769
+			if ($nbDuplicate > 0) {
770
+				setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
771
+			} elseif ($nbDuplicate == 0) {
772
+				setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
773
+			} else {
774
+				setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
775
+			}
747 776
 			
748 777
 			header('Location: ?id='.$object->id);
749 778
 			exit;
@@ -761,21 +790,26 @@  discard block
 block discarded – undo
761 790
 		global $conf;
762 791
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && !empty($object->table_element_line) && in_array($object->element, array('commande', 'facture', 'propal')))
763 792
 		{
764
-			if ($object->element == 'commande')
765
-				$obj = new OrderLine($object->db);
766
-			if ($object->element == 'propal')
767
-				$obj = new PropaleLigne($object->db);
768
-			if ($object->element == 'facture')
769
-				$obj = new FactureLigne($object->db);
793
+			if ($object->element == 'commande') {
794
+							$obj = new OrderLine($object->db);
795
+			}
796
+			if ($object->element == 'propal') {
797
+							$obj = new PropaleLigne($object->db);
798
+			}
799
+			if ($object->element == 'facture') {
800
+							$obj = new FactureLigne($object->db);
801
+			}
770 802
 			if (!empty($parameters['fk_element']))
771 803
 			{
772 804
 				
773 805
 				if($obj->fetch($parameters['fk_element'])){
774 806
 					$obj->id= $obj->rowid;
775
-					if (empty($obj->array_options))
776
-						$obj->fetch_optionals();
777
-					if (!empty($obj->array_options['options_subtotal_nc']))
778
-						return 1;
807
+					if (empty($obj->array_options)) {
808
+											$obj->fetch_optionals();
809
+					}
810
+					if (!empty($obj->array_options['options_subtotal_nc'])) {
811
+											return 1;
812
+					}
779 813
 				}
780 814
 			}
781 815
 		}
@@ -847,27 +881,33 @@  discard block
 block discarded – undo
847 881
 		$TTotal_tva = array();
848 882
 		
849 883
 		$sign=1;
850
-		if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
884
+		if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
885
+			$sign=-1;
886
+		}
851 887
 		
852
-		if (GETPOST('action') == 'builddoc') $builddoc = true;
853
-		else $builddoc = false;
888
+		if (GETPOST('action') == 'builddoc') {
889
+			$builddoc = true;
890
+		} else {
891
+			$builddoc = false;
892
+		}
854 893
 		
855 894
 		dol_include_once('/subtotal/class/subtotal.class.php');
856 895
 		foreach($object->lines as $l) {
857 896
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
858 897
 			if($l->rang>=$rang) {
859 898
 				//echo 'return!<br>';
860
-				if (!$return_all) return $total;
861
-				else return array($total, $total_tva, $total_ttc, $TTotal_tva);
862
-			}
863
-			else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
899
+				if (!$return_all) {
900
+					return $total;
901
+				} else {
902
+					return array($total, $total_tva, $total_ttc, $TTotal_tva);
903
+				}
904
+			} else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
864 905
 		  	{
865 906
 				$total = 0;
866 907
 				$total_tva = 0;
867 908
 				$total_ttc = 0;
868 909
 				$TTotal_tva = array();
869
-			}
870
-			elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
910
+			} elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
871 911
 				
872 912
 				// TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF
873 913
 				if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION)
@@ -889,8 +929,7 @@  discard block
 block discarded – undo
889 929
 						$TTotal_tva[$l->tva_tx] += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
890 930
 						$total_ttc += $sign * ($l->total_tva / ($l->total_ttc / 100)) * $progress;
891 931
 					}
892
-				}
893
-				else
932
+				} else
894 933
 				{
895 934
 					$total += $l->total_ht;
896 935
 					$total_tva += $l->total_tva;
@@ -900,8 +939,11 @@  discard block
 block discarded – undo
900 939
 			}
901 940
 			
902 941
 		}
903
-		if (!$return_all) return $total;
904
-		else return array($total, $total_tva, $total_ttc, $TTotal_tva);
942
+		if (!$return_all) {
943
+			return $total;
944
+		} else {
945
+			return array($total, $total_tva, $total_ttc, $TTotal_tva);
946
+		}
905 947
 	}
906 948
 
907 949
 	/**
@@ -948,15 +990,18 @@  discard block
 block discarded – undo
948 990
 		}
949 991
 		
950 992
 			
951
-		if($line->qty==99)
952
-			$pdf->SetFillColor(220,220,220);
953
-		elseif ($line->qty==98)
954
-			$pdf->SetFillColor(230,230,230);
955
-		else
956
-			$pdf->SetFillColor(240,240,240);
993
+		if($line->qty==99) {
994
+					$pdf->SetFillColor(220,220,220);
995
+		} elseif ($line->qty==98) {
996
+					$pdf->SetFillColor(230,230,230);
997
+		} else {
998
+					$pdf->SetFillColor(240,240,240);
999
+		}
957 1000
 		
958 1001
 		$style = 'B';
959
-		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
1002
+		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) {
1003
+			$style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
1004
+		}
960 1005
 		
961 1006
 		$pdf->SetFont('', $style, 9);
962 1007
 		
@@ -998,8 +1043,7 @@  discard block
 block discarded – undo
998 1043
 //					$line->total_tva
999 1044
 //					$line->total
1000 1045
 //					$line->total_ttc
1001
-				}
1002
-				else
1046
+				} else
1003 1047
 				{
1004 1048
 					//					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
1005 1049
 					
@@ -1009,17 +1053,22 @@  discard block
 block discarded – undo
1009 1053
 
1010 1054
                     $line->total_ht = $TInfo[0];
1011 1055
 					$line->total = $TInfo[0];
1012
-					if (!TSubtotal::isModSubtotalLine($line)) $line->total_tva = $TInfo[1];
1056
+					if (!TSubtotal::isModSubtotalLine($line)) {
1057
+						$line->total_tva = $TInfo[1];
1058
+					}
1013 1059
 					$line->total_ttc = $TInfo[2];
1014 1060
 				}
1015 1061
 			}
1016 1062
 
1017 1063
 			$pdf->SetXY($pdf->postotalht, $posy);
1018
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1064
+			if($set_pagebreak_margin) {
1065
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1066
+			}
1019 1067
 			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
1020
-		}
1021
-		else{
1022
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1068
+		} else{
1069
+			if($set_pagebreak_margin) {
1070
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1071
+			}
1023 1072
 		}
1024 1073
 		
1025 1074
 		$posy = $posy + $cell_height;
@@ -1051,25 +1100,40 @@  discard block
 block discarded – undo
1051 1100
 		
1052 1101
  
1053 1102
 		$style = ($line->qty==1) ? 'BU' : 'BUI';
1054
-		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
1103
+		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) {
1104
+			$style = $conf->global->SUBTOTAL_TITLE_STYLE;
1105
+		}
1055 1106
 		
1056 1107
 		if($hideInnerLines) {
1057
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
1058
-			else 
1108
+			if($line->qty==1) {
1109
+				$pdf->SetFont('', $style, 9);
1110
+			} else 
1059 1111
 			{
1060
-				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
1112
+				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) {
1113
+					$style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
1114
+				}
1061 1115
 				$pdf->SetFont('', $style, 9);
1062 1116
 			}
1063
-		}
1064
-		else {
1117
+		} else {
1065 1118
 
1066
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
1067
-			else $pdf->SetFont('', $style, 9);
1119
+			if($line->qty==1) {
1120
+				$pdf->SetFont('', $style, 9);
1121
+			}
1122
+			//TODO if super utile
1123
+			else {
1124
+				$pdf->SetFont('', $style, 9);
1125
+			}
1068 1126
 			
1069 1127
 		}
1070 1128
 		
1071
-		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
1072
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
1129
+		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) {
1130
+			$pdf->MultiCell($w, $h, $label, 0, 'L');
1131
+		}
1132
+		// Pas de HTML dans la chaine
1133
+		else {
1134
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true);
1135
+		}
1136
+		// et maintenant avec du HTML
1073 1137
 		
1074 1138
 		if($description && !$hidedesc) {
1075 1139
 			$posy = $pdf->GetY();
@@ -1093,8 +1157,7 @@  discard block
 block discarded – undo
1093 1157
 		
1094 1158
 		if(is_array($parameters)) {
1095 1159
 			$i = & $parameters['i'];	
1096
-		}
1097
-		else {
1160
+		} else {
1098 1161
 			$i = (int)$parameters;
1099 1162
 		}
1100 1163
 
@@ -1124,17 +1187,14 @@  discard block
 block discarded – undo
1124 1187
 			
1125 1188
 			if((float)DOL_VERSION<=3.6) {
1126 1189
 				return '';
1127
-			}
1128
-			else if((float)DOL_VERSION>=3.8) {
1190
+			} else if((float)DOL_VERSION>=3.8) {
1129 1191
 				return 1;
1130 1192
 			}
1131 1193
 			
1132
-		}
1133
-		elseif(!empty($hideprices)) {
1194
+		} elseif(!empty($hideprices)) {
1134 1195
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1135 1196
 			return 1;
1136
-		}
1137
-		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1197
+		} elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1138 1198
 		{
1139 1199
 			$hideInnerLines = (int)GETPOST('hideInnerLines');
1140 1200
 			$hidedetails = (int)GETPOST('hidedetails');
@@ -1144,12 +1204,20 @@  discard block
 block discarded – undo
1144 1204
 			}
1145 1205
 		}
1146 1206
 		
1147
-		if(is_array($parameters)) $i = & $parameters['i'];
1148
-		else $i = (int)$parameters;
1207
+		if(is_array($parameters)) {
1208
+			$i = & $parameters['i'];
1209
+		} else {
1210
+			$i = (int)$parameters;
1211
+		}
1149 1212
 
1150
-		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)
1213
+		if (empty($object->lines[$i])) {
1214
+			return 0;
1215
+		}
1216
+		// 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)
1151 1217
 		
1152
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1218
+		if(empty($object->lines[$i]->array_options)) {
1219
+			$object->lines[$i]->fetch_optionals();
1220
+		}
1153 1221
 
1154 1222
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1155 1223
 		{
@@ -1166,8 +1234,11 @@  discard block
 block discarded – undo
1166 1234
 	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1167 1235
 	    global $conf, $hideprices, $hookmanager;
1168 1236
 		
1169
-		if(is_array($parameters)) $i = & $parameters['i'];
1170
-		else $i = (int)$parameters;
1237
+		if(is_array($parameters)) {
1238
+			$i = & $parameters['i'];
1239
+		} else {
1240
+			$i = (int)$parameters;
1241
+		}
1171 1242
 			
1172 1243
 		if($this->isModSubtotalLine($parameters,$object) ){
1173 1244
 			
@@ -1175,13 +1246,11 @@  discard block
 block discarded – undo
1175 1246
 			
1176 1247
 			if((float)DOL_VERSION<=3.6) {
1177 1248
 				return '';
1178
-			}
1179
-			else if((float)DOL_VERSION>=3.8) {
1249
+			} else if((float)DOL_VERSION>=3.8) {
1180 1250
 				return 1;
1181 1251
 			}
1182 1252
 			
1183
-		}
1184
-		elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1253
+		} elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1185 1254
 		{
1186 1255
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1187 1256
 			{
@@ -1253,12 +1322,10 @@  discard block
 block discarded – undo
1253 1322
 			$this->error = $hookmanager->error;
1254 1323
 			$this->errors = $hookmanager->errors;
1255 1324
 			return -1;
1256
-		}
1257
-		elseif (empty($reshook))
1325
+		} elseif (empty($reshook))
1258 1326
 		{
1259 1327
 			$this->resprints .= $hookmanager->resprints;
1260
-		}
1261
-		else
1328
+		} else
1262 1329
 		{
1263 1330
 			$this->resprints = $hookmanager->resprints;
1264 1331
 
@@ -1281,14 +1348,16 @@  discard block
 block discarded – undo
1281 1348
 		
1282 1349
 			if((float)DOL_VERSION<=3.6) {
1283 1350
 				return '';
1284
-			}
1285
-			else if((float)DOL_VERSION>=3.8) {
1351
+			} else if((float)DOL_VERSION>=3.8) {
1286 1352
 				return 1;
1287 1353
 			}
1288 1354
 		}
1289 1355
 		
1290
-		if(is_array($parameters)) $i = & $parameters['i'];
1291
-		else $i = (int)$parameters;
1356
+		if(is_array($parameters)) {
1357
+			$i = & $parameters['i'];
1358
+		} else {
1359
+			$i = (int)$parameters;
1360
+		}
1292 1361
 		
1293 1362
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1294 1363
 		{
@@ -1310,14 +1379,16 @@  discard block
 block discarded – undo
1310 1379
 		
1311 1380
 			if((float)DOL_VERSION<=3.6) {
1312 1381
 				return '';
1313
-			}
1314
-			else if((float)DOL_VERSION>=3.8) {
1382
+			} else if((float)DOL_VERSION>=3.8) {
1315 1383
 				return 1;
1316 1384
 			}
1317 1385
 		}
1318 1386
 		
1319
-		if(is_array($parameters)) $i = & $parameters['i'];
1320
-		else $i = (int)$parameters;
1387
+		if(is_array($parameters)) {
1388
+			$i = & $parameters['i'];
1389
+		} else {
1390
+			$i = (int)$parameters;
1391
+		}
1321 1392
 			
1322 1393
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1323 1394
 		{
@@ -1334,8 +1405,11 @@  discard block
 block discarded – undo
1334 1405
 	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1335 1406
 	    global $conf,$hideprices,$hookmanager;
1336 1407
 
1337
-		if(is_array($parameters)) $i = & $parameters['i'];
1338
-		else $i = (int)$parameters;
1408
+		if(is_array($parameters)) {
1409
+			$i = & $parameters['i'];
1410
+		} else {
1411
+			$i = (int)$parameters;
1412
+		}
1339 1413
 
1340 1414
 		if($this->isModSubtotalLine($parameters,$object) ) {
1341 1415
 			$this->resprints = ' ';
@@ -1346,7 +1420,9 @@  discard block
 block discarded – undo
1346 1420
             if(TSubtotal::isSubtotal($line)) {
1347 1421
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1348 1422
 
1349
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1423
+                if(is_object($parentTitle) && empty($parentTitle->array_options)) {
1424
+                	$parentTitle->fetch_optionals();
1425
+                }
1350 1426
                 if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1351 1427
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1352 1428
                     $this->resprints = price($TTotal['total_unit_subprice']);
@@ -1355,8 +1431,7 @@  discard block
 block discarded – undo
1355 1431
 		
1356 1432
 			if((float)DOL_VERSION<=3.6) {
1357 1433
 				return '';
1358
-			}
1359
-			else if((float)DOL_VERSION>=3.8) {
1434
+			} else if((float)DOL_VERSION>=3.8) {
1360 1435
 				return 1;
1361 1436
 			}
1362 1437
 		}
@@ -1401,8 +1476,11 @@  discard block
 block discarded – undo
1401 1476
 	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1402 1477
 	    global $conf,$hideprices,$hookmanager;
1403 1478
 
1404
-        if(is_array($parameters)) $i = & $parameters['i'];
1405
-        else $i = (int) $parameters;
1479
+        if(is_array($parameters)) {
1480
+        	$i = & $parameters['i'];
1481
+        } else {
1482
+        	$i = (int) $parameters;
1483
+        }
1406 1484
 
1407 1485
 		if($this->isModSubtotalLine($parameters,$object) ) {
1408 1486
 			$this->resprints = ' ';
@@ -1413,7 +1491,9 @@  discard block
 block discarded – undo
1413 1491
             if(TSubtotal::isSubtotal($line)) {
1414 1492
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1415 1493
 
1416
-                if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1494
+                if(empty($parentTitle->array_options)) {
1495
+                	$parentTitle->fetch_optionals();
1496
+                }
1417 1497
                 if(! empty($parentTitle->array_options['options_show_reduc'])) {
1418 1498
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1419 1499
                     $this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
@@ -1422,12 +1502,10 @@  discard block
 block discarded – undo
1422 1502
 		
1423 1503
 			if((float)DOL_VERSION<=3.6) {
1424 1504
 				return '';
1425
-			}
1426
-			else if((float)DOL_VERSION>=3.8) {
1505
+			} else if((float)DOL_VERSION>=3.8) {
1427 1506
 				return 1;
1428 1507
 			}
1429
-		}
1430
-		elseif (!empty($hideprices)
1508
+		} elseif (!empty($hideprices)
1431 1509
 		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1432 1510
 		        )
1433 1511
 		    {
@@ -1448,14 +1526,16 @@  discard block
 block discarded – undo
1448 1526
 			$this->resprints = ' ';
1449 1527
 			if((float)DOL_VERSION<=3.6) {
1450 1528
 				return '';
1451
-			}
1452
-			else if((float)DOL_VERSION>=3.8) {
1529
+			} else if((float)DOL_VERSION>=3.8) {
1453 1530
 				return 1;
1454 1531
 			}
1455 1532
 		}
1456 1533
 		
1457
-		if(is_array($parameters)) $i = & $parameters['i'];
1458
-		else $i = (int)$parameters;
1534
+		if(is_array($parameters)) {
1535
+			$i = & $parameters['i'];
1536
+		} else {
1537
+			$i = (int)$parameters;
1538
+		}
1459 1539
 			
1460 1540
 		if (!empty($hideprices)
1461 1541
 				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
@@ -1479,16 +1559,21 @@  discard block
 block discarded – undo
1479 1559
 			
1480 1560
 			if((float)DOL_VERSION<=3.6) {
1481 1561
 				return '';
1482
-			}
1483
-			else if((float)DOL_VERSION>=3.8) {
1562
+			} else if((float)DOL_VERSION>=3.8) {
1484 1563
 				return 1;
1485 1564
 			}
1486 1565
 		}
1487 1566
 		
1488
-		if(is_array($parameters)) $i = & $parameters['i'];
1489
-		else $i = (int)$parameters;
1567
+		if(is_array($parameters)) {
1568
+			$i = & $parameters['i'];
1569
+		} else {
1570
+			$i = (int)$parameters;
1571
+		}
1490 1572
 		
1491
-		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)
1573
+		if (empty($object->lines[$i])) {
1574
+			return 0;
1575
+		}
1576
+		// 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)
1492 1577
 
1493 1578
 		$object->lines[$i]->fetch_optionals();
1494 1579
 		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
@@ -1534,14 +1619,16 @@  discard block
 block discarded – undo
1534 1619
 			$this->resprints = ' ';
1535 1620
 			if((float)DOL_VERSION<=3.6) {
1536 1621
 				return '';
1537
-			}
1538
-			else if((float)DOL_VERSION>=3.8) {
1622
+			} else if((float)DOL_VERSION>=3.8) {
1539 1623
 				return 1;
1540 1624
 			}
1541 1625
 		}
1542 1626
 		
1543
-		if(is_array($parameters)) $i = & $parameters['i'];
1544
-		else $i = (int)$parameters;
1627
+		if(is_array($parameters)) {
1628
+			$i = & $parameters['i'];
1629
+		} else {
1630
+			$i = (int)$parameters;
1631
+		}
1545 1632
 			
1546 1633
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1547 1634
 		{
@@ -1571,7 +1658,9 @@  discard block
 block discarded – undo
1571 1658
 				}
1572 1659
 			}
1573 1660
 			
1574
-			if (!empty($TLineTitle)) $TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1661
+			if (!empty($TLineTitle)) {
1662
+				$TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1663
+			}
1575 1664
 		}
1576 1665
 		
1577 1666
 	}
@@ -1585,8 +1674,12 @@  discard block
 block discarded – undo
1585 1674
 		$j=0;
1586 1675
 		foreach ($TLineTitle as $k => &$line)
1587 1676
 		{
1588
-			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
1589
-			if (!empty($line_reference) && $line->qty <= $line_reference->qty) break;
1677
+			if (!empty($line_reference) && $line->rang <= $line_reference->rang) {
1678
+				continue;
1679
+			}
1680
+			if (!empty($line_reference) && $line->qty <= $line_reference->qty) {
1681
+				break;
1682
+			}
1590 1683
 			
1591 1684
 			if ($line->qty == $level)
1592 1685
 			{
@@ -1620,7 +1713,9 @@  discard block
 block discarded – undo
1620 1713
 		
1621 1714
 		$hidedetails = (int)GETPOST('hidedetails');
1622 1715
 		
1623
-		if(empty($hidedetails)) return false;
1716
+		if(empty($hidedetails)) {
1717
+			return false;
1718
+		}
1624 1719
 		
1625 1720
 		// TODO can't add VAT to document without lines... :-/
1626 1721
 		
@@ -1648,7 +1743,9 @@  discard block
 block discarded – undo
1648 1743
         foreach($object->lines as $k => &$l) {
1649 1744
             if(TSubtotal::isSubtotal($l)) {
1650 1745
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1651
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1746
+                if(is_object($parentTitle) && empty($parentTitle->array_options)) {
1747
+                	$parentTitle->fetch_optionals();
1748
+                }
1652 1749
                 if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_reduc'])) {
1653 1750
                     $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1654 1751
                 }
@@ -1692,7 +1789,9 @@  discard block
 block discarded – undo
1692 1789
 						
1693 1790
 						$TInfo = $this->getTotalLineFromObject($object, $line, '', 1);
1694 1791
 
1695
-						if (TSubtotal::getNiveau($line) == 1) $line->TTotal_tva = $TInfo[3];
1792
+						if (TSubtotal::getNiveau($line) == 1) {
1793
+							$line->TTotal_tva = $TInfo[3];
1794
+						}
1696 1795
 						$line->total_ht = $TInfo[0];
1697 1796
 						$line->total_tva = $TInfo[1];
1698 1797
 						$line->total = $line->total_ht;
@@ -1756,8 +1855,7 @@  discard block
 block discarded – undo
1756 1855
 				    }
1757 1856
 				    
1758 1857
 					
1759
-				}
1760
-				elseif ($hidedetails)
1858
+				} elseif ($hidedetails)
1761 1859
 				{
1762 1860
 					$TLines[] = $line; //Cas où je cache uniquement les prix des produits	
1763 1861
 				}
@@ -1828,13 +1926,17 @@  discard block
 block discarded – undo
1828 1926
 				
1829 1927
 				if(!empty($hideprices)) {
1830 1928
 					foreach($object->lines as &$line) {
1831
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1929
+						if($line->fk_product_type!=9) {
1930
+							$line->fk_parent_line = -1;
1931
+						}
1832 1932
 					}
1833 1933
 				}
1834 1934
 			
1835 1935
 				$line = &$object->lines[$i];
1836 1936
 
1837
-				if($object->element == 'delivery' && ! empty($object->commande->expeditions[$line->fk_origin_line])) unset($object->commande->expeditions[$line->fk_origin_line]);
1937
+				if($object->element == 'delivery' && ! empty($object->commande->expeditions[$line->fk_origin_line])) {
1938
+					unset($object->commande->expeditions[$line->fk_origin_line]);
1939
+				}
1838 1940
 
1839 1941
 				if($line->info_bits>0) { // PAGE BREAK
1840 1942
 					$pdf->addPage();
@@ -1850,7 +1952,9 @@  discard block
 block discarded – undo
1850 1952
 				}
1851 1953
 
1852 1954
 				if($line->qty>90) {
1853
-					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1955
+					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) {
1956
+						$label .= ' '.$this->getTitle($object, $line);
1957
+					}
1854 1958
 					
1855 1959
 					$pageBefore = $pdf->getPage();
1856 1960
 					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
@@ -1888,8 +1992,7 @@  discard block
 block discarded – undo
1888 1992
 				
1889 1993
 					$posy = $pdf->GetY();
1890 1994
 					return 1;
1891
-				}	
1892
-				else if ($line->qty < 10) {
1995
+				} else if ($line->qty < 10) {
1893 1996
 					$pageBefore = $pdf->getPage();
1894 1997
 
1895 1998
 					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
@@ -1919,8 +2022,7 @@  discard block
 block discarded – undo
1919 2022
 //	if($line->rowid==47) exit;
1920 2023
 			
1921 2024
 			return 0;
1922
-		}
1923
-		elseif (empty($object->lines[$parameters['i']]))
2025
+		} elseif (empty($object->lines[$parameters['i']]))
1924 2026
 		{
1925 2027
 			$this->resprints = -1;
1926 2028
 		}
@@ -1953,7 +2055,9 @@  discard block
 block discarded – undo
1953 2055
 		
1954 2056
 		foreach ($object->lines as $line)
1955 2057
 		{
1956
-			if ($line->id == $currentLine->id) break;
2058
+			if ($line->id == $currentLine->id) {
2059
+				break;
2060
+			}
1957 2061
 			
1958 2062
 			$qty_search = 100 - $currentLine->qty;
1959 2063
 			
@@ -1984,7 +2088,9 @@  discard block
 block discarded – undo
1984 2088
 		$var = &$parameters['var'];
1985 2089
 
1986 2090
 		$contexts = explode(':',$parameters['context']);
1987
-		if($parameters['currentcontext'] === 'paiementcard') return 0;
2091
+		if($parameters['currentcontext'] === 'paiementcard') {
2092
+			return 0;
2093
+		}
1988 2094
 		$originline = null;
1989 2095
 
1990 2096
 		$createRight = $user->rights->{$object->element}->creer;
@@ -1992,22 +2098,18 @@  discard block
 block discarded – undo
1992 2098
 		{
1993 2099
 			$object->statut = 0; // hack for facture rec
1994 2100
 			$createRight = $user->rights->facture->creer;
1995
-		}
1996
-		elseif($object->element == 'order_supplier' )
2101
+		} elseif($object->element == 'order_supplier' )
1997 2102
 		{
1998 2103
 		    $createRight = $user->rights->fournisseur->commande->creer;
1999
-		}
2000
-		elseif($object->element == 'invoice_supplier' )
2104
+		} elseif($object->element == 'invoice_supplier' )
2001 2105
 		{
2002 2106
 		    $createRight = $user->rights->fournisseur->facture->creer;
2003
-		}
2004
-		elseif($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
2107
+		} elseif($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
2005 2108
 		{
2006 2109
 			// H4cK 4n0nYm0u$-style : $line n'est pas un objet instancié mais provient d'un fetch_object d'une requête SQL
2007 2110
 			$line->id = $line->rowid;
2008 2111
 			$line->product_type = $line->type;
2009
-		}
2010
-		elseif($object->element == 'shipping' || $object->element == 'delivery')
2112
+		} elseif($object->element == 'shipping' || $object->element == 'delivery')
2011 2113
 		{
2012 2114
 			if(empty($line->origin_line_id) && ! empty($line->fk_origin_line))
2013 2115
 			{
@@ -2027,8 +2129,11 @@  discard block
 block discarded – undo
2027 2129
 
2028 2130
 			$line = $originline;
2029 2131
 		}
2030
- 		if($object->element=='facture')$idvar = 'facid';
2031
-        else $idvar='id';
2132
+ 		if($object->element=='facture') {
2133
+ 			$idvar = 'facid';
2134
+ 		} else {
2135
+        	$idvar='id';
2136
+        }
2032 2137
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
2033 2138
 			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE) && $object->element !== 'invoice_supplier')
2034 2139
             {
@@ -2046,8 +2151,7 @@  discard block
 block discarded – undo
2046 2151
 
2047 2152
             }
2048 2153
 			return 0;
2049
-		}
2050
-		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)) 
2154
+		} 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)) 
2051 2155
         {
2052 2156
 
2053 2157
 
@@ -2075,22 +2179,44 @@  discard block
 block discarded – undo
2075 2179
 				<?php
2076 2180
 			}
2077 2181
 			
2078
-			if(empty($line->description)) $line->description = $line->desc;
2182
+			if(empty($line->description)) {
2183
+				$line->description = $line->desc;
2184
+			}
2079 2185
 			
2080 2186
 			$colspan = 5;
2081
-			if($object->element == 'facturerec' ) $colspan = 3;
2082
-			if($object->element == 'order_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
2083
-			if($object->element == 'invoice_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7;
2084
-			if($object->element == 'supplier_proposal') (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2187
+			if($object->element == 'facturerec' ) {
2188
+				$colspan = 3;
2189
+			}
2190
+			if($object->element == 'order_supplier') {
2191
+				(float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
2192
+			}
2193
+			if($object->element == 'invoice_supplier') {
2194
+				(float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7;
2195
+			}
2196
+			if($object->element == 'supplier_proposal') {
2197
+				(float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2198
+			}
2085 2199
 			if(!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
2086 2200
 				$colspan++; // Colonne PU Devise
2087 2201
 			}
2088
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
2089
-			if(!empty($conf->margin->enabled)) $colspan++;
2090
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
2091
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
2092
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
2093
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
2202
+			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) {
2203
+				$colspan++;
2204
+			}
2205
+			if(!empty($conf->margin->enabled)) {
2206
+				$colspan++;
2207
+			}
2208
+			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) {
2209
+				$colspan++;
2210
+			}
2211
+			if(!empty($conf->global->DISPLAY_MARK_RATES)) {
2212
+				$colspan++;
2213
+			}
2214
+			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) {
2215
+				$colspan++;
2216
+			}
2217
+			if(!empty($conf->global->PRODUCT_USE_UNITS)) {
2218
+				$colspan++;
2219
+			}
2094 2220
 					
2095 2221
 			/* Titre */
2096 2222
 			//var_dump($line);
@@ -2103,23 +2229,36 @@  discard block
 block discarded – undo
2103 2229
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2104 2230
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2105 2231
 					{
2106
-						if($line->qty==99) print 'background:#adadcf';
2107
-						else if($line->qty==98) print 'background:#ddddff;';
2108
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2109
-						else if($line->qty==1) print 'background:#adadcf;';
2110
-						else if($line->qty==2) print 'background:#ddddff;';
2111
-						else if($line->qty==50) print '';
2112
-						else print 'background:#eeeeff;';
2232
+						if($line->qty==99) {
2233
+							print 'background:#adadcf';
2234
+						} else if($line->qty==98) {
2235
+							print 'background:#ddddff;';
2236
+						} else if($line->qty<=97 && $line->qty>=91) {
2237
+							print 'background:#eeeeff;';
2238
+						} else if($line->qty==1) {
2239
+							print 'background:#adadcf;';
2240
+						} else if($line->qty==2) {
2241
+							print 'background:#ddddff;';
2242
+						} else if($line->qty==50) {
2243
+							print '';
2244
+						} else {
2245
+							print 'background:#eeeeff;';
2246
+						}
2113 2247
 
2114 2248
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2115
-					}
2116
-					else 
2249
+					} else 
2117 2250
 					{
2118
-						if($line->qty==99) print 'background:#ddffdd';
2119
-						else if($line->qty==98) print 'background:#ddddff;';
2120
-						else if($line->qty==2) print 'background:#eeeeff; ';
2121
-						else if($line->qty==50) print '';
2122
-						else print 'background:#eeffee;' ;
2251
+						if($line->qty==99) {
2252
+							print 'background:#ddffdd';
2253
+						} else if($line->qty==98) {
2254
+							print 'background:#ddddff;';
2255
+						} else if($line->qty==2) {
2256
+							print 'background:#eeeeff; ';
2257
+						} else if($line->qty==50) {
2258
+							print '';
2259
+						} else {
2260
+							print 'background:#eeffee;' ;
2261
+						}
2123 2262
 					}
2124 2263
 
2125 2264
 			?>;">
@@ -2146,13 +2285,11 @@  discard block
 block discarded – undo
2146 2285
 							$qty_displayed = $line->qty;
2147 2286
 							print img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
2148 2287
 							
2149
-						}
2150
-						else if (TSubtotal::isSubtotal($line))
2288
+						} else if (TSubtotal::isSubtotal($line))
2151 2289
 						{
2152 2290
 							$qty_displayed = 100 - $line->qty;
2153 2291
 							print img_picto('', 'subsubtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
2154
-						}
2155
-						else
2292
+						} else
2156 2293
 						{
2157 2294
 							$isFreeText = true;
2158 2295
 						}
@@ -2173,9 +2310,13 @@  discard block
 block discarded – undo
2173 2310
 						}
2174 2311
 
2175 2312
 						$readonlyForSituation = '';
2176
-						if (!empty($line->fk_prev_id) && $line->fk_prev_id != null) $readonlyForSituation = 'readonly';
2313
+						if (!empty($line->fk_prev_id) && $line->fk_prev_id != null) {
2314
+							$readonlyForSituation = 'readonly';
2315
+						}
2177 2316
 						
2178
-						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2317
+						if (!$isFreeText) {
2318
+							echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2319
+						}
2179 2320
 						
2180 2321
 						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
2181 2322
 						{
@@ -2183,8 +2324,12 @@  discard block
 block discarded – undo
2183 2324
 							for ($j=1; $j<10; $j++)
2184 2325
 							{
2185 2326
 								if (!empty($readonlyForSituation)) {
2186
-									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2187
-								} else $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2327
+									if ($qty_displayed == $j) {
2328
+										$select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2329
+									}
2330
+								} else {
2331
+									$select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2332
+								}
2188 2333
 							}
2189 2334
 							$select .= '</select>&nbsp;';
2190 2335
 
@@ -2204,7 +2349,9 @@  discard block
 block discarded – undo
2204 2349
                             echo '<div>';
2205 2350
                             echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2206 2351
                             echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2207
-                            if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2352
+                            if (empty($readonlyForSituation)) {
2353
+                            	echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2354
+                            }
2208 2355
                             echo '</select>';
2209 2356
                             echo '</div>';
2210 2357
 
@@ -2223,8 +2370,9 @@  discard block
 block discarded – undo
2223 2370
                             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;';
2224 2371
                             echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2225 2372
                             echo '</div>';
2373
+                        } else if ($isFreeText) {
2374
+                        	echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2226 2375
                         }
2227
-                        else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2228 2376
 						echo '</div>';
2229 2377
 
2230 2378
 						if($line->qty<10) {
@@ -2244,8 +2392,7 @@  discard block
 block discarded – undo
2244 2392
 							$doleditor->Create();
2245 2393
 						}
2246 2394
 						
2247
-					}
2248
-					else {
2395
+					} else {
2249 2396
 
2250 2397
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2251 2398
 						 {
@@ -2253,14 +2400,19 @@  discard block
 block discarded – undo
2253 2400
 							{
2254 2401
 								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2255 2402
 								
2256
-								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2257
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2403
+								if (TSubtotal::isTitle($line)) {
2404
+									print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2405
+								} else {
2406
+									print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2407
+								}
2258 2408
 							}
2259
-						 }
2260
-						 else 
2409
+						 } else 
2261 2410
 						 {
2262
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2263
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2411
+							if($line->qty<=1) {
2412
+								print img_picto('', 'subtotal@subtotal');
2413
+							} else if($line->qty==2) {
2414
+								print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2415
+							}
2264 2416
 						 }
2265 2417
 						 
2266 2418
 						 
@@ -2270,21 +2422,26 @@  discard block
 block discarded – undo
2270 2422
 						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2271 2423
 						 
2272 2424
 						 if (empty($line->label)) {
2273
-							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2274
-							else print  $line->description;
2275
-						 } 
2276
-						 else {
2425
+							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2426
+								print  $line->description.' '.$this->getTitle($object, $line);
2427
+							} else {
2428
+								print  $line->description;
2429
+							}
2430
+						 } else {
2277 2431
 
2278 2432
 							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2279 2433
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2280
-							}
2281
-							else{
2434
+							} else{
2282 2435
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
2283 2436
 							}
2284 2437
 
2285 2438
 						 } 
2286
-						if($line->qty>90) print ' : ';
2287
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2439
+						if($line->qty>90) {
2440
+							print ' : ';
2441
+						}
2442
+						if($line->info_bits > 0) {
2443
+							echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2444
+						}
2288 2445
 
2289 2446
 						 
2290 2447
 
@@ -2327,11 +2484,12 @@  discard block
 block discarded – undo
2327 2484
 						</script>
2328 2485
 						<?php
2329 2486
 						
2330
-					}
2331
-					else{
2487
+					} else{
2332 2488
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2333 2489
 						{
2334
-							if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2490
+							if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) {
2491
+								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2492
+							}
2335 2493
 						}
2336 2494
 
2337 2495
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
@@ -2421,7 +2579,9 @@  discard block
 block discarded – undo
2421 2579
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2422 2580
 				
2423 2581
 				$colspan+=3; $mode = 'view';
2424
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2582
+				if($action === 'editline' && $line->rowid == GETPOST('lineid')) {
2583
+					$mode = 'edit';
2584
+				}
2425 2585
 				
2426 2586
 				$ex_element = $line->element;
2427 2587
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
@@ -2480,8 +2640,7 @@  discard block
 block discarded – undo
2480 2640
 			
2481 2641
 			return 1;	
2482 2642
 			
2483
-		}
2484
-		elseif(($object->element == 'commande' && in_array('ordershipmentcard', $contexts)) || (in_array('expeditioncard', $contexts) && $action == 'create'))
2643
+		} elseif(($object->element == 'commande' && in_array('ordershipmentcard', $contexts)) || (in_array('expeditioncard', $contexts) && $action == 'create'))
2485 2644
 		{
2486 2645
 			$colspan = 4;
2487 2646
 
@@ -2491,23 +2650,36 @@  discard block
 block discarded – undo
2491 2650
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2492 2651
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2493 2652
 					{
2494
-						if($line->qty==99) print 'background:#adadcf';
2495
-						else if($line->qty==98) print 'background:#ddddff;';
2496
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2497
-						else if($line->qty==1) print 'background:#adadcf;';
2498
-						else if($line->qty==2) print 'background:#ddddff;';
2499
-						else if($line->qty==50) print '';
2500
-						else print 'background:#eeeeff;';
2653
+						if($line->qty==99) {
2654
+							print 'background:#adadcf';
2655
+						} else if($line->qty==98) {
2656
+							print 'background:#ddddff;';
2657
+						} else if($line->qty<=97 && $line->qty>=91) {
2658
+							print 'background:#eeeeff;';
2659
+						} else if($line->qty==1) {
2660
+							print 'background:#adadcf;';
2661
+						} else if($line->qty==2) {
2662
+							print 'background:#ddddff;';
2663
+						} else if($line->qty==50) {
2664
+							print '';
2665
+						} else {
2666
+							print 'background:#eeeeff;';
2667
+						}
2501 2668
 
2502 2669
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2503
-					}
2504
-					else
2670
+					} else
2505 2671
 					{
2506
-						if($line->qty==99) print 'background:#ddffdd';
2507
-						else if($line->qty==98) print 'background:#ddddff;';
2508
-						else if($line->qty==2) print 'background:#eeeeff; ';
2509
-						else if($line->qty==50) print '';
2510
-						else print 'background:#eeffee;' ;
2672
+						if($line->qty==99) {
2673
+							print 'background:#ddffdd';
2674
+						} else if($line->qty==98) {
2675
+							print 'background:#ddddff;';
2676
+						} else if($line->qty==2) {
2677
+							print 'background:#eeeeff; ';
2678
+						} else if($line->qty==50) {
2679
+							print '';
2680
+						} else {
2681
+							print 'background:#eeffee;' ;
2682
+						}
2511 2683
 					}
2512 2684
 
2513 2685
 			?>;">
@@ -2521,14 +2693,19 @@  discard block
 block discarded – undo
2521 2693
 							{
2522 2694
 								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2523 2695
 
2524
-								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2525
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2696
+								if (TSubtotal::isTitle($line)) {
2697
+									print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2698
+								} else {
2699
+									print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2700
+								}
2526 2701
 							}
2527
-						 }
2528
-						 else
2702
+						 } else
2529 2703
 						 {
2530
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2531
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2704
+							if($line->qty<=1) {
2705
+								print img_picto('', 'subtotal@subtotal');
2706
+							} else if($line->qty==2) {
2707
+								print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2708
+							}
2532 2709
 						 }
2533 2710
 
2534 2711
 
@@ -2538,21 +2715,24 @@  discard block
 block discarded – undo
2538 2715
 						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2539 2716
 
2540 2717
 						 if (empty($line->label)) {
2541
-							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2542
-							else print  $line->description;
2543
-						 }
2544
-						 else {
2718
+							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2719
+								print  $line->description.' '.$this->getTitle($object, $line);
2720
+							} else {
2721
+								print  $line->description;
2722
+							}
2723
+						 } else {
2545 2724
 
2546 2725
 							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2547 2726
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2548
-							}
2549
-							else{
2727
+							} else{
2550 2728
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2551 2729
 							}
2552 2730
 
2553 2731
 						 }
2554 2732
 						//if($line->qty>90) print ' : ';
2555
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2733
+						if($line->info_bits > 0) {
2734
+							echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2735
+						}
2556 2736
 
2557 2737
 			?>
2558 2738
 				</td>
@@ -2575,8 +2755,7 @@  discard block
 block discarded – undo
2575 2755
 			</tr>
2576 2756
 <?php
2577 2757
 			return 1;
2578
-		}
2579
-		elseif ($object->element == 'shipping' || $object->element == 'delivery')
2758
+		} elseif ($object->element == 'shipping' || $object->element == 'delivery')
2580 2759
 		{
2581 2760
 			global $form;
2582 2761
 
@@ -2588,13 +2767,25 @@  discard block
 block discarded – undo
2588 2767
 			$extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2589 2768
 
2590 2769
 			$colspan = 4;
2591
-			if($object->origin && $object->origin_id > 0) $colspan++;
2592
-			if(! empty($conf->stock->enabled)) $colspan++;
2593
-			if(! empty($conf->productbatch->enabled)) $colspan++;
2594
-			if($object->statut == 0) $colspan++;
2595
-			if($object->statut == 0 && empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) $colspan++;
2770
+			if($object->origin && $object->origin_id > 0) {
2771
+				$colspan++;
2772
+			}
2773
+			if(! empty($conf->stock->enabled)) {
2774
+				$colspan++;
2775
+			}
2776
+			if(! empty($conf->productbatch->enabled)) {
2777
+				$colspan++;
2778
+			}
2779
+			if($object->statut == 0) {
2780
+				$colspan++;
2781
+			}
2782
+			if($object->statut == 0 && empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK)) {
2783
+				$colspan++;
2784
+			}
2596 2785
 
2597
-			if($object->element == 'delivery') $colspan = 2;
2786
+			if($object->element == 'delivery') {
2787
+				$colspan = 2;
2788
+			}
2598 2789
 
2599 2790
 			print '<!-- origin line id = '.$line->origin_line_id.' -->'; // id of order line
2600 2791
 
@@ -2604,23 +2795,36 @@  discard block
 block discarded – undo
2604 2795
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2605 2796
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2606 2797
 					{
2607
-						if($line->qty==99) print 'background:#adadcf';
2608
-						else if($line->qty==98) print 'background:#ddddff;';
2609
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2610
-						else if($line->qty==1) print 'background:#adadcf;';
2611
-						else if($line->qty==2) print 'background:#ddddff;';
2612
-						else if($line->qty==50) print '';
2613
-						else print 'background:#eeeeff;';
2798
+						if($line->qty==99) {
2799
+							print 'background:#adadcf';
2800
+						} else if($line->qty==98) {
2801
+							print 'background:#ddddff;';
2802
+						} else if($line->qty<=97 && $line->qty>=91) {
2803
+							print 'background:#eeeeff;';
2804
+						} else if($line->qty==1) {
2805
+							print 'background:#adadcf;';
2806
+						} else if($line->qty==2) {
2807
+							print 'background:#ddddff;';
2808
+						} else if($line->qty==50) {
2809
+							print '';
2810
+						} else {
2811
+							print 'background:#eeeeff;';
2812
+						}
2614 2813
 
2615 2814
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2616
-					}
2617
-					else 
2815
+					} else 
2618 2816
 					{
2619
-						if($line->qty==99) print 'background:#ddffdd';
2620
-						else if($line->qty==98) print 'background:#ddddff;';
2621
-						else if($line->qty==2) print 'background:#eeeeff; ';
2622
-						else if($line->qty==50) print '';
2623
-						else print 'background:#eeffee;' ;
2817
+						if($line->qty==99) {
2818
+							print 'background:#ddffdd';
2819
+						} else if($line->qty==98) {
2820
+							print 'background:#ddddff;';
2821
+						} else if($line->qty==2) {
2822
+							print 'background:#eeeeff; ';
2823
+						} else if($line->qty==50) {
2824
+							print '';
2825
+						} else {
2826
+							print 'background:#eeffee;' ;
2827
+						}
2624 2828
 					}
2625 2829
 
2626 2830
 			?>;">
@@ -2642,14 +2846,19 @@  discard block
 block discarded – undo
2642 2846
 				{
2643 2847
 					echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2644 2848
 
2645
-					if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2646
-					else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2849
+					if (TSubtotal::isTitle($line)) {
2850
+						print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2851
+					} else {
2852
+						print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2853
+					}
2647 2854
 				}
2648
-			}
2649
-			else
2855
+			} else
2650 2856
 			{
2651
-				if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2652
-				else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2857
+				if($line->qty<=1) {
2858
+					print img_picto('', 'subtotal@subtotal');
2859
+				} else if($line->qty==2) {
2860
+					print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2861
+				}
2653 2862
 			}
2654 2863
 
2655 2864
 
@@ -2659,19 +2868,22 @@  discard block
 block discarded – undo
2659 2868
 			$titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2660 2869
 
2661 2870
 			if (empty($line->label)) {
2662
-				if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2663
-				else print  $line->description;
2664
-			}
2665
-			else {
2871
+				if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2872
+					print  $line->description.' '.$this->getTitle($object, $line);
2873
+				} else {
2874
+					print  $line->description;
2875
+				}
2876
+			} else {
2666 2877
 				if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2667 2878
 					print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2668
-				}
2669
-				else{
2879
+				} else{
2670 2880
 					print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';
2671 2881
 				}
2672 2882
 			}
2673 2883
 			//if($line->qty>90) print ' : ';
2674
-			if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2884
+			if($line->info_bits > 0) {
2885
+				echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2886
+			}
2675 2887
 
2676 2888
 			?>
2677 2889
 				</td>
@@ -2851,10 +3063,9 @@  discard block
 block discarded – undo
2851 3063
 	    
2852 3064
 	    if(TSubtotal::isTitle($line)){
2853 3065
 	        $ThtmlData['data-issubtotal'] = 'title';
2854
-	    }elseif(TSubtotal::isSubtotal($line)){
3066
+	    } elseif(TSubtotal::isSubtotal($line)){
2855 3067
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2856
-	    }
2857
-	    else{
3068
+	    } else{
2858 3069
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2859 3070
 	    }
2860 3071
 	    
@@ -2864,7 +3075,9 @@  discard block
 block discarded – undo
2864 3075
 	    
2865 3076
 	    // hook 
2866 3077
 	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2867
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
3078
+	    if ($reshook < 0) {
3079
+	    	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
3080
+	    }
2868 3081
 	    if ($reshook>0)
2869 3082
 	    {
2870 3083
 	        $ThtmlData = $hookmanager->resArray;
Please login to merge, or discard this patch.
core/modules/modSubtotal.class.php 1 patch
Indentation   +402 added lines, -402 removed lines patch added patch discarded remove patch
@@ -31,187 +31,187 @@  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.2.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(
100
-                'invoicecard'
101
-                ,'invoicesuppliercard'
102
-                ,'propalcard'
103
-                ,'supplier_proposalcard'
104
-                ,'ordercard'
105
-                ,'ordersuppliercard'
106
-                ,'odtgeneration'
107
-                ,'orderstoinvoice'
108
-                ,'orderstoinvoicesupplier'
109
-                ,'admin'
110
-                ,'invoicereccard'
111
-                ,'consumptionthirdparty'
112
-            	,'ordershipmentcard'
113
-            	,'expeditioncard'
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.2.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(
100
+				'invoicecard'
101
+				,'invoicesuppliercard'
102
+				,'propalcard'
103
+				,'supplier_proposalcard'
104
+				,'ordercard'
105
+				,'ordersuppliercard'
106
+				,'odtgeneration'
107
+				,'orderstoinvoice'
108
+				,'orderstoinvoicesupplier'
109
+				,'admin'
110
+				,'invoicereccard'
111
+				,'consumptionthirdparty'
112
+				,'ordershipmentcard'
113
+				,'expeditioncard'
114 114
 				,'deliverycard'
115 115
 				,'paiementcard'
116
-            )
117
-            // Set here all workflow context managed by module
118
-            //'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE'))
119
-        );
116
+			)
117
+			// Set here all workflow context managed by module
118
+			//'workflow' => array('order' => array('WORKFLOW_ORDER_AUTOCREATE_INVOICE'))
119
+		);
120 120
 
121
-        // Data directories to create when module is enabled.
122
-        // Example: this->dirs = array("/titre/temp");
123
-        $this->dirs = array();
121
+		// Data directories to create when module is enabled.
122
+		// Example: this->dirs = array("/titre/temp");
123
+		$this->dirs = array();
124 124
 
125
-        // Config pages. Put here list of php pages
126
-        // stored into titre/admin directory, used to setup module.
127
-        $this->config_page_url = array("subtotal_setup.php@subtotal");
125
+		// Config pages. Put here list of php pages
126
+		// stored into titre/admin directory, used to setup module.
127
+		$this->config_page_url = array("subtotal_setup.php@subtotal");
128 128
 
129
-        // Dependencies
130
-        // List of modules id that must be enabled if this module is enabled
131
-        $this->depends = array();
129
+		// Dependencies
130
+		// List of modules id that must be enabled if this module is enabled
131
+		$this->depends = array();
132 132
 
133 133
 		$this->conflictwith=array('modMilestone');
134
-        // List of modules id to disable if this one is disabled
135
-        $this->requiredby = array();
136
-        // Minimum version of PHP required by module
137
-        $this->phpmin = array(5, 3);
138
-        // Minimum version of Dolibarr required by module
139
-        $this->need_dolibarr_version = array(3, 2);
140
-        $this->langfiles = array("subtotal@subtotal"); // langfiles@titre
141
-        // Constants
142
-        // List of particular constants to add when module is enabled
143
-        // (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
144
-        // Example:
145
-        $this->const = array(
146
-            	0=>array(
147
-            		'SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES',
148
-            		'chaine',
149
-            		'I',
150
-            		'Définit le style (B : gras, I : Italique, U : Souligné) des sous titres lorsque le détail des lignes et des ensembles est caché',
151
-            		1
152
-            	)
134
+		// List of modules id to disable if this one is disabled
135
+		$this->requiredby = array();
136
+		// Minimum version of PHP required by module
137
+		$this->phpmin = array(5, 3);
138
+		// Minimum version of Dolibarr required by module
139
+		$this->need_dolibarr_version = array(3, 2);
140
+		$this->langfiles = array("subtotal@subtotal"); // langfiles@titre
141
+		// Constants
142
+		// List of particular constants to add when module is enabled
143
+		// (key, 'chaine', value, desc, visible, 'current' or 'allentities', deleteonunactive)
144
+		// Example:
145
+		$this->const = array(
146
+				0=>array(
147
+					'SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES',
148
+					'chaine',
149
+					'I',
150
+					'Définit le style (B : gras, I : Italique, U : Souligné) des sous titres lorsque le détail des lignes et des ensembles est caché',
151
+					1
152
+				)
153 153
 				,1=>array('SUBTOTAL_ALLOW_ADD_BLOCK', 'chaine', '1', 'Permet l\'ajout de titres et sous-totaux')
154 154
 				,2=>array('SUBTOTAL_ALLOW_EDIT_BLOCK', 'chaine', '1', 'Permet de modifier titres et sous-totaux')
155 155
 				,3=>array('SUBTOTAL_ALLOW_REMOVE_BLOCK', 'chaine', '1', 'Permet de supprimer les titres et sous-totaux')
156 156
 				,4=>array('SUBTOTAL_TITLE_STYLE', 'chaine', 'BU')
157 157
 				,5=>array('SUBTOTAL_SUBTOTAL_STYLE', 'chaine', 'B')
158
-            //	1=>array(
159
-            //		'MYMODULE_MYNEWCONST2',
160
-            //		'chaine',
161
-            //		'myvalue',
162
-            //		'This is another constant to add',
163
-            //		0
164
-            //	)
165
-        );
158
+			//	1=>array(
159
+			//		'MYMODULE_MYNEWCONST2',
160
+			//		'chaine',
161
+			//		'myvalue',
162
+			//		'This is another constant to add',
163
+			//		0
164
+			//	)
165
+		);
166 166
 		
167 167
 
168 168
 
169 169
 
170
-        // Array to add new pages in new tabs
171
-        // Example:
172
-        $this->tabs = array(
173
-            //	// To add a new tab identified by code tabname1
174
-            //	'objecttype:+tabname1:Title1:langfile@titre:$user->rights->titre->read:/titre/mynewtab1.php?id=__ID__',
175
-            //	// To add another new tab identified by code tabname2
176
-            //	'objecttype:+tabname2:Title2:langfile@titre:$user->rights->othermodule->read:/titre/mynewtab2.php?id=__ID__',
177
-            //	// To remove an existing tab identified by code tabname
178
-            //	'objecttype:-tabname'
179
-        );
180
-        // where objecttype can be
181
-        // 'thirdparty'			to add a tab in third party view
182
-        // 'intervention'		to add a tab in intervention view
183
-        // 'order_supplier'		to add a tab in supplier order view
184
-        // 'invoice_supplier'	to add a tab in supplier invoice view
185
-        // 'invoice'			to add a tab in customer invoice view
186
-        // 'order'				to add a tab in customer order view
187
-        // 'product'			to add a tab in product view
188
-        // 'stock'				to add a tab in stock view
189
-        // 'propal'				to add a tab in propal view
190
-        // 'member'				to add a tab in fundation member view
191
-        // 'contract'			to add a tab in contract view
192
-        // 'user'				to add a tab in user view
193
-        // 'group'				to add a tab in group view
194
-        // 'contact'			to add a tab in contact view
195
-        // 'categories_x'		to add a tab in category view
196
-        // (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
197
-        // Dictionnaries
198
-        if (! isset($conf->subtotal->enabled)) {
199
-            $conf->subtotal=new stdClass();
200
-            $conf->subtotal->enabled = 0;
201
-        }
202
-        $this->dictionaries = array(
170
+		// Array to add new pages in new tabs
171
+		// Example:
172
+		$this->tabs = array(
173
+			//	// To add a new tab identified by code tabname1
174
+			//	'objecttype:+tabname1:Title1:langfile@titre:$user->rights->titre->read:/titre/mynewtab1.php?id=__ID__',
175
+			//	// To add another new tab identified by code tabname2
176
+			//	'objecttype:+tabname2:Title2:langfile@titre:$user->rights->othermodule->read:/titre/mynewtab2.php?id=__ID__',
177
+			//	// To remove an existing tab identified by code tabname
178
+			//	'objecttype:-tabname'
179
+		);
180
+		// where objecttype can be
181
+		// 'thirdparty'			to add a tab in third party view
182
+		// 'intervention'		to add a tab in intervention view
183
+		// 'order_supplier'		to add a tab in supplier order view
184
+		// 'invoice_supplier'	to add a tab in supplier invoice view
185
+		// 'invoice'			to add a tab in customer invoice view
186
+		// 'order'				to add a tab in customer order view
187
+		// 'product'			to add a tab in product view
188
+		// 'stock'				to add a tab in stock view
189
+		// 'propal'				to add a tab in propal view
190
+		// 'member'				to add a tab in fundation member view
191
+		// 'contract'			to add a tab in contract view
192
+		// 'user'				to add a tab in user view
193
+		// 'group'				to add a tab in group view
194
+		// 'contact'			to add a tab in contact view
195
+		// 'categories_x'		to add a tab in category view
196
+		// (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
197
+		// Dictionnaries
198
+		if (! isset($conf->subtotal->enabled)) {
199
+			$conf->subtotal=new stdClass();
200
+			$conf->subtotal->enabled = 0;
201
+		}
202
+		$this->dictionaries = array(
203 203
 			'langs'=>'subtotal@subtotal',
204
-            'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'),		// List of tables we want to see into dictonnary editor
205
-            'tablib'=>array($langs->trans('subtotalFreeLineDictionary')),													// Label of tables
206
-            '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
207
-            'tabsqlsort'=>array('label ASC'),																					// Sort order
208
-            'tabfield'=>array('label,content'),							// List of fields (result of select to show dictionary)
209
-            'tabfieldvalue'=>array('label,content'),						// List of fields (list of fields to edit a record)
210
-            'tabfieldinsert'=>array('label,content,entity'),					// List of fields (list of fields for insert)
211
-            'tabrowid'=>array('rowid'),											// Name of columns with primary key (try to always name it 'rowid')
212
-            'tabcond'=>array($conf->subtotal->enabled)	
204
+			'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'),		// List of tables we want to see into dictonnary editor
205
+			'tablib'=>array($langs->trans('subtotalFreeLineDictionary')),													// Label of tables
206
+			'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
207
+			'tabsqlsort'=>array('label ASC'),																					// Sort order
208
+			'tabfield'=>array('label,content'),							// List of fields (result of select to show dictionary)
209
+			'tabfieldvalue'=>array('label,content'),						// List of fields (list of fields to edit a record)
210
+			'tabfieldinsert'=>array('label,content,entity'),					// List of fields (list of fields for insert)
211
+			'tabrowid'=>array('rowid'),											// Name of columns with primary key (try to always name it 'rowid')
212
+			'tabcond'=>array($conf->subtotal->enabled)	
213 213
 		);
214
-        /* Example:
214
+		/* Example:
215 215
           // This is to avoid warnings
216 216
           if (! isset($conf->titre->enabled)) $conf->titre->enabled=0;
217 217
           $this->dictionnaries=array(
@@ -252,223 +252,223 @@  discard block
 block discarded – undo
252 252
           );
253 253
          */
254 254
 
255
-        // Boxes
256
-        // Add here list of php file(s) stored in core/boxes that contains class to show a box.
257
-        $this->boxes = array(); // Boxes list
255
+		// Boxes
256
+		// Add here list of php file(s) stored in core/boxes that contains class to show a box.
257
+		$this->boxes = array(); // Boxes list
258 258
        
259
-        /*
259
+		/*
260 260
           $this->boxes[$r][1] = "myboxb.php";
261 261
           $r++;
262 262
          */
263 263
 
264
-        // Permissions
265
-        $this->rights = array(); // Permission array used by this module
266
-        $r = 0;
264
+		// Permissions
265
+		$this->rights = array(); // Permission array used by this module
266
+		$r = 0;
267 267
 
268
-        // Add here list of permission defined by
269
-        // an id, a label, a boolean and two constant strings.
270
-        // Example:
271
-        //// Permission id (must not be already used)
272
-        //$this->rights[$r][0] = 2000;
273
-        //// Permission label
274
-        //$this->rights[$r][1] = 'Permision label';
275
-        //// Permission by default for new user (0/1)
276
-        //$this->rights[$r][3] = 1;
277
-        //// In php code, permission will be checked by test
278
-        //// if ($user->rights->permkey->level1->level2)
279
-        //$this->rights[$r][4] = 'level1';
280
-        //// In php code, permission will be checked by test
281
-        //// if ($user->rights->permkey->level1->level2)
282
-        //$this->rights[$r][5] = 'level2';
283
-        //$r++;
284
-        // Main menu entries
285
-        $this->menus = array(); // List of menus to add
286
-        $r = 0;
268
+		// Add here list of permission defined by
269
+		// an id, a label, a boolean and two constant strings.
270
+		// Example:
271
+		//// Permission id (must not be already used)
272
+		//$this->rights[$r][0] = 2000;
273
+		//// Permission label
274
+		//$this->rights[$r][1] = 'Permision label';
275
+		//// Permission by default for new user (0/1)
276
+		//$this->rights[$r][3] = 1;
277
+		//// In php code, permission will be checked by test
278
+		//// if ($user->rights->permkey->level1->level2)
279
+		//$this->rights[$r][4] = 'level1';
280
+		//// In php code, permission will be checked by test
281
+		//// if ($user->rights->permkey->level1->level2)
282
+		//$this->rights[$r][5] = 'level2';
283
+		//$r++;
284
+		// Main menu entries
285
+		$this->menus = array(); // List of menus to add
286
+		$r = 0;
287 287
 
288
-        // Add here entries to declare new menus
289
-        //
290
-        // Example to declare a new Top Menu entry and its Left menu entry:
291
-        //$this->menu[$r]=array(
292
-        //	// Put 0 if this is a top menu
293
-        //	'fk_menu'=>0,
294
-        //	// This is a Top menu entry
295
-        //	'type'=>'top',
296
-        //	'titre'=>'titre top menu',
297
-        //	'mainmenu'=>'titre',
298
-        //	'leftmenu'=>'titre',
299
-        //	'url'=>'/titre/pagetop.php',
300
-        //	// Lang file to use (without .lang) by module.
301
-        //	// File must be in langs/code_CODE/ directory.
302
-        //	'langs'=>'mylangfile',
303
-        //	'position'=>100,
304
-        //	// Define condition to show or hide menu entry.
305
-        //	// Use '$conf->titre->enabled' if entry must be visible if module is enabled.
306
-        //	'enabled'=>'$conf->titre->enabled',
307
-        //	// Use 'perms'=>'$user->rights->titre->level1->level2'
308
-        //	// if you want your menu with a permission rules
309
-        //	'perms'=>'1',
310
-        //	'target'=>'',
311
-        //	// 0=Menu for internal users, 1=external users, 2=both
312
-        //	'user'=>2
313
-        //);
314
-        //$r++;
315
-        //$this->menu[$r]=array(
316
-        //	// Use r=value where r is index key used for the parent menu entry
317
-        //	// (higher parent must be a top menu entry)
318
-        //	'fk_menu'=>'r=0',
319
-        //	// This is a Left menu entry
320
-        //	'type'=>'left',
321
-        //	'titre'=>'titre left menu',
322
-        //	'mainmenu'=>'titre',
323
-        //	'leftmenu'=>'titre',
324
-        //	'url'=>'/titre/pagelevel1.php',
325
-        //	// Lang file to use (without .lang) by module.
326
-        //	// File must be in langs/code_CODE/ directory.
327
-        //	'langs'=>'mylangfile',
328
-        //	'position'=>100,
329
-        //	// Define condition to show or hide menu entry.
330
-        //	// Use '$conf->titre->enabled' if entry must be visible if module is enabled.
331
-        //	'enabled'=>'$conf->titre->enabled',
332
-        //	// Use 'perms'=>'$user->rights->titre->level1->level2'
333
-        //	// if you want your menu with a permission rules
334
-        //	'perms'=>'1',
335
-        //	'target'=>'',
336
-        //	// 0=Menu for internal users, 1=external users, 2=both
337
-        //	'user'=>2
338
-        //);
339
-        //$r++;
340
-        //
341
-        // Example to declare a Left Menu entry into an existing Top menu entry:
342
-        //$this->menu[$r]=array(
343
-        //	// Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy'
344
-        //	'fk_menu'=>'fk_mainmenu=mainmenucode',
345
-        //	// This is a Left menu entry
346
-        //	'type'=>'left',
347
-        //	'titre'=>'titre left menu',
348
-        //	'mainmenu'=>'mainmenucode',
349
-        //	'leftmenu'=>'titre',
350
-        //	'url'=>'/titre/pagelevel2.php',
351
-        //	// Lang file to use (without .lang) by module.
352
-        //	// File must be in langs/code_CODE/ directory.
353
-        //	'langs'=>'mylangfile',
354
-        //	'position'=>100,
355
-        //	// Define condition to show or hide menu entry.
356
-        //	// Use '$conf->titre->enabled' if entry must be visible if module is enabled.
357
-        //	// Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
358
-        //	'enabled'=>'$conf->titre->enabled',
359
-        //	// Use 'perms'=>'$user->rights->titre->level1->level2'
360
-        //	// if you want your menu with a permission rules
361
-        //	'perms'=>'1',
362
-        //	'target'=>'',
363
-        //	// 0=Menu for internal users, 1=external users, 2=both
364
-        //	'user'=>2
365
-        //);
366
-        //$r++;
367
-        // Exports
368
-        $r = 1;
288
+		// Add here entries to declare new menus
289
+		//
290
+		// Example to declare a new Top Menu entry and its Left menu entry:
291
+		//$this->menu[$r]=array(
292
+		//	// Put 0 if this is a top menu
293
+		//	'fk_menu'=>0,
294
+		//	// This is a Top menu entry
295
+		//	'type'=>'top',
296
+		//	'titre'=>'titre top menu',
297
+		//	'mainmenu'=>'titre',
298
+		//	'leftmenu'=>'titre',
299
+		//	'url'=>'/titre/pagetop.php',
300
+		//	// Lang file to use (without .lang) by module.
301
+		//	// File must be in langs/code_CODE/ directory.
302
+		//	'langs'=>'mylangfile',
303
+		//	'position'=>100,
304
+		//	// Define condition to show or hide menu entry.
305
+		//	// Use '$conf->titre->enabled' if entry must be visible if module is enabled.
306
+		//	'enabled'=>'$conf->titre->enabled',
307
+		//	// Use 'perms'=>'$user->rights->titre->level1->level2'
308
+		//	// if you want your menu with a permission rules
309
+		//	'perms'=>'1',
310
+		//	'target'=>'',
311
+		//	// 0=Menu for internal users, 1=external users, 2=both
312
+		//	'user'=>2
313
+		//);
314
+		//$r++;
315
+		//$this->menu[$r]=array(
316
+		//	// Use r=value where r is index key used for the parent menu entry
317
+		//	// (higher parent must be a top menu entry)
318
+		//	'fk_menu'=>'r=0',
319
+		//	// This is a Left menu entry
320
+		//	'type'=>'left',
321
+		//	'titre'=>'titre left menu',
322
+		//	'mainmenu'=>'titre',
323
+		//	'leftmenu'=>'titre',
324
+		//	'url'=>'/titre/pagelevel1.php',
325
+		//	// Lang file to use (without .lang) by module.
326
+		//	// File must be in langs/code_CODE/ directory.
327
+		//	'langs'=>'mylangfile',
328
+		//	'position'=>100,
329
+		//	// Define condition to show or hide menu entry.
330
+		//	// Use '$conf->titre->enabled' if entry must be visible if module is enabled.
331
+		//	'enabled'=>'$conf->titre->enabled',
332
+		//	// Use 'perms'=>'$user->rights->titre->level1->level2'
333
+		//	// if you want your menu with a permission rules
334
+		//	'perms'=>'1',
335
+		//	'target'=>'',
336
+		//	// 0=Menu for internal users, 1=external users, 2=both
337
+		//	'user'=>2
338
+		//);
339
+		//$r++;
340
+		//
341
+		// Example to declare a Left Menu entry into an existing Top menu entry:
342
+		//$this->menu[$r]=array(
343
+		//	// Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy'
344
+		//	'fk_menu'=>'fk_mainmenu=mainmenucode',
345
+		//	// This is a Left menu entry
346
+		//	'type'=>'left',
347
+		//	'titre'=>'titre left menu',
348
+		//	'mainmenu'=>'mainmenucode',
349
+		//	'leftmenu'=>'titre',
350
+		//	'url'=>'/titre/pagelevel2.php',
351
+		//	// Lang file to use (without .lang) by module.
352
+		//	// File must be in langs/code_CODE/ directory.
353
+		//	'langs'=>'mylangfile',
354
+		//	'position'=>100,
355
+		//	// Define condition to show or hide menu entry.
356
+		//	// Use '$conf->titre->enabled' if entry must be visible if module is enabled.
357
+		//	// Use '$leftmenu==\'system\'' to show if leftmenu system is selected.
358
+		//	'enabled'=>'$conf->titre->enabled',
359
+		//	// Use 'perms'=>'$user->rights->titre->level1->level2'
360
+		//	// if you want your menu with a permission rules
361
+		//	'perms'=>'1',
362
+		//	'target'=>'',
363
+		//	// 0=Menu for internal users, 1=external users, 2=both
364
+		//	'user'=>2
365
+		//);
366
+		//$r++;
367
+		// Exports
368
+		$r = 1;
369 369
 
370
-        // Example:
371
-        //$this->export_code[$r]=$this->rights_class.'_'.$r;
372
-        //// Translation key (used only if key ExportDataset_xxx_z not found)
373
-        //$this->export_label[$r]='CustomersInvoicesAndInvoiceLines';
374
-        //// Condition to show export in list (ie: '$user->id==3').
375
-        //// Set to 1 to always show when module is enabled.
376
-        //$this->export_enabled[$r]='1';
377
-        //$this->export_permission[$r]=array(array("facture","facture","export"));
378
-        //$this->export_fields_array[$r]=array(
379
-        //	's.rowid'=>"IdCompany",
380
-        //	's.nom'=>'CompanyName',
381
-        //	's.address'=>'Address',
382
-        //	's.cp'=>'Zip',
383
-        //	's.ville'=>'Town',
384
-        //	's.fk_pays'=>'Country',
385
-        //	's.tel'=>'Phone',
386
-        //	's.siren'=>'ProfId1',
387
-        //	's.siret'=>'ProfId2',
388
-        //	's.ape'=>'ProfId3',
389
-        //	's.idprof4'=>'ProfId4',
390
-        //	's.code_compta'=>'CustomerAccountancyCode',
391
-        //	's.code_compta_fournisseur'=>'SupplierAccountancyCode',
392
-        //	'f.rowid'=>"InvoiceId",
393
-        //	'f.facnumber'=>"InvoiceRef",
394
-        //	'f.datec'=>"InvoiceDateCreation",
395
-        //	'f.datef'=>"DateInvoice",
396
-        //	'f.total'=>"TotalHT",
397
-        //	'f.total_ttc'=>"TotalTTC",
398
-        //	'f.tva'=>"TotalVAT",
399
-        //	'f.paye'=>"InvoicePaid",
400
-        //	'f.fk_statut'=>'InvoiceStatus',
401
-        //	'f.note'=>"InvoiceNote",
402
-        //	'fd.rowid'=>'LineId',
403
-        //	'fd.description'=>"LineDescription",
404
-        //	'fd.price'=>"LineUnitPrice",
405
-        //	'fd.tva_tx'=>"LineVATRate",
406
-        //	'fd.qty'=>"LineQty",
407
-        //	'fd.total_ht'=>"LineTotalHT",
408
-        //	'fd.total_tva'=>"LineTotalTVA",
409
-        //	'fd.total_ttc'=>"LineTotalTTC",
410
-        //	'fd.date_start'=>"DateStart",
411
-        //	'fd.date_end'=>"DateEnd",
412
-        //	'fd.fk_product'=>'ProductId',
413
-        //	'p.ref'=>'ProductRef'
414
-        //);
415
-        //$this->export_entities_array[$r]=array('s.rowid'=>"company",
416
-        //	's.nom'=>'company',
417
-        //	's.address'=>'company',
418
-        //	's.cp'=>'company',
419
-        //	's.ville'=>'company',
420
-        //	's.fk_pays'=>'company',
421
-        //	's.tel'=>'company',
422
-        //	's.siren'=>'company',
423
-        //	's.siret'=>'company',
424
-        //	's.ape'=>'company',
425
-        //	's.idprof4'=>'company',
426
-        //	's.code_compta'=>'company',
427
-        //	's.code_compta_fournisseur'=>'company',
428
-        //	'f.rowid'=>"invoice",
429
-        //	'f.facnumber'=>"invoice",
430
-        //	'f.datec'=>"invoice",
431
-        //	'f.datef'=>"invoice",
432
-        //	'f.total'=>"invoice",
433
-        //	'f.total_ttc'=>"invoice",
434
-        //	'f.tva'=>"invoice",
435
-        //	'f.paye'=>"invoice",
436
-        //	'f.fk_statut'=>'invoice',
437
-        //	'f.note'=>"invoice",
438
-        //	'fd.rowid'=>'invoice_line',
439
-        //	'fd.description'=>"invoice_line",
440
-        //	'fd.price'=>"invoice_line",
441
-        //	'fd.total_ht'=>"invoice_line",
442
-        //	'fd.total_tva'=>"invoice_line",
443
-        //	'fd.total_ttc'=>"invoice_line",
444
-        //	'fd.tva_tx'=>"invoice_line",
445
-        //	'fd.qty'=>"invoice_line",
446
-        //	'fd.date_start'=>"invoice_line",
447
-        //	'fd.date_end'=>"invoice_line",
448
-        //	'fd.fk_product'=>'product',
449
-        //	'p.ref'=>'product'
450
-        //);
451
-        //$this->export_sql_start[$r] = 'SELECT DISTINCT ';
452
-        //$this->export_sql_end[$r] = ' FROM (' . MAIN_DB_PREFIX . 'facture as f, '
453
-        //	. MAIN_DB_PREFIX . 'facturedet as fd, ' . MAIN_DB_PREFIX . 'societe as s)';
454
-        //$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX
455
-        //	. 'product as p on (fd.fk_product = p.rowid)';
456
-        //$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid '
457
-        //	. 'AND f.rowid = fd.fk_facture';
458
-        //$r++;
459
-    }
370
+		// Example:
371
+		//$this->export_code[$r]=$this->rights_class.'_'.$r;
372
+		//// Translation key (used only if key ExportDataset_xxx_z not found)
373
+		//$this->export_label[$r]='CustomersInvoicesAndInvoiceLines';
374
+		//// Condition to show export in list (ie: '$user->id==3').
375
+		//// Set to 1 to always show when module is enabled.
376
+		//$this->export_enabled[$r]='1';
377
+		//$this->export_permission[$r]=array(array("facture","facture","export"));
378
+		//$this->export_fields_array[$r]=array(
379
+		//	's.rowid'=>"IdCompany",
380
+		//	's.nom'=>'CompanyName',
381
+		//	's.address'=>'Address',
382
+		//	's.cp'=>'Zip',
383
+		//	's.ville'=>'Town',
384
+		//	's.fk_pays'=>'Country',
385
+		//	's.tel'=>'Phone',
386
+		//	's.siren'=>'ProfId1',
387
+		//	's.siret'=>'ProfId2',
388
+		//	's.ape'=>'ProfId3',
389
+		//	's.idprof4'=>'ProfId4',
390
+		//	's.code_compta'=>'CustomerAccountancyCode',
391
+		//	's.code_compta_fournisseur'=>'SupplierAccountancyCode',
392
+		//	'f.rowid'=>"InvoiceId",
393
+		//	'f.facnumber'=>"InvoiceRef",
394
+		//	'f.datec'=>"InvoiceDateCreation",
395
+		//	'f.datef'=>"DateInvoice",
396
+		//	'f.total'=>"TotalHT",
397
+		//	'f.total_ttc'=>"TotalTTC",
398
+		//	'f.tva'=>"TotalVAT",
399
+		//	'f.paye'=>"InvoicePaid",
400
+		//	'f.fk_statut'=>'InvoiceStatus',
401
+		//	'f.note'=>"InvoiceNote",
402
+		//	'fd.rowid'=>'LineId',
403
+		//	'fd.description'=>"LineDescription",
404
+		//	'fd.price'=>"LineUnitPrice",
405
+		//	'fd.tva_tx'=>"LineVATRate",
406
+		//	'fd.qty'=>"LineQty",
407
+		//	'fd.total_ht'=>"LineTotalHT",
408
+		//	'fd.total_tva'=>"LineTotalTVA",
409
+		//	'fd.total_ttc'=>"LineTotalTTC",
410
+		//	'fd.date_start'=>"DateStart",
411
+		//	'fd.date_end'=>"DateEnd",
412
+		//	'fd.fk_product'=>'ProductId',
413
+		//	'p.ref'=>'ProductRef'
414
+		//);
415
+		//$this->export_entities_array[$r]=array('s.rowid'=>"company",
416
+		//	's.nom'=>'company',
417
+		//	's.address'=>'company',
418
+		//	's.cp'=>'company',
419
+		//	's.ville'=>'company',
420
+		//	's.fk_pays'=>'company',
421
+		//	's.tel'=>'company',
422
+		//	's.siren'=>'company',
423
+		//	's.siret'=>'company',
424
+		//	's.ape'=>'company',
425
+		//	's.idprof4'=>'company',
426
+		//	's.code_compta'=>'company',
427
+		//	's.code_compta_fournisseur'=>'company',
428
+		//	'f.rowid'=>"invoice",
429
+		//	'f.facnumber'=>"invoice",
430
+		//	'f.datec'=>"invoice",
431
+		//	'f.datef'=>"invoice",
432
+		//	'f.total'=>"invoice",
433
+		//	'f.total_ttc'=>"invoice",
434
+		//	'f.tva'=>"invoice",
435
+		//	'f.paye'=>"invoice",
436
+		//	'f.fk_statut'=>'invoice',
437
+		//	'f.note'=>"invoice",
438
+		//	'fd.rowid'=>'invoice_line',
439
+		//	'fd.description'=>"invoice_line",
440
+		//	'fd.price'=>"invoice_line",
441
+		//	'fd.total_ht'=>"invoice_line",
442
+		//	'fd.total_tva'=>"invoice_line",
443
+		//	'fd.total_ttc'=>"invoice_line",
444
+		//	'fd.tva_tx'=>"invoice_line",
445
+		//	'fd.qty'=>"invoice_line",
446
+		//	'fd.date_start'=>"invoice_line",
447
+		//	'fd.date_end'=>"invoice_line",
448
+		//	'fd.fk_product'=>'product',
449
+		//	'p.ref'=>'product'
450
+		//);
451
+		//$this->export_sql_start[$r] = 'SELECT DISTINCT ';
452
+		//$this->export_sql_end[$r] = ' FROM (' . MAIN_DB_PREFIX . 'facture as f, '
453
+		//	. MAIN_DB_PREFIX . 'facturedet as fd, ' . MAIN_DB_PREFIX . 'societe as s)';
454
+		//$this->export_sql_end[$r] .= ' LEFT JOIN ' . MAIN_DB_PREFIX
455
+		//	. 'product as p on (fd.fk_product = p.rowid)';
456
+		//$this->export_sql_end[$r] .= ' WHERE f.fk_soc = s.rowid '
457
+		//	. 'AND f.rowid = fd.fk_facture';
458
+		//$r++;
459
+	}
460 460
 
461
-    /**
462
-     * Function called when module is enabled.
463
-     * The init function add constants, boxes, permissions and menus
464
-     * (defined in constructor) into Dolibarr database.
465
-     * It also creates data directories
466
-     *
467
-     * 	@param		string	$options	Options when enabling module ('', 'noboxes')
468
-     * 	@return		int					1 if OK, 0 if KO
469
-     */
470
-    public function init($options = '')
471
-    {
461
+	/**
462
+	 * Function called when module is enabled.
463
+	 * The init function add constants, boxes, permissions and menus
464
+	 * (defined in constructor) into Dolibarr database.
465
+	 * It also creates data directories
466
+	 *
467
+	 * 	@param		string	$options	Options when enabling module ('', 'noboxes')
468
+	 * 	@return		int					1 if OK, 0 if KO
469
+	 */
470
+	public function init($options = '')
471
+	{
472 472
 	  	global $conf, $db;
473 473
 		
474 474
 		
@@ -476,46 +476,46 @@  discard block
 block discarded – undo
476 476
 			exit("Attention, ce module rentre ne conflit avec le module Jalon/Milestones. Merci de le désactiver auparavant.");
477 477
 		}
478 478
       */
479
-	    $sql = array();
479
+		$sql = array();
480 480
 
481
-        $result = $this->loadTables();
482
-        dol_include_once('/core/class/extrafields.class.php');
481
+		$result = $this->loadTables();
482
+		dol_include_once('/core/class/extrafields.class.php');
483 483
 	
484
-        $extra = new ExtraFields($db); // propaldet, commandedet, facturedet
485
-        $TElementType = array('propaldet', 'commandedet', 'facturedet', 'supplier_proposaldet', 'commande_fournisseurdet', 'facture_fourn_det');
486
-        foreach($TElementType as $element_type) {
487
-            $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);
488
-            $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);
489
-        }
484
+		$extra = new ExtraFields($db); // propaldet, commandedet, facturedet
485
+		$TElementType = array('propaldet', 'commandedet', 'facturedet', 'supplier_proposaldet', 'commande_fournisseurdet', 'facture_fourn_det');
486
+		foreach($TElementType as $element_type) {
487
+			$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);
488
+			$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);
489
+		}
490 490
 		
491
-        return $this->_init($sql, $options);
492
-    }
491
+		return $this->_init($sql, $options);
492
+	}
493 493
 
494
-    /**
495
-     * Function called when module is disabled.
496
-     * Remove from database constants, boxes and permissions from Dolibarr database.
497
-     * Data directories are not deleted
498
-     *
499
-     * 	@param		string	$options	Options when enabling module ('', 'noboxes')
500
-     * 	@return		int					1 if OK, 0 if KO
501
-     */
502
-    public function remove($options = '')
503
-    {
504
-        $sql = array();
494
+	/**
495
+	 * Function called when module is disabled.
496
+	 * Remove from database constants, boxes and permissions from Dolibarr database.
497
+	 * Data directories are not deleted
498
+	 *
499
+	 * 	@param		string	$options	Options when enabling module ('', 'noboxes')
500
+	 * 	@return		int					1 if OK, 0 if KO
501
+	 */
502
+	public function remove($options = '')
503
+	{
504
+		$sql = array();
505 505
 
506
-        return $this->_remove($sql, $options);
507
-    }
506
+		return $this->_remove($sql, $options);
507
+	}
508 508
 
509
-    /**
510
-     * Create tables, keys and data required by module
511
-     * Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys
512
-     * and create data commands must be stored in directory /titre/sql/
513
-     * This function is called by this->init
514
-     *
515
-     * 	@return		int		<=0 if KO, >0 if OK
516
-     */
517
-    private function loadTables()
518
-    {
519
-        return $this->_load_tables('/subtotal/sql/');
520
-    }
509
+	/**
510
+	 * Create tables, keys and data required by module
511
+	 * Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys
512
+	 * and create data commands must be stored in directory /titre/sql/
513
+	 * This function is called by this->init
514
+	 *
515
+	 * 	@return		int		<=0 if KO, >0 if OK
516
+	 */
517
+	private function loadTables()
518
+	{
519
+		return $this->_load_tables('/subtotal/sql/');
520
+	}
521 521
 }
Please login to merge, or discard this patch.
core/triggers/interface_90_modSubtotal_subtotaltrigger.class.php 3 patches
Indentation   +567 added lines, -567 removed lines patch added patch discarded remove patch
@@ -36,68 +36,68 @@  discard block
 block discarded – undo
36 36
 class Interfacesubtotaltrigger
37 37
 {
38 38
 
39
-    private $db;
40
-
41
-    /**
42
-     * Constructor
43
-     *
44
-     * 	@param		DoliDB		$db		Database handler
45
-     */
46
-    public function __construct($db)
47
-    {
48
-        $this->db = $db;
49
-
50
-        $this->name = preg_replace('/^Interface/i', '', get_class($this));
51
-        $this->family = "demo";
52
-        $this->description = "Triggers of this module are empty functions."
53
-            . "They have no effect."
54
-            . "They are provided for tutorial purpose only.";
55
-        // 'development', 'experimental', 'dolibarr' or version
56
-        $this->version = 'development';
57
-        $this->picto = 'titre@titre';
58
-    }
59
-
60
-    /**
61
-     * Trigger name
62
-     *
63
-     * 	@return		string	Name of trigger file
64
-     */
65
-    public function getName()
66
-    {
67
-        return $this->name;
68
-    }
69
-
70
-    /**
71
-     * Trigger description
72
-     *
73
-     * 	@return		string	Description of trigger file
74
-     */
75
-    public function getDesc()
76
-    {
77
-        return $this->description;
78
-    }
79
-
80
-    /**
81
-     * Trigger version
82
-     *
83
-     * 	@return		string	Version of trigger file
84
-     */
85
-    public function getVersion()
86
-    {
87
-        global $langs;
88
-        $langs->load("admin");
89
-
90
-        if ($this->version == 'development') {
91
-            return $langs->trans("Development");
92
-        } elseif ($this->version == 'experimental')
93
-
94
-                return $langs->trans("Experimental");
95
-        elseif ($this->version == 'dolibarr') return DOL_VERSION;
96
-        elseif ($this->version) return $this->version;
97
-        else {
98
-            return $langs->trans("Unknown");
99
-        }
100
-    }
39
+	private $db;
40
+
41
+	/**
42
+	 * Constructor
43
+	 *
44
+	 * 	@param		DoliDB		$db		Database handler
45
+	 */
46
+	public function __construct($db)
47
+	{
48
+		$this->db = $db;
49
+
50
+		$this->name = preg_replace('/^Interface/i', '', get_class($this));
51
+		$this->family = "demo";
52
+		$this->description = "Triggers of this module are empty functions."
53
+			. "They have no effect."
54
+			. "They are provided for tutorial purpose only.";
55
+		// 'development', 'experimental', 'dolibarr' or version
56
+		$this->version = 'development';
57
+		$this->picto = 'titre@titre';
58
+	}
59
+
60
+	/**
61
+	 * Trigger name
62
+	 *
63
+	 * 	@return		string	Name of trigger file
64
+	 */
65
+	public function getName()
66
+	{
67
+		return $this->name;
68
+	}
69
+
70
+	/**
71
+	 * Trigger description
72
+	 *
73
+	 * 	@return		string	Description of trigger file
74
+	 */
75
+	public function getDesc()
76
+	{
77
+		return $this->description;
78
+	}
79
+
80
+	/**
81
+	 * Trigger version
82
+	 *
83
+	 * 	@return		string	Version of trigger file
84
+	 */
85
+	public function getVersion()
86
+	{
87
+		global $langs;
88
+		$langs->load("admin");
89
+
90
+		if ($this->version == 'development') {
91
+			return $langs->trans("Development");
92
+		} elseif ($this->version == 'experimental')
93
+
94
+				return $langs->trans("Experimental");
95
+		elseif ($this->version == 'dolibarr') return DOL_VERSION;
96
+		elseif ($this->version) return $this->version;
97
+		else {
98
+			return $langs->trans("Unknown");
99
+		}
100
+	}
101 101
 	
102 102
 	public function addToBegin(&$parent, &$object, $rang)
103 103
 	{
@@ -147,27 +147,27 @@  discard block
 block discarded – undo
147 147
 		}
148 148
 	}
149 149
 	
150
-    /**
151
-     * Function called when a Dolibarrr business event is done.
152
-     * All functions "run_trigger" are triggered if file
153
-     * is inside directory core/triggers
154
-     *
155
-     * 	@param		string		$action		Event action code
156
-     * 	@param		Object		$object		Object
157
-     * 	@param		User		$user		Object user
158
-     * 	@param		Translate	$langs		Object langs
159
-     * 	@param		conf		$conf		Object conf
160
-     * 	@return		int						<0 if KO, 0 if no triggered ran, >0 if OK
161
-     */
162
-    public function run_trigger($action, $object, $user, $langs, $conf)
163
-    {
164
-        // Put here code you want to execute when a Dolibarr business events occurs.
165
-        // Data and type of action are stored into $object and $action
166
-        // Users
167
-        dol_include_once('/subtotal/class/subtotal.class.php');
168
-        $langs->load('subtotal@subtotal');
169
-
170
-        if (!empty($conf->global->SUBTOTAL_ALLOW_ADD_LINE_UNDER_TITLE) && in_array($action, array('LINEPROPAL_INSERT', 'LINEORDER_INSERT', 'LINEBILL_INSERT')))
150
+	/**
151
+	 * Function called when a Dolibarrr business event is done.
152
+	 * All functions "run_trigger" are triggered if file
153
+	 * is inside directory core/triggers
154
+	 *
155
+	 * 	@param		string		$action		Event action code
156
+	 * 	@param		Object		$object		Object
157
+	 * 	@param		User		$user		Object user
158
+	 * 	@param		Translate	$langs		Object langs
159
+	 * 	@param		conf		$conf		Object conf
160
+	 * 	@return		int						<0 if KO, 0 if no triggered ran, >0 if OK
161
+	 */
162
+	public function run_trigger($action, $object, $user, $langs, $conf)
163
+	{
164
+		// Put here code you want to execute when a Dolibarr business events occurs.
165
+		// Data and type of action are stored into $object and $action
166
+		// Users
167
+		dol_include_once('/subtotal/class/subtotal.class.php');
168
+		$langs->load('subtotal@subtotal');
169
+
170
+		if (!empty($conf->global->SUBTOTAL_ALLOW_ADD_LINE_UNDER_TITLE) && in_array($action, array('LINEPROPAL_INSERT', 'LINEORDER_INSERT', 'LINEBILL_INSERT')))
171 171
 		{
172 172
 			
173 173
 			$rang = GETPOST('under_title', 'int'); // Rang du titre
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
 		}
200 200
         
201 201
 		
202
-        if ($action == 'LINEBILL_INSERT' || $action == 'LINEBILL_SUPPLIER_CREATE')
202
+		if ($action == 'LINEBILL_INSERT' || $action == 'LINEBILL_SUPPLIER_CREATE')
203 203
 		{
204
-		    $is_supplier = $action == 'LINEBILL_SUPPLIER_CREATE' ? true : false;
204
+			$is_supplier = $action == 'LINEBILL_SUPPLIER_CREATE' ? true : false;
205 205
 			$subtotal_add_title_bloc_from_orderstoinvoice = GETPOST('subtotal_add_title_bloc_from_orderstoinvoice');
206 206
 			if (!empty($subtotal_add_title_bloc_from_orderstoinvoice))
207 207
 			{
@@ -211,38 +211,38 @@  discard block
 block discarded – undo
211 211
 				$last_fk_commandedet = TSubtotal::getLastLineOrderId($this->db, $current_fk_commande, $is_supplier);
212 212
 
213 213
 				if (!$is_supplier){
214
-				    $facture = new Facture($this->db);
215
-				    $ret = $facture->fetch($object->fk_facture);
216
-                }
214
+					$facture = new Facture($this->db);
215
+					$ret = $facture->fetch($object->fk_facture);
216
+				}
217 217
 				else
218
-                {
219
-				    $facture = new FactureFournisseur($this->db);
220
-				    $ret = $facture->fetch($object->fk_facture_fourn);
221
-                }
218
+				{
219
+					$facture = new FactureFournisseur($this->db);
220
+					$ret = $facture->fetch($object->fk_facture_fourn);
221
+				}
222 222
 
223 223
 				if ($ret > 0)
224 224
 				{
225 225
 					$rang = !empty($subtotal_current_rang) ? $subtotal_current_rang : $object->rang;
226 226
 					// Si le fk_commande courrant est différent alors on change de commande => ajout d'un titre
227 227
 					if ($current_fk_commande != $subtotal_bloc_previous_fk_commande ) {
228
-                        if (!$is_supplier) $commande = new Commande($this->db);
229
-                        else $commande = new CommandeFournisseur($this->db);
230
-                        $commande->fetch($current_fk_commande);
231
-
232
-                        $label = $conf->global->SUBTOTAL_TEXT_FOR_TITLE_ORDETSTOINVOICE;
233
-                        if (empty($label)) {
234
-                            $label = 'Commande [__REFORDER__]';
235
-                            if (!$is_supplier) $label .= ' - Référence client : [__REFCUSTOMER__]';
236
-                        }
237
-                        $label = str_replace(array('__REFORDER__', '__REFCUSTOMER__'), array($commande->ref, $commande->ref_client), $label);
238
-
239
-                        if (!empty($current_fk_commande)) {
240
-                            TSubtotal::addTitle($facture, $label, 1, $rang);
241
-                            $rang++;
242
-                        }
243
-                    }
244
-
245
-                    $object->rang = $rang;
228
+						if (!$is_supplier) $commande = new Commande($this->db);
229
+						else $commande = new CommandeFournisseur($this->db);
230
+						$commande->fetch($current_fk_commande);
231
+
232
+						$label = $conf->global->SUBTOTAL_TEXT_FOR_TITLE_ORDETSTOINVOICE;
233
+						if (empty($label)) {
234
+							$label = 'Commande [__REFORDER__]';
235
+							if (!$is_supplier) $label .= ' - Référence client : [__REFCUSTOMER__]';
236
+						}
237
+						$label = str_replace(array('__REFORDER__', '__REFCUSTOMER__'), array($commande->ref, $commande->ref_client), $label);
238
+
239
+						if (!empty($current_fk_commande)) {
240
+							TSubtotal::addTitle($facture, $label, 1, $rang);
241
+							$rang++;
242
+						}
243
+					}
244
+
245
+					$object->rang = $rang;
246 246
 					$facture->updateRangOfLine($object->id, $rang);
247 247
 
248 248
 					$rang++;
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 		
272 272
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && in_array($action, array('LINEPROPAL_INSERT', 'LINEPROPAL_UPDATE', 'LINEORDER_INSERT', 'LINEORDER_UPDATE', 'LINEBILL_INSERT', 'LINEBILL_UPDATE')))
273 273
 		{
274
-            if(! function_exists('_updateLineNC')) dol_include_once('/subtotal/lib/subtotal.lib.php');
274
+			if(! function_exists('_updateLineNC')) dol_include_once('/subtotal/lib/subtotal.lib.php');
275 275
 
276 276
 			$doli_action = GETPOST('action');
277 277
 			$set = GETPOST('set');
@@ -337,173 +337,173 @@  discard block
 block discarded – undo
337 337
 		}
338 338
 		
339 339
         
340
-        if ($action == 'USER_LOGIN') {
341
-            dol_syslog(
342
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
343
-            );
344
-        } elseif ($action == 'USER_UPDATE_SESSION') {
345
-            // Warning: To increase performances, this action is triggered only if
346
-            // constant MAIN_ACTIVATE_UPDATESESSIONTRIGGER is set to 1.
347
-            dol_syslog(
348
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
349
-            );
350
-        } elseif ($action == 'USER_CREATE') {
351
-            dol_syslog(
352
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
353
-            );
354
-        } elseif ($action == 'USER_CREATE_FROM_CONTACT') {
355
-            dol_syslog(
356
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
357
-            );
358
-        } elseif ($action == 'USER_MODIFY') {
359
-            dol_syslog(
360
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
361
-            );
362
-        } elseif ($action == 'USER_NEW_PASSWORD') {
363
-            dol_syslog(
364
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
365
-            );
366
-        } elseif ($action == 'USER_ENABLEDISABLE') {
367
-            dol_syslog(
368
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
369
-            );
370
-        } elseif ($action == 'USER_DELETE') {
371
-            dol_syslog(
372
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
373
-            );
374
-        } elseif ($action == 'USER_LOGOUT') {
375
-            dol_syslog(
376
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
377
-            );
378
-        } elseif ($action == 'USER_SETINGROUP') {
379
-            dol_syslog(
380
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
381
-            );
382
-        } elseif ($action == 'USER_REMOVEFROMGROUP') {
383
-            dol_syslog(
384
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
385
-            );
386
-        }
387
-
388
-        // Groups
389
-        elseif ($action == 'GROUP_CREATE') {
390
-            dol_syslog(
391
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
392
-            );
393
-        } elseif ($action == 'GROUP_MODIFY') {
394
-            dol_syslog(
395
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
396
-            );
397
-        } elseif ($action == 'GROUP_DELETE') {
398
-            dol_syslog(
399
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
400
-            );
401
-        }
402
-
403
-        // Companies
404
-        elseif ($action == 'COMPANY_CREATE') {
405
-            dol_syslog(
406
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
407
-            );
408
-        } elseif ($action == 'COMPANY_MODIFY') {
409
-            dol_syslog(
410
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
411
-            );
412
-        } elseif ($action == 'COMPANY_DELETE') {
413
-            dol_syslog(
414
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
415
-            );
416
-        }
417
-
418
-        // Contacts
419
-        elseif ($action == 'CONTACT_CREATE') {
420
-            dol_syslog(
421
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
422
-            );
423
-        } elseif ($action == 'CONTACT_MODIFY') {
424
-            dol_syslog(
425
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
426
-            );
427
-        } elseif ($action == 'CONTACT_DELETE') {
428
-            dol_syslog(
429
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
430
-            );
431
-        }
432
-
433
-        // Products
434
-        elseif ($action == 'PRODUCT_CREATE') {
435
-            dol_syslog(
436
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
437
-            );
438
-        } elseif ($action == 'PRODUCT_MODIFY') {
439
-            dol_syslog(
440
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
441
-            );
442
-        } elseif ($action == 'PRODUCT_DELETE') {
443
-            dol_syslog(
444
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
445
-            );
446
-        }
447
-
448
-        // Customer orders
449
-        elseif ($action == 'ORDER_CREATE') {
450
-            dol_syslog(
451
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
452
-            );
453
-        } elseif ($action == 'ORDER_VALIDATE') {
454
-            dol_syslog(
455
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
456
-            );
457
-        } elseif ($action == 'ORDER_DELETE') {
458
-            dol_syslog(
459
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
460
-            );
461
-        } elseif ($action == 'ORDER_BUILDDOC') {
462
-            dol_syslog(
463
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
464
-            );
465
-        } elseif ($action == 'ORDER_SENTBYMAIL') {
466
-            dol_syslog(
467
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
468
-            );
469
-        } elseif ($action == 'LINEORDER_INSERT') {
470
-            dol_syslog(
471
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
472
-            );
473
-        } elseif ($action == 'LINEORDER_DELETE') {
474
-            dol_syslog(
475
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
476
-            );
477
-        }
478
-
479
-        // Supplier orders
480
-        elseif ($action == 'ORDER_SUPPLIER_CREATE') {
481
-            dol_syslog(
482
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
483
-            );
484
-        } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') {
485
-            dol_syslog(
486
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
487
-            );
488
-        } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') {
489
-            dol_syslog(
490
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
491
-            );
492
-        } elseif ($action == 'SUPPLIER_ORDER_BUILDDOC') {
493
-            dol_syslog(
494
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
495
-            );
496
-        }
497
-
498
-        // Proposals
499
-        elseif ($action == 'PROPAL_CREATE') {
500
-            dol_syslog(
501
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
502
-            );
503
-        } elseif (in_array($action, array('PROPAL_CLONE', 'ORDER_CLONE', 'BILL_CLONE'))) {
504
-            dol_syslog(
505
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
506
-            );
340
+		if ($action == 'USER_LOGIN') {
341
+			dol_syslog(
342
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
343
+			);
344
+		} elseif ($action == 'USER_UPDATE_SESSION') {
345
+			// Warning: To increase performances, this action is triggered only if
346
+			// constant MAIN_ACTIVATE_UPDATESESSIONTRIGGER is set to 1.
347
+			dol_syslog(
348
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
349
+			);
350
+		} elseif ($action == 'USER_CREATE') {
351
+			dol_syslog(
352
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
353
+			);
354
+		} elseif ($action == 'USER_CREATE_FROM_CONTACT') {
355
+			dol_syslog(
356
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
357
+			);
358
+		} elseif ($action == 'USER_MODIFY') {
359
+			dol_syslog(
360
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
361
+			);
362
+		} elseif ($action == 'USER_NEW_PASSWORD') {
363
+			dol_syslog(
364
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
365
+			);
366
+		} elseif ($action == 'USER_ENABLEDISABLE') {
367
+			dol_syslog(
368
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
369
+			);
370
+		} elseif ($action == 'USER_DELETE') {
371
+			dol_syslog(
372
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
373
+			);
374
+		} elseif ($action == 'USER_LOGOUT') {
375
+			dol_syslog(
376
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
377
+			);
378
+		} elseif ($action == 'USER_SETINGROUP') {
379
+			dol_syslog(
380
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
381
+			);
382
+		} elseif ($action == 'USER_REMOVEFROMGROUP') {
383
+			dol_syslog(
384
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
385
+			);
386
+		}
387
+
388
+		// Groups
389
+		elseif ($action == 'GROUP_CREATE') {
390
+			dol_syslog(
391
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
392
+			);
393
+		} elseif ($action == 'GROUP_MODIFY') {
394
+			dol_syslog(
395
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
396
+			);
397
+		} elseif ($action == 'GROUP_DELETE') {
398
+			dol_syslog(
399
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
400
+			);
401
+		}
402
+
403
+		// Companies
404
+		elseif ($action == 'COMPANY_CREATE') {
405
+			dol_syslog(
406
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
407
+			);
408
+		} elseif ($action == 'COMPANY_MODIFY') {
409
+			dol_syslog(
410
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
411
+			);
412
+		} elseif ($action == 'COMPANY_DELETE') {
413
+			dol_syslog(
414
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
415
+			);
416
+		}
417
+
418
+		// Contacts
419
+		elseif ($action == 'CONTACT_CREATE') {
420
+			dol_syslog(
421
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
422
+			);
423
+		} elseif ($action == 'CONTACT_MODIFY') {
424
+			dol_syslog(
425
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
426
+			);
427
+		} elseif ($action == 'CONTACT_DELETE') {
428
+			dol_syslog(
429
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
430
+			);
431
+		}
432
+
433
+		// Products
434
+		elseif ($action == 'PRODUCT_CREATE') {
435
+			dol_syslog(
436
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
437
+			);
438
+		} elseif ($action == 'PRODUCT_MODIFY') {
439
+			dol_syslog(
440
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
441
+			);
442
+		} elseif ($action == 'PRODUCT_DELETE') {
443
+			dol_syslog(
444
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
445
+			);
446
+		}
447
+
448
+		// Customer orders
449
+		elseif ($action == 'ORDER_CREATE') {
450
+			dol_syslog(
451
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
452
+			);
453
+		} elseif ($action == 'ORDER_VALIDATE') {
454
+			dol_syslog(
455
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
456
+			);
457
+		} elseif ($action == 'ORDER_DELETE') {
458
+			dol_syslog(
459
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
460
+			);
461
+		} elseif ($action == 'ORDER_BUILDDOC') {
462
+			dol_syslog(
463
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
464
+			);
465
+		} elseif ($action == 'ORDER_SENTBYMAIL') {
466
+			dol_syslog(
467
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
468
+			);
469
+		} elseif ($action == 'LINEORDER_INSERT') {
470
+			dol_syslog(
471
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
472
+			);
473
+		} elseif ($action == 'LINEORDER_DELETE') {
474
+			dol_syslog(
475
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
476
+			);
477
+		}
478
+
479
+		// Supplier orders
480
+		elseif ($action == 'ORDER_SUPPLIER_CREATE') {
481
+			dol_syslog(
482
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
483
+			);
484
+		} elseif ($action == 'ORDER_SUPPLIER_VALIDATE') {
485
+			dol_syslog(
486
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
487
+			);
488
+		} elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') {
489
+			dol_syslog(
490
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
491
+			);
492
+		} elseif ($action == 'SUPPLIER_ORDER_BUILDDOC') {
493
+			dol_syslog(
494
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
495
+			);
496
+		}
497
+
498
+		// Proposals
499
+		elseif ($action == 'PROPAL_CREATE') {
500
+			dol_syslog(
501
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
502
+			);
503
+		} elseif (in_array($action, array('PROPAL_CLONE', 'ORDER_CLONE', 'BILL_CLONE'))) {
504
+			dol_syslog(
505
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
506
+			);
507 507
 			
508 508
 			$doli_action = GETPOST('action');
509 509
 
@@ -536,296 +536,296 @@  discard block
 block discarded – undo
536 536
 				if (!empty($line)) $object->update_price(1);
537 537
 			}
538 538
 			
539
-        } elseif ($action == 'PROPAL_MODIFY') {
540
-            dol_syslog(
541
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
542
-            );
543
-        } elseif ($action == 'PROPAL_VALIDATE') {
544
-            dol_syslog(
545
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
546
-            );
547
-        } elseif ($action == 'PROPAL_BUILDDOC') {
548
-            dol_syslog(
549
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
550
-            );
551
-        } elseif ($action == 'PROPAL_SENTBYMAIL') {
552
-            dol_syslog(
553
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
554
-            );
555
-        } elseif ($action == 'PROPAL_CLOSE_SIGNED') {
556
-            dol_syslog(
557
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
558
-            );
559
-        } elseif ($action == 'PROPAL_CLOSE_REFUSED') {
560
-            dol_syslog(
561
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
562
-            );
563
-        } elseif ($action == 'PROPAL_DELETE') {
564
-            dol_syslog(
565
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
566
-            );
567
-        } elseif ($action == 'LINEPROPAL_INSERT') {
568
-            dol_syslog(
569
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
570
-            );
571
-        } elseif ($action == 'LINEPROPAL_MODIFY') {
572
-            dol_syslog(
573
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
574
-            );
575
-        } elseif ($action == 'LINEPROPAL_DELETE') {
576
-            dol_syslog(
577
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
578
-            );
579
-        }
580
-
581
-        // Contracts
582
-        elseif ($action == 'CONTRACT_CREATE') {
583
-            dol_syslog(
584
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
585
-            );
586
-        } elseif ($action == 'CONTRACT_MODIFY') {
587
-            dol_syslog(
588
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
589
-            );
590
-        } elseif ($action == 'CONTRACT_ACTIVATE') {
591
-            dol_syslog(
592
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
593
-            );
594
-        } elseif ($action == 'CONTRACT_CANCEL') {
595
-            dol_syslog(
596
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
597
-            );
598
-        } elseif ($action == 'CONTRACT_CLOSE') {
599
-            dol_syslog(
600
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
601
-            );
602
-        } elseif ($action == 'CONTRACT_DELETE') {
603
-            dol_syslog(
604
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
605
-            );
606
-        }
539
+		} elseif ($action == 'PROPAL_MODIFY') {
540
+			dol_syslog(
541
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
542
+			);
543
+		} elseif ($action == 'PROPAL_VALIDATE') {
544
+			dol_syslog(
545
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
546
+			);
547
+		} elseif ($action == 'PROPAL_BUILDDOC') {
548
+			dol_syslog(
549
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
550
+			);
551
+		} elseif ($action == 'PROPAL_SENTBYMAIL') {
552
+			dol_syslog(
553
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
554
+			);
555
+		} elseif ($action == 'PROPAL_CLOSE_SIGNED') {
556
+			dol_syslog(
557
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
558
+			);
559
+		} elseif ($action == 'PROPAL_CLOSE_REFUSED') {
560
+			dol_syslog(
561
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
562
+			);
563
+		} elseif ($action == 'PROPAL_DELETE') {
564
+			dol_syslog(
565
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
566
+			);
567
+		} elseif ($action == 'LINEPROPAL_INSERT') {
568
+			dol_syslog(
569
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
570
+			);
571
+		} elseif ($action == 'LINEPROPAL_MODIFY') {
572
+			dol_syslog(
573
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
574
+			);
575
+		} elseif ($action == 'LINEPROPAL_DELETE') {
576
+			dol_syslog(
577
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
578
+			);
579
+		}
580
+
581
+		// Contracts
582
+		elseif ($action == 'CONTRACT_CREATE') {
583
+			dol_syslog(
584
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
585
+			);
586
+		} elseif ($action == 'CONTRACT_MODIFY') {
587
+			dol_syslog(
588
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
589
+			);
590
+		} elseif ($action == 'CONTRACT_ACTIVATE') {
591
+			dol_syslog(
592
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
593
+			);
594
+		} elseif ($action == 'CONTRACT_CANCEL') {
595
+			dol_syslog(
596
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
597
+			);
598
+		} elseif ($action == 'CONTRACT_CLOSE') {
599
+			dol_syslog(
600
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
601
+			);
602
+		} elseif ($action == 'CONTRACT_DELETE') {
603
+			dol_syslog(
604
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
605
+			);
606
+		}
607 607
 
608 608
 		elseif ($action == 'BILL_MODIFY') {
609
-            dol_syslog(
610
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
611
-            );
612
-
613
-
614
-            global $conf;
615
-
616
-            if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
617
-            {
618
-                $object->situation_final = 1;
619
-                foreach($object->lines as $i => $line) {
620
-                    if(!TSubtotal::isModSubtotalLine($line) && $line->situation_percent != 100){
621
-                        $object->situation_final = 0;
622
-                        break;
623
-                    }
624
-                }
625
-                // ne pas utiliser $object->setFinal ne peut pas marcher
626
-                $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture SET situation_final = ' . $object->situation_final . ' where rowid = ' . $object->id;
627
-                $resql=$object->db->query($sql);
628
-            }
629
-
630
-
631
-        } elseif ($action == 'BILL_VALIDATE') {
632
-            dol_syslog(
633
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
634
-            );
635
-        } elseif ($action == 'BILL_BUILDDOC') {
636
-            dol_syslog(
637
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
638
-            );
639
-        } elseif ($action == 'BILL_SENTBYMAIL') {
640
-            dol_syslog(
641
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
642
-            );
643
-        } elseif ($action == 'BILL_CANCEL') {
644
-            dol_syslog(
645
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
646
-            );
647
-        } elseif ($action == 'BILL_DELETE') {
648
-            dol_syslog(
649
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
650
-            );
651
-        } elseif ($action == 'LINEBILL_INSERT') {
609
+			dol_syslog(
610
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
611
+			);
612
+
613
+
614
+			global $conf;
615
+
616
+			if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
617
+			{
618
+				$object->situation_final = 1;
619
+				foreach($object->lines as $i => $line) {
620
+					if(!TSubtotal::isModSubtotalLine($line) && $line->situation_percent != 100){
621
+						$object->situation_final = 0;
622
+						break;
623
+					}
624
+				}
625
+				// ne pas utiliser $object->setFinal ne peut pas marcher
626
+				$sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture SET situation_final = ' . $object->situation_final . ' where rowid = ' . $object->id;
627
+				$resql=$object->db->query($sql);
628
+			}
629
+
630
+
631
+		} elseif ($action == 'BILL_VALIDATE') {
632
+			dol_syslog(
633
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
634
+			);
635
+		} elseif ($action == 'BILL_BUILDDOC') {
636
+			dol_syslog(
637
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
638
+			);
639
+		} elseif ($action == 'BILL_SENTBYMAIL') {
640
+			dol_syslog(
641
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
642
+			);
643
+		} elseif ($action == 'BILL_CANCEL') {
644
+			dol_syslog(
645
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
646
+			);
647
+		} elseif ($action == 'BILL_DELETE') {
648
+			dol_syslog(
649
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
650
+			);
651
+		} elseif ($action == 'LINEBILL_INSERT') {
652 652
 				
653
-        	dol_syslog(
654
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
655
-            );
656
-        } elseif ($action == 'LINEBILL_DELETE') {
657
-            dol_syslog(
658
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
659
-            );
660
-        }
661
-
662
-        // Payments
663
-        elseif ($action == 'PAYMENT_CUSTOMER_CREATE') {
664
-            dol_syslog(
665
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
666
-            );
667
-        } elseif ($action == 'PAYMENT_SUPPLIER_CREATE') {
668
-            dol_syslog(
669
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
670
-            );
671
-        } elseif ($action == 'PAYMENT_ADD_TO_BANK') {
672
-            dol_syslog(
673
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
674
-            );
675
-        } elseif ($action == 'PAYMENT_DELETE') {
676
-            dol_syslog(
677
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
678
-            );
679
-        }
680
-
681
-        // Interventions
682
-        elseif ($action == 'FICHEINTER_CREATE') {
683
-            dol_syslog(
684
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
685
-            );
686
-        } elseif ($action == 'FICHEINTER_MODIFY') {
687
-            dol_syslog(
688
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
689
-            );
690
-        } elseif ($action == 'FICHEINTER_VALIDATE') {
691
-            dol_syslog(
692
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
693
-            );
694
-        } elseif ($action == 'FICHEINTER_DELETE') {
695
-            dol_syslog(
696
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
697
-            );
698
-        }
699
-
700
-        // Members
701
-        elseif ($action == 'MEMBER_CREATE') {
702
-            dol_syslog(
703
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
704
-            );
705
-        } elseif ($action == 'MEMBER_VALIDATE') {
706
-            dol_syslog(
707
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
708
-            );
709
-        } elseif ($action == 'MEMBER_SUBSCRIPTION') {
710
-            dol_syslog(
711
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
712
-            );
713
-        } elseif ($action == 'MEMBER_MODIFY') {
714
-            dol_syslog(
715
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
716
-            );
717
-        } elseif ($action == 'MEMBER_NEW_PASSWORD') {
718
-            dol_syslog(
719
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
720
-            );
721
-        } elseif ($action == 'MEMBER_RESILIATE') {
722
-            dol_syslog(
723
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
724
-            );
725
-        } elseif ($action == 'MEMBER_DELETE') {
726
-            dol_syslog(
727
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
728
-            );
729
-        }
730
-
731
-        // Categories
732
-        elseif ($action == 'CATEGORY_CREATE') {
733
-            dol_syslog(
734
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
735
-            );
736
-        } elseif ($action == 'CATEGORY_MODIFY') {
737
-            dol_syslog(
738
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
739
-            );
740
-        } elseif ($action == 'CATEGORY_DELETE') {
741
-            dol_syslog(
742
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
743
-            );
744
-        }
745
-
746
-        // Projects
747
-        elseif ($action == 'PROJECT_CREATE') {
748
-            dol_syslog(
749
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
750
-            );
751
-        } elseif ($action == 'PROJECT_MODIFY') {
752
-            dol_syslog(
753
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
754
-            );
755
-        } elseif ($action == 'PROJECT_DELETE') {
756
-            dol_syslog(
757
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
758
-            );
759
-        }
760
-
761
-        // Project tasks
762
-        elseif ($action == 'TASK_CREATE') {
763
-            dol_syslog(
764
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
765
-            );
766
-        } elseif ($action == 'TASK_MODIFY') {
767
-            dol_syslog(
768
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
769
-            );
770
-        } elseif ($action == 'TASK_DELETE') {
771
-            dol_syslog(
772
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
773
-            );
774
-        }
775
-
776
-        // Task time spent
777
-        elseif ($action == 'TASK_TIMESPENT_CREATE') {
778
-            dol_syslog(
779
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
780
-            );
781
-        } elseif ($action == 'TASK_TIMESPENT_MODIFY') {
782
-            dol_syslog(
783
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
784
-            );
785
-        } elseif ($action == 'TASK_TIMESPENT_DELETE') {
786
-            dol_syslog(
787
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
788
-            );
789
-        }
790
-
791
-        // Shipping
792
-        elseif ($action == 'SHIPPING_CREATE') {
793
-            dol_syslog(
794
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
795
-            );
796
-        } elseif ($action == 'SHIPPING_MODIFY') {
797
-            dol_syslog(
798
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
799
-            );
800
-        } elseif ($action == 'SHIPPING_VALIDATE') {
801
-            dol_syslog(
802
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
803
-            );
804
-        } elseif ($action == 'SHIPPING_SENTBYMAIL') {
805
-            dol_syslog(
806
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
807
-            );
808
-        } elseif ($action == 'SHIPPING_DELETE') {
809
-            dol_syslog(
810
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
811
-            );
812
-        } elseif ($action == 'SHIPPING_BUILDDOC') {
813
-            dol_syslog(
814
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
815
-            );
816
-        }
817
-
818
-        // File
819
-        elseif ($action == 'FILE_UPLOAD') {
820
-            dol_syslog(
821
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
822
-            );
823
-        } elseif ($action == 'FILE_DELETE') {
824
-            dol_syslog(
825
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
826
-            );
827
-        }
828
-
829
-        return 0;
830
-    }
653
+			dol_syslog(
654
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
655
+			);
656
+		} elseif ($action == 'LINEBILL_DELETE') {
657
+			dol_syslog(
658
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
659
+			);
660
+		}
661
+
662
+		// Payments
663
+		elseif ($action == 'PAYMENT_CUSTOMER_CREATE') {
664
+			dol_syslog(
665
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
666
+			);
667
+		} elseif ($action == 'PAYMENT_SUPPLIER_CREATE') {
668
+			dol_syslog(
669
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
670
+			);
671
+		} elseif ($action == 'PAYMENT_ADD_TO_BANK') {
672
+			dol_syslog(
673
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
674
+			);
675
+		} elseif ($action == 'PAYMENT_DELETE') {
676
+			dol_syslog(
677
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
678
+			);
679
+		}
680
+
681
+		// Interventions
682
+		elseif ($action == 'FICHEINTER_CREATE') {
683
+			dol_syslog(
684
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
685
+			);
686
+		} elseif ($action == 'FICHEINTER_MODIFY') {
687
+			dol_syslog(
688
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
689
+			);
690
+		} elseif ($action == 'FICHEINTER_VALIDATE') {
691
+			dol_syslog(
692
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
693
+			);
694
+		} elseif ($action == 'FICHEINTER_DELETE') {
695
+			dol_syslog(
696
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
697
+			);
698
+		}
699
+
700
+		// Members
701
+		elseif ($action == 'MEMBER_CREATE') {
702
+			dol_syslog(
703
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
704
+			);
705
+		} elseif ($action == 'MEMBER_VALIDATE') {
706
+			dol_syslog(
707
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
708
+			);
709
+		} elseif ($action == 'MEMBER_SUBSCRIPTION') {
710
+			dol_syslog(
711
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
712
+			);
713
+		} elseif ($action == 'MEMBER_MODIFY') {
714
+			dol_syslog(
715
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
716
+			);
717
+		} elseif ($action == 'MEMBER_NEW_PASSWORD') {
718
+			dol_syslog(
719
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
720
+			);
721
+		} elseif ($action == 'MEMBER_RESILIATE') {
722
+			dol_syslog(
723
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
724
+			);
725
+		} elseif ($action == 'MEMBER_DELETE') {
726
+			dol_syslog(
727
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
728
+			);
729
+		}
730
+
731
+		// Categories
732
+		elseif ($action == 'CATEGORY_CREATE') {
733
+			dol_syslog(
734
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
735
+			);
736
+		} elseif ($action == 'CATEGORY_MODIFY') {
737
+			dol_syslog(
738
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
739
+			);
740
+		} elseif ($action == 'CATEGORY_DELETE') {
741
+			dol_syslog(
742
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
743
+			);
744
+		}
745
+
746
+		// Projects
747
+		elseif ($action == 'PROJECT_CREATE') {
748
+			dol_syslog(
749
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
750
+			);
751
+		} elseif ($action == 'PROJECT_MODIFY') {
752
+			dol_syslog(
753
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
754
+			);
755
+		} elseif ($action == 'PROJECT_DELETE') {
756
+			dol_syslog(
757
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
758
+			);
759
+		}
760
+
761
+		// Project tasks
762
+		elseif ($action == 'TASK_CREATE') {
763
+			dol_syslog(
764
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
765
+			);
766
+		} elseif ($action == 'TASK_MODIFY') {
767
+			dol_syslog(
768
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
769
+			);
770
+		} elseif ($action == 'TASK_DELETE') {
771
+			dol_syslog(
772
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
773
+			);
774
+		}
775
+
776
+		// Task time spent
777
+		elseif ($action == 'TASK_TIMESPENT_CREATE') {
778
+			dol_syslog(
779
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
780
+			);
781
+		} elseif ($action == 'TASK_TIMESPENT_MODIFY') {
782
+			dol_syslog(
783
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
784
+			);
785
+		} elseif ($action == 'TASK_TIMESPENT_DELETE') {
786
+			dol_syslog(
787
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
788
+			);
789
+		}
790
+
791
+		// Shipping
792
+		elseif ($action == 'SHIPPING_CREATE') {
793
+			dol_syslog(
794
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
795
+			);
796
+		} elseif ($action == 'SHIPPING_MODIFY') {
797
+			dol_syslog(
798
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
799
+			);
800
+		} elseif ($action == 'SHIPPING_VALIDATE') {
801
+			dol_syslog(
802
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
803
+			);
804
+		} elseif ($action == 'SHIPPING_SENTBYMAIL') {
805
+			dol_syslog(
806
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
807
+			);
808
+		} elseif ($action == 'SHIPPING_DELETE') {
809
+			dol_syslog(
810
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
811
+			);
812
+		} elseif ($action == 'SHIPPING_BUILDDOC') {
813
+			dol_syslog(
814
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
815
+			);
816
+		}
817
+
818
+		// File
819
+		elseif ($action == 'FILE_UPLOAD') {
820
+			dol_syslog(
821
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
822
+			);
823
+		} elseif ($action == 'FILE_DELETE') {
824
+			dol_syslog(
825
+				"Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
826
+			);
827
+		}
828
+
829
+		return 0;
830
+	}
831 831
 }
832 832
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +118 added lines, -118 removed lines patch added patch discarded remove patch
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
 			if ($object->id != $line->id && $line->rang > $rang)
108 108
 			{
109 109
 				// Update du rang de toutes les lignes suivant mon titre
110
-				$parent->updateRangOfLine($line->id, $line->rang+1);
110
+				$parent->updateRangOfLine($line->id, $line->rang + 1);
111 111
 			}
112 112
 		}
113 113
 		
114 114
 		// Update du rang de la ligne fraichement ajouté pour la déplacer sous mon titre
115
-		$parent->updateRangOfLine($object->id, $rang+1);
116
-		$object->rang = $rang+1;
115
+		$parent->updateRangOfLine($object->id, $rang + 1);
116
+		$object->rang = $rang + 1;
117 117
 	}
118 118
 	
119 119
 	public function addToEnd(&$parent, &$object, $rang)
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 			
137 137
 			if ($subtotal_line_found)
138 138
 			{
139
-				$parent->updateRangOfLine($line->id, $line->rang+1);
139
+				$parent->updateRangOfLine($line->id, $line->rang + 1);
140 140
 			}
141 141
 		}
142 142
 		
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 				$current_fk_commande = TSubtotal::getOrderIdFromLineId($this->db, $object->origin_id, $is_supplier);
211 211
 				$last_fk_commandedet = TSubtotal::getLastLineOrderId($this->db, $current_fk_commande, $is_supplier);
212 212
 
213
-				if (!$is_supplier){
213
+				if (!$is_supplier) {
214 214
 				    $facture = new Facture($this->db);
215 215
 				    $ret = $facture->fetch($object->fk_facture);
216 216
                 }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 				{
225 225
 					$rang = !empty($subtotal_current_rang) ? $subtotal_current_rang : $object->rang;
226 226
 					// Si le fk_commande courrant est différent alors on change de commande => ajout d'un titre
227
-					if ($current_fk_commande != $subtotal_bloc_previous_fk_commande ) {
227
+					if ($current_fk_commande != $subtotal_bloc_previous_fk_commande) {
228 228
                         if (!$is_supplier) $commande = new Commande($this->db);
229 229
                         else $commande = new CommandeFournisseur($this->db);
230 230
                         $commande->fetch($current_fk_commande);
@@ -271,14 +271,14 @@  discard block
 block discarded – undo
271 271
 		
272 272
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && in_array($action, array('LINEPROPAL_INSERT', 'LINEPROPAL_UPDATE', 'LINEORDER_INSERT', 'LINEORDER_UPDATE', 'LINEBILL_INSERT', 'LINEBILL_UPDATE')))
273 273
 		{
274
-            if(! function_exists('_updateLineNC')) dol_include_once('/subtotal/lib/subtotal.lib.php');
274
+            if (!function_exists('_updateLineNC')) dol_include_once('/subtotal/lib/subtotal.lib.php');
275 275
 
276 276
 			$doli_action = GETPOST('action');
277 277
 			$set = GETPOST('set');
278
-			if ( (in_array($doli_action, array('updateligne', 'updateline', 'addline', 'add', 'create', 'setstatut')) || $set == 'defaultTVA') && !TSubtotal::isTitle($object) && !TSubtotal::isSubtotal($object) && in_array($object->element, array('propaldet', 'commandedet', 'facturedet')))
278
+			if ((in_array($doli_action, array('updateligne', 'updateline', 'addline', 'add', 'create', 'setstatut')) || $set == 'defaultTVA') && !TSubtotal::isTitle($object) && !TSubtotal::isSubtotal($object) && in_array($object->element, array('propaldet', 'commandedet', 'facturedet')))
279 279
 			{
280 280
 				 dol_syslog(
281
-					"[SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS] Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". object=".$object->element." id=" . $object->id
281
+					"[SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS] Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". object=".$object->element." id=".$object->id
282 282
 				);
283 283
 				 
284 284
 				$TTitle = TSubtotal::getAllTitleFromLine($object);
@@ -298,9 +298,9 @@  discard block
 block discarded – undo
298 298
 				}
299 299
 
300 300
 				// $object correspond à la ligne ajoutée
301
-				if(empty($object->array_options)) $object->fetch_optionals();
301
+				if (empty($object->array_options)) $object->fetch_optionals();
302 302
 
303
-				if(! empty($object->array_options['options_subtotal_nc'])) {
303
+				if (!empty($object->array_options['options_subtotal_nc'])) {
304 304
 					$object->total_ht = $object->total_tva = $object->total_ttc = $object->total_localtax1 = $object->total_localtax2 = 
305 305
 							$object->multicurrency_total_ht = $object->multicurrency_total_tva = $object->multicurrency_total_ttc = 0;
306 306
 
@@ -312,11 +312,11 @@  discard block
 block discarded – undo
312 312
 
313 313
 				// Correction d'un bug lors de la création d'une commande depuis une propale qui a, au moins, une ligne NC
314 314
 				$parent_element = '';
315
-				if($object->element == 'propaldet') $parent_element = 'propal';
316
-				if($object->element == 'commandedet') $parent_element = 'commande';
317
-				if($object->element == 'facturedet') $parent_element = 'facture';
315
+				if ($object->element == 'propaldet') $parent_element = 'propal';
316
+				if ($object->element == 'commandedet') $parent_element = 'commande';
317
+				if ($object->element == 'facturedet') $parent_element = 'facture';
318 318
 
319
-				if(! empty($parent_element) && ! empty($object->array_options['options_subtotal_nc'])) {
319
+				if (!empty($parent_element) && !empty($object->array_options['options_subtotal_nc'])) {
320 320
 					_updateLineNC($parent_element, $object->{'fk_'.$parent_element}, $object->id, $object->array_options['options_subtotal_nc'], 1);
321 321
 				}
322 322
 			}
@@ -324,12 +324,12 @@  discard block
 block discarded – undo
324 324
 		
325 325
 		// Les lignes libres (y compris les sous-totaux) créées à partir d'une facture modèle n'ont pas la TVA de la ligne du modèle mais la TVA par défaut
326 326
 		if ($action == 'BILL_CREATE' && $object->fac_rec > 0) {
327
-			dol_syslog("Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id);
327
+			dol_syslog("Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id);
328 328
 
329 329
 			$object->fetch_lines(); // Lignes pas rajoutées à $object->lines par les appels à addline();
330 330
 
331
-			foreach($object->lines as &$line) {
332
-				if(TSubtotal::isSubtotal($line) && ! empty($line->tva_tx)) {
331
+			foreach ($object->lines as &$line) {
332
+				if (TSubtotal::isSubtotal($line) && !empty($line->tva_tx)) {
333 333
 					$line->tva_tx = 0;
334 334
 					$line->update();
335 335
 				}
@@ -339,170 +339,170 @@  discard block
 block discarded – undo
339 339
         
340 340
         if ($action == 'USER_LOGIN') {
341 341
             dol_syslog(
342
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
342
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
343 343
             );
344 344
         } elseif ($action == 'USER_UPDATE_SESSION') {
345 345
             // Warning: To increase performances, this action is triggered only if
346 346
             // constant MAIN_ACTIVATE_UPDATESESSIONTRIGGER is set to 1.
347 347
             dol_syslog(
348
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
348
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
349 349
             );
350 350
         } elseif ($action == 'USER_CREATE') {
351 351
             dol_syslog(
352
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
352
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
353 353
             );
354 354
         } elseif ($action == 'USER_CREATE_FROM_CONTACT') {
355 355
             dol_syslog(
356
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
356
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
357 357
             );
358 358
         } elseif ($action == 'USER_MODIFY') {
359 359
             dol_syslog(
360
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
360
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
361 361
             );
362 362
         } elseif ($action == 'USER_NEW_PASSWORD') {
363 363
             dol_syslog(
364
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
364
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
365 365
             );
366 366
         } elseif ($action == 'USER_ENABLEDISABLE') {
367 367
             dol_syslog(
368
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
368
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
369 369
             );
370 370
         } elseif ($action == 'USER_DELETE') {
371 371
             dol_syslog(
372
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
372
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
373 373
             );
374 374
         } elseif ($action == 'USER_LOGOUT') {
375 375
             dol_syslog(
376
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
376
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
377 377
             );
378 378
         } elseif ($action == 'USER_SETINGROUP') {
379 379
             dol_syslog(
380
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
380
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
381 381
             );
382 382
         } elseif ($action == 'USER_REMOVEFROMGROUP') {
383 383
             dol_syslog(
384
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
384
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
385 385
             );
386 386
         }
387 387
 
388 388
         // Groups
389 389
         elseif ($action == 'GROUP_CREATE') {
390 390
             dol_syslog(
391
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
391
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
392 392
             );
393 393
         } elseif ($action == 'GROUP_MODIFY') {
394 394
             dol_syslog(
395
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
395
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
396 396
             );
397 397
         } elseif ($action == 'GROUP_DELETE') {
398 398
             dol_syslog(
399
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
399
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
400 400
             );
401 401
         }
402 402
 
403 403
         // Companies
404 404
         elseif ($action == 'COMPANY_CREATE') {
405 405
             dol_syslog(
406
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
406
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
407 407
             );
408 408
         } elseif ($action == 'COMPANY_MODIFY') {
409 409
             dol_syslog(
410
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
410
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
411 411
             );
412 412
         } elseif ($action == 'COMPANY_DELETE') {
413 413
             dol_syslog(
414
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
414
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
415 415
             );
416 416
         }
417 417
 
418 418
         // Contacts
419 419
         elseif ($action == 'CONTACT_CREATE') {
420 420
             dol_syslog(
421
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
421
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
422 422
             );
423 423
         } elseif ($action == 'CONTACT_MODIFY') {
424 424
             dol_syslog(
425
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
425
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
426 426
             );
427 427
         } elseif ($action == 'CONTACT_DELETE') {
428 428
             dol_syslog(
429
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
429
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
430 430
             );
431 431
         }
432 432
 
433 433
         // Products
434 434
         elseif ($action == 'PRODUCT_CREATE') {
435 435
             dol_syslog(
436
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
436
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
437 437
             );
438 438
         } elseif ($action == 'PRODUCT_MODIFY') {
439 439
             dol_syslog(
440
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
440
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
441 441
             );
442 442
         } elseif ($action == 'PRODUCT_DELETE') {
443 443
             dol_syslog(
444
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
444
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
445 445
             );
446 446
         }
447 447
 
448 448
         // Customer orders
449 449
         elseif ($action == 'ORDER_CREATE') {
450 450
             dol_syslog(
451
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
451
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
452 452
             );
453 453
         } elseif ($action == 'ORDER_VALIDATE') {
454 454
             dol_syslog(
455
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
455
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
456 456
             );
457 457
         } elseif ($action == 'ORDER_DELETE') {
458 458
             dol_syslog(
459
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
459
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
460 460
             );
461 461
         } elseif ($action == 'ORDER_BUILDDOC') {
462 462
             dol_syslog(
463
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
463
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
464 464
             );
465 465
         } elseif ($action == 'ORDER_SENTBYMAIL') {
466 466
             dol_syslog(
467
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
467
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
468 468
             );
469 469
         } elseif ($action == 'LINEORDER_INSERT') {
470 470
             dol_syslog(
471
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
471
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
472 472
             );
473 473
         } elseif ($action == 'LINEORDER_DELETE') {
474 474
             dol_syslog(
475
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
475
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
476 476
             );
477 477
         }
478 478
 
479 479
         // Supplier orders
480 480
         elseif ($action == 'ORDER_SUPPLIER_CREATE') {
481 481
             dol_syslog(
482
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
482
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
483 483
             );
484 484
         } elseif ($action == 'ORDER_SUPPLIER_VALIDATE') {
485 485
             dol_syslog(
486
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
486
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
487 487
             );
488 488
         } elseif ($action == 'ORDER_SUPPLIER_SENTBYMAIL') {
489 489
             dol_syslog(
490
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
490
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
491 491
             );
492 492
         } elseif ($action == 'SUPPLIER_ORDER_BUILDDOC') {
493 493
             dol_syslog(
494
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
494
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
495 495
             );
496 496
         }
497 497
 
498 498
         // Proposals
499 499
         elseif ($action == 'PROPAL_CREATE') {
500 500
             dol_syslog(
501
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
501
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
502 502
             );
503 503
         } elseif (in_array($action, array('PROPAL_CLONE', 'ORDER_CLONE', 'BILL_CLONE'))) {
504 504
             dol_syslog(
505
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
505
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
506 506
             );
507 507
 			
508 508
 			$doli_action = GETPOST('action');
@@ -510,7 +510,7 @@  discard block
 block discarded – undo
510 510
 			if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && in_array($doli_action, array('confirm_clone')))
511 511
 			{
512 512
 				dol_syslog(
513
-					"[SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS] Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". object=".$object->element." id=" . $object->id
513
+					"[SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS] Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". object=".$object->element." id=".$object->id
514 514
 				);
515 515
 				
516 516
 				// En fonction de l'objet et de la version, les lignes conservent l'id de l'objet d'origine
@@ -538,76 +538,76 @@  discard block
 block discarded – undo
538 538
 			
539 539
         } elseif ($action == 'PROPAL_MODIFY') {
540 540
             dol_syslog(
541
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
541
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
542 542
             );
543 543
         } elseif ($action == 'PROPAL_VALIDATE') {
544 544
             dol_syslog(
545
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
545
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
546 546
             );
547 547
         } elseif ($action == 'PROPAL_BUILDDOC') {
548 548
             dol_syslog(
549
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
549
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
550 550
             );
551 551
         } elseif ($action == 'PROPAL_SENTBYMAIL') {
552 552
             dol_syslog(
553
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
553
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
554 554
             );
555 555
         } elseif ($action == 'PROPAL_CLOSE_SIGNED') {
556 556
             dol_syslog(
557
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
557
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
558 558
             );
559 559
         } elseif ($action == 'PROPAL_CLOSE_REFUSED') {
560 560
             dol_syslog(
561
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
561
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
562 562
             );
563 563
         } elseif ($action == 'PROPAL_DELETE') {
564 564
             dol_syslog(
565
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
565
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
566 566
             );
567 567
         } elseif ($action == 'LINEPROPAL_INSERT') {
568 568
             dol_syslog(
569
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
569
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
570 570
             );
571 571
         } elseif ($action == 'LINEPROPAL_MODIFY') {
572 572
             dol_syslog(
573
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
573
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
574 574
             );
575 575
         } elseif ($action == 'LINEPROPAL_DELETE') {
576 576
             dol_syslog(
577
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
577
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
578 578
             );
579 579
         }
580 580
 
581 581
         // Contracts
582 582
         elseif ($action == 'CONTRACT_CREATE') {
583 583
             dol_syslog(
584
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
584
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
585 585
             );
586 586
         } elseif ($action == 'CONTRACT_MODIFY') {
587 587
             dol_syslog(
588
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
588
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
589 589
             );
590 590
         } elseif ($action == 'CONTRACT_ACTIVATE') {
591 591
             dol_syslog(
592
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
592
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
593 593
             );
594 594
         } elseif ($action == 'CONTRACT_CANCEL') {
595 595
             dol_syslog(
596
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
596
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
597 597
             );
598 598
         } elseif ($action == 'CONTRACT_CLOSE') {
599 599
             dol_syslog(
600
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
600
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
601 601
             );
602 602
         } elseif ($action == 'CONTRACT_DELETE') {
603 603
             dol_syslog(
604
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
604
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
605 605
             );
606 606
         }
607 607
 
608 608
 		elseif ($action == 'BILL_MODIFY') {
609 609
             dol_syslog(
610
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
610
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
611 611
             );
612 612
 
613 613
 
@@ -616,213 +616,213 @@  discard block
 block discarded – undo
616 616
             if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
617 617
             {
618 618
                 $object->situation_final = 1;
619
-                foreach($object->lines as $i => $line) {
620
-                    if(!TSubtotal::isModSubtotalLine($line) && $line->situation_percent != 100){
619
+                foreach ($object->lines as $i => $line) {
620
+                    if (!TSubtotal::isModSubtotalLine($line) && $line->situation_percent != 100) {
621 621
                         $object->situation_final = 0;
622 622
                         break;
623 623
                     }
624 624
                 }
625 625
                 // ne pas utiliser $object->setFinal ne peut pas marcher
626
-                $sql = 'UPDATE ' . MAIN_DB_PREFIX . 'facture SET situation_final = ' . $object->situation_final . ' where rowid = ' . $object->id;
627
-                $resql=$object->db->query($sql);
626
+                $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET situation_final = '.$object->situation_final.' where rowid = '.$object->id;
627
+                $resql = $object->db->query($sql);
628 628
             }
629 629
 
630 630
 
631 631
         } elseif ($action == 'BILL_VALIDATE') {
632 632
             dol_syslog(
633
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
633
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
634 634
             );
635 635
         } elseif ($action == 'BILL_BUILDDOC') {
636 636
             dol_syslog(
637
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
637
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
638 638
             );
639 639
         } elseif ($action == 'BILL_SENTBYMAIL') {
640 640
             dol_syslog(
641
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
641
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
642 642
             );
643 643
         } elseif ($action == 'BILL_CANCEL') {
644 644
             dol_syslog(
645
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
645
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
646 646
             );
647 647
         } elseif ($action == 'BILL_DELETE') {
648 648
             dol_syslog(
649
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
649
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
650 650
             );
651 651
         } elseif ($action == 'LINEBILL_INSERT') {
652 652
 				
653 653
         	dol_syslog(
654
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
654
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
655 655
             );
656 656
         } elseif ($action == 'LINEBILL_DELETE') {
657 657
             dol_syslog(
658
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
658
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
659 659
             );
660 660
         }
661 661
 
662 662
         // Payments
663 663
         elseif ($action == 'PAYMENT_CUSTOMER_CREATE') {
664 664
             dol_syslog(
665
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
665
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
666 666
             );
667 667
         } elseif ($action == 'PAYMENT_SUPPLIER_CREATE') {
668 668
             dol_syslog(
669
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
669
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
670 670
             );
671 671
         } elseif ($action == 'PAYMENT_ADD_TO_BANK') {
672 672
             dol_syslog(
673
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
673
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
674 674
             );
675 675
         } elseif ($action == 'PAYMENT_DELETE') {
676 676
             dol_syslog(
677
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
677
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
678 678
             );
679 679
         }
680 680
 
681 681
         // Interventions
682 682
         elseif ($action == 'FICHEINTER_CREATE') {
683 683
             dol_syslog(
684
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
684
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
685 685
             );
686 686
         } elseif ($action == 'FICHEINTER_MODIFY') {
687 687
             dol_syslog(
688
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
688
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
689 689
             );
690 690
         } elseif ($action == 'FICHEINTER_VALIDATE') {
691 691
             dol_syslog(
692
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
692
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
693 693
             );
694 694
         } elseif ($action == 'FICHEINTER_DELETE') {
695 695
             dol_syslog(
696
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
696
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
697 697
             );
698 698
         }
699 699
 
700 700
         // Members
701 701
         elseif ($action == 'MEMBER_CREATE') {
702 702
             dol_syslog(
703
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
703
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
704 704
             );
705 705
         } elseif ($action == 'MEMBER_VALIDATE') {
706 706
             dol_syslog(
707
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
707
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
708 708
             );
709 709
         } elseif ($action == 'MEMBER_SUBSCRIPTION') {
710 710
             dol_syslog(
711
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
711
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
712 712
             );
713 713
         } elseif ($action == 'MEMBER_MODIFY') {
714 714
             dol_syslog(
715
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
715
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
716 716
             );
717 717
         } elseif ($action == 'MEMBER_NEW_PASSWORD') {
718 718
             dol_syslog(
719
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
719
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
720 720
             );
721 721
         } elseif ($action == 'MEMBER_RESILIATE') {
722 722
             dol_syslog(
723
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
723
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
724 724
             );
725 725
         } elseif ($action == 'MEMBER_DELETE') {
726 726
             dol_syslog(
727
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
727
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
728 728
             );
729 729
         }
730 730
 
731 731
         // Categories
732 732
         elseif ($action == 'CATEGORY_CREATE') {
733 733
             dol_syslog(
734
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
734
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
735 735
             );
736 736
         } elseif ($action == 'CATEGORY_MODIFY') {
737 737
             dol_syslog(
738
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
738
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
739 739
             );
740 740
         } elseif ($action == 'CATEGORY_DELETE') {
741 741
             dol_syslog(
742
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
742
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
743 743
             );
744 744
         }
745 745
 
746 746
         // Projects
747 747
         elseif ($action == 'PROJECT_CREATE') {
748 748
             dol_syslog(
749
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
749
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
750 750
             );
751 751
         } elseif ($action == 'PROJECT_MODIFY') {
752 752
             dol_syslog(
753
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
753
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
754 754
             );
755 755
         } elseif ($action == 'PROJECT_DELETE') {
756 756
             dol_syslog(
757
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
757
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
758 758
             );
759 759
         }
760 760
 
761 761
         // Project tasks
762 762
         elseif ($action == 'TASK_CREATE') {
763 763
             dol_syslog(
764
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
764
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
765 765
             );
766 766
         } elseif ($action == 'TASK_MODIFY') {
767 767
             dol_syslog(
768
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
768
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
769 769
             );
770 770
         } elseif ($action == 'TASK_DELETE') {
771 771
             dol_syslog(
772
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
772
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
773 773
             );
774 774
         }
775 775
 
776 776
         // Task time spent
777 777
         elseif ($action == 'TASK_TIMESPENT_CREATE') {
778 778
             dol_syslog(
779
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
779
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
780 780
             );
781 781
         } elseif ($action == 'TASK_TIMESPENT_MODIFY') {
782 782
             dol_syslog(
783
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
783
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
784 784
             );
785 785
         } elseif ($action == 'TASK_TIMESPENT_DELETE') {
786 786
             dol_syslog(
787
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
787
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
788 788
             );
789 789
         }
790 790
 
791 791
         // Shipping
792 792
         elseif ($action == 'SHIPPING_CREATE') {
793 793
             dol_syslog(
794
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
794
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
795 795
             );
796 796
         } elseif ($action == 'SHIPPING_MODIFY') {
797 797
             dol_syslog(
798
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
798
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
799 799
             );
800 800
         } elseif ($action == 'SHIPPING_VALIDATE') {
801 801
             dol_syslog(
802
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
802
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
803 803
             );
804 804
         } elseif ($action == 'SHIPPING_SENTBYMAIL') {
805 805
             dol_syslog(
806
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
806
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
807 807
             );
808 808
         } elseif ($action == 'SHIPPING_DELETE') {
809 809
             dol_syslog(
810
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
810
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
811 811
             );
812 812
         } elseif ($action == 'SHIPPING_BUILDDOC') {
813 813
             dol_syslog(
814
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
814
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
815 815
             );
816 816
         }
817 817
 
818 818
         // File
819 819
         elseif ($action == 'FILE_UPLOAD') {
820 820
             dol_syslog(
821
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
821
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
822 822
             );
823 823
         } elseif ($action == 'FILE_DELETE') {
824 824
             dol_syslog(
825
-                "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
825
+                "Trigger '".$this->name."' for action '$action' launched by ".__FILE__.". id=".$object->id
826 826
             );
827 827
         }
828 828
 
Please login to merge, or discard this patch.
Braces   +79 added lines, -36 removed lines patch added patch discarded remove patch
@@ -89,12 +89,14 @@  discard block
 block discarded – undo
89 89
 
90 90
         if ($this->version == 'development') {
91 91
             return $langs->trans("Development");
92
-        } elseif ($this->version == 'experimental')
93
-
92
+        } elseif ($this->version == 'experimental') {
93
+        
94 94
                 return $langs->trans("Experimental");
95
-        elseif ($this->version == 'dolibarr') return DOL_VERSION;
96
-        elseif ($this->version) return $this->version;
97
-        else {
95
+        } elseif ($this->version == 'dolibarr') {
96
+        	return DOL_VERSION;
97
+        } elseif ($this->version) {
98
+        	return $this->version;
99
+        } else {
98 100
             return $langs->trans("Unknown");
99 101
         }
100 102
     }
@@ -122,14 +124,18 @@  discard block
 block discarded – undo
122 124
 		$subtotal_line_found = false;
123 125
 		foreach ($parent->lines as $k => &$line)
124 126
 		{
125
-			if ($line->rang < $rang) continue;
126
-			elseif ($line->rang == $rang) // Je suis sur la ligne de titre où je souhaite ajouter ma nouvelle ligne en fin de bloc
127
+			if ($line->rang < $rang) {
128
+				continue;
129
+			} elseif ($line->rang == $rang) {
130
+				// Je suis sur la ligne de titre où je souhaite ajouter ma nouvelle ligne en fin de bloc
127 131
 			{
128 132
 				$title_level = $line->qty;
129 133
 			}
130
-			elseif (!$subtotal_line_found && $title_level > -1 && ($line->qty == 100 - $title_level)) // Le level de mon titre a été trouvé avant, donc maintenant je vais m'arrêter jusqu'à trouver un sous-total
134
+			} elseif (!$subtotal_line_found && $title_level > -1 && ($line->qty == 100 - $title_level)) {
135
+				// Le level de mon titre a été trouvé avant, donc maintenant je vais m'arrêter jusqu'à trouver un sous-total
131 136
 			{
132 137
 				$subtotal_line_found = true;
138
+			}
133 139
 				$rang = $line->rang;
134 140
 			}
135 141
 			
@@ -191,8 +197,11 @@  discard block
 block discarded – undo
191 197
 						break;
192 198
 				}
193 199
 				
194
-				if (!empty($conf->global->SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK)) $this->addToEnd($parent, $object, $rang);
195
-				else $this->addToBegin($parent, $object, $rang);
200
+				if (!empty($conf->global->SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK)) {
201
+					$this->addToEnd($parent, $object, $rang);
202
+				} else {
203
+					$this->addToBegin($parent, $object, $rang);
204
+				}
196 205
 				
197 206
 			}
198 207
 			
@@ -213,8 +222,7 @@  discard block
 block discarded – undo
213 222
 				if (!$is_supplier){
214 223
 				    $facture = new Facture($this->db);
215 224
 				    $ret = $facture->fetch($object->fk_facture);
216
-                }
217
-				else
225
+                } else
218 226
                 {
219 227
 				    $facture = new FactureFournisseur($this->db);
220 228
 				    $ret = $facture->fetch($object->fk_facture_fourn);
@@ -225,14 +233,19 @@  discard block
 block discarded – undo
225 233
 					$rang = !empty($subtotal_current_rang) ? $subtotal_current_rang : $object->rang;
226 234
 					// Si le fk_commande courrant est différent alors on change de commande => ajout d'un titre
227 235
 					if ($current_fk_commande != $subtotal_bloc_previous_fk_commande ) {
228
-                        if (!$is_supplier) $commande = new Commande($this->db);
229
-                        else $commande = new CommandeFournisseur($this->db);
236
+                        if (!$is_supplier) {
237
+                        	$commande = new Commande($this->db);
238
+                        } else {
239
+                        	$commande = new CommandeFournisseur($this->db);
240
+                        }
230 241
                         $commande->fetch($current_fk_commande);
231 242
 
232 243
                         $label = $conf->global->SUBTOTAL_TEXT_FOR_TITLE_ORDETSTOINVOICE;
233 244
                         if (empty($label)) {
234 245
                             $label = 'Commande [__REFORDER__]';
235
-                            if (!$is_supplier) $label .= ' - Référence client : [__REFCUSTOMER__]';
246
+                            if (!$is_supplier) {
247
+                            	$label .= ' - Référence client : [__REFCUSTOMER__]';
248
+                            }
236 249
                         }
237 250
                         $label = str_replace(array('__REFORDER__', '__REFCUSTOMER__'), array($commande->ref, $commande->ref_client), $label);
238 251
 
@@ -271,7 +284,9 @@  discard block
 block discarded – undo
271 284
 		
272 285
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && in_array($action, array('LINEPROPAL_INSERT', 'LINEPROPAL_UPDATE', 'LINEORDER_INSERT', 'LINEORDER_UPDATE', 'LINEBILL_INSERT', 'LINEBILL_UPDATE')))
273 286
 		{
274
-            if(! function_exists('_updateLineNC')) dol_include_once('/subtotal/lib/subtotal.lib.php');
287
+            if(! function_exists('_updateLineNC')) {
288
+            	dol_include_once('/subtotal/lib/subtotal.lib.php');
289
+            }
275 290
 
276 291
 			$doli_action = GETPOST('action');
277 292
 			$set = GETPOST('set');
@@ -289,32 +304,50 @@  discard block
 block discarded – undo
289 304
 						$object->total_ht = $object->total_tva = $object->total_ttc = $object->total_localtax1 = $object->total_localtax2 = 
290 305
 							$object->multicurrency_total_ht = $object->multicurrency_total_tva = $object->multicurrency_total_ttc = 0;
291 306
 
292
-						if ($object->element == 'propal') $res = $object->update(1);
293
-						else $res = $object->update($user, 1);
307
+						if ($object->element == 'propal') {
308
+							$res = $object->update(1);
309
+						} else {
310
+							$res = $object->update($user, 1);
311
+						}
294 312
 						
295
-						if ($res > 0) setEventMessage($langs->trans('subtotal_update_nc_success'));
313
+						if ($res > 0) {
314
+							setEventMessage($langs->trans('subtotal_update_nc_success'));
315
+						}
296 316
 						break;
297 317
 					}
298 318
 				}
299 319
 
300 320
 				// $object correspond à la ligne ajoutée
301
-				if(empty($object->array_options)) $object->fetch_optionals();
321
+				if(empty($object->array_options)) {
322
+					$object->fetch_optionals();
323
+				}
302 324
 
303 325
 				if(! empty($object->array_options['options_subtotal_nc'])) {
304 326
 					$object->total_ht = $object->total_tva = $object->total_ttc = $object->total_localtax1 = $object->total_localtax2 = 
305 327
 							$object->multicurrency_total_ht = $object->multicurrency_total_tva = $object->multicurrency_total_ttc = 0;
306 328
 
307
-					if ($object->element == 'propaldet') $res = $object->update(1);
308
-					else $res = $object->update($user, 1);
329
+					if ($object->element == 'propaldet') {
330
+						$res = $object->update(1);
331
+					} else {
332
+						$res = $object->update($user, 1);
333
+					}
309 334
 
310
-					if ($res > 0) setEventMessage($langs->trans('subtotal_update_nc_success'));
335
+					if ($res > 0) {
336
+						setEventMessage($langs->trans('subtotal_update_nc_success'));
337
+					}
311 338
 				}
312 339
 
313 340
 				// Correction d'un bug lors de la création d'une commande depuis une propale qui a, au moins, une ligne NC
314 341
 				$parent_element = '';
315
-				if($object->element == 'propaldet') $parent_element = 'propal';
316
-				if($object->element == 'commandedet') $parent_element = 'commande';
317
-				if($object->element == 'facturedet') $parent_element = 'facture';
342
+				if($object->element == 'propaldet') {
343
+					$parent_element = 'propal';
344
+				}
345
+				if($object->element == 'commandedet') {
346
+					$parent_element = 'commande';
347
+				}
348
+				if($object->element == 'facturedet') {
349
+					$parent_element = 'facture';
350
+				}
318 351
 
319 352
 				if(! empty($parent_element) && ! empty($object->array_options['options_subtotal_nc'])) {
320 353
 					_updateLineNC($parent_element, $object->{'fk_'.$parent_element}, $object->id, $object->array_options['options_subtotal_nc'], 1);
@@ -514,26 +547,38 @@  discard block
 block discarded – undo
514 547
 				);
515 548
 				
516 549
 				// En fonction de l'objet et de la version, les lignes conservent l'id de l'objet d'origine
517
-				if (method_exists($object, 'fetch_lines')) $object->fetch_lines();
518
-				else $object->fetch($object->id);
550
+				if (method_exists($object, 'fetch_lines')) {
551
+					$object->fetch_lines();
552
+				} else {
553
+					$object->fetch($object->id);
554
+				}
519 555
 			
520 556
 				foreach ($object->lines as &$line)
521 557
 				{
522
-					if (empty($line->array_options)) $line->fetch_optionals();
558
+					if (empty($line->array_options)) {
559
+						$line->fetch_optionals();
560
+					}
523 561
 					
524 562
 					if (!TSubtotal::isModSubtotalLine($line) && !empty($line->array_options['options_subtotal_nc']))
525 563
 					{
526 564
 						$line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = 
527 565
 							$line->multicurrency_total_ht = $line->multicurrency_total_tva = $line->multicurrency_total_ttc = 0;
528 566
 
529
-						if ($line->element == 'propaldet') $res = $line->update(1);
530
-						else $res = $line->update($user, 1);
567
+						if ($line->element == 'propaldet') {
568
+							$res = $line->update(1);
569
+						} else {
570
+							$res = $line->update($user, 1);
571
+						}
531 572
 						
532
-						if ($res > 0) setEventMessage($langs->trans('subtotal_update_nc_success'));
573
+						if ($res > 0) {
574
+							setEventMessage($langs->trans('subtotal_update_nc_success'));
575
+						}
533 576
 					}
534 577
 				}
535 578
 				
536
-				if (!empty($line)) $object->update_price(1);
579
+				if (!empty($line)) {
580
+					$object->update_price(1);
581
+				}
537 582
 			}
538 583
 			
539 584
         } elseif ($action == 'PROPAL_MODIFY') {
@@ -603,9 +648,7 @@  discard block
 block discarded – undo
603 648
             dol_syslog(
604 649
                 "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
605 650
             );
606
-        }
607
-
608
-		elseif ($action == 'BILL_MODIFY') {
651
+        } elseif ($action == 'BILL_MODIFY') {
609 652
             dol_syslog(
610 653
                 "Trigger '" . $this->name . "' for action '$action' launched by " . __FILE__ . ". id=" . $object->id
611 654
             );
Please login to merge, or discard this patch.