Passed
Pull Request — master (#114)
by
unknown
02:00
created
class/actions_subtotal.class.php 1 patch
Spacing   +385 added lines, -385 removed lines patch added patch discarded remove patch
@@ -85,43 +85,43 @@  discard block
 block discarded – undo
85 85
     
86 86
     function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
87 87
     {
88
-      	global $langs,$db,$user, $conf;
88
+      	global $langs, $db, $user, $conf;
89 89
 		
90 90
 		$langs->load('subtotal@subtotal');
91 91
 		
92
-		$contexts = explode(':',$parameters['context']);
92
+		$contexts = explode(':', $parameters['context']);
93 93
 		
94
-		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)) {
94
+		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)) {
95 95
 			
96 96
 			$createRight = $user->rights->{$object->element}->creer;
97
-			if($object->element == 'facturerec' )
97
+			if ($object->element == 'facturerec')
98 98
 			{
99 99
 				$object->statut = 0; // hack for facture rec
100 100
 				$createRight = $user->rights->facture->creer;
101
-			} elseif($object->element == 'order_supplier' )
101
+			} elseif ($object->element == 'order_supplier')
102 102
 			{
103 103
 			    $createRight = $user->rights->fournisseur->commande->creer;
104
-			} elseif($object->element == 'invoice_supplier' )
104
+			} elseif ($object->element == 'invoice_supplier')
105 105
 			{
106 106
 			    $createRight = $user->rights->fournisseur->facture->creer;
107 107
 			}
108 108
 			
