Passed
Pull Request — master (#135)
by
unknown
01:44
created
class/actions_subtotal.class.php 3 patches
Indentation   +298 added lines, -298 removed lines patch added patch discarded remove patch
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	 * @return     void
102 102
 	 */
103 103
     
104
-    var $module_number = 104777;
104
+	var $module_number = 104777;
105 105
     
106
-    function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
107
-    {
108
-      	global $langs,$db,$user, $conf;
106
+	function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
107
+	{
108
+	  	global $langs,$db,$user, $conf;
109 109
 		
110 110
 		$langs->load('subtotal@subtotal');
111 111
 		
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
 				$createRight = $user->rights->facture->creer;
121 121
 			} elseif($object->element == 'order_supplier' )
122 122
 			{
123
-			    $createRight = $user->rights->fournisseur->commande->creer;
123
+				$createRight = $user->rights->fournisseur->commande->creer;
124 124
 			} elseif($object->element == 'invoice_supplier' )
125 125
 			{
126
-			    $createRight = $user->rights->fournisseur->facture->creer;
126
+				$createRight = $user->rights->fournisseur->facture->creer;
127 127
 			}
128 128
 			
129 129
 			if ($object->statut == 0  && $createRight) {
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 					
174 174
 					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
175 175
 					
176
-	    			TSubtotal::addSubTotalLine($object, $title, $qty);
176
+					TSubtotal::addSubTotalLine($object, $title, $qty);
177 177
 				}
178 178
 				else if($action==='ask_deleteallline') {
179 179
 						$form=new Form($db);
@@ -395,36 +395,36 @@  discard block
 block discarded – undo
395 395
 		$TContext = explode(':',$parameters['context']);
396 396
 		if (
397 397
 				in_array('invoicecard',$TContext)
398
-		        || in_array('invoicesuppliercard',$TContext)
398
+				|| in_array('invoicesuppliercard',$TContext)
399 399
 				|| in_array('propalcard',$TContext)
400 400
 				|| in_array('ordercard',$TContext)
401
-		        || in_array('ordersuppliercard',$TContext)
401
+				|| in_array('ordersuppliercard',$TContext)
402 402
 				|| in_array('invoicereccard',$TContext)
403 403
 			)
404
-	        {	
405
-	            $hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
406
-	            $hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
404
+			{	
405
+				$hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
406
+				$hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
407 407
 				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0;
408 408
 				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
409 409
 				
410 410
 				$var=false;
411
-		     	$out.= '<tr '.$bc[$var].'>
411
+			 	$out.= '<tr '.$bc[$var].'>
412 412
 		     			<td colspan="4" align="right">
413 413
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
414 414
 		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
415 415
 		     			</td>
416 416
 		     			</tr>';
417 417
 				
418
-		     	$var=!$var;
419
-		     	$out.= '<tr '.$bc[$var].'>
418
+			 	$var=!$var;
419
+			 	$out.= '<tr '.$bc[$var].'>
420 420
 		     			<td colspan="4" align="right">
421 421
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
422 422
 		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
423 423
 		     			</td>
424 424
 		     			</tr>';
425 425
 		     	
426
-		     	$var=!$var;
427
-		     	$out.= '<tr '.$bc[$var].'>
426
+			 	$var=!$var;
427
+			 	$out.= '<tr '.$bc[$var].'>
428 428
 		     			<td colspan="4" align="right">
429 429
 		     				<label for="hideprices">'.$langs->trans('SubTotalhidePrice').'</label>
430 430
 		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
@@ -436,9 +436,9 @@  discard block
 block discarded – undo
436 436
 				if ( 
437 437
 					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
438 438
 					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
439
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
439
+					|| (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
440 440
 					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
441
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
441
+					|| (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
442 442
 					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
443 443
 				)
444 444
 				{
@@ -457,19 +457,19 @@  discard block
 block discarded – undo
457 457
 			}
458 458
 			
459 459
 		
460
-        return 1;
460
+		return 1;
461 461
 	} 
462 462
 	 
463
-    function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
464
-    {
463
+	function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
464
+	{
465 465
 		
466
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
467
-        {
466
+		if (in_array('invoicecard',explode(':',$parameters['context'])))
467
+		{
468 468
         	
469
-        }
469
+		}
470 470
 		
471
-        return 0;
472
-    }
471
+		return 0;
472
+	}
473 473
 	
474 474
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
475 475
 		global $conf;
@@ -518,11 +518,11 @@  discard block
 block discarded – undo
518 518
 	
519 519
 		if (
520 520
 				in_array('invoicecard',explode(':',$parameters['context']))
521
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
521
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
522 522
 				|| in_array('propalcard',explode(':',$parameters['context']))
523
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
523
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
524 524
 				|| in_array('ordercard',explode(':',$parameters['context']))
525
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
525
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
526 526
 				|| in_array('invoicereccard',explode(':',$parameters['context']))
527 527
 		) {
528 528
 			
@@ -601,20 +601,20 @@  discard block
 block discarded – undo
601 601
 				in_array('invoicecard',explode(':',$parameters['context']))
602 602
 				|| in_array('propalcard',explode(':',$parameters['context']))
603 603
 				|| in_array('ordercard',explode(':',$parameters['context']))
604
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
605
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
606
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
604
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
605
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
606
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
607 607
 			)
608
-	        {								
608
+			{								
609 609
 				if(in_array('invoicecard',explode(':',$parameters['context']))) {
610 610
 					$sessname = 'subtotal_hideInnerLines_facture';	
611 611
 					$sessname2 = 'subtotal_hidedetails_facture';
612 612
 					$sessname3 = 'subtotal_hideprices_facture';
613 613
 				}
614 614
 				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
615
-				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
616
-				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
617
-				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
615
+					$sessname = 'subtotal_hideInnerLines_facture_fournisseur';
616
+					$sessname2 = 'subtotal_hidedetails_facture_fournisseur';
617
+					$sessname3 = 'subtotal_hideprices_facture_fournisseur';
618 618
 				}
619 619
 				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
620 620
 					$sessname = 'subtotal_hideInnerLines_propal';
@@ -622,9 +622,9 @@  discard block
 block discarded – undo
622 622
 					$sessname3 = 'subtotal_hideprices_propal';
623 623
 				}
624 624
 				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
625
-				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
626
-				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
627
-				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
625
+					$sessname = 'subtotal_hideInnerLines_supplier_proposal';
626
+					$sessname2 = 'subtotal_hidedetails_supplier_proposal';
627
+					$sessname3 = 'subtotal_hideprices_supplier_proposal';
628 628
 				}
629 629
 				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
630 630
 					$sessname = 'subtotal_hideInnerLines_commande';
@@ -632,9 +632,9 @@  discard block
 block discarded – undo
632 632
 					$sessname3 = 'subtotal_hideprices_commande';
633 633
 				}
634 634
 				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
635
-				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
636
-				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
637
-				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
635
+					$sessname = 'subtotal_hideInnerLines_commande_fournisseur';
636
+					$sessname2 = 'subtotal_hidedetails_commande_fournisseur';
637
+					$sessname3 = 'subtotal_hideprices_commande_fournisseur';
638 638
 				}
639 639
 				else {
640 640
 					$sessname = 'subtotal_hideInnerLines_unknown';
@@ -659,17 +659,17 @@  discard block
 block discarded – undo
659 659
 				foreach($object->lines as &$line) {
660 660
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
661 661
 					    
662
-                        if($line->qty>=90) {
663
-                            $line->modsubtotal_total = 1;
664
-                        }
665
-                        else{
666
-                            $line->modsubtotal_title = 1;
667
-                        }
662
+						if($line->qty>=90) {
663
+							$line->modsubtotal_total = 1;
664
+						}
665
+						else{
666
+							$line->modsubtotal_title = 1;
667
+						}
668 668
                         
669 669
 						$line->total_ht = $this->getTotalLineFromObject($object, $line, '');
670 670
 					}
671
-	        	}
672
-	        }
671
+				}
672
+			}
673 673
 			
674 674
 		}
675 675
 		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 				 */
687 687
 				else if($object->element=='invoice_supplier')
688 688
 				{
689
-				    $object->deleteline($idLine);
689
+					$object->deleteline($idLine);
690 690
 				}
691 691
 				/**
692 692
 				 * @var $object Propal
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 				 */
710 710
 				else if($object->element=='order_supplier')
711 711
 				{
712
-				    $object->deleteline($idLine);
712
+					$object->deleteline($idLine);
713 713
 				}
714 714
 				/**
715 715
 				 * @var $object Facturerec
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
 		
781 781
 		foreach($object->lines as $l) {
782 782
 		
783
-		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
783
+			$lid = (!empty($l->rowid) ? $l->rowid : $l->id);
784 784
 			if($lid == $lineid) {
785 785
 
786 786
 				$found = true;
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 			
790 790
 			if($found) {
791 791
 				
792
-			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
792
+				$Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
793 793
 				
794 794
 				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
795 795
 					break; // end of story
@@ -916,7 +916,7 @@  discard block
 block discarded – undo
916 916
 		if(method_exists('Closure','bind')) {
917 917
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
918 918
 			$sweetsThief = function ($pdf) {
919
-		    		return $pdf->bMargin ;
919
+					return $pdf->bMargin ;
920 920
 			};
921 921
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
922 922
 	
@@ -984,7 +984,7 @@  discard block
 block discarded – undo
984 984
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
985 985
 					$total_to_print = price($total);
986 986
 					
987
-                    $line->total_ht = $total;
987
+					$line->total_ht = $total;
988 988
 					$line->total = $total;
989 989
 					$line->total_tva = $total_tva;
990 990
 					$line->total_ttc = $total_ttc;
@@ -1133,7 +1133,7 @@  discard block
 block discarded – undo
1133 1133
 	}
1134 1134
 	
1135 1135
 	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1136
-	    global $conf, $hideprices, $hookmanager;
1136
+		global $conf, $hideprices, $hookmanager;
1137 1137
 		
1138 1138
 		if(is_array($parameters)) $i = & $parameters['i'];
1139 1139
 		else $i = (int)$parameters;
@@ -1172,7 +1172,7 @@  discard block
 block discarded – undo
1172 1172
 			}
1173 1173
 		}
1174 1174
 		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1175
-		    $this->resprints = price($object->lines[$i]->total_ht);
1175
+			$this->resprints = price($object->lines[$i]->total_ht);
1176 1176
 		}
1177 1177
 		
1178 1178
 		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
 	}
1302 1302
 	
1303 1303
 	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1304
-	    global $conf,$hideprices,$hookmanager;
1304
+		global $conf,$hideprices,$hookmanager;
1305 1305
 
1306 1306
 		if(is_array($parameters)) $i = & $parameters['i'];
1307 1307
 		else $i = (int)$parameters;
@@ -1309,18 +1309,18 @@  discard block
 block discarded – undo
1309 1309
 		if($this->isModSubtotalLine($parameters,$object) ) {
1310 1310
 			$this->resprints = ' ';
1311 1311
 
1312
-            $line = $object->lines[$i];
1312
+			$line = $object->lines[$i];
1313 1313
 
1314
-            // On récupère les montants du bloc pour les afficher dans la ligne de sous-total
1315
-            if(TSubtotal::isSubtotal($line)) {
1316
-                $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1314
+			// On récupère les montants du bloc pour les afficher dans la ligne de sous-total
1315
+			if(TSubtotal::isSubtotal($line)) {
1316
+				$parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1317 1317
 
1318
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1319
-                if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1320
-                    $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1321
-                    $this->resprints = price($TTotal['total_subprice']);
1322
-                }
1323
-            }
1318
+				if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1319
+				if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1320
+					$TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1321
+					$this->resprints = price($TTotal['total_subprice']);
1322
+				}
1323
+			}
1324 1324
 		
1325 1325
 			if((float)DOL_VERSION<=3.6) {
1326 1326
 				return '';
@@ -1336,58 +1336,58 @@  discard block
 block discarded – undo
1336 1336
 		(!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))
1337 1337
 		)
1338 1338
 		{
1339
-		    // alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1340
-		    if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1341
-		    {
1342
-		        $this->resprints = ' ';
1339
+			// alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1340
+			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1341
+			{
1342
+				$this->resprints = ' ';
1343 1343
 		        
1344
-		        // currentcontext à modifier celon l'appel
1345
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1346
-		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1344
+				// currentcontext à modifier celon l'appel
1345
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1346
+				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1347 1347
 		        
1348
-		    }
1348
+			}
1349 1349
 		}
1350 1350
 		// Cache le prix pour les lignes standards dolibarr qui sont dans un ensemble
1351 1351
 		else if (!empty($hideprices))
1352 1352
 		{
1353 1353
 		    
1354
-		    // Check if a title exist for this line && if the title have subtotal
1355
-		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1356
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1357
-		    {
1354
+			// Check if a title exist for this line && if the title have subtotal
1355
+			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1356
+			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1357
+			{
1358 1358
 		        
1359
-		        $this->resprints = ' ';
1359
+				$this->resprints = ' ';
1360 1360
 		        
1361
-		        // currentcontext à modifier celon l'appel
1362
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1363
-		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1364
-		    }
1361
+				// currentcontext à modifier celon l'appel
1362
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1363
+				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1364
+			}
1365 1365
 		}
1366 1366
 		
1367 1367
 		return 0;
1368 1368
 	}
1369 1369
 	
1370 1370
 	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1371
-	    global $conf,$hideprices,$hookmanager;
1371
+		global $conf,$hideprices,$hookmanager;
1372 1372
 
1373
-        if(is_array($parameters)) $i = & $parameters['i'];
1374
-        else $i = (int) $parameters;
1373
+		if(is_array($parameters)) $i = & $parameters['i'];
1374
+		else $i = (int) $parameters;
1375 1375
 
1376 1376
 		if($this->isModSubtotalLine($parameters,$object) ) {
1377 1377
 			$this->resprints = ' ';
1378 1378
 
1379
-            $line = $object->lines[$i];
1379
+			$line = $object->lines[$i];
1380 1380
 
1381
-            // Affichage de la remise 
1382
-            if(TSubtotal::isSubtotal($line)) {
1383
-                $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1381
+			// Affichage de la remise 
1382
+			if(TSubtotal::isSubtotal($line)) {
1383
+				$parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1384 1384
 
1385
-                if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1386
-                if(! empty($parentTitle->array_options['options_show_reduc'])) {
1387
-                    $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1388
-                    $this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
1389
-                }
1390
-            }
1385
+				if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1386
+				if(! empty($parentTitle->array_options['options_show_reduc'])) {
1387
+					$TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1388
+					$this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
1389
+				}
1390
+			}
1391 1391
 		
1392 1392
 			if((float)DOL_VERSION<=3.6) {
1393 1393
 				return '';
@@ -1397,15 +1397,15 @@  discard block
 block discarded – undo
1397 1397
 			}
1398 1398
 		}
1399 1399
 		elseif (!empty($hideprices)
1400
-		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1401
-		        )
1402
-		    {
1403
-		        if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1404
-		        {
1405
-		            $this->resprints = ' ';
1406
-		            return 1;
1407
-		        }
1408
-		    }
1400
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1401
+				)
1402
+			{
1403
+				if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1404
+				{
1405
+					$this->resprints = ' ';
1406
+					return 1;
1407
+				}
1408
+			}
1409 1409
 		
1410 1410
 		return 0;
1411 1411
 	}
@@ -1441,7 +1441,7 @@  discard block
 block discarded – undo
1441 1441
 	}
1442 1442
 	
1443 1443
 	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
1444
-	    global $conf,$hideprices,$hookmanager;
1444
+		global $conf,$hideprices,$hookmanager;
1445 1445
 	    
1446 1446
 		if($this->isModSubtotalLine($parameters,$object) ){
1447 1447
 			$this->resprints = ' ';
@@ -1466,31 +1466,31 @@  discard block
 block discarded – undo
1466 1466
 		(!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))
1467 1467
 		)
1468 1468
 		{
1469
-		    // alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1470
-		    if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1471
-		    {
1472
-		        $this->resprints = ' ';
1469
+			// alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1470
+			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1471
+			{
1472
+				$this->resprints = ' ';
1473 1473
 		        
1474
-		        // currentcontext à modifier celon l'appel
1475
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1476
-		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1477
-		    }
1474
+				// currentcontext à modifier celon l'appel
1475
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1476
+				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1477
+			}
1478 1478
 		}
1479 1479
 		// Cache le prix pour les lignes standards dolibarr qui sont dans un ensemble
1480 1480
 		else if (!empty($hideprices))
1481 1481
 		{
1482 1482
 		    
1483
-		    // Check if a title exist for this line && if the title have subtotal
1484
-		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1485
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1486
-		    {
1483
+			// Check if a title exist for this line && if the title have subtotal
1484
+			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1485
+			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1486
+			{
1487 1487
 		        
1488
-		        $this->resprints = ' ';
1488
+				$this->resprints = ' ';
1489 1489
 		        
1490
-		        // currentcontext à modifier celon l'appel
1491
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1492
-		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1493
-		    }
1490
+				// currentcontext à modifier celon l'appel
1491
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1492
+				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1493
+			}
1494 1494
 		}
1495 1495
 		
1496 1496
 		return 0;
@@ -1614,25 +1614,25 @@  discard block
 block discarded – undo
1614 1614
 		
1615 1615
 		$this->add_numerotation($object);	
1616 1616
 		
1617
-        foreach($object->lines as $k => &$l) {
1618
-            if(TSubtotal::isSubtotal($l)) {
1619
-                $parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1620
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1621
-                if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_total_ht'])) {
1622
-                    $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1623
-                }
1624
-            }
1625
-        }
1617
+		foreach($object->lines as $k => &$l) {
1618
+			if(TSubtotal::isSubtotal($l)) {
1619
+				$parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1620
+				if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1621
+				if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_total_ht'])) {
1622
+					$l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1623
+				}
1624
+			}
1625
+		}
1626 1626
 
1627 1627
 		$hideInnerLines = (int)GETPOST('hideInnerLines');
1628 1628
 		$hidedetails = (int)GETPOST('hidedetails');
1629 1629
 
1630 1630
 		if ($hideInnerLines) { // si c une ligne de titre
1631
-	    	$fk_parent_line=0;
1631
+			$fk_parent_line=0;
1632 1632
 			$TLines =array();
1633 1633
 		
1634 1634
 			$original_count=count($object->lines);
1635
-		    $TTvas = array(); // tableau de tva
1635
+			$TTvas = array(); // tableau de tva
1636 1636
 		    
1637 1637
 			foreach($object->lines as $k=>&$line) 
1638 1638
 			{
@@ -1671,48 +1671,48 @@  discard block
 block discarded – undo
1671 1671
 			
1672 1672
 				if ($hideInnerLines)
1673 1673
 				{
1674
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1675
-				    {
1676
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1674
+					if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1675
+					{
1676
+						if($line->tva_tx != '0.000' && $line->product_type!=9){
1677 1677
 				            
1678
-    				        // on remplit le tableau de tva pour substituer les lignes cachées
1679
-    				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1680
-    				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1681
-    				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1682
-    				    }
1683
-    					if($line->product_type==9 && $line->rowid>0)
1684
-    					{
1685
-    					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1686
-    					    // génère des lignes d'affichage des montants HT soumis à tva
1687
-    					    $nbtva = count($TTvas);
1688
-    					    if(!empty($nbtva)){
1689
-    					        foreach ($TTvas as $tx =>$val){
1690
-    					            $l = clone $line;
1691
-    					            $l->product_type = 1;
1692
-    					            $l->special_code = '';
1693
-    					            $l->qty = 1;
1694
-    					            $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1695
-    					            $l->tva_tx = $tx;
1696
-    					            $l->total_ht = $val['total_ht'];
1697
-    					            $l->total_tva = $val['total_tva'];
1698
-    					            $l->total = $line->total_ht;
1699
-    					            $l->total_ttc = $val['total_ttc'];
1700
-    					            $TLines[] = $l;
1701
-    					            array_shift($TTvas);
1702
-    					       }
1703
-    					    }
1678
+							// on remplit le tableau de tva pour substituer les lignes cachées
1679
+							$TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1680
+							$TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1681
+							$TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1682
+						}
1683
+						if($line->product_type==9 && $line->rowid>0)
1684
+						{
1685
+							//Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1686
+							// génère des lignes d'affichage des montants HT soumis à tva
1687
+							$nbtva = count($TTvas);
1688
+							if(!empty($nbtva)){
1689
+								foreach ($TTvas as $tx =>$val){
1690
+									$l = clone $line;
1691
+									$l->product_type = 1;
1692
+									$l->special_code = '';
1693
+									$l->qty = 1;
1694
+									$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1695
+									$l->tva_tx = $tx;
1696
+									$l->total_ht = $val['total_ht'];
1697
+									$l->total_tva = $val['total_tva'];
1698
+									$l->total = $line->total_ht;
1699
+									$l->total_ttc = $val['total_ttc'];
1700
+									$TLines[] = $l;
1701
+									array_shift($TTvas);
1702
+							   }
1703
+							}
1704 1704
     					    
1705
-    					    // ajoute la ligne de sous-total
1706
-    					    $TLines[] = $line; 
1707
-    					}
1708
-				    } else {
1705
+							// ajoute la ligne de sous-total
1706
+							$TLines[] = $line; 
1707
+						}
1708
+					} else {
1709 1709
 				        
1710
-				        if($line->product_type==9 && $line->rowid>0)
1711
-				        {
1712
-				            // ajoute la ligne de sous-total
1713
-				            $TLines[] = $line; 
1714
-				        }
1715
-				    }
1710
+						if($line->product_type==9 && $line->rowid>0)
1711
+						{
1712
+							// ajoute la ligne de sous-total
1713
+							$TLines[] = $line; 
1714
+						}
1715
+					}
1716 1716
 				    
1717 1717
 					
1718 1718
 				}
@@ -1737,20 +1737,20 @@  discard block
 block discarded – undo
1737 1737
 			$nbtva = count($TTvas);
1738 1738
 			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1739 1739
 			{
1740
-			    foreach ($TTvas as $tx =>$val){
1741
-			        $l = clone $line;
1742
-			        $l->product_type = 1;
1743
-			        $l->special_code = '';
1744
-			        $l->qty = 1;
1745
-			        $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1746
-			        $l->tva_tx = $tx;
1747
-			        $l->total_ht = $val['total_ht'];
1748
-			        $l->total_tva = $val['total_tva'];
1749
-			        $l->total = $line->total_ht;
1750
-			        $l->total_ttc = $val['total_ttc'];
1751
-			        $TLines[] = $l;
1752
-			        array_shift($TTvas);
1753
-			    }
1740
+				foreach ($TTvas as $tx =>$val){
1741
+					$l = clone $line;
1742
+					$l->product_type = 1;
1743
+					$l->special_code = '';
1744
+					$l->qty = 1;
1745
+					$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1746
+					$l->tva_tx = $tx;
1747
+					$l->total_ht = $val['total_ht'];
1748
+					$l->total_tva = $val['total_tva'];
1749
+					$l->total = $line->total_ht;
1750
+					$l->total_ttc = $val['total_ttc'];
1751
+					$TLines[] = $l;
1752
+					array_shift($TTvas);
1753
+				}
1754 1754
 			}
1755 1755
 			
1756 1756
 			global $nblignes;
@@ -1762,7 +1762,7 @@  discard block
 block discarded – undo
1762 1762
 				$this->resprints = '';
1763 1763
 				return 0;
1764 1764
 			}
1765
-	    }
1765
+		}
1766 1766
 		
1767 1767
 		return 0;
1768 1768
 	}
@@ -1925,34 +1925,34 @@  discard block
 block discarded – undo
1925 1925
 		}
1926 1926
 		elseif($object->element == 'order_supplier' )
1927 1927
 		{
1928
-		    $createRight = $user->rights->fournisseur->commande->creer;
1928
+			$createRight = $user->rights->fournisseur->commande->creer;
1929 1929
 		}
1930 1930
 		elseif($object->element == 'invoice_supplier' )
1931 1931
 		{
1932
-		    $createRight = $user->rights->fournisseur->facture->creer;
1932
+			$createRight = $user->rights->fournisseur->facture->creer;
1933 1933
 		}
1934
-        if($object->element=='facture')$idvar = 'facid';
1935
-        else $idvar='id';
1934
+		if($object->element=='facture')$idvar = 'facid';
1935
+		else $idvar='id';
1936 1936
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1937
-            if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
1938
-            {
1939
-                if(!(TSubtotal::isModSubtotalLine($line)) && ( $line->fk_prev_id === null ) && !($action == "editline" && GETPOST('lineid') == $line->id)) {
1940
-                    echo '<a name="duplicate-'.$line->id.'" href="' . $_SERVER['PHP_SELF'] . '?' . $idvar . '=' . $object->id . '&action=duplicate&lineid=' . $line->id . '">' . img_picto($langs->trans('Duplicate'), 'duplicate@subtotal') . '</a>';
1937
+			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
1938
+			{
1939
+				if(!(TSubtotal::isModSubtotalLine($line)) && ( $line->fk_prev_id === null ) && !($action == "editline" && GETPOST('lineid') == $line->id)) {
1940
+					echo '<a name="duplicate-'.$line->id.'" href="' . $_SERVER['PHP_SELF'] . '?' . $idvar . '=' . $object->id . '&action=duplicate&lineid=' . $line->id . '">' . img_picto($langs->trans('Duplicate'), 'duplicate@subtotal') . '</a>';
1941 1941
 
1942
-                    ?>
1942
+					?>
1943 1943
                         <script type="text/javascript">
1944 1944
                             $(document).ready(function() {
1945 1945
                                 $("a[name='duplicate-<?php echo $line->id; ?>']").prependTo($('#row-<?php echo $line->id; ?>').find('.linecoledit'));
1946 1946
                             });
1947 1947
                         </script>
1948 1948
                     <?php
1949
-                }
1949
+				}
1950 1950
 
1951
-            }
1951
+			}
1952 1952
 			return 0;
1953 1953
 		}	
1954 1954
 		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)) 
1955
-        {
1955
+		{
1956 1956
 
1957 1957
 			
1958 1958
 			if((float)DOL_VERSION <= 3.4)
@@ -2000,7 +2000,7 @@  discard block
 block discarded – undo
2000 2000
 			//var_dump($line);
2001 2001
             
2002 2002
 			// HTML 5 data for js
2003
-            $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2003
+			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2004 2004
             
2005 2005
 			
2006 2006
 			?>
@@ -2062,8 +2062,8 @@  discard block
 block discarded – undo
2062 2062
 						}
2063 2063
 						
2064 2064
 						if ($object->element == 'order_supplier' || $object->element == 'invoice_supplier') {
2065
-						    $line->label = !empty($line->description) ? $line->description : $line->desc;
2066
-						    $line->description = '';
2065
+							$line->label = !empty($line->description) ? $line->description : $line->desc;
2066
+							$line->description = '';
2067 2067
 						}
2068 2068
 						$newlabel = $line->label;
2069 2069
 						if($line->label=='' && !$isFreeText) {
@@ -2097,38 +2097,38 @@  discard block
 block discarded – undo
2097 2097
 						
2098 2098
 
2099 2099
 						echo '<div class="subtotal_underline" style="margin-left:24px; line-height: 25px;">';
2100
-                        echo '<div>';
2101
-                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2102
-                        echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2103
-                        echo '</div>';
2104
-
2105
-                        if (TSubtotal::isTitle($line))
2106
-                        {
2107
-                            $form = new Form($db);
2108
-                            echo '<div>';
2109
-                            echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2110
-                            echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2111
-                            if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2112
-                            echo '</select>';
2113
-                            echo '</div>';
2114
-
2115
-                            if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
2116
-                            {
2117
-                                echo '<div>';
2118
-                                echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%';
2119
-                                echo '</div>';
2120
-                            }
2121
-                            echo '<div>';
2122
-                            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;';
2123
-                            echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2124
-                            echo '</div>';
2125
-
2126
-                            echo '<div>';
2127
-                            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;';
2128
-                            echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2129
-                            echo '</div>';
2130
-                        }
2131
-                        else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2100
+						echo '<div>';
2101
+						echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2102
+						echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2103
+						echo '</div>';
2104
+
2105
+						if (TSubtotal::isTitle($line))
2106
+						{
2107
+							$form = new Form($db);
2108
+							echo '<div>';
2109
+							echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2110
+							echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2111
+							if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2112
+							echo '</select>';
2113
+							echo '</div>';
2114
+
2115
+							if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
2116
+							{
2117
+								echo '<div>';
2118
+								echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%';
2119
+								echo '</div>';
2120
+							}
2121
+							echo '<div>';
2122
+							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;';
2123
+							echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2124
+							echo '</div>';
2125
+
2126
+							echo '<div>';
2127
+							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;';
2128
+							echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2129
+							echo '</div>';
2130
+						}
2131
+						else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2132 2132
 						echo '</div>';
2133 2133
 
2134 2134
 						if($line->qty<10) {
@@ -2394,17 +2394,17 @@  discard block
 block discarded – undo
2394 2394
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2395 2395
 		{
2396 2396
 		    
2397
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2398
-		    {
2399
-		        foreach ($object->lines as $line)
2400
-		        {
2401
-		            // fetch optionals attributes and labels
2402
-		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2403
-		            $extrafields=new ExtraFields($this->db);
2404
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2405
-		            $line->fetch_optionals($line->id,$extralabels);
2406
-		        }
2407
-		    }
2397
+			if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2398
+			{
2399
+				foreach ($object->lines as $line)
2400
+				{
2401
+					// fetch optionals attributes and labels
2402
+					require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2403
+					$extrafields=new ExtraFields($this->db);
2404
+					$extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2405
+					$line->fetch_optionals($line->id,$extralabels);
2406
+				}
2407
+			}
2408 2408
 		    
2409 2409
 			$TSubNc = array();
2410 2410
 			foreach ($object->lines as &$l)
@@ -2495,80 +2495,80 @@  discard block
 block discarded – undo
2495 2495
 	{
2496 2496
 		dol_include_once('/subtotal/class/subtotal.class.php');
2497 2497
 
2498
-	    $line = &$parameters['line'];
2498
+		$line = &$parameters['line'];
2499 2499
 	    
2500
-	    $ThtmlData['data-id']           = $line->id;
2501
-	    $ThtmlData['data-product_type'] = $line->product_type;
2502
-	    $ThtmlData['data-qty']          = 0; //$line->qty;
2503
-	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2500
+		$ThtmlData['data-id']           = $line->id;
2501
+		$ThtmlData['data-product_type'] = $line->product_type;
2502
+		$ThtmlData['data-qty']          = 0; //$line->qty;
2503
+		$ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2504 2504
 	    
2505
-	    if(TSubtotal::isTitle($line)){
2506
-	        $ThtmlData['data-issubtotal'] = 'title';
2507
-	    }elseif(TSubtotal::isSubtotal($line)){
2508
-	        $ThtmlData['data-issubtotal'] = 'subtotal';
2509
-	    }
2510
-	    else{
2511
-	        $ThtmlData['data-issubtotal'] = 'freetext';
2512
-	    }
2505
+		if(TSubtotal::isTitle($line)){
2506
+			$ThtmlData['data-issubtotal'] = 'title';
2507
+		}elseif(TSubtotal::isSubtotal($line)){
2508
+			$ThtmlData['data-issubtotal'] = 'subtotal';
2509
+		}
2510
+		else{
2511
+			$ThtmlData['data-issubtotal'] = 'freetext';
2512
+		}
2513 2513
 	    
2514 2514
 	    
2515
-	    // Change or add data  from hooks
2516
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2515
+		// Change or add data  from hooks
2516
+		$parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2517 2517
 	    
2518
-	    // hook 
2519
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2520
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2521
-	    if ($reshook>0)
2522
-	    {
2523
-	        $ThtmlData = $hookmanager->resArray;
2524
-	    }
2525
-
2526
-	    return $this->implodeHtmlData($ThtmlData);
2518
+		// hook 
2519
+		$reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2520
+		if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2521
+		if ($reshook>0)
2522
+		{
2523
+			$ThtmlData = $hookmanager->resArray;
2524
+		}
2525
+
2526
+		return $this->implodeHtmlData($ThtmlData);
2527 2527
 	
2528 2528
 	}
2529 2529
 	
2530 2530
 	
2531 2531
 	function implodeHtmlData($ThtmlData = array())
2532 2532
 	{
2533
-	    $data = '';
2534
-	    foreach($ThtmlData as $k => $h )
2535
-	    {
2536
-	        if(is_array($h))
2537
-	        {
2538
-	            $h = json_encode($h);
2539
-	        }
2533
+		$data = '';
2534
+		foreach($ThtmlData as $k => $h )
2535
+		{
2536
+			if(is_array($h))
2537
+			{
2538
+				$h = json_encode($h);
2539
+			}
2540 2540
 	        
2541
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2542
-	    }
2541
+			$data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2542
+		}
2543 2543
 	    
2544
-	    return $data;
2544
+		return $data;
2545 2545
 	}
2546 2546
 	
2547 2547
 	function _ajax_block_order_js($object)
2548 2548
 	{
2549
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2549
+		global $conf,$tagidfortablednd,$filepath,$langs;
2550 2550
 	    
2551
-	    /*
2551
+		/*
2552 2552
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2553 2553
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2554 2554
 	     */
