Passed
Push — master ( 21f027...66b259 )
by
unknown
04:58
created
class/actions_subtotal.class.php 1 patch
Spacing   +410 added lines, -410 removed lines patch added patch discarded remove patch
@@ -16,17 +16,17 @@  discard block
 block discarded – undo
16 16
 		
17 17
 		global $type_element, $where;
18 18
 		
19
-		$contexts = explode(':',$parameters['context']);
19
+		$contexts = explode(':', $parameters['context']);
20 20
 		
21
-		if(in_array('consumptionthirdparty',$contexts) && in_array($type_element, array('propal', 'order', 'invoice', 'supplier_order', 'supplier_invoice', 'supplier_proposal'))) {
21
+		if (in_array('consumptionthirdparty', $contexts) && in_array($type_element, array('propal', 'order', 'invoice', 'supplier_order', 'supplier_invoice', 'supplier_proposal'))) {
22 22
 			$mod_num = TSubtotal::$module_number;
23 23
 			
24 24
 			// Not a title (can't use TSubtotal class methods in sql)
25
-			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty > 9)';
25
+			$where .= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty > 9)';
26 26
 			// Not a subtotal (can't use TSubtotal class methods in sql)
27
-			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty < 90)';
27
+			$where .= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty < 90)';
28 28
 			// Not a free line text (can't use TSubtotal class methods in sql)
29
-			$where.= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty != 50)';
29
+			$where .= ' AND (d.special_code != '.$mod_num.' OR d.product_type != 9 OR d.qty != 50)';
30 30
 			
31 31
 		}
32 32
 		
@@ -105,43 +105,43 @@  discard block
 block discarded – undo
105 105
     
106 106
     function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
