Passed
Push — master ( 9ce9eb...91cbcc )
by
unknown
02:21
created
class/actions_subtotal.class.php 2 patches
Indentation   +196 added lines, -196 removed lines patch added patch discarded remove patch
@@ -47,11 +47,11 @@  discard block
 block discarded – undo
47 47
 	 * @return     void
48 48
 	 */
49 49
     
50
-    var $module_number = 104777;
50
+	var $module_number = 104777;
51 51
     
52
-    function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
53
-    {
54
-      	global $langs,$db,$user, $conf;
52
+	function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
53
+	{
54
+	  	global $langs,$db,$user, $conf;
55 55
 		
56 56
 		$langs->load('subtotal@subtotal');
57 57
 		
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
 				$createRight = $user->rights->facture->creer;
67 67
 			} elseif($object->element == 'order_supplier' )
68 68
 			{
69
-			    $createRight = $user->rights->fournisseur->commande->creer;
69
+				$createRight = $user->rights->fournisseur->commande->creer;
70 70
 			} elseif($object->element == 'invoice_supplier' )
71 71
 			{
72
-			    $createRight = $user->rights->fournisseur->facture->creer;
72
+				$createRight = $user->rights->fournisseur->facture->creer;
73 73
 			}
74 74
 			
75 75
 			if ($object->statut == 0  && $createRight) {
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 					
120 120
 					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
121 121
 					
122
-	    			TSubtotal::addSubTotalLine($object, $title, $qty);
122
+					TSubtotal::addSubTotalLine($object, $title, $qty);
123 123
 				}
124 124
 				else if($action==='ask_deleteallline') {
125 125
 						$form=new Form($db);
@@ -341,35 +341,35 @@  discard block
 block discarded – undo
341 341
 		$TContext = explode(':',$parameters['context']);
342 342
 		if (
343 343
 				in_array('invoicecard',$TContext)
344
-		        || in_array('invoicesuppliercard',$TContext)
344
+				|| in_array('invoicesuppliercard',$TContext)
345 345
 				|| in_array('propalcard',$TContext)
346 346
 				|| in_array('ordercard',$TContext)
347
-		        || in_array('ordersuppliercard',$TContext)
347
+				|| in_array('ordersuppliercard',$TContext)
348 348
 				|| in_array('invoicereccard',$TContext)
349 349
 			)
350
-	        {	
350
+			{	
351 351
 				$hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] : 0;
352 352
 				$hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] : 0;
353 353
 				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] : 0;
354 354
 				
355 355
 				$var=false;
356
-		     	$out.= '<tr '.$bc[$var].'>
356
+			 	$out.= '<tr '.$bc[$var].'>
357 357
 		     			<td colspan="4" align="right">
358 358
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
359 359
 		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
360 360
 		     			</td>
361 361
 		     			</tr>';
362 362
 				
363
-		     	$var=!$var;
364
-		     	$out.= '<tr '.$bc[$var].'>
363
+			 	$var=!$var;
364
+			 	$out.= '<tr '.$bc[$var].'>
365 365
 		     			<td colspan="4" align="right">
366 366
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
367 367
 		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
368 368
 		     			</td>
369 369
 		     			</tr>';
370 370
 		     	
371
-		     	$var=!$var;
372
-		     	$out.= '<tr '.$bc[$var].'>
371
+			 	$var=!$var;
372
+			 	$out.= '<tr '.$bc[$var].'>
373 373
 		     			<td colspan="4" align="right">
374 374
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidePrice').'</label>
375 375
 		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
@@ -381,9 +381,9 @@  discard block
 block discarded – undo
381 381
 				if ( 
382 382
 					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
383 383
 					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
384
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
384
+					|| (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
385 385
 					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
386
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
386
+					|| (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
387 387
 					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
388 388
 				)
389 389
 				{
@@ -402,19 +402,19 @@  discard block
 block discarded – undo
402 402
 			}
403 403
 			
404 404
 		
405
-        return 1;
405
+		return 1;
406 406
 	} 
407 407
 	 
408
-    function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
409
-    {
408
+	function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
409
+	{
410 410
 		
411
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
412
-        {
411
+		if (in_array('invoicecard',explode(':',$parameters['context'])))
412
+		{
413 413
         	
414
-        }
414
+		}
415 415
 		
416
-        return 0;
417
-    }
416
+		return 0;
417
+	}
418 418
 	
419 419
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
420 420
 		global $conf;
@@ -463,11 +463,11 @@  discard block
 block discarded – undo
463 463
 	
464 464
 		if (
465 465
 				in_array('invoicecard',explode(':',$parameters['context']))
466
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
466
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
467 467
 				|| in_array('propalcard',explode(':',$parameters['context']))
468
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
468
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
469 469
 				|| in_array('ordercard',explode(':',$parameters['context']))
470
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
470
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
471 471
 				|| in_array('invoicereccard',explode(':',$parameters['context']))
472 472
 		) {
473 473
 			
@@ -546,20 +546,20 @@  discard block
 block discarded – undo
546 546
 				in_array('invoicecard',explode(':',$parameters['context']))
547 547
 				|| in_array('propalcard',explode(':',$parameters['context']))
548 548
 				|| in_array('ordercard',explode(':',$parameters['context']))
549
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
550
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
551
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
549
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
550
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
551
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
552 552
 			)
553
-	        {								
553
+			{								
554 554
 				if(in_array('invoicecard',explode(':',$parameters['context']))) {
555 555
 					$sessname = 'subtotal_hideInnerLines_facture';	
556 556
 					$sessname2 = 'subtotal_hidedetails_facture';
557 557
 					$sessname3 = 'subtotal_hideprices_facture';
558 558
 				}
559 559
 				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
560
-				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
561
-				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
562
-				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
560
+					$sessname = 'subtotal_hideInnerLines_facture_fournisseur';
561
+					$sessname2 = 'subtotal_hidedetails_facture_fournisseur';
562
+					$sessname3 = 'subtotal_hideprices_facture_fournisseur';
563 563
 				}
564 564
 				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
565 565
 					$sessname = 'subtotal_hideInnerLines_propal';
@@ -567,9 +567,9 @@  discard block
 block discarded – undo
567 567
 					$sessname3 = 'subtotal_hideprices_propal';
568 568
 				}
569 569
 				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
570
-				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
571
-				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
572
-				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
570
+					$sessname = 'subtotal_hideInnerLines_supplier_proposal';
571
+					$sessname2 = 'subtotal_hidedetails_supplier_proposal';
572
+					$sessname3 = 'subtotal_hideprices_supplier_proposal';
573 573
 				}
574 574
 				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
575 575
 					$sessname = 'subtotal_hideInnerLines_commande';
@@ -577,9 +577,9 @@  discard block
 block discarded – undo
577 577
 					$sessname3 = 'subtotal_hideprices_commande';
578 578
 				}
579 579
 				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
580
-				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
581
-				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
582
-				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
580
+					$sessname = 'subtotal_hideInnerLines_commande_fournisseur';
581
+					$sessname2 = 'subtotal_hidedetails_commande_fournisseur';
582
+					$sessname3 = 'subtotal_hideprices_commande_fournisseur';
583 583
 				}
584 584
 				else {
585 585
 					$sessname = 'subtotal_hideInnerLines_unknown';
@@ -601,17 +601,17 @@  discard block
 block discarded – undo
601 601
 				foreach($object->lines as &$line) {
602 602
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
603 603
 					    
604
-                        if($line->qty>=90) {
605
-                            $line->modsubtotal_total = 1;
606
-                        }
607
-                        else{
608
-                            $line->modsubtotal_title = 1;
609
-                        }
604
+						if($line->qty>=90) {
605
+							$line->modsubtotal_total = 1;
606
+						}
607
+						else{
608
+							$line->modsubtotal_title = 1;
609
+						}
610 610
                         
611 611
 						$line->total_ht = $this->getTotalLineFromObject($object, $line, '');
612 612
 					}
613
-	        	}
614
-	        }
613
+				}
614
+			}
615 615
 			
616 616
 		}
617 617
 		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 				 */
629 629
 				else if($object->element=='invoice_supplier')
630 630
 				{
631
-				    $object->deleteline($idLine);
631
+					$object->deleteline($idLine);
632 632
 				}
633 633
 				/**
634 634
 				 * @var $object Propal
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 				 */
652 652
 				else if($object->element=='order_supplier')
653 653
 				{
654
-				    $object->deleteline($idLine);
654
+					$object->deleteline($idLine);
655 655
 				}
656 656
 				/**
657 657
 				 * @var $object Facturerec
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 		
696 696
 		foreach($object->lines as $l) {
697 697
 		
698
-		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
698
+			$lid = (!empty($l->rowid) ? $l->rowid : $l->id);
699 699
 			if($lid == $lineid) {
700 700
 
701 701
 				$found = true;
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 			
705 705
 			if($found) {
706 706
 				
707
-			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
707
+				$Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
708 708
 				
709 709
 				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
710 710
 					break; // end of story
@@ -783,17 +783,17 @@  discard block
 block discarded – undo
783 783
 			if($l->rang>=$rang) {
784 784
 				return price($total);
785 785
 			}
786
-                        if (TSubtotal::isSubtotal($l)){
787
-                            $total = 0;
788
-                        } else  if ($l->situation_percent > 0 ){
786
+						if (TSubtotal::isSubtotal($l)){
787
+							$total = 0;
788
+						} else  if ($l->situation_percent > 0 ){
789 789
                            
790 790
         	
791 791
 		 	$prev_progress = $l->get_prev_progress($object->id);
792 792
 		 	$progress = ($l->situation_percent - $prev_progress) /100;
793
-                        $total += ($l->total_ht/($l->situation_percent/100)) * $progress;
793
+						$total += ($l->total_ht/($l->situation_percent/100)) * $progress;
794 794
                         
795
-                    }
796
-                }
795
+					}
796
+				}
797 797
                 
798 798
 		return price($total);
799 799
 	}
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
 		if(method_exists('Closure','bind')) {
826 826
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
827 827
 			$sweetsThief = function ($pdf) {
828
-		    		return $pdf->bMargin ;
828
+					return $pdf->bMargin ;
829 829
 			};
830 830
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
831 831
 	
@@ -888,11 +888,11 @@  discard block
 block discarded – undo
888 888
 				else
889 889
 				{
890 890
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
891
-                                        if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
892
-                                                $total_to_print = $this->getTotalToPrintSituation($object, $line);
893
-                                        } else {
894
-                                            	$total_to_print = price($total);
895
-                                        }
891
+										if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
892
+												$total_to_print = $this->getTotalToPrintSituation($object, $line);
893
+										} else {
894
+												$total_to_print = price($total);
895
+										}
896 896
                                             
897 897
 					$line->total_ht = $total;
898 898
 					$line->total = $total;
@@ -1082,19 +1082,19 @@  discard block
 block discarded – undo
1082 1082
 			}
1083 1083
 		}
1084 1084
 		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1085
-		    if(is_array($parameters)) $i = & $parameters['i'];
1086
-		    else $i = (int)$parameters;
1087
-		    $this->resprints = price($object->lines[$i]->total_ht);
1085
+			if(is_array($parameters)) $i = & $parameters['i'];
1086
+			else $i = (int)$parameters;
1087
+			$this->resprints = price($object->lines[$i]->total_ht);
1088 1088
 		}
1089 1089
 		if (!empty($hideprices)
1090
-		    || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1091
-		    )
1090
+			|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1091
+			)
1092 1092
 		{
1093
-		    if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1094
-		    {
1095
-		        $this->resprints = ' ';
1096
-		        return 1;
1097
-		    }
1093
+			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1094
+			{
1095
+				$this->resprints = ' ';
1096
+				return 1;
1097
+			}
1098 1098
 		}
1099 1099
         
1100 1100
 		return 0;
@@ -1374,11 +1374,11 @@  discard block
 block discarded – undo
1374 1374
 		$hidedetails = (int)GETPOST('hidedetails');
1375 1375
 		
1376 1376
 		if ($hideInnerLines) { // si c une ligne de titre
1377
-	    	$fk_parent_line=0;
1377
+			$fk_parent_line=0;
1378 1378
 			$TLines =array();
1379 1379
 		
1380 1380
 			$original_count=count($object->lines);
1381
-		    $TTvas = array(); // tableau de tva
1381
+			$TTvas = array(); // tableau de tva
1382 1382
 		    
1383 1383
 			foreach($object->lines as $k=>&$line) 
1384 1384
 			{
@@ -1408,48 +1408,48 @@  discard block
 block discarded – undo
1408 1408
 			
1409 1409
 				if ($hideInnerLines)
1410 1410
 				{
1411
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1412
-				    {
1413
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1411
+					if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1412
+					{
1413
+						if($line->tva_tx != '0.000' && $line->product_type!=9){
1414 1414
 				            
1415
-    				        // on remplit le tableau de tva pour substituer les lignes cachées
1416
-    				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1417
-    				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1418
-    				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1419
-    				    }
1420
-    					if($line->product_type==9 && $line->rowid>0)
1421
-    					{
1422
-    					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1423
-    					    // génère des lignes d'affichage des montants HT soumis à tva
1424
-    					    $nbtva = count($TTvas);
1425
-    					    if(!empty($nbtva)){
1426
-    					        foreach ($TTvas as $tx =>$val){
1427
-    					            $l = clone $line;
1428
-    					            $l->product_type = 1;
1429
-    					            $l->special_code = '';
1430
-    					            $l->qty = 1;
1431
-    					            $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1432
-    					            $l->tva_tx = $tx;
1433
-    					            $l->total_ht = $val['total_ht'];
1434
-    					            $l->total_tva = $val['total_tva'];
1435
-    					            $l->total = $line->total_ht;
1436
-    					            $l->total_ttc = $val['total_ttc'];
1437
-    					            $TLines[] = $l;
1438
-    					            array_shift($TTvas);
1439
-    					       }
1440
-    					    }
1415
+							// on remplit le tableau de tva pour substituer les lignes cachées
1416
+							$TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1417
+							$TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1418
+							$TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1419
+						}
1420
+						if($line->product_type==9 && $line->rowid>0)
1421
+						{
1422
+							//Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1423
+							// génère des lignes d'affichage des montants HT soumis à tva
1424
+							$nbtva = count($TTvas);
1425
+							if(!empty($nbtva)){
1426
+								foreach ($TTvas as $tx =>$val){
1427
+									$l = clone $line;
1428
+									$l->product_type = 1;
1429
+									$l->special_code = '';
1430
+									$l->qty = 1;
1431
+									$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1432
+									$l->tva_tx = $tx;
1433
+									$l->total_ht = $val['total_ht'];
1434
+									$l->total_tva = $val['total_tva'];
1435
+									$l->total = $line->total_ht;
1436
+									$l->total_ttc = $val['total_ttc'];
1437
+									$TLines[] = $l;
1438
+									array_shift($TTvas);
1439
+							   }
1440
+							}
1441 1441
     					    
1442
-    					    // ajoute la ligne de sous-total
1443
-    					    $TLines[] = $line; 
1444
-    					}
1445
-				    } else {
1442
+							// ajoute la ligne de sous-total
1443
+							$TLines[] = $line; 
1444
+						}
1445
+					} else {
1446 1446
 				        
1447
-				        if($line->product_type==9 && $line->rowid>0)
1448
-				        {
1449
-				            // ajoute la ligne de sous-total
1450
-				            $TLines[] = $line; 
1451
-				        }
1452
-				    }
1447
+						if($line->product_type==9 && $line->rowid>0)
1448
+						{
1449
+							// ajoute la ligne de sous-total
1450
+							$TLines[] = $line; 
1451
+						}
1452
+					}
1453 1453
 				    
1454 1454
 					
1455 1455
 				}
@@ -1474,20 +1474,20 @@  discard block
 block discarded – undo
1474 1474
 			$nbtva = count($TTvas);
1475 1475
 			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1476 1476
 			{
1477
-			    foreach ($TTvas as $tx =>$val){
1478
-			        $l = clone $line;
1479
-			        $l->product_type = 1;
1480
-			        $l->special_code = '';
1481
-			        $l->qty = 1;
1482
-			        $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1483
-			        $l->tva_tx = $tx;
1484
-			        $l->total_ht = $val['total_ht'];
1485
-			        $l->total_tva = $val['total_tva'];
1486
-			        $l->total = $line->total_ht;
1487
-			        $l->total_ttc = $val['total_ttc'];
1488
-			        $TLines[] = $l;
1489
-			        array_shift($TTvas);
1490
-			    }
1477
+				foreach ($TTvas as $tx =>$val){
1478
+					$l = clone $line;
1479
+					$l->product_type = 1;
1480
+					$l->special_code = '';
1481
+					$l->qty = 1;
1482
+					$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1483
+					$l->tva_tx = $tx;
1484
+					$l->total_ht = $val['total_ht'];
1485
+					$l->total_tva = $val['total_tva'];
1486
+					$l->total = $line->total_ht;
1487
+					$l->total_ttc = $val['total_ttc'];
1488
+					$TLines[] = $l;
1489
+					array_shift($TTvas);
1490
+				}
1491 1491
 			}
1492 1492
 			
1493 1493
 			global $nblignes;
@@ -1499,7 +1499,7 @@  discard block
 block discarded – undo
1499 1499
 				$this->resprints = '';
1500 1500
 				return 0;
1501 1501
 			}
1502
-	    }
1502
+		}
1503 1503
 		
1504 1504
 		return 0;
1505 1505
 	}
@@ -1662,18 +1662,18 @@  discard block
 block discarded – undo
1662 1662
 		}
1663 1663
 		elseif($object->element == 'order_supplier' )
1664 1664
 		{
1665
-		    $createRight = $user->rights->fournisseur->commande->creer;
1665
+			$createRight = $user->rights->fournisseur->commande->creer;
1666 1666
 		}
1667 1667
 		elseif($object->element == 'invoice_supplier' )
1668 1668
 		{
1669
-		    $createRight = $user->rights->fournisseur->facture->creer;
1669
+			$createRight = $user->rights->fournisseur->facture->creer;
1670 1670
 		}
1671 1671
 		
1672 1672
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1673 1673
 			null;
1674 1674
 		}	
1675 1675
 		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)) 
1676
-        {
1676
+		{
1677 1677
 			if($object->element=='facture')$idvar = 'facid';
1678 1678
 			else $idvar='id';
1679 1679
 			
@@ -1720,7 +1720,7 @@  discard block
 block discarded – undo
1720 1720
 			//var_dump($line);
1721 1721
             
1722 1722
 			// HTML 5 data for js
1723
-            $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
1723
+			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
1724 1724
             
1725 1725
 			
1726 1726
 			?>
@@ -1778,8 +1778,8 @@  discard block
 block discarded – undo
1778 1778
 						}
1779 1779
 						
1780 1780
 						if ($object->element == 'order_supplier' || $object->element == 'invoice_supplier') {
1781
-						    $line->label = !empty($line->description) ? $line->description : $line->desc;
1782
-						    $line->description = '';
1781
+							$line->label = !empty($line->description) ? $line->description : $line->desc;
1782
+							$line->description = '';
1783 1783
 						}
1784 1784
 						$newlabel = $line->label;
1785 1785
 						if($line->label=='' && !$isFreeText) {
@@ -2070,17 +2070,17 @@  discard block
 block discarded – undo
2070 2070
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2071 2071
 		{
2072 2072
 		    
2073
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2074
-		    {
2075
-		        foreach ($object->lines as $line)
2076
-		        {
2077
-		            // fetch optionals attributes and labels
2078
-		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2079
-		            $extrafields=new ExtraFields($this->db);
2080
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2081
-		            $line->fetch_optionals($line->id,$extralabels);
2082
-		        }
2083
-		    }
2073
+			if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2074
+			{
2075
+				foreach ($object->lines as $line)
2076
+				{
2077
+					// fetch optionals attributes and labels
2078
+					require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2079
+					$extrafields=new ExtraFields($this->db);
2080
+					$extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2081
+					$line->fetch_optionals($line->id,$extralabels);
2082
+				}
2083
+			}
2084 2084
 		    
2085 2085
 			$TSubNc = array();
2086 2086
 			foreach ($object->lines as &$l)
@@ -2171,80 +2171,80 @@  discard block
 block discarded – undo
2171 2171
 	{
2172 2172
 		dol_include_once('/subtotal/class/subtotal.class.php');
2173 2173
 
2174
-	    $line = &$parameters['line'];
2174
+		$line = &$parameters['line'];
2175 2175
 	    
2176
-	    $ThtmlData['data-id']           = $line->id;
2177
-	    $ThtmlData['data-product_type'] = $line->product_type;
2178
-	    $ThtmlData['data-qty']          = 0; //$line->qty;
2179
-	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2176
+		$ThtmlData['data-id']           = $line->id;
2177
+		$ThtmlData['data-product_type'] = $line->product_type;
2178
+		$ThtmlData['data-qty']          = 0; //$line->qty;
2179
+		$ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2180 2180
 	    
2181
-	    if(TSubtotal::isTitle($line)){
2182
-	        $ThtmlData['data-issubtotal'] = 'title';
2183
-	    }elseif(TSubtotal::isSubtotal($line)){
2184
-	        $ThtmlData['data-issubtotal'] = 'subtotal';
2185
-	    }
2186
-	    else{
2187
-	        $ThtmlData['data-issubtotal'] = 'freetext';
2188
-	    }
2181
+		if(TSubtotal::isTitle($line)){
2182
+			$ThtmlData['data-issubtotal'] = 'title';
2183
+		}elseif(TSubtotal::isSubtotal($line)){
2184
+			$ThtmlData['data-issubtotal'] = 'subtotal';
2185
+		}
2186
+		else{
2187
+			$ThtmlData['data-issubtotal'] = 'freetext';
2188
+		}
2189 2189
 	    
2190 2190
 	    
2191
-	    // Change or add data  from hooks
2192
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2191
+		// Change or add data  from hooks
2192
+		$parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2193 2193
 	    
2194
-	    // hook 
2195
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2196
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2197
-	    if ($reshook>0)
2198
-	    {
2199
-	        $ThtmlData = $hookmanager->resArray;
2200
-	    }
2201
-
2202
-	    return $this->implodeHtmlData($ThtmlData);
2194
+		// hook 
2195
+		$reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2196
+		if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2197
+		if ($reshook>0)
2198
+		{
2199
+			$ThtmlData = $hookmanager->resArray;
2200
+		}
2201
+
2202
+		return $this->implodeHtmlData($ThtmlData);
2203 2203
 	
2204 2204
 	}
2205 2205
 	
2206 2206
 	
2207 2207
 	function implodeHtmlData($ThtmlData = array())
2208 2208
 	{
2209
-	    $data = '';
2210
-	    foreach($ThtmlData as $k => $h )
2211
-	    {
2212
-	        if(is_array($h))
2213
-	        {
2214
-	            $h = json_encode($h);
2215
-	        }
2209
+		$data = '';
2210
+		foreach($ThtmlData as $k => $h )
2211
+		{
2212
+			if(is_array($h))
2213
+			{
2214
+				$h = json_encode($h);
2215
+			}
2216 2216
 	        
2217
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2218
-	    }
2217
+			$data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2218
+		}
2219 2219
 	    
2220
-	    return $data;
2220
+		return $data;
2221 2221
 	}
2222 2222
 	
2223 2223
 	function _ajax_block_order_js($object)
2224 2224
 	{
2225
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2225
+		global $conf,$tagidfortablednd,$filepath,$langs;
2226 2226
 	    
2227
-	    /*
2227
+		/*
2228 2228
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2229 2229
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2230 2230
 	     */