2555 2555
 	    
2556
-	    $id=$object->id;
2557
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2558
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2556
+		$id=$object->id;
2557
+		$nboflines=(isset($object->lines)?count($object->lines):0);
2558
+		$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2559 2559
 	    
2560
-	    $id=$object->id;
2561
-	    $fk_element=$object->fk_element;
2562
-	    $table_element_line=$object->table_element_line;
2563
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2564
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2565
-	    $filepath=(empty($filepath)?'':$filepath);
2560
+		$id=$object->id;
2561
+		$fk_element=$object->fk_element;
2562
+		$table_element_line=$object->table_element_line;
2563
+		$nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2564
+		$tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2565
+		$filepath=(empty($filepath)?'':$filepath);
2566 2566
 	    
2567 2567
 	    
2568
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2569
-	    {
2568
+		if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2569
+		{
2570 2570
 	        
2571
-	        ?>
2571
+			?>
2572 2572
 		
2573 2573
 		
2574 2574
 			<script type="text/javascript">
Please login to merge, or discard this patch.
Spacing   +416 added lines, -416 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,32 +1300,32 @@  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(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1319
-                if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1318
+                if (is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1319
+                if (!empty($parentTitle->array_options['options_show_total_ht'])) {
1320 1320
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1321 1321
                     $this->resprints = price($TTotal['total_subprice']);
1322 1322
                 }
1323 1323
             }
1324 1324
 		
1325
-			if((float)DOL_VERSION<=3.6) {
1325
+			if ((float) DOL_VERSION <= 3.6) {
1326 1326
 				return '';
1327 1327
 			}
1328
-			else if((float)DOL_VERSION>=3.8) {
1328
+			else if ((float) DOL_VERSION >= 3.8) {
1329 1329
 				return 1;
1330 1330
 			}
1331 1331
 		}
@@ -1353,7 +1353,7 @@  discard block
 block discarded – undo
1353 1353
 		    
1354 1354
 		    // Check if a title exist for this line && if the title have subtotal
1355 1355
 		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1356
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1356
+		    if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1357 1357
 		    {
1358 1358
 		        
1359 1359
 		        $this->resprints = ' ';
@@ -1367,37 +1367,37 @@  discard block
 block discarded – undo
1367 1367
 		return 0;
1368 1368
 	}
1369 1369
 	
1370
-	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1371
-	    global $conf,$hideprices,$hookmanager;
1370
+	function pdf_getlineremisepercent($parameters = array(), &$object, &$action = '') {
1371
+	    global $conf, $hideprices, $hookmanager;
1372 1372
 
1373
-        if(is_array($parameters)) $i = & $parameters['i'];
1373
+        if (is_array($parameters)) $i = & $parameters['i'];
1374 1374
         else $i = (int) $parameters;
1375 1375
 
1376
-		if($this->isModSubtotalLine($parameters,$object) ) {
1376
+		if ($this->isModSubtotalLine($parameters, $object)) {
1377 1377
 			$this->resprints = ' ';
1378 1378
 
1379 1379
             $line = $object->lines[$i];
1380 1380
 
1381 1381
             // Affichage de la remise 
1382
-            if(TSubtotal::isSubtotal($line)) {
1382
+            if (TSubtotal::isSubtotal($line)) {
1383 1383
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1384 1384
 
1385
-                if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1386
-                if(! empty($parentTitle->array_options['options_show_reduc'])) {
1385
+                if (empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1386
+                if (!empty($parentTitle->array_options['options_show_reduc'])) {
1387 1387
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1388
-                    $this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
1388
+                    $this->resprints = price((1 - $TTotal['total_ht'] / $TTotal['total_subprice']) * 100, 0, '', 1, 2, 2).'%';
1389 1389
                 }
1390 1390
             }
1391 1391
 		
1392
-			if((float)DOL_VERSION<=3.6) {
1392
+			if ((float) DOL_VERSION <= 3.6) {
1393 1393
 				return '';
1394 1394
 			}
1395
-			else if((float)DOL_VERSION>=3.8) {
1395
+			else if ((float) DOL_VERSION >= 3.8) {
1396 1396
 				return 1;
1397 1397
 			}
1398 1398
 		}
1399 1399
 		elseif (!empty($hideprices)
1400
-		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1400
+		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1401 1401
 		        )
1402 1402
 		    {
1403 1403
 		        if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1410,24 +1410,24 @@  discard block
 block discarded – undo
1410 1410
 		return 0;
1411 1411
 	}
1412 1412
 	
1413
-	function pdf_getlineupwithtax($parameters=array(), &$object, &$action='') {
1414
-		global $conf,$hideprices;
1413
+	function pdf_getlineupwithtax($parameters = array(), &$object, &$action = '') {
1414
+		global $conf, $hideprices;
1415 1415
 		
1416
-		if($this->isModSubtotalLine($parameters,$object) ){
1416
+		if ($this->isModSubtotalLine($parameters, $object)) {
1417 1417
 			$this->resprints = ' ';
1418
-			if((float)DOL_VERSION<=3.6) {
1418
+			if ((float) DOL_VERSION <= 3.6) {
1419 1419
 				return '';
1420 1420
 			}
1421
-			else if((float)DOL_VERSION>=3.8) {
1421
+			else if ((float) DOL_VERSION >= 3.8) {
1422 1422
 				return 1;
1423 1423
 			}
1424 1424
 		}
1425 1425
 		
1426
-		if(is_array($parameters)) $i = & $parameters['i'];
1427
-		else $i = (int)$parameters;
1426
+		if (is_array($parameters)) $i = & $parameters['i'];
1427
+		else $i = (int) $parameters;
1428 1428
 			
1429 1429
 		if (!empty($hideprices)
1430
-				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1430
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1431 1431
 		)
1432 1432
 		{
1433 1433
 			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1440,22 +1440,22 @@  discard block
 block discarded – undo
1440 1440
 		return 0;
1441 1441
 	}
1442 1442
 	
1443
-	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
1444
-	    global $conf,$hideprices,$hookmanager;
1443
+	function pdf_getlinevatrate($parameters = array(), &$object, &$action = '') {
1444
+	    global $conf, $hideprices, $hookmanager;
1445 1445
 	    
1446
-		if($this->isModSubtotalLine($parameters,$object) ){
1446
+		if ($this->isModSubtotalLine($parameters, $object)) {
1447 1447
 			$this->resprints = ' ';
1448 1448
 			
1449
-			if((float)DOL_VERSION<=3.6) {
1449
+			if ((float) DOL_VERSION <= 3.6) {
1450 1450
 				return '';
1451 1451
 			}
1452
-			else if((float)DOL_VERSION>=3.8) {
1452
+			else if ((float) DOL_VERSION >= 3.8) {
1453 1453
 				return 1;
1454 1454
 			}
1455 1455
 		}
1456 1456
 		
1457
-		if(is_array($parameters)) $i = & $parameters['i'];
1458
-		else $i = (int)$parameters;
1457
+		if (is_array($parameters)) $i = & $parameters['i'];
1458
+		else $i = (int) $parameters;
1459 1459
 		
1460 1460
 		if (empty($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)
1461 1461
 
@@ -1482,7 +1482,7 @@  discard block
 block discarded – undo
1482 1482
 		    
1483 1483
 		    // Check if a title exist for this line && if the title have subtotal
1484 1484
 		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1485
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1485
+		    if (TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1486 1486
 		    {
1487 1487
 		        
1488 1488
 		        $this->resprints = ' ';
@@ -1496,23 +1496,23 @@  discard block
 block discarded – undo
1496 1496
 		return 0;
1497 1497
 	}
1498 1498
 		
1499
-	function pdf_getlineprogress($parameters=array(), &$object, &$action) {
1499
+	function pdf_getlineprogress($parameters = array(), &$object, &$action) {
1500 1500
 		global $conf;
1501 1501
 		
1502
-		if($this->isModSubtotalLine($parameters,$object) ){
1502
+		if ($this->isModSubtotalLine($parameters, $object)) {
1503 1503
 			$this->resprints = ' ';
1504
-			if((float)DOL_VERSION<=3.6) {
1504
+			if ((float) DOL_VERSION <= 3.6) {
1505 1505
 				return '';
1506 1506
 			}
1507
-			else if((float)DOL_VERSION>=3.8) {
1507
+			else if ((float) DOL_VERSION >= 3.8) {
1508 1508
 				return 1;
1509 1509
 			}
1510 1510
 		}
1511 1511
 		
1512
-		if(is_array($parameters)) $i = & $parameters['i'];
1513
-		else $i = (int)$parameters;
1512
+		if (is_array($parameters)) $i = & $parameters['i'];
1513
+		else $i = (int) $parameters;
1514 1514
 			
1515
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1515
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1516 1516
 		{
1517 1517
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1518 1518
 			{
@@ -1527,12 +1527,12 @@  discard block
 block discarded – undo
1527 1527
 	function add_numerotation(&$object) {
1528 1528
 		global $conf;
1529 1529
 		
1530
-		if(!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1530
+		if (!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1531 1531
 		
1532 1532
 			$TLevelTitre = array();
1533 1533
 			$prevlevel = 0;
1534 1534
 		
1535
-			foreach($object->lines as $k=>&$line) 
1535
+			foreach ($object->lines as $k=>&$line) 
1536 1536
 			{
1537 1537
 				if ($line->id > 0 && $this->isModSubtotalLine($k, $object) && $line->qty <= 10)
1538 1538
 				{
@@ -1546,12 +1546,12 @@  discard block
 block discarded – undo
1546 1546
 	}
1547 1547
 
1548 1548
 	// TODO ne gère pas encore la numération des lignes "Totaux"
1549
-	private function formatNumerotation(&$TLineTitle, $line_reference='', $level=1, $prefix_num=0)
1549
+	private function formatNumerotation(&$TLineTitle, $line_reference = '', $level = 1, $prefix_num = 0)
1550 1550
 	{
1551 1551
 		$TTitle = array();
1552 1552
 		
1553
-		$i=1;
1554
-		$j=0;
1553
+		$i = 1;
1554
+		$j = 0;
1555 1555
 		foreach ($TLineTitle as $k => &$line)
1556 1556
 		{
1557 1557
 			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
@@ -1561,7 +1561,7 @@  discard block
 block discarded – undo
1561 1561
 			{
1562 1562
 				$TTitle[$j]['numerotation'] = ($prefix_num == 0) ? $i : $prefix_num.'.'.$i;
1563 1563
 				//var_dump('Prefix == '.$prefix_num.' // '.$line->desc.' ==> numerotation == '.$TTitle[$j]['numerotation'].'   ###    '.$line->qty .'=='. $level);
1564
-				if (empty($line->label) && (float)DOL_VERSION < 6)
1564
+				if (empty($line->label) && (float) DOL_VERSION < 6)
1565 1565
 				{
1566 1566
 					$line->label = !empty($line->desc) ? $line->desc : $line->description;
1567 1567
 					$line->desc = $line->description = '';
@@ -1587,26 +1587,26 @@  discard block
 block discarded – undo
1587 1587
 	
1588 1588
 	function setDocTVA(&$pdf, &$object) {
1589 1589
 		
1590
-		$hidedetails = (int)GETPOST('hidedetails');
1590
+		$hidedetails = (int) GETPOST('hidedetails');
1591 1591
 		
1592
-		if(empty($hidedetails)) return false;
1592
+		if (empty($hidedetails)) return false;
1593 1593
 		
1594 1594
 		// TODO can't add VAT to document without lines... :-/
1595 1595
 		
1596 1596
 		return true;
1597 1597
 	}
1598 1598
 	
1599
-	function beforePDFCreation($parameters=array(), &$object, &$action)
1599
+	function beforePDFCreation($parameters = array(), &$object, &$action)
1600 1600
 	{
1601 1601
 		/**
1602 1602
 		 * @var $pdf    TCPDF
1603 1603
 		 */
1604
-		global $pdf,$conf, $langs;
1604
+		global $pdf, $conf, $langs;
1605 1605
 
1606 1606
 		// var_dump($object->lines);
1607 1607
 		dol_include_once('/subtotal/class/subtotal.class.php');
1608 1608
 
1609
-		foreach($parameters as $key=>$value) {
1609
+		foreach ($parameters as $key=>$value) {
1610 1610
 			${$key} = $value;
1611 1611
 		}
1612 1612
 		
@@ -1614,35 +1614,35 @@  discard block
 block discarded – undo
1614 1614
 		
1615 1615
 		$this->add_numerotation($object);	
1616 1616
 		
1617
-        foreach($object->lines as $k => &$l) {
1618
-            if(TSubtotal::isSubtotal($l)) {
1617
+        foreach ($object->lines as $k => &$l) {
1618
+            if (TSubtotal::isSubtotal($l)) {
1619 1619
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1620
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1621
-                if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_total_ht'])) {
1622
-                    $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1620
+                if (is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1621
+                if (!empty($parentTitle->id) && !empty($parentTitle->array_options['options_show_total_ht'])) {
1622
+                    $l->remise_percent = 100; // Affichage de la réduction sur la ligne de sous-total
1623 1623
                 }
1624 1624
             }
1625 1625
         }
1626 1626
 
1627
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1628
-		$hidedetails = (int)GETPOST('hidedetails');
1627
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1628
+		$hidedetails = (int) GETPOST('hidedetails');
1629 1629
 
1630 1630
 		if ($hideInnerLines) { // si c une ligne de titre
1631
-	    	$fk_parent_line=0;
1632
-			$TLines =array();
1631
+	    	$fk_parent_line = 0;
1632
+			$TLines = array();
1633 1633
 		
1634
-			$original_count=count($object->lines);
1634
+			$original_count = count($object->lines);
1635 1635
 		    $TTvas = array(); // tableau de tva
1636 1636
 		    
1637
-			foreach($object->lines as $k=>&$line) 
1637
+			foreach ($object->lines as $k=>&$line) 
1638 1638
 			{
1639 1639
 			    
1640
-				if($line->product_type==9 && $line->rowid>0) 
1640
+				if ($line->product_type == 9 && $line->rowid > 0) 
1641 1641
 				{
1642 1642
 					$fk_parent_line = $line->rowid;
1643 1643
 					
1644 1644
 					// 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
1645
-					if(TSubtotal::isSubtotal($line)) 
1645
+					if (TSubtotal::isSubtotal($line)) 
1646 1646
 					{
1647 1647
 						/*$total = $this->getTotalLineFromObject($object, $line, '');
1648 1648
 						
@@ -1671,22 +1671,22 @@  discard block
 block discarded – undo
1671 1671
 			
1672 1672
 				if ($hideInnerLines)
1673 1673
 				{
1674
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1674
+				    if (!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1675 1675
 				    {
1676
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1676
+				        if ($line->tva_tx != '0.000' && $line->product_type != 9) {
1677 1677
 				            
1678 1678
     				        // on remplit le tableau de tva pour substituer les lignes cachées
1679 1679
     				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1680 1680
     				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1681 1681
     				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1682 1682
     				    }
1683
-    					if($line->product_type==9 && $line->rowid>0)
1683
+    					if ($line->product_type == 9 && $line->rowid > 0)
1684 1684
     					{
1685 1685
     					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1686 1686
     					    // génère des lignes d'affichage des montants HT soumis à tva
1687 1687
     					    $nbtva = count($TTvas);
1688
-    					    if(!empty($nbtva)){
1689
-    					        foreach ($TTvas as $tx =>$val){
1688
+    					    if (!empty($nbtva)) {
1689
+    					        foreach ($TTvas as $tx =>$val) {
1690 1690
     					            $l = clone $line;
1691 1691
     					            $l->product_type = 1;
1692 1692
     					            $l->special_code = '';
@@ -1707,7 +1707,7 @@  discard block
 block discarded – undo
1707 1707
     					}
1708 1708
 				    } else {
1709 1709
 				        
1710
-				        if($line->product_type==9 && $line->rowid>0)
1710
+				        if ($line->product_type == 9 && $line->rowid > 0)
1711 1711
 				        {
1712 1712
 				            // ajoute la ligne de sous-total
1713 1713
 				            $TLines[] = $line; 
@@ -1735,9 +1735,9 @@  discard block
 block discarded – undo
1735 1735
 			
1736 1736
 			// cas incongru où il y aurait des produits en dessous du dernier sous-total
1737 1737
 			$nbtva = count($TTvas);
1738
-			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1738
+			if (!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1739 1739
 			{
1740
-			    foreach ($TTvas as $tx =>$val){
1740
+			    foreach ($TTvas as $tx =>$val) {
1741 1741
 			        $l = clone $line;
1742 1742
 			        $l->product_type = 1;
1743 1743
 			        $l->special_code = '';
@@ -1754,11 +1754,11 @@  discard block
 block discarded – undo
1754 1754
 			}
1755 1755
 			
1756 1756
 			global $nblignes;
1757
-			$nblignes=count($TLines);
1757
+			$nblignes = count($TLines);
1758 1758
 
1759 1759
 			$object->lines = $TLines;
1760 1760
 			
1761
-			if($i>count($object->lines)) {
1761
+			if ($i > count($object->lines)) {
1762 1762
 				$this->resprints = '';
1763 1763
 				return 0;
1764 1764
 			}
@@ -1767,59 +1767,59 @@  discard block
 block discarded – undo
1767 1767
 		return 0;
1768 1768
 	}
1769 1769
 
1770
-	function pdf_writelinedesc($parameters=array(), &$object, &$action)
1770
+	function pdf_writelinedesc($parameters = array(), &$object, &$action)
1771 1771
 	{
1772 1772
 		/**
1773 1773
 		 * @var $pdf    TCPDF
1774 1774
 		 */
1775
-		global $pdf,$conf;
1775
+		global $pdf, $conf;
1776 1776
 
1777
-		foreach($parameters as $key=>$value) {
1777
+		foreach ($parameters as $key=>$value) {
1778 1778
 			${$key} = $value;
1779 1779
 		}
1780 1780
 		
1781
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1782
-		$hidedetails = (int)GETPOST('hidedetails');
1781
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1782
+		$hidedetails = (int) GETPOST('hidedetails');
1783 1783
 		
1784
-		if($this->isModSubtotalLine($parameters,$object) ){			
1784
+		if ($this->isModSubtotalLine($parameters, $object)) {			
1785 1785
 		
1786 1786
 				global $hideprices;
1787 1787
 				
1788
-				if(!empty($hideprices)) {
1789
-					foreach($object->lines as &$line) {
1790
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1788
+				if (!empty($hideprices)) {
1789
+					foreach ($object->lines as &$line) {
1790
+						if ($line->fk_product_type != 9) $line->fk_parent_line = -1;	
1791 1791
 					}
1792 1792
 				}
1793 1793
 			
1794 1794
 				$line = &$object->lines[$i];
1795 1795
 				
1796
-				if($line->info_bits>0) { // PAGE BREAK
1796
+				if ($line->info_bits > 0) { // PAGE BREAK
1797 1797
 					$pdf->addPage();
1798 1798
 					$posy = $pdf->GetY();
1799 1799
 				}
1800 1800
 				
1801 1801
 				$label = $line->label;
1802
-				$description= !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1802
+				$description = !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1803 1803
 				
1804
-				if(empty($label)) {
1804
+				if (empty($label)) {
1805 1805
 					$label = $description;
1806
-					$description='';
1806
+					$description = '';
1807 1807
 				}
1808 1808
 				
1809
-				if($line->qty>90) {
1809
+				if ($line->qty > 90) {
1810 1810
 					
1811 1811
 					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1812 1812
 					
1813 1813
 					$pageBefore = $pdf->getPage();
1814
-					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1814
+					$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1815 1815
 					$pageAfter = $pdf->getPage();	
1816 1816
 
1817
-					if($pageAfter>$pageBefore) {
1817
+					if ($pageAfter > $pageBefore) {
1818 1818
 						//print "ST $pageAfter>$pageBefore<br>";
1819 1819
 						$pdf->rollbackTransaction(true);	
1820
-						$pdf->addPage('','', true);
1820
+						$pdf->addPage('', '', true);
1821 1821
 						$posy = $pdf->GetY();
1822
-						$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1822
+						$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1823 1823
 						$posy = $pdf->GetY();
1824 1824
 						//print 'add ST'.$pdf->getPage().'<br />';
1825 1825
 					}
@@ -1830,7 +1830,7 @@  discard block
 block discarded – undo
1830 1830
 				else if ($line->qty < 10) {
1831 1831
 					$pageBefore = $pdf->getPage();
1832 1832
 
1833
-					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
1833
+					$this->pdf_add_title($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h); 
1834 1834
 					$pageAfter = $pdf->getPage();	
1835 1835
 
1836 1836
 					
@@ -1905,9 +1905,9 @@  discard block
 block discarded – undo
1905 1905
 	 * @param $hookmanager  HookManager
1906 1906
 	 * @return int
1907 1907
 	 */
1908
-	function printObjectLine ($parameters, &$object, &$action, $hookmanager){
1908
+	function printObjectLine($parameters, &$object, &$action, $hookmanager) {
1909 1909
 		
1910
-		global $conf,$langs,$user,$db,$bc;
1910
+		global $conf, $langs, $user, $db, $bc;
1911 1911
 
1912 1912
 		$num = &$parameters['num'];
1913 1913
 		$line = &$parameters['line'];
@@ -1915,29 +1915,29 @@  discard block
 block discarded – undo
1915 1915
 		
1916 1916
 		$var = &$parameters['var'];
1917 1917
 
1918
-		$contexts = explode(':',$parameters['context']);
1918
+		$contexts = explode(':', $parameters['context']);
1919 1919
 
1920 1920
 		$createRight = $user->rights->{$object->element}->creer;
1921
-		if($object->element == 'facturerec' )
1921
+		if ($object->element == 'facturerec')
1922 1922
 		{
1923 1923
 			$object->statut = 0; // hack for facture rec
1924 1924
 			$createRight = $user->rights->facture->creer;
1925 1925
 		}
1926
-		elseif($object->element == 'order_supplier' )
1926
+		elseif ($object->element == 'order_supplier')
1927 1927
 		{
1928 1928
 		    $createRight = $user->rights->fournisseur->commande->creer;
1929 1929
 		}
1930
-		elseif($object->element == 'invoice_supplier' )
1930
+		elseif ($object->element == 'invoice_supplier')
1931 1931
 		{
1932 1932
 		    $createRight = $user->rights->fournisseur->facture->creer;
1933 1933
 		}
1934
-        if($object->element=='facture')$idvar = 'facid';
1935
-        else $idvar='id';
1936
-		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1937
-            if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
1934
+        if ($object->element == 'facture')$idvar = 'facid';
1935
+        else $idvar = 'id';
1936
+		if ($line->special_code != $this->module_number || $line->product_type != 9) {
1937
+            if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
1938 1938
             {
1939
-                if(!(TSubtotal::isModSubtotalLine($line)) && ( $line->fk_prev_id === null ) && !($action == "editline" && GETPOST('lineid') == $line->id)) {
1940
-                    echo '<a name="duplicate-'.$line->id.'" href="' . $_SERVER['PHP_SELF'] . '?' . $idvar . '=' . $object->id . '&action=duplicate&lineid=' . $line->id . '">' . img_picto($langs->trans('Duplicate'), 'duplicate@subtotal') . '</a>';
1939
+                if (!(TSubtotal::isModSubtotalLine($line)) && ($line->fk_prev_id === null) && !($action == "editline" && GETPOST('lineid') == $line->id)) {
1940
+                    echo '<a name="duplicate-'.$line->id.'" href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'.img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
1941 1941
 
1942 1942
                     ?>
1943 1943
                         <script type="text/javascript">
@@ -1951,11 +1951,11 @@  discard block
 block discarded – undo
1951 1951
             }
1952 1952
 			return 0;
1953 1953
 		}	
1954
-		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)) 
1954
+		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)) 
1955 1955
         {
1956 1956
 
1957 1957
 			
1958
-			if((float)DOL_VERSION <= 3.4)
1958
+			if ((float) DOL_VERSION <= 3.4)
1959 1959
 			{
1960 1960
 				?>
1961 1961
 				<script type="text/javascript">
@@ -1979,22 +1979,22 @@  discard block
 block discarded – undo
1979 1979
 				<?php
1980 1980
 			}
1981 1981
 			
1982
-			if(empty($line->description)) $line->description = $line->desc;
1982
+			if (empty($line->description)) $line->description = $line->desc;
1983 1983
 			
1984 1984
 			$colspan = 5;
1985
-			if($object->element == 'facturerec' ) $colspan = 3;
1986
-			if($object->element == 'order_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
1987
-			if($object->element == 'invoice_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7;
1988
-			if($object->element == 'supplier_proposal') (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
1989
-			if(!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
1985
+			if ($object->element == 'facturerec') $colspan = 3;
1986
+			if ($object->element == 'order_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
1987
+			if ($object->element == 'invoice_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 4 : $colspan = 7;
1988
+			if ($object->element == 'supplier_proposal') (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
1989
+			if (!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
1990 1990
 				$colspan++; // Colonne PU Devise
1991 1991
 			}
1992
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1993
-			if(!empty($conf->margin->enabled)) $colspan++;
1994
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1995
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1996
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1997
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
1992
+			if ($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1993
+			if (!empty($conf->margin->enabled)) $colspan++;
1994
+			if (!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1995
+			if (!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1996
+			if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1997
+			if (!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
1998 1998
 					
1999 1999
 			/* Titre */
2000 2000
 			//var_dump($line);
@@ -2004,39 +2004,39 @@  discard block
 block discarded – undo
2004 2004
             
2005 2005
 			
2006 2006
 			?>
2007
-			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2007
+			<tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2008 2008
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2009 2009
 					{
2010
-						if($line->qty==99) print 'background:#adadcf';
2011
-						else if($line->qty==98) print 'background:#ddddff;';
2012
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2013
-						else if($line->qty==1) print 'background:#adadcf;';
2014
-						else if($line->qty==2) print 'background:#ddddff;';
2015
-						else if($line->qty==50) print '';
2010
+						if ($line->qty == 99) print 'background:#adadcf';
2011
+						else if ($line->qty == 98) print 'background:#ddddff;';
2012
+						else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;';
2013
+						else if ($line->qty == 1) print 'background:#adadcf;';
2014
+						else if ($line->qty == 2) print 'background:#ddddff;';
2015
+						else if ($line->qty == 50) print '';
2016 2016
 						else print 'background:#eeeeff;';
2017 2017
 
2018 2018
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2019 2019
 					}
2020 2020
 					else 
2021 2021
 					{
2022
-						if($line->qty==99) print 'background:#ddffdd';
2023
-						else if($line->qty==98) print 'background:#ddddff;';
2024
-						else if($line->qty==2) print 'background:#eeeeff; ';
2025
-						else if($line->qty==50) print '';
2026
-						else print 'background:#eeffee;' ;
2022
+						if ($line->qty == 99) print 'background:#ddffdd';
2023
+						else if ($line->qty == 98) print 'background:#ddddff;';
2024
+						else if ($line->qty == 2) print 'background:#eeeeff; ';
2025
+						else if ($line->qty == 50) print '';
2026
+						else print 'background:#eeffee;';
2027 2027
 					}
2028 2028
 
2029 2029
 			?>;">
2030 2030
 
2031
-				<?php if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
2031
+				<?php if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER)) { ?>
2032 2032
 				<td class="linecolnum"><?php echo $i + 1; ?></td>
2033 2033
 				<?php } ?>
2034 2034
 
2035
-				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
2036
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
2035
+				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php
2036
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
2037 2037
 
2038
-						$params=array('line'=>$line);
2039
-						$reshook=$hookmanager->executeHooks('formEditProductOptions',$params,$object,$action);
2038
+						$params = array('line'=>$line);
2039
+						$reshook = $hookmanager->executeHooks('formEditProductOptions', $params, $object, $action);
2040 2040
 						
2041 2041
 						echo '<div id="line_'.$line->id.'"></div>'; // Imitation Dolibarr
2042 2042
 						echo '<input type="hidden" value="'.$line->id.'" name="lineid">';
@@ -2044,7 +2044,7 @@  discard block
 block discarded – undo
2044 2044
 						echo '<input id="product_id" type="hidden" value="'.$line->fk_product.'" name="type">';
2045 2045
 						echo '<input id="special_code" type="hidden" value="'.$line->special_code.'" name="type">';
2046 2046
 
2047
-						$isFreeText=false;
2047
+						$isFreeText = false;
2048 2048
 						if (TSubtotal::isTitle($line))
2049 2049
 						{
2050 2050
 							$qty_displayed = $line->qty;
@@ -2066,13 +2066,13 @@  discard block
 block discarded – undo
2066 2066
 						    $line->description = '';
2067 2067
 						}
2068 2068
 						$newlabel = $line->label;
2069
-						if($line->label=='' && !$isFreeText) {
2070
-							if(TSubtotal::isSubtotal($line)) {
2069
+						if ($line->label == '' && !$isFreeText) {
2070
+							if (TSubtotal::isSubtotal($line)) {
2071 2071
 								$newlabel = $line->description.' '.$this->getTitle($object, $line);
2072
-								$line->description='';
2073
-							} elseif( (float)DOL_VERSION < 6 ) {
2074
-								$newlabel= $line->description;
2075
-								$line->description='';
2072
+								$line->description = '';
2073
+							} elseif ((float) DOL_VERSION < 6) {
2074
+								$newlabel = $line->description;
2075
+								$line->description = '';
2076 2076
 							}
2077 2077
 						}
2078 2078
 
@@ -2081,10 +2081,10 @@  discard block
 block discarded – undo
2081 2081
 						
2082 2082
 						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2083 2083
 						
2084
-						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
2084
+						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)))
2085 2085
 						{
2086 2086
 							$select = '<select name="subtotal_level">';
2087
-							for ($j=1; $j<10; $j++)
2087
+							for ($j = 1; $j < 10; $j++)
2088 2088
 							{
2089 2089
 								if (!empty($readonlyForSituation)) {
2090 2090
 									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
@@ -2098,7 +2098,7 @@  discard block
 block discarded – undo
2098 2098
 
2099 2099
 						echo '<div class="subtotal_underline" style="margin-left:24px; line-height: 25px;">';
2100 2100
                         echo '<div>';
2101
-                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2101
+                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '').' />&nbsp;';
2102 2102
                         echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2103 2103
                         echo '</div>';
2104 2104
 
@@ -2119,21 +2119,21 @@  discard block
 block discarded – undo
2119 2119
                                 echo '</div>';
2120 2120
                             }
2121 2121
                             echo '<div>';
2122
-                            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;';
2122
+                            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;';
2123 2123
                             echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2124 2124
                             echo '</div>';
2125 2125
 
2126 2126
                             echo '<div>';
2127
-                            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;';
2127
+                            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;';
2128 2128
                             echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2129 2129
                             echo '</div>';
2130 2130
                         }
2131 2131
                         else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2132 2132
 						echo '</div>';
2133 2133
 
2134
-						if($line->qty<10) {
2134
+						if ($line->qty < 10) {
2135 2135
 							// WYSIWYG editor
2136
-							require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
2136
+							require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
2137 2137
 							$nbrows = ROWS_2;
2138 2138
 							$cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
2139 2139
 							if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
@@ -2153,25 +2153,25 @@  discard block
 block discarded – undo
2153 2153
 
2154 2154
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2155 2155
 						 {
2156
-							if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
2156
+							if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
2157 2157
 							{
2158
-								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2158
+								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
2159 2159
 								
2160 2160
 								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2161
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2161
+								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
2162 2162
 							}
2163 2163
 						 }
2164 2164
 						 else 
2165 2165
 						 {
2166
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2167
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2166
+							if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal');
2167
+							else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2168 2168
 						 }
2169 2169
 						 
2170 2170
 						 
2171 2171
 						 // Get display styles and apply them
2172 2172
 						 $titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
2173
-						 $titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2174
-						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2173
+						 $titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
2174
+						 $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2175 2175
 						 
2176 2176
 						 if (empty($line->label)) {
2177 2177
 							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
@@ -2179,16 +2179,16 @@  discard block
 block discarded – undo
2179 2179
 						 } 
2180 2180
 						 else {
2181 2181
 
2182
-							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2182
+							if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2183 2183
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2184 2184
 							}
2185
-							else{
2185
+							else {
2186 2186
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
2187 2187
 							}
2188 2188
 
2189 2189
 						 } 
2190
-						if($line->qty>90) print ' : ';
2191
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2190
+						if ($line->qty > 90) print ' : ';
2191
+						if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2192 2192
 
2193 2193
 						 
2194 2194
 
@@ -2197,7 +2197,7 @@  discard block
 block discarded – undo
2197 2197
 			?></td>
2198 2198
 					 
2199 2199
 			<?php
2200
-				if($line->qty>90) {
2200
+				if ($line->qty > 90) {
2201 2201
 					/* Total */
2202 2202
 					$total_line = $this->getTotalLineFromObject($object, $line, '');
2203 2203
 					echo '<td class="linecolht nowrap" align="right" style="font-weight:bold;" rel="subtotal_total">'.price($total_line).'</td>';
@@ -2216,7 +2216,7 @@  discard block
 block discarded – undo
2216 2216
 				<?php
2217 2217
 				if ($action != 'selectlines') {
2218 2218
 				
2219
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
2219
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
2220 2220
 						?>
2221 2221
 						<input id="savelinebutton" class="button" type="submit" name="save" value="<?php echo $langs->trans('Save') ?>" />
2222 2222
 						<br />
@@ -2232,13 +2232,13 @@  discard block
 block discarded – undo
2232 2232
 						<?php
2233 2233
 						
2234 2234
 					}
2235
-					else{
2236
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2235
+					else {
2236
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2237 2237
 						{
2238
-							if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2238
+							if (TSubtotal::isTitle($line) && ($line->fk_prev_id === null)) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'.img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2239 2239
 						}
2240 2240
 
2241
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
2241
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
2242 2242
 						{
2243 2243
 							echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=editline&lineid='.$line->id.'">'.img_edit().'</a>';
2244 2244
 						}								
@@ -2253,7 +2253,7 @@  discard block
 block discarded – undo
2253 2253
 				<?php
2254 2254
 
2255 2255
 				if ($action != 'editline' && $action != 'selectlines') {
2256
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2256
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
2257 2257
 						{
2258 2258
 
2259 2259
 							if ($line->fk_prev_id === null)
@@ -2261,12 +2261,12 @@  discard block
 block discarded – undo
2261 2261
 								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteline&lineid='.$line->id.'">'.img_delete().'</a>';
2262 2262
 							}
2263 2263
 
2264
-							if(TSubtotal::isTitle($line) && ($line->fk_prev_id === null) )
2264
+							if (TSubtotal::isTitle($line) && ($line->fk_prev_id === null))
2265 2265
 							{
2266 2266
 								if ((float) DOL_VERSION >= 8.0) {
2267 2267
 									$img_delete = img_delete($langs->trans('deleteWithAllLines'), ' class="pictodelete pictodeleteallline"');
2268 2268
 								} elseif ((float) DOL_VERSION >= 3.8) {
2269
-									$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal',' class="pictodelete" ');
2269
+									$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal', ' class="pictodelete" ');
2270 2270
 								} else {
2271 2271
 									$img_delete = img_picto($langs->trans('deleteWithAllLines'), 'delete_all@subtotal');
2272 2272
 								}
@@ -2276,7 +2276,7 @@  discard block
 block discarded – undo
2276 2276
 								/* Depuis la 8.0, les icônes "standard" utilisent FontAwesome et sont préconfigurées selon la clé de l'image
2277 2277
 								 * Impossible d'en customiser par exemple la couleur, même en utilisant img_picto() directement
2278 2278
 								 */
2279
-								if((float) DOL_VERSION >= 8.0) {
2279
+								if ((float) DOL_VERSION >= 8.0) {
2280 2280
 								?>
2281 2281
 								<script>
2282 2282
 									$(document).ready(function () {
@@ -2292,7 +2292,7 @@  discard block
 block discarded – undo
2292 2292
 			</td>
2293 2293
 			
2294 2294
 			<?php 
2295
-			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
2295
+			if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
2296 2296
 			{
2297 2297
 				echo '<td class="subtotal_nc">';
2298 2298
 				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"' : '').' />';
@@ -2303,11 +2303,11 @@  discard block
 block discarded – undo
2303 2303
 			<td align="center" class="linecolmove tdlineupdown">
2304 2304
 			</td>
2305 2305
 			<?php } else { ?>
2306
-			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0  && $createRight ))?' class="tdlineupdown"':''); ?>></td>
2306
+			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0 && $createRight)) ? ' class="tdlineupdown"' : ''); ?>></td>
2307 2307
 			<?php } ?>
2308 2308
 
2309
-			<?php  if($action == 'selectlines'){ // dolibarr 8 ?>
2310
-			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
2309
+			<?php  if ($action == 'selectlines') { // dolibarr 8 ?>
2310
+			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i + 1; ?>]" value="<?php echo $line->id; ?>" ></td>
2311 2311
 			<?php } ?>
2312 2312
 
2313 2313
 			</tr>
@@ -2315,29 +2315,29 @@  discard block
 block discarded – undo
2315 2315
 			
2316 2316
 			
2317 2317
 			// Affichage des extrafields à la Dolibarr (car sinon non affiché sur les titres)
2318
-			if(TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2318
+			if (TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
2319 2319
 				
2320
-				require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
2320
+				require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
2321 2321
 				
2322 2322
 				// Extrafields
2323 2323
 				$extrafieldsline = new ExtraFields($db);
2324 2324
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2325 2325
 				
2326
-				$colspan+=3; $mode = 'view';
2327
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2326
+				$colspan += 3; $mode = 'view';
2327
+				if ($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2328 2328
 				
2329 2329
 				$ex_element = $line->element;
2330 2330
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
2331
-				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ','colspan'=>$colspan));
2331
+				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ', 'colspan'=>$colspan));
2332 2332
 				$isExtraSelected = false;
2333
-				foreach($line->array_options as $option) {
2334
-					if(!empty($option) && $option != "-1") {
2333
+				foreach ($line->array_options as $option) {
2334
+					if (!empty($option) && $option != "-1") {
2335 2335
 						$isExtraSelected = true;
2336 2336
 						break;
2337 2337
 					}
2338 2338
 				}
2339 2339
 				
2340
-				if($mode === 'edit') {
2340
+				if ($mode === 'edit') {
2341 2341
 					?>
2342 2342
 					<script>
2343 2343
 						$(document).ready(function(){
@@ -2345,7 +2345,7 @@  discard block
 block discarded – undo
2345 2345
 							var all_tr_extrafields = $("tr.tr_extrafield_title");
2346 2346
 							<?php 
2347 2347
 							// Si un extrafield est rempli alors on affiche directement les extrafields
2348
-							if(!$isExtraSelected) {
2348
+							if (!$isExtraSelected) {
2349 2349
 								echo 'all_tr_extrafields.hide();';
2350 2350
 								echo 'var trad = "'.$langs->trans('showExtrafields').'";';
2351 2351
 								echo 'var extra = 0;';
@@ -2389,20 +2389,20 @@  discard block
 block discarded – undo
2389 2389
 
2390 2390
 	
2391 2391
 	function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) {
2392
-		global $conf,$langs;
2392
+		global $conf, $langs;
2393 2393
 		 
2394 2394
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2395 2395
 		{
2396 2396
 		    
2397
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2397
+		    if ($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2398 2398
 		    {
2399 2399
 		        foreach ($object->lines as $line)
2400 2400
 		        {
2401 2401
 		            // fetch optionals attributes and labels
2402 2402
 		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2403
-		            $extrafields=new ExtraFields($this->db);
2404
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2405
-		            $line->fetch_optionals($line->id,$extralabels);
2403
+		            $extrafields = new ExtraFields($this->db);
2404
+		            $extralabels = $extrafields->fetch_name_optionals_label($object->table_element_line, true);
2405
+		            $line->fetch_optionals($line->id, $extralabels);
2406 2406
 		        }
2407 2407
 		    }
2408 2408
 		    
@@ -2502,23 +2502,23 @@  discard block
 block discarded – undo
2502 2502
 	    $ThtmlData['data-qty']          = 0; //$line->qty;
2503 2503
 	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2504 2504
 	    
2505
-	    if(TSubtotal::isTitle($line)){
2505
+	    if (TSubtotal::isTitle($line)) {
2506 2506
 	        $ThtmlData['data-issubtotal'] = 'title';
2507
-	    }elseif(TSubtotal::isSubtotal($line)){
2507
+	    }elseif (TSubtotal::isSubtotal($line)) {
2508 2508
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2509 2509
 	    }
2510
-	    else{
2510
+	    else {
2511 2511
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2512 2512
 	    }
2513 2513
 	    
2514 2514
 	    
2515 2515
 	    // Change or add data  from hooks
2516
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2516
+	    $parameters = array_replace($parameters, array('ThtmlData' => $ThtmlData));
2517 2517
 	    
2518 2518
 	    // hook 
2519
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2519
+	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2520 2520
 	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2521
-	    if ($reshook>0)
2521
+	    if ($reshook > 0)
2522 2522
 	    {
2523 2523
 	        $ThtmlData = $hookmanager->resArray;
2524 2524
 	    }
@@ -2531,14 +2531,14 @@  discard block
 block discarded – undo
2531 2531
 	function implodeHtmlData($ThtmlData = array())
2532 2532
 	{
2533 2533
 	    $data = '';
2534
-	    foreach($ThtmlData as $k => $h )
2534
+	    foreach ($ThtmlData as $k => $h)
2535 2535
 	    {
2536
-	        if(is_array($h))
2536
+	        if (is_array($h))
2537 2537
 	        {
2538 2538
 	            $h = json_encode($h);
2539 2539
 	        }
2540 2540
 	        
2541
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2541
+	        $data .= $k.'="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2542 2542
 	    }
2543 2543
 	    
2544 2544
 	    return $data;
@@ -2546,26 +2546,26 @@  discard block
 block discarded – undo
2546 2546
 	
2547 2547
 	function _ajax_block_order_js($object)
2548 2548
 	{
2549
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2549
+	    global $conf, $tagidfortablednd, $filepath, $langs;
2550 2550
 	    
2551 2551
 	    /*
2552 2552
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2553 2553
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2554 2554
 	     */
2555 2555
 	    
2556
-	    $id=$object->id;
2557
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2558
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2556
+	    $id = $object->id;
2557
+	    $nboflines = (isset($object->lines) ?count($object->lines) : 0);
2558
+	    $forcereloadpage = empty($conf->global->MAIN_FORCE_RELOAD_PAGE) ? 0 : 1;
2559 2559
 	    
2560
-	    $id=$object->id;
2561
-	    $fk_element=$object->fk_element;
2562
-	    $table_element_line=$object->table_element_line;
2563
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2564
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2565
-	    $filepath=(empty($filepath)?'':$filepath);
2560
+	    $id = $object->id;
2561
+	    $fk_element = $object->fk_element;
2562
+	    $table_element_line = $object->table_element_line;
2563
+	    $nboflines = (isset($object->lines) ?count($object->lines) : (empty($nboflines) ? 0 : $nboflines));
2564
+	    $tagidfortablednd = (empty($tagidfortablednd) ? 'tablelines' : $tagidfortablednd);
2565
+	    $filepath = (empty($filepath) ? '' : $filepath);
2566 2566
 	    
2567 2567
 	    
2568
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2568
+	    if (GETPOST('action', 'aZ09') != 'editline' && $nboflines > 1)
2569 2569
 	    {
2570 2570
 	        
2571 2571
 	        ?>
@@ -2583,7 +2583,7 @@  discard block
 block discarded – undo
2583 2583
 				moveBlockCol.disableSelection(); // prevent selection
2584 2584
 <?php if ($object->statut == 0) { ?>
2585 2585
 				// apply some graphical stuff
2586
-				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png',2);  ?>)');
2586
+				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png', 2); ?>)');
2587 2587
 				moveBlockCol.css("background-repeat","no-repeat");
2588 2588
 				moveBlockCol.css("background-position","center center");
2589 2589
 				moveBlockCol.css("cursor","move");
Please login to merge, or discard this patch.
Braces   +396 added lines, -240 removed lines patch added patch discarded remove patch
@@ -45,7 +45,9 @@  discard block
 block discarded – undo
45 45
 				$value = '';
46 46
 				$sql = 'SELECT content FROM '.MAIN_DB_PREFIX.'c_subtotal_free_text WHERE rowid = '.GETPOST('rowid');
47 47
 				$resql = $this->db->query($sql);
48
-				if ($resql && ($obj = $this->db->fetch_object($resql))) $value = $obj->content;
48
+				if ($resql && ($obj = $this->db->fetch_object($resql))) {
49
+					$value = $obj->content;
50
+				}
49 51
 			}
50 52
 			
51 53
 			?>
@@ -129,8 +131,11 @@  discard block
 block discarded – undo
129 131
 			if ($object->statut == 0  && $createRight) {
130 132
 			
131 133
 
132
-				if($object->element=='facture')$idvar = 'facid';
133
-				else $idvar='id';
134
+				if($object->element=='facture') {
135
+					$idvar = 'facid';
136
+				} else {
137
+					$idvar='id';
138
+				}
134 139
 				
135 140
 				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
136 141
 				{
@@ -138,10 +143,11 @@  discard block
 block discarded – undo
138 143
 					
139 144
 					if($action=='add_title_line') {
140 145
 						$title = GETPOST('title');
141
-						if(empty($title)) $title = $langs->trans('title');
146
+						if(empty($title)) {
147
+							$title = $langs->trans('title');
148
+						}
142 149
 						$qty = $level<1 ? 1 : $level ;
143
-					}
144
-					else if($action=='add_free_text') {
150
+					} else if($action=='add_free_text') {
145 151
 						$title = GETPOST('title');
146 152
 
147 153
 						if (empty($title)) {
@@ -153,29 +159,31 @@  discard block
 block discarded – undo
153 159
 								}
154 160
 							}
155 161
 						}
156
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
162
+						if(empty($title)) {
163
+							$title = $langs->trans('subtotalAddLineDescription');
164
+						}
157 165
 						$qty = 50;
158
-					}
159
-					else if($action=='add_subtitle_line') {
166
+					} else if($action=='add_subtitle_line') {
160 167
 						$title = GETPOST('title');
161
-						if(empty($title)) $title = $langs->trans('subtitle');
168
+						if(empty($title)) {
169
+							$title = $langs->trans('subtitle');
170
+						}
162 171
 						$qty = 2;
163
-					}
164
-					else if($action=='add_subtotal_line') {
172
+					} else if($action=='add_subtotal_line') {
165 173
 						$title = $langs->trans('SubSubTotal');
166 174
 						$qty = 98;
167
-					}
168
-					else {
175
+					} else {
169 176
 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
170 177
 						$qty = $level ? 100-$level : 99;
171 178
 					}
172 179
 					dol_include_once('/subtotal/class/subtotal.class.php');
173 180
 					
174
-					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
181
+					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) {
182
+						TSubtotal::addSubtotalMissing($object, $qty);
183
+					}
175 184
 					
176 185
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
177
-				}
178
-				else if($action==='ask_deleteallline') {
186
+				} else if($action==='ask_deleteallline') {
179 187
 						$form=new Form($db);
180 188
 						
181 189
 						$lineid = GETPOST('lineid','integer');
@@ -198,8 +206,7 @@  discard block
 block discarded – undo
198 206
 					$this->printNewFormat($object, $conf, $langs, $idvar);
199 207
 				}
200 208
 			}
201
-		}
202
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
209
+		} elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
203 210
 		{
204 211
 			?>
205 212
 			<script type="text/javascript">
@@ -217,8 +224,13 @@  discard block
 block discarded – undo
217 224
      
218 225
 	function printNewFormat(&$object, &$conf, &$langs, $idvar)
219 226
 	{
220
-		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) return false;
221
-		if ($line->fk_prev_id != null && !empty($line->fk_prev_id)) return false; // Si facture de situation
227
+		if (empty($conf->global->SUBTOTAL_ALLOW_ADD_BLOCK)) {
228
+			return false;
229
+		}
230
+		if ($line->fk_prev_id != null && !empty($line->fk_prev_id)) {
231
+			return false;
232
+		}
233
+		// Si facture de situation
222 234
 		?>
223 235
 		 	<script type="text/javascript">
224 236
 				$(document).ready(function() {
@@ -504,8 +516,7 @@  discard block
 block discarded – undo
504 516
 				}
505 517
 				
506 518
 				
507
-			}	
508
-			else{
519
+			} else{
509 520
 				$substitutionarray['line_not_modsubtotal'] = true;
510 521
 				$substitutionarray['line_modsubtotal'] = 0;
511 522
 			}
@@ -563,8 +574,11 @@  discard block
 block discarded – undo
563 574
 		
564 575
 		$showBlockExtrafields = GETPOST('showBlockExtrafields');
565 576
 		
566
-		if($object->element=='facture') $idvar = 'facid';
567
-		else $idvar = 'id';
577
+		if($object->element=='facture') {
578
+			$idvar = 'facid';
579
+		} else {
580
+			$idvar = 'id';
581
+		}
568 582
 			
569 583
 		if ($action == 'updateligne' || $action == 'updateline')
570 584
 		{
@@ -594,8 +608,7 @@  discard block
 block discarded – undo
594 608
 				header('Location: '.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id);
595 609
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
596 610
 			}
597
-		}
598
-		else if($action === 'builddoc') {
611
+		} else if($action === 'builddoc') {
599 612
 			
600 613
 			if (
601 614
 				in_array('invoicecard',explode(':',$parameters['context']))
@@ -610,33 +623,27 @@  discard block
 block discarded – undo
610 623
 					$sessname = 'subtotal_hideInnerLines_facture';	
611 624
 					$sessname2 = 'subtotal_hidedetails_facture';
612 625
 					$sessname3 = 'subtotal_hideprices_facture';
613
-				}
614
-				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
626
+				} elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
615 627
 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
616 628
 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
617 629
 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
618
-				}
619
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
630
+				} elseif(in_array('propalcard',explode(':',$parameters['context']))) {
620 631
 					$sessname = 'subtotal_hideInnerLines_propal';
621 632
 					$sessname2 = 'subtotal_hidedetails_propal';	
622 633
 					$sessname3 = 'subtotal_hideprices_propal';
623
-				}
624
-				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
634
+				} elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
625 635
 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
626 636
 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
627 637
 				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
628
-				}
629
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
638
+				} elseif(in_array('ordercard',explode(':',$parameters['context']))) {
630 639
 					$sessname = 'subtotal_hideInnerLines_commande';
631 640
 					$sessname2 = 'subtotal_hidedetails_commande';	
632 641
 					$sessname3 = 'subtotal_hideprices_commande';
633
-				}
634
-				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
642
+				} elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
635 643
 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
636 644
 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
637 645
 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
638
-				}
639
-				else {
646
+				} else {
640 647
 					$sessname = 'subtotal_hideInnerLines_unknown';
641 648
 					$sessname2 = 'subtotal_hidedetails_unknown';
642 649
 					$sessname3 = 'subtotal_hideprices_unknown';
@@ -645,15 +652,24 @@  discard block
 block discarded – undo
645 652
 				global $hideprices;
646 653
 				
647 654
 				$hideInnerLines = (int)GETPOST('hideInnerLines');
648
-				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) $_SESSION[$sessname] = array(); // prevent old system
655
+				if(!empty($_SESSION[$sessname]) && !is_array($_SESSION[$sessname][$object->id]) ) {
656
+					$_SESSION[$sessname] = array();
657
+				}
658
+				// prevent old system
649 659
 				$_SESSION[$sessname][$object->id] = $hideInnerLines;		
650 660
 				
651 661
 				$hidedetails= (int)GETPOST('hidedetails');
652
-				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) $_SESSION[$sessname2] = array(); // prevent old system
662
+				if(!empty($_SESSION[$sessname2]) && !is_array($_SESSION[$sessname2][$object->id]) ) {
663
+					$_SESSION[$sessname2] = array();
664
+				}
665
+				// prevent old system
653 666
 				$_SESSION[$sessname2][$object->id] = $hidedetails;
654 667
 				
655 668
 				$hideprices= (int)GETPOST('hideprices');
656
-				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) $_SESSION[$sessname3] = array(); // prevent old system
669
+				if(!empty($_SESSION[$sessname3]) && !is_array($_SESSION[$sessname3][$object->id]) ) {
670
+					$_SESSION[$sessname3] = array();
671
+				}
672
+				// prevent old system
657 673
 				$_SESSION[$sessname3][$object->id] = $hideprices;
658 674
 				
659 675
 				foreach($object->lines as &$line) {
@@ -661,8 +677,7 @@  discard block
 block discarded – undo
661 677
 					    
662 678
                         if($line->qty>=90) {
663 679
                             $line->modsubtotal_total = 1;
664
-                        }
665
-                        else{
680
+                        } else{
666 681
                             $line->modsubtotal_title = 1;
667 682
                         }
668 683
                         
@@ -671,8 +686,7 @@  discard block
 block discarded – undo
671 686
 	        	}
672 687
 	        }
673 688
 			
674
-		}
675
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
689
+		} else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
676 690
 			
677 691
 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
678 692
 			
@@ -680,7 +694,9 @@  discard block
 block discarded – undo
680 694
 				/**
681 695
 				 * @var $object Facture
682 696
 				 */
683
-				if($object->element=='facture') $object->deleteline($idLine);
697
+				if($object->element=='facture') {
698
+					$object->deleteline($idLine);
699
+				}
684 700
 				/**
685 701
 				 * @var $object Facture fournisseur
686 702
 				 */
@@ -691,18 +707,25 @@  discard block
 block discarded – undo
691 707
 				/**
692 708
 				 * @var $object Propal
693 709
 				 */
694
-				else if($object->element=='propal') $object->deleteline($idLine);
710
+				else if($object->element=='propal') {
711
+					$object->deleteline($idLine);
712
+				}
695 713
 				/**
696 714
 				 * @var $object Propal Fournisseur
697 715
 				 */
698
-				else if($object->element=='supplier_proposal') $object->deleteline($idLine);
716
+				else if($object->element=='supplier_proposal') {
717
+					$object->deleteline($idLine);
718
+				}
699 719
 				/**
700 720
 				 * @var $object Commande
701 721
 				 */
702 722
 				else if($object->element=='commande') 
703 723
 				{
704
-					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
705
-					else $object->deleteline($idLine);
724
+					if ((float) DOL_VERSION >= 5.0) {
725
+						$object->deleteline($user, $idLine);
726
+					} else {
727
+						$object->deleteline($idLine);
728
+					}
706 729
 				}
707 730
 				/**
708 731
 				 * @var $object Commande fournisseur
@@ -714,21 +737,26 @@  discard block
 block discarded – undo
714 737
 				/**
715 738
 				 * @var $object Facturerec
716 739
 				 */
717
-				else if($object->element=='facturerec') $object->deleteline($idLine);
740
+				else if($object->element=='facturerec') {
741
+					$object->deleteline($idLine);
742
+				}
718 743
 			}
719 744
 			
720 745
 			header('location:?id='.$object->id);
721 746
 			exit;
722 747
 			
723
-		}
724
-		else if ($action == 'duplicate')
748
+		} else if ($action == 'duplicate')
725 749
 		{
726 750
 			$lineid = GETPOST('lineid', 'int');
727 751
 			$nbDuplicate = TSubtotal::duplicateLines($object, $lineid, true);
728 752
 			
729
-			if ($nbDuplicate > 0) setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
730
-			elseif ($nbDuplicate == 0) setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
731
-			else setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
753
+			if ($nbDuplicate > 0) {
754
+				setEventMessage($langs->trans('subtotal_duplicate_success', $nbDuplicate));
755
+			} elseif ($nbDuplicate == 0) {
756
+				setEventMessage($langs->trans('subtotal_duplicate_lineid_not_found'), 'warnings');
757
+			} else {
758
+				setEventMessage($langs->trans('subtotal_duplicate_error'), 'errors');
759
+			}
732 760
 			
733 761
 			header('Location: ?id='.$object->id);
734 762
 			exit;
@@ -746,21 +774,26 @@  discard block
 block discarded – undo
746 774
 		global $conf;
747 775
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && !empty($object->table_element_line) && in_array($object->element, array('commande', 'facture', 'propal')))
748 776
 		{
749
-			if ($object->element == 'commande')
750
-				$obj = new OrderLine($object->db);
751
-			if ($object->element == 'propal')
752
-				$obj = new PropaleLigne($object->db);
753
-			if ($object->element == 'facture')
754
-				$obj = new FactureLigne($object->db);
777
+			if ($object->element == 'commande') {
778
+							$obj = new OrderLine($object->db);
779
+			}
780
+			if ($object->element == 'propal') {
781
+							$obj = new PropaleLigne($object->db);
782
+			}
783
+			if ($object->element == 'facture') {
784
+							$obj = new FactureLigne($object->db);
785
+			}
755 786
 			if (!empty($parameters['fk_element']))
756 787
 			{
757 788
 				
758 789
 				if($obj->fetch($parameters['fk_element'])){
759 790
 					$obj->id= $obj->rowid;
760
-					if (empty($obj->array_options))
761
-						$obj->fetch_optionals();
762
-					if (!empty($obj->array_options['options_subtotal_nc']))
763
-						return 1;
791
+					if (empty($obj->array_options)) {
792
+											$obj->fetch_optionals();
793
+					}
794
+					if (!empty($obj->array_options['options_subtotal_nc'])) {
795
+											return 1;
796
+					}
764 797
 				}
765 798
 			}
766 799
 		}
@@ -832,27 +865,33 @@  discard block
 block discarded – undo
832 865
 		$TTotal_tva = array();
833 866
 		
834 867
 		$sign=1;
835
-		if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) $sign=-1;
868
+		if (isset($object->type) && $object->type == 2 && ! empty($conf->global->INVOICE_POSITIVE_CREDIT_NOTE)) {
869
+			$sign=-1;
870
+		}
836 871
 		
837
-		if (GETPOST('action') == 'builddoc') $builddoc = true;
838
-		else $builddoc = false;
872
+		if (GETPOST('action') == 'builddoc') {
873
+			$builddoc = true;
874
+		} else {
875
+			$builddoc = false;
876
+		}
839 877
 		
840 878
 		dol_include_once('/subtotal/class/subtotal.class.php');
841 879
 		foreach($object->lines as $l) {
842 880
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
843 881
 			if($l->rang>=$rang) {
844 882
 				//echo 'return!<br>';
845
-				if (!$return_all) return $total;
846
-				else return array($total, $total_tva, $total_ttc, $TTotal_tva);
847
-			}
848
-			else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
883
+				if (!$return_all) {
884
+					return $total;
885
+				} else {
886
+					return array($total, $total_tva, $total_ttc, $TTotal_tva);
887
+				}
888
+			} else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
849 889
 		  	{
850 890
 				$total = 0;
851 891
 				$total_tva = 0;
852 892
 				$total_ttc = 0;
853 893
 				$TTotal_tva = array();
854
-			}
855
-			elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
894
+			} elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
856 895
 				
857 896
 				// TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF
858 897
 				if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION)
@@ -874,8 +913,7 @@  discard block
 block discarded – undo
874 913
 						$TTotal_tva[$l->tva_tx] += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
875 914
 						$total_ttc += $sign * ($l->total_tva / ($l->total_ttc / 100)) * $progress;
876 915
 					}
877
-				}
878
-				else
916
+				} else
879 917
 				{
880 918
 					$total += $l->total_ht;
881 919
 					$total_tva += $l->total_tva;
@@ -885,8 +923,11 @@  discard block
 block discarded – undo
885 923
 			}
886 924
 			
887 925
 		}
888
-		if (!$return_all) return $total;
889
-		else return array($total, $total_tva, $total_ttc, $TTotal_tva);
926
+		if (!$return_all) {
927
+			return $total;
928
+		} else {
929
+			return array($total, $total_tva, $total_ttc, $TTotal_tva);
930
+		}
890 931
 	}
891 932
 
892 933
 	/**
@@ -928,15 +969,18 @@  discard block
 block discarded – undo
928 969
 		}
929 970
 		
930 971
 			
931
-		if($line->qty==99)
932
-			$pdf->SetFillColor(220,220,220);
933
-		elseif ($line->qty==98)
934
-			$pdf->SetFillColor(230,230,230);
935
-		else
936
-			$pdf->SetFillColor(240,240,240);
972
+		if($line->qty==99) {
973
+					$pdf->SetFillColor(220,220,220);
974
+		} elseif ($line->qty==98) {
975
+					$pdf->SetFillColor(230,230,230);
976
+		} else {
977
+					$pdf->SetFillColor(240,240,240);
978
+		}
937 979
 		
938 980
 		$style = 'B';
939
-		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
981
+		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) {
982
+			$style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
983
+		}
940 984
 		
941 985
 		$pdf->SetFont('', $style, 9);
942 986
 		
@@ -978,8 +1022,7 @@  discard block
 block discarded – undo
978 1022
 //					$line->total_tva
979 1023
 //					$line->total
980 1024
 //					$line->total_ttc
981
-				}
982
-				else
1025
+				} else
983 1026
 				{
984 1027
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
985 1028
 					$total_to_print = price($total);
@@ -992,11 +1035,14 @@  discard block
 block discarded – undo
992 1035
 			}
993 1036
 
994 1037
 			$pdf->SetXY($pdf->postotalht, $posy);
995
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1038
+			if($set_pagebreak_margin) {
1039
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1040
+			}
996 1041
 			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
997
-		}
998
-		else{
999
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1042
+		} else{
1043
+			if($set_pagebreak_margin) {
1044
+				$pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
1045
+			}
1000 1046
 		}
1001 1047
 		
1002 1048
 		$posy = $posy + $cell_height;
@@ -1028,25 +1074,40 @@  discard block
 block discarded – undo
1028 1074
 		
1029 1075
  
1030 1076
 		$style = ($line->qty==1) ? 'BU' : 'BUI';
1031
-		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
1077
+		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) {
1078
+			$style = $conf->global->SUBTOTAL_TITLE_STYLE;
1079
+		}
1032 1080
 		
1033 1081
 		if($hideInnerLines) {
1034
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
1035
-			else 
1082
+			if($line->qty==1) {
1083
+				$pdf->SetFont('', $style, 9);
1084
+			} else 
1036 1085
 			{
1037
-				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
1086
+				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) {
1087
+					$style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
1088
+				}
1038 1089
 				$pdf->SetFont('', $style, 9);
1039 1090
 			}
1040
-		}
1041
-		else {
1091
+		} else {
1042 1092
 
1043
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
1044
-			else $pdf->SetFont('', $style, 9);
1093
+			if($line->qty==1) {
1094
+				$pdf->SetFont('', $style, 9);
1095
+			}
1096
+			//TODO if super utile
1097
+			else {
1098
+				$pdf->SetFont('', $style, 9);
1099
+			}
1045 1100
 			
1046 1101
 		}
1047 1102
 		
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
1103
+		if ($label === strip_tags($label) && $label === dol_html_entity_decode($label, ENT_QUOTES)) {
1104
+			$pdf->MultiCell($w, $h, $label, 0, 'L');
1105
+		}
1106
+		// Pas de HTML dans la chaine
1107
+		else {
1108
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true);
1109
+		}
1110
+		// et maintenant avec du HTML
1050 1111
 		
1051 1112
 		if($description && !$hidedesc) {
1052 1113
 			$posy = $pdf->GetY();
@@ -1070,8 +1131,7 @@  discard block
 block discarded – undo
1070 1131
 		
1071 1132
 		if(is_array($parameters)) {
1072 1133
 			$i = & $parameters['i'];	
1073
-		}
1074
-		else {
1134
+		} else {
1075 1135
 			$i = (int)$parameters;
1076 1136
 		}
1077 1137
 		
@@ -1093,17 +1153,14 @@  discard block
 block discarded – undo
1093 1153
 			
1094 1154
 			if((float)DOL_VERSION<=3.6) {
1095 1155
 				return '';
1096
-			}
1097
-			else if((float)DOL_VERSION>=3.8) {
1156
+			} else if((float)DOL_VERSION>=3.8) {
1098 1157
 				return 1;
1099 1158
 			}
1100 1159
 			
1101
-		}
1102
-		elseif(!empty($hideprices)) {
1160
+		} elseif(!empty($hideprices)) {
1103 1161
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1104 1162
 			return 1;
1105
-		}
1106
-		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1163
+		} elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1107 1164
 		{
1108 1165
 			$hideInnerLines = (int)GETPOST('hideInnerLines');
1109 1166
 			$hidedetails = (int)GETPOST('hidedetails');
@@ -1113,12 +1170,20 @@  discard block
 block discarded – undo
1113 1170
 			}
1114 1171
 		}
1115 1172
 		
1116
-		if(is_array($parameters)) $i = & $parameters['i'];
1117
-		else $i = (int)$parameters;
1173
+		if(is_array($parameters)) {
1174
+			$i = & $parameters['i'];
1175
+		} else {
1176
+			$i = (int)$parameters;
1177
+		}
1118 1178
 
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)
1179
+		if (empty($object->lines[$i])) {
1180
+			return 0;
1181
+		}
1182
+		// 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 1183
 		
1121
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1184
+		if(empty($object->lines[$i]->array_options)) {
1185
+			$object->lines[$i]->fetch_optionals();
1186
+		}
1122 1187
 
1123 1188
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1124 1189
 		{
@@ -1135,8 +1200,11 @@  discard block
 block discarded – undo
1135 1200
 	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1136 1201
 	    global $conf, $hideprices, $hookmanager;
1137 1202
 		
1138
-		if(is_array($parameters)) $i = & $parameters['i'];
1139
-		else $i = (int)$parameters;
1203
+		if(is_array($parameters)) {
1204
+			$i = & $parameters['i'];
1205
+		} else {
1206
+			$i = (int)$parameters;
1207
+		}
1140 1208
 			
1141 1209
 		if($this->isModSubtotalLine($parameters,$object) ){
1142 1210
 			
@@ -1144,13 +1212,11 @@  discard block
 block discarded – undo
1144 1212
 			
1145 1213
 			if((float)DOL_VERSION<=3.6) {
1146 1214
 				return '';
1147
-			}
1148
-			else if((float)DOL_VERSION>=3.8) {
1215
+			} else if((float)DOL_VERSION>=3.8) {
1149 1216
 				return 1;
1150 1217
 			}
1151 1218
 			
1152
-		}
1153
-		elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1219
+		} elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1154 1220
 		{
1155 1221
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1156 1222
 			{
@@ -1222,12 +1288,10 @@  discard block
 block discarded – undo
1222 1288
 			$this->error = $hookmanager->error;
1223 1289
 			$this->errors = $hookmanager->errors;
1224 1290
 			return -1;
1225
-		}
1226
-		elseif (empty($reshook))
1291
+		} elseif (empty($reshook))
1227 1292
 		{
1228 1293
 			$this->resprints .= $hookmanager->resprints;
1229
-		}
1230
-		else
1294
+		} else
1231 1295
 		{
1232 1296
 			$this->resprints = $hookmanager->resprints;
1233 1297
 
@@ -1250,14 +1314,16 @@  discard block
 block discarded – undo
1250 1314
 		
1251 1315
 			if((float)DOL_VERSION<=3.6) {
1252 1316
 				return '';
1253
-			}
1254
-			else if((float)DOL_VERSION>=3.8) {
1317
+			} else if((float)DOL_VERSION>=3.8) {
1255 1318
 				return 1;
1256 1319
 			}
1257 1320
 		}
1258 1321
 		
1259
-		if(is_array($parameters)) $i = & $parameters['i'];
1260
-		else $i = (int)$parameters;
1322
+		if(is_array($parameters)) {
1323
+			$i = & $parameters['i'];
1324
+		} else {
1325
+			$i = (int)$parameters;
1326
+		}
1261 1327
 		
1262 1328
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1263 1329
 		{
@@ -1279,14 +1345,16 @@  discard block
 block discarded – undo
1279 1345
 		
1280 1346
 			if((float)DOL_VERSION<=3.6) {
1281 1347
 				return '';
1282
-			}
1283
-			else if((float)DOL_VERSION>=3.8) {
1348
+			} else if((float)DOL_VERSION>=3.8) {
1284 1349
 				return 1;
1285 1350
 			}
1286 1351
 		}
1287 1352
 		
1288
-		if(is_array($parameters)) $i = & $parameters['i'];
1289
-		else $i = (int)$parameters;
1353
+		if(is_array($parameters)) {
1354
+			$i = & $parameters['i'];
1355
+		} else {
1356
+			$i = (int)$parameters;
1357
+		}
1290 1358
 			
1291 1359
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1292 1360
 		{
@@ -1303,8 +1371,11 @@  discard block
 block discarded – undo
1303 1371
 	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1304 1372
 	    global $conf,$hideprices,$hookmanager;
1305 1373
 
1306
-		if(is_array($parameters)) $i = & $parameters['i'];
1307
-		else $i = (int)$parameters;
1374
+		if(is_array($parameters)) {
1375
+			$i = & $parameters['i'];
1376
+		} else {
1377
+			$i = (int)$parameters;
1378
+		}
1308 1379
 
1309 1380
 		if($this->isModSubtotalLine($parameters,$object) ) {
1310 1381
 			$this->resprints = ' ';
@@ -1315,7 +1386,9 @@  discard block
 block discarded – undo
1315 1386
             if(TSubtotal::isSubtotal($line)) {
1316 1387
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1317 1388
 
1318
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1389
+                if(is_object($parentTitle) && empty($parentTitle->array_options)) {
1390
+                	$parentTitle->fetch_optionals();
1391
+                }
1319 1392
                 if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1320 1393
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1321 1394
                     $this->resprints = price($TTotal['total_subprice']);
@@ -1324,8 +1397,7 @@  discard block
 block discarded – undo
1324 1397
 		
1325 1398
 			if((float)DOL_VERSION<=3.6) {
1326 1399
 				return '';
1327
-			}
1328
-			else if((float)DOL_VERSION>=3.8) {
1400
+			} else if((float)DOL_VERSION>=3.8) {
1329 1401
 				return 1;
1330 1402
 			}
1331 1403
 		}
@@ -1370,8 +1442,11 @@  discard block
 block discarded – undo
1370 1442
 	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1371 1443
 	    global $conf,$hideprices,$hookmanager;
1372 1444
 
1373
-        if(is_array($parameters)) $i = & $parameters['i'];
1374
-        else $i = (int) $parameters;
1445
+        if(is_array($parameters)) {
1446
+        	$i = & $parameters['i'];
1447
+        } else {
1448
+        	$i = (int) $parameters;
1449
+        }
1375 1450
 
1376 1451
 		if($this->isModSubtotalLine($parameters,$object) ) {
1377 1452
 			$this->resprints = ' ';
@@ -1382,7 +1457,9 @@  discard block
 block discarded – undo
1382 1457
             if(TSubtotal::isSubtotal($line)) {
1383 1458
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1384 1459
 
1385
-                if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1460
+                if(empty($parentTitle->array_options)) {
1461
+                	$parentTitle->fetch_optionals();
1462
+                }
1386 1463
                 if(! empty($parentTitle->array_options['options_show_reduc'])) {
1387 1464
                     $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1388 1465
                     $this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
@@ -1391,12 +1468,10 @@  discard block
 block discarded – undo
1391 1468
 		
1392 1469
 			if((float)DOL_VERSION<=3.6) {
1393 1470
 				return '';
1394
-			}
1395
-			else if((float)DOL_VERSION>=3.8) {
1471
+			} else if((float)DOL_VERSION>=3.8) {
1396 1472
 				return 1;
1397 1473
 			}
1398
-		}
1399
-		elseif (!empty($hideprices)
1474
+		} elseif (!empty($hideprices)
1400 1475
 		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1401 1476
 		        )
1402 1477
 		    {
@@ -1417,14 +1492,16 @@  discard block
 block discarded – undo
1417 1492
 			$this->resprints = ' ';
1418 1493
 			if((float)DOL_VERSION<=3.6) {
1419 1494
 				return '';
1420
-			}
1421
-			else if((float)DOL_VERSION>=3.8) {
1495
+			} else if((float)DOL_VERSION>=3.8) {
1422 1496
 				return 1;
1423 1497
 			}
1424 1498
 		}
1425 1499
 		
1426
-		if(is_array($parameters)) $i = & $parameters['i'];
1427
-		else $i = (int)$parameters;
1500
+		if(is_array($parameters)) {
1501
+			$i = & $parameters['i'];
1502
+		} else {
1503
+			$i = (int)$parameters;
1504
+		}
1428 1505
 			
1429 1506
 		if (!empty($hideprices)
1430 1507
 				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
@@ -1448,16 +1525,21 @@  discard block
 block discarded – undo
1448 1525
 			
1449 1526
 			if((float)DOL_VERSION<=3.6) {
1450 1527
 				return '';
1451
-			}
1452
-			else if((float)DOL_VERSION>=3.8) {
1528
+			} else if((float)DOL_VERSION>=3.8) {
1453 1529
 				return 1;
1454 1530
 			}
1455 1531
 		}
1456 1532
 		
1457
-		if(is_array($parameters)) $i = & $parameters['i'];
1458
-		else $i = (int)$parameters;
1533
+		if(is_array($parameters)) {
1534
+			$i = & $parameters['i'];
1535
+		} else {
1536
+			$i = (int)$parameters;
1537
+		}
1459 1538
 		
1460
-		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)
1539
+		if (empty($object->lines[$i])) {
1540
+			return 0;
1541
+		}
1542
+		// 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)
1461 1543
 
1462 1544
 		$object->lines[$i]->fetch_optionals();
1463 1545
 		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
@@ -1503,14 +1585,16 @@  discard block
 block discarded – undo
1503 1585
 			$this->resprints = ' ';
1504 1586
 			if((float)DOL_VERSION<=3.6) {
1505 1587
 				return '';
1506
-			}
1507
-			else if((float)DOL_VERSION>=3.8) {
1588
+			} else if((float)DOL_VERSION>=3.8) {
1508 1589
 				return 1;
1509 1590
 			}
1510 1591
 		}
1511 1592
 		
1512
-		if(is_array($parameters)) $i = & $parameters['i'];
1513
-		else $i = (int)$parameters;
1593
+		if(is_array($parameters)) {
1594
+			$i = & $parameters['i'];
1595
+		} else {
1596
+			$i = (int)$parameters;
1597
+		}
1514 1598
 			
1515 1599
 		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1516 1600
 		{
@@ -1540,7 +1624,9 @@  discard block
 block discarded – undo
1540 1624
 				}
1541 1625
 			}
1542 1626
 			
1543
-			if (!empty($TLineTitle)) $TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1627
+			if (!empty($TLineTitle)) {
1628
+				$TTitleNumeroted = $this->formatNumerotation($TLineTitle);
1629
+			}
1544 1630
 		}
1545 1631
 		
1546 1632
 	}
@@ -1554,8 +1640,12 @@  discard block
 block discarded – undo
1554 1640
 		$j=0;
1555 1641
 		foreach ($TLineTitle as $k => &$line)
1556 1642
 		{
1557
-			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
1558
-			if (!empty($line_reference) && $line->qty <= $line_reference->qty) break;
1643
+			if (!empty($line_reference) && $line->rang <= $line_reference->rang) {
1644
+				continue;
1645
+			}
1646
+			if (!empty($line_reference) && $line->qty <= $line_reference->qty) {
1647
+				break;
1648
+			}
1559 1649
 			
1560 1650
 			if ($line->qty == $level)
1561 1651
 			{
@@ -1589,7 +1679,9 @@  discard block
 block discarded – undo
1589 1679
 		
1590 1680
 		$hidedetails = (int)GETPOST('hidedetails');
1591 1681
 		
1592
-		if(empty($hidedetails)) return false;
1682
+		if(empty($hidedetails)) {
1683
+			return false;
1684
+		}
1593 1685
 		
1594 1686
 		// TODO can't add VAT to document without lines... :-/
1595 1687
 		
@@ -1617,7 +1709,9 @@  discard block
 block discarded – undo
1617 1709
         foreach($object->lines as $k => &$l) {
1618 1710
             if(TSubtotal::isSubtotal($l)) {
1619 1711
                 $parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1620
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1712
+                if(is_object($parentTitle) && empty($parentTitle->array_options)) {
1713
+                	$parentTitle->fetch_optionals();
1714
+                }
1621 1715
                 if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_total_ht'])) {
1622 1716
                     $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1623 1717
                 }
@@ -1651,7 +1745,9 @@  discard block
 block discarded – undo
1651 1745
 						*/
1652 1746
 						list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
1653 1747
 						
1654
-						if (TSubtotal::getNiveau($line) == 1) $line->TTotal_tva = $TTotal_tva;
1748
+						if (TSubtotal::getNiveau($line) == 1) {
1749
+							$line->TTotal_tva = $TTotal_tva;
1750
+						}
1655 1751
 						$line->total_ht = $total;
1656 1752
 						$line->total_tva = $total_tva;
1657 1753
 						$line->total = $line->total_ht;
@@ -1715,8 +1811,7 @@  discard block
 block discarded – undo
1715 1811
 				    }
1716 1812
 				    
1717 1813
 					
1718
-				}
1719
-				elseif ($hidedetails)
1814
+				} elseif ($hidedetails)
1720 1815
 				{
1721 1816
 					$TLines[] = $line; //Cas où je cache uniquement les prix des produits	
1722 1817
 				}
@@ -1787,7 +1882,9 @@  discard block
 block discarded – undo
1787 1882
 				
1788 1883
 				if(!empty($hideprices)) {
1789 1884
 					foreach($object->lines as &$line) {
1790
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1885
+						if($line->fk_product_type!=9) {
1886
+							$line->fk_parent_line = -1;
1887
+						}
1791 1888
 					}
1792 1889
 				}
1793 1890
 			
@@ -1808,7 +1905,9 @@  discard block
 block discarded – undo
1808 1905
 				
1809 1906
 				if($line->qty>90) {
1810 1907
 					
1811
-					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1908
+					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT) {
1909
+						$label .= ' '.$this->getTitle($object, $line);
1910
+					}
1812 1911
 					
1813 1912
 					$pageBefore = $pdf->getPage();
1814 1913
 					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
@@ -1826,8 +1925,7 @@  discard block
 block discarded – undo
1826 1925
 				
1827 1926
 					$posy = $pdf->GetY();
1828 1927
 					return 1;
1829
-				}	
1830
-				else if ($line->qty < 10) {
1928
+				} else if ($line->qty < 10) {
1831 1929
 					$pageBefore = $pdf->getPage();
1832 1930
 
1833 1931
 					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
@@ -1851,8 +1949,7 @@  discard block
 block discarded – undo
1851 1949
 //	if($line->rowid==47) exit;
1852 1950
 			
1853 1951
 			return 0;
1854
-		}
1855
-		elseif (empty($object->lines[$parameters['i']]))
1952
+		} elseif (empty($object->lines[$parameters['i']]))
1856 1953
 		{
1857 1954
 			$this->resprints = -1;
1858 1955
 		}
@@ -1885,7 +1982,9 @@  discard block
 block discarded – undo
1885 1982
 		
1886 1983
 		foreach ($object->lines as $line)
1887 1984
 		{
1888
-			if ($line->id == $currentLine->id) break;
1985
+			if ($line->id == $currentLine->id) {
1986
+				break;
1987
+			}
1889 1988
 			
1890 1989
 			$qty_search = 100 - $currentLine->qty;
1891 1990
 			
@@ -1922,17 +2021,18 @@  discard block
 block discarded – undo
1922 2021
 		{
1923 2022
 			$object->statut = 0; // hack for facture rec
1924 2023
 			$createRight = $user->rights->facture->creer;
1925
-		}
1926
-		elseif($object->element == 'order_supplier' )
2024
+		} elseif($object->element == 'order_supplier' )
1927 2025
 		{
1928 2026
 		    $createRight = $user->rights->fournisseur->commande->creer;
1929
-		}
1930
-		elseif($object->element == 'invoice_supplier' )
2027
+		} elseif($object->element == 'invoice_supplier' )
1931 2028
 		{
1932 2029
 		    $createRight = $user->rights->fournisseur->facture->creer;
1933 2030
 		}
1934
-        if($object->element=='facture')$idvar = 'facid';
1935
-        else $idvar='id';
2031
+        if($object->element=='facture') {
2032
+        	$idvar = 'facid';
2033
+        } else {
2034
+        	$idvar='id';
2035
+        }
1936 2036
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1937 2037
             if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
1938 2038
             {
@@ -1950,8 +2050,7 @@  discard block
 block discarded – undo
1950 2050
 
1951 2051
             }
1952 2052
 			return 0;
1953
-		}	
1954
-		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)) 
2053
+		} 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)) 
1955 2054
         {
1956 2055
 
1957 2056
 			
@@ -1979,22 +2078,44 @@  discard block
 block discarded – undo
1979 2078
 				<?php
1980 2079
 			}
1981 2080
 			
1982
-			if(empty($line->description)) $line->description = $line->desc;
2081
+			if(empty($line->description)) {
2082
+				$line->description = $line->desc;
2083
+			}
1983 2084
 			
1984 2085
 			$colspan = 5;
1985
-			if($object->element == 'facturerec' ) $colspan = 3;
1986
-			if($object->element == 'order_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
1987
-			if($object->element == 'invoice_supplier') (float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7;
1988
-			if($object->element == 'supplier_proposal') (float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2086
+			if($object->element == 'facturerec' ) {
2087
+				$colspan = 3;
2088
+			}
2089
+			if($object->element == 'order_supplier') {
2090
+				(float) DOL_VERSION < 7.0 ? $colspan = 3 : $colspan = 6;
2091
+			}
2092
+			if($object->element == 'invoice_supplier') {
2093
+				(float) DOL_VERSION < 7.0 ? $colspan = 4: $colspan = 7;
2094
+			}
2095
+			if($object->element == 'supplier_proposal') {
2096
+				(float) DOL_VERSION < 6.0 ? $colspan = 4 : $colspan = 3;
2097
+			}
1989 2098
 			if(!empty($conf->multicurrency->enabled) && ((float) DOL_VERSION < 8.0 || $object->multicurrency_code != $conf->currency)) {
1990 2099
 				$colspan++; // Colonne PU Devise
1991 2100
 			}
1992
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1993
-			if(!empty($conf->margin->enabled)) $colspan++;
1994
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1995
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1996
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1997
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
2101
+			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) {
2102
+				$colspan++;
2103
+			}
2104
+			if(!empty($conf->margin->enabled)) {
2105
+				$colspan++;
2106
+			}
2107
+			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) {
2108
+				$colspan++;
2109
+			}
2110
+			if(!empty($conf->global->DISPLAY_MARK_RATES)) {
2111
+				$colspan++;
2112
+			}
2113
+			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) {
2114
+				$colspan++;
2115
+			}
2116
+			if(!empty($conf->global->PRODUCT_USE_UNITS)) {
2117
+				$colspan++;
2118
+			}
1998 2119
 					
1999 2120
 			/* Titre */
2000 2121
 			//var_dump($line);
@@ -2007,23 +2128,36 @@  discard block
 block discarded – undo
2007 2128
 			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
2008 2129
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
2009 2130
 					{
2010
-						if($line->qty==99) print 'background:#adadcf';
2011
-						else if($line->qty==98) print 'background:#ddddff;';
2012
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
2013
-						else if($line->qty==1) print 'background:#adadcf;';
2014
-						else if($line->qty==2) print 'background:#ddddff;';
2015
-						else if($line->qty==50) print '';
2016
-						else print 'background:#eeeeff;';
2131
+						if($line->qty==99) {
2132
+							print 'background:#adadcf';
2133
+						} else if($line->qty==98) {
2134
+							print 'background:#ddddff;';
2135
+						} else if($line->qty<=97 && $line->qty>=91) {
2136
+							print 'background:#eeeeff;';
2137
+						} else if($line->qty==1) {
2138
+							print 'background:#adadcf;';
2139
+						} else if($line->qty==2) {
2140
+							print 'background:#ddddff;';
2141
+						} else if($line->qty==50) {
2142
+							print '';
2143
+						} else {
2144
+							print 'background:#eeeeff;';
2145
+						}
2017 2146
 
2018 2147
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
2019
-					}
2020
-					else 
2148
+					} else 
2021 2149
 					{
2022
-						if($line->qty==99) print 'background:#ddffdd';
2023
-						else if($line->qty==98) print 'background:#ddddff;';
2024
-						else if($line->qty==2) print 'background:#eeeeff; ';
2025
-						else if($line->qty==50) print '';
2026
-						else print 'background:#eeffee;' ;
2150
+						if($line->qty==99) {
2151
+							print 'background:#ddffdd';
2152
+						} else if($line->qty==98) {
2153
+							print 'background:#ddddff;';
2154
+						} else if($line->qty==2) {
2155
+							print 'background:#eeeeff; ';
2156
+						} else if($line->qty==50) {
2157
+							print '';
2158
+						} else {
2159
+							print 'background:#eeffee;' ;
2160
+						}
2027 2161
 					}
2028 2162
 
2029 2163
 			?>;">
@@ -2050,13 +2184,11 @@  discard block
 block discarded – undo
2050 2184
 							$qty_displayed = $line->qty;
2051 2185
 							print img_picto('', 'subsubtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
2052 2186
 							
2053
-						}
2054
-						else if (TSubtotal::isSubtotal($line))
2187
+						} else if (TSubtotal::isSubtotal($line))
2055 2188
 						{
2056 2189
 							$qty_displayed = 100 - $line->qty;
2057 2190
 							print img_picto('', 'subsubtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;color:#0075DE;">'.$qty_displayed.'</span>&nbsp;&nbsp;';
2058
-						}
2059
-						else
2191
+						} else
2060 2192
 						{
2061 2193
 							$isFreeText = true;
2062 2194
 						}
@@ -2077,9 +2209,13 @@  discard block
 block discarded – undo
2077 2209
 						}
2078 2210
 
2079 2211
 						$readonlyForSituation = '';
2080
-						if (!empty($line->fk_prev_id) && $line->fk_prev_id != null) $readonlyForSituation = 'readonly';
2212
+						if (!empty($line->fk_prev_id) && $line->fk_prev_id != null) {
2213
+							$readonlyForSituation = 'readonly';
2214
+						}
2081 2215
 						
2082
-						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2216
+						if (!$isFreeText) {
2217
+							echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
2218
+						}
2083 2219
 						
2084 2220
 						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
2085 2221
 						{
@@ -2087,8 +2223,12 @@  discard block
 block discarded – undo
2087 2223
 							for ($j=1; $j<10; $j++)
2088 2224
 							{
2089 2225
 								if (!empty($readonlyForSituation)) {
2090
-									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2091
-								} else $select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2226
+									if ($qty_displayed == $j) {
2227
+										$select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2228
+									}
2229
+								} else {
2230
+									$select .= '<option '.($qty_displayed == $j ? 'selected="selected"' : '').' value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
2231
+								}
2092 2232
 							}
2093 2233
 							$select .= '</select>&nbsp;';
2094 2234
 
@@ -2108,7 +2248,9 @@  discard block
 block discarded – undo
2108 2248
                             echo '<div>';
2109 2249
                             echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2110 2250
                             echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2111
-                            if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2251
+                            if (empty($readonlyForSituation)) {
2252
+                            	echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2253
+                            }
2112 2254
                             echo '</select>';
2113 2255
                             echo '</div>';
2114 2256
 
@@ -2127,8 +2269,9 @@  discard block
 block discarded – undo
2127 2269
                             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;';
2128 2270
                             echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2129 2271
                             echo '</div>';
2272
+                        } else if ($isFreeText) {
2273
+                        	echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2130 2274
                         }
2131
-                        else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2132 2275
 						echo '</div>';
2133 2276
 
2134 2277
 						if($line->qty<10) {
@@ -2148,8 +2291,7 @@  discard block
 block discarded – undo
2148 2291
 							$doleditor->Create();
2149 2292
 						}
2150 2293
 						
2151
-					}
2152
-					else {
2294
+					} else {
2153 2295
 
2154 2296
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
2155 2297
 						 {
@@ -2157,14 +2299,19 @@  discard block
 block discarded – undo
2157 2299
 							{
2158 2300
 								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
2159 2301
 								
2160
-								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2161
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2302
+								if (TSubtotal::isTitle($line)) {
2303
+									print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
2304
+								} else {
2305
+									print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
2306
+								}
2162 2307
 							}
2163
-						 }
2164
-						 else 
2308
+						 } else 
2165 2309
 						 {
2166
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
2167
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
2310
+							if($line->qty<=1) {
2311
+								print img_picto('', 'subtotal@subtotal');
2312
+							} else if($line->qty==2) {
2313
+								print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
2314
+							}
2168 2315
 						 }
2169 2316
 						 
2170 2317
 						 
@@ -2174,21 +2321,26 @@  discard block
 block discarded – undo
2174 2321
 						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
2175 2322
 						 
2176 2323
 						 if (empty($line->label)) {
2177
-							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
2178
-							else print  $line->description;
2179
-						 } 
2180
-						 else {
2324
+							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) {
2325
+								print  $line->description.' '.$this->getTitle($object, $line);
2326
+							} else {
2327
+								print  $line->description;
2328
+							}
2329
+						 } else {
2181 2330
 
2182 2331
 							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
2183 2332
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
2184
-							}
2185
-							else{
2333
+							} else{
2186 2334
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
2187 2335
 							}
2188 2336
 
2189 2337
 						 } 
2190
-						if($line->qty>90) print ' : ';
2191
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2338
+						if($line->qty>90) {
2339
+							print ' : ';
2340
+						}
2341
+						if($line->info_bits > 0) {
2342
+							echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
2343
+						}
2192 2344
 
2193 2345
 						 
2194 2346
 
@@ -2231,11 +2383,12 @@  discard block
 block discarded – undo
2231 2383
 						</script>
2232 2384
 						<?php
2233 2385
 						
2234
-					}
2235
-					else{
2386
+					} else{
2236 2387
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
2237 2388
 						{
2238
-							if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2389
+							if(TSubtotal::isTitle($line) && ( $line->fk_prev_id === null )) {
2390
+								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
2391
+							}
2239 2392
 						}
2240 2393
 
2241 2394
 						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
@@ -2324,7 +2477,9 @@  discard block
 block discarded – undo
2324 2477
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
2325 2478
 				
2326 2479
 				$colspan+=3; $mode = 'view';
2327
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2480
+				if($action === 'editline' && $line->rowid == GETPOST('lineid')) {
2481
+					$mode = 'edit';
2482
+				}
2328 2483
 				
2329 2484
 				$ex_element = $line->element;
2330 2485
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
@@ -2504,10 +2659,9 @@  discard block
 block discarded – undo
2504 2659
 	    
2505 2660
 	    if(TSubtotal::isTitle($line)){
2506 2661
 	        $ThtmlData['data-issubtotal'] = 'title';
2507
-	    }elseif(TSubtotal::isSubtotal($line)){
2662
+	    } elseif(TSubtotal::isSubtotal($line)){
2508 2663
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2509
-	    }
2510
-	    else{
2664
+	    } else{
2511 2665
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2512 2666
 	    }
2513 2667
 	    
@@ -2517,7 +2671,9 @@  discard block
 block discarded – undo
2517 2671
 	    
2518 2672
 	    // hook 
2519 2673
 	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2520
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2674
+	    if ($reshook < 0) {
2675
+	    	setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2676
+	    }
2521 2677
 	    if ($reshook>0)
2522 2678
 	    {
2523 2679
 	        $ThtmlData = $hookmanager->resArray;
Please login to merge, or discard this patch.
class/subtotal.class.php 3 patches
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
 			 * @var $object Facture fournisseur
42 42
 			 */
43 43
 			else if($object->element=='invoice_supplier') {
44
-			    $object->special_code = TSubtotal::$module_number;
45
-			    $rang = $object->line_max() + 1;
46
-			    $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
44
+				$object->special_code = TSubtotal::$module_number;
45
+				$rang = $object->line_max() + 1;
46
+				$res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
47 47
 			}
48 48
 			/**
49 49
 			 * @var $object Propal
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 			 * @var $object Commande fournisseur
63 63
 			 */
64 64
 			else if($object->element=='order_supplier') {
65
-			    $object->special_code = TSubtotal::$module_number;
66
-			    $res = $object->addline($label, 0,$qty,0,0,0,0,0,'',0,'HT', 0, 9);
65
+				$object->special_code = TSubtotal::$module_number;
66
+				$res = $object->addline($label, 0,$qty,0,0,0,0,0,'',0,'HT', 0, 9);
67 67
 			}
68 68
 			/**
69 69
 			 * @var $object Facturerec
@@ -369,10 +369,10 @@  discard block
 block discarded – undo
369 369
 	
370 370
 	public static function isSubtotal(&$line, $level=-1)
371 371
 	{
372
-	    $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90;
373
-	    if($res && $level > -1) {
374
-	        return self::getNiveau($line) == $level;
375
-	    } else return $res;
372
+		$res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90;
373
+		if($res && $level > -1) {
374
+			return self::getNiveau($line) == $level;
375
+		} else return $res;
376 376
 	}
377 377
 	
378 378
 	public static function isFreeText(&$line)
@@ -409,29 +409,29 @@  discard block
 block discarded – undo
409 409
 		$createRight = $user->rights->{$object->element}->creer;
410 410
 		if($object->element == 'facturerec' )
411 411
 		{
412
-		    $object->statut = 0; // hack for facture rec
413
-		    $createRight = $user->rights->facture->creer;
412
+			$object->statut = 0; // hack for facture rec
413
+			$createRight = $user->rights->facture->creer;
414 414
 		}
415 415
 		elseif($object->element == 'order_supplier' )
416 416
 		{
417
-		    $createRight = $user->rights->fournisseur->commande->creer;
417
+			$createRight = $user->rights->fournisseur->commande->creer;
418 418
 		}
419 419
 		elseif($object->element == 'invoice_supplier' )
420 420
 		{
421
-		    $createRight = $user->rights->fournisseur->facture->creer;
421
+			$createRight = $user->rights->fournisseur->facture->creer;
422 422
 		}
423 423
 		
424 424
 		if ($object->statut == 0  && $createRight && (!empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) || !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE)))
425 425
 		{
426 426
 			dol_include_once('/subtotal/lib/subtotal.lib.php');
427 427
 
428
-            if(!empty($object->lines)) {
429
-                foreach($object->lines as $line) {
430
-                    if($line->id == $lineid) $duplicateLine = $line;
431
-                }
432
-            }
433
-            if(!empty($duplicateLine) && !self::isModSubtotalLine($duplicateLine)) $TLine = array($duplicateLine);
434
-            else $TLine = self::getLinesFromTitleId($object, $lineid, $withBlockLine);
428
+			if(!empty($object->lines)) {
429
+				foreach($object->lines as $line) {
430
+					if($line->id == $lineid) $duplicateLine = $line;
431
+				}
432
+			}
433
+			if(!empty($duplicateLine) && !self::isModSubtotalLine($duplicateLine)) $TLine = array($duplicateLine);
434
+			else $TLine = self::getLinesFromTitleId($object, $lineid, $withBlockLine);
435 435
 
436 436
 			if (!empty($TLine))
437 437
 			{
@@ -449,8 +449,8 @@  discard block
 block discarded – undo
449 449
 							break;
450 450
 							
451 451
 						case 'supplier_proposal':
452
-						    $res = $object->addline($line->desc, $line->subprice, $line->qty, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, $line->remise_percent, 'HT', 0, $line->info_bits, $line->product_type, -1, $line->special_code, 0, 0, $line->pa_ht, $line->label, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->origin, $line->origin_id);
453
-						    break;
452
+							$res = $object->addline($line->desc, $line->subprice, $line->qty, $line->tva_tx, $line->localtax1_tx, $line->localtax2_tx, $line->fk_product, $line->remise_percent, 'HT', 0, $line->info_bits, $line->product_type, -1, $line->special_code, 0, 0, $line->pa_ht, $line->label, $line->date_start, $line->date_end, $line->array_options, $line->fk_unit, $line->origin, $line->origin_id);
453
+							break;
454 454
 							
455 455
 						case 'commande':
456 456
 							//$desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $info_bits=0, $fk_remise_except=0, $price_base_type='HT', $pu_ttc=0, $date_start='', $date_end='', $type=0, $rang=-1, $special_code=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_options=0, $fk_unit=null, $origin='', $origin_id=0)
@@ -458,10 +458,10 @@  discard block
 block discarded – undo
458 458
 							break;
459 459
 							
460 460
 						case 'order_supplier':
461
-						    $object->line = $line;
462
-						    $object->line->fk_commande = $object->id;
463
-						    $object->line->rang = $object->line_max() +1;
464
-						    $res = $object->line->insert(1);
461
+							$object->line = $line;
462
+							$object->line->fk_commande = $object->id;
463
+							$object->line->rang = $object->line_max() +1;
464
+							$res = $object->line->insert(1);
465 465
 							break;
466 466
 							
467 467
 						case 'facture':
@@ -514,8 +514,8 @@  discard block
 block discarded – undo
514 514
 					$object->db->commit();
515 515
 					foreach ($TLineAdded as &$line)
516 516
 					{
517
-					    // ça peut paraitre non optimisé de déclancher la fonction sur toutes les lignes mais ceci est nécessaire pour réappliquer l'état exact de chaque ligne
518
-					    _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']);
517
+						// ça peut paraitre non optimisé de déclancher la fonction sur toutes les lignes mais ceci est nécessaire pour réappliquer l'état exact de chaque ligne
518
+						_updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']);
519 519
 					}
520 520
 					return count($TLineAdded);
521 521
 				}
@@ -589,33 +589,33 @@  discard block
 block discarded – undo
589 589
 		
590 590
 		switch ($object->element) 
591 591
 		{
592
-		    case 'propal':
593
-		        $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, $date_start, $date_end, $array_options, $fk_unit, 0, $notrigger);
594
-		        break;
592
+			case 'propal':
593
+				$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, $date_start, $date_end, $array_options, $fk_unit, 0, $notrigger);
594
+				break;
595 595
 		        
596
-		    case 'supplier_proposal':
597
-		        $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);
598
-		        break;
596
+			case 'supplier_proposal':
597
+				$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);
598
+				break;
599 599
 		        
600 600
 			case 'commande':
601 601
 				$res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $date_start, $date_end, $type, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $special_code, $array_options, $fk_unit, 0, $notrigger);
602 602
 				break;
603 603
 				
604 604
 			case 'order_supplier':
605
-			    $object->special_code = SELF::$module_number;
606
-			    if (empty($desc)) $desc = $label;
607
-			    $res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, 0, $date_start, $date_end, $array_options, $fk_unit);
608
-			    break;
605
+				$object->special_code = SELF::$module_number;
606
+				if (empty($desc)) $desc = $label;
607
+				$res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, 0, $date_start, $date_end, $array_options, $fk_unit);
608
+				break;
609 609
 			
610 610
 			case 'facture':
611 611
 				$res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, $fk_parent_line, $skip_update_total, $fk_fournprice, $pa_ht, $label, $special_code, $array_options, $situation_percent, $fk_unit, 0, $notrigger);
612 612
 				break;
613 613
 				
614 614
 			case 'invoice_supplier':
615
-			    $object->special_code = SELF::$module_number;
616
-			    if (empty($desc)) $desc = $label;
617
-			    $res = $object->updateline($rowid, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, 0, $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $fk_unit);
618
-			    break;
615
+				$object->special_code = SELF::$module_number;
616
+				if (empty($desc)) $desc = $label;
617
+				$res = $object->updateline($rowid, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, 0, $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $fk_unit);
618
+				break;
619 619
 				
620 620
 			case 'facturerec':
621 621
 				// Add extrafields and get rang
@@ -1006,8 +1006,8 @@  discard block
 block discarded – undo
1006 1006
 		{
1007 1007
 			if (is_readable($logo))
1008 1008
 			{
1009
-			    $height=pdf_getHeightForLogo($logo);
1010
-			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1009
+				$height=pdf_getHeightForLogo($logo);
1010
+				$pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1011 1011
 			}
1012 1012
 			else
1013 1013
 			{
@@ -1198,13 +1198,13 @@  discard block
 block discarded – undo
1198 1198
 	 * @param	int		$hidebottom		Hide bottom
1199 1199
 	 * @return	void
1200 1200
 	 */
1201
-    private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1202
-    {
1203
-	    if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1204
-	    $pdf->line($x+$l, $y, $x+$l, $y+$h);
1205
-	    if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1206
-	    $pdf->line($x, $y+$h, $x, $y);
1207
-    }
1201
+	private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1202
+	{
1203
+		if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1204
+		$pdf->line($x+$l, $y, $x+$l, $y+$h);
1205
+		if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1206
+		$pdf->line($x, $y+$h, $x, $y);
1207
+	}
1208 1208
 	
1209 1209
 	
1210 1210
 	public static function concat(&$outputlangs, $files, $fileoutput='')
@@ -1214,14 +1214,14 @@  discard block
 block discarded – undo
1214 1214
 		if (empty($fileoutput)) $fileoutput = $file[0];
1215 1215
 		
1216 1216
 		$pdf=pdf_getInstance();
1217
-        if (class_exists('TCPDF'))
1218
-        {
1219
-            $pdf->setPrintHeader(false);
1220
-            $pdf->setPrintFooter(false);
1221
-        }
1222
-        $pdf->SetFont(pdf_getPDFFont($outputlangs));
1217
+		if (class_exists('TCPDF'))
1218
+		{
1219
+			$pdf->setPrintHeader(false);
1220
+			$pdf->setPrintFooter(false);
1221
+		}
1222
+		$pdf->SetFont(pdf_getPDFFont($outputlangs));
1223 1223
 
1224
-        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1224
+		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1225 1225
 
1226 1226
 		
1227 1227
 		foreach($files as $file)
Please login to merge, or discard this patch.
Spacing   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -5,30 +5,30 @@  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 29
 			
30
-			$TNotElements = array ('invoice_supplier', 'order_supplier');
31
-			if ((float) DOL_VERSION < 6  || $qty==50 && !in_array($object->element, $TNotElements) ) {
30
+			$TNotElements = array('invoice_supplier', 'order_supplier');
31
+			if ((float) DOL_VERSION < 6 || $qty == 50 && !in_array($object->element, $TNotElements)) {
32 32
 				$desc = $label;
33 33
 				$label = '';
34 34
 			}
@@ -36,39 +36,39 @@  discard block
 block discarded – undo
36 36
 			/**
37 37
 			 * @var $object Facture
38 38
 			 */
39
-			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);
39
+			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);
40 40
 			/**
41 41
 			 * @var $object Facture fournisseur
42 42
 			 */
43
-			else if($object->element=='invoice_supplier') {
43
+			else if ($object->element == 'invoice_supplier') {
44 44
 			    $object->special_code = TSubtotal::$module_number;
45 45
 			    $rang = $object->line_max() + 1;
46
-			    $res = $object->addline($label,0,0,0,0,$qty,0,0,'','',0,0,'HT',9,$rang);
46
+			    $res = $object->addline($label, 0, 0, 0, 0, $qty, 0, 0, '', '', 0, 0, 'HT', 9, $rang);
47 47
 			}
48 48
 			/**
49 49
 			 * @var $object Propal
50 50
 			 */
51
-			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
+			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);
52 52
 			/**
53 53
 			 * @var $object Propal Fournisseur
54 54
 			 */
55
-			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
+			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);
56 56
 			
57 57
 			/**
58 58
 			 * @var $object Commande
59 59
 			 */
60
-			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
+			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);
61 61
 			/**
62 62
 			 * @var $object Commande fournisseur
63 63
 			 */
64
-			else if($object->element=='order_supplier') {
64
+			else if ($object->element == 'order_supplier') {
65 65
 			    $object->special_code = TSubtotal::$module_number;
66
-			    $res = $object->addline($label, 0,$qty,0,0,0,0,0,'',0,'HT', 0, 9);
66
+			    $res = $object->addline($label, 0, $qty, 0, 0, 0, 0, 0, '', 0, 'HT', 0, 9);
67 67
 			}
68 68
 			/**
69 69
 			 * @var $object Facturerec
70 70
 			 */
71
-			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
+			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); 
72 72
 			
73 73
 		}
74 74
 	
@@ -79,20 +79,20 @@  discard block
 block discarded – undo
79 79
 
80 80
 	public static function generateDoc(&$object)
81 81
 	{
82
-		global $conf,$langs,$db;
82
+		global $conf, $langs, $db;
83 83
 		
84 84
 		if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
85 85
 		{
86
-			$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
87
-			$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
88
-			$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
86
+			$hidedetails = (GETPOST('hidedetails', 'int') ? GETPOST('hidedetails', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0));
87
+			$hidedesc = (GETPOST('hidedesc', 'int') ? GETPOST('hidedesc', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0));
88
+			$hideref = (GETPOST('hideref', 'int') ? GETPOST('hideref', 'int') : (!empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0));
89 89
 			
90 90
 			// Define output language
91 91
 			$outputlangs = $langs;
92 92
 			$newlang = GETPOST('lang_id', 'alpha');
93
-			if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
93
+			if (!empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
94 94
 				$newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang;
95
-			if (! empty($newlang)) {
95
+			if (!empty($newlang)) {
96 96
 				$outputlangs = new Translate("", $conf);
97 97
 				$outputlangs->setDefaultLang($newlang);
98 98
 			}
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 			}
107 107
 			else
108 108
 			{
109
-				if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
109
+				if ($object->element != 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
110 110
 			}
111 111
 		}
112 112
 	}
@@ -118,11 +118,11 @@  discard block
 block discarded – undo
118 118
 	 * @param type $rang_start
119 119
 	 * @param type $move_to
120 120
 	 */
121
-	public static function updateRang(&$object, $rang_start, $move_to=1)
121
+	public static function updateRang(&$object, $rang_start, $move_to = 1)
122 122
 	{
123 123
 		if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
124 124
 		
125
-		$row=new GenericObject($object->db);
125
+		$row = new GenericObject($object->db);
126 126
 		$row->table_element_line = $object->table_element_line;
127 127
 		$row->fk_element = $object->fk_element;
128 128
 		$row->id = $object->id;
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 		{
132 132
 			if ($line->rang < $rang_start) continue;
133 133
 			
134
-			$row->updateRangOfLine($line->id, $line->rang+$move_to);
134
+			$row->updateRangOfLine($line->id, $line->rang + $move_to);
135 135
 		}
136 136
 	}
137 137
 	
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 			{
161 161
 				if ($rang_to_add != -1) self::updateRang($object, $rang_to_add);
162 162
 				
163
-				self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add);
163
+				self::addSubTotalLine($object, $langs->trans('SubTotal'), 100 - $title_niveau, $rang_to_add);
164 164
 				
165 165
 				$object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas)
166 166
 				if ($rang_to_add != -1) 
@@ -172,14 +172,14 @@  discard block
 block discarded – undo
172 172
 		}
173 173
 	}
174 174
 	
175
-	public static function addTitle(&$object, $label, $level, $rang=-1)
175
+	public static function addTitle(&$object, $label, $level, $rang = -1)
176 176
 	{
177 177
 		self::addSubTotalLine($object, $label, $level, $rang);
178 178
 	}
179 179
 	
180
-	public static function addTotal(&$object, $label, $level, $rang=-1)
180
+	public static function addTotal(&$object, $label, $level, $rang = -1)
181 181
 	{
182
-		self::addSubTotalLine($object, $label, (100-$level), $rang);
182
+		self::addSubTotalLine($object, $label, (100 - $level), $rang);
183 183
 	}
184 184
 
185 185
 	/**
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 	 * 
191 191
 	 * @return array
192 192
 	 */
193
-	public static function getAllTitleWithoutTotalFromDocument(&$object, $get_block_total=false)
193
+	public static function getAllTitleWithoutTotalFromDocument(&$object, $get_block_total = false)
194 194
 	{
195 195
 		$TTitle = self::getAllTitleFromDocument($object, $get_block_total);
196 196
 		
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
 	 * @param boolean								$return_rang_on_false	si true alors renvoi le rang où devrait ce trouver le sous-total
212 212
 	 * @return boolean
213 213
 	 */
214
-	public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false)
214
+	public static function titleHasTotalLine(&$object, &$title_line, $strict_mode = false, $return_rang_on_false = false)
215 215
 	{
216 216
 		if (empty($object->lines) || !is_array($object->lines)) return false;
217 217
 		
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
 		return ($return_rang_on_false) ? -1 : false;
238 238
 	}
239 239
 	
240
-	public static function getAllTitleFromDocument(&$object, $get_block_total=false)
240
+	public static function getAllTitleFromDocument(&$object, $get_block_total = false)
241 241
 	{
242 242
 		$TRes = array();
243 243
 		if (!empty($object->lines))
@@ -358,19 +358,19 @@  discard block
 block discarded – undo
358 358
 		return false;
359 359
 	}
360 360
 	
361
-	public static function isTitle(&$line, $level=-1)
361
+	public static function isTitle(&$line, $level = -1)
362 362
 	{
363 363
 		$res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty <= 9;
364
-		if($res && $level > -1) {
364
+		if ($res && $level > -1) {
365 365
 			return $line->qty == $level;
366 366
 		} else return $res;
367 367
 		
368 368
 	}
369 369
 	
370
-	public static function isSubtotal(&$line, $level=-1)
370
+	public static function isSubtotal(&$line, $level = -1)
371 371
 	{
372 372
 	    $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90;
373
-	    if($res && $level > -1) {
373
+	    if ($res && $level > -1) {
374 374
 	        return self::getNiveau($line) == $level;
375 375
 	    } else return $res;
376 376
 	}
@@ -385,52 +385,52 @@  discard block
 block discarded – undo
385 385
 		return self::isTitle($line) || self::isSubtotal($line) || self::isFreeText($line);
386 386
 	}
387 387
 
388
-	public static function getFreeTextHtml(&$line, $readonly=0)
388
+	public static function getFreeTextHtml(&$line, $readonly = 0)
389 389
 	{
390 390
 		global $conf;
391 391
 		
392 392
 		// Copie du fichier "objectline_edit.tpl.php"
393 393
 		// editeur wysiwyg
394 394
 		require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
395
-		$nbrows=ROWS_2;
396
-		if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
397
-		$enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
398
-		$toolbarname='dolibarr_details';
399
-		if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes';
400
-		$text = !empty($line->description)?$line->description:$line->label;
401
-		$doleditor=new DolEditor('line-description',$text,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%', $readonly);
395
+		$nbrows = ROWS_2;
396
+		if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows = $conf->global->MAIN_INPUT_DESC_HEIGHT;
397
+		$enable = (isset($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
398
+		$toolbarname = 'dolibarr_details';
399
+		if (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname = 'dolibarr_notes';
400
+		$text = !empty($line->description) ? $line->description : $line->label;
401
+		$doleditor = new DolEditor('line-description', $text, '', 164, $toolbarname, '', false, true, $enable, $nbrows, '98%', $readonly);
402 402
 		return $doleditor->Create(1);
403 403
 	}
404 404
 	
405
-	public static function duplicateLines(&$object, $lineid, $withBlockLine=false)
405
+	public static function duplicateLines(&$object, $lineid, $withBlockLine = false)
406 406
 	{
407
-		global $db,$user,$conf;
407
+		global $db, $user, $conf;
408 408
 
409 409
 		$createRight = $user->rights->{$object->element}->creer;
410
-		if($object->element == 'facturerec' )
410
+		if ($object->element == 'facturerec')
411 411
 		{
412 412
 		    $object->statut = 0; // hack for facture rec
413 413
 		    $createRight = $user->rights->facture->creer;
414 414
 		}
415
-		elseif($object->element == 'order_supplier' )
415
+		elseif ($object->element == 'order_supplier')
416 416
 		{
417 417
 		    $createRight = $user->rights->fournisseur->commande->creer;
418 418
 		}
419
-		elseif($object->element == 'invoice_supplier' )
419
+		elseif ($object->element == 'invoice_supplier')
420 420
 		{
421 421
 		    $createRight = $user->rights->fournisseur->facture->creer;
422 422
 		}
423 423
 		
424
-		if ($object->statut == 0  && $createRight && (!empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) || !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE)))
424
+		if ($object->statut == 0 && $createRight && (!empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) || !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE)))
425 425
 		{
426 426
 			dol_include_once('/subtotal/lib/subtotal.lib.php');
427 427
 
428
-            if(!empty($object->lines)) {
429
-                foreach($object->lines as $line) {
430
-                    if($line->id == $lineid) $duplicateLine = $line;
428
+            if (!empty($object->lines)) {
429
+                foreach ($object->lines as $line) {
430
+                    if ($line->id == $lineid) $duplicateLine = $line;
431 431
                 }
432 432
             }
433
-            if(!empty($duplicateLine) && !self::isModSubtotalLine($duplicateLine)) $TLine = array($duplicateLine);
433
+            if (!empty($duplicateLine) && !self::isModSubtotalLine($duplicateLine)) $TLine = array($duplicateLine);
434 434
             else $TLine = self::getLinesFromTitleId($object, $lineid, $withBlockLine);
435 435
 
436 436
 			if (!empty($TLine))
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 						case 'order_supplier':
461 461
 						    $object->line = $line;
462 462
 						    $object->line->fk_commande = $object->id;
463
-						    $object->line->rang = $object->line_max() +1;
463
+						    $object->line->rang = $object->line_max() + 1;
464 464
 						    $res = $object->line->insert(1);
465 465
 							break;
466 466
 							
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 					{
501 501
 						$object->line_from = $line;
502 502
 						// Call trigger
503
-						$result=$object->call_trigger('LINE_DUPLICATE',$user); // $object->line
503
+						$result = $object->call_trigger('LINE_DUPLICATE', $user); // $object->line
504 504
 						if ($result < 0)
505 505
 						{
506 506
 							$object->db->rollback();
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 		}
531 531
 	}
532 532
 	
533
-	public static function getLinesFromTitle(&$object, $key_trad, $level=1, $under_title='', $withBlockLine=false, $key_is_id=false)
533
+	public static function getLinesFromTitle(&$object, $key_trad, $level = 1, $under_title = '', $withBlockLine = false, $key_is_id = false)
534 534
 	{
535 535
 		global $langs;
536 536
 		
@@ -542,17 +542,17 @@  discard block
 block discarded – undo
542 542
 		
543 543
 		$TLine = array();
544 544
 		$add_line = false;
545
-		$under_title_found=false;
545
+		$under_title_found = false;
546 546
 		
547 547
 		foreach ($object->lines as $key => &$line)
548 548
 		{
549 549
 			if (!$under_title_found && !empty($TTitle_under_search))
550 550
 			{
551
-				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true;
551
+				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search))) $under_title_found = true;
552 552
 			}
553 553
 			else
554 554
 			{
555
-				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) )))
555
+				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))))
556 556
 				{
557 557
 					if ($key_is_id) $level = $line->qty;
558 558
 					
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 				
569 569
 				if ($add_line)
570 570
 				{
571
-					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue;
571
+					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line))) continue;
572 572
 					else $TLine[] = $line;
573 573
 				}
574 574
 			}
@@ -577,12 +577,12 @@  discard block
 block discarded – undo
577 577
 		return $TLine;
578 578
 	}
579 579
 	
580
-	public static function getLinesFromTitleId(&$object, $lineid, $withBlockLine=false)
580
+	public static function getLinesFromTitleId(&$object, $lineid, $withBlockLine = false)
581 581
 	{
582 582
 		return self::getLinesFromTitle($object, $lineid, '', '', $withBlockLine, true);
583 583
 	}
584 584
 	
585
-	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)
585
+	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)
586 586
 	{
587 587
 		$res = 0;
588 588
 		$object->db->begin();
@@ -594,7 +594,7 @@  discard block
 block discarded – undo
594 594
 		        break;
595 595
 		        
596 596
 		    case 'supplier_proposal':
597
-		        $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);
597
+		        $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);
598 598
 		        break;
599 599
 		        
600 600
 			case 'commande':
@@ -623,9 +623,9 @@  discard block
 block discarded – undo
623 623
 				$factureRecLine->fetch($rowid);
624 624
 				$factureRecLine->array_options = $array_options;
625 625
 				$factureRecLine->insertExtraFields();
626
-				$rang=$factureRecLine->rang;
626
+				$rang = $factureRecLine->rang;
627 627
 				
628
-				$fk_product=0; $fk_remise_except=''; $pu_ttc=0;	
628
+				$fk_product = 0; $fk_remise_except = ''; $pu_ttc = 0;	
629 629
 				$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);
630 630
 				break;
631 631
 		}
@@ -641,7 +641,7 @@  discard block
 block discarded – undo
641 641
 		global $db, $object;
642 642
 		
643 643
 		$TTitle = array();
644
-		if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {}
644
+		if (!empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {}
645 645
 		else {
646 646
 			if ($origin_line->element == 'propaldet')
647 647
 			{
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 	 */
722 722
 	public static function addRecapPage(&$parameters, &$origin_pdf)
723 723
 	{
724
-		global $user,$conf,$langs;
724
+		global $user, $conf, $langs;
725 725
 		
726 726
 		$origin_file = $parameters['file'];
727 727
 		$outputlangs = $parameters['outputlangs'];
@@ -737,21 +737,21 @@  discard block
 block discarded – undo
737 737
 		$objmarge->marge_droite = 10;
738 738
 		
739 739
 		$objectref = dol_sanitizeFileName($object->ref);
740
-		if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref;
741
-		elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref;
742
-		elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref;
740
+		if ($object->element == 'propal') $dir = $conf->propal->dir_output.'/'.$objectref;
741
+		elseif ($object->element == 'commande') $dir = $conf->commande->dir_output.'/'.$objectref;
742
+		elseif ($object->element == 'facture') $dir = $conf->facture->dir_output.'/'.$objectref;
743 743
 		elseif ($object->element == 'facturerec') return; // no PDF for facturerec
744 744
 		else
745 745
 		{
746 746
 			setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings');
747 747
 			return -1;
748 748
 		}
749
-		$file = $dir . '/' . $objectref . '_recap.pdf';
749
+		$file = $dir.'/'.$objectref.'_recap.pdf';
750 750
 
751 751
 //		$pdf=pdf_getInstance($origin_pdf->format);
752
-		$pdf=pdf_getInstance(array(210, 297)); // Format A4 Portrait
753
-		$default_font_size = pdf_getPDFFontSize($outputlangs);	// Must be after pdf_getInstance
754
-		$pdf->SetAutoPageBreak(1,0);
752
+		$pdf = pdf_getInstance(array(210, 297)); // Format A4 Portrait
753
+		$default_font_size = pdf_getPDFFontSize($outputlangs); // Must be after pdf_getInstance
754
+		$pdf->SetAutoPageBreak(1, 0);
755 755
 	             
756 756
 		if (class_exists('TCPDF'))
757 757
 		{
@@ -760,49 +760,49 @@  discard block
 block discarded – undo
760 760
 		}
761 761
 		$pdf->SetFont(pdf_getPDFFont($outputlangs));
762 762
 		// Set path to the background PDF File
763
-		if (empty($conf->global->MAIN_DISABLE_FPDI) && ! empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
763
+		if (empty($conf->global->MAIN_DISABLE_FPDI) && !empty($conf->global->MAIN_ADD_PDF_BACKGROUND))
764 764
 		{
765 765
 			$pagecount = $pdf->setSourceFile($conf->mycompany->dir_output.'/'.$conf->global->MAIN_ADD_PDF_BACKGROUND);
766 766
 			$tplidx = $pdf->importPage(1);
767 767
 		}
768 768
 
769 769
 		$pdf->Open();
770
-		$pagenb=0;
771
-		$pdf->SetDrawColor(128,128,128);
770
+		$pagenb = 0;
771
+		$pdf->SetDrawColor(128, 128, 128);
772 772
 
773 773
 		$pdf->SetTitle($outputlangs->convToOutputCharset($object->ref));
774 774
 		$pdf->SetSubject($outputlangs->transnoentities("subtotalRecap"));
775 775
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
776 776
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
777 777
 		$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
778
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
778
+		if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
779 779
 
780
-		$pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite);   // Left, Top, Right
780
+		$pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite); // Left, Top, Right
781 781
 
782
-		$pagenb=0;
783
-		$pdf->SetDrawColor(128,128,128);
782
+		$pagenb = 0;
783
+		$pdf->SetDrawColor(128, 128, 128);
784 784
 
785 785
 			
786 786
 		// New page
787 787
 		$pdf->AddPage();
788
-		if (! empty($tplidx)) $pdf->useTemplate($tplidx);
788
+		if (!empty($tplidx)) $pdf->useTemplate($tplidx);
789 789
 		$pagenb++;
790 790
 		
791 791
 		
792 792
 		self::pagehead($objmarge, $pdf, $object, 1, $outputlangs);
793
-		$pdf->SetFont('','', $default_font_size - 1);
794
-		$pdf->MultiCell(0, 3, '');		// Set interline to 3
795
-		$pdf->SetTextColor(0,0,0);
793
+		$pdf->SetFont('', '', $default_font_size - 1);
794
+		$pdf->MultiCell(0, 3, ''); // Set interline to 3
795
+		$pdf->SetTextColor(0, 0, 0);
796 796
 		
797
-		$heightforinfotot = 25;	// Height reserved to output the info and total part
798
-		$heightforfooter = $objmarge->marge_basse + 8;	// Height reserved to output the footer (value include bottom margin)
797
+		$heightforinfotot = 25; // Height reserved to output the info and total part
798
+		$heightforfooter = $objmarge->marge_basse + 8; // Height reserved to output the footer (value include bottom margin)
799 799
 		
800 800
 		$posx_designation = 25;
801 801
 		$posx_options = 150;
802 802
 		$posx_montant = 170;
803 803
 		
804 804
 		$tab_top = 72;
805
-		$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)?72:20); // TODO à vérifier
805
+		$tab_top_newpage = (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD) ? 72 : 20); // TODO à vérifier
806 806
 		
807 807
 		$TTot = array('total_ht' => 0, 'total_ttc' => 0, 'TTotal_tva' => array());
808 808
 		
@@ -816,14 +816,14 @@  discard block
 block discarded – undo
816 816
 			$nexY = $tab_top + 10;
817 817
 			
818 818
 			$nblignes = count($TLine);
819
-			foreach($TLine as $i => &$line)
819
+			foreach ($TLine as $i => &$line)
820 820
 			{
821 821
 				$curY = $nexY;
822 822
 				
823 823
 				if (self::getNiveau($line) == 1) 
824 824
 				{
825
-					$pdf->SetFont('','B', $default_font_size - 1);   // Into loop to work with multipage
826
-					$curY+=2;
825
+					$pdf->SetFont('', 'B', $default_font_size - 1); // Into loop to work with multipage
826
+					$curY += 2;
827 827
 					
828 828
 					$TTot['total_ht'] += $line->total_ht;
829 829
 					$TTot['total_tva'] += $line->total_tva;
@@ -842,67 +842,67 @@  discard block
 block discarded – undo
842 842
 						$TTot['TTotal_tva_multicurrency'][$tx] += $amount;
843 843
 					}	
844 844
 				}
845
-				else $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
845
+				else $pdf->SetFont('', '', $default_font_size - 1); // Into loop to work with multipage
846 846
 				
847
-				$pdf->SetTextColor(0,0,0);
847
+				$pdf->SetTextColor(0, 0, 0);
848 848
 				
849 849
 				$pdf->setTopMargin($tab_top_newpage + 10);
850
-				$pdf->setPageOrientation('', 1, $heightforfooter+$heightforinfotot);	// The only function to edit the bottom margin of current page to set it.
851
-				$pageposbefore=$pdf->getPage();
850
+				$pdf->setPageOrientation('', 1, $heightforfooter + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
851
+				$pageposbefore = $pdf->getPage();
852 852
 				
853
-				$showpricebeforepagebreak=1;
853
+				$showpricebeforepagebreak = 1;
854 854
 				
855 855
 				$decalage = (self::getNiveau($line) - 1) * 2;
856 856
 				
857 857
 				// Print: Designation
858 858
 				$label = $line->label;
859
-				if( (float)DOL_VERSION < 6 ) {
859
+				if ((float) DOL_VERSION < 6) {
860 860
 					$label = !empty($line->label) ? $line->label : $line->desc;
861 861
 				}
862 862
 				
863 863
 				
864 864
 				$pdf->startTransaction();
865
-				$pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true);
866
-				$pageposafter=$pdf->getPage();
865
+				$pdf->writeHTMLCell($posx_options - $posx_designation - $decalage, 3, $posx_designation + $decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J', true);
866
+				$pageposafter = $pdf->getPage();
867 867
 				if ($pageposafter > $pageposbefore)	// There is a pagebreak
868 868
 				{
869 869
 					$pdf->rollbackTransaction(true);
870
-					$pageposafter=$pageposbefore;
870
+					$pageposafter = $pageposbefore;
871 871
 					//print $pageposafter.'-'.$pageposbefore;exit;
872
-					$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
873
-					$pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true);
872
+					$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
873
+					$pdf->writeHTMLCell($posx_options - $posx_designation - $decalage, 3, $posx_designation + $decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J', true);
874 874
 
875
-					$pageposafter=$pdf->getPage();
876
-					$posyafter=$pdf->GetY();
875
+					$pageposafter = $pdf->getPage();
876
+					$posyafter = $pdf->GetY();
877 877
 					//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
878
-					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot)))	// There is no space left for total+free text
878
+					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter + $heightforinfotot)))	// There is no space left for total+free text
879 879
 					{
880
-						if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
880
+						if ($i == ($nblignes - 1))	// No more lines, and no space left to show total, so we create a new page
881 881
 						{
882
-							$pdf->AddPage('','',true);
883
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
882
+							$pdf->AddPage('', '', true);
883
+							if (!empty($tplidx)) $pdf->useTemplate($tplidx);
884 884
 							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
885
-							$pdf->setPage($pageposafter+1);
885
+							$pdf->setPage($pageposafter + 1);
886 886
 						}
887 887
 					}
888 888
 					else
889 889
 					{
890 890
 						// We found a page break
891
-						$showpricebeforepagebreak=0;
891
+						$showpricebeforepagebreak = 0;
892 892
 					}
893 893
 				}
894 894
 				else	// No pagebreak
895 895
 				{
896 896
 					$pdf->commitTransaction();
897 897
 				}
898
-				$posYAfterDescription=$pdf->GetY();
898
+				$posYAfterDescription = $pdf->GetY();
899 899
 
900 900
 				$nexY = $pdf->GetY();
901
-				$pageposafter=$pdf->getPage();
901
+				$pageposafter = $pdf->getPage();
902 902
 
903 903
 				$pdf->setPage($pageposbefore);
904 904
 				$pdf->setTopMargin($objmarge->marge_haute);
905
-				$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
905
+				$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
906 906
 
907 907
 				// We suppose that a too long description or photo were moved completely on next page
908 908
 				if ($pageposafter > $pageposbefore && empty($showpricebeforepagebreak)) {
@@ -915,14 +915,14 @@  discard block
 block discarded – undo
915 915
 				if (!empty($line->total_options))
916 916
 				{
917 917
 					$pdf->SetXY($posx_options, $curY);
918
-					$pdf->MultiCell($posx_montant-$posx_options-0.8, 3, price($line->total_options, 0, $outputlangs), 0, 'R', 0);
918
+					$pdf->MultiCell($posx_montant - $posx_options - 0.8, 3, price($line->total_options, 0, $outputlangs), 0, 'R', 0);
919 919
 				}
920 920
 				
921 921
 				// Print: Montant
922 922
 				$pdf->SetXY($posx_montant, $curY);
923
-				$pdf->MultiCell($objmarge->page_largeur-$objmarge->marge_droite-$posx_montant-0.8, 3, price($line->total_ht, 0, $outputlangs), 0, 'R', 0);
923
+				$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant - 0.8, 3, price($line->total_ht, 0, $outputlangs), 0, 'R', 0);
924 924
 				
925
-				$nexY+=2;    // Passe espace entre les lignes
925
+				$nexY += 2; // Passe espace entre les lignes
926 926
 
927 927
 				// Detect if some page were added automatically and output _tableau for past pages
928 928
 				while ($pagenb < $pageposafter)
@@ -939,7 +939,7 @@  discard block
 block discarded – undo
939 939
 					
940 940
 					$pagenb++;
941 941
 					$pdf->setPage($pagenb);
942
-					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
942
+					$pdf->setPageOrientation('', 1, 0); // The only function to edit the bottom margin of current page to set it.
943 943
 					if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
944 944
 				}
945 945
 			}
@@ -949,19 +949,19 @@  discard block
 block discarded – undo
949 949
 		if ($pagenb == 1)
950 950
 		{
951 951
 			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);
952
-			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
952
+			$bottomlasttab = $objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
953 953
 		}
954 954
 		else
955 955
 		{
956 956
 			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);
957
-			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
957
+			$bottomlasttab = $objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
958 958
 		}
959 959
 		
960 960
 		// Affiche zone totaux
961
-		$posy=self::tableau_tot($objmarge, $pdf, $object, $bottomlasttab, $outputlangs, $TTot);
961
+		$posy = self::tableau_tot($objmarge, $pdf, $object, $bottomlasttab, $outputlangs, $TTot);
962 962
 		
963 963
 		$pdf->Close();
964
-		$pdf->Output($file,'F');
964
+		$pdf->Output($file, 'F');
965 965
 		
966 966
 		$pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file);
967 967
 		
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
 		$level = $line->qty; // TODO à améliorer
974 974
 		
975 975
 		$pdf->SetXY($objmarge->marge_gauche, $curY);
976
-		$pdf->MultiCell($posx_designation-$objmarge->marge_gauche-0.8, 5, $level, 0, 'L', 0);
976
+		$pdf->MultiCell($posx_designation - $objmarge->marge_gauche - 0.8, 5, $level, 0, 'L', 0);
977 977
 	}
978 978
 	
979 979
 	/**
@@ -987,50 +987,50 @@  discard block
 block discarded – undo
987 987
 	 */
988 988
 	private static function pagehead(&$objmarge, &$pdf, &$object, $showdetail, $outputlangs)
989 989
 	{
990
-		global $conf,$mysoc;
990
+		global $conf, $mysoc;
991 991
 
992 992
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
993 993
 
994
-		pdf_pagehead($pdf,$outputlangs,$objmarge->page_hauteur);
994
+		pdf_pagehead($pdf, $outputlangs, $objmarge->page_hauteur);
995 995
 
996
-		$pdf->SetTextColor(0,0,60);
997
-		$pdf->SetFont('','B', $default_font_size + 3);
996
+		$pdf->SetTextColor(0, 0, 60);
997
+		$pdf->SetFont('', 'B', $default_font_size + 3);
998 998
 
999
-		$posy=$objmarge->marge_haute;
1000
-		$posx=$objmarge->page_largeur-$objmarge->marge_droite-100;
999
+		$posy = $objmarge->marge_haute;
1000
+		$posx = $objmarge->page_largeur - $objmarge->marge_droite - 100;
1001 1001
 		
1002
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
1002
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
1003 1003
 
1004
-		$logo=$conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
1004
+		$logo = $conf->mycompany->dir_output.'/logos/'.$mysoc->logo;
1005 1005
 		if ($mysoc->logo)
1006 1006
 		{
1007 1007
 			if (is_readable($logo))
1008 1008
 			{
1009
-			    $height=pdf_getHeightForLogo($logo);
1010
-			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1009
+			    $height = pdf_getHeightForLogo($logo);
1010
+			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height); // width=0 (auto)
1011 1011
 			}
1012 1012
 			else
1013 1013
 			{
1014
-				$pdf->SetTextColor(200,0,0);
1015
-				$pdf->SetFont('','B',$default_font_size - 2);
1016
-				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
1014
+				$pdf->SetTextColor(200, 0, 0);
1015
+				$pdf->SetFont('', 'B', $default_font_size - 2);
1016
+				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound", $logo), 0, 'L');
1017 1017
 				$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
1018 1018
 			}
1019 1019
 			
1020
-			$posy+=35;
1020
+			$posy += 35;
1021 1021
 		}
1022 1022
 		else
1023 1023
 		{
1024
-			$text=$mysoc->name;
1024
+			$text = $mysoc->name;
1025 1025
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
1026 1026
 			
1027
-			$posy+=15;
1027
+			$posy += 15;
1028 1028
 		}
1029 1029
 		
1030 1030
 		
1031
-		$pdf->SetTextColor(0,0,0);
1032
-		$pdf->SetFont('','B', $default_font_size + 2);
1033
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
1031
+		$pdf->SetTextColor(0, 0, 0);
1032
+		$pdf->SetFont('', 'B', $default_font_size + 2);
1033
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
1034 1034
 		
1035 1035
 		$key = 'subtotalPropalTitle';
1036 1036
 		if ($object->element == 'commande') $key = 'subtotalCommandeTitle';
@@ -1039,14 +1039,14 @@  discard block
 block discarded – undo
1039 1039
 		
1040 1040
 		$pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L');
1041 1041
 		
1042
-		$pdf->SetFont('','', $default_font_size);
1043
-		$pdf->SetXY($objmarge->page_largeur-$objmarge->marge_droite-40,$posy);
1042
+		$pdf->SetFont('', '', $default_font_size);
1043
+		$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - 40, $posy);
1044 1044
 		$pdf->MultiCell(40, 4, dol_print_date($object->date, 'daytext'), '', 'R');
1045 1045
 		
1046 1046
 		$posy += 8;
1047 1047
 			
1048
-		$pdf->SetFont('','B', $default_font_size + 2);
1049
-		$pdf->SetXY($objmarge->marge_gauche,$posy);
1048
+		$pdf->SetFont('', 'B', $default_font_size + 2);
1049
+		$pdf->SetXY($objmarge->marge_gauche, $posy);
1050 1050
 		$pdf->MultiCell(70, 4, $outputlangs->transnoentities('subtotalRecapLot'), '', 'L');
1051 1051
 		
1052 1052
 	}
@@ -1064,44 +1064,44 @@  discard block
 block discarded – undo
1064 1064
 	 *   @param		string		$currency		Currency code
1065 1065
 	 *   @return	void
1066 1066
 	 */
1067
-	private static function tableau(&$objmarge, &$pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop=0, $hidebottom=0, $currency='')
1067
+	private static function tableau(&$objmarge, &$pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $tab_height, $nexY, $outputlangs, $hidetop = 0, $hidebottom = 0, $currency = '')
1068 1068
 	{
1069 1069
 		global $conf;
1070 1070
 		
1071 1071
 		// Force to disable hidetop and hidebottom
1072
-		$hidebottom=0;
1073
-		if ($hidetop) $hidetop=-1;
1072
+		$hidebottom = 0;
1073
+		if ($hidetop) $hidetop = -1;
1074 1074
 
1075 1075
 		$currency = !empty($currency) ? $currency : $conf->currency;
1076 1076
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1077 1077
 
1078 1078
 		// Amount in (at tab_top - 1)
1079
-		$pdf->SetTextColor(0,0,0);
1080
-		$pdf->SetFont('','',$default_font_size);
1079
+		$pdf->SetTextColor(0, 0, 0);
1080
+		$pdf->SetFont('', '', $default_font_size);
1081 1081
 
1082 1082
 		if (empty($hidetop))
1083 1083
 		{
1084
-			$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$currency));
1085
-			$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5);
1084
+			$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
1085
+			$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top - 4.5);
1086 1086
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1087 1087
 			
1088
-			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));
1088
+			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));
1089 1089
 			
1090 1090
 			
1091
-			$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
1091
+			$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
1092 1092
 
1093
-			$pdf->SetXY($posx_designation, $tab_top+2);
1094
-			$pdf->MultiCell($posx_options - $posx_designation,2, $outputlangs->transnoentities("Designation"),'','L');
1095
-			$pdf->SetXY($posx_options, $tab_top+2);
1096
-			$pdf->MultiCell($posx_montant - $posx_options,2, $outputlangs->transnoentities("Options"),'','R');
1097
-			$pdf->SetXY($posx_montant, $tab_top+2);
1098
-			$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R');
1093
+			$pdf->SetXY($posx_designation, $tab_top + 2);
1094
+			$pdf->MultiCell($posx_options - $posx_designation, 2, $outputlangs->transnoentities("Designation"), '', 'L');
1095
+			$pdf->SetXY($posx_options, $tab_top + 2);
1096
+			$pdf->MultiCell($posx_montant - $posx_options, 2, $outputlangs->transnoentities("Options"), '', 'R');
1097
+			$pdf->SetXY($posx_montant, $tab_top + 2);
1098
+			$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant, 2, $outputlangs->transnoentities("Amount"), '', 'R');
1099 1099
 			
1100
-			$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
1100
+			$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
1101 1101
 		}
1102 1102
 		else
1103 1103
 		{
1104
-			$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
1104
+			$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
1105 1105
 		}
1106 1106
 		
1107 1107
 	}
@@ -1110,29 +1110,29 @@  discard block
 block discarded – undo
1110 1110
 	{
1111 1111
 		global $conf;
1112 1112
 		
1113
-		$pdf->line($objmarge->marge_gauche, $posy, $objmarge->page_largeur-$objmarge->marge_droite, $posy);	// line prend une position y en 2eme param et 4eme param
1113
+		$pdf->line($objmarge->marge_gauche, $posy, $objmarge->page_largeur - $objmarge->marge_droite, $posy); // line prend une position y en 2eme param et 4eme param
1114 1114
 		
1115 1115
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
1116 1116
 		
1117
-		$tab2_top = $posy+2;
1117
+		$tab2_top = $posy + 2;
1118 1118
 		$tab2_hl = 4;
1119
-		$pdf->SetFont('','', $default_font_size - 1);
1119
+		$pdf->SetFont('', '', $default_font_size - 1);
1120 1120
 
1121 1121
 		// Tableau total
1122 1122
 		$col1x = 120; $col2x = 170;
1123 1123
 		if ($objmarge->page_largeur < 210) // To work with US executive format
1124 1124
 		{
1125
-			$col2x-=20;
1125
+			$col2x -= 20;
1126 1126
 		}
1127 1127
 		$largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x);
1128 1128
 
1129
-		$useborder=0;
1129
+		$useborder = 0;
1130 1130
 		$index = 0;
1131 1131
 
1132 1132
 		// Total HT
1133
-		$pdf->SetFillColor(255,255,255);
1133
+		$pdf->SetFillColor(255, 255, 255);
1134 1134
 		$pdf->SetXY($col1x, $tab2_top + 0);
1135
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1135
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
1136 1136
 
1137 1137
 		// $total_ht = ($conf->multicurrency->enabled && $object->mylticurrency_tx != 1) ? $TTot['multicurrency_total_ht'] : $TTot['total_ht'];
1138 1138
 		$total_ht = $TTot['total_ht'];
@@ -1140,10 +1140,10 @@  discard block
 block discarded – undo
1140 1140
 		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ht, 0, $outputlangs), 0, 'R', 1);
1141 1141
 
1142 1142
 		// Show VAT by rates and total
1143
-		$pdf->SetFillColor(248,248,248);
1143
+		$pdf->SetFillColor(248, 248, 248);
1144 1144
 		
1145
-		$atleastoneratenotnull=0;
1146
-		foreach($TTot['TTotal_tva'] as $tvakey => $tvaval)
1145
+		$atleastoneratenotnull = 0;
1146
+		foreach ($TTot['TTotal_tva'] as $tvakey => $tvaval)
1147 1147
 		{
1148 1148
 			if ($tvakey != 0)    // On affiche pas taux 0
1149 1149
 			{
@@ -1152,15 +1152,15 @@  discard block
 block discarded – undo
1152 1152
 				$index++;
1153 1153
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1154 1154
 
1155
-				$tvacompl='';
1156
-				if (preg_match('/\*/',$tvakey))
1155
+				$tvacompl = '';
1156
+				if (preg_match('/\*/', $tvakey))
1157 1157
 				{
1158
-					$tvakey=str_replace('*','',$tvakey);
1158
+					$tvakey = str_replace('*', '', $tvakey);
1159 1159
 					$tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")";
1160 1160
 				}
1161
-				$totalvat =$outputlangs->transnoentities("TotalVAT").' ';
1162
-				$totalvat.=vatrate($tvakey,1).$tvacompl;
1163
-				$pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1161
+				$totalvat = $outputlangs->transnoentities("TotalVAT").' ';
1162
+				$totalvat .= vatrate($tvakey, 1).$tvacompl;
1163
+				$pdf->MultiCell($col2x - $col1x, $tab2_hl, $totalvat, 0, 'L', 1);
1164 1164
 
1165 1165
 				$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1166 1166
 				$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval, 0, $outputlangs), 0, 'R', 1);
@@ -1170,16 +1170,16 @@  discard block
 block discarded – undo
1170 1170
 		// Total TTC
1171 1171
 		$index++;
1172 1172
 		$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
1173
-		$pdf->SetTextColor(0,0,60);
1174
-		$pdf->SetFillColor(224,224,224);
1175
-		$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1173
+		$pdf->SetTextColor(0, 0, 60);
1174
+		$pdf->SetFillColor(224, 224, 224);
1175
+		$pdf->MultiCell($col2x - $col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1);
1176 1176
 
1177 1177
 		// $total_ttc = ($conf->multicurrency->enabled && $object->multiccurency_tx != 1) ? $TTot['multicurrency_total_ttc'] : $TTot['total_ttc'];
1178 1178
 		$total_ttc = $TTot['total_ttc'];
1179 1179
 		$pdf->SetXY($col2x, $tab2_top + $tab2_hl * $index);
1180 1180
 		$pdf->MultiCell($largcol2, $tab2_hl, price($total_ttc, 0, $outputlangs), $useborder, 'R', 1);
1181 1181
 
1182
-		$pdf->SetTextColor(0,0,0);
1182
+		$pdf->SetTextColor(0, 0, 0);
1183 1183
 				
1184 1184
 		$index++;
1185 1185
 		return ($tab2_top + ($tab2_hl * $index));
@@ -1198,22 +1198,22 @@  discard block
 block discarded – undo
1198 1198
 	 * @param	int		$hidebottom		Hide bottom
1199 1199
 	 * @return	void
1200 1200
 	 */
1201
-    private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1201
+    private static function printRect($pdf, $x, $y, $l, $h, $hidetop = 0, $hidebottom = 0)
1202 1202
     {
1203
-	    if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1204
-	    $pdf->line($x+$l, $y, $x+$l, $y+$h);
1205
-	    if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1206
-	    $pdf->line($x, $y+$h, $x, $y);
1203
+	    if (empty($hidetop) || $hidetop == -1) $pdf->line($x, $y, $x + $l, $y);
1204
+	    $pdf->line($x + $l, $y, $x + $l, $y + $h);
1205
+	    if (empty($hidebottom)) $pdf->line($x + $l, $y + $h, $x, $y + $h);
1206
+	    $pdf->line($x, $y + $h, $x, $y);
1207 1207
     }
1208 1208
 	
1209 1209
 	
1210
-	public static function concat(&$outputlangs, $files, $fileoutput='')
1210
+	public static function concat(&$outputlangs, $files, $fileoutput = '')
1211 1211
 	{
1212 1212
 		global $conf;
1213 1213
 		
1214 1214
 		if (empty($fileoutput)) $fileoutput = $file[0];
1215 1215
 		
1216
-		$pdf=pdf_getInstance();
1216
+		$pdf = pdf_getInstance();
1217 1217
         if (class_exists('TCPDF'))
1218 1218
         {
1219 1219
             $pdf->setPrintHeader(false);
@@ -1221,10 +1221,10 @@  discard block
 block discarded – undo
1221 1221
         }
1222 1222
         $pdf->SetFont(pdf_getPDFFont($outputlangs));
1223 1223
 
1224
-        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1224
+        if (!empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1225 1225
 
1226 1226
 		
1227
-		foreach($files as $file)
1227
+		foreach ($files as $file)
1228 1228
 		{
1229 1229
 			$pagecount = $pdf->setSourceFile($file);
1230 1230
 			for ($i = 1; $i <= $pagecount; $i++)
@@ -1236,8 +1236,8 @@  discard block
 block discarded – undo
1236 1236
 			}
1237 1237
 		}
1238 1238
 		
1239
-		$pdf->Output($fileoutput,'F');
1240
-		if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK));
1239
+		$pdf->Output($fileoutput, 'F');
1240
+		if (!empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK));
1241 1241
 