107 107
     {
108
-      	global $langs,$db,$user, $conf;
108
+      	global $langs, $db, $user, $conf;
109 109
 		
110 110
 		$langs->load('subtotal@subtotal');
111 111
 		
112
-		$contexts = explode(':',$parameters['context']);
112
+		$contexts = explode(':', $parameters['context']);
113 113
 		
114
-		if(in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('invoicereccard',$contexts)) {
114
+		if (in_array('ordercard', $contexts) || in_array('ordersuppliercard', $contexts) || in_array('propalcard', $contexts) || in_array('supplier_proposalcard', $contexts) || in_array('invoicecard', $contexts) || in_array('invoicesuppliercard', $contexts) || in_array('invoicereccard', $contexts)) {
115 115
 			
116 116
 			$createRight = $user->rights->{$object->element}->creer;
117
-			if($object->element == 'facturerec' )
117
+			if ($object->element == 'facturerec')
118 118
 			{
119 119
 				$object->statut = 0; // hack for facture rec
120 120
 				$createRight = $user->rights->facture->creer;
121
-			} elseif($object->element == 'order_supplier' )
121
+			} elseif ($object->element == 'order_supplier')
122 122
 			{
123 123
 			    $createRight = $user->rights->fournisseur->commande->creer;
124
-			} elseif($object->element == 'invoice_supplier' )
124
+			} elseif ($object->element == 'invoice_supplier')
125 125
 			{
126 126
 			    $createRight = $user->rights->fournisseur->facture->creer;
127 127
 			}
128 128
 			
129
-			if ($object->statut == 0  && $createRight) {
129
+			if ($object->statut == 0 && $createRight) {
130 130
 			
131 131
 
132
-				if($object->element=='facture')$idvar = 'facid';
133
-				else $idvar='id';
132
+				if ($object->element == 'facture')$idvar = 'facid';
133
+				else $idvar = 'id';
134 134
 				
135
-				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
135
+				if (in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')))
136 136
 				{
137 137
 					$level = GETPOST('level', 'int'); //New avec SUBTOTAL_USE_NEW_FORMAT
138 138
 					
139
-					if($action=='add_title_line') {
139
+					if ($action == 'add_title_line') {
140 140
 						$title = GETPOST('title');
141
-						if(empty($title)) $title = $langs->trans('title');
142
-						$qty = $level<1 ? 1 : $level ;
141
+						if (empty($title)) $title = $langs->trans('title');
142
+						$qty = $level < 1 ? 1 : $level;
143 143
 					}
144
-					else if($action=='add_free_text') {
144
+					else if ($action == 'add_free_text') {
145 145
 						$title = GETPOST('title');
146 146
 
147 147
 						if (empty($title)) {
@@ -153,21 +153,21 @@  discard block
 block discarded – undo
153 153
 								}
154 154
 							}
155 155
 						}
156
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
156
+						if (empty($title)) $title = $langs->trans('subtotalAddLineDescription');
157 157
 						$qty = 50;
158 158
 					}
159
-					else if($action=='add_subtitle_line') {
159
+					else if ($action == 'add_subtitle_line') {
160 160
 						$title = GETPOST('title');
161
-						if(empty($title)) $title = $langs->trans('subtitle');
161
+						if (empty($title)) $title = $langs->trans('subtitle');
162 162
 						$qty = 2;
163 163
 					}
164
-					else if($action=='add_subtotal_line') {
164
+					else if ($action == 'add_subtotal_line') {
165 165
 						$title = $langs->trans('SubSubTotal');
166 166
 						$qty = 98;
167 167
 					}
168 168
 					else {
169 169
 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
170
-						$qty = $level ? 100-$level : 99;
170
+						$qty = $level ? 100 - $level : 99;
171 171
 					}
172 172
 					dol_include_once('/subtotal/class/subtotal.class.php');
173 173
 					
@@ -175,15 +175,15 @@  discard block
 block discarded – undo
175 175
 					
176 176
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
177 177
 				}
178
-				else if($action==='ask_deleteallline') {
179
-						$form=new Form($db);
178
+				else if ($action === 'ask_deleteallline') {
179
+						$form = new Form($db);
180 180
 						
181
-						$lineid = GETPOST('lineid','integer');
181
+						$lineid = GETPOST('lineid', 'integer');
182 182
 						$TIdForGroup = $this->getArrayOfLineForAGroup($object, $lineid);
183 183
 					
184 184
 						$nbLines = count($TIdForGroup);
185 185
 					
186
-						$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines',$nbLines), 'confirm_delete_all_lines','',0,1);
186
+						$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines', $nbLines), 'confirm_delete_all_lines', '', 0, 1);
187 187
 						print $formconfirm;
188 188
 				}
189 189
 
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
 				}
194 194
 
195 195
 				
196
-				if($action!='editline') {
196
+				if ($action != 'editline') {
197 197
 					// New format is for 3.8
198 198
 					$this->printNewFormat($object, $conf, $langs, $idvar);
199 199
 				}
200 200
 			}
201 201
 		}
202
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
202
+		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice', $contexts))
203 203
 		{
204 204
 			?>
205 205
 			<script type="text/javascript">
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 				$(document).ready(function() {
225 225
 					$('div.fiche div.tabsAction').append('<br />');
226 226
 					
227
-					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_title_line" rel="add_title_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddTitle' )?></a></div>');
227
+					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_title_line" rel="add_title_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddTitle')?></a></div>');
228 228
 					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_total_line" rel="add_total_line" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddSubTotal')?></a></div>');
229 229
 					$('div.fiche div.tabsAction').append('<div class="inline-block divButAction"><a id="add_free_text" rel="add_free_text" href="javascript:;" class="butAction"><?php echo  $langs->trans('AddFreeText')?></a></div>');
230 230
 
@@ -275,9 +275,9 @@  discard block
 block discarded – undo
275 275
 						$('body').append(dialog_html);
276 276
 
277 277
 						<?php 
278
-						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME)?'ckeditor':$conf->global->FCKEDITOR_EDITORNAME;
279
-						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
280
-						if($editorConf && in_array($editorTool,array('textarea','ckeditor'))){ 
278
+						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME) ? 'ckeditor' : $conf->global->FCKEDITOR_EDITORNAME;
279
+						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
280
+						if ($editorConf && in_array($editorTool, array('textarea', 'ckeditor'))) { 
281 281
 						?>
282 282
 						if (action == 'addTitle' || action == 'addFreeTxt')
283 283
 						{
@@ -392,62 +392,62 @@  discard block
 block discarded – undo
392 392
 		global $conf, $langs, $bc;
393 393
 			
394 394
 		$action = GETPOST('action');	
395
-		$TContext = explode(':',$parameters['context']);
395
+		$TContext = explode(':', $parameters['context']);
396 396
 		if (
397
-				in_array('invoicecard',$TContext)
398
-		        || in_array('invoicesuppliercard',$TContext)
399
-				|| in_array('propalcard',$TContext)
400
-				|| in_array('ordercard',$TContext)
401
-		        || in_array('ordersuppliercard',$TContext)
402
-				|| in_array('invoicereccard',$TContext)
397
+				in_array('invoicecard', $TContext)
398
+		        || in_array('invoicesuppliercard', $TContext)
399
+				|| in_array('propalcard', $TContext)
400
+				|| in_array('ordercard', $TContext)
401
+		        || in_array('ordersuppliercard', $TContext)
402
+				|| in_array('invoicereccard', $TContext)
403 403
 			)
404 404
 	        {	
405
-	            $hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
406
-	            $hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
407
-				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0;
408
-				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
405
+	            $hideInnerLines = isset($_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
406
+	            $hidedetails = isset($_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
407
+				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED) ? $conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED : 0;
408
+				$hideprices = isset($_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id]) ? $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
409 409
 				
410
-				$var=false;
411
-		     	$out.= '<tr '.$bc[$var].'>
410
+				$var = false;
411
+		     	$out .= '<tr '.$bc[$var].'>
412 412
 		     			<td colspan="4" align="right">
413 413
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
414
-		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
414
+		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(($hideInnerLines) ? 'checked="checked"' : '').' />
415 415
 		     			</td>
416 416
 		     			</tr>';
417 417
 				
418
-		     	$var=!$var;
419
-		     	$out.= '<tr '.$bc[$var].'>
418
+		     	$var = !$var;
419
+		     	$out .= '<tr '.$bc[$var].'>
420 420
 		     			<td colspan="4" align="right">
421 421
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
422
-		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
422
+		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(($hidedetails) ? 'checked="checked"' : '').' />
423 423
 		     			</td>
424 424
 		     			</tr>';
425 425
 		     	
426
-		     	$var=!$var;
427
-		     	$out.= '<tr '.$bc[$var].'>
426
+		     	$var = !$var;
427
+		     	$out .= '<tr '.$bc[$var].'>
428 428
 		     			<td colspan="4" align="right">
429 429
 		     				<label for="hideprices">'.$langs->trans('SubTotalhidePrice').'</label>
430
-		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
430
+		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(($hideprices) ? 'checked="checked"' : '').' />
431 431
 		     			</td>
432 432
 		     			</tr>';
433 433
 		     	
434 434
 		     	
435 435
 				 
436 436
 				if ( 
437
-					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
438
-					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
439
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
440
-					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
441
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
442
-					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
437
+					(in_array('propalcard', $TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
438
+					|| (in_array('ordercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
439
+				    || (in_array('ordersuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
440
+					|| (in_array('invoicecard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
441
+				    || (in_array('invoicesuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
442
+					|| (in_array('invoicereccard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
443 443
 				)
444 444
 				{
445
-					$var=!$var;
446
-					$out.= '
445
+					$var = !$var;
446
+					$out .= '
447 447
 						<tr '.$bc[$var].'>
448 448
 							<td colspan="4" align="right">
449 449
 								<label for="subtotal_add_recap">'.$langs->trans('subtotal_add_recap').'</label>
450
-								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.( GETPOST('subtotal_add_recap') ? 'checked="checked"' : '' ).' />
450
+								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.(GETPOST('subtotal_add_recap') ? 'checked="checked"' : '').' />
451 451
 							</td>
452 452
 						</tr>';
453 453
 				}
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
     function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
464 464
     {
465 465
 		
466
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
466
+    	if (in_array('invoicecard', explode(':', $parameters['context'])))
467 467
         {
468 468
         	
469 469
         }
@@ -474,13 +474,13 @@  discard block
 block discarded – undo
474 474
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
475 475
 		global $conf;
476 476
 		
477
-		if($action === 'builddoc') {
477
+		if ($action === 'builddoc') {
478 478
 			
479 479
 			$line = &$parameters['line'];
480 480
 			$object = &$parameters['object'];
481 481
 			$substitutionarray = &$parameters['substitutionarray'];
482 482
 			
483
-			if($line->product_type == 9 && $line->special_code == $this->module_number) {
483
+			if ($line->product_type == 9 && $line->special_code == $this->module_number) {
484 484
 				$substitutionarray['line_modsubtotal'] = 1;	
485 485
 				
486 486
 				$substitutionarray['line_price_ht']
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 					 = $substitutionarray['line_up'] 
492 492
 					 = '';
493 493
 				
494
-				if($line->qty>90) {
494
+				if ($line->qty > 90) {
495 495
 					$substitutionarray['line_modsubtotal_total'] = true;
496 496
 					
497 497
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 				
506 506
 				
507 507
 			}	
508
-			else{
508
+			else {
509 509
 				$substitutionarray['line_not_modsubtotal'] = true;
510 510
 				$substitutionarray['line_modsubtotal'] = 0;
511 511
 			}
@@ -517,29 +517,29 @@  discard block
 block discarded – undo
517 517
 	function createFrom($parameters, &$object, $action, $hookmanager) {
518 518
 	
519 519
 		if (
520
-				in_array('invoicecard',explode(':',$parameters['context']))
521
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
522
-				|| in_array('propalcard',explode(':',$parameters['context']))
523
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
524
-				|| in_array('ordercard',explode(':',$parameters['context']))
525
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
526
-				|| in_array('invoicereccard',explode(':',$parameters['context']))
520
+				in_array('invoicecard', explode(':', $parameters['context']))
521
+		        || in_array('invoicesuppliercard', explode(':', $parameters['context']))
522
+				|| in_array('propalcard', explode(':', $parameters['context']))
523
+		        || in_array('supplier_proposalcard', explode(':', $parameters['context']))
524
+				|| in_array('ordercard', explode(':', $parameters['context']))
525
+		        || in_array('ordersuppliercard', explode(':', $parameters['context']))
526
+				|| in_array('invoicereccard', explode(':', $parameters['context']))
527 527
 		) {
528 528
 			
529 529
 			global $db;
530 530
 			
531 531
 			$objFrom = $parameters['objFrom'];
532 532
 			
533
-			foreach($objFrom->lines as $k=> &$lineOld) {
533
+			foreach ($objFrom->lines as $k=> &$lineOld) {
534 534
 				
535
-					if($lineOld->product_type == 9 && $lineOld->info_bits > 0 ) {
535
+					if ($lineOld->product_type == 9 && $lineOld->info_bits > 0) {
536 536
 							
537 537
 							$line = & $object->lines[$k];
538 538
 				
539 539
 							$idLine = (int) ($line->id ? $line->id : $line->rowid); 
540 540
 				
541 541
 							$db->query("UPDATE ".MAIN_DB_PREFIX.$line->table_element."
542
-							SET info_bits=".(int)$lineOld->info_bits."
542
+							SET info_bits=".(int) $lineOld->info_bits."
543 543
 							WHERE rowid = ".$idLine."
544 544
 							");
545 545
 						
@@ -555,15 +555,15 @@  discard block
 block discarded – undo
555 555
 	
556 556
 	function doActions($parameters, &$object, $action, $hookmanager)
557 557
 	{
558
-		global $db, $conf, $langs,$user;
558
+		global $db, $conf, $langs, $user;
559 559
 		
560 560
 		dol_include_once('/subtotal/class/subtotal.class.php');
561 561
 		dol_include_once('/subtotal/lib/subtotal.lib.php');
562
-		require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
562
+		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
563 563
 		
564 564
 		$showBlockExtrafields = GETPOST('showBlockExtrafields');
565 565
 		
566
-		if($object->element=='facture') $idvar = 'facid';
566
+		if ($object->element == 'facture') $idvar = 'facid';
567 567
 		else $idvar = 'id';
568 568
 			
569 569
 		if ($action == 'updateligne' || $action == 'updateline')
@@ -576,7 +576,7 @@  discard block
 block discarded – undo
576 576
 				if ($line->id == $lineid && TSubtotal::isModSubtotalLine($line))
577 577
 				{
578 578
 					$found = true;
579
-					if(TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
579
+					if (TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
580 580
 						$extrafieldsline = new ExtraFields($db);
581 581
 						$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
582 582
 						$extrafieldsline->setOptionalsFromPost($extralabelsline, $line);
@@ -595,43 +595,43 @@  discard block
 block discarded – undo
595 595
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
596 596
 			}
597 597
 		}
598
-		else if($action === 'builddoc') {
598
+		else if ($action === 'builddoc') {
599 599
 			
600 600
 			if (
601
-				in_array('invoicecard',explode(':',$parameters['context']))
602
-				|| in_array('propalcard',explode(':',$parameters['context']))
603
-				|| in_array('ordercard',explode(':',$parameters['context']))
604
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
605
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
606
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
601
+				in_array('invoicecard', explode(':', $parameters['context']))
602
+				|| in_array('propalcard', explode(':', $parameters['context']))
603
+				|| in_array('ordercard', explode(':', $parameters['context']))
604
+			    || in_array('ordersuppliercard', explode(':', $parameters['context']))
605
+			    || in_array('invoicesuppliercard', explode(':', $parameters['context']))
606
+			    || in_array('supplier_proposalcard', explode(':', $parameters['context']))
607 607
 			)
608 608
 	        {								
609
-				if(in_array('invoicecard',explode(':',$parameters['context']))) {
609
+				if (in_array('invoicecard', explode(':', $parameters['context']))) {
610 610
 					$sessname = 'subtotal_hideInnerLines_facture';	
611 611
 					$sessname2 = 'subtotal_hidedetails_facture';
612 612
 					$sessname3 = 'subtotal_hideprices_facture';
613 613
 				}
614
-				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
614
+				elseif (in_array('invoicesuppliercard', explode(':', $parameters['context']))) {
615 615
 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
616 616
 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
617 617
 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
618 618
 				}
619
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
619
+				elseif (in_array('propalcard', explode(':', $parameters['context']))) {
620 620
 					$sessname = 'subtotal_hideInnerLines_propal';
621 621
 					$sessname2 = 'subtotal_hidedetails_propal';	
622 622
 					$sessname3 = 'subtotal_hideprices_propal';
623 623
 				}
624
-				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
624
+				elseif (in_array('supplier_proposalcard', explode(':', $parameters['context']))) {
625 625
 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
626 626
 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
627 627
 				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
628 628
 				}
629
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
629
+				elseif (in_array('ordercard', explode(':', $parameters['context']))) {
630 630
 					$sessname = 'subtotal_hideInnerLines_commande';
631 631
 					$sessname2 = 'subtotal_hidedetails_commande';	
632 632
 					$sessname3 = 'subtotal_hideprices_commande';
633 633
 				}
634
-				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
634
+				elseif (in_array('ordersuppliercard', explode(':', $parameters['context']))) {
635 635
 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
636 636
 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
637 637
 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
@@ -644,25 +644,25 @@  discard block
 block discarded – undo
644 644
 					
645 645
 				global $hideprices;
646 646
 				
647
-				$hideInnerLines = (int)GETPOST('hideInnerLines');
648
-				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) $_SESSION[$sessname] = array(); // prevent old system
647
+				$hideInnerLines = (int) GETPOST('hideInnerLines');
648
+				if (!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id])) $_SESSION[$sessname] = array(); // prevent old system
649 649
 				$_SESSION[$sessname][$object->id] = $hideInnerLines;		
650 650
 				
651
-				$hidedetails= (int)GETPOST('hidedetails');
652
-				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) $_SESSION[$sessname2] = array(); // prevent old system
651
+				$hidedetails = (int) GETPOST('hidedetails');
652
+				if (!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id])) $_SESSION[$sessname2] = array(); // prevent old system
653 653
 				$_SESSION[$sessname2][$object->id] = $hidedetails;
654 654
 				
655
-				$hideprices= (int)GETPOST('hideprices');
656
-				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) $_SESSION[$sessname3] = array(); // prevent old system
655
+				$hideprices = (int) GETPOST('hideprices');
656
+				if (!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id])) $_SESSION[$sessname3] = array(); // prevent old system
657 657
 				$_SESSION[$sessname3][$object->id] = $hideprices;
658 658
 				
659
-				foreach($object->lines as &$line) {
659
+				foreach ($object->lines as &$line) {
660 660
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
661 661
 					    
662
-                        if($line->qty>=90) {
662
+                        if ($line->qty >= 90) {
663 663
                             $line->modsubtotal_total = 1;
664 664
                         }
665
-                        else{
665
+                        else {
666 666
                             $line->modsubtotal_title = 1;
667 667
                         }
668 668
                         
@@ -672,34 +672,34 @@  discard block
 block discarded – undo
672 672
 	        }
673 673
 			
674 674
 		}
675
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
675
+		else if ($action === 'confirm_delete_all_lines' && GETPOST('confirm') == 'yes') {
676 676
 			
677 677
 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
678 678
 			
679
-			foreach($Tab as $idLine) {
679
+			foreach ($Tab as $idLine) {
680 680
 				/**
681 681
 				 * @var $object Facture
682 682
 				 */
683
-				if($object->element=='facture') $object->deleteline($idLine);
683
+				if ($object->element == 'facture') $object->deleteline($idLine);
684 684
 				/**
685 685
 				 * @var $object Facture fournisseur
686 686
 				 */
687
-				else if($object->element=='invoice_supplier')
687
+				else if ($object->element == 'invoice_supplier')
688 688
 				{
689 689
 				    $object->deleteline($idLine);
690 690
 				}
691 691
 				/**
692 692
 				 * @var $object Propal
693 693
 				 */
694
-				else if($object->element=='propal') $object->deleteline($idLine);
694
+				else if ($object->element == 'propal') $object->deleteline($idLine);
695 695
 				/**
696 696
 				 * @var $object Propal Fournisseur
697 697
 				 */
698
-				else if($object->element=='supplier_proposal') $object->deleteline($idLine);
698
+				else if ($object->element == 'supplier_proposal') $object->deleteline($idLine);
699 699
 				/**
700 700
 				 * @var $object Commande
701 701
 				 */
702
-				else if($object->element=='commande') 
702
+				else if ($object->element == 'commande') 
703 703
 				{
704 704
 					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
705 705
 					else $object->deleteline($idLine);
@@ -707,14 +707,14 @@  discard block
 block discarded – undo
707 707
 				/**
708 708
 				 * @var $object Commande fournisseur
709 709
 				 */
710
-				else if($object->element=='order_supplier')
710
+				else if ($object->element == 'order_supplier')
711 711
 				{
712 712
 				    $object->deleteline($idLine);
713 713
 				}
714 714
 				/**
715 715
 				 * @var $object Facturerec
716 716
 				 */
717
-				else if($object->element=='facturerec') $object->deleteline($idLine);
717
+				else if ($object->element == 'facturerec') $object->deleteline($idLine);
718 718
 			}
719 719
 			
720 720
 			header('location:?id='.$object->id);
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
 		return 0;
738 738
 	}
739 739
 	
740
-	function formAddObjectLine ($parameters, &$object, &$action, $hookmanager) {
740
+	function formAddObjectLine($parameters, &$object, &$action, $hookmanager) {
741 741
 		return 0;
742 742
 	}
743 743
 	
@@ -755,8 +755,8 @@  discard block
 block discarded – undo
755 755
 			if (!empty($parameters['fk_element']))
756 756
 			{
757 757
 				
758
-				if($obj->fetch($parameters['fk_element'])){
759
-					$obj->id= $obj->rowid;
758
+				if ($obj->fetch($parameters['fk_element'])) {
759
+					$obj->id = $obj->rowid;
760 760
 					if (empty($obj->array_options))
761 761
 						$obj->fetch_optionals();
762 762
 					if (!empty($obj->array_options['options_subtotal_nc']))
@@ -776,22 +776,22 @@  discard block
 block discarded – undo
776 776
 		
777 777
 		$found = false;
778 778
 
779
-		$Tab= array();
779
+		$Tab = array();
780 780
 		
781
-		foreach($object->lines as $l) {
781
+		foreach ($object->lines as $l) {
782 782
 		
783 783
 		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
784
-			if($lid == $lineid) {
784
+			if ($lid == $lineid) {
785 785
 
786 786
 				$found = true;
787 787
 				$qty_line = $l->qty;
788 788
 			}
789 789
 			
790
-			if($found) {
790
+			if ($found) {
791 791
 				
792 792
 			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
793 793
 				
794
-				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
794
+				if ($l->special_code == $this->module_number && (($l->qty == 99 && $qty_line == 1) || ($l->qty == 98 && $qty_line == 2))) {
795 795
 					break; // end of story
796 796
 				}
797 797
 			}
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
 	 * 
821 821
 	 * @param	$use_level		isn't used anymore
822 822
 	 */
823
-	function getTotalLineFromObject(&$object, &$line, $use_level=false, $return_all=0) {
823
+	function getTotalLineFromObject(&$object, &$line, $use_level = false, $return_all = 0) {
824 824
 		global $conf;
825 825
 		
826 826
 		$rang = $line->rang;
@@ -831,31 +831,31 @@  discard block
 block discarded – undo
831 831
 		$total_ttc = 0;
832 832
 		$TTotal_tva = array();
833 833
 		
834
-		$sign=1;
835
-		if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
834
+		$sign = 1;
835
+		if (isset($object->type) && $object->type == 2 && !empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign = -1;
836 836
 		
837 837
 		if (GETPOST('action') == 'builddoc') $builddoc = true;
838 838
 		else $builddoc = false;
839 839
 		
840 840
 		dol_include_once('/subtotal/class/subtotal.class.php');
841
-		foreach($object->lines as $l) {
841
+		foreach ($object->lines as $l) {
842 842
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
843
-			if($l->rang>=$rang) {
843
+			if ($l->rang >= $rang) {
844 844
 				//echo 'return!<br>';
845 845
 				if (!$return_all) return $total;
846 846
 				else return array($total, $total_tva, $total_ttc, $TTotal_tva);
847 847
 			}
848
-			else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
848
+			else if (TSubtotal::isTitle($l, 100 - $qty_line)) 
849 849
 		  	{
850 850
 				$total = 0;
851 851
 				$total_tva = 0;
852 852
 				$total_ttc = 0;
853 853
 				$TTotal_tva = array();
854 854
 			}
855
-			elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
855
+			elseif (!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
856 856
 				
857 857
 				// TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF
858
-				if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION)
858
+				if ($builddoc && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
859 859
 				{
860 860
 					if ($l->situation_percent > 0)
861 861
 					{
@@ -868,7 +868,7 @@  discard block
 block discarded – undo
868 868
 						}
869 869
 						
870 870
 						$result = $sign * ($l->total_ht / ($l->situation_percent / 100)) * $progress;
871
-						$total+= $result;
871
+						$total += $result;
872 872
 						// TODO check si les 3 lignes du dessous sont corrects
873 873
 						$total_tva += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
874 874
 						$TTotal_tva[$l->tva_tx] += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
@@ -900,10 +900,10 @@  discard block
 block discarded – undo
900 900
 	 * @param $w            float               width
901 901
 	 * @param $h            float               height
902 902
 	 */
903
-	function pdf_add_total(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
904
-		global $conf,$subtotal_last_title_posy;
903
+	function pdf_add_total(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
904
+		global $conf, $subtotal_last_title_posy;
905 905
 
906
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
906
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
907 907
 		if (!empty($conf->global->SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES) && $hideInnerLines && !empty($subtotal_last_title_posy))
908 908
 		{
909 909
 			$posy = $subtotal_last_title_posy;
@@ -913,34 +913,34 @@  discard block
 block discarded – undo
913 913
 		$hidePriceOnSubtotalLines = (int) GETPOST('hide_price_on_subtotal_lines');
914 914
 		
915 915
 		$set_pagebreak_margin = false;
916
-		if(method_exists('Closure','bind')) {
916
+		if (method_exists('Closure', 'bind')) {
917 917
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
918
-			$sweetsThief = function ($pdf) {
919
-		    		return $pdf->bMargin ;
918
+			$sweetsThief = function($pdf) {
919
+		    		return $pdf->bMargin;
920 920
 			};
921 921
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
922 922
 	
923
-			$bMargin  = $sweetsThief($pdf);
923
+			$bMargin = $sweetsThief($pdf);
924 924
 	
925
-			$pdf->SetAutoPageBreak( false );
925
+			$pdf->SetAutoPageBreak(false);
926 926
 
927 927
 			$set_pagebreak_margin = true;			
928 928
 		}
929 929
 		
930 930
 			
931
-		if($line->qty==99)
932
-			$pdf->SetFillColor(220,220,220);
933
-		elseif ($line->qty==98)
934
-			$pdf->SetFillColor(230,230,230);
931
+		if ($line->qty == 99)
932
+			$pdf->SetFillColor(220, 220, 220);
933
+		elseif ($line->qty == 98)
934
+			$pdf->SetFillColor(230, 230, 230);
935 935
 		else
936
-			$pdf->SetFillColor(240,240,240);
936
+			$pdf->SetFillColor(240, 240, 240);
937 937
 		
938 938
 		$style = 'B';
939 939
 		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
940 940
 		
941 941
 		$pdf->SetFont('', $style, 9);
942 942
 		
943
-		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R',true);
943
+		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R', true);
944 944
 //		var_dump($bMargin);
945 945
 		$pageAfter = $pdf->getPage();
946 946
 		
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
 			
969 969
 			
970 970
 			
971
-			if($total_to_print !== '') {
971
+			if ($total_to_print !== '') {
972 972
 				
973 973
 				if (GETPOST('hideInnerLines'))
974 974
 				{
@@ -992,11 +992,11 @@  discard block
 block discarded – undo
992 992
 			}
993 993
 
994 994
 			$pdf->SetXY($pdf->postotalht, $posy);
995
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
996
-			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
995
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
996
+			$pdf->MultiCell($pdf->page_largeur - $pdf->marge_droite - $pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
997 997
 		}
998
-		else{
999
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
998
+		else {
999
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
1000 1000
 		}
1001 1001
 		
1002 1002
 		$posy = $posy + $cell_height;
@@ -1016,22 +1016,22 @@  discard block
 block discarded – undo
1016 1016
 	 * @param $w            float               width
1017 1017
 	 * @param $h            float               height
1018 1018
 	 */
1019
-	function pdf_add_title(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
1019
+	function pdf_add_title(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
1020 1020
 		
1021
-		global $db,$conf,$subtotal_last_title_posy;
1021
+		global $db, $conf, $subtotal_last_title_posy;
1022 1022
 		
1023 1023
 		$subtotal_last_title_posy = $posy;
1024
-		$pdf->SetXY ($posx, $posy);
1024
+		$pdf->SetXY($posx, $posy);
1025 1025
 		
1026
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1026
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1027 1027
 		
1028 1028
 		
1029 1029
  
1030
-		$style = ($line->qty==1) ? 'BU' : 'BUI';
1030
+		$style = ($line->qty == 1) ? 'BU' : 'BUI';
1031 1031
 		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
1032 1032
 		
1033
-		if($hideInnerLines) {
1034
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
1033
+		if ($hideInnerLines) {
1034
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9);
1035 1035
 			else 
1036 1036
 			{
1037 1037
 				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
@@ -1040,43 +1040,43 @@  discard block
 block discarded – undo
1040 1040
 		}
1041 1041
 		else {
1042 1042
 
1043
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
1043
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9); //TODO if super utile
1044 1044
 			else $pdf->SetFont('', $style, 9);
1045 1045
 			
1046 1046
 		}
1047 1047
 		
1048 1048
 		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
1049
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
1049
+		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J', true); // et maintenant avec du HTML
1050 1050
 		
1051
-		if($description && !$hidedesc) {
1051
+		if ($description && !$hidedesc) {
1052 1052
 			$posy = $pdf->GetY();
1053 1053
 			
1054 1054
 			$pdf->SetFont('', '', 8);
1055 1055
 			
1056
-			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J',true);
1056
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J', true);
1057 1057
 
1058 1058
 		}
1059 1059
 		
1060 1060
 	}
1061 1061
 
1062
-	function pdf_writelinedesc_ref($parameters=array(), &$object, &$action='') {
1062
+	function pdf_writelinedesc_ref($parameters = array(), &$object, &$action = '') {
1063 1063
 	// ultimate PDF hook O_o
1064 1064
 		
1065
-		return $this->pdf_writelinedesc($parameters,$object,$action);
1065
+		return $this->pdf_writelinedesc($parameters, $object, $action);
1066 1066
 		
1067 1067
 	}
1068 1068
 
1069 1069
 	function isModSubtotalLine(&$parameters, &$object) {
1070 1070
 		
1071
-		if(is_array($parameters)) {
1071
+		if (is_array($parameters)) {
1072 1072
 			$i = & $parameters['i'];	
1073 1073
 		}
1074 1074
 		else {
1075
-			$i = (int)$parameters;
1075
+			$i = (int) $parameters;
1076 1076
 		}
1077 1077
 		
1078 1078
 		
1079
-		if($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) {
1079
+		if ($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) {
1080 1080
 			return true;
1081 1081
 		}
1082 1082
 		
@@ -1084,43 +1084,43 @@  discard block
 block discarded – undo
1084 1084
 		
1085 1085
 	}
1086 1086
 
1087
-	function pdf_getlineqty($parameters=array(), &$object, &$action='') {
1088
-		global $conf,$hideprices;
1087
+	function pdf_getlineqty($parameters = array(), &$object, &$action = '') {
1088
+		global $conf, $hideprices;
1089 1089
 		
1090
-		if($this->isModSubtotalLine($parameters,$object) ){
1090
+		if ($this->isModSubtotalLine($parameters, $object)) {
1091 1091
 			
1092 1092
 			$this->resprints = ' ';
1093 1093
 			
1094
-			if((float)DOL_VERSION<=3.6) {
1094
+			if ((float) DOL_VERSION <= 3.6) {
1095 1095
 				return '';
1096 1096
 			}
1097
-			else if((float)DOL_VERSION>=3.8) {
1097
+			else if ((float) DOL_VERSION >= 3.8) {
1098 1098
 				return 1;
1099 1099
 			}
1100 1100
 			
1101 1101
 		}
1102
-		elseif(!empty($hideprices)) {
1102
+		elseif (!empty($hideprices)) {
1103 1103
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1104 1104
 			return 1;
1105 1105
 		}
1106 1106
 		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1107 1107
 		{
1108
-			$hideInnerLines = (int)GETPOST('hideInnerLines');
1109
-			$hidedetails = (int)GETPOST('hidedetails');
1108
+			$hideInnerLines = (int) GETPOST('hideInnerLines');
1109
+			$hidedetails = (int) GETPOST('hidedetails');
1110 1110
 			if (empty($hideInnerLines) && !empty($hidedetails))
1111 1111
 			{
1112 1112
 				$this->resprints = $object->lines[$parameters['i']]->qty;
1113 1113
 			}
1114 1114
 		}
1115 1115
 		
1116
-		if(is_array($parameters)) $i = & $parameters['i'];
1117
-		else $i = (int)$parameters;
1116
+		if (is_array($parameters)) $i = & $parameters['i'];
1117
+		else $i = (int) $parameters;
1118 1118
 
1119 1119
 		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)
1120 1120
 		
1121
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1121
+		if (empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1122 1122
 
1123
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1123
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1124 1124
 		{
1125 1125
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1126 1126
 			{
@@ -1132,20 +1132,20 @@  discard block
 block discarded – undo
1132 1132
 		return 0;
1133 1133
 	}
1134 1134
 	
1135
-	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1135
+	function pdf_getlinetotalexcltax($parameters = array(), &$object, &$action = '') {
1136 1136
 	    global $conf, $hideprices, $hookmanager;
1137 1137
 		
1138
-		if(is_array($parameters)) $i = & $parameters['i'];
1139
-		else $i = (int)$parameters;
1138
+		if (is_array($parameters)) $i = & $parameters['i'];
1139
+		else $i = (int) $parameters;
1140 1140
 			
1141
-		if($this->isModSubtotalLine($parameters,$object) ){
1141
+		if ($this->isModSubtotalLine($parameters, $object)) {
1142 1142
 			
1143 1143
 			$this->resprints = ' ';
1144 1144
 			
1145
-			if((float)DOL_VERSION<=3.6) {
1145
+			if ((float) DOL_VERSION <= 3.6) {
1146 1146
 				return '';
1147 1147
 			}
1148
-			else if((float)DOL_VERSION>=3.8) {
1148
+			else if ((float) DOL_VERSION >= 3.8) {
1149 1149
 				return 1;
1150 1150
 			}
1151 1151
 			
@@ -1171,7 +1171,7 @@  discard block
 block discarded – undo
1171 1171
 				}
1172 1172
 			}
1173 1173
 		}
1174
-		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1174
+		if ((int) GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) {
1175 1175
 		    $this->resprints = price($object->lines[$i]->total_ht);
1176 1176
 		}
1177 1177
 		
@@ -1196,7 +1196,7 @@  discard block
 block discarded – undo
1196 1196
 		{
1197 1197
 			// Check if a title exist for this line && if the title have subtotal
1198 1198
 			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1199
-			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1199
+			if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1200 1200
 			{
1201 1201
 
1202 1202
 				$this->resprints = ' ';
@@ -1216,7 +1216,7 @@  discard block
 block discarded – undo
1216 1216
 	 */
1217 1217
 	private function callHook(&$object, &$hookmanager, $action, $params, $defaultReturn = 1)
1218 1218
 	{
1219
-		$reshook=$hookmanager->executeHooks('subtotalHidePrices',$params, $object, $action);
1219
+		$reshook = $hookmanager->executeHooks('subtotalHidePrices', $params, $object, $action);
1220 1220
 		if ($reshook < 0)
1221 1221
 		{
1222 1222
 			$this->error = $hookmanager->error;
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
 			$this->resprints = $hookmanager->resprints;
1233 1233
 
1234 1234
 			// override return (use  $this->results['overrideReturn'] or $this->resArray['overrideReturn'] in other module action_xxxx.class.php )
1235
-			if(isset($hookmanager->resArray['overrideReturn']))
1235
+			if (isset($hookmanager->resArray['overrideReturn']))
1236 1236
 			{
1237 1237
 				return $hookmanager->resArray['overrideReturn'];
1238 1238
 			}
@@ -1241,25 +1241,25 @@  discard block
 block discarded – undo
1241 1241
 		return $defaultReturn;
1242 1242
 	}
1243 1243
 	
1244
-	function pdf_getlinetotalwithtax($parameters=array(), &$object, &$action='') {
1244
+	function pdf_getlinetotalwithtax($parameters = array(), &$object, &$action = '') {
1245 1245
 		global $conf;
1246 1246
 		
1247
-		if($this->isModSubtotalLine($parameters,$object) ){
1247
+		if ($this->isModSubtotalLine($parameters, $object)) {
1248 1248
 			
1249 1249
 			$this->resprints = ' ';
1250 1250
 		
1251
-			if((float)DOL_VERSION<=3.6) {
1251
+			if ((float) DOL_VERSION <= 3.6) {
1252 1252
 				return '';
1253 1253
 			}
1254
-			else if((float)DOL_VERSION>=3.8) {
1254
+			else if ((float) DOL_VERSION >= 3.8) {
1255 1255
 				return 1;
1256 1256
 			}
1257 1257
 		}
1258 1258
 		
1259
-		if(is_array($parameters)) $i = & $parameters['i'];
1260
-		else $i = (int)$parameters;
1259
+		if (is_array($parameters)) $i = & $parameters['i'];
1260
+		else $i = (int) $parameters;
1261 1261
 		
1262
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1262
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))) 
1263 1263
 		{
1264 1264
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1265 1265
 			{
@@ -1271,24 +1271,24 @@  discard block
 block discarded – undo
1271 1271
 		return 0;
1272 1272
 	}
1273 1273
 	
1274
-	function pdf_getlineunit($parameters=array(), &$object, &$action='') {
1274
+	function pdf_getlineunit($parameters = array(), &$object, &$action = '') {
1275 1275
 		global $conf;
1276 1276
 		
1277
-		if($this->isModSubtotalLine($parameters,$object) ){
1277
+		if ($this->isModSubtotalLine($parameters, $object)) {
1278 1278
 			$this->resprints = ' ';
1279 1279
 		
1280
-			if((float)DOL_VERSION<=3.6) {
1280
+			if ((float) DOL_VERSION <= 3.6) {
1281 1281
 				return '';
1282 1282
 			}
1283
-			else if((float)DOL_VERSION>=3.8) {
1283
+			else if ((float) DOL_VERSION >= 3.8) {
1284 1284
 				return 1;
1285 1285
 			}
1286 1286
 		}
1287 1287
 		
1288
-		if(is_array($parameters)) $i = & $parameters['i'];
1289
-		else $i = (int)$parameters;
1288
+		if (is_array($parameters)) $i = & $parameters['i'];
1289
+		else $i = (int) $parameters;
1290 1290
 			
1291
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1291
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1292 1292
 		{
1293 1293
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1294 1294
 			{
@@ -1300,31 +1300,31 @@  discard block
 block discarded – undo
1300 1300
 		return 0;
1301 1301
 	}
1302 1302
 	
1303
-	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1304
-	    global $conf,$hideprices,$hookmanager;
1303
+	function pdf_getlineupexcltax($parameters = array(), &$object, &$action = '') {
1304
+	    global $conf, $hideprices, $hookmanager;
1305 1305
 
1306
-		if(is_array($parameters)) $i = & $parameters['i'];
1307
-		else $i = (int)$parameters;
1306
+		if (is_array($parameters)) $i = & $parameters['i'];
1307
+		else $i = (int) $parameters;
1308 1308
 
1309
-		if($this->isModSubtotalLine($parameters,$object) ) {
1309
+		if ($this->isModSubtotalLine($parameters, $object)) {
1310 1310
 			$this->resprints = ' ';
1311 1311
 
1312 1312
             $line = $object->lines[$i];
1313 1313
 
1314 1314
             // On récupère les montants du bloc pour les afficher dans la ligne de sous-total
1315
-            if(TSubtotal::isSubtotal($line)) {
1315
+            if (TSubtotal::isSubtotal($line)) {
1316 1316
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1317 1317
 
1318
-                if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1318
+                if (!empty($parentTitle->array_options['options_show_total_ht'])) {
1319 1319
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1320 1320
                     $this->resprints = price($TTotal['total_subprice']);
1321 1321
                 }
1322 1322
             }
1323 1323
 		
1324
-			if((float)DOL_VERSION<=3.6) {
1324
+			if ((float) DOL_VERSION <= 3.6) {
1325 1325
 				return '';
1326 1326
 			}
1327
-			else if((float)DOL_VERSION>=3.8) {
1327
+			else if ((float) DOL_VERSION >= 3.8) {
1328 1328
 				return 1;
1329 1329
 			}
1330 1330
 		}
@@ -1352,7 +1352,7 @@  discard block
 block discarded – undo
1352 1352
 		    
1353 1353
 		    // Check if a title exist for this line && if the title have subtotal
1354 1354
 		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1355
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1355
+		    if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1356 1356
 		    {
1357 1357
 		        
1358 1358
 		        $this->resprints = ' ';
@@ -1366,36 +1366,36 @@  discard block
 block discarded – undo
1366 1366
 		return 0;
1367 1367
 	}
1368 1368
 	
1369
-	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1370
-	    global $conf,$hideprices,$hookmanager;
1369
+	function pdf_getlineremisepercent($parameters = array(), &$object, &$action = '') {
1370
+	    global $conf, $hideprices, $hookmanager;
1371 1371
 
1372
-        if(is_array($parameters)) $i = & $parameters['i'];
1372
+        if (is_array($parameters)) $i = & $parameters['i'];
1373 1373
         else $i = (int) $parameters;
1374 1374
 
1375
-		if($this->isModSubtotalLine($parameters,$object) ) {
1375
+		if ($this->isModSubtotalLine($parameters, $object)) {
1376 1376
 			$this->resprints = ' ';
1377 1377
 
1378 1378
             $line = $object->lines[$i];
1379 1379
 
1380 1380
             // Affichage de la remise 
1381
-            if(TSubtotal::isSubtotal($line)) {
1381
+            if (TSubtotal::isSubtotal($line)) {
1382 1382
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1383 1383
 
1384
-                if(! empty($parentTitle->array_options['options_show_reduc'])) {
1384
+                if (!empty($parentTitle->array_options['options_show_reduc'])) {
1385 1385
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1386
-                    $this->resprints = price($TTotal['total_ht'] / $TTotal['total_subprice']*100, 0, '', 1, 2, 2).'%';
1386
+                    $this->resprints = price($TTotal['total_ht'] / $TTotal['total_subprice'] * 100, 0, '', 1, 2, 2).'%';
1387 1387
                 }
1388 1388
             }
1389 1389
 		
1390
-			if((float)DOL_VERSION<=3.6) {
1390
+			if ((float) DOL_VERSION <= 3.6) {
1391 1391
 				return '';
1392 1392
 			}
1393
-			else if((float)DOL_VERSION>=3.8) {
1393
+			else if ((float) DOL_VERSION >= 3.8) {
1394 1394
 				return 1;
1395 1395
 			}
1396 1396
 		}
1397 1397
 		elseif (!empty($hideprices)
1398
-		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1398
+		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1399 1399
 		        )
1400 1400
 		    {
1401 1401
 		        if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1408,24 +1408,24 @@  discard block
 block discarded – undo
1408 1408
 		return 0;
1409 1409
 	}
1410 1410
 	
1411
-	function pdf_getlineupwithtax($parameters=array(), &$object, &$action='') {
1412
-		global $conf,$hideprices;
1411
+	function pdf_getlineupwithtax($parameters = array(), &$object, &$action = '') {
1412
+		global $conf, $hideprices;
1413 1413
 		
1414
-		if($this->isModSubtotalLine($parameters,$object) ){
1414
+		if ($this->isModSubtotalLine($parameters, $object)) {
1415 1415
 			$this->resprints = ' ';
1416
-			if((float)DOL_VERSION<=3.6) {
1416
+			if ((float) DOL_VERSION <= 3.6) {
1417 1417
 				return '';
1418 1418
 			}
1419
-			else if((float)DOL_VERSION>=3.8) {
1419
+			else if ((float) DOL_VERSION >= 3.8) {
1420 1420
 				return 1;
1421 1421
 			}
1422 1422
 		}
1423 1423
 		
1424
-		if(is_array($parameters)) $i = & $parameters['i'];
1425
-		else $i = (int)$parameters;
1424
+		if (is_array($parameters)) $i = & $parameters['i'];
1425
+		else $i = (int) $parameters;
1426 1426
 			
1427 1427
 		if (!empty($hideprices)
1428
-				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1428
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1429 1429
 		)
1430 1430
 		{
1431 1431
 			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1438,22 +1438,22 @@  discard block
 block discarded – undo
1438 1438
 		return 0;
1439 1439
 	}
1440 1440
 	
1441
-	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
1442
-	    global $conf,$hideprices,$hookmanager;
1441
+	function pdf_getlinevatrate($parameters = array(), &$object, &$action = '') {
1442
+	    global $conf, $hideprices, $hookmanager;
1443 1443
 	    
1444
-		if($this->isModSubtotalLine($parameters,$object) ){
1444
+		if ($this->isModSubtotalLine($parameters, $object)) {
1445 1445
 			$this->resprints = ' ';
1446 1446
 			
1447
-			if((float)DOL_VERSION<=3.6) {
1447
+			if ((float) DOL_VERSION <= 3.6) {
1448 1448
 				return '';
1449 1449
 			}
1450
-			else if((float)DOL_VERSION>=3.8) {
1450
+			else if ((float) DOL_VERSION >= 3.8) {
1451 1451
 				return 1;
1452 1452
 			}
1453 1453
 		}
1454 1454
 		
1455
-		if(is_array($parameters)) $i = & $parameters['i'];
1456
-		else $i = (int)$parameters;
1455
+		if (is_array($parameters)) $i = & $parameters['i'];
1456
+		else $i = (int) $parameters;
1457 1457
 		
1458 1458
 		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)
1459 1459
 
@@ -1480,7 +1480,7 @@  discard block
 block discarded – undo
1480 1480
 		    
1481 1481
 		    // Check if a title exist for this line && if the title have subtotal
1482 1482
 		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1483
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1483
+		    if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1484 1484
 		    {
1485 1485
 		        
1486 1486
 		        $this->resprints = ' ';
@@ -1494,23 +1494,23 @@  discard block
 block discarded – undo
1494 1494
 		return 0;
1495 1495
 	}
1496 1496
 		
1497
-	function pdf_getlineprogress($parameters=array(), &$object, &$action) {
1497
+	function pdf_getlineprogress($parameters = array(), &$object, &$action) {
1498 1498
 		global $conf;
1499 1499
 		
1500
-		if($this->isModSubtotalLine($parameters,$object) ){
1500
+		if ($this->isModSubtotalLine($parameters, $object)) {
1501 1501
 			$this->resprints = ' ';
1502
-			if((float)DOL_VERSION<=3.6) {
1502
+			if ((float) DOL_VERSION <= 3.6) {
1503 1503
 				return '';
1504 1504
 			}
1505
-			else if((float)DOL_VERSION>=3.8) {
1505
+			else if ((float) DOL_VERSION >= 3.8) {
1506 1506
 				return 1;
1507 1507
 			}
1508 1508
 		}
1509 1509
 		
1510
-		if(is_array($parameters)) $i = & $parameters['i'];
1511
-		else $i = (int)$parameters;
1510
+		if (is_array($parameters)) $i = & $parameters['i'];
1511
+		else $i = (int) $parameters;
1512 1512
 			
1513
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1513
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1514 1514
 		{
1515 1515
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1516 1516
 			{
@@ -1525,12 +1525,12 @@  discard block
 block discarded – undo
1525 1525
 	function add_numerotation(&$object) {
1526 1526
 		global $conf;
1527 1527
 		
1528
-		if(!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1528
+		if (!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1529 1529
 		
1530 1530
 			$TLevelTitre = array();
1531 1531
 			$prevlevel = 0;
1532 1532
 		
1533
-			foreach($object->lines as $k=>&$line) 
1533
+			foreach ($object->lines as $k=>&$line) 
1534 1534
 			{
1535 1535
 				if ($line->id > 0 && $this->isModSubtotalLine($k, $object) && $line->qty <= 10)
1536 1536
 				{
@@ -1544,12 +1544,12 @@  discard block
 block discarded – undo
1544 1544
 	}
1545 1545
 
1546 1546
 	// TODO ne gère pas encore la numération des lignes "Totaux"
1547
-	private function formatNumerotation(&$TLineTitle, $line_reference='', $level=1, $prefix_num=0)
1547
+	private function formatNumerotation(&$TLineTitle, $line_reference = '', $level = 1, $prefix_num = 0)
1548 1548
 	{
1549 1549
 		$TTitle = array();
1550 1550
 		
1551
-		$i=1;
1552
-		$j=0;
1551
+		$i = 1;
1552
+		$j = 0;
1553 1553
 		foreach ($TLineTitle as $k => &$line)
1554 1554
 		{
1555 1555
 			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
@@ -1559,7 +1559,7 @@  discard block
 block discarded – undo
1559 1559
 			{
1560 1560
 				$TTitle[$j]['numerotation'] = ($prefix_num == 0) ? $i : $prefix_num.'.'.$i;
1561 1561
 				//var_dump('Prefix == '.$prefix_num.' // '.$line->desc.' ==> numerotation == '.$TTitle[$j]['numerotation'].'   ###    '.$line->qty .'=='. $level);
1562
-				if (empty($line->label) && (float)DOL_VERSION < 6)
1562
+				if (empty($line->label) && (float) DOL_VERSION < 6)
1563 1563
 				{
1564 1564
 					$line->label = !empty($line->desc) ? $line->desc : $line->description;
1565 1565
 					$line->desc = $line->description = '';
@@ -1585,26 +1585,26 @@  discard block
 block discarded – undo
1585 1585
 	
1586 1586
 	function setDocTVA(&$pdf, &$object) {
1587 1587
 		
1588
-		$hidedetails = (int)GETPOST('hidedetails');
1588
+		$hidedetails = (int) GETPOST('hidedetails');
1589 1589
 		
1590
-		if(empty($hidedetails)) return false;
1590
+		if (empty($hidedetails)) return false;
1591 1591
 		
1592 1592
 		// TODO can't add VAT to document without lines... :-/
1593 1593
 		
1594 1594
 		return true;
1595 1595
 	}
1596 1596
 	
1597
-	function beforePDFCreation($parameters=array(), &$object, &$action)
1597
+	function beforePDFCreation($parameters = array(), &$object, &$action)
1598 1598
 	{
1599 1599
 		/**
1600 1600
 		 * @var $pdf    TCPDF
1601 1601
 		 */
1602
-		global $pdf,$conf, $langs;
1602
+		global $pdf, $conf, $langs;
1603 1603
 
1604 1604
 		// var_dump($object->lines);
1605 1605
 		dol_include_once('/subtotal/class/subtotal.class.php');
1606 1606
 
1607
-		foreach($parameters as $key=>$value) {
1607
+		foreach ($parameters as $key=>$value) {
1608 1608
 			${$key} = $value;
1609 1609
 		}
1610 1610
 		
@@ -1612,34 +1612,34 @@  discard block
 block discarded – undo
1612 1612
 		
1613 1613
 		$this->add_numerotation($object);	
1614 1614
 		
1615
-        foreach($object->lines as $k => &$l) {
1616
-            if(TSubtotal::isSubtotal($l)) {
1615
+        foreach ($object->lines as $k => &$l) {
1616
+            if (TSubtotal::isSubtotal($l)) {
1617 1617
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1618
-                if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_total_ht'])) {
1619
-                    $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1618
+                if (!empty($parentTitle->id) && !empty($parentTitle->array_options['options_show_total_ht'])) {
1619
+                    $l->remise_percent = 100; // Affichage de la réduction sur la ligne de sous-total
1620 1620
                 }
1621 1621
             }
1622 1622
         }
1623 1623
 
1624
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1625
-		$hidedetails = (int)GETPOST('hidedetails');
1624
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1625
+		$hidedetails = (int) GETPOST('hidedetails');
1626 1626
 
1627 1627
 		if ($hideInnerLines) { // si c une ligne de titre
1628
-	    	$fk_parent_line=0;
1629
-			$TLines =array();
1628
+	    	$fk_parent_line = 0;
1629
+			$TLines = array();
1630 1630
 		
1631
-			$original_count=count($object->lines);
1631
+			$original_count = count($object->lines);
1632 1632
 		    $TTvas = array(); // tableau de tva
1633 1633
 		    
1634
-			foreach($object->lines as $k=>&$line) 
1634
+			foreach ($object->lines as $k=>&$line) 
1635 1635
 			{
1636 1636
 			    
1637
-				if($line->product_type==9 && $line->rowid>0) 
1637
+				if ($line->product_type == 9 && $line->rowid > 0) 
1638 1638
 				{
1639 1639
 					$fk_parent_line = $line->rowid;
1640 1640
 					
1641 1641
 					// 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
1642
-					if(TSubtotal::isSubtotal($line)) 
1642
+					if (TSubtotal::isSubtotal($line)) 
1643 1643
 					{
1644 1644
 						/*$total = $this->getTotalLineFromObject($object, $line, '');
1645 1645
 						
@@ -1668,22 +1668,22 @@  discard block
 block discarded – undo
1668 1668
 			
1669 1669
 				if ($hideInnerLines)
1670 1670
 				{
1671
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1671
+				    if (!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1672 1672
 				    {
1673
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1673
+				        if ($line->tva_tx != '0.000' && $line->product_type != 9) {
1674 1674
 				            
1675 1675
     				        // on remplit le tableau de tva pour substituer les lignes cachées
1676 1676
     				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1677 1677
     				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1678 1678
     				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1679 1679
     				    }
1680
-    					if($line->product_type==9 && $line->rowid>0)
1680
+    					if ($line->product_type == 9 && $line->rowid > 0)
1681 1681
     					{
1682 1682
     					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1683 1683
     					    // génère des lignes d'affichage des montants HT soumis à tva
1684 1684
     					    $nbtva = count($TTvas);
1685
-    					    if(!empty($nbtva)){
1686
-    					        foreach ($TTvas as $tx =>$val){
1685
+    					    if (!empty($nbtva)) {
1686
+    					        foreach ($TTvas as $tx =>$val) {
1687 1687
     					            $l = clone $line;
1688 1688
     					            $l->product_type = 1;
1689 1689
     					            $l->special_code = '';
@@ -1704,7 +1704,7 @@  discard block
 block discarded – undo
1704 1704
     					}
1705 1705
 				    } else {
1706 1706
 				        
1707
-				        if($line->product_type==9 && $line->rowid>0)
1707
+				        if ($line->product_type == 9 && $line->rowid > 0)
1708 1708
 				        {
1709 1709
 				            // ajoute la ligne de sous-total
1710 1710
 				            $TLines[] = $line; 
@@ -1732,9 +1732,9 @@  discard block
 block discarded – undo
1732 1732
 			
1733 1733
 			// cas incongru où il y aurait des produits en dessous du dernier sous-total
1734 1734
 			$nbtva = count($TTvas);
1735
-			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1735
+			if (!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1736 1736
 			{
1737
-			    foreach ($TTvas as $tx =>$val){
1737
+			    foreach ($TTvas as $tx =>$val) {
1738 1738
 			        $l = clone $line;
1739 1739
 			        $l->product_type = 1;
1740 1740
 			        $l->special_code = '';
@@ -1751,11 +1751,11 @@  discard block
 block discarded – undo
1751 1751
 			}
1752 1752
 			
1753 1753
 			global $nblignes;
1754
-			$nblignes=count($TLines);
1754
+			$nblignes = count($TLines);
1755 1755
 
1756 1756
 			$object->lines = $TLines;
1757 1757
 			
1758
-			if($i>count($object->lines)) {
1758
+			if ($i > count($object->lines)) {
1759 1759
 				$this->resprints = '';
1760 1760
 				return 0;
1761 1761
 			}
@@ -1764,59 +1764,59 @@  discard block
 block discarded – undo
1764 1764
 		return 0;
1765 1765
 	}
1766 1766
 
1767
-	function pdf_writelinedesc($parameters=array(), &$object, &$action)
1767
+	function pdf_writelinedesc($parameters = array(), &$object, &$action)
1768 1768
 	{
1769 1769
 		/**
1770 1770
 		 * @var $pdf    TCPDF
1771 1771
 		 */
1772
-		global $pdf,$conf;
1772
+		global $pdf, $conf;
1773 1773
 
1774
-		foreach($parameters as $key=>$value) {
1774
+		foreach ($parameters as $key=>$value) {
1775 1775
 			${$key} = $value;
1776 1776
 		}
1777 1777
 		
1778
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1779
-		$hidedetails = (int)GETPOST('hidedetails');
1778
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1779
+		$hidedetails = (int) GETPOST('hidedetails');
1780 1780
 		
1781
-		if($this->isModSubtotalLine($parameters,$object) ){			
1781
+		if ($this->isModSubtotalLine($parameters, $object)) {			
1782 1782
 		
1783 1783
 				global $hideprices;
1784 1784
 				
1785
-				if(!empty($hideprices)) {
1786
-					foreach($object->lines as &$line) {
1787
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1785
+				if (!empty($hideprices)) {
1786
+					foreach ($object->lines as &$line) {
1787
+						if ($line->fk_product_type != 9) $line->fk_parent_line = -1;	
1788 1788
 					}
1789 1789
 				}
1790 1790
 			
1791 1791
 				$line = &$object->lines[$i];
1792 1792
 				
1793
-				if($line->info_bits>0) { // PAGE BREAK
1793
+				if ($line->info_bits > 0) { // PAGE BREAK
1794 1794
 					$pdf->addPage();
1795 1795
 					$posy = $pdf->GetY();
1796 1796
 				}
1797 1797
 				
1798 1798
 				$label = $line->label;
1799
-				$description= !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1799
+				$description = !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1800 1800
 				
1801
-				if(empty($label)) {
1801
+				if (empty($label)) {
1802 1802
 					$label = $description;
1803
-					$description='';
1803
+					$description = '';
1804 1804
 				}
1805 1805
 				
1806
-				if($line->qty>90) {
1806
+				if ($line->qty > 90) {
1807 1807
 					
1808 1808
 					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1809 1809
 					
1810 1810
 					$pageBefore = $pdf->getPage();
1811
-					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1811
+					$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1812 1812
 					$pageAfter = $pdf->getPage();	
1813 1813
 
1814
-					if($pageAfter>$pageBefore) {
1814
+					if ($pageAfter > $pageBefore) {
1815 1815
 						//print "ST $pageAfter>$pageBefore<br>";
1816 1816
 						$pdf->rollbackTransaction(true);	
1817
-						$pdf->addPage('','', true);
1817
+						$pdf->addPage('', '', true);
1818 1818
 						$posy = $pdf->GetY();
1819
-						$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1819
+						$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1820 1820
 						$posy = $pdf->GetY();
1821 1821
 						//print 'add ST'.$pdf->getPage().'<br />';
1822 1822
 					}
@@ -1827,7 +1827,7 @@  discard block
 block discarded – undo
1827 1827
 				else if ($line->qty < 10) {
1828 1828
 					$pageBefore = $pdf->getPage();
1829 1829
 
1830
-					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
1830
+					$this->pdf_add_title($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h); 
1831 1831
 					$pageAfter = $pdf->getPage();	
1832 1832
 
1833 1833
 					
@@ -1902,9 +1902,9 @@  discard block
 block discarded – undo
1902 1902
 	 * @param $hookmanager  HookManager
1903 1903
 	 * @return int
1904 1904
 	 */
1905
-	function printObjectLine ($parameters, &$object, &$action, $hookmanager){
1905
+	function printObjectLine($parameters, &$object, &$action, $hookmanager) {
1906 1906
 		
1907
-		global $conf,$langs,$user,$db,$bc;
1907
+		global $conf, $langs, $user, $db, $bc;
1908 1908
 		
1909 1909
 		$num = &$parameters['num'];
1910 1910
 		$line = &$parameters['line'];
@@ -1912,32 +1912,32 @@  discard block
 block discarded – undo
1912 1912
 		
1913 1913
 		$var = &$parameters['var'];
1914 1914
 
1915
-		$contexts = explode(':',$parameters['context']);
1915
+		$contexts = explode(':', $parameters['context']);
1916 1916
 
1917 1917
 		$createRight = $user->rights->{$object->element}->creer;
1918
-		if($object->element == 'facturerec' )
1918
+		if ($object->element == 'facturerec')
1919 1919
 		{
1920 1920
 			$object->statut = 0; // hack for facture rec
1921 1921
 			$createRight = $user->rights->facture->creer;
1922 1922
 		}
1923
-		elseif($object->element == 'order_supplier' )
1923
+		elseif ($object->element == 'order_supplier')
1924 1924
 		{
1925 1925
 		    $createRight = $user->rights->fournisseur->commande->creer;
1926 1926
 		}
1927
-		elseif($object->element == 'invoice_supplier' )
1927
+		elseif ($object->element == 'invoice_supplier')
1928 1928
 		{
1929 1929
 		    $createRight = $user->rights->fournisseur->facture->creer;
1930 1930
 		}
1931 1931
 		
1932
-		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1932
+		if ($line->special_code != $this->module_number || $line->product_type != 9) {
1933 1933
 			null;
1934 1934
 		}	
1935
-		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)) 
1935
+		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)) 
1936 1936
         {
1937
-			if($object->element=='facture')$idvar = 'facid';
1938
-			else $idvar='id';
1937
+			if ($object->element == 'facture')$idvar = 'facid';
1938
+			else $idvar = 'id';
1939 1939
 			
1940
-			if((float)DOL_VERSION <= 3.4)
1940
+			if ((float) DOL_VERSION <= 3.4)
1941 1941
 			{
1942 1942
 				?>
1943 1943
 				<script type="text/javascript">
@@ -1961,22 +1961,22 @@  discard block
 block discarded – undo
1961 1961
 				<?php
1962 1962
 			}
1963 1963
 			
1964
-			if(empty($line->description)) $line->description = $line->desc;
1964
+			if (empty($line->description)) $line->description = $line->desc;
1965 1965
 			
1966 1966
 			$colspan = 5;
1967
-			if($object->element == 'facturerec' ) $colspan = 3;
1968
-			if($object->element == 'order_supplier') $colspan = 3;
1969
-			if($object->element == 'invoice_supplier') $colspan = 4;
1970
-			if($object->element == 'supplier_proposal') $colspan = 4;
1971
-			if(!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
1967
+			if ($object->element == 'facturerec') $colspan = 3;
1968
+			if ($object->element == 'order_supplier') $colspan = 3;
1969
+			if ($object->element == 'invoice_supplier') $colspan = 4;
1970
+			if ($object->element == 'supplier_proposal') $colspan = 4;
1971
+			if (!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
1972 1972
 				$colspan++; // Colonne PU Devise
1973 1973
 			}
1974
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1975
-			if(!empty($conf->margin->enabled)) $colspan++;
1976
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1977
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1978
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1979
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
1974
+			if ($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1975
+			if (!empty($conf->margin->enabled)) $colspan++;
1976
+			if (!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1977
+			if (!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1978
+			if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1979
+			if (!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
1980 1980
 					
1981 1981
 			/* Titre */
1982 1982
 			//var_dump($line);
@@ -1986,39 +1986,39 @@  discard block
 block discarded – undo
1986 1986
             
1987 1987
 			
1988 1988
 			?>
1989
-			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
1989
+			<tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
1990 1990
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
1991 1991
 					{
1992
-						if($line->qty==99) print 'background:#adadcf';
1993
-						else if($line->qty==98) print 'background:#ddddff;';
1994
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
1995
-						else if($line->qty==1) print 'background:#adadcf;';
1996
-						else if($line->qty==2) print 'background:#ddddff;';
1997
-						else if($line->qty==50) print '';
1992
+						if ($line->qty == 99) print 'background:#adadcf';
1993
+						else if ($line->qty == 98) print 'background:#ddddff;';
1994
+						else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;';
1995
+						else if ($line->qty == 1) print 'background:#adadcf;';
1996
+						else if ($line->qty == 2) print 'background:#ddddff;';
1997
+						else if ($line->qty == 50) print '';
1998 1998
 						else print 'background:#eeeeff;';
1999 1999
 
2000 2000
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2001 2001
 					}
2002 2002
 					else 
2003 2003
 					{
2004
-						if($line->qty==99) print 'background:#ddffdd';
2005
-						else if($line->qty==98) print 'background:#ddddff;';
2006
-						else if($line->qty==2) print 'background:#eeeeff; ';
2007
-						else if($line->qty==50) print '';
2008
-						else print 'background:#eeffee;' ;
2004
+						if ($line->qty == 99) print 'background:#ddffdd';
2005
+						else if ($line->qty == 98) print 'background:#ddddff;';
2006
+						else if ($line->qty == 2) print 'background:#eeeeff; ';
2007
+						else if ($line->qty == 50) print '';
2008
+						else print 'background:#eeffee;';
2009 2009
 					}
2010 2010
 
2011 2011
 			?>;">
2012 2012
 
2013
-				<?php if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
2013
+				<?php if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
2014 2014
 				<td class="linecolnum"><?php echo $i + 1; ?></td>
2015 2015
 				<?php } ?>
2016 2016
 
2017
-				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
2018
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
2017
+				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php
2018
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
2019 2019
 
2020
-						$params=array('line'=>$line);
2021
-						$reshook=$hookmanager->executeHooks('formEditProductOptions',$params,$object,$action);
2020
+						$params = array('line'=>$line);
2021
+						$reshook = $hookmanager->executeHooks('formEditProductOptions', $params, $object, $action);
2022 2022
 						
2023 2023
 						echo '<div id="line_'.$line->id.'"></div>'; // Imitation Dolibarr
2024 2024
 						echo '<input type="hidden" value="'.$line->id.'" name="lineid">';
@@ -2026,7 +2026,7 @@  discard block
 block discarded – undo
2026 2026
 						echo '<input id="product_id" type="hidden" value="'.$line->fk_product.'" name="type">';
2027 2027
 						echo '<input id="special_code" type="hidden" value="'.$line->special_code.'" name="type">';
2028 2028
 
2029
-						$isFreeText=false;
2029
+						$isFreeText = false;
2030 2030
 						if (TSubtotal::isTitle($line))
2031 2031
 						{
2032 2032
 							$qty_displayed = $line->qty;
@@ -2048,13 +2048,13 @@  discard block
 block discarded – undo
2048 2048
 						    $line->description = '';
2049 2049
 						}
2050 2050
 						$newlabel = $line->label;
2051
-						if($line->label=='' && !$isFreeText) {
2052
-							if(TSubtotal::isSubtotal($line)) {
2051
+						if ($line->label == '' && !$isFreeText) {
2052
+							if (TSubtotal::isSubtotal($line)) {
2053 2053
 								$newlabel = $line->description.' '.$this->getTitle($object, $line);
2054
-								$line->description='';
2055
-							} elseif( (float)DOL_VERSION < 6 ) {
2056
-								$newlabel= $line->description;
2057
-								$line->description='';
2054
+								$line->description = '';
2055
+							} elseif ((float) DOL_VERSION < 6) {
2056
+								$newlabel = $line->description;
2057
+								$line->description = '';
2058 2058
 							}
2059 2059
 						}
2060 2060
 
@@ -2063,10 +2063,10 @@  discard block
 block discarded – undo
2063 2063
 						
2064 2064
 						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2065 2065
 						
2066
-						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
2066
+						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)))
2067 2067
 						{
2068 2068
 							$select = '<select name="subtotal_level">';
2069
-							for ($j=1; $j<10; $j++)
2069
+							for ($j = 1; $j < 10; $j++)
2070 2070
 							{
2071 2071
 								if (!empty($readonlyForSituation)) {
2072 2072
 									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
@@ -2080,7 +2080,7 @@  discard block
 block discarded – undo
2080 2080
 
2081 2081
 						echo '<div class="subtotal_underline" style="margin-left:24px; line-height: 25px;">';
2082 2082
                         echo '<div>';
2083
-                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2083
+                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '').' />&nbsp;';
2084 2084
                         echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2085 2085
                         echo '</div>';
2086 2086
 
@@ -2101,21 +2101,21 @@  discard block
 block discarded – undo
2101 2101
                                 echo '</div>';
2102 2102
                             }
2103 2103
                             echo '<div>';
2104
-                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showTotalHT" id="subtotal-showTotalHT" value="9" '.(($line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2104
+                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showTotalHT" id="subtotal-showTotalHT" value="9" '.(($line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '').' />&nbsp;';
2105 2105
                             echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2106 2106
                             echo '</div>';
2107 2107
 
2108 2108
                             echo '<div>';
2109
-                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2109
+                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '').' />&nbsp;';
2110 2110
                             echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2111 2111
                             echo '</div>';
2112 2112
                         }
2113 2113
                         else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2114 2114
 						echo '</div>';
2115 2115
 
2116
-						if($line->qty<10) {
2116
+						if ($line->qty < 10) {
2117 2117
 							// WYSIWYG editor
2118
-							require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
2118
+							require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
2119 2119
 							$nbrows = ROWS_2;
2120 2120
 							$cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
2121 2121
 							if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
@@ -2135,25 +2135,25 @@  discard block
 block discarded – undo
2135 2135
 
2136 2136
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2137 2137
 						 {
2138
-							if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
2138
+							if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
2139 2139
 							{
2140
-								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2140
+								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
2141 2141
 								
2142 2142
 								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2143
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2143
+								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
2144 2144
 							}
2145 2145
 						 }
2146 2146
 						 else 
2147 2147
 						 {
2148
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2149
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2148
+							if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal');
2149
+							else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2150 2150
 						 }
2151 2151
 						 
2152 2152
 						 
2153 2153
 						 // Get display styles and apply them
2154 2154
 						 $titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
2155
-						 $titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2156
-						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2155
+						 $titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2156
+						 $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2157 2157
 						 
2158 2158
 						 if (empty($line->label)) {
2159 2159
 							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
@@ -2161,16 +2161,16 @@  discard block
 block discarded – undo
2161 2161
 						 } 
2162 2162
 						 else {
2163 2163
 
2164
-							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2164
+							if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2165 2165
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2166 2166
 							}
2167
-							else{
2167
+							else {
2168 2168
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
2169 2169
 							}
2170 2170
 
2171 2171
 						 } 
2172
-						if($line->qty>90) print ' : ';
2173
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2172
+						if ($line->qty > 90) print ' : ';
2173
+						if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2174 2174
 
2175 2175
 						 
2176 2176
 
@@ -2179,7 +2179,7 @@  discard block
 block discarded – undo
2179 2179
 			?></td>
2180 2180
 					 
2181 2181
 			<?php
2182
-				if($line->qty>90) {
2182
+				if ($line->qty > 90) {
2183 2183
 					/* Total */
2184 2184
 					$total_line = $this->getTotalLineFromObject($object, $line, '');
2185 2185
 					echo '<td class="linecolht nowrap" align="right" style="font-weight:bold;" rel="subtotal_total">'.price($total_line).'</td>';
@@ -2198,7 +2198,7 @@  discard block
 block discarded – undo
2198 2198
 				<?php
2199 2199
 				if ($action != 'selectlines') {
2200 2200
 				
2201
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
2201
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
2202 2202
 						?>
2203 2203
 						<input id="savelinebutton" class="button" type="submit" name="save" value="<?php echo $langs->trans('Save') ?>" />
2204 2204
 						<br />
@@ -2214,13 +2214,13 @@  discard block
 block discarded – undo
2214 2214
 						<?php
2215 2215
 						
2216 2216
 					}
2217
-					else{
2218
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2217
+					else {
2218
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2219 2219
 						{
2220
-							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>';
2220
+							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>';
2221 2221
 						}
2222 2222
 
2223
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
2223
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
2224 2224
 						{
2225 2225
 							echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=editline&lineid='.$line->id.'">'.img_edit().'</a>';
2226 2226
 						}								
@@ -2235,7 +2235,7 @@  discard block
 block discarded – undo
2235 2235
 				<?php
2236 2236
 
2237 2237
 				if ($action != 'editline' && $action != 'selectlines') {
2238
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2238
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2239 2239
 						{
2240 2240
 
2241 2241
 							if ($object->situation_counter == 1 || !$object->situation_cycle_ref)
@@ -2243,12 +2243,12 @@  discard block
 block discarded – undo
2243 2243
 								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteline&lineid='.$line->id.'">'.img_delete().'</a>';
2244 2244
 							}
2245 2245
 
2246
-							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) )
2246
+							if (TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref))
2247 2247
 							{
2248 2248
 								if ((float) DOL_VERSION >= 8.0) {
2249 2249
 									$img_delete = img_delete($langs->trans('deleteWithAllLines'), ' class="pictodelete pictodeleteallline"');
2250 2250
 								} elseif ((float) DOL_VERSION >= 3.8) {
2251
-									$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal',' class="pictodelete" ');
2251
+									$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal', ' class="pictodelete" ');
2252 2252
 								} else {
2253 2253
 									$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all@subtotal');
2254 2254
 								}
@@ -2258,7 +2258,7 @@  discard block
 block discarded – undo
2258 2258
 								/* Depuis la 8.0, les icônes "standard" utilisent FontAwesome et sont préconfigurées selon la clé de l'image
2259 2259
 								 * Impossible d'en customiser par exemple la couleur, même en utilisant img_picto() directement
2260 2260
 								 */
2261
-								if((float) DOL_VERSION >= 8.0) {
2261
+								if ((float) DOL_VERSION >= 8.0) {
2262 2262
 								?>
2263 2263
 								<script>
2264 2264
 									$(document).ready(function () {
@@ -2274,7 +2274,7 @@  discard block
 block discarded – undo
2274 2274
 			</td>
2275 2275
 			
2276 2276
 			<?php 
2277
-			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
2277
+			if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
2278 2278
 			{
2279 2279
 				echo '<td class="subtotal_nc">';
2280 2280
 				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"' : '').' />';
@@ -2285,11 +2285,11 @@  discard block
 block discarded – undo
2285 2285
 			<td align="center" class="linecolmove tdlineupdown">
2286 2286
 			</td>
2287 2287
 			<?php } else { ?>
2288
-			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0  && $createRight ))?' class="tdlineupdown"':''); ?>></td>
2288
+			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0 && $createRight)) ? ' class="tdlineupdown"' : ''); ?>></td>
2289 2289
 			<?php } ?>
2290 2290
 
2291
-			<?php  if($action == 'selectlines'){ // dolibarr 8 ?>
2292
-			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
2291
+			<?php  if ($action == 'selectlines') { // dolibarr 8 ?>
2292
+			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i + 1; ?>]" value="<?php echo $line->id; ?>" ></td>
2293 2293
 			<?php } ?>
2294 2294
 
2295 2295
 			</tr>
@@ -2297,29 +2297,29 @@  discard block
 block discarded – undo
2297 2297
 			
2298 2298
 			
2299 2299
 			// Affichage des extrafields à la Dolibarr (car sinon non affiché sur les titres)
2300
-			if(TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2300
+			if (TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2301 2301
 				
2302
-				require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
2302
+				require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
2303 2303
 				
2304 2304
 				// Extrafields
2305 2305
 				$extrafieldsline = new ExtraFields($db);
2306 2306
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2307 2307
 				
2308
-				$colspan+=3; $mode = 'view';
2309
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2308
+				$colspan += 3; $mode = 'view';
2309
+				if ($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2310 2310
 				
2311 2311
 				$ex_element = $line->element;
2312 2312
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
2313
-				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ','colspan'=>$colspan));
2313
+				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ', 'colspan'=>$colspan));
2314 2314
 				$isExtraSelected = false;
2315
-				foreach($line->array_options as $option) {
2316
-					if(!empty($option) && $option != "-1") {
2315
+				foreach ($line->array_options as $option) {
2316
+					if (!empty($option) && $option != "-1") {
2317 2317
 						$isExtraSelected = true;
2318 2318
 						break;
2319 2319
 					}
2320 2320
 				}
2321 2321
 				
2322
-				if($mode === 'edit') {
2322
+				if ($mode === 'edit') {
2323 2323
 					?>
2324 2324
 					<script>
2325 2325
 						$(document).ready(function(){
@@ -2327,7 +2327,7 @@  discard block
 block discarded – undo
2327 2327
 							var all_tr_extrafields = $("tr.tr_extrafield_title");
2328 2328
 							<?php 
2329 2329
 							// Si un extrafield est rempli alors on affiche directement les extrafields
2330
-							if(!$isExtraSelected) {
2330
+							if (!$isExtraSelected) {
2331 2331
 								echo 'all_tr_extrafields.hide();';
2332 2332
 								echo 'var trad = "'.$langs->trans('showExtrafields').'";';
2333 2333
 								echo 'var extra = 0;';
@@ -2373,20 +2373,20 @@  discard block
 block discarded – undo
2373 2373
 
2374 2374
 	
2375 2375
 	function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) {
2376
-		global $conf,$langs;
2376
+		global $conf, $langs;
2377 2377
 		 
2378 2378
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2379 2379
 		{
2380 2380
 		    
2381
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2381
+		    if ($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2382 2382
 		    {
2383 2383
 		        foreach ($object->lines as $line)
2384 2384
 		        {
2385 2385
 		            // fetch optionals attributes and labels
2386 2386
 		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2387
-		            $extrafields=new ExtraFields($this->db);
2388
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2389
-		            $line->fetch_optionals($line->id,$extralabels);
2387
+		            $extrafields = new ExtraFields($this->db);
2388
+		            $extralabels = $extrafields->fetch_name_optionals_label($object->table_element_line, true);
2389
+		            $line->fetch_optionals($line->id, $extralabels);
2390 2390
 		        }
2391 2391
 		    }
2392 2392
 		    
@@ -2486,23 +2486,23 @@  discard block
 block discarded – undo
2486 2486
 	    $ThtmlData['data-qty']          = 0; //$line->qty;
2487 2487
 	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2488 2488
 	    
2489
-	    if(TSubtotal::isTitle($line)){
2489
+	    if (TSubtotal::isTitle($line)) {
2490 2490
 	        $ThtmlData['data-issubtotal'] = 'title';
2491
-	    }elseif(TSubtotal::isSubtotal($line)){
2491
+	    }elseif (TSubtotal::isSubtotal($line)) {
2492 2492
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2493 2493
 	    }
2494
-	    else{
2494
+	    else {
2495 2495
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2496 2496
 	    }
2497 2497
 	    
2498 2498
 	    
2499 2499
 	    // Change or add data  from hooks
2500
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2500
+	    $parameters = array_replace($parameters, array('ThtmlData' => $ThtmlData));
2501 2501
 	    
2502 2502
 	    // hook 
2503
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2503
+	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2504 2504
 	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2505
-	    if ($reshook>0)
2505
+	    if ($reshook > 0)
2506 2506
 	    {
2507 2507
 	        $ThtmlData = $hookmanager->resArray;
2508 2508
 	    }
@@ -2515,14 +2515,14 @@  discard block
 block discarded – undo
2515 2515
 	function implodeHtmlData($ThtmlData = array())
2516 2516
 	{
2517 2517
 	    $data = '';
2518
-	    foreach($ThtmlData as $k => $h )
2518
+	    foreach ($ThtmlData as $k => $h)
2519 2519
 	    {
2520
-	        if(is_array($h))
2520
+	        if (is_array($h))
2521 2521
 	        {
2522 2522
 	            $h = json_encode($h);
2523 2523
 	        }
2524 2524
 	        
2525
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2525
+	        $data .= $k.'="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2526 2526
 	    }
2527 2527
 	    
2528 2528
 	    return $data;
@@ -2530,26 +2530,26 @@  discard block
 block discarded – undo
2530 2530
 	
2531 2531
 	function _ajax_block_order_js($object)
2532 2532
 	{
2533
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2533
+	    global $conf, $tagidfortablednd, $filepath, $langs;
2534 2534
 	    
2535 2535
 	    /*
2536 2536
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2537 2537
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2538 2538
 	     */
2539 2539
 	    
2540
-	    $id=$object->id;
2541
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2542
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2540
+	    $id = $object->id;
2541
+	    $nboflines = (isset($object->lines) ?count($object->lines) : 0);
2542
+	    $forcereloadpage = empty($conf->global->MAIN_FORCE_RELOAD_PAGE) ? 0 : 1;
2543 2543
 	    
2544
-	    $id=$object->id;
2545
-	    $fk_element=$object->fk_element;
2546
-	    $table_element_line=$object->table_element_line;
2547
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2548
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2549
-	    $filepath=(empty($filepath)?'':$filepath);
2544
+	    $id = $object->id;
2545
+	    $fk_element = $object->fk_element;
2546
+	    $table_element_line = $object->table_element_line;
2547
+	    $nboflines = (isset($object->lines) ?count($object->lines) : (empty($nboflines) ? 0 : $nboflines));
2548
+	    $tagidfortablednd = (empty($tagidfortablednd) ? 'tablelines' : $tagidfortablednd);
2549
+	    $filepath = (empty($filepath) ? '' : $filepath);
2550 2550
 	    
2551 2551
 	    
2552
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2552
+	    if (GETPOST('action', 'aZ09') != 'editline' && $nboflines > 1)
2553 2553
 	    {
2554 2554
 	        
2555 2555
 	        ?>
@@ -2567,7 +2567,7 @@  discard block
 block discarded – undo
2567 2567
 				moveBlockCol.disableSelection(); // prevent selection
2568 2568
 <?php if ($object->statut == 0) { ?>
2569 2569
 				// apply some graphical stuff
2570
-				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png',2);  ?>)');
2570
+				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png', 2); ?>)');
2571 2571
 				moveBlockCol.css("background-repeat","no-repeat");
2572 2572
 				moveBlockCol.css("background-position","center center");
2573 2573
 				moveBlockCol.css("cursor","move");
Please login to merge, or discard this patch.
class/subtotal.class.php 1 patch
Spacing   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -5,28 +5,28 @@  discard block
 block discarded – undo
5 5
 	
6 6
 	static $module_number = 104777;
7 7
 	
8
-	static function addSubTotalLine(&$object, $label, $qty, $rang=-1) {
8
+	static function addSubTotalLine(&$object, $label, $qty, $rang = -1) {
9 9
 		
10 10
 		$res = 0;
11 11
 		
12
-		if( (float)DOL_VERSION <= 3.4 ) {
12
+		if ((float) DOL_VERSION <= 3.4) {
13 13
 			/**
14 14
 			 * @var $object Facture
15 15
 			 */
16
-			if($object->element=='facture') $res =  $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number);
16
+			if ($object->element == 'facture') $res = $object->addline($object->id, $label, 0, $qty, 0, 0, 0, 0, 0, '', '', 0, 0, '', 'HT', 0, 9, -1, TSubtotal::$module_number);
17 17
 			/**
18 18
 			 * @var $object Propal
19 19
 			 */
20
-			else if($object->element=='propal') $res =  $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number);
20
+			else if ($object->element == 'propal') $res = $object->addline($object->id, $label, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, -1, TSubtotal::$module_number);
21 21
 			/**
22 22
 			 * @var $object Commande
23 23
 			 */
24
-			else if($object->element=='commande') $res =  $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number);
24
+			else if ($object->element == 'commande') $res = $object->addline($object->id, $label, 0, $qty, 0, 0, 0, 0, 0, 0, 0, 'HT', 0, '', '', 9, -1, TSubtotal::$module_number);
25 25
 
26 26
 		}
27 27
 		else {
28 28
 			$desc = '';
29
-			if ((float) DOL_VERSION < 6  || $qty==50) {
29
+			if ((float) DOL_VERSION < 6 || $qty == 50) {
30 30
 				$desc = $label;
31 31
 				$label = '';
32 32
 			}
@@ -34,40 +34,40 @@  discard block
 block discarded – undo
34 34
 			/**
35 35
 			 * @var $object Facture
36 36
 			 */
37
-			if($object->element=='facture') $res =  $object->addline($desc, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,$rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label);
37
+			if ($object->element == 'facture') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, '', '', 0, 0, '', 'HT', 0, 9, $rang, TSubtotal::$module_number, '', 0, 0, null, 0, $label);
38 38
 			/**
39 39
 			 * @var $object Facture fournisseur
40 40
 			 */
41
-			else if($object->element=='invoice_supplier') {
41
+			else if ($object->element == 'invoice_supplier') {
42 42
 			    $object->special_code = TSubtotal::$module_number;
43 43
 			    $rang = $object->line_max() + 1;
44
-			    if($qty==50) $res = $object->addline($desc,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
45
-			    else $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
44
+			    if ($qty == 50) $res = $object->addline($desc, 0, 0, 0, 0, $qty, 0, 0, '', '', 0, 0, 'HT', 9, $rang);
45
+			    else $res = $object->addline($label, 0, 0, 0, 0, $qty, 0, 0, '', '', 0, 0, 'HT', 9, $rang);
46 46
 			}
47 47
 			/**
48 48
 			 * @var $object Propal
49 49
 			 */
50
-			else if($object->element=='propal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
50
+			else if ($object->element == 'propal') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, $rang, TSubtotal::$module_number, 0, 0, 0, $label);
51 51
 			/**
52 52
 			 * @var $object Propal Fournisseur
53 53
 			 */
54
-			else if($object->element=='supplier_proposal') $res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
54
+			else if ($object->element == 'supplier_proposal') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, 0, 9, $rang, TSubtotal::$module_number, 0, 0, 0, $label);
55 55
 			
56 56
 			/**
57 57
 			 * @var $object Commande
58 58
 			 */
59
-			else if($object->element=='commande') $res =  $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label);
59
+			else if ($object->element == 'commande') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 0, 0, 'HT', 0, '', '', 9, $rang, TSubtotal::$module_number, 0, null, 0, $label);
60 60
 			/**
61 61
 			 * @var $object Commande fournisseur
62 62
 			 */
63
-			else if($object->element=='order_supplier') {
63
+			else if ($object->element == 'order_supplier') {
64 64
 			    $object->special_code = TSubtotal::$module_number;
65
-			    $res = $object->addline($label, 0,$qty,0,0,0,0,0,'',0,'HT', 0, 9);
65
+			    $res = $object->addline($label, 0, $qty, 0, 0, 0, 0, 0, '', 0, 'HT', 0, 9);
66 66
 			}
67 67
 			/**
68 68
 			 * @var $object Facturerec
69 69
 			 */
70
-			else if($object->element=='facturerec') $res =  $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label); 
70
+			else if ($object->element == 'facturerec') $res = $object->addline($desc, 0, $qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number, $label); 
71 71
 			
72 72
 		}
73 73
 	
@@ -78,20 +78,20 @@  discard block
 block discarded – undo
78 78
 
79 79
 	public static function generateDoc(&$object)
80 80
 	{
81
-		global $conf,$langs,$db;
81
+		global $conf, $langs, $db;
82 82
 		
83 83
 		if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
84 84
 		{
85
-			$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
86
-			$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
87
-			$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
85
+			$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
86
+			$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
87
+			$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
88 88
 			
89 89
 			// Define output language
90 90
 			$outputlangs = $langs;
91 91
 			$newlang = GETPOST('lang_id', 'alpha');
92
-			if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
92
+			if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
93 93
 				$newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang;
94
-			if (! empty($newlang)) {
94
+			if (!empty($newlang)) {
95 95
 				$outputlangs = new Translate("", $conf);
96 96
 				$outputlangs->setDefaultLang($newlang);
97 97
 			}
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 			}
106 106
 			else
107 107
 			{
108
-				if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
108
+				if ($object->element != 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
109 109
 			}
110 110
 		}
111 111
 	}
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
 	 * @param type $rang_start
118 118
 	 * @param type $move_to
119 119
 	 */
120
-	public static function updateRang(&$object, $rang_start, $move_to=1)
120
+	public static function updateRang(&$object, $rang_start, $move_to = 1)
121 121
 	{
122 122
 		if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
123 123
 		
124
-		$row=new GenericObject($object->db);
124
+		$row = new GenericObject($object->db);
125 125
 		$row->table_element_line = $object->table_element_line;
126 126
 		$row->fk_element = $object->fk_element;
127 127
 		$row->id = $object->id;
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 		{
131 131
 			if ($line->rang < $rang_start) continue;
132 132
 			
133
-			$row->updateRangOfLine($line->id, $line->rang+$move_to);
133
+			$row->updateRangOfLine($line->id, $line->rang + $move_to);
134 134
 		}
135 135
 	}
136 136
 	
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 			{
160 160
 				if ($rang_to_add != -1) self::updateRang($object, $rang_to_add);
161 161
 				
162
-				self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add);
162
+				self::addSubTotalLine($object, $langs->trans('SubTotal'), 100 - $title_niveau, $rang_to_add);
163 163
 				
164 164
 				$object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas)
165 165
 				if ($rang_to_add != -1) 
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
 		}
172 172
 	}
173 173
 	
174
-	public static function addTitle(&$object, $label, $level, $rang=-1)
174
+	public static function addTitle(&$object, $label, $level, $rang = -1)
175 175
 	{
176 176
 		self::addSubTotalLine($object, $label, $level, $rang);
177 177
 	}
178 178
 	
179
-	public static function addTotal(&$object, $label, $level, $rang=-1)
179
+	public static function addTotal(&$object, $label, $level, $rang = -1)
180 180
 	{
181
-		self::addSubTotalLine($object, $label, (100-$level), $rang);
181
+		self::addSubTotalLine($object, $label, (100 - $level), $rang);
182 182
 	}
183 183
 
184 184
 	/**
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 	 * 
190 190
 	 * @return array
191 191
 	 */
192
-	public static function getAllTitleWithoutTotalFromDocument(&$object, $get_block_total=false)
192
+	public static function getAllTitleWithoutTotalFromDocument(&$object, $get_block_total = false)
193 193
 	{
194 194
 		$TTitle = self::getAllTitleFromDocument($object, $get_block_total);
195 195
 		
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 	 * @param boolean								$return_rang_on_false	si true alors renvoi le rang où devrait ce trouver le sous-total
211 211
 	 * @return boolean
212 212
 	 */
213
-	public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false)
213
+	public static function titleHasTotalLine(&$object, &$title_line, $strict_mode = false, $return_rang_on_false = false)
214 214
 	{
215 215
 		if (empty($object->lines) || !is_array($object->lines)) return false;
216 216
 		
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 		return ($return_rang_on_false) ? -1 : false;
237 237
 	}
238 238
 	
239
-	public static function getAllTitleFromDocument(&$object, $get_block_total=false)
239
+	public static function getAllTitleFromDocument(&$object, $get_block_total = false)
240 240
 	{
241 241
 		$TRes = array();
242 242
 		if (!empty($object->lines))
@@ -357,19 +357,19 @@  discard block
 block discarded – undo
357 357
 		return false;
358 358
 	}
359 359
 	
360
-	public static function isTitle(&$line, $level=-1)
360
+	public static function isTitle(&$line, $level = -1)
361 361
 	{
362 362
 		$res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty <= 9;
363
-		if($res && $level > -1) {
363
+		if ($res && $level > -1) {
364 364
 			return $line->qty == $level;
365 365
 		} else return $res;
366 366
 		
367 367
 	}
368 368
 	
369
-	public static function isSubtotal(&$line, $level=-1)
369
+	public static function isSubtotal(&$line, $level = -1)
370 370
 	{
371 371
 	    $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90;
372
-	    if($res && $level > -1) {
372
+	    if ($res && $level > -1) {
373 373
 	        return self::getNiveau($line) == $level;
374 374
 	    } else return $res;
375 375
 	}
@@ -384,43 +384,43 @@  discard block
 block discarded – undo
384 384
 		return self::isTitle($line) || self::isSubtotal($line) || self::isFreeText($line);
385 385
 	}
386 386
 
387
-	public static function getFreeTextHtml(&$line, $readonly=0)
387
+	public static function getFreeTextHtml(&$line, $readonly = 0)
388 388
 	{
389 389
 		global $conf;
390 390
 		
391 391
 		// Copie du fichier "objectline_edit.tpl.php"
392 392
 		// editeur wysiwyg
393 393
 		require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
394
-		$nbrows=ROWS_2;
395
-		if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
396
-		$enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
397
-		$toolbarname='dolibarr_details';
398
-		if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes';
399
-		$text = !empty($line->description)?$line->description:$line->label;
400
-		$doleditor=new DolEditor('line-description',$text,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%', $readonly);
394
+		$nbrows = ROWS_2;
395
+		if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;
396
+		$enable = (isset($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
397
+		$toolbarname = 'dolibarr_details';
398
+		if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname = 'dolibarr_notes';
399
+		$text = !empty($line->description) ? $line->description : $line->label;
400
+		$doleditor = new DolEditor('line-description', $text, '', 164, $toolbarname, '', false, true, $enable, $nbrows, '98%', $readonly);
401 401
 		return $doleditor->Create(1);
402 402
 	}
403 403
 	
404
-	public static function duplicateLines(&$object, $lineid, $withBlockLine=false)
404
+	public static function duplicateLines(&$object, $lineid, $withBlockLine = false)
405 405
 	{
406
-		global $db,$user,$conf;
406
+		global $db, $user, $conf;
407 407
 
408 408
 		$createRight = $user->rights->{$object->element}->creer;
409
-		if($object->element == 'facturerec' )
409
+		if ($object->element == 'facturerec')
410 410
 		{
411 411
 		    $object->statut = 0; // hack for facture rec
412 412
 		    $createRight = $user->rights->facture->creer;
413 413
 		}
414
-		elseif($object->element == 'order_supplier' )
414
+		elseif ($object->element == 'order_supplier')
415 415
 		{
416 416
 		    $createRight = $user->rights->fournisseur->commande->creer;
417 417
 		}
418
-		elseif($object->element == 'invoice_supplier' )
418
+		elseif ($object->element == 'invoice_supplier')
419 419
 		{
420 420
 		    $createRight = $user->rights->fournisseur->facture->creer;
421 421
 		}
422 422
 		
423
-		if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK))
423
+		if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK))
424 424
 		{
425 425
 			dol_include_once('/subtotal/lib/subtotal.lib.php');
426 426
 			
@@ -453,7 +453,7 @@  discard block
 block discarded – undo
453 453
 						case 'order_supplier':
454 454
 						    $object->line = $line;
455 455
 						    $object->line->fk_commande = $object->id;
456
-						    $object->line->rang = $object->line_max() +1;
456
+						    $object->line->rang = $object->line_max() + 1;
457 457
 						    $res = $object->line->insert(1);
458 458
 							break;
459 459
 							
@@ -493,7 +493,7 @@  discard block
 block discarded – undo
493 493
 					{
494 494
 						$object->line_from = $line;
495 495
 						// Call trigger
496
-						$result=$object->call_trigger('LINE_DUPLICATE',$user); // $object->line
496
+						$result = $object->call_trigger('LINE_DUPLICATE', $user); // $object->line
497 497
 						if ($result < 0)
498 498
 						{
499 499
 							$object->db->rollback();
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 		}
524 524
 	}
525 525
 	
526
-	public static function getLinesFromTitle(&$object, $key_trad, $level=1, $under_title='', $withBlockLine=false, $key_is_id=false)
526
+	public static function getLinesFromTitle(&$object, $key_trad, $level = 1, $under_title = '', $withBlockLine = false, $key_is_id = false)
527 527
 	{
528 528
 		global $langs;
529 529
 		
@@ -535,17 +535,17 @@  discard block
 block discarded – undo
535 535
 		
536 536
 		$TLine = array();
537 537
 		$add_line = false;
538
-		$under_title_found=false;
538
+		$under_title_found = false;
539 539
 		
540 540
 		foreach ($object->lines as $key => &$line)
541 541
 		{
542 542
 			if (!$under_title_found && !empty($TTitle_under_search))
543 543
 			{
544
-				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true;
544
+				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search))) $under_title_found = true;
545 545
 			}
546 546
 			else
547 547
 			{
548
-				if ( ($key_is_id && $line->id == $key_trad) || (!$key_is_id && $line->product_type == 9 && $line->qty == $level && (in_array($line->desc, $TTitle_search) || in_array($line->label, $TTitle_search) )))
548
+				if (($key_is_id && $line->id == $key_trad) || (!$key_is_id && $line->product_type == 9 && $line->qty == $level && (in_array($line->desc, $TTitle_search) || in_array($line->label, $TTitle_search))))
549 549
 				{
550 550
 					if ($key_is_id) $level = $line->qty;
551 551
 					
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
 				
562 562
 				if ($add_line)
563 563
 				{
564
-					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue;
564
+					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line))) continue;
565 565
 					else $TLine[] = $line;
566 566
 				}
567 567
 			}
@@ -570,12 +570,12 @@  discard block
 block discarded – undo
570 570
 		return $TLine;
571 571
 	}
572 572
 	
573
-	public static function getLinesFromTitleId(&$object, $lineid, $withBlockLine=false)
573
+	public static function getLinesFromTitleId(&$object, $lineid, $withBlockLine = false)
574 574
 	{
575 575
 		return self::getLinesFromTitle($object, $lineid, '', '', $withBlockLine, true);
576 576
 	}
577 577
 	
578
-	public static function doUpdateLine(&$object, $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $type, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=0, $fk_unit = null, $notrigger = 0)
578
+	public static function doUpdateLine(&$object, $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $type, $txlocaltax1 = 0, $txlocaltax2 = 0, $price_base_type = 'HT', $info_bits = 0, $fk_parent_line = 0, $skip_update_total = 0, $fk_fournprice = null, $pa_ht = 0, $label = '', $special_code = 0, $array_options = 0, $situation_percent = 0, $fk_unit = null, $notrigger = 0)
579 579
 	{
580 580
 		$res = 0;
581 581
 		$object->db->begin();
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 		        break;
588 588
 		        
589 589
 		    case 'supplier_proposal':
590
-		        $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $array_options,'', $fk_unit);
590
+		        $res = $object->updateline($rowid, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $desc, $price_base_type, $info_bits, $special_code, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $type, $array_options, '', $fk_unit);
591 591
 		        break;
592 592
 		        
593 593
 			case 'commande':
@@ -616,9 +616,9 @@  discard block
 block discarded – undo
616 616
 				$factureRecLine->fetch($rowid);
617 617
 				$factureRecLine->array_options = $array_options;
618 618
 				$factureRecLine->insertExtraFields();
619
-				$rang=$factureRecLine->rang;
619
+				$rang = $factureRecLine->rang;
620 620
 				
621
-				$fk_product=0; $fk_remise_except=''; $pu_ttc=0;	
621
+				$fk_product = 0; $fk_remise_except = ''; $pu_ttc = 0;	
622 622
 				$res = $object->updateline($rowid, $desc, $pu, $qty, $txtva, $txlocaltax1, $txlocaltax2, $fk_product, $remise_percent, $price_base_type, $info_bits, $fk_remise_except, $pu_ttc, $type, $rang, $special_code, $label, $fk_unit);
623 623
 				break;
624 624
 		}
@@ -634,7 +634,7 @@  discard block
 block discarded – undo
634 634
 		global $db, $object;
635 635
 		
636 636
 		$TTitle = array();
637
-		if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {}
637
+		if (!empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {}
638 638
 		else {
639 639
 			if ($origin_line->element == 'propaldet')
640 640
 			{
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
 	 */
715 715
 	public static function addRecapPage(&$parameters, &$origin_pdf)
716 716
 	{
717
-		global $user,$conf,$langs;
717
+		global $user, $conf, $langs;
718 718
 		
719 719
 		$origin_file = $parameters['file'];
720 720
 		$outputlangs = $parameters['outputlangs'];
@@ -730,21 +730,21 @@  discard block
 block discarded – undo
730 730
 		$objmarge->marge_droite = 10;
731 731
 		
732 732
 		$objectref = dol_sanitizeFileName($object->ref);
733
-		if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref;
734
-		elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref;
735
-		elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref;
733
+		if ($object->element == 'propal') $dir = $conf->propal->dir_output.'/'.$objectref;
734
+		elseif ($object->element == 'commande') $dir = $conf->commande->dir_output.'/'.$objectref;
735
+		elseif ($object->element == 'facture') $dir = $conf->facture->dir_output.'/'.$objectref;
736 736
 		elseif ($object->element == 'facturerec') return; // no PDF for facturerec
737 737
 		else
738 738
 		{
739 739
 			setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings');
740 740
 			return -1;
741 741
 		}
742
-		$file = $dir . '/' . $objectref . '_recap.pdf';
742
+		$file = $dir.'/'.$objectref.'_recap.pdf';
743 743
 
744 744
 //		$pdf=pdf_getInstance($origin_pdf->format);
745
-		$pdf=pdf_getInstance(array(210, 297)); // Format A4 Portrait
746
-		$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
747
-		$pdf->SetAutoPageBreak(1,0);
745
+		$pdf = pdf_getInstance(array(210, 297)); // Format A4 Portrait
746
+		$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
747
+		$pdf->SetAutoPageBreak(1, 0);
748 748
 	             
749 749
 		if (class_exists('TCPDF'))
750 750
 		{
@@ -753,49 +753,49 @@  discard block
 block discarded – undo
753 753
 		}
754 754
 		$pdf->SetFont(pdf_getPDFFont($outputlangs));
755 755
 		// Set path to the background PDF File
756
-		if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
756
+		if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
757 757
 		{
758 758
 			$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
759 759
 			$tplidx = $pdf->importPage(1);
760 760
 		}
761 761
 
762 762
 		$pdf->Open();
763
-		$pagenb=0;
764
-		$pdf->SetDrawColor(128,128,128);
763
+		$pagenb = 0;
764
+		$pdf->SetDrawColor(128, 128, 128);
765 765
 
766 766
 		$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
767 767
 		$pdf->SetSubject($outputlangs->transnoentities("subtotalRecap"));
768 768
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
769 769
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
770 770
 		$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
771
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
771
+		if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
772 772
 
773
-		$pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite);   // Left, Top, Right
773
+		$pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite); // Left, Top, Right
774 774
 
775
-		$pagenb=0;
776
-		$pdf->SetDrawColor(128,128,128);
775
+		$pagenb = 0;
776
+		$pdf->SetDrawColor(128, 128, 128);
777 777
 
778 778
 			
779 779
 		// New page
780 780
 		$pdf->AddPage();
781
-		if (! empty($tplidx)) $pdf->useTemplate($tplidx);
781
+		if (!empty($tplidx)) $pdf->useTemplate($tplidx);
782 782
 		$pagenb++;
783 783
 		
784 784
 		
785 785
 		self::pagehead($objmarge, $pdf, $object, 1, $outputlangs);
786
-		$pdf->SetFont('','', $default_font_size - 1);
787
-		$pdf->MultiCell(0, 3, '');		// Set interline to 3
788
-		$pdf->SetTextColor(0,0,0);
786
+		$pdf->SetFont('', '', $default_font_size - 1);
787
+		$pdf->MultiCell(0, 3, ''); // Set interline to 3
788
+		$pdf->SetTextColor(0, 0, 0);
789 789
 		
790
-		$heightforinfotot = 25;	// Height reserved to output the info and total part
791
-		$heightforfooter = $objmarge->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
790
+		$heightforinfotot = 25; // Height reserved to output the info and total part
791
+		$heightforfooter = $objmarge->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
792 792
 		
793 793
 		$posx_designation = 25;
794 794
 		$posx_options = 150;
795 795
 		$posx_montant = 170;
796 796
 		
797 797
 		$tab_top = 72;
798
-		$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?72:20); // TODO à vérifier
798
+		$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 72 : 20); // TODO à vérifier
799 799
 		
800 800
 		$TTot = array('total_ht' => 0, 'total_ttc' => 0, 'TTotal_tva' => array());
801 801
 		
@@ -809,14 +809,14 @@  discard block
 block discarded – undo
809 809
 			$nexY = $tab_top + 10;
810 810
 			
811 811
 			$nblignes = count($TLine);
812
-			foreach($TLine as $i => &$line)
812
+			foreach ($TLine as $i => &$line)
813 813
 			{
814 814
 				$curY = $nexY;
815 815
 				
816 816
 				if (self::getNiveau($line) == 1) 
817 817
 				{
818
-					$pdf->SetFont('','B', $default_font_size - 1);   // Into loop to work with multipage
819
-					$curY+=2;
818
+					$pdf->SetFont('', 'B', $default_font_size - 1); // Into loop to work with multipage
819
+					$curY += 2;
820 820
 					
821 821
 					$TTot['total_ht'] += $line->total_ht;
822 822
 					$TTot['total_tva'] += $line->total_tva;
@@ -835,67 +835,67 @@  discard block
 block discarded – undo
835 835
 						$TTot['TTotal_tva_multicurrency'][$tx] += $amount;
836 836
 					}	
837 837
 				}
838
-				else $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
838
+				else $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
839 839
 				
840
-				$pdf->SetTextColor(0,0,0);
840
+				$pdf->SetTextColor(0, 0, 0);
841 841
 				
842 842
 				$pdf->setTopMargin($tab_top_newpage + 10);
843
-				$pdf->setPageOrientation('', 1, $heightforfooter+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
844
-				$pageposbefore=$pdf->getPage();
843
+				$pdf->setPageOrientation('', 1, $heightforfooter + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
844
+				$pageposbefore = $pdf->getPage();
845 845
 				
846
-				$showpricebeforepagebreak=1;
846
+				$showpricebeforepagebreak = 1;
847 847
 				
848 848
 				$decalage = (self::getNiveau($line) - 1) * 2;
849 849
 				
850 850
 				// Print: Designation
851 851
 				$label = $line->label;
852
-				if( (float)DOL_VERSION < 6 ) {
852
+				if ((float) DOL_VERSION < 6) {
853 853
 					$label = !empty($line->label) ? $line->label : $line->desc;
854 854
 				}
855 855
 				
856 856
 				
857 857
 				$pdf->startTransaction();
858
-				$pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true);
859
-				$pageposafter=$pdf->getPage();
858
+				$pdf->writeHTMLCell($posx_options - $posx_designation - $decalage, 3, $posx_designation + $decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J', true);
859
+				$pageposafter = $pdf->getPage();
860 860
 				if ($pageposafter > $pageposbefore)	// There is a pagebreak
861 861
 				{
862 862
 					$pdf->rollbackTransaction(true);
863
-					$pageposafter=$pageposbefore;
863
+					$pageposafter = $pageposbefore;
864 864
 					//print $pageposafter.'-'.$pageposbefore;exit;
865
-					$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
866
-					$pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true);
865
+					$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
866
+					$pdf->writeHTMLCell($posx_options - $posx_designation - $decalage, 3, $posx_designation + $decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J', true);
867 867
 
868
-					$pageposafter=$pdf->getPage();
869
-					$posyafter=$pdf->GetY();
868
+					$pageposafter = $pdf->getPage();
869
+					$posyafter = $pdf->GetY();
870 870
 					//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
871
-					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot)))	// There is no space left for total+free text
871
+					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter + $heightforinfotot)))	// There is no space left for total+free text
872 872
 					{
873
-						if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
873
+						if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
874 874
 						{
875
-							$pdf->AddPage('','',true);
876
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
875
+							$pdf->AddPage('', '', true);
876
+							if (!empty($tplidx)) $pdf->useTemplate($tplidx);
877 877
 							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
878
-							$pdf->setPage($pageposafter+1);
878
+							$pdf->setPage($pageposafter + 1);
879 879
 						}
880 880
 					}
881 881
 					else
882 882
 					{
883 883
 						// We found a page break
884
-						$showpricebeforepagebreak=0;
884
+						$showpricebeforepagebreak = 0;
885 885
 					}
886 886
 				}
887 887
 				else	// No pagebreak
888 888
 				{
889 889
 					$pdf->commitTransaction();
890 890
 				}
891
-				$posYAfterDescription=$pdf->GetY();
891
+				$posYAfterDescription = $pdf->GetY();
892 892
 
893 893
 				$nexY = $pdf->GetY();
894
-				$pageposafter=$pdf->getPage();
894
+				$pageposafter = $pdf->getPage();
895 895
 
896 896
 				$pdf->setPage($pageposbefore);
897 897
 				$pdf->setTopMargin($objmarge->marge_haute);
898
-				$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
898
+				$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
899 899
 
900 900
 				// We suppose that a too long description or photo were moved completely on next page
901 901
 				if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
@@ -908,14 +908,14 @@  discard block
 block discarded – undo
908 908
 				if (!empty($line->total_options))
909 909
 				{
910 910
 					$pdf->SetXY($posx_options, $curY);
911
-					$pdf->MultiCell($posx_montant-$posx_options-0.8, 3, price($line->total_options, 0, $outputlangs), 0, 'R', 0);
911
+					$pdf->MultiCell($posx_montant - $posx_options - 0.8, 3, price($line->total_options, 0, $outputlangs), 0, 'R', 0);
912 912
 				}
913 913
 				
914 914
 				// Print: Montant
915 915
 				$pdf->SetXY($posx_montant, $curY);
916
-				$pdf->MultiCell($objmarge->page_largeur-$objmarge->marge_droite-$posx_montant-0.8, 3, price($line->total_ht, 0, $outputlangs), 0, 'R', 0);
916
+				$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant - 0.8, 3, price($line->total_ht, 0, $outputlangs), 0, 'R', 0);
917 917
 				
918
-				$nexY+=2;    // Passe espace entre les lignes
918
+				$nexY += 2; // Passe espace entre les lignes
919 919
 
920 920
 				// Detect if some page were added automatically and output _tableau for past pages
921 921
 				while ($pagenb < $pageposafter)
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
 					
933 933
 					$pagenb++;
934 934
 					$pdf->setPage($pagenb);
935
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
935
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
936 936
 					if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
937 937
 				}
938 938
 			}
@@ -942,19 +942,19 @@  discard block
 block discarded – undo
942 942
 		if ($pagenb == 1)
943 943
 		{
944 944
 			self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $objmarge->page_hauteur - $tab_top - $heightforinfotot - $heightforfooter, 0, $outputlangs, 0, 0, $object->multicurrency_code);
945
-			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
945
+			$bottomlasttab = $objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
946 946
 		}
947 947
 		else
948 948
 		{
949 949
 			self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top_newpage, $objmarge->page_hauteur - $tab_top_newpage - $heightforinfotot - $heightforfooter, 0, $outputlangs, $hidetop, 0, $object->multicurrency_code);
950
-			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
950
+			$bottomlasttab = $objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
951 951
 		}
952 952
 		
953 953
 		// Affiche zone totaux
954
-		$posy=self::tableau_tot($objmarge, $pdf, $object, $bottomlasttab, $outputlangs, $TTot);
954
+		$posy = self::tableau_tot($objmarge, $pdf, $object, $bottomlasttab, $outputlangs, $TTot);
955 955
 		
956 956
 		$pdf->Close();
957
-		$pdf->Output($file,'F');
957
+		$pdf->Output($file, 'F');
958 958
 		
959 959
 		$pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file);
960 960
 		
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
 		$level = $line->qty; // TODO à améliorer
967 967
 		
968 968
 		$pdf->SetXY($objmarge->marge_gauche, $curY);
969
-		$pdf->MultiCell($posx_designation-$objmarge->marge_gauche-0.8, 5, $level, 0, 'L', 0);
969
+		$pdf->MultiCell($posx_designation - $objmarge->marge_gauche - 0.8, 5, $level, 0, 'L', 0);
970 970
 	}
971 971
 	
972 972
 	/**
@@ -980,50 +980,50 @@  discard block
 block discarded – undo
980 980
 	 */
981 981
 	private static function pagehead(&$objmarge, &$pdf, &$object, $showdetail, $outputlangs)
982 982
 	{
983
-		global $conf,$mysoc;
983
+		global $conf, $mysoc;
984 984
 
985 985
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
986 986
 
987
-		pdf_pagehead($pdf,$outputlangs,$objmarge->page_hauteur);
987
+		pdf_pagehead($pdf, $outputlangs, $objmarge->page_hauteur);
988 988
 
989
-		$pdf->SetTextColor(0,0,60);
990
-		$pdf->SetFont('','B', $default_font_size + 3);
989
+		$pdf->SetTextColor(0, 0, 60);
990
+		$pdf->SetFont('', 'B', $default_font_size + 3);
991 991
 
992
-		$posy=$objmarge->marge_haute;
993
-		$posx=$objmarge->page_largeur-$objmarge->marge_droite-100;
992
+		$posy = $objmarge->marge_haute;
993
+		$posx = $objmarge->page_largeur - $objmarge->marge_droite - 100;
994 994
 		
995
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
995
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
996 996
 
997
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
997
+		$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
998 998
 		if ($mysoc->logo)
999 999
 		{
1000 1000
 			if (is_readable($logo))
1001 1001
 			{
1002
-			    $height=pdf_getHeightForLogo($logo);
1003
-			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1002
+			    $height = pdf_getHeightForLogo($logo);
1003
+			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto)
1004 1004
 			}
1005 1005
 			else
1006 1006
 			{
1007
-				$pdf->SetTextColor(200,0,0);
1008
-				$pdf->SetFont('','B',$default_font_size - 2);
1009
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1007
+				$pdf->SetTextColor(200, 0, 0);
1008
+				$pdf->SetFont('', 'B', $default_font_size - 2);
1009
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1010 1010
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1011 1011
 			}
1012 1012
 			
1013
-			$posy+=35;
1013
+			$posy += 35;
1014 1014
 		}
1015 1015
 		else
1016 1016
 		{
1017
-			$text=$mysoc->name;
1017
+			$text = $mysoc->name;
1018 1018
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1019 1019
 			
1020
-			$posy+=15;
1020
+			$posy += 15;
1021 1021
 		}
1022 1022
 		
1023 1023
 		
1024
-		$pdf->SetTextColor(0,0,0);
1025
-		$pdf->SetFont('','B', $default_font_size + 2);
1026
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
1024
+		$pdf->SetTextColor(0, 0, 0);
1025
+		$pdf->SetFont('', 'B', $default_font_size + 2);
1026
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
1027 1027
 		
1028 1028
 		$key = 'subtotalPropalTitle';
1029 1029
 		if ($object->element == 'commande') $key = 'subtotalCommandeTitle';
@@ -1032,14 +1032,14 @@  discard block
 block discarded – undo
1032 1032
 		
1033 1033
 		$pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L');
1034 1034
 		
1035
-		$pdf->SetFont('','', $default_font_size);
1036
-		$pdf->SetXY($objmarge->page_largeur-$objmarge->marge_droite-40,$posy);
1035
+		$pdf->SetFont('', '', $default_font_size);
1036
+		$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - 40, $posy);
1037 1037
 		$pdf->MultiCell(40, 4, dol_print_date($object->date, 'daytext'), '', 'R');
1038 1038
 		
1039 1039
 		$posy += 8;
1040 1040
 			
1041
-		$pdf->SetFont('','B', $default_font_size + 2);
1042
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
1041
+		$pdf->SetFont('', 'B', $default_font_size + 2);
1042
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
1043 1043
 		$pdf->MultiCell(70, 4, $outputlangs->transnoentities('subtotalRecapLot'), '', 'L');
1044 1044
 		
1045 1045
 	}
@@ -1057,44 +1057,44 @@  discard block
 block discarded – undo
1057 1057
 	 *   @param		string		$currency		Currency code
1058 1058
 	 *   @return	void
1059 1059
 	 */
1060
-	private static function tableau(&$objmarge, &$pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1060
+	private static function tableau(&$objmarge, &$pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1061 1061
 	{
1062 1062
 		global $conf;
1063 1063
 		
1064 1064
 		// Force to disable hidetop and hidebottom
1065
-		$hidebottom=0;
1066
-		if ($hidetop) $hidetop=-1;
1065
+		$hidebottom = 0;
1066
+		if ($hidetop) $hidetop = -1;
1067 1067
 
1068 1068
 		$currency = !empty($currency) ? $currency : $conf->currency;
1069 1069
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1070 1070
 
1071 1071
 		// Amount in (at tab_top - 1)
1072
-		$pdf->SetTextColor(0,0,0);
1073
-		$pdf->SetFont('','',$default_font_size);
1072
+		$pdf->SetTextColor(0, 0, 0);
1073
+		$pdf->SetFont('', '', $default_font_size);
1074 1074
 
1075 1075
 		if (empty($hidetop))
1076 1076
 		{
1077
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1078
-			$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5);
1077
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1078
+			$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4.5);
1079 1079
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1080 1080
 			
1081
-			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite-$objmarge->marge_gauche, 8, 'F', null, explode(',',$conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1081
+			if (!empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) $pdf->Rect($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur - $objmarge->marge_droite - $objmarge->marge_gauche, 8, 'F', null, explode(',', $conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR));
1082 1082
 			
1083 1083
 			
1084
-			$pdf->line($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top);	// line prend une position y en 2eme param et 4eme param
1084
+			$pdf->line($objmarge->marge_gauche, $tab_top, $objmarge->page_largeur - $objmarge->marge_droite, $tab_top); // line prend une position y en 2eme param et 4eme param
1085 1085
 
1086
-			$pdf->SetXY($posx_designation, $tab_top+2);
1087
-			$pdf->MultiCell($posx_options - $posx_designation,2, $outputlangs->transnoentities("Designation"),'','L');
1088
-			$pdf->SetXY($posx_options, $tab_top+2);
1089
-			$pdf->MultiCell($posx_montant - $posx_options,2, $outputlangs->transnoentities("Options"),'','R');
1090
-			$pdf->SetXY($posx_montant, $tab_top+2);
1091
-			$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R');
1086
+			$pdf->SetXY($posx_designation, $tab_top + 2);
1087
+			$pdf->MultiCell($posx_options - $posx_designation, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1088
+			$pdf->SetXY($posx_options, $tab_top + 2);
1089
+			$pdf->MultiCell($posx_montant - $posx_options, 2, $outputlangs->transnoentities("Options"), '', 'R');
1090
+			$pdf->SetXY($posx_montant, $tab_top + 2);
1091
+			$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant, 2, $outputlangs->transnoentities("Amount"), '', 'R');
1092 1092
 			
1093
-			$pdf->line($objmarge->marge_gauche, $tab_top+8, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top+8);	// line prend une position y en 2eme param et 4eme param
1093
+			$pdf->line($objmarge->marge_gauche, $tab_top + 8, $objmarge->page_largeur - $objmarge->marge_droite, $tab_top + 8); // line prend une position y en 2eme param et 4eme param
1094 1094
 		}
1095 1095
 		else
1096 1096
 		{
1097
-			$pdf->line($objmarge->marge_gauche, $tab_top-2, $objmarge->page_largeur-$objmarge->marge_droite, $tab_top-2);	// line prend une position y en 2eme param et 4eme param
1097
+			$pdf->line($objmarge->marge_gauche, $tab_top - 2, $objmarge->page_largeur - $objmarge->marge_droite, $tab_top - 2); // line prend une position y en 2eme param et 4eme param
1098 1098
 		}
1099 1099
 		
1100 1100
 	}
@@ -1103,29 +1103,29 @@  discard block
 block discarded – undo
1103 1103
 	{
1104 1104
 		global $conf;
1105 1105
 		
1106
-		$pdf->line($objmarge->marge_gauche, $posy, $objmarge->page_largeur-$objmarge->marge_droite, $posy);	// line prend une position y en 2eme param et 4eme param
1106
+		$pdf->line($objmarge->marge_gauche, $posy, $objmarge->page_largeur - $objmarge->marge_droite, $posy); // line prend une position y en 2eme param et 4eme param
1107 1107
 		
1108 1108
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1109 1109
 		
1110
-		$tab2_top = $posy+2;
1110
+		$tab2_top = $posy + 2;
1111 1111
 		$tab2_hl = 4;
1112
-		$pdf->SetFont('','', $default_font_size - 1);
1112
+		$pdf->SetFont('', '', $default_font_size - 1);
1113 1113
 
1114 1114
 		// Tableau total
1115 1115
 		$col1x = 120; $col2x = 170;
1116 1116
 		if ($objmarge->page_largeur < 210) // To work with US executive format
1117 1117
 		{
1118
-			$col2x-=20;
1118
+			$col2x -= 20;
1119 1119
 		}
1120 1120
 		$largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x);
1121 1121
 
1122
-		$useborder=0;
1122
+		$useborder = 0;
1123 1123
 		$index = 0;
1124 1124
 
1125 1125
 		// Total HT
1126
-		$pdf->SetFillColor(255,255,255);
1126
+		$pdf->SetFillColor(255, 255, 255);
1127 1127
 		$pdf->SetXY($col1x, $tab2_top + 0);
1128
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1128
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1129 1129
 
1130 1130
 		// $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1) ? $TTot['multicurrency_total_ht'] : $TTot['total_ht'];
1131 1131
 		$total_ht = $TTot['total_ht'];
@@ -1133,10 +1133,10 @@  discard block
 block discarded – undo
1133 1133
 		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht, 0, $outputlangs), 0, 'R', 1);
1134 1134
 
1135 1135
 		// Show VAT by rates and total
1136
-		$pdf->SetFillColor(248,248,248);
1136
+		$pdf->SetFillColor(248, 248, 248);
1137 1137
 		
1138
-		$atleastoneratenotnull=0;
1139
-		foreach($TTot['TTotal_tva'] as $tvakey => $tvaval)
1138
+		$atleastoneratenotnull = 0;
1139
+		foreach ($TTot['TTotal_tva'] as $tvakey => $tvaval)
1140 1140
 		{
1141 1141
 			if ($tvakey != 0)    // On affiche pas taux 0
1142 1142
 			{
@@ -1145,15 +1145,15 @@  discard block
 block discarded – undo
1145 1145
 				$index++;
1146 1146
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1147 1147
 
1148
-				$tvacompl='';
1149
-				if (preg_match('/\*/',$tvakey))
1148
+				$tvacompl = '';
1149
+				if (preg_match('/\*/', $tvakey))
1150 1150
 				{
1151
-					$tvakey=str_replace('*','',$tvakey);
1151
+					$tvakey = str_replace('*', '', $tvakey);
1152 1152
 					$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1153 1153
 				}
1154
-				$totalvat =$outputlangs->transnoentities("TotalVAT").' ';
1155
-				$totalvat.=vatrate($tvakey,1).$tvacompl;
1156
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1154
+				$totalvat = $outputlangs->transnoentities("TotalVAT").' ';
1155
+				$totalvat .= vatrate($tvakey, 1).$tvacompl;
1156
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1157 1157
 
1158 1158
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1159 1159
 				$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1163,16 +1163,16 @@  discard block
 block discarded – undo
1163 1163
 		// Total TTC
1164 1164
 		$index++;
1165 1165
 		$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1166
-		$pdf->SetTextColor(0,0,60);
1167
-		$pdf->SetFillColor(224,224,224);
1168
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1166
+		$pdf->SetTextColor(0, 0, 60);
1167
+		$pdf->SetFillColor(224, 224, 224);
1168
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1169 1169
 
1170 1170
 		// $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $TTot['multicurrency_total_ttc'] : $TTot['total_ttc'];
1171 1171
 		$total_ttc = $TTot['total_ttc'];
1172 1172
 		$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1173 1173
 		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1174 1174
 
1175
-		$pdf->SetTextColor(0,0,0);
1175
+		$pdf->SetTextColor(0, 0, 0);
1176 1176
 				
1177 1177
 		$index++;
1178 1178
 		return ($tab2_top + ($tab2_hl * $index));
@@ -1191,22 +1191,22 @@  discard block
 block discarded – undo
1191 1191
 	 * @param	int		$hidebottom		Hide bottom
1192 1192
 	 * @return	void
1193 1193
 	 */
1194
-    private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1194
+    private static function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0)
1195 1195
     {
1196
-	    if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1197
-	    $pdf->line($x+$l, $y, $x+$l, $y+$h);
1198
-	    if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1199
-	    $pdf->line($x, $y+$h, $x, $y);
1196
+	    if (empty($hidetop) || $hidetop == -1) $pdf->line($x, $y, $x + $l, $y);
1197
+	    $pdf->line($x + $l, $y, $x + $l, $y + $h);
1198
+	    if (empty($hidebottom)) $pdf->line($x + $l, $y + $h, $x, $y + $h);
1199
+	    $pdf->line($x, $y + $h, $x, $y);
1200 1200
     }
1201 1201
 	
1202 1202
 	
1203
-	public static function concat(&$outputlangs, $files, $fileoutput='')
1203
+	public static function concat(&$outputlangs, $files, $fileoutput = '')
1204 1204
 	{
1205 1205
 		global $conf;
1206 1206
 		
1207 1207
 		if (empty($fileoutput)) $fileoutput = $file[0];
1208 1208
 		
1209
-		$pdf=pdf_getInstance();
1209
+		$pdf = pdf_getInstance();
1210 1210
         if (class_exists('TCPDF'))
1211 1211
         {
1212 1212
             $pdf->setPrintHeader(false);
@@ -1214,10 +1214,10 @@  discard block
 block discarded – undo
1214 1214
         }
1215 1215
         $pdf->SetFont(pdf_getPDFFont($outputlangs));
1216 1216
 
1217
-        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1217
+        if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1218 1218
 
1219 1219
 		
1220
-		foreach($files as $file)
1220
+		foreach ($files as $file)
1221 1221
 		{
1222 1222
 			$pagecount = $pdf->setSourceFile($file);
1223 1223
 			for ($i = 1; $i <= $pagecount; $i++)
@@ -1229,8 +1229,8 @@  discard block
 block discarded – undo
1229 1229
 			}
1230 1230
 		}
1231 1231
 		
1232
-		$pdf->Output($fileoutput,'F');
1233
-		if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK));
1232
+		$pdf->Output($fileoutput, 'F');
1233
+		if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK));
1234 1234
 
1235 1235
 		return $pagecount;
1236 1236
 	}
@@ -1243,7 +1243,7 @@  discard block
 block discarded – undo
1243 1243
 	 */
1244 1244
 	public static function hasNcTitle(&$line)
1245 1245
 	{
1246
-		if(isset($line->has_nc_title)) return $line->has_nc_title;
1246
+		if (isset($line->has_nc_title)) return $line->has_nc_title;
1247 1247
 
1248 1248
 		$TTitle = self::getAllTitleFromLine($line);
1249 1249
 		foreach ($TTitle as &$line_title)
Please login to merge, or discard this patch.
core/modules/modSubtotal.class.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  * 	\ingroup	titre
24 24
  * 	\brief		Description and activation file for module titre
25 25
  */
26
-include_once DOL_DOCUMENT_ROOT . "/core/modules/DolibarrModules.class.php";
26
+include_once DOL_DOCUMENT_ROOT."/core/modules/DolibarrModules.class.php";
27 27
 
28 28
 /**
29 29
  * Description and activation class for module titre
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
         $this->version = '3.1.6';
67 67
         // Key used in llx_const table to save module status enabled/disabled
68 68
         // (where MYMODULE is value of property name of module in uppercase)
69
-        $this->const_name = 'MAIN_MODULE_' . strtoupper($this->name);
69
+        $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
70 70
         // Where to store the module in setup page
71 71
         // (0=common,1=interface,2=others,3=very specific)
72 72
         $this->special = 2;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
         // List of modules id that must be enabled if this module is enabled
126 126
         $this->depends = array();
127 127
 
128
-		$this->conflictwith=array('modMilestone');
128
+		$this->conflictwith = array('modMilestone');
129 129
         // List of modules id to disable if this one is disabled
130 130
         $this->requiredby = array();
131 131
         // Minimum version of PHP required by module
@@ -190,20 +190,20 @@  discard block
 block discarded – undo
190 190
         // 'categories_x'		to add a tab in category view
191 191
         // (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
192 192
         // Dictionnaries
193
-        if (! isset($conf->subtotal->enabled)) {
194
-            $conf->subtotal=new stdClass();
193
+        if (!isset($conf->subtotal->enabled)) {
194
+            $conf->subtotal = new stdClass();
195 195
             $conf->subtotal->enabled = 0;
196 196
         }
197 197
         $this->dictionaries = array(
198 198
 			'langs'=>'subtotal@subtotal',
199
-            'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'),		// List of tables we want to see into dictonnary editor
200
-            'tablib'=>array($langs->trans('subtotalFreeLineDictionary')),													// Label of tables
201
-            'tabsql'=>array('SELECT f.rowid as rowid, f.label, f.content, f.entity, f.active FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text as f WHERE f.entity='.$conf->entity),	// Request to select fields
202
-            'tabsqlsort'=>array('label ASC'),																					// Sort order
203
-            'tabfield'=>array('label,content'),							// List of fields (result of select to show dictionary)
204
-            'tabfieldvalue'=>array('label,content'),						// List of fields (list of fields to edit a record)
205
-            'tabfieldinsert'=>array('label,content,entity'),					// List of fields (list of fields for insert)
206
-            'tabrowid'=>array('rowid'),											// Name of columns with primary key (try to always name it 'rowid')
199
+            'tabname'=>array(MAIN_DB_PREFIX.'c_subtotal_free_text'), // List of tables we want to see into dictonnary editor
200
+            'tablib'=>array($langs->trans('subtotalFreeLineDictionary')), // Label of tables
201
+            'tabsql'=>array('SELECT f.rowid as rowid, f.label, f.content, f.entity, f.active FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text as f WHERE f.entity='.$conf->entity), // Request to select fields
202
+            'tabsqlsort'=>array('label ASC'), // Sort order
203
+            'tabfield'=>array('label,content'), // List of fields (result of select to show dictionary)
204
+            'tabfieldvalue'=>array('label,content'), // List of fields (list of fields to edit a record)
205
+            'tabfieldinsert'=>array('label,content,entity'), // List of fields (list of fields for insert)
206
+            'tabrowid'=>array('rowid'), // Name of columns with primary key (try to always name it 'rowid')
207 207
             'tabcond'=>array($conf->subtotal->enabled)	
208 208
 		);
209 209
         /* Example:
@@ -478,7 +478,7 @@  discard block
 block discarded – undo
478 478
 	
479 479
         $extra = new ExtraFields($db); // propaldet, commandedet, facturedet
480 480
         $TElementType = array('propaldet', 'commandedet', 'facturedet', 'supplier_proposaldet', 'commande_fournisseurdet', 'facture_fourn_det');
481
-        foreach($TElementType as $element_type) {
481
+        foreach ($TElementType as $element_type) {
482 482
             $extra->addExtraField('show_total_ht', 'Afficher le Total HT sur le sous-total', 'int', 0, 10, $element_type, 0, 0, '', unserialize('a:1:{s:7:"options";a:1:{s:0:"";N;}}'), 0, '', 0, 1);
483 483
             $extra->addExtraField('show_reduc', 'Afficher la réduction sur le sous-total', 'int', 0, 10, $element_type, 0, 0, '', unserialize('a:1:{s:7:"options";a:1:{s:0:"";N;}}'), 0, '', 0, 1);
484 484
         }
Please login to merge, or discard this patch.