2231 2231
 	    
2232
-	    $id=$object->id;
2233
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2234
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2232
+		$id=$object->id;
2233
+		$nboflines=(isset($object->lines)?count($object->lines):0);
2234
+		$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2235 2235
 	    
2236
-	    $id=$object->id;
2237
-	    $fk_element=$object->fk_element;
2238
-	    $table_element_line=$object->table_element_line;
2239
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2240
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2241
-	    $filepath=(empty($filepath)?'':$filepath);
2236
+		$id=$object->id;
2237
+		$fk_element=$object->fk_element;
2238
+		$table_element_line=$object->table_element_line;
2239
+		$nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2240
+		$tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2241
+		$filepath=(empty($filepath)?'':$filepath);
2242 2242
 	    
2243 2243
 	    
2244
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2245
-	    {
2244
+		if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2245
+		{
2246 2246
 	        
2247
-	        ?>
2247
+			?>
2248 2248
 		
2249 2249
 		
2250 2250
 			<script type="text/javascript">
Please login to merge, or discard this patch.
Spacing   +380 added lines, -380 removed lines patch added patch discarded remove patch
@@ -51,43 +51,43 @@  discard block
 block discarded – undo
51 51
     
52 52
     function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
53 53
     {
54
-      	global $langs,$db,$user, $conf;
54
+      	global $langs, $db, $user, $conf;
55 55
 		
56 56
 		$langs->load('subtotal@subtotal');
57 57
 		
58
-		$contexts = explode(':',$parameters['context']);
58
+		$contexts = explode(':', $parameters['context']);
59 59
 		
60
-		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)) {
60
+		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)) {
61 61
 			
62 62
 			$createRight = $user->rights->{$object->element}->creer;
63
-			if($object->element == 'facturerec' )
63
+			if ($object->element == 'facturerec')
64 64
 			{
65 65
 				$object->statut = 0; // hack for facture rec
66 66
 				$createRight = $user->rights->facture->creer;
67
-			} elseif($object->element == 'order_supplier' )
67
+			} elseif ($object->element == 'order_supplier')
68 68
 			{
69 69
 			    $createRight = $user->rights->fournisseur->commande->creer;
70
-			} elseif($object->element == 'invoice_supplier' )
70
+			} elseif ($object->element == 'invoice_supplier')
71 71
 			{
72 72
 			    $createRight = $user->rights->fournisseur->facture->creer;
73 73
 			}
74 74
 			