1242 1242
 		return $pagecount;
1243 1243
 	}
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
 	 */
1251 1251
 	public static function hasNcTitle(&$line)
1252 1252
 	{
1253
-		if(isset($line->has_nc_title)) return $line->has_nc_title;
1253
+		if (isset($line->has_nc_title)) return $line->has_nc_title;
1254 1254
 
1255 1255
 		$TTitle = self::getAllTitleFromLine($line);
1256 1256
 		foreach ($TTitle as &$line_title)
Please login to merge, or discard this patch.
Braces   +285 added lines, -138 removed lines patch added patch discarded remove patch
@@ -13,18 +13,23 @@  discard block
 block discarded – undo
13 13
 			/**
14 14
 			 * @var $object Facture
15 15
 			 */
16
-			if($object->element=='facture') $res =  $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number);
16
+			if($object->element=='facture') {
17
+				$res =  $object->addline($object->id, $label, 0,$qty,0,0,0,0,0,'','',0,0,'','HT',0,9,-1, TSubtotal::$module_number);
18
+			}
17 19
 			/**
18 20
 			 * @var $object Propal
19 21
 			 */
20
-			else if($object->element=='propal') $res =  $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number);
22
+			else if($object->element=='propal') {
23
+				$res =  $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,'HT',0,0,9,-1, TSubtotal::$module_number);
24
+			}
21 25
 			/**
22 26
 			 * @var $object Commande
23 27
 			 */