109
-			if ($object->statut == 0  && $createRight) {
109
+			if ($object->statut == 0 && $createRight) {
110 110
 			
111 111
 
112
-				if($object->element=='facture')$idvar = 'facid';
113
-				else $idvar='id';
112
+				if ($object->element == 'facture')$idvar = 'facid';
113
+				else $idvar = 'id';
114 114
 				
115
-				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
115
+				if (in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')))
116 116
 				{
117 117
 					$level = GETPOST('level', 'int'); //New avec SUBTOTAL_USE_NEW_FORMAT
118 118
 					
119
-					if($action=='add_title_line') {
119
+					if ($action == 'add_title_line') {
120 120
 						$title = GETPOST('title');
121
-						if(empty($title)) $title = $langs->trans('title');
122
-						$qty = $level<1 ? 1 : $level ;
121
+						if (empty($title)) $title = $langs->trans('title');
122
+						$qty = $level < 1 ? 1 : $level;
123 123
 					}
124
-					else if($action=='add_free_text') {
124
+					else if ($action == 'add_free_text') {
125 125
 						$title = GETPOST('title');
126 126
 
127 127
 						if (empty($title)) {
@@ -133,21 +133,21 @@  discard block
 block discarded – undo
133 133
 								}
134 134
 							}
135 135
 						}
136
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
136
+						if (empty($title)) $title = $langs->trans('subtotalAddLineDescription');
137 137
 						$qty = 50;
138 138
 					}
139
-					else if($action=='add_subtitle_line') {
139
+					else if ($action == 'add_subtitle_line') {
140 140
 						$title = GETPOST('title');
141
-						if(empty($title)) $title = $langs->trans('subtitle');
141
+						if (empty($title)) $title = $langs->trans('subtitle');
142 142
 						$qty = 2;
143 143
 					}
144
-					else if($action=='add_subtotal_line') {
144
+					else if ($action == 'add_subtotal_line') {
145 145
 						$title = $langs->trans('SubSubTotal');
146 146
 						$qty = 98;
147 147
 					}
148 148
 					else {
149 149
 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
150
-						$qty = $level ? 100-$level : 99;
150
+						$qty = $level ? 100 - $level : 99;
151 151
 					}
152 152
 					dol_include_once('/subtotal/class/subtotal.class.php');
153 153
 					
@@ -155,15 +155,15 @@  discard block
 block discarded – undo
155 155
 					
156 156
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
157 157
 				}
158
-				else if($action==='ask_deleteallline') {
159
-						$form=new Form($db);
158
+				else if ($action === 'ask_deleteallline') {
159
+						$form = new Form($db);
160 160
 						
161
-						$lineid = GETPOST('lineid','integer');
161
+						$lineid = GETPOST('lineid', 'integer');
162 162
 						$TIdForGroup = $this->getArrayOfLineForAGroup($object, $lineid);
163 163
 					
164 164
 						$nbLines = count($TIdForGroup);
165 165
 					
166
-						$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines',$nbLines), 'confirm_delete_all_lines','',0,1);
166
+						$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines', $nbLines), 'confirm_delete_all_lines', '', 0, 1);
167 167
 						print $formconfirm;
168 168
 				}
169 169
 
@@ -173,13 +173,13 @@  discard block
 block discarded – undo
173 173
 				}
174 174
 
175 175
 				
176
-				if($action!='editline') {
176
+				if ($action != 'editline') {
177 177
 					// New format is for 3.8
178 178
 					$this->printNewFormat($object, $conf, $langs, $idvar);
179 179
 				}
180 180
 			}
181 181
 		}
182
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
182
+		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice', $contexts))
183 183
 		{
184 184
 			?>
185 185
 			<script type="text/javascript">
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 				$(document).ready(function() {
205 205
 					$('div.fiche div.tabsAction').append('<br />');
206 206
 					
207
-					$('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>');
207
+					$('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>');
208 208
 					$('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>');
209 209
 					$('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>');
210 210
 
@@ -255,9 +255,9 @@  discard block
 block discarded – undo
255 255
 						$('body').append(dialog_html);
256 256
 
257 257
 						<?php 
258
-						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME)?'ckeditor':$conf->global->FCKEDITOR_EDITORNAME;
259
-						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
260
-						if($editorConf && in_array($editorTool,array('textarea','ckeditor'))){ 
258
+						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME) ? 'ckeditor' : $conf->global->FCKEDITOR_EDITORNAME;
259
+						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
260
+						if ($editorConf && in_array($editorTool, array('textarea', 'ckeditor'))) { 
261 261
 						?>
262 262
 						if (action == 'addTitle' || action == 'addFreeTxt')
263 263
 						{
@@ -372,62 +372,62 @@  discard block
 block discarded – undo
372 372
 		global $conf, $langs, $bc;
373 373
 			
374 374
 		$action = GETPOST('action');	
375
-		$TContext = explode(':',$parameters['context']);
375
+		$TContext = explode(':', $parameters['context']);
376 376
 		if (
377
-				in_array('invoicecard',$TContext)
378
-		        || in_array('invoicesuppliercard',$TContext)
379
-				|| in_array('propalcard',$TContext)
380
-				|| in_array('ordercard',$TContext)
381
-		        || in_array('ordersuppliercard',$TContext)
382
-				|| in_array('invoicereccard',$TContext)
377
+				in_array('invoicecard', $TContext)
378
+		        || in_array('invoicesuppliercard', $TContext)
379
+				|| in_array('propalcard', $TContext)
380
+				|| in_array('ordercard', $TContext)
381
+		        || in_array('ordersuppliercard', $TContext)
382
+				|| in_array('invoicereccard', $TContext)
383 383
 			)
384 384
 	        {	
385
-				$hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] : 0;
386
-				$hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] : 0;
387
-				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0;
388
-				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] : $hidepricesDefaultConf;
385
+				$hideInnerLines = isset($_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']]) ? $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] : 0;
386
+				$hidedetails = isset($_SESSION['subtotal_hidedetails_'.$parameters['modulepart']]) ? $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] : 0;
387
+				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED) ? $conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED : 0;
388
+				$hideprices = isset($_SESSION['subtotal_hideprices_'.$parameters['modulepart']]) ? $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] : $hidepricesDefaultConf;
389 389
 				
390
-				$var=false;
391
-		     	$out.= '<tr '.$bc[$var].'>
390
+				$var = false;
391
+		     	$out .= '<tr '.$bc[$var].'>
392 392
 		     			<td colspan="4" align="right">
393 393
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
394
-		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
394
+		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(($hideInnerLines) ? 'checked="checked"' : '').' />
395 395
 		     			</td>
396 396
 		     			</tr>';
397 397
 				
398
-		     	$var=!$var;
399
-		     	$out.= '<tr '.$bc[$var].'>
398
+		     	$var = !$var;
399
+		     	$out .= '<tr '.$bc[$var].'>
400 400
 		     			<td colspan="4" align="right">
401 401
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
402
-		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
402
+		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(($hidedetails) ? 'checked="checked"' : '').' />
403 403
 		     			</td>
404 404
 		     			</tr>';
405 405
 		     	
406
-		     	$var=!$var;
407
-		     	$out.= '<tr '.$bc[$var].'>
406
+		     	$var = !$var;
407
+		     	$out .= '<tr '.$bc[$var].'>
408 408
 		     			<td colspan="4" align="right">
409 409
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidePrice').'</label>
410
-		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
410
+		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(($hideprices) ? 'checked="checked"' : '').' />
411 411
 		     			</td>
412 412
 		     			</tr>';
413 413
 		     	
414 414
 		     	
415 415
 				 
416 416
 				if ( 
417
-					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
418
-					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
419
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
420
-					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
421
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
422
-					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
417
+					(in_array('propalcard', $TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
418
+					|| (in_array('ordercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
419
+				    || (in_array('ordersuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
420
+					|| (in_array('invoicecard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
421
+				    || (in_array('invoicesuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
422
+					|| (in_array('invoicereccard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
423 423
 				)
424 424
 				{
425
-					$var=!$var;
426
-					$out.= '
425
+					$var = !$var;
426
+					$out .= '
427 427
 						<tr '.$bc[$var].'>
428 428
 							<td colspan="4" align="right">
429 429
 								<label for="subtotal_add_recap">'.$langs->trans('subtotal_add_recap').'</label>
430
-								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.( GETPOST('subtotal_add_recap') ? 'checked="checked"' : '' ).' />
430
+								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.(GETPOST('subtotal_add_recap') ? 'checked="checked"' : '').' />
431 431
 							</td>
432 432
 						</tr>';
433 433
 				}
@@ -443,7 +443,7 @@  discard block
 block discarded – undo
443 443
     function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
444 444
     {
445 445
 		
446
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
446
+    	if (in_array('invoicecard', explode(':', $parameters['context'])))
447 447
         {
448 448
         	
449 449
         }
@@ -454,13 +454,13 @@  discard block
 block discarded – undo
454 454
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
455 455
 		global $conf;
456 456
 		
457
-		if($action === 'builddoc') {
457
+		if ($action === 'builddoc') {
458 458
 			
459 459
 			$line = &$parameters['line'];
460 460
 			$object = &$parameters['object'];
461 461
 			$substitutionarray = &$parameters['substitutionarray'];
462 462
 			
463
-			if($line->product_type == 9 && $line->special_code == $this->module_number) {
463
+			if ($line->product_type == 9 && $line->special_code == $this->module_number) {
464 464
 				$substitutionarray['line_modsubtotal'] = 1;	
465 465
 				
466 466
 				$substitutionarray['line_price_ht']
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 					 = $substitutionarray['line_up'] 
472 472
 					 = '';
473 473
 				
474
-				if($line->qty>90) {
474
+				if ($line->qty > 90) {
475 475
 					$substitutionarray['line_modsubtotal_total'] = true;
476 476
 					
477 477
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 				
486 486
 				
487 487
 			}	
488
-			else{
488
+			else {
489 489
 				$substitutionarray['line_not_modsubtotal'] = true;
490 490
 				$substitutionarray['line_modsubtotal'] = 0;
491 491
 			}
@@ -497,29 +497,29 @@  discard block
 block discarded – undo
497 497
 	function createFrom($parameters, &$object, $action, $hookmanager) {
498 498
 	
499 499
 		if (
500
-				in_array('invoicecard',explode(':',$parameters['context']))
501
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
502
-				|| in_array('propalcard',explode(':',$parameters['context']))
503
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
504
-				|| in_array('ordercard',explode(':',$parameters['context']))
505
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
506
-				|| in_array('invoicereccard',explode(':',$parameters['context']))
500
+				in_array('invoicecard', explode(':', $parameters['context']))
501
+		        || in_array('invoicesuppliercard', explode(':', $parameters['context']))
502
+				|| in_array('propalcard', explode(':', $parameters['context']))
503
+		        || in_array('supplier_proposalcard', explode(':', $parameters['context']))
504
+				|| in_array('ordercard', explode(':', $parameters['context']))
505
+		        || in_array('ordersuppliercard', explode(':', $parameters['context']))
506
+				|| in_array('invoicereccard', explode(':', $parameters['context']))
507 507
 		) {
508 508
 			
509 509
 			global $db;
510 510
 			
511 511
 			$objFrom = $parameters['objFrom'];
512 512
 			
513
-			foreach($objFrom->lines as $k=> &$lineOld) {
513
+			foreach ($objFrom->lines as $k=> &$lineOld) {
514 514
 				
515
-					if($lineOld->product_type == 9 && $lineOld->info_bits > 0 ) {
515
+					if ($lineOld->product_type == 9 && $lineOld->info_bits > 0) {
516 516
 							
517 517
 							$line = & $object->lines[$k];
518 518
 				
519 519
 							$idLine = (int) ($line->id ? $line->id : $line->rowid); 
520 520
 				
521 521
 							$db->query("UPDATE ".MAIN_DB_PREFIX.$line->table_element."
522
-							SET info_bits=".(int)$lineOld->info_bits."
522
+							SET info_bits=".(int) $lineOld->info_bits."
523 523
 							WHERE rowid = ".$idLine."
524 524
 							");
525 525
 						
@@ -535,15 +535,15 @@  discard block
 block discarded – undo
535 535
 	
536 536
 	function doActions($parameters, &$object, $action, $hookmanager)
537 537
 	{
538
-		global $db, $conf, $langs,$user;
538
+		global $db, $conf, $langs, $user;
539 539
 		
540 540
 		dol_include_once('/subtotal/class/subtotal.class.php');
541 541
 		dol_include_once('/subtotal/lib/subtotal.lib.php');
542
-		require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
542
+		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
543 543
 		
544 544
 		$showBlockExtrafields = GETPOST('showBlockExtrafields');
545 545
 		
546
-		if($object->element=='facture') $idvar = 'facid';
546
+		if ($object->element == 'facture') $idvar = 'facid';
547 547
 		else $idvar = 'id';
548 548
 			
549 549
 		if ($action == 'updateligne' || $action == 'updateline')
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 				if ($line->id == $lineid && TSubtotal::isModSubtotalLine($line))
557 557
 				{
558 558
 					$found = true;
559
-					if(TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
559
+					if (TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
560 560
 						$extrafieldsline = new ExtraFields($db);
561 561
 						$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
562 562
 						$extrafieldsline->setOptionalsFromPost($extralabelsline, $line);
@@ -575,43 +575,43 @@  discard block
 block discarded – undo
575 575
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
576 576
 			}
577 577
 		}
578
-		else if($action === 'builddoc') {
578
+		else if ($action === 'builddoc') {
579 579
 			
580 580
 			if (
581
-				in_array('invoicecard',explode(':',$parameters['context']))
582
-				|| in_array('propalcard',explode(':',$parameters['context']))
583
-				|| in_array('ordercard',explode(':',$parameters['context']))
584
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
585
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
586
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
581
+				in_array('invoicecard', explode(':', $parameters['context']))
582
+				|| in_array('propalcard', explode(':', $parameters['context']))
583
+				|| in_array('ordercard', explode(':', $parameters['context']))
584
+			    || in_array('ordersuppliercard', explode(':', $parameters['context']))
585
+			    || in_array('invoicesuppliercard', explode(':', $parameters['context']))
586
+			    || in_array('supplier_proposalcard', explode(':', $parameters['context']))
587 587
 			)
588 588
 	        {								
589
-				if(in_array('invoicecard',explode(':',$parameters['context']))) {
589
+				if (in_array('invoicecard', explode(':', $parameters['context']))) {
590 590
 					$sessname = 'subtotal_hideInnerLines_facture';	
591 591
 					$sessname2 = 'subtotal_hidedetails_facture';
592 592
 					$sessname3 = 'subtotal_hideprices_facture';
593 593
 				}
594
-				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
594
+				elseif (in_array('invoicesuppliercard', explode(':', $parameters['context']))) {
595 595
 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
596 596
 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
597 597
 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
598 598
 				}
599
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
599
+				elseif (in_array('propalcard', explode(':', $parameters['context']))) {
600 600
 					$sessname = 'subtotal_hideInnerLines_propal';
601 601
 					$sessname2 = 'subtotal_hidedetails_propal';	
602 602
 					$sessname3 = 'subtotal_hideprices_propal';
603 603
 				}
604
-				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
604
+				elseif (in_array('supplier_proposalcard', explode(':', $parameters['context']))) {
605 605
 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
606 606
 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
607 607
 				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
608 608
 				}
609
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
609
+				elseif (in_array('ordercard', explode(':', $parameters['context']))) {
610 610
 					$sessname = 'subtotal_hideInnerLines_commande';
611 611
 					$sessname2 = 'subtotal_hidedetails_commande';	
612 612
 					$sessname3 = 'subtotal_hideprices_commande';
613 613
 				}
614
-				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
614
+				elseif (in_array('ordersuppliercard', explode(':', $parameters['context']))) {
615 615
 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
616 616
 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
617 617
 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
@@ -624,22 +624,22 @@  discard block
 block discarded – undo
624 624
 					
625 625
 				global $hideprices;
626 626
 				
627
-				$hideInnerLines = (int)GETPOST('hideInnerLines');
627
+				$hideInnerLines = (int) GETPOST('hideInnerLines');
628 628
 				$_SESSION[$sessname] = $hideInnerLines;		
629 629
 				
630
-				$hidedetails= (int)GETPOST('hidedetails');
630
+				$hidedetails = (int) GETPOST('hidedetails');
631 631
 				$_SESSION[$sessname2] = $hidedetails;
632 632
 				
633
-				$hideprices= (int)GETPOST('hideprices');
633
+				$hideprices = (int) GETPOST('hideprices');
634 634
 				$_SESSION[$sessname3] = $hideprices;
635 635
 				
636
-				foreach($object->lines as &$line) {
636
+				foreach ($object->lines as &$line) {
637 637
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
638 638
 					    
639
-                        if($line->qty>=90) {
639
+                        if ($line->qty >= 90) {
640 640
                             $line->modsubtotal_total = 1;
641 641
                         }
642
-                        else{
642
+                        else {
643 643
                             $line->modsubtotal_title = 1;
644 644
                         }
645 645
                         
@@ -649,34 +649,34 @@  discard block
 block discarded – undo
649 649
 	        }
650 650
 			
651 651
 		}
652
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
652
+		else if ($action === 'confirm_delete_all_lines' && GETPOST('confirm') == 'yes') {
653 653
 			
654 654
 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
655 655
 			
656
-			foreach($Tab as $idLine) {
656
+			foreach ($Tab as $idLine) {
657 657
 				/**
658 658
 				 * @var $object Facture
659 659
 				 */
660
-				if($object->element=='facture') $object->deleteline($idLine);
660
+				if ($object->element == 'facture') $object->deleteline($idLine);
661 661
 				/**
662 662
 				 * @var $object Facture fournisseur
663 663
 				 */
664
-				else if($object->element=='invoice_supplier')
664
+				else if ($object->element == 'invoice_supplier')
665 665
 				{
666 666
 				    $object->deleteline($idLine);
667 667
 				}
668 668
 				/**
669 669
 				 * @var $object Propal
670 670
 				 */
671
-				else if($object->element=='propal') $object->deleteline($idLine);
671
+				else if ($object->element == 'propal') $object->deleteline($idLine);
672 672
 				/**
673 673
 				 * @var $object Propal Fournisseur
674 674
 				 */
675
-				else if($object->element=='supplier_proposal') $object->deleteline($idLine);
675
+				else if ($object->element == 'supplier_proposal') $object->deleteline($idLine);
676 676
 				/**
677 677
 				 * @var $object Commande
678 678
 				 */
679
-				else if($object->element=='commande') 
679
+				else if ($object->element == 'commande') 
680 680
 				{
681 681
 					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
682 682
 					else $object->deleteline($idLine);
@@ -684,14 +684,14 @@  discard block
 block discarded – undo
684 684
 				/**
685 685
 				 * @var $object Commande fournisseur
686 686
 				 */
687
-				else if($object->element=='order_supplier')
687
+				else if ($object->element == 'order_supplier')
688 688
 				{
689 689
 				    $object->deleteline($idLine);
690 690
 				}
691 691
 				/**
692 692
 				 * @var $object Facturerec
693 693
 				 */
694
-				else if($object->element=='facturerec') $object->deleteline($idLine);
694
+				else if ($object->element == 'facturerec') $object->deleteline($idLine);
695 695
 			}
696 696
 			
697 697
 			header('location:?id='.$object->id);
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 		return 0;
715 715
 	}
716 716
 	
717
-	function formAddObjectLine ($parameters, &$object, &$action, $hookmanager) {
717
+	function formAddObjectLine($parameters, &$object, &$action, $hookmanager) {
718 718
 		return 0;
719 719
 	}
720 720
 
@@ -726,22 +726,22 @@  discard block
 block discarded – undo
726 726
 		
727 727
 		$found = false;
728 728
 
729
-		$Tab= array();
729
+		$Tab = array();
730 730
 		
731
-		foreach($object->lines as $l) {
731
+		foreach ($object->lines as $l) {
732 732
 		
733 733
 		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
734
-			if($lid == $lineid) {
734
+			if ($lid == $lineid) {
735 735
 
736 736
 				$found = true;
737 737
 				$qty_line = $l->qty;
738 738
 			}
739 739
 			
740
-			if($found) {
740
+			if ($found) {
741 741
 				
742 742
 			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
743 743
 				
744
-				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
744
+				if ($l->special_code == $this->module_number && (($l->qty == 99 && $qty_line == 1) || ($l->qty == 98 && $qty_line == 2))) {
745 745
 					break; // end of story
746 746
 				}
747 747
 			}
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
 	 * 
771 771
 	 * @param	$use_level		isn't used anymore
772 772
 	 */
773
-	function getTotalLineFromObject(&$object, &$line, $use_level=false, $return_all=0) {
773
+	function getTotalLineFromObject(&$object, &$line, $use_level = false, $return_all = 0) {
774 774
 		
775 775
 		$rang = $line->rang;
776 776
 		$qty_line = $line->qty;
@@ -781,21 +781,21 @@  discard block
 block discarded – undo
781 781
 		$TTotal_tva = array();
782 782
 		
783 783
 		dol_include_once('/subtotal/class/subtotal.class.php');
784
-		foreach($object->lines as $l) {
784
+		foreach ($object->lines as $l) {
785 785
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
786
-			if($l->rang>=$rang) {
786
+			if ($l->rang >= $rang) {
787 787
 				//echo 'return!<br>';
788 788
 				if (!$return_all) return $total;
789 789
 				else return array($total, $total_tva, $total_ttc, $TTotal_tva);
790 790
 			}
791
-			else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
791
+			else if (TSubtotal::isTitle($l, 100 - $qty_line)) 
792 792
 		  	{
793 793
 				$total = 0;
794 794
 				$total_tva = 0;
795 795
 				$total_ttc = 0;
796 796
 				$TTotal_tva = array();
797 797
 			}
798
-			elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
798
+			elseif (!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
799 799
 				$total += $l->total_ht;
800 800
 				$total_tva += $l->total_tva;
801 801
 				$TTotal_tva[$l->tva_tx] += $l->total_tva;
@@ -814,18 +814,18 @@  discard block
 block discarded – undo
814 814
 		
815 815
 		$rang = $line->rang;
816 816
 		$total = 0;
817
-		foreach($object->lines as $l) {
818
-			if($l->rang>=$rang) {
817
+		foreach ($object->lines as $l) {
818
+			if ($l->rang >= $rang) {
819 819
 				return price($total);
820 820
 			}
821
-                        if (TSubtotal::isSubtotal($l)){
821
+                        if (TSubtotal::isSubtotal($l)) {
822 822
                             $total = 0;
823
-                        } else  if ($l->situation_percent > 0 ){
823
+                        } else  if ($l->situation_percent > 0) {
824 824
                            
825 825
         	
826 826
 		 	$prev_progress = $l->get_prev_progress($object->id);
827
-		 	$progress = ($l->situation_percent - $prev_progress) /100;
828
-                        $total += ($l->total_ht/($l->situation_percent/100)) * $progress;
827
+		 	$progress = ($l->situation_percent - $prev_progress) / 100;
828
+                        $total += ($l->total_ht / ($l->situation_percent / 100)) * $progress;
829 829
                         
830 830
                     }
831 831
                 }
@@ -844,10 +844,10 @@  discard block
 block discarded – undo
844 844
 	 * @param $w            float               width
845 845
 	 * @param $h            float               height
846 846
 	 */
847
-	function pdf_add_total(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
848
-		global $conf,$subtotal_last_title_posy;
847
+	function pdf_add_total(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
848
+		global $conf, $subtotal_last_title_posy;
849 849
 		
850
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
850
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
851 851
 		if (!empty($conf->global->SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES) && $hideInnerLines && !empty($subtotal_last_title_posy))
852 852
 		{
853 853
 			$posy = $subtotal_last_title_posy;
@@ -857,34 +857,34 @@  discard block
 block discarded – undo
857 857
 		$hidePriceOnSubtotalLines = (int) GETPOST('hide_price_on_subtotal_lines');
858 858
 		
859 859
 		$set_pagebreak_margin = false;
860
-		if(method_exists('Closure','bind')) {
860
+		if (method_exists('Closure', 'bind')) {
861 861
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
862
-			$sweetsThief = function ($pdf) {
863
-		    		return $pdf->bMargin ;
862
+			$sweetsThief = function($pdf) {
863
+		    		return $pdf->bMargin;
864 864
 			};
865 865
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
866 866
 	
867
-			$bMargin  = $sweetsThief($pdf);
867
+			$bMargin = $sweetsThief($pdf);
868 868
 	
869
-			$pdf->SetAutoPageBreak( false );
869
+			$pdf->SetAutoPageBreak(false);
870 870
 
871 871
 			$set_pagebreak_margin = true;			
872 872
 		}
873 873
 		
874 874
 			
875
-		if($line->qty==99)
876
-			$pdf->SetFillColor(220,220,220);
877
-		elseif ($line->qty==98)
878
-			$pdf->SetFillColor(230,230,230);
875
+		if ($line->qty == 99)
876
+			$pdf->SetFillColor(220, 220, 220);
877
+		elseif ($line->qty == 98)
878
+			$pdf->SetFillColor(230, 230, 230);
879 879
 		else
880
-			$pdf->SetFillColor(240,240,240);
880
+			$pdf->SetFillColor(240, 240, 240);
881 881
 		
882 882
 		$style = 'B';
883 883
 		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
884 884
 		
885 885
 		$pdf->SetFont('', $style, 9);
886 886
 		
887
-		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R',true);
887
+		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R', true);
888 888
 //		var_dump($bMargin);
889 889
 		$pageAfter = $pdf->getPage();
890 890
 		
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
 				}
910 910
 			}
911 911
 			
912
-			if($total_to_print) {
912
+			if ($total_to_print) {
913 913
 				
914 914
 				if (GETPOST('hideInnerLines'))
915 915
 				{
@@ -923,7 +923,7 @@  discard block
 block discarded – undo
923 923
 				else
924 924
 				{
925 925
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
926
-                                        if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
926
+                                        if (get_class($object) == 'Facture' && $object->type == Facture::TYPE_SITUATION) {//Facture de situation
927 927
                                                 $total_to_print = $this->getTotalToPrintSituation($object, $line);
928 928
                                         } else {
929 929
                                             	$total_to_print = price($total);
@@ -937,11 +937,11 @@  discard block
 block discarded – undo
937 937
 			}
938 938
 
939 939
 			$pdf->SetXY($pdf->postotalht, $posy);
940
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
941
-			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
940
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
941
+			$pdf->MultiCell($pdf->page_largeur - $pdf->marge_droite - $pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
942 942
 		}
943
-		else{
944
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
943
+		else {
944
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
945 945
 		}
946 946
 		
947 947
 		$posy = $posy + $cell_height;
@@ -961,22 +961,22 @@  discard block
 block discarded – undo
961 961
 	 * @param $w            float               width
962 962
 	 * @param $h            float               height
963 963
 	 */
964
-	function pdf_add_title(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
964
+	function pdf_add_title(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
965 965
 		
966
-		global $db,$conf,$subtotal_last_title_posy;
966
+		global $db, $conf, $subtotal_last_title_posy;
967 967
 		
968 968
 		$subtotal_last_title_posy = $posy;
969
-		$pdf->SetXY ($posx, $posy);
969
+		$pdf->SetXY($posx, $posy);
970 970
 		
971
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
971
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
972 972
 		
973 973
 		
974 974
  
975
-		$style = ($line->qty==1) ? 'BU' : 'BUI';
975
+		$style = ($line->qty == 1) ? 'BU' : 'BUI';
976 976
 		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
977 977
 		
978
-		if($hideInnerLines) {
979
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
978
+		if ($hideInnerLines) {
979
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9);
980 980
 			else 
981 981
 			{
982 982
 				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
@@ -985,43 +985,43 @@  discard block
 block discarded – undo
985 985
 		}
986 986
 		else {
987 987
 
988
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
988
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9); //TODO if super utile
989 989
 			else $pdf->SetFont('', $style, 9);
990 990
 			
991 991
 		}
992 992
 		
993 993
 		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
994
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
994
+		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J', true); // et maintenant avec du HTML
995 995
 		
996
-		if($description && !$hidedesc) {
996
+		if ($description && !$hidedesc) {
997 997
 			$posy = $pdf->GetY();
998 998
 			
999 999
 			$pdf->SetFont('', '', 8);
1000 1000
 			
1001
-			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J',true);
1001
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J', true);
1002 1002
 
1003 1003
 		}
1004 1004
 		
1005 1005
 	}
1006 1006
 
1007
-	function pdf_writelinedesc_ref($parameters=array(), &$object, &$action='') {
1007
+	function pdf_writelinedesc_ref($parameters = array(), &$object, &$action = '') {
1008 1008
 	// ultimate PDF hook O_o
1009 1009
 		
1010
-		return $this->pdf_writelinedesc($parameters,$object,$action);
1010
+		return $this->pdf_writelinedesc($parameters, $object, $action);
1011 1011
 		
1012 1012
 	}
1013 1013
 
1014 1014
 	function isModSubtotalLine(&$parameters, &$object) {
1015 1015
 		
1016
-		if(is_array($parameters)) {
1016
+		if (is_array($parameters)) {
1017 1017
 			$i = & $parameters['i'];	
1018 1018
 		}
1019 1019
 		else {
1020
-			$i = (int)$parameters;
1020
+			$i = (int) $parameters;
1021 1021
 		}
1022 1022
 		
1023 1023
 		
1024
-		if($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) {
1024
+		if ($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) {
1025 1025
 			return true;
1026 1026
 		}
1027 1027
 		
@@ -1029,43 +1029,43 @@  discard block
 block discarded – undo
1029 1029
 		
1030 1030
 	}
1031 1031
 
1032
-	function pdf_getlineqty($parameters=array(), &$object, &$action='') {
1033
-		global $conf,$hideprices;
1032
+	function pdf_getlineqty($parameters = array(), &$object, &$action = '') {
1033
+		global $conf, $hideprices;
1034 1034
 		
1035
-		if($this->isModSubtotalLine($parameters,$object) ){
1035
+		if ($this->isModSubtotalLine($parameters, $object)) {
1036 1036
 			
1037 1037
 			$this->resprints = ' ';
1038 1038
 			
1039
-			if((float)DOL_VERSION<=3.6) {
1039
+			if ((float) DOL_VERSION <= 3.6) {
1040 1040
 				return '';
1041 1041
 			}
1042
-			else if((float)DOL_VERSION>=3.8) {
1042
+			else if ((float) DOL_VERSION >= 3.8) {
1043 1043
 				return 1;
1044 1044
 			}
1045 1045
 			
1046 1046
 		}
1047
-		elseif(!empty($hideprices)) {
1047
+		elseif (!empty($hideprices)) {
1048 1048
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1049 1049
 			return 1;
1050 1050
 		}
1051 1051
 		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1052 1052
 		{
1053
-			$hideInnerLines = (int)GETPOST('hideInnerLines');
1054
-			$hidedetails = (int)GETPOST('hidedetails');
1053
+			$hideInnerLines = (int) GETPOST('hideInnerLines');
1054
+			$hidedetails = (int) GETPOST('hidedetails');
1055 1055
 			if (empty($hideInnerLines) && !empty($hidedetails))
1056 1056
 			{
1057 1057
 				$this->resprints = $object->lines[$parameters['i']]->qty;
1058 1058
 			}
1059 1059
 		}
1060 1060
 		
1061
-		if(is_array($parameters)) $i = & $parameters['i'];
1062
-		else $i = (int)$parameters;
1061
+		if (is_array($parameters)) $i = & $parameters['i'];
1062
+		else $i = (int) $parameters;
1063 1063
 
1064 1064
 		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)
1065 1065
 		
1066
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1066
+		if (empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1067 1067
 
1068
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1068
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1069 1069
 		{
1070 1070
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1071 1071
 			{
@@ -1077,25 +1077,25 @@  discard block
 block discarded – undo
1077 1077
 		return 0;
1078 1078
 	}
1079 1079
 	
1080
-	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1080
+	function pdf_getlinetotalexcltax($parameters = array(), &$object, &$action = '') {
1081 1081
 	    global $conf, $hideprices, $hookmanager;
1082 1082
 		
1083
-		if($this->isModSubtotalLine($parameters,$object) ){
1083
+		if ($this->isModSubtotalLine($parameters, $object)) {
1084 1084
 			
1085 1085
 			$this->resprints = ' ';
1086 1086
 			
1087
-			if((float)DOL_VERSION<=3.6) {
1087
+			if ((float) DOL_VERSION <= 3.6) {
1088 1088
 				return '';
1089 1089
 			}
1090
-			else if((float)DOL_VERSION>=3.8) {
1090
+			else if ((float) DOL_VERSION >= 3.8) {
1091 1091
 				return 1;
1092 1092
 			}
1093 1093
 			
1094 1094
 		}
1095 1095
 		elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1096 1096
 		{
1097
-			if(is_array($parameters)) $i = & $parameters['i'];
1098
-			else $i = (int)$parameters;
1097
+			if (is_array($parameters)) $i = & $parameters['i'];
1098
+			else $i = (int) $parameters;
1099 1099
 			
1100 1100
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1101 1101
 			{
@@ -1116,9 +1116,9 @@  discard block
 block discarded – undo
1116 1116
 				}
1117 1117
 			}
1118 1118
 		}
1119
-		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1120
-		    if(is_array($parameters)) $i = & $parameters['i'];
1121
-		    else $i = (int)$parameters;
1119
+		if ((int) GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) {
1120
+		    if (is_array($parameters)) $i = & $parameters['i'];
1121
+		    else $i = (int) $parameters;
1122 1122
 		    $this->resprints = price($object->lines[$i]->total_ht);
1123 1123
 		}
1124 1124
 		
@@ -1141,12 +1141,12 @@  discard block
 block discarded – undo
1141 1141
 		// Cache le prix pour les lignes standards dolibarr qui sont dans un ensemble
1142 1142
 		else if (!empty($hideprices))
1143 1143
 		{
1144
-			if(is_array($parameters)) $i = & $parameters['i'];
1145
-			else $i = (int)$parameters;
1144
+			if (is_array($parameters)) $i = & $parameters['i'];
1145
+			else $i = (int) $parameters;
1146 1146
 
1147 1147
 			// Check if a title exist for this line && if the title have subtotal
1148 1148
 			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1149
-			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1149
+			if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1150 1150
 			{
1151 1151
 
1152 1152
 				$this->resprints = ' ';
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
 	 */
1167 1167
 	function call_hook(&$object, &$hookmanager, $action, $params)
1168 1168
 	{
1169
-		$reshook=$hookmanager->executeHooks('subtotalHidePrices',$params, $object, $action);
1169
+		$reshook = $hookmanager->executeHooks('subtotalHidePrices', $params, $object, $action);
1170 1170
 		if ($reshook < 0)
1171 1171
 		{
1172 1172
 			$this->error = $hookmanager->error;
@@ -1182,7 +1182,7 @@  discard block
 block discarded – undo
1182 1182
 			$this->resprints = $hookmanager->resprints;
1183 1183
 
1184 1184
 			// override return (use  $this->results['overrideReturn'] or $this->resArray['overrideReturn'] in other module action_xxxx.class.php )
1185
-			if(isset($hookmanager->resArray['overrideReturn']))
1185
+			if (isset($hookmanager->resArray['overrideReturn']))
1186 1186
 			{
1187 1187
 				return $hookmanager->resArray['overrideReturn'];
1188 1188
 			}
@@ -1191,25 +1191,25 @@  discard block
 block discarded – undo
1191 1191
 		return 1;
1192 1192
 	}
1193 1193
 	
1194
-	function pdf_getlinetotalwithtax($parameters=array(), &$object, &$action='') {
1194
+	function pdf_getlinetotalwithtax($parameters = array(), &$object, &$action = '') {
1195 1195
 		global $conf;
1196 1196
 		
1197
-		if($this->isModSubtotalLine($parameters,$object) ){
1197
+		if ($this->isModSubtotalLine($parameters, $object)) {
1198 1198
 			
1199 1199
 			$this->resprints = ' ';
1200 1200
 		
1201
-			if((float)DOL_VERSION<=3.6) {
1201
+			if ((float) DOL_VERSION <= 3.6) {
1202 1202
 				return '';
1203 1203
 			}
1204
-			else if((float)DOL_VERSION>=3.8) {
1204
+			else if ((float) DOL_VERSION >= 3.8) {
1205 1205
 				return 1;
1206 1206
 			}
1207 1207
 		}
1208 1208
 		
1209
-		if(is_array($parameters)) $i = & $parameters['i'];
1210
-		else $i = (int)$parameters;
1209
+		if (is_array($parameters)) $i = & $parameters['i'];
1210
+		else $i = (int) $parameters;
1211 1211
 		
1212
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1212
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))) 
1213 1213
 		{
1214 1214
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1215 1215
 			{
@@ -1221,24 +1221,24 @@  discard block
 block discarded – undo
1221 1221
 		return 0;
1222 1222
 	}
1223 1223
 	
1224
-	function pdf_getlineunit($parameters=array(), &$object, &$action='') {
1224
+	function pdf_getlineunit($parameters = array(), &$object, &$action = '') {
1225 1225
 		global $conf;
1226 1226
 		
1227
-		if($this->isModSubtotalLine($parameters,$object) ){
1227
+		if ($this->isModSubtotalLine($parameters, $object)) {
1228 1228
 			$this->resprints = ' ';
1229 1229
 		
1230
-			if((float)DOL_VERSION<=3.6) {
1230
+			if ((float) DOL_VERSION <= 3.6) {
1231 1231
 				return '';
1232 1232
 			}
1233
-			else if((float)DOL_VERSION>=3.8) {
1233
+			else if ((float) DOL_VERSION >= 3.8) {
1234 1234
 				return 1;
1235 1235
 			}
1236 1236
 		}
1237 1237
 		
1238
-		if(is_array($parameters)) $i = & $parameters['i'];
1239
-		else $i = (int)$parameters;
1238
+		if (is_array($parameters)) $i = & $parameters['i'];
1239
+		else $i = (int) $parameters;
1240 1240
 			
1241
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1241
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1242 1242
 		{
1243 1243
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1244 1244
 			{
@@ -1250,24 +1250,24 @@  discard block
 block discarded – undo
1250 1250
 		return 0;
1251 1251
 	}
1252 1252
 	
1253
-	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1254
-		global $conf,$hideprices;
1253
+	function pdf_getlineupexcltax($parameters = array(), &$object, &$action = '') {
1254
+		global $conf, $hideprices;
1255 1255
 
1256
-		if($this->isModSubtotalLine($parameters,$object) ){
1256
+		if ($this->isModSubtotalLine($parameters, $object)) {
1257 1257
 			$this->resprints = ' ';
1258 1258
 		
1259
-			if((float)DOL_VERSION<=3.6) {
1259
+			if ((float) DOL_VERSION <= 3.6) {
1260 1260
 				return '';
1261 1261
 			}
1262
-			else if((float)DOL_VERSION>=3.8) {
1262
+			else if ((float) DOL_VERSION >= 3.8) {
1263 1263
 				return 1;
1264 1264
 			}
1265 1265
 		}
1266
-		if(is_array($parameters)) $i = & $parameters['i'];
1267
-		else $i = (int)$parameters;
1266
+		if (is_array($parameters)) $i = & $parameters['i'];
1267
+		else $i = (int) $parameters;
1268 1268
 		
1269 1269
 		if (!empty($hideprices) 
1270
-				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1270
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1271 1271
 		)
1272 1272
 		{
1273 1273
 			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1280,24 +1280,24 @@  discard block
 block discarded – undo
1280 1280
 		return 0;
1281 1281
 	}
1282 1282
 	
1283
-	function pdf_getlineupwithtax($parameters=array(), &$object, &$action='') {
1284
-		global $conf,$hideprices;
1283
+	function pdf_getlineupwithtax($parameters = array(), &$object, &$action = '') {
1284
+		global $conf, $hideprices;
1285 1285
 		
1286
-		if($this->isModSubtotalLine($parameters,$object) ){
1286
+		if ($this->isModSubtotalLine($parameters, $object)) {
1287 1287
 			$this->resprints = ' ';
1288
-			if((float)DOL_VERSION<=3.6) {
1288
+			if ((float) DOL_VERSION <= 3.6) {
1289 1289
 				return '';
1290 1290
 			}
1291
-			else if((float)DOL_VERSION>=3.8) {
1291
+			else if ((float) DOL_VERSION >= 3.8) {
1292 1292
 				return 1;
1293 1293
 			}
1294 1294
 		}
1295 1295
 		
1296
-		if(is_array($parameters)) $i = & $parameters['i'];
1297
-		else $i = (int)$parameters;
1296
+		if (is_array($parameters)) $i = & $parameters['i'];
1297
+		else $i = (int) $parameters;
1298 1298
 			
1299 1299
 		if (!empty($hideprices)
1300
-				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1300
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1301 1301
 		)
1302 1302
 		{
1303 1303
 			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1310,27 +1310,27 @@  discard block
 block discarded – undo
1310 1310
 		return 0;
1311 1311
 	}
1312 1312
 	
1313
-	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
1313
+	function pdf_getlinevatrate($parameters = array(), &$object, &$action = '') {
1314 1314
 		global $conf;
1315 1315
 		
1316
-		if($this->isModSubtotalLine($parameters,$object) ){
1316
+		if ($this->isModSubtotalLine($parameters, $object)) {
1317 1317
 			$this->resprints = ' ';
1318 1318
 			
1319
-			if((float)DOL_VERSION<=3.6) {
1319
+			if ((float) DOL_VERSION <= 3.6) {
1320 1320
 				return '';
1321 1321
 			}
1322
-			else if((float)DOL_VERSION>=3.8) {
1322
+			else if ((float) DOL_VERSION >= 3.8) {
1323 1323
 				return 1;
1324 1324
 			}
1325 1325
 		}
1326 1326
 		
1327
-		if(is_array($parameters)) $i = & $parameters['i'];
1328
-		else $i = (int)$parameters;
1327
+		if (is_array($parameters)) $i = & $parameters['i'];
1328
+		else $i = (int) $parameters;
1329 1329
 		
1330 1330
 		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)
1331 1331
 
1332 1332
 		$object->lines[$i]->fetch_optionals();
1333
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1333
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1334 1334
 		{
1335 1335
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1336 1336
 			{
@@ -1342,23 +1342,23 @@  discard block
 block discarded – undo
1342 1342
 		return 0;
1343 1343
 	}
1344 1344
 		
1345
-	function pdf_getlineprogress($parameters=array(), &$object, &$action) {
1345
+	function pdf_getlineprogress($parameters = array(), &$object, &$action) {
1346 1346
 		global $conf;
1347 1347
 		
1348
-		if($this->isModSubtotalLine($parameters,$object) ){
1348
+		if ($this->isModSubtotalLine($parameters, $object)) {
1349 1349
 			$this->resprints = ' ';
1350
-			if((float)DOL_VERSION<=3.6) {
1350
+			if ((float) DOL_VERSION <= 3.6) {
1351 1351
 				return '';
1352 1352
 			}
1353
-			else if((float)DOL_VERSION>=3.8) {
1353
+			else if ((float) DOL_VERSION >= 3.8) {
1354 1354
 				return 1;
1355 1355
 			}
1356 1356
 		}
1357 1357
 		
1358
-		if(is_array($parameters)) $i = & $parameters['i'];
1359
-		else $i = (int)$parameters;
1358
+		if (is_array($parameters)) $i = & $parameters['i'];
1359
+		else $i = (int) $parameters;
1360 1360
 			
1361
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1361
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1362 1362
 		{
1363 1363
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1364 1364
 			{
@@ -1373,12 +1373,12 @@  discard block
 block discarded – undo
1373 1373
 	function add_numerotation(&$object) {
1374 1374
 		global $conf;
1375 1375
 		
1376
-		if(!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1376
+		if (!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1377 1377
 		
1378 1378
 			$TLevelTitre = array();
1379 1379
 			$prevlevel = 0;
1380 1380
 		
1381
-			foreach($object->lines as $k=>&$line) 
1381
+			foreach ($object->lines as $k=>&$line) 
1382 1382
 			{
1383 1383
 				if ($line->id > 0 && $this->isModSubtotalLine($k, $object) && $line->qty <= 10)
1384 1384
 				{
@@ -1392,12 +1392,12 @@  discard block
 block discarded – undo
1392 1392
 	}
1393 1393
 
1394 1394
 	// TODO ne gère pas encore la numération des lignes "Totaux"
1395
-	private function formatNumerotation(&$TLineTitle, $line_reference='', $level=1, $prefix_num=0)
1395
+	private function formatNumerotation(&$TLineTitle, $line_reference = '', $level = 1, $prefix_num = 0)
1396 1396
 	{
1397 1397
 		$TTitle = array();
1398 1398
 		
1399
-		$i=1;
1400
-		$j=0;
1399
+		$i = 1;
1400
+		$j = 0;
1401 1401
 		foreach ($TLineTitle as $k => &$line)
1402 1402
 		{
1403 1403
 			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
@@ -1407,7 +1407,7 @@  discard block
 block discarded – undo
1407 1407
 			{
1408 1408
 				$TTitle[$j]['numerotation'] = ($prefix_num == 0) ? $i : $prefix_num.'.'.$i;
1409 1409
 				//var_dump('Prefix == '.$prefix_num.' // '.$line->desc.' ==> numerotation == '.$TTitle[$j]['numerotation'].'   ###    '.$line->qty .'=='. $level);
1410
-				if (empty($line->label) && (float)DOL_VERSION < 6)
1410
+				if (empty($line->label) && (float) DOL_VERSION < 6)
1411 1411
 				{
1412 1412
 					$line->label = !empty($line->desc) ? $line->desc : $line->description;
1413 1413
 					$line->desc = $line->description = '';
@@ -1433,26 +1433,26 @@  discard block
 block discarded – undo
1433 1433
 	
1434 1434
 	function setDocTVA(&$pdf, &$object) {
1435 1435
 		
1436
-		$hidedetails = (int)GETPOST('hidedetails');
1436
+		$hidedetails = (int) GETPOST('hidedetails');
1437 1437
 		
1438
-		if(empty($hidedetails)) return false;
1438
+		if (empty($hidedetails)) return false;
1439 1439
 		
1440 1440
 		// TODO can't add VAT to document without lines... :-/
1441 1441
 		
1442 1442
 		return true;
1443 1443
 	}
1444 1444
 	
1445
-	function beforePDFCreation($parameters=array(), &$object, &$action)
1445
+	function beforePDFCreation($parameters = array(), &$object, &$action)
1446 1446
 	{
1447 1447
 		/**
1448 1448
 		 * @var $pdf    TCPDF
1449 1449
 		 */
1450
-		global $pdf,$conf, $langs;
1450
+		global $pdf, $conf, $langs;
1451 1451
 
1452 1452
 		// var_dump($object->lines);
1453 1453
 		dol_include_once('/subtotal/class/subtotal.class.php');
1454 1454
 
1455
-		foreach($parameters as $key=>$value) {
1455
+		foreach ($parameters as $key=>$value) {
1456 1456
 			${$key} = $value;
1457 1457
 		}
1458 1458
 		
@@ -1461,25 +1461,25 @@  discard block
 block discarded – undo
1461 1461
 		$this->add_numerotation($object);	
1462 1462
 		
1463 1463
 		
1464
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1465
-		$hidedetails = (int)GETPOST('hidedetails');
1464
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1465
+		$hidedetails = (int) GETPOST('hidedetails');
1466 1466
 		
1467 1467
 		if ($hideInnerLines) { // si c une ligne de titre
1468
-	    	$fk_parent_line=0;
1469
-			$TLines =array();
1468
+	    	$fk_parent_line = 0;
1469
+			$TLines = array();
1470 1470
 		
1471
-			$original_count=count($object->lines);
1471
+			$original_count = count($object->lines);
1472 1472
 		    $TTvas = array(); // tableau de tva
1473 1473
 		    
1474
-			foreach($object->lines as $k=>&$line) 
1474
+			foreach ($object->lines as $k=>&$line) 
1475 1475
 			{
1476 1476
 			    
1477
-				if($line->product_type==9 && $line->rowid>0) 
1477
+				if ($line->product_type == 9 && $line->rowid > 0) 
1478 1478
 				{
1479 1479
 					$fk_parent_line = $line->rowid;
1480 1480
 					
1481 1481
 					// 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
1482
-					if(TSubtotal::isSubtotal($line)) 
1482
+					if (TSubtotal::isSubtotal($line)) 
1483 1483
 					{
1484 1484
 						/*$total = $this->getTotalLineFromObject($object, $line, '');
1485 1485
 						
@@ -1499,22 +1499,22 @@  discard block
 block discarded – undo
1499 1499
 			
1500 1500
 				if ($hideInnerLines)
1501 1501
 				{
1502
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1502
+				    if (!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1503 1503
 				    {
1504
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1504
+				        if ($line->tva_tx != '0.000' && $line->product_type != 9) {
1505 1505
 				            
1506 1506
     				        // on remplit le tableau de tva pour substituer les lignes cachées
1507 1507
     				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1508 1508
     				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1509 1509
     				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1510 1510
     				    }
1511
-    					if($line->product_type==9 && $line->rowid>0)
1511
+    					if ($line->product_type == 9 && $line->rowid > 0)
1512 1512
     					{
1513 1513
     					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1514 1514
     					    // génère des lignes d'affichage des montants HT soumis à tva
1515 1515
     					    $nbtva = count($TTvas);
1516
-    					    if(!empty($nbtva)){
1517
-    					        foreach ($TTvas as $tx =>$val){
1516
+    					    if (!empty($nbtva)) {
1517
+    					        foreach ($TTvas as $tx =>$val) {
1518 1518
     					            $l = clone $line;
1519 1519
     					            $l->product_type = 1;
1520 1520
     					            $l->special_code = '';
@@ -1535,7 +1535,7 @@  discard block
 block discarded – undo
1535 1535
     					}
1536 1536
 				    } else {
1537 1537
 				        
1538
-				        if($line->product_type==9 && $line->rowid>0)
1538
+				        if ($line->product_type == 9 && $line->rowid > 0)
1539 1539
 				        {
1540 1540
 				            // ajoute la ligne de sous-total
1541 1541
 				            $TLines[] = $line; 
@@ -1563,9 +1563,9 @@  discard block
 block discarded – undo
1563 1563
 			
1564 1564
 			// cas incongru où il y aurait des produits en dessous du dernier sous-total
1565 1565
 			$nbtva = count($TTvas);
1566
-			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1566
+			if (!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1567 1567
 			{
1568
-			    foreach ($TTvas as $tx =>$val){
1568
+			    foreach ($TTvas as $tx =>$val) {
1569 1569
 			        $l = clone $line;
1570 1570
 			        $l->product_type = 1;
1571 1571
 			        $l->special_code = '';
@@ -1582,11 +1582,11 @@  discard block
 block discarded – undo
1582 1582
 			}
1583 1583
 			
1584 1584
 			global $nblignes;
1585
-			$nblignes=count($TLines);
1585
+			$nblignes = count($TLines);
1586 1586
 
1587 1587
 			$object->lines = $TLines;
1588 1588
 			
1589
-			if($i>count($object->lines)) {
1589
+			if ($i > count($object->lines)) {
1590 1590
 				$this->resprints = '';
1591 1591
 				return 0;
1592 1592
 			}
@@ -1595,59 +1595,59 @@  discard block
 block discarded – undo
1595 1595
 		return 0;
1596 1596
 	}
1597 1597
 
1598
-	function pdf_writelinedesc($parameters=array(), &$object, &$action)
1598
+	function pdf_writelinedesc($parameters = array(), &$object, &$action)
1599 1599
 	{
1600 1600
 		/**
1601 1601
 		 * @var $pdf    TCPDF
1602 1602
 		 */
1603
-		global $pdf,$conf;
1603
+		global $pdf, $conf;
1604 1604
 
1605
-		foreach($parameters as $key=>$value) {
1605
+		foreach ($parameters as $key=>$value) {
1606 1606
 			${$key} = $value;
1607 1607
 		}
1608 1608
 		
1609
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1610
-		$hidedetails = (int)GETPOST('hidedetails');
1609
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1610
+		$hidedetails = (int) GETPOST('hidedetails');
1611 1611
 		
1612
-		if($this->isModSubtotalLine($parameters,$object) ){			
1612
+		if ($this->isModSubtotalLine($parameters, $object)) {			
1613 1613
 		
1614 1614
 				global $hideprices;
1615 1615
 				
1616
-				if(!empty($hideprices)) {
1617
-					foreach($object->lines as &$line) {
1618
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1616
+				if (!empty($hideprices)) {
1617
+					foreach ($object->lines as &$line) {
1618
+						if ($line->fk_product_type != 9) $line->fk_parent_line = -1;	
1619 1619
 					}
1620 1620
 				}
1621 1621
 			
1622 1622
 				$line = &$object->lines[$i];
1623 1623
 				
1624
-				if($line->info_bits>0) { // PAGE BREAK
1624
+				if ($line->info_bits > 0) { // PAGE BREAK
1625 1625
 					$pdf->addPage();
1626 1626
 					$posy = $pdf->GetY();
1627 1627
 				}
1628 1628
 				
1629 1629
 				$label = $line->label;
1630
-				$description= !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1630
+				$description = !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1631 1631
 				
1632
-				if(empty($label)) {
1632
+				if (empty($label)) {
1633 1633
 					$label = $description;
1634
-					$description='';
1634
+					$description = '';
1635 1635
 				}
1636 1636
 				
1637
-				if($line->qty>90) {
1637
+				if ($line->qty > 90) {
1638 1638
 					
1639 1639
 					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1640 1640
 					
1641 1641
 					$pageBefore = $pdf->getPage();
1642
-					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1642
+					$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1643 1643
 					$pageAfter = $pdf->getPage();	
1644 1644
 
1645
-					if($pageAfter>$pageBefore) {
1645
+					if ($pageAfter > $pageBefore) {
1646 1646
 						//print "ST $pageAfter>$pageBefore<br>";
1647 1647
 						$pdf->rollbackTransaction(true);	
1648
-						$pdf->addPage('','', true);
1648
+						$pdf->addPage('', '', true);
1649 1649
 						$posy = $pdf->GetY();
1650
-						$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1650
+						$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1651 1651
 						$posy = $pdf->GetY();
1652 1652
 						//print 'add ST'.$pdf->getPage().'<br />';
1653 1653
 					}
@@ -1658,7 +1658,7 @@  discard block
 block discarded – undo
1658 1658
 				else if ($line->qty < 10) {
1659 1659
 					$pageBefore = $pdf->getPage();
1660 1660
 
1661
-					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
1661
+					$this->pdf_add_title($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h); 
1662 1662
 					$pageAfter = $pdf->getPage();	
1663 1663
 
1664 1664
 					
@@ -1733,9 +1733,9 @@  discard block
 block discarded – undo
1733 1733
 	 * @param $hookmanager  HookManager
1734 1734
 	 * @return int
1735 1735
 	 */
1736
-	function printObjectLine ($parameters, &$object, &$action, $hookmanager){
1736
+	function printObjectLine($parameters, &$object, &$action, $hookmanager) {
1737 1737
 		
1738
-		global $conf,$langs,$user,$db,$bc;
1738
+		global $conf, $langs, $user, $db, $bc;
1739 1739
 		
1740 1740
 		$num = &$parameters['num'];
1741 1741
 		$line = &$parameters['line'];
@@ -1743,32 +1743,32 @@  discard block
 block discarded – undo
1743 1743
 		
1744 1744
 		$var = &$parameters['var'];
1745 1745
 
1746
-		$contexts = explode(':',$parameters['context']);
1746
+		$contexts = explode(':', $parameters['context']);
1747 1747
 
1748 1748
 		$createRight = $user->rights->{$object->element}->creer;
1749
-		if($object->element == 'facturerec' )
1749
+		if ($object->element == 'facturerec')
1750 1750
 		{
1751 1751
 			$object->statut = 0; // hack for facture rec
1752 1752
 			$createRight = $user->rights->facture->creer;
1753 1753
 		}
1754
-		elseif($object->element == 'order_supplier' )
1754
+		elseif ($object->element == 'order_supplier')
1755 1755
 		{
1756 1756
 		    $createRight = $user->rights->fournisseur->commande->creer;
1757 1757
 		}
1758
-		elseif($object->element == 'invoice_supplier' )
1758
+		elseif ($object->element == 'invoice_supplier')
1759 1759
 		{
1760 1760
 		    $createRight = $user->rights->fournisseur->facture->creer;
1761 1761
 		}
1762 1762
 		
1763
-		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1763
+		if ($line->special_code != $this->module_number || $line->product_type != 9) {
1764 1764
 			null;
1765 1765
 		}	
1766
-		else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) 
1766
+		else if (in_array('invoicecard', $contexts) || in_array('invoicesuppliercard', $contexts) || in_array('propalcard', $contexts) || in_array('supplier_proposalcard', $contexts) || in_array('ordercard', $contexts) || in_array('ordersuppliercard', $contexts) || in_array('invoicereccard', $contexts)) 
1767 1767
         {
1768
-			if($object->element=='facture')$idvar = 'facid';
1769
-			else $idvar='id';
1768
+			if ($object->element == 'facture')$idvar = 'facid';
1769
+			else $idvar = 'id';
1770 1770
 			
1771
-			if((float)DOL_VERSION <= 3.4)
1771
+			if ((float) DOL_VERSION <= 3.4)
1772 1772
 			{
1773 1773
 				?>
1774 1774
 				<script type="text/javascript">
@@ -1792,20 +1792,20 @@  discard block
 block discarded – undo
1792 1792
 				<?php
1793 1793
 			}
1794 1794
 			
1795
-			if(empty($line->description)) $line->description = $line->desc;
1795
+			if (empty($line->description)) $line->description = $line->desc;
1796 1796
 			
1797 1797
 			$colspan = 5;
1798
-			if($object->element == 'facturerec' ) $colspan = 3;
1799
-			if($object->element == 'order_supplier') $colspan = 3;
1800
-			if($object->element == 'invoice_supplier') $colspan = 4;
1801
-			if($object->element == 'supplier_proposal') $colspan = 4;
1802
-			if(!empty($conf->multicurrency->enabled)) $colspan+=2;
1803
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1804
-			if(!empty($conf->margin->enabled)) $colspan++;
1805
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1806
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1807
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1808
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
1798
+			if ($object->element == 'facturerec') $colspan = 3;
1799
+			if ($object->element == 'order_supplier') $colspan = 3;
1800
+			if ($object->element == 'invoice_supplier') $colspan = 4;
1801
+			if ($object->element == 'supplier_proposal') $colspan = 4;
1802
+			if (!empty($conf->multicurrency->enabled)) $colspan += 2;
1803
+			if ($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1804
+			if (!empty($conf->margin->enabled)) $colspan++;
1805
+			if (!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1806
+			if (!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1807
+			if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1808
+			if (!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
1809 1809
 					
1810 1810
 			/* Titre */
1811 1811
 			//var_dump($line);
@@ -1815,35 +1815,35 @@  discard block
 block discarded – undo
1815 1815
             
1816 1816
 			
1817 1817
 			?>
1818
-			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
1818
+			<tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
1819 1819
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
1820 1820
 					{
1821
-						if($line->qty==99) print 'background:#adadcf';
1822
-						else if($line->qty==98) print 'background:#ddddff;';
1823
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
1824
-						else if($line->qty==1) print 'background:#adadcf;';
1825
-						else if($line->qty==2) print 'background:#ddddff;';
1826
-						else if($line->qty==50) print '';
1821
+						if ($line->qty == 99) print 'background:#adadcf';
1822
+						else if ($line->qty == 98) print 'background:#ddddff;';
1823
+						else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;';
1824
+						else if ($line->qty == 1) print 'background:#adadcf;';
1825
+						else if ($line->qty == 2) print 'background:#ddddff;';
1826
+						else if ($line->qty == 50) print '';
1827 1827
 						else print 'background:#eeeeff;';
1828 1828
 
1829 1829
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
1830 1830
 					}
1831 1831
 					else 
1832 1832
 					{
1833
-						if($line->qty==99) print 'background:#ddffdd';
1834
-						else if($line->qty==98) print 'background:#ddddff;';
1835
-						else if($line->qty==2) print 'background:#eeeeff; ';
1836
-						else if($line->qty==50) print '';
1837
-						else print 'background:#eeffee;' ;
1833
+						if ($line->qty == 99) print 'background:#ddffdd';
1834
+						else if ($line->qty == 98) print 'background:#ddddff;';
1835
+						else if ($line->qty == 2) print 'background:#eeeeff; ';
1836
+						else if ($line->qty == 50) print '';
1837
+						else print 'background:#eeffee;';
1838 1838
 					}
1839 1839
 
1840 1840
 			?>;">
1841 1841
 			
1842
-				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
1843
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
1842
+				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php
1843
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
1844 1844
 
1845
-						$params=array('line'=>$line);
1846
-						$reshook=$hookmanager->executeHooks('formEditProductOptions',$params,$object,$action);
1845
+						$params = array('line'=>$line);
1846
+						$reshook = $hookmanager->executeHooks('formEditProductOptions', $params, $object, $action);
1847 1847
 						
1848 1848
 						echo '<div id="line_'.$line->id.'"></div>'; // Imitation Dolibarr
1849 1849
 						echo '<input type="hidden" value="'.$line->id.'" name="lineid">';
@@ -1851,7 +1851,7 @@  discard block
 block discarded – undo
1851 1851
 						echo '<input id="product_id" type="hidden" value="'.$line->fk_product.'" name="type">';
1852 1852
 						echo '<input id="special_code" type="hidden" value="'.$line->special_code.'" name="type">';
1853 1853
 
1854
-						$isFreeText=false;
1854
+						$isFreeText = false;
1855 1855
 						if (TSubtotal::isTitle($line))
1856 1856
 						{
1857 1857
 							$qty_displayed = $line->qty;
@@ -1873,13 +1873,13 @@  discard block
 block discarded – undo
1873 1873
 						    $line->description = '';
1874 1874
 						}
1875 1875
 						$newlabel = $line->label;
1876
-						if($line->label=='' && !$isFreeText) {
1877
-							if(TSubtotal::isSubtotal($line)) {
1876
+						if ($line->label == '' && !$isFreeText) {
1877
+							if (TSubtotal::isSubtotal($line)) {
1878 1878
 								$newlabel = $line->description.' '.$this->getTitle($object, $line);
1879
-								$line->description='';
1880
-							} elseif( (float)DOL_VERSION < 6 ) {
1881
-								$newlabel= $line->description;
1882
-								$line->description='';
1879
+								$line->description = '';
1880
+							} elseif ((float) DOL_VERSION < 6) {
1881
+								$newlabel = $line->description;
1882
+								$line->description = '';
1883 1883
 							}
1884 1884
 						}
1885 1885
 
@@ -1888,10 +1888,10 @@  discard block
 block discarded – undo
1888 1888
 						
1889 1889
 						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
1890 1890
 						
1891
-						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
1891
+						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)))
1892 1892
 						{
1893 1893
 							$select = '<select name="subtotal_level">';
1894
-							for ($j=1; $j<10; $j++)
1894
+							for ($j = 1; $j < 10; $j++)
1895 1895
 							{
1896 1896
 								if (!empty($readonlyForSituation)) {
1897 1897
 									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
@@ -1904,7 +1904,7 @@  discard block
 block discarded – undo
1904 1904
 						
1905 1905
 
1906 1906
 						echo '<div class="subtotal_underline" style="margin-left:24px;">';
1907
-							echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label> <input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;&nbsp;';
1907
+							echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label> <input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '').' />&nbsp;&nbsp;';
1908 1908
 
1909 1909
 							if (TSubtotal::isTitle($line))
1910 1910
 							{
@@ -1922,9 +1922,9 @@  discard block
 block discarded – undo
1922 1922
 							else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
1923 1923
 						echo '</div>';
1924 1924
 
1925
-						if($line->qty<10) {
1925
+						if ($line->qty < 10) {
1926 1926
 							// WYSIWYG editor
1927
-							require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
1927
+							require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1928 1928
 							$nbrows = ROWS_2;
1929 1929
 							$cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
1930 1930
 							if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
@@ -1944,25 +1944,25 @@  discard block
 block discarded – undo
1944 1944
 
1945 1945
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
1946 1946
 						 {
1947
-							if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
1947
+							if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
1948 1948
 							{
1949
-								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
1949
+								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
1950 1950
 								
1951 1951
 								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
1952
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
1952
+								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
1953 1953
 							}
1954 1954
 						 }
1955 1955
 						 else 
1956 1956
 						 {
1957
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
1958
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
1957
+							if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal');
1958
+							else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
1959 1959
 						 }
1960 1960
 						 
1961 1961
 						 
1962 1962
 						 // Get display styles and apply them
1963 1963
 						 $titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
1964
-						 $titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
1965
-						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
1964
+						 $titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
1965
+						 $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
1966 1966
 						 
1967 1967
 						 if (empty($line->label)) {
1968 1968
 							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
@@ -1970,16 +1970,16 @@  discard block
 block discarded – undo
1970 1970
 						 } 
1971 1971
 						 else {
1972 1972
 
1973
-							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
1973
+							if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
1974 1974
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
1975 1975
 							}
1976
-							else{
1976
+							else {
1977 1977
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
1978 1978
 							}
1979 1979
 
1980 1980
 						 } 
1981
-						if($line->qty>90) print ' : ';
1982
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
1981
+						if ($line->qty > 90) print ' : ';
1982
+						if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
1983 1983
 
1984 1984
 						 
1985 1985
 
@@ -1988,7 +1988,7 @@  discard block
 block discarded – undo
1988 1988
 			?></td>
1989 1989
 					 
1990 1990
 			<?php
1991
-				if($line->qty>90) {
1991
+				if ($line->qty > 90) {
1992 1992
 					/* Total */
1993 1993
 					$total_line = $this->getTotalLineFromObject($object, $line, '');
1994 1994
 					echo '<td class="nowrap liencolht" align="right" style="font-weight:bold;" rel="subtotal_total">'.price($total_line).'</td>';
@@ -2001,7 +2001,7 @@  discard block
 block discarded – undo
2001 2001
 				<?php
2002 2002
 				if ($action != 'selectlines') {
2003 2003
 				
2004
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
2004
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
2005 2005
 						?>
2006 2006
 						<input id="savelinebutton" class="button" type="submit" name="save" value="<?php echo $langs->trans('Save') ?>" />
2007 2007
 						<br />
@@ -2017,13 +2017,13 @@  discard block
 block discarded – undo
2017 2017
 						<?php
2018 2018
 						
2019 2019
 					}
2020
-					else{
2021
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2020
+					else {
2021
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2022 2022
 						{
2023
-							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2023
+							if (TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref)) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'.img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2024 2024
 						}
2025 2025
 
2026
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
2026
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
2027 2027
 						{
2028 2028
 							echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=editline&lineid='.$line->id.'">'.img_edit().'</a>';
2029 2029
 						}								
@@ -2038,7 +2038,7 @@  discard block
 block discarded – undo
2038 2038
 				<?php
2039 2039
 
2040 2040
 				if ($action != 'editline' && $action != 'selectlines') {
2041
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2041
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2042 2042
 						{
2043 2043
 
2044 2044
 							if ($object->situation_counter == 1 || !$object->situation_cycle_ref)
@@ -2046,7 +2046,7 @@  discard block
 block discarded – undo
2046 2046
 								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteline&lineid='.$line->id.'">'.img_delete().'</a>';
2047 2047
 							}
2048 2048
 
2049
-							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) )
2049
+							if (TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref))
2050 2050
 							{
2051 2051
 								$img_delete = ((float) DOL_VERSION >= 3.8) ? img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal') : img_picto($langs->trans('deleteWithAllLines'), 'delete_all@subtotal');
2052 2052
 								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteallline&lineid='.$line->id.'">'.$img_delete.'</a>';
@@ -2057,7 +2057,7 @@  discard block
 block discarded – undo
2057 2057
 			</td>
2058 2058
 			
2059 2059
 			<?php 
2060
-			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
2060
+			if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
2061 2061
 			{
2062 2062
 				echo '<td class="subtotal_nc">';
2063 2063
 				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"' : '').' />';
@@ -2068,11 +2068,11 @@  discard block
 block discarded – undo
2068 2068
 			<td align="center" class="tdlineupdown">
2069 2069
 			</td>
2070 2070
 			<?php } else { ?>
2071
-			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0  && $createRight ))?' class="tdlineupdown"':''); ?>></td>
2071
+			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0 && $createRight)) ? ' class="tdlineupdown"' : ''); ?>></td>
2072 2072
 			<?php } ?>
2073 2073
 
2074
-			<?php  if($action == 'selectlines'){ // dolibarr 8 ?>
2075
-			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
2074
+			<?php  if ($action == 'selectlines') { // dolibarr 8 ?>
2075
+			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i + 1; ?>]" value="<?php echo $line->id; ?>" ></td>
2076 2076
 			<?php } ?>
2077 2077
 
2078 2078
 			</tr>
@@ -2080,29 +2080,29 @@  discard block
 block discarded – undo
2080 2080
 			
2081 2081
 			
2082 2082
 			// Affichage des extrafields à la Dolibarr (car sinon non affiché sur les titres)
2083
-			if(TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2083
+			if (TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2084 2084
 				
2085
-				require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
2085
+				require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
2086 2086
 				
2087 2087
 				// Extrafields
2088 2088
 				$extrafieldsline = new ExtraFields($db);
2089 2089
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2090 2090
 				
2091
-				$colspan+=3; $mode = 'view';
2092
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2091
+				$colspan += 3; $mode = 'view';
2092
+				if ($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2093 2093
 				
2094 2094
 				$ex_element = $line->element;
2095 2095
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
2096
-				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ','colspan'=>$colspan));
2096
+				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ', 'colspan'=>$colspan));
2097 2097
 				$isExtraSelected = false;
2098
-				foreach($line->array_options as $option) {
2099
-					if(!empty($option) && $option != "-1") {
2098
+				foreach ($line->array_options as $option) {
2099
+					if (!empty($option) && $option != "-1") {
2100 2100
 						$isExtraSelected = true;
2101 2101
 						break;
2102 2102
 					}
2103 2103
 				}
2104 2104
 				
2105
-				if($mode === 'edit') {
2105
+				if ($mode === 'edit') {
2106 2106
 					?>
2107 2107
 					<script>
2108 2108
 						$(document).ready(function(){
@@ -2110,7 +2110,7 @@  discard block
 block discarded – undo
2110 2110
 							var all_tr_extrafields = $("tr.tr_extrafield_title");
2111 2111
 							<?php 
2112 2112
 							// Si un extrafield est rempli alors on affiche directement les extrafields
2113
-							if(!$isExtraSelected) {
2113
+							if (!$isExtraSelected) {
2114 2114
 								echo 'all_tr_extrafields.hide();';
2115 2115
 								echo 'var trad = "'.$langs->trans('showExtrafields').'";';
2116 2116
 								echo 'var extra = 0;';
@@ -2156,20 +2156,20 @@  discard block
 block discarded – undo
2156 2156
 
2157 2157
 	
2158 2158
 	function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) {
2159
-		global $conf,$langs;
2159
+		global $conf, $langs;
2160 2160
 		 
2161 2161
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2162 2162
 		{
2163 2163
 		    
2164
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2164
+		    if ($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2165 2165
 		    {
2166 2166
 		        foreach ($object->lines as $line)
2167 2167
 		        {
2168 2168
 		            // fetch optionals attributes and labels
2169 2169
 		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2170
-		            $extrafields=new ExtraFields($this->db);
2171
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2172
-		            $line->fetch_optionals($line->id,$extralabels);
2170
+		            $extrafields = new ExtraFields($this->db);
2171
+		            $extralabels = $extrafields->fetch_name_optionals_label($object->table_element_line, true);
2172
+		            $line->fetch_optionals($line->id, $extralabels);
2173 2173
 		        }
2174 2174
 		    }
2175 2175
 		    
@@ -2269,23 +2269,23 @@  discard block
 block discarded – undo
2269 2269
 	    $ThtmlData['data-qty']          = 0; //$line->qty;
2270 2270
 	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2271 2271
 	    
2272
-	    if(TSubtotal::isTitle($line)){
2272
+	    if (TSubtotal::isTitle($line)) {
2273 2273
 	        $ThtmlData['data-issubtotal'] = 'title';
2274
-	    }elseif(TSubtotal::isSubtotal($line)){
2274
+	    }elseif (TSubtotal::isSubtotal($line)) {
2275 2275
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2276 2276
 	    }
2277
-	    else{
2277
+	    else {
2278 2278
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2279 2279
 	    }
2280 2280
 	    
2281 2281
 	    
2282 2282
 	    // Change or add data  from hooks
2283
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2283
+	    $parameters = array_replace($parameters, array('ThtmlData' => $ThtmlData));
2284 2284
 	    
2285 2285
 	    // hook 
2286
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2286
+	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2287 2287
 	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2288
-	    if ($reshook>0)
2288
+	    if ($reshook > 0)
2289 2289
 	    {
2290 2290
 	        $ThtmlData = $hookmanager->resArray;
2291 2291
 	    }
@@ -2298,14 +2298,14 @@  discard block
 block discarded – undo
2298 2298
 	function implodeHtmlData($ThtmlData = array())
2299 2299
 	{
2300 2300
 	    $data = '';
2301
-	    foreach($ThtmlData as $k => $h )
2301
+	    foreach ($ThtmlData as $k => $h)
2302 2302
 	    {
2303
-	        if(is_array($h))
2303
+	        if (is_array($h))
2304 2304
 	        {
2305 2305
 	            $h = json_encode($h);
2306 2306
 	        }
2307 2307
 	        
2308
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2308
+	        $data .= $k.'="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2309 2309
 	    }
2310 2310
 	    
2311 2311
 	    return $data;
@@ -2313,26 +2313,26 @@  discard block
 block discarded – undo
2313 2313
 	
2314 2314
 	function _ajax_block_order_js($object)
2315 2315
 	{
2316
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2316
+	    global $conf, $tagidfortablednd, $filepath, $langs;
2317 2317
 	    
2318 2318
 	    /*
2319 2319
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2320 2320
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2321 2321
 	     */
2322 2322
 	    
2323
-	    $id=$object->id;
2324
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2325
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2323
+	    $id = $object->id;
2324
+	    $nboflines = (isset($object->lines) ?count($object->lines) : 0);
2325
+	    $forcereloadpage = empty($conf->global->MAIN_FORCE_RELOAD_PAGE) ? 0 : 1;
2326 2326
 	    
2327
-	    $id=$object->id;
2328
-	    $fk_element=$object->fk_element;
2329
-	    $table_element_line=$object->table_element_line;
2330
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2331
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2332
-	    $filepath=(empty($filepath)?'':$filepath);
2327
+	    $id = $object->id;
2328
+	    $fk_element = $object->fk_element;
2329
+	    $table_element_line = $object->table_element_line;
2330
+	    $nboflines = (isset($object->lines) ?count($object->lines) : (empty($nboflines) ? 0 : $nboflines));
2331
+	    $tagidfortablednd = (empty($tagidfortablednd) ? 'tablelines' : $tagidfortablednd);
2332
+	    $filepath = (empty($filepath) ? '' : $filepath);
2333 2333
 	    
2334 2334
 	    
2335
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2335
+	    if (GETPOST('action', 'aZ09') != 'editline' && $nboflines > 1)
2336 2336
 	    {
2337 2337
 	        
2338 2338
 	        ?>
@@ -2350,7 +2350,7 @@  discard block
 block discarded – undo
2350 2350
 				moveBlockCol.disableSelection(); // prevent selection
2351 2351
 <?php if ($object->statut == 0) { ?>
2352 2352
 				// apply some graphical stuff
2353
-				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png',2);  ?>)');
2353
+				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png', 2); ?>)');
2354 2354
 				moveBlockCol.css("background-repeat","no-repeat");
2355 2355
 				moveBlockCol.css("background-position","center center");
2356 2356
 				moveBlockCol.css("cursor","move");
Please login to merge, or discard this patch.