75
-			if ($object->statut == 0  && $createRight) {
75
+			if ($object->statut == 0 && $createRight) {
76 76
 			
77 77
 
78
-				if($object->element=='facture')$idvar = 'facid';
79
-				else $idvar='id';
78
+				if ($object->element == 'facture')$idvar = 'facid';
79
+				else $idvar = 'id';
80 80
 				
81
-				if(in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')) )
81
+				if (in_array($action, array('add_title_line', 'add_total_line', 'add_subtitle_line', 'add_subtotal_line', 'add_free_text')))
82 82
 				{
83 83
 					$level = GETPOST('level', 'int'); //New avec SUBTOTAL_USE_NEW_FORMAT
84 84
 					
85
-					if($action=='add_title_line') {
85
+					if ($action == 'add_title_line') {
86 86
 						$title = GETPOST('title');
87
-						if(empty($title)) $title = $langs->trans('title');
88
-						$qty = $level<1 ? 1 : $level ;
87
+						if (empty($title)) $title = $langs->trans('title');
88
+						$qty = $level < 1 ? 1 : $level;
89 89
 					}
90
-					else if($action=='add_free_text') {
90
+					else if ($action == 'add_free_text') {
91 91
 						$title = GETPOST('title');
92 92
 
93 93
 						if (empty($title)) {
@@ -99,21 +99,21 @@  discard block
 block discarded – undo
99 99
 								}
100 100
 							}
101 101
 						}
102
-						if(empty($title)) $title = $langs->trans('subtotalAddLineDescription');
102
+						if (empty($title)) $title = $langs->trans('subtotalAddLineDescription');
103 103
 						$qty = 50;
104 104
 					}
105
-					else if($action=='add_subtitle_line') {
105
+					else if ($action == 'add_subtitle_line') {
106 106
 						$title = GETPOST('title');
107
-						if(empty($title)) $title = $langs->trans('subtitle');
107
+						if (empty($title)) $title = $langs->trans('subtitle');
108 108
 						$qty = 2;
109 109
 					}
110
-					else if($action=='add_subtotal_line') {
110
+					else if ($action == 'add_subtotal_line') {
111 111
 						$title = $langs->trans('SubSubTotal');
112 112
 						$qty = 98;
113 113
 					}
114 114
 					else {
115 115
 						$title = GETPOST('title') ? GETPOST('title') : $langs->trans('SubTotal');
116
-						$qty = $level ? 100-$level : 99;
116
+						$qty = $level ? 100 - $level : 99;
117 117
 					}
118 118
 					dol_include_once('/subtotal/class/subtotal.class.php');
119 119
 					
@@ -121,15 +121,15 @@  discard block
 block discarded – undo
121 121
 					
122 122
 	    			TSubtotal::addSubTotalLine($object, $title, $qty);
123 123
 				}
124
-				else if($action==='ask_deleteallline') {
125
-						$form=new Form($db);
124
+				else if ($action === 'ask_deleteallline') {
125
+						$form = new Form($db);
126 126
 						
127
-						$lineid = GETPOST('lineid','integer');
127
+						$lineid = GETPOST('lineid', 'integer');
128 128
 						$TIdForGroup = $this->getArrayOfLineForAGroup($object, $lineid);
129 129
 					
130 130
 						$nbLines = count($TIdForGroup);
131 131
 					
132
-						$formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines',$nbLines), 'confirm_delete_all_lines','',0,1);
132
+						$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('deleteWithAllLines'), $langs->trans('ConfirmDeleteAllThisLines', $nbLines), 'confirm_delete_all_lines', '', 0, 1);
133 133
 						print $formconfirm;
134 134
 				}
135 135
 
@@ -139,13 +139,13 @@  discard block
 block discarded – undo
139 139
 				}
140 140
 
141 141
 				
142
-				if($action!='editline') {
142
+				if ($action != 'editline') {
143 143
 					// New format is for 3.8
144 144
 					$this->printNewFormat($object, $conf, $langs, $idvar);
145 145
 				}
146 146
 			}
147 147
 		}
148
-		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice',$contexts))
148
+		elseif ((!empty($parameters['currentcontext']) && $parameters['currentcontext'] == 'orderstoinvoice') || in_array('orderstoinvoice', $contexts))
149 149
 		{
150 150
 			?>
151 151
 			<script type="text/javascript">
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 				$(document).ready(function() {
171 171
 					$('div.fiche div.tabsAction').append('<br />');
172 172
 					
173
-					$('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>');
173
+					$('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>');
174 174
 					$('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>');
175 175
 					$('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>');
176 176
 
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
 						$('body').append(dialog_html);
222 222
 
223 223
 						<?php 
224
-						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME)?'ckeditor':$conf->global->FCKEDITOR_EDITORNAME;
225
-						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS)?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
226
-						if($editorConf && in_array($editorTool,array('textarea','ckeditor'))){ 
224
+						$editorTool = empty($conf->global->FCKEDITOR_EDITORNAME) ? 'ckeditor' : $conf->global->FCKEDITOR_EDITORNAME;
225
+						$editorConf = empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ?false:$conf->global->FCKEDITOR_ENABLE_DETAILS;
226
+						if ($editorConf && in_array($editorTool, array('textarea', 'ckeditor'))) { 
227 227
 						?>
228 228
 						if (action == 'addTitle' || action == 'addFreeTxt')
229 229
 						{
@@ -338,61 +338,61 @@  discard block
 block discarded – undo
338 338
 		global $conf, $langs, $bc;
339 339
 			
340 340
 		$action = GETPOST('action');	
341
-		$TContext = explode(':',$parameters['context']);
341
+		$TContext = explode(':', $parameters['context']);
342 342
 		if (
343
-				in_array('invoicecard',$TContext)
344
-		        || in_array('invoicesuppliercard',$TContext)
345
-				|| in_array('propalcard',$TContext)
346
-				|| in_array('ordercard',$TContext)
347
-		        || in_array('ordersuppliercard',$TContext)
348
-				|| in_array('invoicereccard',$TContext)
343
+				in_array('invoicecard', $TContext)
344
+		        || in_array('invoicesuppliercard', $TContext)
345
+				|| in_array('propalcard', $TContext)
346
+				|| in_array('ordercard', $TContext)
347
+		        || in_array('ordersuppliercard', $TContext)
348
+				|| in_array('invoicereccard', $TContext)
349 349
 			)
350 350
 	        {	
351
-				$hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] : 0;
352
-				$hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] : 0;
353
-				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] : 0;
351
+				$hideInnerLines = isset($_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']]) ? $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] : 0;
352
+				$hidedetails = isset($_SESSION['subtotal_hidedetails_'.$parameters['modulepart']]) ? $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] : 0;
353
+				$hideprices = isset($_SESSION['subtotal_hideprices_'.$parameters['modulepart']]) ? $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] : 0;
354 354
 				
355
-				$var=false;
356
-		     	$out.= '<tr '.$bc[$var].'>
355
+				$var = false;
356
+		     	$out .= '<tr '.$bc[$var].'>
357 357
 		     			<td colspan="4" align="right">
358 358
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
359
-		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
359
+		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(($hideInnerLines) ? 'checked="checked"' : '').' />
360 360
 		     			</td>
361 361
 		     			</tr>';
362 362
 				
363
-		     	$var=!$var;
364
-		     	$out.= '<tr '.$bc[$var].'>
363
+		     	$var = !$var;
364
+		     	$out .= '<tr '.$bc[$var].'>
365 365
 		     			<td colspan="4" align="right">
366 366
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
367
-		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
367
+		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(($hidedetails) ? 'checked="checked"' : '').' />
368 368
 		     			</td>
369 369
 		     			</tr>';
370 370
 		     	
371
-		     	$var=!$var;
372
-		     	$out.= '<tr '.$bc[$var].'>
371
+		     	$var = !$var;
372
+		     	$out .= '<tr '.$bc[$var].'>
373 373
 		     			<td colspan="4" align="right">
374 374
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidePrice').'</label>
375
-		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
375
+		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(($hideprices) ? 'checked="checked"' : '').' />
376 376
 		     			</td>
377 377
 		     			</tr>';
378 378
 		     	
379 379
 		     	
380 380
 				 
381 381
 				if ( 
382
-					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
383
-					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
384
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
385
-					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
386
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
387
-					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
382
+					(in_array('propalcard', $TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
383
+					|| (in_array('ordercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
384
+				    || (in_array('ordersuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
385
+					|| (in_array('invoicecard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
386
+				    || (in_array('invoicesuppliercard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
387
+					|| (in_array('invoicereccard', $TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
388 388
 				)
389 389
 				{
390
-					$var=!$var;
391
-					$out.= '
390
+					$var = !$var;
391
+					$out .= '
392 392
 						<tr '.$bc[$var].'>
393 393
 							<td colspan="4" align="right">
394 394
 								<label for="subtotal_add_recap">'.$langs->trans('subtotal_add_recap').'</label>
395
-								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.( GETPOST('subtotal_add_recap') ? 'checked="checked"' : '' ).' />
395
+								<input type="checkbox" id="subtotal_add_recap" name="subtotal_add_recap" value="1" '.(GETPOST('subtotal_add_recap') ? 'checked="checked"' : '').' />
396 396
 							</td>
397 397
 						</tr>';
398 398
 				}
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
     function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
409 409
     {
410 410
 		
411
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
411
+    	if (in_array('invoicecard', explode(':', $parameters['context'])))
412 412
         {
413 413
         	
414 414
         }
@@ -419,13 +419,13 @@  discard block
 block discarded – undo
419 419
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
420 420
 		global $conf;
421 421
 		
422
-		if($action === 'builddoc') {
422
+		if ($action === 'builddoc') {
423 423
 			
424 424
 			$line = &$parameters['line'];
425 425
 			$object = &$parameters['object'];
426 426
 			$substitutionarray = &$parameters['substitutionarray'];
427 427
 			
428
-			if($line->product_type == 9 && $line->special_code == $this->module_number) {
428
+			if ($line->product_type == 9 && $line->special_code == $this->module_number) {
429 429
 				$substitutionarray['line_modsubtotal'] = 1;	
430 430
 				
431 431
 				$substitutionarray['line_price_ht']
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 					 = $substitutionarray['line_up'] 
437 437
 					 = '';
438 438
 				
439
-				if($line->qty>90) {
439
+				if ($line->qty > 90) {
440 440
 					$substitutionarray['line_modsubtotal_total'] = true;
441 441
 					
442 442
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 				
451 451
 				
452 452
 			}	
453
-			else{
453
+			else {
454 454
 				$substitutionarray['line_not_modsubtotal'] = true;
455 455
 				$substitutionarray['line_modsubtotal'] = 0;
456 456
 			}
@@ -462,29 +462,29 @@  discard block
 block discarded – undo
462 462
 	function createFrom($parameters, &$object, $action, $hookmanager) {
463 463
 	
464 464
 		if (
465
-				in_array('invoicecard',explode(':',$parameters['context']))
466
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
467
-				|| in_array('propalcard',explode(':',$parameters['context']))
468
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
469
-				|| in_array('ordercard',explode(':',$parameters['context']))
470
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
471
-				|| in_array('invoicereccard',explode(':',$parameters['context']))
465
+				in_array('invoicecard', explode(':', $parameters['context']))
466
+		        || in_array('invoicesuppliercard', explode(':', $parameters['context']))
467
+				|| in_array('propalcard', explode(':', $parameters['context']))
468
+		        || in_array('supplier_proposalcard', explode(':', $parameters['context']))
469
+				|| in_array('ordercard', explode(':', $parameters['context']))
470
+		        || in_array('ordersuppliercard', explode(':', $parameters['context']))
471
+				|| in_array('invoicereccard', explode(':', $parameters['context']))
472 472
 		) {
473 473
 			
474 474
 			global $db;
475 475
 			
476 476
 			$objFrom = $parameters['objFrom'];
477 477
 			
478
-			foreach($objFrom->lines as $k=> &$lineOld) {
478
+			foreach ($objFrom->lines as $k=> &$lineOld) {
479 479
 				
480
-					if($lineOld->product_type == 9 && $lineOld->info_bits > 0 ) {
480
+					if ($lineOld->product_type == 9 && $lineOld->info_bits > 0) {
481 481
 							
482 482
 							$line = & $object->lines[$k];
483 483
 				
484 484
 							$idLine = (int) ($line->id ? $line->id : $line->rowid); 
485 485
 				
486 486
 							$db->query("UPDATE ".MAIN_DB_PREFIX.$line->table_element."
487
-							SET info_bits=".(int)$lineOld->info_bits."
487
+							SET info_bits=".(int) $lineOld->info_bits."
488 488
 							WHERE rowid = ".$idLine."
489 489
 							");
490 490
 						
@@ -500,15 +500,15 @@  discard block
 block discarded – undo
500 500
 	
501 501
 	function doActions($parameters, &$object, $action, $hookmanager)
502 502
 	{
503
-		global $db, $conf, $langs,$user;
503
+		global $db, $conf, $langs, $user;
504 504
 		
505 505
 		dol_include_once('/subtotal/class/subtotal.class.php');
506 506
 		dol_include_once('/subtotal/lib/subtotal.lib.php');
507
-		require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
507
+		require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
508 508
 		
509 509
 		$showBlockExtrafields = GETPOST('showBlockExtrafields');
510 510
 		
511
-		if($object->element=='facture') $idvar = 'facid';
511
+		if ($object->element == 'facture') $idvar = 'facid';
512 512
 		else $idvar = 'id';
513 513
 			
514 514
 		if ($action == 'updateligne' || $action == 'updateline')
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 				if ($line->id == $lineid && TSubtotal::isModSubtotalLine($line))
522 522
 				{
523 523
 					$found = true;
524
-					if(TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
524
+					if (TSubtotal::isTitle($line) && !empty($showBlockExtrafields)) {
525 525
 						$extrafieldsline = new ExtraFields($db);
526 526
 						$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
527 527
 						$extrafieldsline->setOptionalsFromPost($extralabelsline, $line);
@@ -540,43 +540,43 @@  discard block
 block discarded – undo
540 540
 				exit; // Surtout ne pas laisser Dolibarr faire du traitement sur le updateligne sinon ça plante les données de la ligne
541 541
 			}
542 542
 		}
543
-		else if($action === 'builddoc') {
543
+		else if ($action === 'builddoc') {
544 544
 			
545 545
 			if (
546
-				in_array('invoicecard',explode(':',$parameters['context']))
547
-				|| in_array('propalcard',explode(':',$parameters['context']))
548
-				|| in_array('ordercard',explode(':',$parameters['context']))
549
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
550
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
551
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
546
+				in_array('invoicecard', explode(':', $parameters['context']))
547
+				|| in_array('propalcard', explode(':', $parameters['context']))
548
+				|| in_array('ordercard', explode(':', $parameters['context']))
549
+			    || in_array('ordersuppliercard', explode(':', $parameters['context']))
550
+			    || in_array('invoicesuppliercard', explode(':', $parameters['context']))
551
+			    || in_array('supplier_proposalcard', explode(':', $parameters['context']))
552 552
 			)
553 553
 	        {								
554
-				if(in_array('invoicecard',explode(':',$parameters['context']))) {
554
+				if (in_array('invoicecard', explode(':', $parameters['context']))) {
555 555
 					$sessname = 'subtotal_hideInnerLines_facture';	
556 556
 					$sessname2 = 'subtotal_hidedetails_facture';
557 557
 					$sessname3 = 'subtotal_hideprices_facture';
558 558
 				}
559
-				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
559
+				elseif (in_array('invoicesuppliercard', explode(':', $parameters['context']))) {
560 560
 				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
561 561
 				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
562 562
 				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
563 563
 				}
564
-				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
564
+				elseif (in_array('propalcard', explode(':', $parameters['context']))) {
565 565
 					$sessname = 'subtotal_hideInnerLines_propal';
566 566
 					$sessname2 = 'subtotal_hidedetails_propal';	
567 567
 					$sessname3 = 'subtotal_hideprices_propal';
568 568
 				}
569
-				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
569
+				elseif (in_array('supplier_proposalcard', explode(':', $parameters['context']))) {
570 570
 				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
571 571
 				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
572 572
 				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
573 573
 				}
574
-				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
574
+				elseif (in_array('ordercard', explode(':', $parameters['context']))) {
575 575
 					$sessname = 'subtotal_hideInnerLines_commande';
576 576
 					$sessname2 = 'subtotal_hidedetails_commande';	
577 577
 					$sessname3 = 'subtotal_hideprices_commande';
578 578
 				}
579
-				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
579
+				elseif (in_array('ordersuppliercard', explode(':', $parameters['context']))) {
580 580
 				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
581 581
 				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
582 582
 				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
@@ -589,22 +589,22 @@  discard block
 block discarded – undo
589 589
 					
590 590
 				global $hideprices;
591 591
 				
592
-				$hideInnerLines = (int)GETPOST('hideInnerLines');
592
+				$hideInnerLines = (int) GETPOST('hideInnerLines');
593 593
 				$_SESSION[$sessname] = $hideInnerLines;		
594 594
 				
595
-				$hidedetails= (int)GETPOST('hidedetails');
595
+				$hidedetails = (int) GETPOST('hidedetails');
596 596
 				$_SESSION[$sessname2] = $hidedetails;
597 597
 				
598
-				$hideprices= (int)GETPOST('hideprices');
598
+				$hideprices = (int) GETPOST('hideprices');
599 599
 				$_SESSION[$sessname3] = $hideprices;
600 600
 				
601
-				foreach($object->lines as &$line) {
601
+				foreach ($object->lines as &$line) {
602 602
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
603 603
 					    
604
-                        if($line->qty>=90) {
604
+                        if ($line->qty >= 90) {
605 605
                             $line->modsubtotal_total = 1;
606 606
                         }
607
-                        else{
607
+                        else {
608 608
                             $line->modsubtotal_title = 1;
609 609
                         }
610 610
                         
@@ -614,34 +614,34 @@  discard block
 block discarded – undo
614 614
 	        }
615 615
 			
616 616
 		}
617
-		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
617
+		else if ($action === 'confirm_delete_all_lines' && GETPOST('confirm') == 'yes') {
618 618
 			
619 619
 			$Tab = $this->getArrayOfLineForAGroup($object, GETPOST('lineid'));
620 620
 			
621
-			foreach($Tab as $idLine) {
621
+			foreach ($Tab as $idLine) {
622 622
 				/**
623 623
 				 * @var $object Facture
624 624
 				 */
625
-				if($object->element=='facture') $object->deleteline($idLine);
625
+				if ($object->element == 'facture') $object->deleteline($idLine);
626 626
 				/**
627 627
 				 * @var $object Facture fournisseur
628 628
 				 */
629
-				else if($object->element=='invoice_supplier')
629
+				else if ($object->element == 'invoice_supplier')
630 630
 				{
631 631
 				    $object->deleteline($idLine);
632 632
 				}
633 633
 				/**
634 634
 				 * @var $object Propal
635 635
 				 */
636
-				else if($object->element=='propal') $object->deleteline($idLine);
636
+				else if ($object->element == 'propal') $object->deleteline($idLine);
637 637
 				/**
638 638
 				 * @var $object Propal Fournisseur
639 639
 				 */
640
-				else if($object->element=='supplier_proposal') $object->deleteline($idLine);
640
+				else if ($object->element == 'supplier_proposal') $object->deleteline($idLine);
641 641
 				/**
642 642
 				 * @var $object Commande
643 643
 				 */
644
-				else if($object->element=='commande') 
644
+				else if ($object->element == 'commande') 
645 645
 				{
646 646
 					if ((float) DOL_VERSION >= 5.0) $object->deleteline($user, $idLine);
647 647
 					else $object->deleteline($idLine);
@@ -649,14 +649,14 @@  discard block
 block discarded – undo
649 649
 				/**
650 650
 				 * @var $object Commande fournisseur
651 651
 				 */
652
-				else if($object->element=='order_supplier')
652
+				else if ($object->element == 'order_supplier')
653 653
 				{
654 654
 				    $object->deleteline($idLine);
655 655
 				}
656 656
 				/**
657 657
 				 * @var $object Facturerec
658 658
 				 */
659
-				else if($object->element=='facturerec') $object->deleteline($idLine);
659
+				else if ($object->element == 'facturerec') $object->deleteline($idLine);
660 660
 			}
661 661
 			
662 662
 			header('location:?id='.$object->id);
@@ -679,7 +679,7 @@  discard block
 block discarded – undo
679 679
 		return 0;
680 680
 	}
681 681
 	
682
-	function formAddObjectLine ($parameters, &$object, &$action, $hookmanager) {
682
+	function formAddObjectLine($parameters, &$object, &$action, $hookmanager) {
683 683
 		return 0;
684 684
 	}
685 685
 
@@ -691,22 +691,22 @@  discard block
 block discarded – undo
691 691
 		
692 692
 		$found = false;
693 693
 
694
-		$Tab= array();
694
+		$Tab = array();
695 695
 		
696
-		foreach($object->lines as $l) {
696
+		foreach ($object->lines as $l) {
697 697
 		
698 698
 		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
699
-			if($lid == $lineid) {
699
+			if ($lid == $lineid) {
700 700
 
701 701
 				$found = true;
702 702
 				$qty_line = $l->qty;
703 703
 			}
704 704
 			
705
-			if($found) {
705
+			if ($found) {
706 706
 				
707 707
 			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
708 708
 				
709
-				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
709
+				if ($l->special_code == $this->module_number && (($l->qty == 99 && $qty_line == 1) || ($l->qty == 98 && $qty_line == 2))) {
710 710
 					break; // end of story
711 711
 				}
712 712
 			}
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
 	 * 
736 736
 	 * @param	$use_level		isn't used anymore
737 737
 	 */
738
-	function getTotalLineFromObject(&$object, &$line, $use_level=false, $return_all=0) {
738
+	function getTotalLineFromObject(&$object, &$line, $use_level = false, $return_all = 0) {
739 739
 		
740 740
 		$rang = $line->rang;
741 741
 		$qty_line = $line->qty;
@@ -746,21 +746,21 @@  discard block
 block discarded – undo
746 746
 		$TTotal_tva = array();
747 747
 		
748 748
 		dol_include_once('/subtotal/class/subtotal.class.php');
749
-		foreach($object->lines as $l) {
749
+		foreach ($object->lines as $l) {
750 750
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
751
-			if($l->rang>=$rang) {
751
+			if ($l->rang >= $rang) {
752 752
 				//echo 'return!<br>';
753 753
 				if (!$return_all) return $total;
754 754
 				else return array($total, $total_tva, $total_ttc, $TTotal_tva);
755 755
 			}
756
-			else if(TSubtotal::isTitle($l, 100 - $qty_line)) 
756
+			else if (TSubtotal::isTitle($l, 100 - $qty_line)) 
757 757
 		  	{
758 758
 				$total = 0;
759 759
 				$total_tva = 0;
760 760
 				$total_ttc = 0;
761 761
 				$TTotal_tva = array();
762 762
 			}
763
-			elseif(!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
763
+			elseif (!TSubtotal::isTitle($l) && !TSubtotal::isSubtotal($l)) {
764 764
 				$total += $l->total_ht;
765 765
 				$total_tva += $l->total_tva;
766 766
 				$TTotal_tva[$l->tva_tx] += $l->total_tva;
@@ -779,18 +779,18 @@  discard block
 block discarded – undo
779 779
 		
780 780
 		$rang = $line->rang;
781 781
 		$total = 0;
782
-		foreach($object->lines as $l) {
783
-			if($l->rang>=$rang) {
782
+		foreach ($object->lines as $l) {
783
+			if ($l->rang >= $rang) {
784 784
 				return price($total);
785 785
 			}
786
-                        if (TSubtotal::isSubtotal($l)){
786
+                        if (TSubtotal::isSubtotal($l)) {
787 787
                             $total = 0;
788
-                        } else  if ($l->situation_percent > 0 ){
788
+                        } else  if ($l->situation_percent > 0) {
789 789
                            
790 790
         	
791 791
 		 	$prev_progress = $l->get_prev_progress($object->id);
792
-		 	$progress = ($l->situation_percent - $prev_progress) /100;
793
-                        $total += ($l->total_ht/($l->situation_percent/100)) * $progress;
792
+		 	$progress = ($l->situation_percent - $prev_progress) / 100;
793
+                        $total += ($l->total_ht / ($l->situation_percent / 100)) * $progress;
794 794
                         
795 795
                     }
796 796
                 }
@@ -809,10 +809,10 @@  discard block
 block discarded – undo
809 809
 	 * @param $w            float               width
810 810
 	 * @param $h            float               height
811 811
 	 */
812
-	function pdf_add_total(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
813
-		global $conf,$subtotal_last_title_posy;
812
+	function pdf_add_total(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
813
+		global $conf, $subtotal_last_title_posy;
814 814
 		
815
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
815
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
816 816
 		if (!empty($conf->global->SUBTOTAL_ONE_LINE_IF_HIDE_INNERLINES) && $hideInnerLines && !empty($subtotal_last_title_posy))
817 817
 		{
818 818
 			$posy = $subtotal_last_title_posy;
@@ -822,34 +822,34 @@  discard block
 block discarded – undo
822 822
 		$hidePriceOnSubtotalLines = (int) GETPOST('hide_price_on_subtotal_lines');
823 823
 		
824 824
 		$set_pagebreak_margin = false;
825
-		if(method_exists('Closure','bind')) {
825
+		if (method_exists('Closure', 'bind')) {
826 826
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
827
-			$sweetsThief = function ($pdf) {
828
-		    		return $pdf->bMargin ;
827
+			$sweetsThief = function($pdf) {
828
+		    		return $pdf->bMargin;
829 829
 			};
830 830
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
831 831
 	
832
-			$bMargin  = $sweetsThief($pdf);
832
+			$bMargin = $sweetsThief($pdf);
833 833
 	
834
-			$pdf->SetAutoPageBreak( false );
834
+			$pdf->SetAutoPageBreak(false);
835 835
 
836 836
 			$set_pagebreak_margin = true;			
837 837
 		}
838 838
 		
839 839
 			
840
-		if($line->qty==99)
841
-			$pdf->SetFillColor(220,220,220);
842
-		elseif ($line->qty==98)
843
-			$pdf->SetFillColor(230,230,230);
840
+		if ($line->qty == 99)
841
+			$pdf->SetFillColor(220, 220, 220);
842
+		elseif ($line->qty == 98)
843
+			$pdf->SetFillColor(230, 230, 230);
844 844
 		else
845
-			$pdf->SetFillColor(240,240,240);
845
+			$pdf->SetFillColor(240, 240, 240);
846 846
 		
847 847
 		$style = 'B';
848 848
 		if (!empty($conf->global->SUBTOTAL_SUBTOTAL_STYLE)) $style = $conf->global->SUBTOTAL_SUBTOTAL_STYLE;
849 849
 		
850 850
 		$pdf->SetFont('', $style, 9);
851 851
 		
852
-		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R',true);
852
+		$pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'R', true);
853 853
 //		var_dump($bMargin);
854 854
 		$pageAfter = $pdf->getPage();
855 855
 		
@@ -874,7 +874,7 @@  discard block
 block discarded – undo
874 874
 				}
875 875
 			}
876 876
 			
877
-			if($total_to_print) {
877
+			if ($total_to_print) {
878 878
 				
879 879
 				if (GETPOST('hideInnerLines'))
880 880
 				{
@@ -888,7 +888,7 @@  discard block
 block discarded – undo
888 888
 				else
889 889
 				{
890 890
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
891
-                                        if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
891
+                                        if (get_class($object) == 'Facture' && $object->type == Facture::TYPE_SITUATION) {//Facture de situation
892 892
                                                 $total_to_print = $this->getTotalToPrintSituation($object, $line);
893 893
                                         } else {
894 894
                                             	$total_to_print = price($total);
@@ -902,11 +902,11 @@  discard block
 block discarded – undo
902 902
 			}
903 903
 
904 904
 			$pdf->SetXY($pdf->postotalht, $posy);
905
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
906
-			$pdf->MultiCell($pdf->page_largeur-$pdf->marge_droite-$pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
905
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
906
+			$pdf->MultiCell($pdf->page_largeur - $pdf->marge_droite - $pdf->postotalht, 3, $total_to_print, 0, 'R', 0);
907 907
 		}
908
-		else{
909
-			if($set_pagebreak_margin) $pdf->SetAutoPageBreak( $pageBreakOriginalValue , $bMargin);
908
+		else {
909
+			if ($set_pagebreak_margin) $pdf->SetAutoPageBreak($pageBreakOriginalValue, $bMargin);
910 910
 		}
911 911
 		
912 912
 		$posy = $posy + $cell_height;
@@ -926,22 +926,22 @@  discard block
 block discarded – undo
926 926
 	 * @param $w            float               width
927 927
 	 * @param $h            float               height
928 928
 	 */
929
-	function pdf_add_title(&$pdf,&$object, &$line, $label, $description,$posx, $posy, $w, $h) {
929
+	function pdf_add_title(&$pdf, &$object, &$line, $label, $description, $posx, $posy, $w, $h) {
930 930
 		
931
-		global $db,$conf,$subtotal_last_title_posy;
931
+		global $db, $conf, $subtotal_last_title_posy;
932 932
 		
933 933
 		$subtotal_last_title_posy = $posy;
934
-		$pdf->SetXY ($posx, $posy);
934
+		$pdf->SetXY($posx, $posy);
935 935
 		
936
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
936
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
937 937
 		
938 938
 		
939 939
  
940
-		$style = ($line->qty==1) ? 'BU' : 'BUI';
940
+		$style = ($line->qty == 1) ? 'BU' : 'BUI';
941 941
 		if (!empty($conf->global->SUBTOTAL_TITLE_STYLE)) $style = $conf->global->SUBTOTAL_TITLE_STYLE;
942 942
 		
943
-		if($hideInnerLines) {
944
-			if($line->qty==1)$pdf->SetFont('', $style, 9);
943
+		if ($hideInnerLines) {
944
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9);
945 945
 			else 
946 946
 			{
947 947
 				if (!empty($conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES)) $style = $conf->global->SUBTOTAL_STYLE_TITRES_SI_LIGNES_CACHEES;
@@ -950,43 +950,43 @@  discard block
 block discarded – undo
950 950
 		}
951 951
 		else {
952 952
 
953
-			if($line->qty==1)$pdf->SetFont('', $style, 9); //TODO if super utile
953
+			if ($line->qty == 1)$pdf->SetFont('', $style, 9); //TODO if super utile
954 954
 			else $pdf->SetFont('', $style, 9);
955 955
 			
956 956
 		}
957 957
 		
958 958
 		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
959
-		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J',true); // et maintenant avec du HTML
959
+		else $pdf->writeHTMLCell($w, $h, $posx, $posy, $label, 0, 1, false, true, 'J', true); // et maintenant avec du HTML
960 960
 		
961
-		if($description && !$hidedesc) {
961
+		if ($description && !$hidedesc) {
962 962
 			$posy = $pdf->GetY();
963 963
 			
964 964
 			$pdf->SetFont('', '', 8);
965 965
 			
966
-			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J',true);
966
+			$pdf->writeHTMLCell($w, $h, $posx, $posy, $description, 0, 1, false, true, 'J', true);
967 967
 
968 968
 		}
969 969
 		
970 970
 	}
971 971
 
972
-	function pdf_writelinedesc_ref($parameters=array(), &$object, &$action='') {
972
+	function pdf_writelinedesc_ref($parameters = array(), &$object, &$action = '') {
973 973
 	// ultimate PDF hook O_o
974 974
 		
975
-		return $this->pdf_writelinedesc($parameters,$object,$action);
975
+		return $this->pdf_writelinedesc($parameters, $object, $action);
976 976
 		
977 977
 	}
978 978
 
979 979
 	function isModSubtotalLine(&$parameters, &$object) {
980 980
 		
981
-		if(is_array($parameters)) {
981
+		if (is_array($parameters)) {
982 982
 			$i = & $parameters['i'];	
983 983
 		}
984 984
 		else {
985
-			$i = (int)$parameters;
985
+			$i = (int) $parameters;
986 986
 		}
987 987
 		
988 988
 		
989
-		if($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) {
989
+		if ($object->lines[$i]->special_code == $this->module_number && $object->lines[$i]->product_type == 9) {
990 990
 			return true;
991 991
 		}
992 992
 		
@@ -994,43 +994,43 @@  discard block
 block discarded – undo
994 994
 		
995 995
 	}
996 996
 
997
-	function pdf_getlineqty($parameters=array(), &$object, &$action='') {
998
-		global $conf,$hideprices;
997
+	function pdf_getlineqty($parameters = array(), &$object, &$action = '') {
998
+		global $conf, $hideprices;
999 999
 		
1000
-		if($this->isModSubtotalLine($parameters,$object) ){
1000
+		if ($this->isModSubtotalLine($parameters, $object)) {
1001 1001
 			
1002 1002
 			$this->resprints = ' ';
1003 1003
 			
1004
-			if((float)DOL_VERSION<=3.6) {
1004
+			if ((float) DOL_VERSION <= 3.6) {
1005 1005
 				return '';
1006 1006
 			}
1007
-			else if((float)DOL_VERSION>=3.8) {
1007
+			else if ((float) DOL_VERSION >= 3.8) {
1008 1008
 				return 1;
1009 1009
 			}
1010 1010
 			
1011 1011
 		}
1012
-		elseif(!empty($hideprices)) {
1012
+		elseif (!empty($hideprices)) {
1013 1013
 			$this->resprints = $object->lines[$parameters['i']]->qty;
1014 1014
 			return 1;
1015 1015
 		}
1016 1016
 		elseif (!empty($conf->global->SUBTOTAL_IF_HIDE_PRICES_SHOW_QTY))
1017 1017
 		{
1018
-			$hideInnerLines = (int)GETPOST('hideInnerLines');
1019
-			$hidedetails = (int)GETPOST('hidedetails');
1018
+			$hideInnerLines = (int) GETPOST('hideInnerLines');
1019
+			$hidedetails = (int) GETPOST('hidedetails');
1020 1020
 			if (empty($hideInnerLines) && !empty($hidedetails))
1021 1021
 			{
1022 1022
 				$this->resprints = $object->lines[$parameters['i']]->qty;
1023 1023
 			}
1024 1024
 		}
1025 1025
 		
1026
-		if(is_array($parameters)) $i = & $parameters['i'];
1027
-		else $i = (int)$parameters;
1026
+		if (is_array($parameters)) $i = & $parameters['i'];
1027
+		else $i = (int) $parameters;
1028 1028
 
1029 1029
 		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)
1030 1030
 		
1031
-		if(empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1031
+		if (empty($object->lines[$i]->array_options)) $object->lines[$i]->fetch_optionals();
1032 1032
 
1033
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1033
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1034 1034
 		{
1035 1035
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1036 1036
 			{
@@ -1042,25 +1042,25 @@  discard block
 block discarded – undo
1042 1042
 		return 0;
1043 1043
 	}
1044 1044
 	
1045
-	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1045
+	function pdf_getlinetotalexcltax($parameters = array(), &$object, &$action = '') {
1046 1046
 		global $conf, $hideprices;
1047 1047
 		
1048
-		if($this->isModSubtotalLine($parameters,$object) ){
1048
+		if ($this->isModSubtotalLine($parameters, $object)) {
1049 1049
 			
1050 1050
 			$this->resprints = ' ';
1051 1051
 			
1052
-			if((float)DOL_VERSION<=3.6) {
1052
+			if ((float) DOL_VERSION <= 3.6) {
1053 1053
 				return '';
1054 1054
 			}
1055
-			else if((float)DOL_VERSION>=3.8) {
1055
+			else if ((float) DOL_VERSION >= 3.8) {
1056 1056
 				return 1;
1057 1057
 			}
1058 1058
 			
1059 1059
 		}
1060 1060
 		elseif (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS))
1061 1061
 		{
1062
-			if(is_array($parameters)) $i = & $parameters['i'];
1063
-			else $i = (int)$parameters;
1062
+			if (is_array($parameters)) $i = & $parameters['i'];
1063
+			else $i = (int) $parameters;
1064 1064
 			
1065 1065
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1066 1066
 			{
@@ -1081,13 +1081,13 @@  discard block
 block discarded – undo
1081 1081
 				}
1082 1082
 			}
1083 1083
 		}
1084
-		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1085
-		    if(is_array($parameters)) $i = & $parameters['i'];
1086
-		    else $i = (int)$parameters;
1084
+		if ((int) GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)) {
1085
+		    if (is_array($parameters)) $i = & $parameters['i'];
1086
+		    else $i = (int) $parameters;
1087 1087
 		    $this->resprints = price($object->lines[$i]->total_ht);
1088 1088
 		}
1089 1089
 		if (!empty($hideprices)
1090
-		    || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1090
+		    || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1091 1091
 		    )
1092 1092
 		{
1093 1093
 		    if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1100,25 +1100,25 @@  discard block
 block discarded – undo
1100 1100
 		return 0;
1101 1101
 	}
1102 1102
 	
1103
-	function pdf_getlinetotalwithtax($parameters=array(), &$object, &$action='') {
1103
+	function pdf_getlinetotalwithtax($parameters = array(), &$object, &$action = '') {
1104 1104
 		global $conf;
1105 1105
 		
1106
-		if($this->isModSubtotalLine($parameters,$object) ){
1106
+		if ($this->isModSubtotalLine($parameters, $object)) {
1107 1107
 			
1108 1108
 			$this->resprints = ' ';
1109 1109
 		
1110
-			if((float)DOL_VERSION<=3.6) {
1110
+			if ((float) DOL_VERSION <= 3.6) {
1111 1111
 				return '';
1112 1112
 			}
1113
-			else if((float)DOL_VERSION>=3.8) {
1113
+			else if ((float) DOL_VERSION >= 3.8) {
1114 1114
 				return 1;
1115 1115
 			}
1116 1116
 		}
1117 1117
 		
1118
-		if(is_array($parameters)) $i = & $parameters['i'];
1119
-		else $i = (int)$parameters;
1118
+		if (is_array($parameters)) $i = & $parameters['i'];
1119
+		else $i = (int) $parameters;
1120 1120
 		
1121
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) ) 
1121
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))) 
1122 1122
 		{
1123 1123
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1124 1124
 			{
@@ -1130,24 +1130,24 @@  discard block
 block discarded – undo
1130 1130
 		return 0;
1131 1131
 	}
1132 1132
 	
1133
-	function pdf_getlineunit($parameters=array(), &$object, &$action='') {
1133
+	function pdf_getlineunit($parameters = array(), &$object, &$action = '') {
1134 1134
 		global $conf;
1135 1135
 		
1136
-		if($this->isModSubtotalLine($parameters,$object) ){
1136
+		if ($this->isModSubtotalLine($parameters, $object)) {
1137 1137
 			$this->resprints = ' ';
1138 1138
 		
1139
-			if((float)DOL_VERSION<=3.6) {
1139
+			if ((float) DOL_VERSION <= 3.6) {
1140 1140
 				return '';
1141 1141
 			}
1142
-			else if((float)DOL_VERSION>=3.8) {
1142
+			else if ((float) DOL_VERSION >= 3.8) {
1143 1143
 				return 1;
1144 1144
 			}
1145 1145
 		}
1146 1146
 		
1147
-		if(is_array($parameters)) $i = & $parameters['i'];
1148
-		else $i = (int)$parameters;
1147
+		if (is_array($parameters)) $i = & $parameters['i'];
1148
+		else $i = (int) $parameters;
1149 1149
 			
1150
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1150
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1151 1151
 		{
1152 1152
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1153 1153
 			{
@@ -1159,24 +1159,24 @@  discard block
 block discarded – undo
1159 1159
 		return 0;
1160 1160
 	}
1161 1161
 	
1162
-	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1163
-		global $conf,$hideprices;
1162
+	function pdf_getlineupexcltax($parameters = array(), &$object, &$action = '') {
1163
+		global $conf, $hideprices;
1164 1164
 
1165
-		if($this->isModSubtotalLine($parameters,$object) ){
1165
+		if ($this->isModSubtotalLine($parameters, $object)) {
1166 1166
 			$this->resprints = ' ';
1167 1167
 		
1168
-			if((float)DOL_VERSION<=3.6) {
1168
+			if ((float) DOL_VERSION <= 3.6) {
1169 1169
 				return '';
1170 1170
 			}
1171
-			else if((float)DOL_VERSION>=3.8) {
1171
+			else if ((float) DOL_VERSION >= 3.8) {
1172 1172
 				return 1;
1173 1173
 			}
1174 1174
 		}
1175
-		if(is_array($parameters)) $i = & $parameters['i'];
1176
-		else $i = (int)$parameters;
1175
+		if (is_array($parameters)) $i = & $parameters['i'];
1176
+		else $i = (int) $parameters;
1177 1177
 		
1178 1178
 		if (!empty($hideprices) 
1179
-				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1179
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1180 1180
 		)
1181 1181
 		{
1182 1182
 			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1189,24 +1189,24 @@  discard block
 block discarded – undo
1189 1189
 		return 0;
1190 1190
 	}
1191 1191
 	
1192
-	function pdf_getlineupwithtax($parameters=array(), &$object, &$action='') {
1193
-		global $conf,$hideprices;
1192
+	function pdf_getlineupwithtax($parameters = array(), &$object, &$action = '') {
1193
+		global $conf, $hideprices;
1194 1194
 		
1195
-		if($this->isModSubtotalLine($parameters,$object) ){
1195
+		if ($this->isModSubtotalLine($parameters, $object)) {
1196 1196
 			$this->resprints = ' ';
1197
-			if((float)DOL_VERSION<=3.6) {
1197
+			if ((float) DOL_VERSION <= 3.6) {
1198 1198
 				return '';
1199 1199
 			}
1200
-			else if((float)DOL_VERSION>=3.8) {
1200
+			else if ((float) DOL_VERSION >= 3.8) {
1201 1201
 				return 1;
1202 1202
 			}
1203 1203
 		}
1204 1204
 		
1205
-		if(is_array($parameters)) $i = & $parameters['i'];
1206
-		else $i = (int)$parameters;
1205
+		if (is_array($parameters)) $i = & $parameters['i'];
1206
+		else $i = (int) $parameters;
1207 1207
 			
1208 1208
 		if (!empty($hideprices)
1209
-				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1209
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1210 1210
 		)
1211 1211
 		{
1212 1212
 			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
@@ -1219,27 +1219,27 @@  discard block
 block discarded – undo
1219 1219
 		return 0;
1220 1220
 	}
1221 1221
 	
1222
-	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
1222
+	function pdf_getlinevatrate($parameters = array(), &$object, &$action = '') {
1223 1223
 		global $conf;
1224 1224
 		
1225
-		if($this->isModSubtotalLine($parameters,$object) ){
1225
+		if ($this->isModSubtotalLine($parameters, $object)) {
1226 1226
 			$this->resprints = ' ';
1227 1227
 			
1228
-			if((float)DOL_VERSION<=3.6) {
1228
+			if ((float) DOL_VERSION <= 3.6) {
1229 1229
 				return '';
1230 1230
 			}
1231
-			else if((float)DOL_VERSION>=3.8) {
1231
+			else if ((float) DOL_VERSION >= 3.8) {
1232 1232
 				return 1;
1233 1233
 			}
1234 1234
 		}
1235 1235
 		
1236
-		if(is_array($parameters)) $i = & $parameters['i'];
1237
-		else $i = (int)$parameters;
1236
+		if (is_array($parameters)) $i = & $parameters['i'];
1237
+		else $i = (int) $parameters;
1238 1238
 		
1239 1239
 		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)
1240 1240
 
1241 1241
 		$object->lines[$i]->fetch_optionals();
1242
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1242
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1243 1243
 		{
1244 1244
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1245 1245
 			{
@@ -1251,23 +1251,23 @@  discard block
 block discarded – undo
1251 1251
 		return 0;
1252 1252
 	}
1253 1253
 		
1254
-	function pdf_getlineprogress($parameters=array(), &$object, &$action) {
1254
+	function pdf_getlineprogress($parameters = array(), &$object, &$action) {
1255 1255
 		global $conf;
1256 1256
 		
1257
-		if($this->isModSubtotalLine($parameters,$object) ){
1257
+		if ($this->isModSubtotalLine($parameters, $object)) {
1258 1258
 			$this->resprints = ' ';
1259
-			if((float)DOL_VERSION<=3.6) {
1259
+			if ((float) DOL_VERSION <= 3.6) {
1260 1260
 				return '';
1261 1261
 			}
1262
-			else if((float)DOL_VERSION>=3.8) {
1262
+			else if ((float) DOL_VERSION >= 3.8) {
1263 1263
 				return 1;
1264 1264
 			}
1265 1265
 		}
1266 1266
 		
1267
-		if(is_array($parameters)) $i = & $parameters['i'];
1268
-		else $i = (int)$parameters;
1267
+		if (is_array($parameters)) $i = & $parameters['i'];
1268
+		else $i = (int) $parameters;
1269 1269
 			
1270
-		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1270
+		if (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])))
1271 1271
 		{
1272 1272
 			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1273 1273
 			{
@@ -1282,12 +1282,12 @@  discard block
 block discarded – undo
1282 1282
 	function add_numerotation(&$object) {
1283 1283
 		global $conf;
1284 1284
 		
1285
-		if(!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1285
+		if (!empty($conf->global->SUBTOTAL_USE_NUMEROTATION)) {
1286 1286
 		
1287 1287
 			$TLevelTitre = array();
1288 1288
 			$prevlevel = 0;
1289 1289
 		
1290
-			foreach($object->lines as $k=>&$line) 
1290
+			foreach ($object->lines as $k=>&$line) 
1291 1291
 			{
1292 1292
 				if ($line->id > 0 && $this->isModSubtotalLine($k, $object) && $line->qty <= 10)
1293 1293
 				{
@@ -1301,12 +1301,12 @@  discard block
 block discarded – undo
1301 1301
 	}
1302 1302
 
1303 1303
 	// TODO ne gère pas encore la numération des lignes "Totaux"
1304
-	private function formatNumerotation(&$TLineTitle, $line_reference='', $level=1, $prefix_num=0)
1304
+	private function formatNumerotation(&$TLineTitle, $line_reference = '', $level = 1, $prefix_num = 0)
1305 1305
 	{
1306 1306
 		$TTitle = array();
1307 1307
 		
1308
-		$i=1;
1309
-		$j=0;
1308
+		$i = 1;
1309
+		$j = 0;
1310 1310
 		foreach ($TLineTitle as $k => &$line)
1311 1311
 		{
1312 1312
 			if (!empty($line_reference) && $line->rang <= $line_reference->rang) continue;
@@ -1316,7 +1316,7 @@  discard block
 block discarded – undo
1316 1316
 			{
1317 1317
 				$TTitle[$j]['numerotation'] = ($prefix_num == 0) ? $i : $prefix_num.'.'.$i;
1318 1318
 				//var_dump('Prefix == '.$prefix_num.' // '.$line->desc.' ==> numerotation == '.$TTitle[$j]['numerotation'].'   ###    '.$line->qty .'=='. $level);
1319
-				if (empty($line->label) && (float)DOL_VERSION < 6)
1319
+				if (empty($line->label) && (float) DOL_VERSION < 6)
1320 1320
 				{
1321 1321
 					$line->label = !empty($line->desc) ? $line->desc : $line->description;
1322 1322
 					$line->desc = $line->description = '';
@@ -1342,26 +1342,26 @@  discard block
 block discarded – undo
1342 1342
 	
1343 1343
 	function setDocTVA(&$pdf, &$object) {
1344 1344
 		
1345
-		$hidedetails = (int)GETPOST('hidedetails');
1345
+		$hidedetails = (int) GETPOST('hidedetails');
1346 1346
 		
1347
-		if(empty($hidedetails)) return false;
1347
+		if (empty($hidedetails)) return false;
1348 1348
 		
1349 1349
 		// TODO can't add VAT to document without lines... :-/
1350 1350
 		
1351 1351
 		return true;
1352 1352
 	}
1353 1353
 	
1354
-	function beforePDFCreation($parameters=array(), &$object, &$action)
1354
+	function beforePDFCreation($parameters = array(), &$object, &$action)
1355 1355
 	{
1356 1356
 		/**
1357 1357
 		 * @var $pdf    TCPDF
1358 1358
 		 */
1359
-		global $pdf,$conf, $langs;
1359
+		global $pdf, $conf, $langs;
1360 1360
 
1361 1361
 		// var_dump($object->lines);
1362 1362
 		dol_include_once('/subtotal/class/subtotal.class.php');
1363 1363
 
1364
-		foreach($parameters as $key=>$value) {
1364
+		foreach ($parameters as $key=>$value) {
1365 1365
 			${$key} = $value;
1366 1366
 		}
1367 1367
 		
@@ -1370,25 +1370,25 @@  discard block
 block discarded – undo
1370 1370
 		$this->add_numerotation($object);	
1371 1371
 		
1372 1372
 		
1373
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1374
-		$hidedetails = (int)GETPOST('hidedetails');
1373
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1374
+		$hidedetails = (int) GETPOST('hidedetails');
1375 1375
 		
1376 1376
 		if ($hideInnerLines) { // si c une ligne de titre
1377
-	    	$fk_parent_line=0;
1378
-			$TLines =array();
1377
+	    	$fk_parent_line = 0;
1378
+			$TLines = array();
1379 1379
 		
1380
-			$original_count=count($object->lines);
1380
+			$original_count = count($object->lines);
1381 1381
 		    $TTvas = array(); // tableau de tva
1382 1382
 		    
1383
-			foreach($object->lines as $k=>&$line) 
1383
+			foreach ($object->lines as $k=>&$line) 
1384 1384
 			{
1385 1385
 			    
1386
-				if($line->product_type==9 && $line->rowid>0) 
1386
+				if ($line->product_type == 9 && $line->rowid > 0) 
1387 1387
 				{
1388 1388
 					$fk_parent_line = $line->rowid;
1389 1389
 					
1390 1390
 					// 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
1391
-					if(TSubtotal::isSubtotal($line)) 
1391
+					if (TSubtotal::isSubtotal($line)) 
1392 1392
 					{
1393 1393
 						/*$total = $this->getTotalLineFromObject($object, $line, '');
1394 1394
 						
@@ -1408,22 +1408,22 @@  discard block
 block discarded – undo
1408 1408
 			
1409 1409
 				if ($hideInnerLines)
1410 1410
 				{
1411
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1411
+				    if (!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1412 1412
 				    {
1413
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1413
+				        if ($line->tva_tx != '0.000' && $line->product_type != 9) {
1414 1414
 				            
1415 1415
     				        // on remplit le tableau de tva pour substituer les lignes cachées
1416 1416
     				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1417 1417
     				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1418 1418
     				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1419 1419
     				    }
1420
-    					if($line->product_type==9 && $line->rowid>0)
1420
+    					if ($line->product_type == 9 && $line->rowid > 0)
1421 1421
     					{
1422 1422
     					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1423 1423
     					    // génère des lignes d'affichage des montants HT soumis à tva
1424 1424
     					    $nbtva = count($TTvas);
1425
-    					    if(!empty($nbtva)){
1426
-    					        foreach ($TTvas as $tx =>$val){
1425
+    					    if (!empty($nbtva)) {
1426
+    					        foreach ($TTvas as $tx =>$val) {
1427 1427
     					            $l = clone $line;
1428 1428
     					            $l->product_type = 1;
1429 1429
     					            $l->special_code = '';
@@ -1444,7 +1444,7 @@  discard block
 block discarded – undo
1444 1444
     					}
1445 1445
 				    } else {
1446 1446
 				        
1447
-				        if($line->product_type==9 && $line->rowid>0)
1447
+				        if ($line->product_type == 9 && $line->rowid > 0)
1448 1448
 				        {
1449 1449
 				            // ajoute la ligne de sous-total
1450 1450
 				            $TLines[] = $line; 
@@ -1472,9 +1472,9 @@  discard block
 block discarded – undo
1472 1472
 			
1473 1473
 			// cas incongru où il y aurait des produits en dessous du dernier sous-total
1474 1474
 			$nbtva = count($TTvas);
1475
-			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1475
+			if (!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1476 1476
 			{
1477
-			    foreach ($TTvas as $tx =>$val){
1477
+			    foreach ($TTvas as $tx =>$val) {
1478 1478
 			        $l = clone $line;
1479 1479
 			        $l->product_type = 1;
1480 1480
 			        $l->special_code = '';
@@ -1491,11 +1491,11 @@  discard block
 block discarded – undo
1491 1491
 			}
1492 1492
 			
1493 1493
 			global $nblignes;
1494
-			$nblignes=count($TLines);
1494
+			$nblignes = count($TLines);
1495 1495
 
1496 1496
 			$object->lines = $TLines;
1497 1497
 			
1498
-			if($i>count($object->lines)) {
1498
+			if ($i > count($object->lines)) {
1499 1499
 				$this->resprints = '';
1500 1500
 				return 0;
1501 1501
 			}
@@ -1504,59 +1504,59 @@  discard block
 block discarded – undo
1504 1504
 		return 0;
1505 1505
 	}
1506 1506
 
1507
-	function pdf_writelinedesc($parameters=array(), &$object, &$action)
1507
+	function pdf_writelinedesc($parameters = array(), &$object, &$action)
1508 1508
 	{
1509 1509
 		/**
1510 1510
 		 * @var $pdf    TCPDF
1511 1511
 		 */
1512
-		global $pdf,$conf;
1512
+		global $pdf, $conf;
1513 1513
 
1514
-		foreach($parameters as $key=>$value) {
1514
+		foreach ($parameters as $key=>$value) {
1515 1515
 			${$key} = $value;
1516 1516
 		}
1517 1517
 		
1518
-		$hideInnerLines = (int)GETPOST('hideInnerLines');
1519
-		$hidedetails = (int)GETPOST('hidedetails');
1518
+		$hideInnerLines = (int) GETPOST('hideInnerLines');
1519
+		$hidedetails = (int) GETPOST('hidedetails');
1520 1520
 		
1521
-		if($this->isModSubtotalLine($parameters,$object) ){			
1521
+		if ($this->isModSubtotalLine($parameters, $object)) {			
1522 1522
 		
1523 1523
 				global $hideprices;
1524 1524
 				
1525
-				if(!empty($hideprices)) {
1526
-					foreach($object->lines as &$line) {
1527
-						if($line->fk_product_type!=9) $line->fk_parent_line = -1;	
1525
+				if (!empty($hideprices)) {
1526
+					foreach ($object->lines as &$line) {
1527
+						if ($line->fk_product_type != 9) $line->fk_parent_line = -1;	
1528 1528
 					}
1529 1529
 				}
1530 1530
 			
1531 1531
 				$line = &$object->lines[$i];
1532 1532
 				
1533
-				if($line->info_bits>0) { // PAGE BREAK
1533
+				if ($line->info_bits > 0) { // PAGE BREAK
1534 1534
 					$pdf->addPage();
1535 1535
 					$posy = $pdf->GetY();
1536 1536
 				}
1537 1537
 				
1538 1538
 				$label = $line->label;
1539
-				$description= !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1539
+				$description = !empty($line->desc) ? $outputlangs->convToOutputCharset($line->desc) : $outputlangs->convToOutputCharset($line->description);
1540 1540
 				
1541
-				if(empty($label)) {
1541
+				if (empty($label)) {
1542 1542
 					$label = $description;
1543
-					$description='';
1543
+					$description = '';
1544 1544
 				}
1545 1545
 				
1546
-				if($line->qty>90) {
1546
+				if ($line->qty > 90) {
1547 1547
 					
1548 1548
 					if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)	$label .= ' '.$this->getTitle($object, $line);
1549 1549
 					
1550 1550
 					$pageBefore = $pdf->getPage();
1551
-					$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1551
+					$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1552 1552
 					$pageAfter = $pdf->getPage();	
1553 1553
 
1554
-					if($pageAfter>$pageBefore) {
1554
+					if ($pageAfter > $pageBefore) {
1555 1555
 						//print "ST $pageAfter>$pageBefore<br>";
1556 1556
 						$pdf->rollbackTransaction(true);	
1557
-						$pdf->addPage('','', true);
1557
+						$pdf->addPage('', '', true);
1558 1558
 						$posy = $pdf->GetY();
1559
-						$this->pdf_add_total($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h);
1559
+						$this->pdf_add_total($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h);
1560 1560
 						$posy = $pdf->GetY();
1561 1561
 						//print 'add ST'.$pdf->getPage().'<br />';
1562 1562
 					}
@@ -1567,7 +1567,7 @@  discard block
 block discarded – undo
1567 1567
 				else if ($line->qty < 10) {
1568 1568
 					$pageBefore = $pdf->getPage();
1569 1569
 
1570
-					$this->pdf_add_title($pdf,$object, $line, $label, $description,$posx, $posy, $w, $h); 
1570
+					$this->pdf_add_title($pdf, $object, $line, $label, $description, $posx, $posy, $w, $h); 
1571 1571
 					$pageAfter = $pdf->getPage();	
1572 1572
 
1573 1573
 					
@@ -1642,9 +1642,9 @@  discard block
 block discarded – undo
1642 1642
 	 * @param $hookmanager  HookManager
1643 1643
 	 * @return int
1644 1644
 	 */
1645
-	function printObjectLine ($parameters, &$object, &$action, $hookmanager){
1645
+	function printObjectLine($parameters, &$object, &$action, $hookmanager) {
1646 1646
 		
1647
-		global $conf,$langs,$user,$db,$bc;
1647
+		global $conf, $langs, $user, $db, $bc;
1648 1648
 		
1649 1649
 		$num = &$parameters['num'];
1650 1650
 		$line = &$parameters['line'];
@@ -1652,32 +1652,32 @@  discard block
 block discarded – undo
1652 1652
 		
1653 1653
 		$var = &$parameters['var'];
1654 1654
 
1655
-		$contexts = explode(':',$parameters['context']);
1655
+		$contexts = explode(':', $parameters['context']);
1656 1656
 
1657 1657
 		$createRight = $user->rights->{$object->element}->creer;
1658
-		if($object->element == 'facturerec' )
1658
+		if ($object->element == 'facturerec')
1659 1659
 		{
1660 1660
 			$object->statut = 0; // hack for facture rec
1661 1661
 			$createRight = $user->rights->facture->creer;
1662 1662
 		}
1663
-		elseif($object->element == 'order_supplier' )
1663
+		elseif ($object->element == 'order_supplier')
1664 1664
 		{
1665 1665
 		    $createRight = $user->rights->fournisseur->commande->creer;
1666 1666
 		}
1667
-		elseif($object->element == 'invoice_supplier' )
1667
+		elseif ($object->element == 'invoice_supplier')
1668 1668
 		{
1669 1669
 		    $createRight = $user->rights->fournisseur->facture->creer;
1670 1670
 		}
1671 1671
 		
1672
-		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1672
+		if ($line->special_code != $this->module_number || $line->product_type != 9) {
1673 1673
 			null;
1674 1674
 		}	
1675
-		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)) 
1675
+		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)) 
1676 1676
         {
1677
-			if($object->element=='facture')$idvar = 'facid';
1678
-			else $idvar='id';
1677
+			if ($object->element == 'facture')$idvar = 'facid';
1678
+			else $idvar = 'id';
1679 1679
 			
1680
-			if((float)DOL_VERSION <= 3.4)
1680
+			if ((float) DOL_VERSION <= 3.4)
1681 1681
 			{
1682 1682
 				?>
1683 1683
 				<script type="text/javascript">
@@ -1701,20 +1701,20 @@  discard block
 block discarded – undo
1701 1701
 				<?php
1702 1702
 			}
1703 1703
 			
1704
-			if(empty($line->description)) $line->description = $line->desc;
1704
+			if (empty($line->description)) $line->description = $line->desc;
1705 1705
 			
1706 1706
 			$colspan = 5;
1707
-			if($object->element == 'facturerec' ) $colspan = 3;
1708
-			if($object->element == 'order_supplier') $colspan = 3;
1709
-			if($object->element == 'invoice_supplier') $colspan = 4;
1710
-			if($object->element == 'supplier_proposal') $colspan = 4;
1711
-			if(!empty($conf->multicurrency->enabled)) $colspan+=2;
1712
-			if($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1713
-			if(!empty($conf->margin->enabled)) $colspan++;
1714
-			if(!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1715
-			if(!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1716
-			if($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1717
-			if(!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
1707
+			if ($object->element == 'facturerec') $colspan = 3;
1708
+			if ($object->element == 'order_supplier') $colspan = 3;
1709
+			if ($object->element == 'invoice_supplier') $colspan = 4;
1710
+			if ($object->element == 'supplier_proposal') $colspan = 4;
1711
+			if (!empty($conf->multicurrency->enabled)) $colspan += 2;
1712
+			if ($object->element == 'commande' && $object->statut < 3 && !empty($conf->shippableorder->enabled)) $colspan++;
1713
+			if (!empty($conf->margin->enabled)) $colspan++;
1714
+			if (!empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
1715
+			if (!empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
1716
+			if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION) $colspan++;
1717
+			if (!empty($conf->global->PRODUCT_USE_UNITS)) $colspan++;
1718 1718
 					
1719 1719
 			/* Titre */
1720 1720
 			//var_dump($line);
@@ -1724,35 +1724,35 @@  discard block
 block discarded – undo
1724 1724
             
1725 1725
 			
1726 1726
 			?>
1727
-			<tr <?php echo $bc[$var]; $var=!$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
1727
+			<tr <?php echo $bc[$var]; $var = !$var; echo $data; ?> rel="subtotal" id="row-<?php echo $line->id ?>" style="<?php
1728 1728
 					if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT))
1729 1729
 					{
1730
-						if($line->qty==99) print 'background:#adadcf';
1731
-						else if($line->qty==98) print 'background:#ddddff;';
1732
-						else if($line->qty<=97 && $line->qty>=91) print 'background:#eeeeff;';
1733
-						else if($line->qty==1) print 'background:#adadcf;';
1734
-						else if($line->qty==2) print 'background:#ddddff;';
1735
-						else if($line->qty==50) print '';
1730
+						if ($line->qty == 99) print 'background:#adadcf';
1731
+						else if ($line->qty == 98) print 'background:#ddddff;';
1732
+						else if ($line->qty <= 97 && $line->qty >= 91) print 'background:#eeeeff;';
1733
+						else if ($line->qty == 1) print 'background:#adadcf;';
1734
+						else if ($line->qty == 2) print 'background:#ddddff;';
1735
+						else if ($line->qty == 50) print '';
1736 1736
 						else print 'background:#eeeeff;';
1737 1737
 
1738 1738
 						//A compléter si on veux plus de nuances de couleurs avec les niveau 4,5,6,7,8 et 9
1739 1739
 					}
1740 1740
 					else 
1741 1741
 					{
1742
-						if($line->qty==99) print 'background:#ddffdd';
1743
-						else if($line->qty==98) print 'background:#ddddff;';
1744
-						else if($line->qty==2) print 'background:#eeeeff; ';
1745
-						else if($line->qty==50) print '';
1746
-						else print 'background:#eeffee;' ;
1742
+						if ($line->qty == 99) print 'background:#ddffdd';
1743
+						else if ($line->qty == 98) print 'background:#ddddff;';
1744
+						else if ($line->qty == 2) print 'background:#eeeeff; ';
1745
+						else if ($line->qty == 50) print '';
1746
+						else print 'background:#eeffee;';
1747 1747
 					}
1748 1748
 
1749 1749
 			?>;">
1750 1750
 			
1751
-				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty>90)?'text-align:right':'' ?> "><?php
1752
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
1751
+				<td colspan="<?php echo $colspan; ?>" style="<?php TSubtotal::isFreeText($line) ? '' : 'font-weight:bold;'; ?>  <?php echo ($line->qty > 90) ? 'text-align:right' : '' ?> "><?php
1752
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
1753 1753
 
1754
-						$params=array('line'=>$line);
1755
-						$reshook=$hookmanager->executeHooks('formEditProductOptions',$params,$object,$action);
1754
+						$params = array('line'=>$line);
1755
+						$reshook = $hookmanager->executeHooks('formEditProductOptions', $params, $object, $action);
1756 1756
 						
1757 1757
 						echo '<div id="line_'.$line->id.'"></div>'; // Imitation Dolibarr
1758 1758
 						echo '<input type="hidden" value="'.$line->id.'" name="lineid">';
@@ -1760,7 +1760,7 @@  discard block
 block discarded – undo
1760 1760
 						echo '<input id="product_id" type="hidden" value="'.$line->fk_product.'" name="type">';
1761 1761
 						echo '<input id="special_code" type="hidden" value="'.$line->special_code.'" name="type">';
1762 1762
 
1763
-						$isFreeText=false;
1763
+						$isFreeText = false;
1764 1764
 						if (TSubtotal::isTitle($line))
1765 1765
 						{
1766 1766
 							$qty_displayed = $line->qty;
@@ -1782,13 +1782,13 @@  discard block
 block discarded – undo
1782 1782
 						    $line->description = '';
1783 1783
 						}
1784 1784
 						$newlabel = $line->label;
1785
-						if($line->label=='' && !$isFreeText) {
1786
-							if(TSubtotal::isSubtotal($line)) {
1785
+						if ($line->label == '' && !$isFreeText) {
1786
+							if (TSubtotal::isSubtotal($line)) {
1787 1787
 								$newlabel = $line->description.' '.$this->getTitle($object, $line);
1788
-								$line->description='';
1789
-							} elseif( (float)DOL_VERSION < 6 ) {
1790
-								$newlabel= $line->description;
1791
-								$line->description='';
1788
+								$line->description = '';
1789
+							} elseif ((float) DOL_VERSION < 6) {
1790
+								$newlabel = $line->description;
1791
+								$line->description = '';
1792 1792
 							}
1793 1793
 						}
1794 1794
 
@@ -1797,10 +1797,10 @@  discard block
 block discarded – undo
1797 1797
 						
1798 1798
 						if (!$isFreeText) echo '<input type="text" name="line-title" id-line="'.$line->id.'" value="'.$newlabel.'" size="80" '.$readonlyForSituation.'/>&nbsp;';
1799 1799
 						
1800
-						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) )
1800
+						if (!empty($conf->global->SUBTOTAL_USE_NEW_FORMAT) && (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)))
1801 1801
 						{
1802 1802
 							$select = '<select name="subtotal_level">';
1803
-							for ($j=1; $j<10; $j++)
1803
+							for ($j = 1; $j < 10; $j++)
1804 1804
 							{
1805 1805
 								if (!empty($readonlyForSituation)) {
1806 1806
 									if ($qty_displayed == $j) $select .= '<option selected="selected" value="'.$j.'">'.$langs->trans('Level').' '.$j.'</option>';
@@ -1813,7 +1813,7 @@  discard block
 block discarded – undo
1813 1813
 						
1814 1814
 
1815 1815
 						echo '<div class="subtotal_underline" style="margin-left:24px;">';
1816
-							echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label> <input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;&nbsp;';
1816
+							echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label> <input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '').' />&nbsp;&nbsp;';
1817 1817
 
1818 1818
 							if (TSubtotal::isTitle($line))
1819 1819
 							{
@@ -1831,9 +1831,9 @@  discard block
 block discarded – undo
1831 1831
 							else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
1832 1832
 						echo '</div>';
1833 1833
 
1834
-						if($line->qty<10) {
1834
+						if ($line->qty < 10) {
1835 1835
 							// WYSIWYG editor
1836
-							require_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
1836
+							require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
1837 1837
 							$nbrows = ROWS_2;
1838 1838
 							$cked_enabled = (!empty($conf->global->FCKEDITOR_ENABLE_DETAILS) ? $conf->global->FCKEDITOR_ENABLE_DETAILS : 0);
1839 1839
 							if (!empty($conf->global->MAIN_INPUT_DESC_HEIGHT)) {
@@ -1853,25 +1853,25 @@  discard block
 block discarded – undo
1853 1853
 
1854 1854
 						 if ($conf->global->SUBTOTAL_USE_NEW_FORMAT)
1855 1855
 						 {
1856
-							if(TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
1856
+							if (TSubtotal::isTitle($line) || TSubtotal::isSubtotal($line)) 
1857 1857
 							{
1858
-								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty-1);
1858
+								echo str_repeat('&nbsp;&nbsp;&nbsp;', $line->qty - 1);
1859 1859
 								
1860 1860
 								if (TSubtotal::isTitle($line)) print img_picto('', 'subtotal@subtotal').'<span style="font-size:9px;margin-left:-3px;">'.$line->qty.'</span>&nbsp;&nbsp;';
1861
-								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100-$line->qty).'</span>&nbsp;&nbsp;';
1861
+								else print img_picto('', 'subtotal2@subtotal').'<span style="font-size:9px;margin-left:-1px;">'.(100 - $line->qty).'</span>&nbsp;&nbsp;';
1862 1862
 							}
1863 1863
 						 }
1864 1864
 						 else 
1865 1865
 						 {
1866
-							if($line->qty<=1) print img_picto('', 'subtotal@subtotal');
1867
-							else if($line->qty==2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
1866
+							if ($line->qty <= 1) print img_picto('', 'subtotal@subtotal');
1867
+							else if ($line->qty == 2) print img_picto('', 'subsubtotal@subtotal').'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; 
1868 1868
 						 }
1869 1869
 						 
1870 1870
 						 
1871 1871
 						 // Get display styles and apply them
1872 1872
 						 $titleStyleItalic = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'I') === false ? '' : ' font-style: italic;';
1873
-						 $titleStyleBold =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
1874
-						 $titleStyleUnderline =  strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
1873
+						 $titleStyleBold = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'B') === false ? '' : ' font-weight:bold;';
1874
+						 $titleStyleUnderline = strpos($conf->global->SUBTOTAL_TITLE_STYLE, 'U') === false ? '' : ' text-decoration: underline;';
1875 1875
 						 
1876 1876
 						 if (empty($line->label)) {
1877 1877
 							if ($line->qty >= 91 && $line->qty <= 99 && $conf->global->SUBTOTAL_USE_NEW_FORMAT) print  $line->description.' '.$this->getTitle($object, $line);
@@ -1879,16 +1879,16 @@  discard block
 block discarded – undo
1879 1879
 						 } 
1880 1880
 						 else {
1881 1881
 
1882
-							if (! empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
1882
+							if (!empty($conf->global->PRODUIT_DESC_IN_FORM) && !empty($line->description)) {
1883 1883
 								print '<span class="subtotal_label" style="'.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" >'.$line->label.'</span><br><div class="subtotal_desc">'.dol_htmlentitiesbr($line->description).'</div>';
1884 1884
 							}
1885
-							else{
1885
+							else {
1886 1886
 								print '<span class="subtotal_label classfortooltip '.$titleStyleItalic.$titleStyleBold.$titleStyleUnderline.'" title="'.$line->description.'">'.$line->label.'</span>';    
1887 1887
 							}
1888 1888
 
1889 1889
 						 } 
1890
-						if($line->qty>90) print ' : ';
1891
-						if($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
1890
+						if ($line->qty > 90) print ' : ';
1891
+						if ($line->info_bits > 0) echo img_picto($langs->trans('Pagebreak'), 'pagebreak@subtotal');
1892 1892
 
1893 1893
 						 
1894 1894
 
@@ -1897,7 +1897,7 @@  discard block
 block discarded – undo
1897 1897
 			?></td>
1898 1898
 					 
1899 1899
 			<?php
1900
-				if($line->qty>90) {
1900
+				if ($line->qty > 90) {
1901 1901
 					/* Total */
1902 1902
 					$total_line = $this->getTotalLineFromObject($object, $line, '');
1903 1903
 					echo '<td class="nowrap liencolht" align="right" style="font-weight:bold;" rel="subtotal_total">'.price($total_line).'</td>';
@@ -1910,7 +1910,7 @@  discard block
 block discarded – undo
1910 1910
 				<?php
1911 1911
 				if ($action != 'selectlines') {
1912 1912
 				
1913
-					if($action=='editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line) ) {
1913
+					if ($action == 'editline' && GETPOST('lineid') == $line->id && TSubtotal::isModSubtotalLine($line)) {
1914 1914
 						?>
1915 1915
 						<input id="savelinebutton" class="button" type="submit" name="save" value="<?php echo $langs->trans('Save') ?>" />
1916 1916
 						<br />
@@ -1926,13 +1926,13 @@  discard block
 block discarded – undo
1926 1926
 						<?php
1927 1927
 						
1928 1928
 					}
1929
-					else{
1930
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
1929
+					else {
1930
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_BLOCK) && $object->element !== 'invoice_supplier')
1931 1931
 						{
1932
-							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) ) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'. img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
1932
+							if (TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref)) echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=duplicate&lineid='.$line->id.'">'.img_picto($langs->trans('Duplicate'), 'duplicate@subtotal').'</a>';
1933 1933
 						}
1934 1934
 
1935
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
1935
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_EDIT_BLOCK)) 
1936 1936
 						{
1937 1937
 							echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=editline&lineid='.$line->id.'">'.img_edit().'</a>';
1938 1938
 						}								
@@ -1947,7 +1947,7 @@  discard block
 block discarded – undo
1947 1947
 				<?php
1948 1948
 
1949 1949
 				if ($action != 'editline' && $action != 'selectlines') {
1950
-						if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
1950
+						if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_REMOVE_BLOCK))
1951 1951
 						{
1952 1952
 
1953 1953
 							if ($object->situation_counter == 1 || !$object->situation_cycle_ref)
@@ -1955,7 +1955,7 @@  discard block
 block discarded – undo
1955 1955
 								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteline&lineid='.$line->id.'">'.img_delete().'</a>';
1956 1956
 							}
1957 1957
 
1958
-							if(TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref) )
1958
+							if (TSubtotal::isTitle($line) && ($object->situation_counter == 1 || !$object->situation_cycle_ref))
1959 1959
 							{
1960 1960
 								$img_delete = ((float) DOL_VERSION >= 3.8) ? img_picto($langs->trans('deleteWithAllLines'), 'delete_all.3.8@subtotal') : img_picto($langs->trans('deleteWithAllLines'), 'delete_all@subtotal');
1961 1961
 								echo '<a href="'.$_SERVER['PHP_SELF'].'?'.$idvar.'='.$object->id.'&action=ask_deleteallline&lineid='.$line->id.'">'.$img_delete.'</a>';
@@ -1966,7 +1966,7 @@  discard block
 block discarded – undo
1966 1966
 			</td>
1967 1967
 			
1968 1968
 			<?php 
1969
-			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
1969
+			if ($object->statut == 0 && $createRight && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && TSubtotal::isTitle($line) && $action != 'editline')
1970 1970
 			{
1971 1971
 				echo '<td class="subtotal_nc">';
1972 1972
 				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"' : '').' />';
@@ -1977,11 +1977,11 @@  discard block
 block discarded – undo
1977 1977
 			<td align="center" class="tdlineupdown">
1978 1978
 			</td>
1979 1979
 			<?php } else { ?>
1980
-			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0  && $createRight ))?' class="tdlineupdown"':''); ?>></td>
1980
+			<td align="center"<?php echo ((empty($conf->browser->phone) && ($object->statut == 0 && $createRight)) ? ' class="tdlineupdown"' : ''); ?>></td>
1981 1981
 			<?php } ?>
1982 1982
 
1983
-			<?php  if($action == 'selectlines'){ // dolibarr 8 ?>
1984
-			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i+1; ?>]" value="<?php echo $line->id; ?>" ></td>
1983
+			<?php  if ($action == 'selectlines') { // dolibarr 8 ?>
1984
+			<td class="linecolcheck" align="center"><input type="checkbox" class="linecheckbox" name="line_checkbox[<?php echo $i + 1; ?>]" value="<?php echo $line->id; ?>" ></td>
1985 1985
 			<?php } ?>
1986 1986
 
1987 1987
 			</tr>
@@ -1989,29 +1989,29 @@  discard block
 block discarded – undo
1989 1989
 			
1990 1990
 			
1991 1991
 			// Affichage des extrafields à la Dolibarr (car sinon non affiché sur les titres)
1992
-			if(TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
1992
+			if (TSubtotal::isTitle($line) && !empty($conf->global->SUBTOTAL_ALLOW_EXTRAFIELDS_ON_TITLE)) {
1993 1993
 				
1994
-				require_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
1994
+				require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
1995 1995
 				
1996 1996
 				// Extrafields
1997 1997
 				$extrafieldsline = new ExtraFields($db);
1998 1998
 				$extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line);
1999 1999
 				
2000
-				$colspan+=3; $mode = 'view';
2001
-				if($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2000
+				$colspan += 3; $mode = 'view';
2001
+				if ($action === 'editline' && $line->rowid == GETPOST('lineid')) $mode = 'edit';
2002 2002
 				
2003 2003
 				$ex_element = $line->element;
2004 2004
 				$line->element = 'tr_extrafield_title '.$line->element; // Pour pouvoir manipuler ces tr
2005
-				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ','colspan'=>$colspan));
2005
+				print $line->showOptionals($extrafieldsline, $mode, array('style'=>' style="background:#eeffee;" ', 'colspan'=>$colspan));
2006 2006
 				$isExtraSelected = false;
2007
-				foreach($line->array_options as $option) {
2008
-					if(!empty($option) && $option != "-1") {
2007
+				foreach ($line->array_options as $option) {
2008
+					if (!empty($option) && $option != "-1") {
2009 2009
 						$isExtraSelected = true;
2010 2010
 						break;
2011 2011
 					}
2012 2012
 				}
2013 2013
 				
2014
-				if($mode === 'edit') {
2014
+				if ($mode === 'edit') {
2015 2015
 					?>
2016 2016
 					<script>
2017 2017
 						$(document).ready(function(){
@@ -2019,7 +2019,7 @@  discard block
 block discarded – undo
2019 2019
 							var all_tr_extrafields = $("tr.tr_extrafield_title");
2020 2020
 							<?php 
2021 2021
 							// Si un extrafield est rempli alors on affiche directement les extrafields
2022
-							if(!$isExtraSelected) {
2022
+							if (!$isExtraSelected) {
2023 2023
 								echo 'all_tr_extrafields.hide();';
2024 2024
 								echo 'var trad = "'.$langs->trans('showExtrafields').'";';
2025 2025
 								echo 'var extra = 0;';
@@ -2065,20 +2065,20 @@  discard block
 block discarded – undo
2065 2065
 
2066 2066
 	
2067 2067
 	function addMoreActionsButtons($parameters, &$object, &$action, $hookmanager) {
2068
-		global $conf,$langs;
2068
+		global $conf, $langs;
2069 2069
 		 
2070 2070
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2071 2071
 		{
2072 2072
 		    
2073
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2073
+		    if ($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2074 2074
 		    {
2075 2075
 		        foreach ($object->lines as $line)
2076 2076
 		        {
2077 2077
 		            // fetch optionals attributes and labels
2078 2078
 		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2079
-		            $extrafields=new ExtraFields($this->db);
2080
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2081
-		            $line->fetch_optionals($line->id,$extralabels);
2079
+		            $extrafields = new ExtraFields($this->db);
2080
+		            $extralabels = $extrafields->fetch_name_optionals_label($object->table_element_line, true);
2081
+		            $line->fetch_optionals($line->id, $extralabels);
2082 2082
 		        }
2083 2083
 		    }
2084 2084
 		    
@@ -2178,23 +2178,23 @@  discard block
 block discarded – undo
2178 2178
 	    $ThtmlData['data-qty']          = 0; //$line->qty;
2179 2179
 	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2180 2180
 	    
2181
-	    if(TSubtotal::isTitle($line)){
2181
+	    if (TSubtotal::isTitle($line)) {
2182 2182
 	        $ThtmlData['data-issubtotal'] = 'title';
2183
-	    }elseif(TSubtotal::isSubtotal($line)){
2183
+	    }elseif (TSubtotal::isSubtotal($line)) {
2184 2184
 	        $ThtmlData['data-issubtotal'] = 'subtotal';
2185 2185
 	    }
2186
-	    else{
2186
+	    else {
2187 2187
 	        $ThtmlData['data-issubtotal'] = 'freetext';
2188 2188
 	    }
2189 2189
 	    
2190 2190
 	    
2191 2191
 	    // Change or add data  from hooks
2192
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2192
+	    $parameters = array_replace($parameters, array('ThtmlData' => $ThtmlData));
2193 2193
 	    
2194 2194
 	    // hook 
2195
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2195
+	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
2196 2196
 	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2197
-	    if ($reshook>0)
2197
+	    if ($reshook > 0)
2198 2198
 	    {
2199 2199
 	        $ThtmlData = $hookmanager->resArray;
2200 2200
 	    }
@@ -2207,14 +2207,14 @@  discard block
 block discarded – undo
2207 2207
 	function implodeHtmlData($ThtmlData = array())
2208 2208
 	{
2209 2209
 	    $data = '';
2210
-	    foreach($ThtmlData as $k => $h )
2210
+	    foreach ($ThtmlData as $k => $h)
2211 2211
 	    {
2212
-	        if(is_array($h))
2212
+	        if (is_array($h))
2213 2213
 	        {
2214 2214
 	            $h = json_encode($h);
2215 2215
 	        }
2216 2216
 	        
2217
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2217
+	        $data .= $k.'="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2218 2218
 	    }
2219 2219
 	    
2220 2220
 	    return $data;
@@ -2222,26 +2222,26 @@  discard block
 block discarded – undo
2222 2222
 	
2223 2223
 	function _ajax_block_order_js($object)
2224 2224
 	{
2225
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2225
+	    global $conf, $tagidfortablednd, $filepath, $langs;
2226 2226
 	    
2227 2227
 	    /*
2228 2228
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2229 2229
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2230 2230
 	     */
2231 2231
 	    
2232
-	    $id=$object->id;
2233
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2234
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2232
+	    $id = $object->id;
2233
+	    $nboflines = (isset($object->lines) ?count($object->lines) : 0);
2234
+	    $forcereloadpage = empty($conf->global->MAIN_FORCE_RELOAD_PAGE) ? 0 : 1;
2235 2235
 	    
2236
-	    $id=$object->id;
2237
-	    $fk_element=$object->fk_element;
2238
-	    $table_element_line=$object->table_element_line;
2239
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2240
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2241
-	    $filepath=(empty($filepath)?'':$filepath);
2236
+	    $id = $object->id;
2237
+	    $fk_element = $object->fk_element;
2238
+	    $table_element_line = $object->table_element_line;
2239
+	    $nboflines = (isset($object->lines) ?count($object->lines) : (empty($nboflines) ? 0 : $nboflines));
2240
+	    $tagidfortablednd = (empty($tagidfortablednd) ? 'tablelines' : $tagidfortablednd);
2241
+	    $filepath = (empty($filepath) ? '' : $filepath);
2242 2242
 	    
2243 2243
 	    
2244
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2244
+	    if (GETPOST('action', 'aZ09') != 'editline' && $nboflines > 1)
2245 2245
 	    {
2246 2246
 	        
2247 2247
 	        ?>
@@ -2259,7 +2259,7 @@  discard block
 block discarded – undo
2259 2259
 				moveBlockCol.disableSelection(); // prevent selection
2260 2260
 <?php if ($object->statut == 0) { ?>
2261 2261
 				// apply some graphical stuff
2262
-				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png',2);  ?>)');
2262
+				moveBlockCol.css("background-image",'url(<?php echo dol_buildpath('subtotal/img/grip_all.png', 2); ?>)');
2263 2263
 				moveBlockCol.css("background-repeat","no-repeat");
2264 2264
 				moveBlockCol.css("background-position","center center");
2265 2265
 				moveBlockCol.css("cursor","move");
Please login to merge, or discard this patch.
lib/subtotal.lib.php 3 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -25,25 +25,25 @@  discard block
 block discarded – undo
25 25
 
26 26
 function subtotalAdminPrepareHead()
27 27
 {
28
-    global $langs, $conf;
28
+	global $langs, $conf;
29 29
 
30
-    $langs->load("subtotal@subtotal");
30
+	$langs->load("subtotal@subtotal");
31 31
 
32
-    $h = 0;
33
-    $head = array();
32
+	$h = 0;
33
+	$head = array();
34 34
 
35
-    $head[$h][0] = dol_buildpath("/subtotal/admin/subtotal_setup.php", 1);
36
-    $head[$h][1] = $langs->trans("Parameters");
37
-    $head[$h][2] = 'settings';
38
-    $h++;
39
-    $head[$h][0] = dol_buildpath("/subtotal/admin/subtotal_about.php", 1);
40
-    $head[$h][1] = $langs->trans("About");
41
-    $head[$h][2] = 'about';
42
-    $h++;
35
+	$head[$h][0] = dol_buildpath("/subtotal/admin/subtotal_setup.php", 1);
36
+	$head[$h][1] = $langs->trans("Parameters");
37
+	$head[$h][2] = 'settings';
38
+	$h++;
39
+	$head[$h][0] = dol_buildpath("/subtotal/admin/subtotal_about.php", 1);
40
+	$head[$h][1] = $langs->trans("About");
41
+	$head[$h][2] = 'about';
42
+	$h++;
43 43
 
44
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'subtotal', $showLabel=false);
44
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'subtotal', $showLabel=false);
45 45
 
46
-    return $head;
46
+	return $head;
47 47
 }
48 48
 
49 49
 function getHtmlSelectTitle(&$object, $showLabel=false)
@@ -242,17 +242,17 @@  discard block
 block discarded – undo
242 242
 			$classname = ucfirst($element);
243 243
 			
244 244
 			switch ($element) {
245
-			    case 'supplier_proposal':
246
-			        $classname = 'SupplierProposal';
247
-			        break;
245
+				case 'supplier_proposal':
246
+					$classname = 'SupplierProposal';
247
+					break;
248 248
 			        
249
-			    case 'order_supplier':
250
-			        $classname = 'CommandeFournisseur';
251
-			        break;
249
+				case 'order_supplier':
250
+					$classname = 'CommandeFournisseur';
251
+					break;
252 252
 			        
253
-			    case 'invoice_supplier':
254
-			        $classname = 'FactureFournisseur';
255
-			        break;
253
+				case 'invoice_supplier':
254
+					$classname = 'FactureFournisseur';
255
+					break;
256 256
 			}
257 257
 			
258 258
 			$object = new $classname($db); // Propal | Commande | Facture
@@ -325,14 +325,14 @@  discard block
 block discarded – undo
325 325
 		else $res = $line->update($user);
326 326
 	}
327 327
 	else {
328
-	    if(in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
329
-	        if(empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
328
+		if(in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
329
+			if(empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
330 330
 	        
331
-	        require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
332
-	        $extrafields=new ExtraFields($object->db);
333
-	        $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
334
-	        $line->fetch_optionals($line->id,$extralabels);
335
-	    }
331
+			require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
332
+			$extrafields=new ExtraFields($object->db);
333
+			$extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
334
+			$line->fetch_optionals($line->id,$extralabels);
335
+		}
336 336
 		$line->array_options['options_subtotal_nc'] = 0;
337 337
 		if($object->element == 'order_supplier') $line->update($user);
338 338
 		$res = TSubtotal::doUpdateLine($object, $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->product_type, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -41,21 +41,21 @@  discard block
 block discarded – undo
41 41
     $head[$h][2] = 'about';
42 42
     $h++;
43 43
 
44
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'subtotal', $showLabel=false);
44
+    complete_head_from_modules($conf, $langs, $object, $head, $h, 'subtotal', $showLabel = false);
45 45
 
46 46
     return $head;
47 47
 }
48 48
 
49
-function getHtmlSelectTitle(&$object, $showLabel=false)
49
+function getHtmlSelectTitle(&$object, $showLabel = false)
50 50
 {
51 51
 	global $langs;
52 52
 	
53
-	require_once DOL_DOCUMENT_ROOT . '/core/lib/functions.lib.php';
53
+	require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
54 54
 	dol_include_once('/subtotal/class/subtotal.class.php');
55 55
 	$TTitle = TSubtotal::getAllTitleFromDocument($object);
56 56
 	$html = '';
57
-	if ($showLabel) $html.= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>';
58
-	$html.= '<select onChange="$(\'select[name=under_title]\').val(this.value);" name="under_title" class="under_title minwidth200"><option value="-1"></option>';
57
+	if ($showLabel) $html .= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>';
58
+	$html .= '<select onChange="$(\'select[name=under_title]\').val(this.value);" name="under_title" class="under_title minwidth200"><option value="-1"></option>';
59 59
 	
60 60
 	$nbsp = '&nbsp;';
61 61
 	foreach ($TTitle as &$line)
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 
71 71
 function getTFreeText()
72 72
 {
73
-	global $db,$conf;
73
+	global $db, $conf;
74 74
 	
75 75
 	$TFreeText = array();
76 76
 	
@@ -88,19 +88,19 @@  discard block
 block discarded – undo
88 88
 	return $TFreeText;
89 89
 }
90 90
 
91
-function getHtmlSelectFreeText($withEmpty=true)
91
+function getHtmlSelectFreeText($withEmpty = true)
92 92
 {
93 93
 	global $langs;
94 94
 	
95 95
 	$TFreeText = getTFreeText();
96 96
 	$html = '<label for="free_text">'.$langs->trans('subtotalLabelForFreeText').'</label>';
97
-	$html.= '<select onChange="getTFreeText($(this));" name="free_text" class="minwidth200">';
98
-	if ($withEmpty) $html.= '<option value=""></option>';
97
+	$html .= '<select onChange="getTFreeText($(this));" name="free_text" class="minwidth200">';
98
+	if ($withEmpty) $html .= '<option value=""></option>';
99 99
 
100 100
 	$TFreeTextContents = array();
101 101
 	foreach ($TFreeText as $id => $tab)
102 102
 	{
103
-		$html.= '<option value="'.$id.'">'.$tab->label.'</option>';
103
+		$html .= '<option value="'.$id.'">'.$tab->label.'</option>';
104 104
 		$TFreeTextContents[$id] = $tab->content;
105 105
 	}
106 106
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 function _updateSubtotalLine(&$object, &$line)
129 129
 {
130 130
 	$label = GETPOST('line-title');
131
-	$description = ($line->qty>90) ? '' : GETPOST('line-description');
131
+	$description = ($line->qty > 90) ? '' : GETPOST('line-description');
132 132
 	$pagebreak = (int) GETPOST('line-pagebreak');
133 133
 
134 134
 	$level = GETPOST('subtotal_level', 'int');
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 
146 146
 function _updateSubtotalBloc($object, $line)
147 147
 {
148
-	global $conf,$langs;
148
+	global $conf, $langs;
149 149
 	
150 150
 	$subtotal_tva_tx = $subtotal_tva_tx_init = GETPOST('subtotal_tva_tx', 'int');
151 151
 	$subtotal_progress = $subtotal_progress_init = GETPOST('subtotal_progress', 'int');
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
  * @param	$lineid			= title lineid
225 225
  * @param	$subtotal_nc	0 = "Compris" prise en compte des totaux des lignes; 1 = "Non compris" non prise en compte des totaux du bloc; null = update de toutes les lignes 
226 226
  */
227
-function _updateLineNC($element, $elementid, $lineid, $subtotal_nc=null)
227
+function _updateLineNC($element, $elementid, $lineid, $subtotal_nc = null)
228 228
 {
229
-	global $db,$langs,$tmp_object_nc;
229
+	global $db, $langs, $tmp_object_nc;
230 230
 	
231 231
 	$error = 0;
232 232
 	if (empty($element)) $error++;
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 	{
267 267
 		foreach ($object->lines as &$l)
268 268
 		{
269
-			if($l->id == $lineid) {
269
+			if ($l->id == $lineid) {
270 270
 				$line = $l;
271 271
 				break;
272 272
 			}
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
 		{
277 277
 			$db->begin();
278 278
 			
279
-			if(TSubtotal::isModSubtotalLine($line))
279
+			if (TSubtotal::isModSubtotalLine($line))
280 280
 			{
281
-				if(TSubtotal::isTitle($line)) {
281
+				if (TSubtotal::isTitle($line)) {
282 282
 					// Update le contenu du titre (ainsi que le titre lui même)
283 283
 					$TTitleBlock = TSubtotal::getLinesFromTitleId($object, $lineid, true);
284
-					foreach($TTitleBlock as &$line_block)
284
+					foreach ($TTitleBlock as &$line_block)
285 285
 					{
286 286
 						$res = doUpdate($object, $line_block, $subtotal_nc);
287 287
 					}
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	
316 316
 	if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) return 1;
317 317
 	// Update extrafield et total
318
-	if(! empty($subtotal_nc)) {
318
+	if (!empty($subtotal_nc)) {
319 319
 		$line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = 
320 320
 			$line->multicurrency_total_ht = $line->multicurrency_total_tva = $line->multicurrency_total_ttc = 0;
321 321
 
@@ -325,16 +325,16 @@  discard block
 block discarded – undo
325 325
 		else $res = $line->update($user);
326 326
 	}
327 327
 	else {
328
-	    if(in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
329
-	        if(empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
328
+	    if (in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
329
+	        if (empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
330 330
 	        
331 331
 	        require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
332
-	        $extrafields=new ExtraFields($object->db);
333
-	        $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
334
-	        $line->fetch_optionals($line->id,$extralabels);
332
+	        $extrafields = new ExtraFields($object->db);
333
+	        $extralabels = $extrafields->fetch_name_optionals_label($object->table_element_line, true);
334
+	        $line->fetch_optionals($line->id, $extralabels);
335 335
 	    }
336 336
 		$line->array_options['options_subtotal_nc'] = 0;
337
-		if($object->element == 'order_supplier') $line->update($user);
337
+		if ($object->element == 'order_supplier') $line->update($user);
338 338
 		$res = TSubtotal::doUpdateLine($object, $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->product_type, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
339 339
 	}
340 340
 	
Please login to merge, or discard this patch.
Braces   +63 added lines, -29 removed lines patch added patch discarded remove patch
@@ -54,7 +54,9 @@  discard block
 block discarded – undo
54 54
 	dol_include_once('/subtotal/class/subtotal.class.php');
55 55
 	$TTitle = TSubtotal::getAllTitleFromDocument($object);
56 56
 	$html = '';
57
-	if ($showLabel) $html.= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>';
57
+	if ($showLabel) {
58
+		$html.= '<label for="under_title">'.$langs->trans('subtotalLabelForUnderTitle').'</label>';
59
+	}
58 60
 	$html.= '<select onChange="$(\'select[name=under_title]\').val(this.value);" name="under_title" class="under_title minwidth200"><option value="-1"></option>';
59 61
 	
60 62
 	$nbsp = '&nbsp;';
@@ -95,7 +97,9 @@  discard block
 block discarded – undo
95 97
 	$TFreeText = getTFreeText();
96 98
 	$html = '<label for="free_text">'.$langs->trans('subtotalLabelForFreeText').'</label>';
97 99
 	$html.= '<select onChange="getTFreeText($(this));" name="free_text" class="minwidth200">';
98
-	if ($withEmpty) $html.= '<option value=""></option>';
100
+	if ($withEmpty) {
101
+		$html.= '<option value=""></option>';
102
+	}
99 103
 
100 104
 	$TFreeTextContents = array();
101 105
 	foreach ($TFreeText as $id => $tab)
@@ -134,8 +138,13 @@  discard block
 block discarded – undo
134 138
 	$level = GETPOST('subtotal_level', 'int');
135 139
 	if (!empty($level))
136 140
 	{
137
-		if ($line->qty > 90) $line->qty = 100 - $level; // Si on edit une ligne sous-total
138
-		else $line->qty = $level;
141
+		if ($line->qty > 90) {
142
+			$line->qty = 100 - $level;
143
+		}
144
+		// Si on edit une ligne sous-total
145
+		else {
146
+			$line->qty = $level;
147
+		}
139 148
 	}
140 149
 	
141 150
 	$res = TSubtotal::doUpdateLine($object, $line->id, $description, 0, $line->qty, 0, '', '', 0, 9, 0, 0, 'HT', $pagebreak, 0, 1, null, 0, $label, TSubtotal::$module_number, $line->array_options);
@@ -162,13 +171,18 @@  discard block
 block discarded – undo
162 171
 			{
163 172
 				$subtotal_tva_tx = $subtotal_tva_tx_init; // ré-init car la variable peut évoluer
164 173
 					
165
-				if (!empty($showBlockExtrafields)) $line->array_options = $array_options;
166
-				if ($subtotal_tva_tx == '') $subtotal_tva_tx = $line->tva_tx;
174
+				if (!empty($showBlockExtrafields)) {
175
+					$line->array_options = $array_options;
176
+				}
177
+				if ($subtotal_tva_tx == '') {
178
+					$subtotal_tva_tx = $line->tva_tx;
179
+				}
167 180
 				if ($object->element == 'facture' && !empty($conf->global->INVOICE_USE_SITUATION) && $object->type == Facture::TYPE_SITUATION)
168 181
 				{
169 182
 					$subtotal_progress = $subtotal_progress_init;
170
-					if ($subtotal_progress == '') $subtotal_progress = $line->situation_percent;
171
-					else
183
+					if ($subtotal_progress == '') {
184
+						$subtotal_progress = $line->situation_percent;
185
+					} else
172 186
 					{
173 187
 						$prev_percent = $line->get_prev_progress($object->id);
174 188
 						if ($subtotal_progress < $prev_percent)
@@ -181,14 +195,21 @@  discard block
 block discarded – undo
181 195
 				
182 196
 				$res = TSubtotal::doUpdateLine($object, $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $subtotal_tva_tx, $line->product_type, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $subtotal_progress, $line->fk_unit);
183 197
 
184
-				if ($res > 0) $success_updated_line++;
185
-				else $error_updated_line++;
198
+				if ($res > 0) {
199
+					$success_updated_line++;
200
+				} else {
201
+					$error_updated_line++;
202
+				}
186 203
 			}
187 204
 		}
188 205
 
189
-		if ($nb_progress_not_updated > 0) setEventMessage($langs->trans('subtotal_nb_progress_not_updated', $nb_progress_not_updated), 'warnings');
206
+		if ($nb_progress_not_updated > 0) {
207
+			setEventMessage($langs->trans('subtotal_nb_progress_not_updated', $nb_progress_not_updated), 'warnings');
208
+		}
190 209
 		
191
-		if ($success_updated_line > 0) setEventMessage($langs->trans('subtotal_success_updated_line', $success_updated_line));
210
+		if ($success_updated_line > 0) {
211
+			setEventMessage($langs->trans('subtotal_success_updated_line', $success_updated_line));
212
+		}
192 213
 		if ($error_updated_line > 0)
193 214
 		{
194 215
 			setEventMessage($langs->trans('subtotal_error_updated_line', $error_updated_line), 'errors');
@@ -229,15 +250,16 @@  discard block
 block discarded – undo
229 250
 	global $db,$langs,$tmp_object_nc;
230 251
 	
231 252
 	$error = 0;
232
-	if (empty($element)) $error++;
253
+	if (empty($element)) {
254
+		$error++;
255
+	}
233 256
 	
234 257
 	if (!$error)
235 258
 	{
236 259
 		if (!empty($tmp_object_nc) && $tmp_object_nc->element == $element && $tmp_object_nc->id == $elementid)
237 260
 		{
238 261
 			$object = $tmp_object_nc;
239
-		}
240
-		else
262
+		} else
241 263
 		{
242 264
 			$classname = ucfirst($element);
243 265
 			
@@ -257,8 +279,11 @@  discard block
 block discarded – undo
257 279
 			
258 280
 			$object = new $classname($db); // Propal | Commande | Facture
259 281
 			$res = $object->fetch($elementid);
260
-			if ($res < 0) $error++;
261
-			else $tmp_object_nc = $object;
282
+			if ($res < 0) {
283
+				$error++;
284
+			} else {
285
+				$tmp_object_nc = $object;
286
+			}
262 287
 		}
263 288
 	}
264 289
 	
@@ -286,21 +311,21 @@  discard block
 block discarded – undo
286 311
 						$res = doUpdate($object, $line_block, $subtotal_nc);
287 312
 					}
288 313
 				}
289
-			}
290
-			else
314
+			} else
291 315
 			{
292 316
 				$res = doUpdate($object, $line, $subtotal_nc);
293 317
 			}
294 318
 			
295 319
 			$res = $object->update_price(1);
296
-			if ($res <= 0) $error++;
320
+			if ($res <= 0) {
321
+				$error++;
322
+			}
297 323
 			
298 324
 			if (!$error)
299 325
 			{
300 326
 				setEventMessage($langs->trans('subtotal_update_nc_success'));
301 327
 				$db->commit();
302
-			}
303
-			else
328
+			} else
304 329
 			{
305 330
 				setEventMessage($langs->trans('subtotal_update_nc_error'), 'errors');
306 331
 				$db->rollback();
@@ -313,7 +338,9 @@  discard block
 block discarded – undo
313 338
 {
314 339
 	global $user;
315 340
 	
316
-	if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) return 1;
341
+	if (TSubtotal::isFreeText($line) || TSubtotal::isSubtotal($line)) {
342
+		return 1;
343
+	}
317 344
 	// Update extrafield et total
318 345
 	if(! empty($subtotal_nc)) {
319 346
 		$line->total_ht = $line->total_tva = $line->total_ttc = $line->total_localtax1 = $line->total_localtax2 = 
@@ -321,12 +348,17 @@  discard block
 block discarded – undo
321 348
 
322 349
 		$line->array_options['options_subtotal_nc'] = 1;
323 350
 
324
-		if ($line->element == 'propaldet') $res = $line->update();
325
-		else $res = $line->update($user);
326
-	}
327
-	else {
351
+		if ($line->element == 'propaldet') {
352
+			$res = $line->update();
353
+		} else {
354
+			$res = $line->update($user);
355
+		}
356
+	} else {
328 357
 	    if(in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
329
-	        if(empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
358
+	        if(empty($line->label)) {
359
+	        	$line->label = $line->description;
360
+	        }
361
+	        // supplier lines don't have the field label
330 362
 	        
331 363
 	        require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
332 364
 	        $extrafields=new ExtraFields($object->db);
@@ -334,7 +366,9 @@  discard block
 block discarded – undo
334 366
 	        $line->fetch_optionals($line->id,$extralabels);
335 367
 	    }
336 368
 		$line->array_options['options_subtotal_nc'] = 0;
337
-		if($object->element == 'order_supplier') $line->update($user);
369
+		if($object->element == 'order_supplier') {
370
+			$line->update($user);
371
+		}
338 372
 		$res = TSubtotal::doUpdateLine($object, $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->product_type, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
339 373
 	}
340 374
 	
Please login to merge, or discard this patch.