24
-			else if($object->element=='commande') $res =  $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number);
28
+			else if($object->element=='commande') {
29
+				$res =  $object->addline($object->id,$label, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,-1, TSubtotal::$module_number);
30
+			}
25 31
 
26
-		}
27
-		else {
32
+		} else {
28 33
 			$desc = '';
29 34
 			
30 35
 			$TNotElements = array ('invoice_supplier', 'order_supplier');
@@ -36,7 +41,9 @@  discard block
 block discarded – undo
36 41
 			/**
37 42
 			 * @var $object Facture
38 43
 			 */
39
-			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);
44
+			if($object->element=='facture') {
45
+				$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);
46
+			}
40 47
 			/**
41 48
 			 * @var $object Facture fournisseur
42 49
 			 */
@@ -48,16 +55,22 @@  discard block
 block discarded – undo
48 55
 			/**
49 56
 			 * @var $object Propal
50 57
 			 */
51
-			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);
58
+			else if($object->element=='propal') {
59
+				$res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
60
+			}
52 61
 			/**
53 62
 			 * @var $object Propal Fournisseur
54 63
 			 */
55
-			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);
64
+			else if($object->element=='supplier_proposal') {
65
+				$res = $object->addline($desc, 0,$qty,0,0,0,0,0,'HT',0,0,9,$rang, TSubtotal::$module_number, 0, 0, 0, $label);
66
+			}
56 67
 			
57 68
 			/**
58 69
 			 * @var $object Commande
59 70
 			 */
60
-			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);
71
+			else if($object->element=='commande') {
72
+				$res =  $object->addline($desc, 0,$qty,0,0,0,0,0,0,0,'HT',0,'','',9,$rang, TSubtotal::$module_number, 0, null, 0, $label);
73
+			}
61 74
 			/**
62 75
 			 * @var $object Commande fournisseur
63 76
 			 */
@@ -68,7 +81,9 @@  discard block
 block discarded – undo
68 81
 			/**
69 82
 			 * @var $object Facturerec
70 83
 			 */
71
-			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); 
84
+			else if($object->element=='facturerec') {
85
+				$res =  $object->addline($desc, 0,$qty, 0, 0, 0, 0, 0, 'HT', 0, '', 0, 9, $rang, TSubtotal::$module_number,$label);
86
+			}
72 87
 			
73 88
 		}
74 89
 	
@@ -90,8 +105,9 @@  discard block
 block discarded – undo
90 105
 			// Define output language
91 106
 			$outputlangs = $langs;
92 107
 			$newlang = GETPOST('lang_id', 'alpha');
93
-			if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang))
94
-				$newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang;
108
+			if (! empty($conf->global->MAIN_MULTILANGS) && empty($newlang)) {
109
+							$newlang = !empty($object->client) ? $object->client->default_lang : $object->thirdparty->default_lang;
110
+			}
95 111
 			if (! empty($newlang)) {
96 112
 				$outputlangs = new Translate("", $conf);
97 113
 				$outputlangs->setDefaultLang($newlang);
@@ -100,13 +116,18 @@  discard block
 block discarded – undo
100 116
 			$ret = $object->fetch($object->id); // Reload to get new records
101 117
 			if ((float) DOL_VERSION <= 3.6)
102 118
 			{
103
-				if ($object->element == 'propal') propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
104
-				elseif ($object->element == 'commande') commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
105
-				elseif ($object->element == 'facture') facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
106
-			}
107
-			else
119
+				if ($object->element == 'propal') {
120
+					propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
121
+				} elseif ($object->element == 'commande') {
122
+					commande_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
123
+				} elseif ($object->element == 'facture') {
124
+					facture_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
125
+				}
126
+			} else
108 127
 			{
109
-				if ($object->element!= 'facturerec') $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
128
+				if ($object->element!= 'facturerec') {
129
+					$object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
130
+				}
110 131
 			}
111 132
 		}
112 133
 	}
@@ -120,7 +141,9 @@  discard block
 block discarded – undo
120 141
 	 */
121 142
 	public static function updateRang(&$object, $rang_start, $move_to=1)
122 143
 	{
123
-		if (!class_exists('GenericObject')) require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
144
+		if (!class_exists('GenericObject')) {
145
+			require_once DOL_DOCUMENT_ROOT.'/core/class/genericobject.class.php';
146
+		}
124 147
 		
125 148
 		$row=new GenericObject($object->db);
126 149
 		$row->table_element_line = $object->table_element_line;
@@ -129,7 +152,9 @@  discard block
 block discarded – undo
129 152
 		
130 153
 		foreach ($object->lines as &$line)
131 154
 		{
132
-			if ($line->rang < $rang_start) continue;
155
+			if ($line->rang < $rang_start) {
156
+				continue;
157
+			}
133 158
 			
134 159
 			$row->updateRangOfLine($line->id, $line->rang+$move_to);
135 160
 		}
@@ -152,21 +177,28 @@  discard block
 block discarded – undo
152 177
 		foreach ($TTitle_reverse as $k => $title_line)
153 178
 		{
154 179
 			$title_niveau = self::getNiveau($title_line);
155
-			if ($title_niveau < $level_new_title) break;
180
+			if ($title_niveau < $level_new_title) {
181
+				break;
182
+			}
156 183
 			
157 184
 			$rang_to_add = self::titleHasTotalLine($object, $title_line, true, true);
158 185
 			
159 186
 			if (is_numeric($rang_to_add)) 
160 187
 			{
161
-				if ($rang_to_add != -1) self::updateRang($object, $rang_to_add);
188
+				if ($rang_to_add != -1) {
189
+					self::updateRang($object, $rang_to_add);
190
+				}
162 191
 				
163 192
 				self::addSubTotalLine($object, $langs->trans('SubTotal'), 100-$title_niveau, $rang_to_add);
164 193
 				
165 194
 				$object->lines[] = $object->line; // ajout de la ligne dans le tableau de ligne (Dolibarr ne le fait pas)
166 195
 				if ($rang_to_add != -1) 
167 196
 				{
168
-					if (method_exists($object, 'fetch_lines')) $object->fetch_lines();
169
-					else $object->fetch($object->id);
197
+					if (method_exists($object, 'fetch_lines')) {
198
+						$object->fetch_lines();
199
+					} else {
200
+						$object->fetch($object->id);
201
+					}
170 202
 				}
171 203
 			}
172 204
 		}
@@ -196,7 +228,9 @@  discard block
 block discarded – undo
196 228
 		
197 229
 		foreach ($TTitle as $k => $title_line)
198 230
 		{
199
-			if (self::titleHasTotalLine($object, $title_line)) unset($TTitle[$k]);
231
+			if (self::titleHasTotalLine($object, $title_line)) {
232
+				unset($TTitle[$k]);
233
+			}
200 234
 		}
201 235
 		
202 236
 		return $TTitle;
@@ -213,23 +247,41 @@  discard block
 block discarded – undo
213 247
 	 */
214 248
 	public static function titleHasTotalLine(&$object, &$title_line, $strict_mode=false, $return_rang_on_false=false)
215 249
 	{
216
-		if (empty($object->lines) || !is_array($object->lines)) return false;
250
+		if (empty($object->lines) || !is_array($object->lines)) {
251
+			return false;
252
+		}
217 253
 		
218 254
 		$title_niveau = self::getNiveau($title_line);
219 255
 		foreach ($object->lines as &$line)
220 256
 		{
221
-			if ($line->rang <= $title_line->rang) continue;
222
-			if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) return false; // Oups on croise un titre d'un niveau inférieur ou égale (exemple : je croise un titre niveau 2 alors que je suis sur un titre de niveau 3) pas lieu de continuer car un nouveau bloc commence
223
-			if (!self::isSubtotal($line)) continue;
257
+			if ($line->rang <= $title_line->rang) {
258
+				continue;
259
+			}
260
+			if (self::isTitle($line) && self::getNiveau($line) <= $title_niveau) {
261
+				return false;
262
+			}
263
+			// Oups on croise un titre d'un niveau inférieur ou égale (exemple : je croise un titre niveau 2 alors que je suis sur un titre de niveau 3) pas lieu de continuer car un nouveau bloc commence
264
+			if (!self::isSubtotal($line)) {
265
+				continue;
266
+			}
224 267
 			
225 268
 			$subtotal_niveau = self::getNiveau($line);
226 269
 			
227 270
 			// Comparaison du niveau de la ligne de sous-total avec celui du titre
228
-			if ($subtotal_niveau == $title_niveau) return true; // niveau égale => Ok mon titre a un sous-total
229
-			elseif ($subtotal_niveau < $title_niveau) // niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3)
271
+			if ($subtotal_niveau == $title_niveau) {
272
+				return true;
273
+			}
274
+			// niveau égale => Ok mon titre a un sous-total
275
+			elseif ($subtotal_niveau < $title_niveau) {
276
+				// niveau inférieur trouvé (exemple : sous-total de niveau 1 contre mon titre de niveau 3)
230 277
 			{
231
-				if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false; // mode strict niveau pas égale donc faux
232
-				else return true; // mode libre => OK je considère que mon titre à un sous-total
278
+				if ($strict_mode) return ($return_rang_on_false) ? $line->rang : false;
279
+			}
280
+			// mode strict niveau pas égale donc faux
281
+				else {
282
+					return true;
283
+				}
284
+				// mode libre => OK je considère que mon titre à un sous-total
233 285
 			}
234 286
 		}
235 287
 		
@@ -277,16 +329,19 @@  discard block
 block discarded – undo
277 329
 		
278 330
 		foreach ($object->lines as &$l)
279 331
 		{
280
-			if ($l->rang <= $line->rang) continue;
281
-			elseif (self::isSubtotal($l) && self::getNiveau($l) <= self::getNiveau($line)) break;
282
-			elseif ($breakOnTitle && self::isTitle($l) && self::getNiveau($l) <= self::getNiveau($line)) break;
332
+			if ($l->rang <= $line->rang) {
333
+				continue;
334
+			} elseif (self::isSubtotal($l) && self::getNiveau($l) <= self::getNiveau($line)) {
335
+				break;
336
+			} elseif ($breakOnTitle && self::isTitle($l) && self::getNiveau($l) <= self::getNiveau($line)) {
337
+				break;
338
+			}
283 339
 			
284 340
 			if (!empty($l->array_options['options_subtotal_nc']))
285 341
 			{
286 342
 				$tabprice = calcul_price_total($l->qty, $l->subprice, $l->remise_percent, $l->tva_tx, $l->localtax1_tx, $l->localtax2_tx, 0, 'HT', $l->info_bits, $l->product_type);
287 343
 				$TTot['total_options'] += $tabprice[0]; // total ht
288
-			}
289
-			else
344
+			} else
290 345
 			{
291 346
 				$TTot['total_pa_ht'] += $l->pa_ht * $l->qty;
292 347
 				$TTot['total_subprice'] += $l->subprice * $l->qty;
@@ -306,29 +361,41 @@  discard block
 block discarded – undo
306 361
 
307 362
 	public static function getOrderIdFromLineId(&$db, $fk_commandedet)
308 363
 	{
309
-		if (empty($fk_commandedet)) return false;
364
+		if (empty($fk_commandedet)) {
365
+			return false;
366
+		}
310 367
 		
311 368
 		$sql = 'SELECT fk_commande FROM '.MAIN_DB_PREFIX.'commandedet WHERE rowid = '.$fk_commandedet;
312 369
 		$resql = $db->query($sql);
313 370
 		
314
-		if ($resql && ($row = $db->fetch_object($resql))) return $row->fk_commande;
315
-		else return false;
371
+		if ($resql && ($row = $db->fetch_object($resql))) {
372
+			return $row->fk_commande;
373
+		} else {
374
+			return false;
375
+		}
316 376
 	}
317 377
 	
318 378
 	public static function getLastLineOrderId(&$db, $fk_commande)
319 379
 	{
320
-		if (empty($fk_commande)) return false;
380
+		if (empty($fk_commande)) {
381
+			return false;
382
+		}
321 383
 		
322 384
 		$sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.'commandedet WHERE fk_commande = '.$fk_commande.' ORDER BY rang DESC LIMIT 1';
323 385
 		$resql = $db->query($sql);
324 386
 		
325
-		if ($resql && ($row = $db->fetch_object($resql))) return $row->rowid;
326
-		else return false;
387
+		if ($resql && ($row = $db->fetch_object($resql))) {
388
+			return $row->rowid;
389
+		} else {
390
+			return false;
391
+		}
327 392
 	}
328 393
 	
329 394
 	public static function getParentTitleOfLine(&$object, $i)
330 395
 	{
331
-		if ($i <= 0) return false;
396
+		if ($i <= 0) {
397
+			return false;
398
+		}
332 399
 		
333 400
 		$skip_title = 0;
334 401
 		// Je parcours les lignes précédentes
@@ -347,8 +414,7 @@  discard block
 block discarded – undo
347 414
 				//@INFO J'ai ma ligne titre qui contient ma ligne, par contre je check pas s'il y a un sous-total
348 415
 				return $line;
349 416
 				break;
350
-			}
351
-			elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99)
417
+			} elseif ($line->product_type == 9 && $line->qty >= 90 && $line->qty <= 99)
352 418
 			{
353 419
 				// Il s'agit d'un sous-total, ça veut dire que le prochain titre théoriquement doit être ignorer (je travail avec un incrément au cas ou je croise plusieurs sous-totaux)
354 420
 				$skip_title++;
@@ -363,7 +429,9 @@  discard block
 block discarded – undo
363 429
 		$res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty <= 9;
364 430
 		if($res && $level > -1) {
365 431
 			return $line->qty == $level;
366
-		} else return $res;
432
+		} else {
433
+			return $res;
434
+		}
367 435
 		
368 436
 	}
369 437
 	
@@ -372,7 +440,9 @@  discard block
 block discarded – undo
372 440
 	    $res = $line->special_code == self::$module_number && $line->product_type == 9 && $line->qty >= 90;
373 441
 	    if($res && $level > -1) {
374 442
 	        return self::getNiveau($line) == $level;
375
-	    } else return $res;
443
+	    } else {
444
+	    	return $res;
445
+	    }
376 446
 	}
377 447
 	
378 448
 	public static function isFreeText(&$line)
@@ -393,10 +463,14 @@  discard block
 block discarded – undo
393 463
 		// editeur wysiwyg
394 464
 		require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
395 465
 		$nbrows=ROWS_2;
396
-		if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) $nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
466
+		if (! empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
467
+			$nbrows=$conf->global->MAIN_INPUT_DESC_HEIGHT;
468
+		}
397 469
 		$enable=(isset($conf->global->FCKEDITOR_ENABLE_DETAILS)?$conf->global->FCKEDITOR_ENABLE_DETAILS:0);
398 470
 		$toolbarname='dolibarr_details';
399
-		if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) $toolbarname='dolibarr_notes';
471
+		if (! empty($conf->global->FCKEDITOR_ENABLE_DETAILS_FULL)) {
472
+			$toolbarname='dolibarr_notes';
473
+		}
400 474
 		$text = !empty($line->description)?$line->description:$line->label;
401 475
 		$doleditor=new DolEditor('line-description',$text,'',164,$toolbarname,'',false,true,$enable,$nbrows,'98%', $readonly);
402 476
 		return $doleditor->Create(1);
@@ -411,12 +485,10 @@  discard block
 block discarded – undo
411 485
 		{
412 486
 		    $object->statut = 0; // hack for facture rec
413 487
 		    $createRight = $user->rights->facture->creer;
414
-		}
415
-		elseif($object->element == 'order_supplier' )
488
+		} elseif($object->element == 'order_supplier' )
416 489
 		{
417 490
 		    $createRight = $user->rights->fournisseur->commande->creer;
418
-		}
419
-		elseif($object->element == 'invoice_supplier' )
491
+		} elseif($object->element == 'invoice_supplier' )
420 492
 		{
421 493
 		    $createRight = $user->rights->fournisseur->facture->creer;
422 494
 		}
@@ -427,11 +499,16 @@  discard block
 block discarded – undo
427 499
 
428 500
             if(!empty($object->lines)) {
429 501
                 foreach($object->lines as $line) {
430
-                    if($line->id == $lineid) $duplicateLine = $line;
502
+                    if($line->id == $lineid) {
503
+                    	$duplicateLine = $line;
504
+                    }
431 505
                 }
432 506
             }
433
-            if(!empty($duplicateLine) && !self::isModSubtotalLine($duplicateLine)) $TLine = array($duplicateLine);
434
-            else $TLine = self::getLinesFromTitleId($object, $lineid, $withBlockLine);
507
+            if(!empty($duplicateLine) && !self::isModSubtotalLine($duplicateLine)) {
508
+            	$TLine = array($duplicateLine);
509
+            } else {
510
+            	$TLine = self::getLinesFromTitleId($object, $lineid, $withBlockLine);
511
+            }
435 512
 
436 513
 			if (!empty($TLine))
437 514
 			{
@@ -495,8 +572,9 @@  discard block
 block discarded – undo
495 572
 
496 573
 					$TLineAdded[] = $object->line;
497 574
 					// Error from addline
498
-					if ($res <= 0) break;
499
-					else
575
+					if ($res <= 0) {
576
+						break;
577
+					} else
500 578
 					{
501 579
 						$object->line_from = $line;
502 580
 						// Call trigger
@@ -518,8 +596,7 @@  discard block
 block discarded – undo
518 596
 					    _updateLineNC($object->element, $object->id, $line->id, $line->array_options['options_subtotal_nc']);
519 597
 					}
520 598
 					return count($TLineAdded);
521
-				}
522
-				else
599
+				} else
523 600
 				{
524 601
 					$object->db->rollback();
525 602
 					return -1;
@@ -535,10 +612,14 @@  discard block
 block discarded – undo
535 612
 		global $langs;
536 613
 		
537 614
 		// Besoin de comparer sur les 2 formes d'écriture
538
-		if (!$key_is_id) $TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad));
615
+		if (!$key_is_id) {
616
+			$TTitle_search = array($langs->trans($key_trad), $langs->transnoentitiesnoconv($key_trad));
617
+		}
539 618
 		
540 619
 		$TTitle_under_search = array();
541
-		if (!empty($under_title)) $TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title));
620
+		if (!empty($under_title)) {
621
+			$TTitle_under_search = array($langs->trans($under_title), $langs->transnoentitiesnoconv($under_title));
622
+		}
542 623
 		
543 624
 		$TLine = array();
544 625
 		$add_line = false;
@@ -548,28 +629,37 @@  discard block
 block discarded – undo
548 629
 		{
549 630
 			if (!$under_title_found && !empty($TTitle_under_search))
550 631
 			{
551
-				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) $under_title_found = true;
552
-			}
553
-			else
632
+				if ($line->product_type == 9 && (in_array($line->desc, $TTitle_under_search) || in_array($line->label, $TTitle_under_search)) ) {
633
+					$under_title_found = true;
634
+				}
635
+			} else
554 636
 			{
555 637
 				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) )))
556 638
 				{
557
-					if ($key_is_id) $level = $line->qty;
639
+					if ($key_is_id) {
640
+						$level = $line->qty;
641
+					}
558 642
 					
559 643
 					$add_line = true;
560
-					if ($withBlockLine) $TLine[] = $line;
644
+					if ($withBlockLine) {
645
+						$TLine[] = $line;
646
+					}
561 647
 					continue;
562
-				}
563
-				elseif ($add_line && TSubtotal::isModSubtotalLine($line) && TSubtotal::getNiveau($line) == $level) // Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre
648
+				} elseif ($add_line && TSubtotal::isModSubtotalLine($line) && TSubtotal::getNiveau($line) == $level) {
649
+					// Si on tombe sur un sous-total, il faut que ce soit un du même niveau que le titre
564 650
 				{
565 651
 					if ($withBlockLine) $TLine[] = $line;
652
+				}
566 653
 					break;
567 654
 				}
568 655
 				
569 656
 				if ($add_line)
570 657
 				{
571
-					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) continue;
572
-					else $TLine[] = $line;
658
+					if (!$withBlockLine && (self::isTitle($line) || self::isSubtotal($line)) ) {
659
+						continue;
660
+					} else {
661
+						$TLine[] = $line;
662
+					}
573 663
 				}
574 664
 			}
575 665
 		}
@@ -603,7 +693,9 @@  discard block
 block discarded – undo
603 693
 				
604 694
 			case 'order_supplier':
605 695
 			    $object->special_code = SELF::$module_number;
606
-			    if (empty($desc)) $desc = $label;
696
+			    if (empty($desc)) {
697
+			    	$desc = $label;
698
+			    }
607 699
 			    $res = $object->updateline($rowid, $desc, $pu, $qty, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, 0, $date_start, $date_end, $array_options, $fk_unit);
608 700
 			    break;
609 701
 			
@@ -613,7 +705,9 @@  discard block
 block discarded – undo
613 705
 				
614 706
 			case 'invoice_supplier':
615 707
 			    $object->special_code = SELF::$module_number;
616
-			    if (empty($desc)) $desc = $label;
708
+			    if (empty($desc)) {
709
+			    	$desc = $label;
710
+			    }
617 711
 			    $res = $object->updateline($rowid, $desc, $pu, $txtva, $txlocaltax1, $txlocaltax2, $qty, 0, $price_base_type, $info_bits, $type, $remise_percent, 0, $date_start, $date_end, $array_options, $fk_unit);
618 712
 			    break;
619 713
 				
@@ -630,8 +724,11 @@  discard block
 block discarded – undo
630 724
 				break;
631 725
 		}
632 726
 		
633
-		if ($res <= 0) $object->db->rollback();
634
-		else $object->db->commit();
727
+		if ($res <= 0) {
728
+			$object->db->rollback();
729
+		} else {
730
+			$object->db->commit();
731
+		}
635 732
 		
636 733
 		return $res;
637 734
 	}
@@ -641,24 +738,20 @@  discard block
 block discarded – undo
641 738
 		global $db, $object;
642 739
 		
643 740
 		$TTitle = array();
644
-		if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {}
645
-		else {
741
+		if(! empty($object->id) && in_array($object->element, array('propal', 'commande', 'facture'))) {} else {
646 742
 			if ($origin_line->element == 'propaldet')
647 743
 			{
648 744
 				$object = new Propal($db);
649 745
 				$object->fetch($origin_line->fk_propal);
650
-			}
651
-			else if ($origin_line->element == 'commandedet')
746
+			} else if ($origin_line->element == 'commandedet')
652 747
 			{
653 748
 				$object = new Commande($db);
654 749
 				$object->fetch($origin_line->fk_commande);
655
-			}
656
-			else if ($origin_line->element == 'facturedet')
750
+			} else if ($origin_line->element == 'facturedet')
657 751
 			{
658 752
 				$object = new Facture($db);
659 753
 				$object->fetch($origin_line->fk_facture);
660
-			}
661
-			else
754
+			} else
662 755
 			{
663 756
 				return $TTitle;
664 757
 			}
@@ -668,8 +761,11 @@  discard block
 block discarded – undo
668 761
 		$i = 0;
669 762
 		foreach ($object->lines as &$line)
670 763
 		{
671
-			if ($origin_line->id == $line->id) break;
672
-			else $i++;
764
+			if ($origin_line->id == $line->id) {
765
+				break;
766
+			} else {
767
+				$i++;
768
+			}
673 769
 		}
674 770
 		
675 771
 		$i--; // Skip la ligne d'origine
@@ -684,35 +780,43 @@  discard block
 block discarded – undo
684 780
 				if (self::isSubtotal($object->lines[$y]))
685 781
 				{
686 782
 					$next_title_lvl_to_skip = self::getNiveau($object->lines[$y]);
687
-				}
688
-				elseif (self::isTitle($object->lines[$y]))
783
+				} elseif (self::isTitle($object->lines[$y]))
689 784
 				{
690 785
 					if ($object->lines[$y]->qty == $next_title_lvl_to_skip)
691 786
 					{
692 787
 						$next_title_lvl_to_skip = 0;
693 788
 						continue;
694
-					}
695
-					else
789
+					} else
696 790
 					{
697
-						if (empty($object->lines[$y]->array_options)) $object->lines[$y]->fetch_optionals();
791
+						if (empty($object->lines[$y]->array_options)) {
792
+							$object->lines[$y]->fetch_optionals();
793
+						}
698 794
 						$TTitle[$object->lines[$y]->id] = $object->lines[$y];
699 795
 						
700
-						if ($object->lines[$y]->qty == 1) break;
796
+						if ($object->lines[$y]->qty == 1) {
797
+							break;
798
+						}
701 799
 					}
702 800
 				}
703 801
 			}
704 802
 		}
705 803
 		
706
-		if ($reverse) $TTitle = array_reverse($TTitle, true);
804
+		if ($reverse) {
805
+			$TTitle = array_reverse($TTitle, true);
806
+		}
707 807
 		
708 808
 		return $TTitle;
709 809
 	}
710 810
 	
711 811
 	public static function getNiveau(&$line)
712 812
 	{
713
-		if (self::isTitle($line)) return $line->qty;
714
-		elseif (self::isSubtotal($line)) return 100 - $line->qty;
715
-		else return 0;
813
+		if (self::isTitle($line)) {
814
+			return $line->qty;
815
+		} elseif (self::isSubtotal($line)) {
816
+			return 100 - $line->qty;
817
+		} else {
818
+			return 0;
819
+		}
716 820
 	}
717 821
 	
718 822
 	/**
@@ -737,10 +841,16 @@  discard block
 block discarded – undo
737 841
 		$objmarge->marge_droite = 10;
738 842
 		
739 843
 		$objectref = dol_sanitizeFileName($object->ref);
740
-		if ($object->element == 'propal') $dir = $conf->propal->dir_output . '/' . $objectref;
741
-		elseif ($object->element == 'commande') $dir = $conf->commande->dir_output . '/' . $objectref;
742
-		elseif ($object->element == 'facture') $dir = $conf->facture->dir_output . '/' . $objectref;
743
-		elseif ($object->element == 'facturerec') return; // no PDF for facturerec
844
+		if ($object->element == 'propal') {
845
+			$dir = $conf->propal->dir_output . '/' . $objectref;
846
+		} elseif ($object->element == 'commande') {
847
+			$dir = $conf->commande->dir_output . '/' . $objectref;
848
+		} elseif ($object->element == 'facture') {
849
+			$dir = $conf->facture->dir_output . '/' . $objectref;
850
+		} elseif ($object->element == 'facturerec') {
851
+			return;
852
+		}
853
+		// no PDF for facturerec
744 854
 		else
745 855
 		{
746 856
 			setEventMessage($langs->trans('warning_subtotal_recap_object_element_unknown', $object->element), 'warnings');
@@ -775,7 +885,9 @@  discard block
 block discarded – undo
775 885
 		$pdf->SetCreator("Dolibarr ".DOL_VERSION);
776 886
 		$pdf->SetAuthor($outputlangs->convToOutputCharset($user->getFullName($outputlangs)));
777 887
 		$pdf->SetKeyWords($outputlangs->convToOutputCharset($object->ref)." ".$outputlangs->transnoentities("subtotalRecap")." ".$outputlangs->convToOutputCharset($object->thirdparty->name));
778
-		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
888
+		if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
889
+			$pdf->SetCompression(false);
890
+		}
779 891
 
780 892
 		$pdf->SetMargins($objmarge->marge_gauche, $objmarge->marge_haute, $objmarge->marge_droite);   // Left, Top, Right
781 893
 
@@ -785,7 +897,9 @@  discard block
 block discarded – undo
785 897
 			
786 898
 		// New page
787 899
 		$pdf->AddPage();
788
-		if (! empty($tplidx)) $pdf->useTemplate($tplidx);
900
+		if (! empty($tplidx)) {
901
+			$pdf->useTemplate($tplidx);
902
+		}
789 903
 		$pagenb++;
790 904
 		
791 905
 		
@@ -841,8 +955,10 @@  discard block
 block discarded – undo
841 955
 					{
842 956
 						$TTot['TTotal_tva_multicurrency'][$tx] += $amount;
843 957
 					}	
958
+				} else {
959
+					$pdf->SetFont('','', $default_font_size - 1);
844 960
 				}
845
-				else $pdf->SetFont('','', $default_font_size - 1);   // Into loop to work with multipage
961
+				// Into loop to work with multipage
846 962
 				
847 963
 				$pdf->SetTextColor(0,0,0);
848 964
 				
@@ -864,9 +980,11 @@  discard block
 block discarded – undo
864 980
 				$pdf->startTransaction();
865 981
 				$pdf->writeHTMLCell($posx_options-$posx_designation-$decalage, 3, $posx_designation+$decalage, $curY, $outputlangs->convToOutputCharset($label), 0, 1, false, true, 'J',true);
866 982
 				$pageposafter=$pdf->getPage();
867
-				if ($pageposafter > $pageposbefore)	// There is a pagebreak
983
+				if ($pageposafter > $pageposbefore) {
984
+					// There is a pagebreak
868 985
 				{
869 986
 					$pdf->rollbackTransaction(true);
987
+				}
870 988
 					$pageposafter=$pageposbefore;
871 989
 					//print $pageposafter.'-'.$pageposbefore;exit;
872 990
 					$pdf->setPageOrientation('', 1, $heightforfooter);	// The only function to edit the bottom margin of current page to set it.
@@ -875,23 +993,27 @@  discard block
 block discarded – undo
875 993
 					$pageposafter=$pdf->getPage();
876 994
 					$posyafter=$pdf->GetY();
877 995
 					//var_dump($posyafter); var_dump(($this->page_hauteur - ($heightforfooter+$heightforfreetext+$heightforinfotot))); exit;
878
-					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot)))	// There is no space left for total+free text
996
+					if ($posyafter > ($objmarge->page_hauteur - ($heightforfooter+$heightforinfotot))) {
997
+						// There is no space left for total+free text
879 998
 					{
880 999
 						if ($i == ($nblignes-1))	// No more lines, and no space left to show total, so we create a new page
881 1000
 						{
882 1001
 							$pdf->AddPage('','',true);
883
-							if (! empty($tplidx)) $pdf->useTemplate($tplidx);
884
-							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
1002
+					}
1003
+							if (! empty($tplidx)) {
1004
+								$pdf->useTemplate($tplidx);
1005
+							}
1006
+							if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
1007
+								self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
1008
+							}
885 1009
 							$pdf->setPage($pageposafter+1);
886 1010
 						}
887
-					}
888
-					else
1011
+					} else
889 1012
 					{
890 1013
 						// We found a page break
891 1014
 						$showpricebeforepagebreak=0;
892 1015
 					}
893
-				}
894
-				else	// No pagebreak
1016
+				} else	// No pagebreak
895 1017
 				{
896 1018
 					$pdf->commitTransaction();
897 1019
 				}
@@ -931,8 +1053,7 @@  discard block
 block discarded – undo
931 1053
 					if ($pagenb == 1)
932 1054
 					{
933 1055
 						self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top, $objmarge->page_hauteur - $tab_top - $heightforfooter, 0, $outputlangs, 0, 1, $object->multicurrency_code);
934
-					}
935
-					else
1056
+					} else
936 1057
 					{
937 1058
 						self::tableau($objmarge, $pdf, $posx_designation, $posx_options, $posx_montant, $tab_top_newpage, $objmarge->page_hauteur - $tab_top_newpage - $heightforfooter, 0, $outputlangs, $hidetop, 1, $object->multicurrency_code);
938 1059
 					}
@@ -940,7 +1061,9 @@  discard block
 block discarded – undo
940 1061
 					$pagenb++;
941 1062
 					$pdf->setPage($pagenb);
942 1063
 					$pdf->setPageOrientation('', 1, 0);	// The only function to edit the bottom margin of current page to set it.
943
-					if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
1064
+					if (empty($conf->global->MAIN_PDF_DONOTREPEAT_HEAD)) {
1065
+						self::pagehead($objmarge, $pdf, $object, 0, $outputlangs);
1066
+					}
944 1067
 				}
945 1068
 			}
946 1069
 		}
@@ -950,8 +1073,7 @@  discard block
 block discarded – undo
950 1073
 		{
951 1074
 			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);
952 1075
 			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
953
-		}
954
-		else
1076
+		} else
955 1077
 		{
956 1078
 			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);
957 1079
 			$bottomlasttab=$objmarge->page_hauteur - $heightforinfotot - $heightforfooter + 1;
@@ -965,7 +1087,9 @@  discard block
 block discarded – undo
965 1087
 		
966 1088
 		$pagecount = self::concat($outputlangs, array($origin_file, $file), $origin_file);
967 1089
 		
968
-		if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) unlink($file);
1090
+		if (empty($conf->global->SUBTOTAL_KEEP_RECAP_FILE)) {
1091
+			unlink($file);
1092
+		}
969 1093
 	}
970 1094
 	
971 1095
 	private static function printLevel($objmarge, $pdf, $line, $curY, $posx_designation)
@@ -1008,8 +1132,7 @@  discard block
 block discarded – undo
1008 1132
 			{
1009 1133
 			    $height=pdf_getHeightForLogo($logo);
1010 1134
 			    $pdf->Image($logo, $objmarge->marge_gauche, $posy, 0, $height);	// width=0 (auto)
1011
-			}
1012
-			else
1135
+			} else
1013 1136
 			{
1014 1137
 				$pdf->SetTextColor(200,0,0);
1015 1138
 				$pdf->SetFont('','B',$default_font_size - 2);
@@ -1018,8 +1141,7 @@  discard block
 block discarded – undo
1018 1141
 			}
1019 1142
 			
1020 1143
 			$posy+=35;
1021
-		}
1022
-		else
1144
+		} else
1023 1145
 		{
1024 1146
 			$text=$mysoc->name;
1025 1147
 			$pdf->MultiCell(100, 4, $outputlangs->convToOutputCharset($text), 0, 'L');
@@ -1033,9 +1155,13 @@  discard block
 block discarded – undo
1033 1155
 		$pdf->SetXY($objmarge->marge_gauche,$posy);
1034 1156
 		
1035 1157
 		$key = 'subtotalPropalTitle';
1036
-		if ($object->element == 'commande') $key = 'subtotalCommandeTitle';
1037
-		elseif ($object->element == 'facture') $key = 'subtotalInvoiceTitle';
1038
-		elseif ($object->element == 'facturerec') $key = 'subtotalInvoiceTitle';
1158
+		if ($object->element == 'commande') {
1159
+			$key = 'subtotalCommandeTitle';
1160
+		} elseif ($object->element == 'facture') {
1161
+			$key = 'subtotalInvoiceTitle';
1162
+		} elseif ($object->element == 'facturerec') {
1163
+			$key = 'subtotalInvoiceTitle';
1164
+		}
1039 1165
 		
1040 1166
 		$pdf->MultiCell(150, 4, $outputlangs->transnoentities($key, $object->ref, $object->thirdparty->name), '', 'L');
1041 1167
 		
@@ -1070,7 +1196,9 @@  discard block
 block discarded – undo
1070 1196
 		
1071 1197
 		// Force to disable hidetop and hidebottom
1072 1198
 		$hidebottom=0;
1073
-		if ($hidetop) $hidetop=-1;
1199
+		if ($hidetop) {
1200
+			$hidetop=-1;
1201
+		}
1074 1202
 
1075 1203
 		$currency = !empty($currency) ? $currency : $conf->currency;
1076 1204
 		$default_font_size = pdf_getPDFFontSize($outputlangs);
@@ -1085,7 +1213,9 @@  discard block
 block discarded – undo
1085 1213
 			$pdf->SetXY($objmarge->page_largeur - $objmarge->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top-4.5);
1086 1214
 			$pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
1087 1215
 			
1088
-			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));
1216
+			if (! empty($conf->global->MAIN_PDF_TITLE_BACKGROUND_COLOR)) {
1217
+				$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));
1218
+			}
1089 1219
 			
1090 1220
 			
1091 1221
 			$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
@@ -1098,8 +1228,7 @@  discard block
 block discarded – undo
1098 1228
 			$pdf->MultiCell($objmarge->page_largeur - $objmarge->marge_droite - $posx_montant,2, $outputlangs->transnoentities("Amount"),'','R');
1099 1229
 			
1100 1230
 			$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
1101
-		}
1102
-		else
1231
+		} else
1103 1232
 		{
1104 1233
 			$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
1105 1234
 		}
@@ -1120,10 +1249,12 @@  discard block
 block discarded – undo
1120 1249
 
1121 1250
 		// Tableau total
1122 1251
 		$col1x = 120; $col2x = 170;
1123
-		if ($objmarge->page_largeur < 210) // To work with US executive format
1252
+		if ($objmarge->page_largeur < 210) {
1253
+			// To work with US executive format
1124 1254
 		{
1125 1255
 			$col2x-=20;
1126 1256
 		}
1257
+		}
1127 1258
 		$largcol2 = ($objmarge->page_largeur - $objmarge->marge_droite - $col2x);
1128 1259
 
1129 1260
 		$useborder=0;
@@ -1145,9 +1276,11 @@  discard block
 block discarded – undo
1145 1276
 		$atleastoneratenotnull=0;
1146 1277
 		foreach($TTot['TTotal_tva'] as $tvakey => $tvaval)
1147 1278
 		{
1148
-			if ($tvakey != 0)    // On affiche pas taux 0
1279
+			if ($tvakey != 0) {
1280
+				// On affiche pas taux 0
1149 1281
 			{
1150 1282
 				$atleastoneratenotnull++;
1283
+			}
1151 1284
 
1152 1285
 				$index++;
1153 1286
 				$pdf->SetXY($col1x, $tab2_top + $tab2_hl * $index);
@@ -1200,9 +1333,13 @@  discard block
 block discarded – undo
1200 1333
 	 */
1201 1334
     private static function printRect($pdf, $x, $y, $l, $h, $hidetop=0, $hidebottom=0)
1202 1335
     {
1203
-	    if (empty($hidetop) || $hidetop==-1) $pdf->line($x, $y, $x+$l, $y);
1336
+	    if (empty($hidetop) || $hidetop==-1) {
1337
+	    	$pdf->line($x, $y, $x+$l, $y);
1338
+	    }
1204 1339
 	    $pdf->line($x+$l, $y, $x+$l, $y+$h);
1205
-	    if (empty($hidebottom)) $pdf->line($x+$l, $y+$h, $x, $y+$h);
1340
+	    if (empty($hidebottom)) {
1341
+	    	$pdf->line($x+$l, $y+$h, $x, $y+$h);
1342
+	    }
1206 1343
 	    $pdf->line($x, $y+$h, $x, $y);
1207 1344
     }
1208 1345
 	
@@ -1211,7 +1348,9 @@  discard block
 block discarded – undo
1211 1348
 	{
1212 1349
 		global $conf;
1213 1350
 		
1214
-		if (empty($fileoutput)) $fileoutput = $file[0];
1351
+		if (empty($fileoutput)) {
1352
+			$fileoutput = $file[0];
1353
+		}
1215 1354
 		
1216 1355
 		$pdf=pdf_getInstance();
1217 1356
         if (class_exists('TCPDF'))
@@ -1221,7 +1360,9 @@  discard block
 block discarded – undo
1221 1360
         }
1222 1361
         $pdf->SetFont(pdf_getPDFFont($outputlangs));
1223 1362
 
1224
-        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) $pdf->SetCompression(false);
1363
+        if (! empty($conf->global->MAIN_DISABLE_PDF_COMPRESSION)) {
1364
+        	$pdf->SetCompression(false);
1365
+        }
1225 1366
 
1226 1367
 		
1227 1368
 		foreach($files as $file)
@@ -1237,7 +1378,9 @@  discard block
 block discarded – undo
1237 1378
 		}
1238 1379
 		
1239 1380
 		$pdf->Output($fileoutput,'F');
1240
-		if (! empty($conf->global->MAIN_UMASK)) @chmod($file, octdec($conf->global->MAIN_UMASK));
1381
+		if (! empty($conf->global->MAIN_UMASK)) {
1382
+			@chmod($file, octdec($conf->global->MAIN_UMASK));
1383
+		}
1241 1384
 
1242 1385
 		return $pagecount;
1243 1386
 	}
@@ -1250,7 +1393,9 @@  discard block
 block discarded – undo
1250 1393
 	 */
1251 1394
 	public static function hasNcTitle(&$line)
1252 1395
 	{
1253
-		if(isset($line->has_nc_title)) return $line->has_nc_title;
1396
+		if(isset($line->has_nc_title)) {
1397
+			return $line->has_nc_title;
1398
+		}
1254 1399
 
1255 1400
 		$TTitle = self::getAllTitleFromLine($line);
1256 1401
 		foreach ($TTitle as &$line_title)
@@ -1275,7 +1420,9 @@  discard block
 block discarded – undo
1275 1420
 	public static function getTitleLabel($line)
1276 1421
 	{
1277 1422
 		$title = $line->label;
1278
-		if (empty($title)) $title = !empty($line->description) ? $line->description : $line->desc;
1423
+		if (empty($title)) {
1424
+			$title = !empty($line->description) ? $line->description : $line->desc;
1425
+		}
1279 1426
 		return $title;
1280 1427
 	}
1281 1428
 }
Please login to merge, or discard this patch.
admin/subtotal_setup.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 // Dolibarr environment
29 29
 $res = @include("../../main.inc.php"); // From htdocs directory
30 30
 if (! $res) {
31
-    $res = @include("../../../main.inc.php"); // From "custom" directory
31
+	$res = @include("../../../main.inc.php"); // From "custom" directory
32 32
 }
33 33
 
34 34
 // Libraries
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
 // Access control
41 41
 if (! $user->admin) {
42
-    accessforbidden();
42
+	accessforbidden();
43 43
 }
44 44
 
45 45
 // Parameters
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
 // Configuration header
92 92
 $head = subtotalAdminPrepareHead();
93 93
 dol_fiche_head(
94
-    $head,
95
-    'settings',
96
-    $langs->trans("Module104777Name"),
97
-    0,
98
-    "subtotal@subtotal"
94
+	$head,
95
+	'settings',
96
+	$langs->trans("Module104777Name"),
97
+	0,
98
+	"subtotal@subtotal"
99 99
 );
100 100
 
101 101
 showParameters();
@@ -164,13 +164,13 @@  discard block
 block discarded – undo
164 164
 	print ajax_constantonoff('SUBTOTAL_ALLOW_DUPLICATE_BLOCK');
165 165
 	print '</td></tr>';
166 166
 
167
-    $var=!$var;
168
-    print '<tr '.$bc[$var].'>';
169
-    print '<td>'.$langs->trans("SUBTOTAL_ALLOW_DUPLICATE_LINE").'</td>';
170
-    print '<td align="center" width="20">&nbsp;</td>';
171
-    print '<td align="center" width="300">';
172
-    print ajax_constantonoff('SUBTOTAL_ALLOW_DUPLICATE_LINE');
173
-    print '</td></tr>';
167
+	$var=!$var;
168
+	print '<tr '.$bc[$var].'>';
169
+	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_DUPLICATE_LINE").'</td>';
170
+	print '<td align="center" width="20">&nbsp;</td>';
171
+	print '<td align="center" width="300">';
172
+	print ajax_constantonoff('SUBTOTAL_ALLOW_DUPLICATE_LINE');
173
+	print '</td></tr>';
174 174
 	
175 175
 	$var=!$var;
176 176
 	print '<tr '.$bc[$var].'>';
@@ -267,12 +267,12 @@  discard block
 block discarded – undo
267 267
 		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
268 268
 		print '<input type="hidden" name="action" value="set_SUBTOTAL_TFIELD_TO_KEEP_WITH_NC">';
269 269
 		$TField = array(
270
-		    'pdf_getlineqty' => $langs->trans('Qty'), 
271
-		    'pdf_getlinevatrate' => $langs->trans('VAT'), 
272
-		    'pdf_getlineupexcltax' => $langs->trans('PriceUHT'), 
273
-		    'pdf_getlinetotalexcltax' => $langs->trans('TotalHT'), 
274
-		    'pdf_getlineunit' => $langs->trans('Unit'),
275
-		    'pdf_getlineremisepercent' => $langs->trans('Discount')
270
+			'pdf_getlineqty' => $langs->trans('Qty'), 
271
+			'pdf_getlinevatrate' => $langs->trans('VAT'), 
272
+			'pdf_getlineupexcltax' => $langs->trans('PriceUHT'), 
273
+			'pdf_getlinetotalexcltax' => $langs->trans('TotalHT'), 
274
+			'pdf_getlineunit' => $langs->trans('Unit'),
275
+			'pdf_getlineremisepercent' => $langs->trans('Discount')
276 276
 		);
277 277
 		print $html->multiselectarray('SUBTOTAL_TFIELD_TO_KEEP_WITH_NC', $TField, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC), 0, 0, '', 0, 0, 'style="min-width:100px"');
278 278
 		print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
Please login to merge, or discard this patch.
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -27,37 +27,37 @@  discard block
 block discarded – undo
27 27
 // Change this following line to use the correct relative path (../, ../../, etc)
28 28
 // Dolibarr environment
29 29
 $res = @include("../../main.inc.php"); // From htdocs directory
30
-if (! $res) {
30
+if (!$res) {
31 31
     $res = @include("../../../main.inc.php"); // From "custom" directory
32 32
 }
33 33
 
34 34
 // Libraries
35
-require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
35
+require_once DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php";
36 36
 require_once '../lib/subtotal.lib.php';
37 37
 
38 38
 $langs->load("subtotal@subtotal");
39 39
 
40 40
 // Access control
41
-if (! $user->admin) {
41
+if (!$user->admin) {
42 42
     accessforbidden();
43 43
 }
44 44
 
45 45
 // Parameters
46 46
 $action = GETPOST('action', 'alpha');
47 47
 
48
-if($action=='save') {
48
+if ($action == 'save') {
49 49
 	
50
-	foreach($_REQUEST['TDivers'] as $name=>$param) {
50
+	foreach ($_REQUEST['TDivers'] as $name=>$param) {
51 51
 		
52
-		dolibarr_set_const($db, $name, $param,'chaine', 0, '', $conf->entity);
52
+		dolibarr_set_const($db, $name, $param, 'chaine', 0, '', $conf->entity);
53 53
 		
54 54
 	}
55 55
 	
56 56
 }
57 57
 
58
-if (preg_match('/set_(.*)/',$action,$reg))
58
+if (preg_match('/set_(.*)/', $action, $reg))
59 59
 {
60
-	$code=$reg[1];
60
+	$code = $reg[1];
61 61
 	$value = GETPOST($code);
62 62
 	if ($code == 'SUBTOTAL_TFIELD_TO_KEEP_WITH_NC') $value = implode(',', $value);
63 63
 	
@@ -83,10 +83,10 @@  discard block
 block discarded – undo
83 83
 
84 84
 
85 85
 
86
-llxHeader('','Gestion de sous-total, à propos','');
86
+llxHeader('', 'Gestion de sous-total, à propos', '');
87 87
 
88
-$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
89
-print_fiche_titre('Gestion de subtotal',$linkback,'setup');
88
+$linkback = '<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToModuleList").'</a>';
89
+print_fiche_titre('Gestion de subtotal', $linkback, 'setup');
90 90
 
91 91
 // Configuration header
92 92
 $head = subtotalAdminPrepareHead();
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 showParameters();
102 102
 
103 103
 function showParameters() {
104
-	global $db,$conf,$langs,$bc;
104
+	global $db, $conf, $langs, $bc;
105 105
 	
106
-	$html=new Form($db);
106
+	$html = new Form($db);
107 107
 	
108
-	$var=false;
108
+	$var = false;
109 109
 	print '<table class="noborder" width="100%">';
110 110
 	print '<tr class="liste_titre">';
111 111
 	print '<td>'.$langs->trans("Parameters").'</td>'."\n";
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
114 114
 	print '</tr>';
115 115
 	
116
-	$var=!$var;
116
+	$var = !$var;
117 117
 	print '<tr '.$bc[$var].'>';
118 118
 	print '<td>'.$langs->trans("SUBTOTAL_USE_NEW_FORMAT").'</td>';
119 119
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 	print ajax_constantonoff('SUBTOTAL_USE_NEW_FORMAT');
122 122
 	print '</td></tr>';
123 123
 	
124
-	if((float)DOL_VERSION>=3.8)
124
+	if ((float) DOL_VERSION >= 3.8)
125 125
 	{
126
-		$var=!$var;
126
+		$var = !$var;
127 127
 		print '<tr '.$bc[$var].'>';
128 128
 		print '<td>'.$langs->trans("SUBTOTAL_USE_NUMEROTATION").'</td>';
129 129
 		print '<td align="center" width="20">&nbsp;</td>';
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 		print '</td></tr>';	
133 133
 	}
134 134
 	
135
-	$var=!$var;
135
+	$var = !$var;
136 136
 	print '<tr '.$bc[$var].'>';
137 137
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_ADD_BLOCK").'</td>';
138 138
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 	print ajax_constantonoff('SUBTOTAL_ALLOW_ADD_BLOCK');
141 141
 	print '</td></tr>';
142 142
 	
143
-	$var=!$var;
143
+	$var = !$var;
144 144
 	print '<tr '.$bc[$var].'>';
145 145
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_EDIT_BLOCK").'</td>';
146 146
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	print ajax_constantonoff('SUBTOTAL_ALLOW_EDIT_BLOCK');
149 149
 	print '</td></tr>';
150 150
 	
151
-	$var=!$var;
151
+	$var = !$var;
152 152
 	print '<tr '.$bc[$var].'>';
153 153
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_REMOVE_BLOCK").'</td>';
154 154
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 	print ajax_constantonoff('SUBTOTAL_ALLOW_REMOVE_BLOCK');
157 157
 	print '</td></tr>';
158 158
 	
159
-	$var=!$var;
159
+	$var = !$var;
160 160
 	print '<tr '.$bc[$var].'>';
161 161
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_DUPLICATE_BLOCK").'</td>';
162 162
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
 	print ajax_constantonoff('SUBTOTAL_ALLOW_DUPLICATE_BLOCK');
165 165
 	print '</td></tr>';
166 166
 
167
-    $var=!$var;
167
+    $var = !$var;
168 168
     print '<tr '.$bc[$var].'>';
169 169
     print '<td>'.$langs->trans("SUBTOTAL_ALLOW_DUPLICATE_LINE").'</td>';
170 170
     print '<td align="center" width="20">&nbsp;</td>';
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
     print ajax_constantonoff('SUBTOTAL_ALLOW_DUPLICATE_LINE');
173 173
     print '</td></tr>';
174 174
 	
175
-	$var=!$var;
175
+	$var = !$var;
176 176
 	print '<tr '.$bc[$var].'>';
177 177
 	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_ADD_LINE_UNDER_TITLE").'</td>';
178 178
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	print ajax_constantonoff('SUBTOTAL_ALLOW_ADD_LINE_UNDER_TITLE');
181 181
 	print '</td></tr>';
182 182
 	
183
-	$var=!$var;
183
+	$var = !$var;
184 184
 	print '<tr '.$bc[$var].'>';
185 185
 	print '<td>'.$langs->trans("SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK").'</td>';
186 186
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	print ajax_constantonoff('SUBTOTAL_ADD_LINE_UNDER_TITLE_AT_END_BLOCK');
189 189
 	print '</td></tr>';
190 190
 
191
-	$var=!$var;
191
+	$var = !$var;
192 192
 	print '<tr '.$bc[$var].'>';
193 193
 	print '<td>'.$html->textwithpicto($langs->trans("SUBTOTAL_TEXT_FOR_TITLE_ORDETSTOINVOICE"), $langs->trans("SUBTOTAL_TEXT_FOR_TITLE_ORDETSTOINVOICE_info")).'</td>';
194 194
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -201,7 +201,7 @@  discard block
 block discarded – undo
201 201
 	print '</form>';
202 202
 	print '</td></tr>';
203 203
 	
204
-	$var=!$var;
204
+	$var = !$var;
205 205
 	print '<tr '.$bc[$var].'>';
206 206
 	print '<td>'.$langs->trans("SUBTOTAL_TITLE_STYLE").'</td>';
207 207
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -214,7 +214,7 @@  discard block
 block discarded – undo
214 214
 	print '</form>';
215 215
 	print '</td></tr>';
216 216
 	
217
-	$var=!$var;
217
+	$var = !$var;
218 218
 	print '<tr '.$bc[$var].'>';
219 219
 	print '<td>'.$langs->trans("SUBTOTAL_SUBTOTAL_STYLE").'</td>';
220 220
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
 	print '</form>';
228 228
 	print '</td></tr>';
229 229
 	
230
-	$var=!$var;
230
+	$var = !$var;
231 231
 	print '<tr '.$bc[$var].'>';
232 232
 	print '<td>'.$langs->trans("SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES", $langs->transnoentitiesnoconv('HideInnerLines')).'</td>';
233 233
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	print ajax_constantonoff('SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES');
236 236
 	print '</td></tr>';
237 237
 	
238
-	$var=!$var;
238
+	$var = !$var;
239 239
 	print '<tr '.$bc[$var].'>';
240 240
 	print '<td>'.$langs->trans("SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES", $langs->transnoentitiesnoconv('HideInnerLines')).'</td>';
241 241
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 	
246 246
 	if ((double) DOL_VERSION >= 4.0)
247 247
 	{
248
-		$var=!$var;
248
+		$var = !$var;
249 249
 		print '<tr '.$bc[$var].'>';
250 250
 		print '<td>'.$langs->trans("SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS").'</td>';
251 251
 		print '<td align="center" width="20">&nbsp;</td>';
@@ -253,12 +253,12 @@  discard block
 block discarded – undo
253 253
 		print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'">';
254 254
 		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
255 255
 		print '<input type="hidden" name="action" value="set_SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS">';
256
-		print $html->selectyesno("SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS",$conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS,1);
256
+		print $html->selectyesno("SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS", $conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS, 1);
257 257
 		print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
258 258
 		print '</form>';
259 259
 		print '</td></tr>';
260 260
 		
261
-		$var=!$var;
261
+		$var = !$var;
262 262
 		print '<tr '.$bc[$var].'>';
263 263
 		print '<td>'.$langs->trans("SUBTOTAL_TFIELD_TO_KEEP_WITH_NC").'</td>';
264 264
 		print '<td align="center" width="20">&nbsp;</td>';
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 		print '</td></tr>';
281 281
 	}
282 282
 	
283
-	$var=!$var;
283
+	$var = !$var;
284 284
 	print '<tr '.$bc[$var].'>';
285 285
 	print '<td>'.$langs->trans('SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE').'</td>';
286 286
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 	print ajax_constantonoff('SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE');
289 289
 	print '</td></tr>';
290 290
 	
291
-	$var=!$var;
291
+	$var = !$var;
292 292
 	print '<tr '.$bc[$var].'>';
293 293
 	print '<td>'.$langs->trans('SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE').'</td>';
294 294
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 	
301 301
 	
302 302
 	
303
-	$var=false;
303
+	$var = false;
304 304
 	print '<table class="noborder" width="100%">';
305 305
 	print '<tr class="liste_titre">';
306 306
 	print '<td>'.$langs->trans("RecapGeneration").'</td>'."\n";
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	print '<td align="center" width="100">'.$langs->trans("Value").'</td>'."\n";
309 309
 	print '</tr>';
310 310
 	
311
-	$var=!$var;
311
+	$var = !$var;
312 312
 	print '<tr '.$bc[$var].'>';
313 313
 	print '<td>'.$langs->trans('SUBTOTAL_KEEP_RECAP_FILE').'</td>';
314 314
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	print ajax_constantonoff('SUBTOTAL_KEEP_RECAP_FILE');
317 317
 	print '</td></tr>';
318 318
 	
319
-	$var=!$var;
319
+	$var = !$var;
320 320
 	print '<tr '.$bc[$var].'>';
321 321
 	print '<td>'.$langs->trans('SUBTOTAL_PROPAL_ADD_RECAP').'</td>';
322 322
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	print ajax_constantonoff('SUBTOTAL_PROPAL_ADD_RECAP');
325 325
 	print '</td></tr>';
326 326
 	
327
-	$var=!$var;
327
+	$var = !$var;
328 328
 	print '<tr '.$bc[$var].'>';
329 329
 	print '<td>'.$langs->trans('SUBTOTAL_COMMANDE_ADD_RECAP').'</td>';
330 330
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	print '</td></tr>';
334 334
 	
335 335
 	
336
-	$var=!$var;
336
+	$var = !$var;
337 337
 	print '<tr '.$bc[$var].'>';
338 338
 	print '<td>'.$langs->trans('SUBTOTAL_INVOICE_ADD_RECAP').'</td>';
339 339
 	print '<td align="center" width="20">&nbsp;</td>';
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
 				<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
366 366
 					<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken'] ?>">
367 367
 					<input type="hidden" name="action" value="set_SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY" />
368
-					<?php echo $html->selectyesno("SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY",$conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY,1); ?>
368
+					<?php echo $html->selectyesno("SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY", $conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY, 1); ?>
369 369
 					<input type="submit" class="button" value="<?php echo $langs->trans("Modify") ?>">
370 370
 				</form>
371 371
 			</td>
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 				<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
378 378
 					<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken'] ?>">
379 379
 					<input type="hidden" name="action" value="set_SUBTOTAL_HIDE_DOCUMENT_TOTAL" />
380
-					<?php echo $html->selectyesno("SUBTOTAL_HIDE_DOCUMENT_TOTAL",$conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL,1); ?>
380
+					<?php echo $html->selectyesno("SUBTOTAL_HIDE_DOCUMENT_TOTAL", $conf->global->SUBTOTAL_HIDE_DOCUMENT_TOTAL, 1); ?>
381 381
 					<input type="submit" class="button" value="<?php echo $langs->trans("Modify") ?>">
382 382
 				</form>
383 383
 			</td>				
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 					<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
391 391
 						<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken'] ?>">
392 392
 						<input type="hidden" name="action" value="set_SUBTOTAL_SHOW_QTY_ON_TITLES" />
393
-						<?php echo $html->selectyesno("SUBTOTAL_SHOW_QTY_ON_TITLES",$conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES,1); ?>
393
+						<?php echo $html->selectyesno("SUBTOTAL_SHOW_QTY_ON_TITLES", $conf->global->SUBTOTAL_SHOW_QTY_ON_TITLES, 1); ?>
394 394
 						<input type="submit" class="button" value="<?php echo $langs->trans("Modify") ?>">
395 395
 					</form>
396 396
 				</td>				
@@ -402,7 +402,7 @@  discard block
 block discarded – undo
402 402
 					<form method="POST" action="<?php echo $_SERVER['PHP_SELF'] ?>">
403 403
 						<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken'] ?>">
404 404
 						<input type="hidden" name="action" value="set_SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES" />
405
-						<?php echo $html->selectyesno("SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES",$conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES,1); ?>
405
+						<?php echo $html->selectyesno("SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES", $conf->global->SUBTOTAL_ONLY_HIDE_SUBPRODUCTS_PRICES, 1); ?>
406 406
 						<input type="submit" class="button" value="<?php echo $langs->trans("Modify") ?>">
407 407
 					</form>
408 408
 				</td>				
Please login to merge, or discard this patch.