Passed
Pull Request — master (#112)
by
unknown
02:07
created
class/actions_subtotal.class.php 1 patch
Indentation   +209 added lines, -209 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,36 +341,36 @@  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
 				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0;
354 354
 				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] : $hidepricesDefaultConf;
355 355
 				
356 356
 				$var=false;
357
-		     	$out.= '<tr '.$bc[$var].'>
357
+			 	$out.= '<tr '.$bc[$var].'>
358 358
 		     			<td colspan="4" align="right">
359 359
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
360 360
 		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
361 361
 		     			</td>
362 362
 		     			</tr>';
363 363
 				
364
-		     	$var=!$var;
365
-		     	$out.= '<tr '.$bc[$var].'>
364
+			 	$var=!$var;
365
+			 	$out.= '<tr '.$bc[$var].'>
366 366
 		     			<td colspan="4" align="right">
367 367
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
368 368
 		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
369 369
 		     			</td>
370 370
 		     			</tr>';
371 371
 		     	
372
-		     	$var=!$var;
373
-		     	$out.= '<tr '.$bc[$var].'>
372
+			 	$var=!$var;
373
+			 	$out.= '<tr '.$bc[$var].'>
374 374
 		     			<td colspan="4" align="right">
375 375
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidePrice').'</label>
376 376
 		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
@@ -382,9 +382,9 @@  discard block
 block discarded – undo
382 382
 				if ( 
383 383
 					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
384 384
 					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
385
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
385
+					|| (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
386 386
 					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
387
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
387
+					|| (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
388 388
 					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
389 389
 				)
390 390
 				{
@@ -403,19 +403,19 @@  discard block
 block discarded – undo
403 403
 			}
404 404
 			
405 405
 		
406
-        return 1;
406
+		return 1;
407 407
 	} 
408 408
 	 
409
-    function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
410
-    {
409
+	function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
410
+	{
411 411
 		
412
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
413
-        {
412
+		if (in_array('invoicecard',explode(':',$parameters['context'])))
413
+		{
414 414
         	
415
-        }
415
+		}
416 416
 		
417
-        return 0;
418
-    }
417
+		return 0;
418
+	}
419 419
 	
420 420
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
421 421
 		global $conf;
@@ -464,11 +464,11 @@  discard block
 block discarded – undo
464 464
 	
465 465
 		if (
466 466
 				in_array('invoicecard',explode(':',$parameters['context']))
467
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
467
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
468 468
 				|| in_array('propalcard',explode(':',$parameters['context']))
469
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
469
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
470 470
 				|| in_array('ordercard',explode(':',$parameters['context']))
471
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
471
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
472 472
 				|| in_array('invoicereccard',explode(':',$parameters['context']))
473 473
 		) {
474 474
 			
@@ -547,20 +547,20 @@  discard block
 block discarded – undo
547 547
 				in_array('invoicecard',explode(':',$parameters['context']))
548 548
 				|| in_array('propalcard',explode(':',$parameters['context']))
549 549
 				|| in_array('ordercard',explode(':',$parameters['context']))
550
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
551
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
552
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
550
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
551
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
552
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
553 553
 			)
554
-	        {								
554
+			{								
555 555
 				if(in_array('invoicecard',explode(':',$parameters['context']))) {
556 556
 					$sessname = 'subtotal_hideInnerLines_facture';	
557 557
 					$sessname2 = 'subtotal_hidedetails_facture';
558 558
 					$sessname3 = 'subtotal_hideprices_facture';
559 559
 				}
560 560
 				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
561
-				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
562
-				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
563
-				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
561
+					$sessname = 'subtotal_hideInnerLines_facture_fournisseur';
562
+					$sessname2 = 'subtotal_hidedetails_facture_fournisseur';
563
+					$sessname3 = 'subtotal_hideprices_facture_fournisseur';
564 564
 				}
565 565
 				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
566 566
 					$sessname = 'subtotal_hideInnerLines_propal';
@@ -568,9 +568,9 @@  discard block
 block discarded – undo
568 568
 					$sessname3 = 'subtotal_hideprices_propal';
569 569
 				}
570 570
 				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
571
-				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
572
-				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
573
-				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
571
+					$sessname = 'subtotal_hideInnerLines_supplier_proposal';
572
+					$sessname2 = 'subtotal_hidedetails_supplier_proposal';
573
+					$sessname3 = 'subtotal_hideprices_supplier_proposal';
574 574
 				}
575 575
 				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
576 576
 					$sessname = 'subtotal_hideInnerLines_commande';
@@ -578,9 +578,9 @@  discard block
 block discarded – undo
578 578
 					$sessname3 = 'subtotal_hideprices_commande';
579 579
 				}
580 580
 				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
581
-				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
582
-				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
583
-				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
581
+					$sessname = 'subtotal_hideInnerLines_commande_fournisseur';
582
+					$sessname2 = 'subtotal_hidedetails_commande_fournisseur';
583
+					$sessname3 = 'subtotal_hideprices_commande_fournisseur';
584 584
 				}
585 585
 				else {
586 586
 					$sessname = 'subtotal_hideInnerLines_unknown';
@@ -602,17 +602,17 @@  discard block
 block discarded – undo
602 602
 				foreach($object->lines as &$line) {
603 603
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
604 604
 					    
605
-                        if($line->qty>=90) {
606
-                            $line->modsubtotal_total = 1;
607
-                        }
608
-                        else{
609
-                            $line->modsubtotal_title = 1;
610
-                        }
605
+						if($line->qty>=90) {
606
+							$line->modsubtotal_total = 1;
607
+						}
608
+						else{
609
+							$line->modsubtotal_title = 1;
610
+						}
611 611
                         
612 612
 						$line->total_ht = $this->getTotalLineFromObject($object, $line, '');
613 613
 					}
614
-	        	}
615
-	        }
614
+				}
615
+			}
616 616
 			
617 617
 		}
618 618
 		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 				 */
630 630
 				else if($object->element=='invoice_supplier')
631 631
 				{
632
-				    $object->deleteline($idLine);
632
+					$object->deleteline($idLine);
633 633
 				}
634 634
 				/**
635 635
 				 * @var $object Propal
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 				 */
653 653
 				else if($object->element=='order_supplier')
654 654
 				{
655
-				    $object->deleteline($idLine);
655
+					$object->deleteline($idLine);
656 656
 				}
657 657
 				/**
658 658
 				 * @var $object Facturerec
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 		
697 697
 		foreach($object->lines as $l) {
698 698
 		
699
-		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
699
+			$lid = (!empty($l->rowid) ? $l->rowid : $l->id);
700 700
 			if($lid == $lineid) {
701 701
 
702 702
 				$found = true;
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
 			
706 706
 			if($found) {
707 707
 				
708
-			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
708
+				$Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
709 709
 				
710 710
 				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
711 711
 					break; // end of story
@@ -784,17 +784,17 @@  discard block
 block discarded – undo
784 784
 			if($l->rang>=$rang) {
785 785
 				return price($total);
786 786
 			}
787
-                        if (TSubtotal::isSubtotal($l)){
788
-                            $total = 0;
789
-                        } else  if ($l->situation_percent > 0 ){
787
+						if (TSubtotal::isSubtotal($l)){
788
+							$total = 0;
789
+						} else  if ($l->situation_percent > 0 ){
790 790
                            
791 791
         	
792 792
 		 	$prev_progress = $l->get_prev_progress($object->id);
793 793
 		 	$progress = ($l->situation_percent - $prev_progress) /100;
794
-                        $total += ($l->total_ht/($l->situation_percent/100)) * $progress;
794
+						$total += ($l->total_ht/($l->situation_percent/100)) * $progress;
795 795
                         
796
-                    }
797
-                }
796
+					}
797
+				}
798 798
                 
799 799
 		return price($total);
800 800
 	}
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
 		if(method_exists('Closure','bind')) {
827 827
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
828 828
 			$sweetsThief = function ($pdf) {
829
-		    		return $pdf->bMargin ;
829
+					return $pdf->bMargin ;
830 830
 			};
831 831
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
832 832
 	
@@ -889,11 +889,11 @@  discard block
 block discarded – undo
889 889
 				else
890 890
 				{
891 891
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
892
-                                        if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
893
-                                                $total_to_print = $this->getTotalToPrintSituation($object, $line);
894
-                                        } else {
895
-                                            	$total_to_print = price($total);
896
-                                        }
892
+										if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
893
+												$total_to_print = $this->getTotalToPrintSituation($object, $line);
894
+										} else {
895
+												$total_to_print = price($total);
896
+										}
897 897
                                             
898 898
 					$line->total_ht = $total;
899 899
 					$line->total = $total;
@@ -1044,7 +1044,7 @@  discard block
 block discarded – undo
1044 1044
 	}
1045 1045
 	
1046 1046
 	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1047
-	    global $conf, $hideprices;
1047
+		global $conf, $hideprices;
1048 1048
 		
1049 1049
 		if($this->isModSubtotalLine($parameters,$object) ){
1050 1050
 			
@@ -1083,33 +1083,33 @@  discard block
 block discarded – undo
1083 1083
 			}
1084 1084
 		}
1085 1085
 		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1086
-		    if(is_array($parameters)) $i = & $parameters['i'];
1087
-		    else $i = (int)$parameters;
1088
-		    $this->resprints = price($object->lines[$i]->total_ht);
1086
+			if(is_array($parameters)) $i = & $parameters['i'];
1087
+			else $i = (int)$parameters;
1088
+			$this->resprints = price($object->lines[$i]->total_ht);
1089 1089
 		}
1090 1090
 		if (!empty($hideprices)
1091
-		    || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1092
-		    )
1091
+			|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1092
+			)
1093 1093
 		{
1094
-		    if (!empty($hideprices))
1095
-		    {
1094
+			if (!empty($hideprices))
1095
+			{
1096 1096
 		        
1097
-		        if(is_array($parameters)) $i = & $parameters['i'];
1098
-		        else $i = (int)$parameters;
1097
+				if(is_array($parameters)) $i = & $parameters['i'];
1098
+				else $i = (int)$parameters;
1099 1099
 		        
1100
-		        // Check if a title exist for this line && if the title have subtotal
1101
-		        $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1102
-		        if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1103
-		        {
1104
-		            $this->resprints = ' ';
1105
-		            return 1;
1106
-		        }
1107
-		    }
1108
-		    elseif (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1109
-		    {
1110
-		        $this->resprints = ' ';
1111
-		        return 1;
1112
-		    }
1100
+				// Check if a title exist for this line && if the title have subtotal
1101
+				$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1102
+				if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1103
+				{
1104
+					$this->resprints = ' ';
1105
+					return 1;
1106
+				}
1107
+			}
1108
+			elseif (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1109
+			{
1110
+				$this->resprints = ' ';
1111
+				return 1;
1112
+			}
1113 1113
 		}
1114 1114
         
1115 1115
 		return 0;
@@ -1389,11 +1389,11 @@  discard block
 block discarded – undo
1389 1389
 		$hidedetails = (int)GETPOST('hidedetails');
1390 1390
 		
1391 1391
 		if ($hideInnerLines) { // si c une ligne de titre
1392
-	    	$fk_parent_line=0;
1392
+			$fk_parent_line=0;
1393 1393
 			$TLines =array();
1394 1394
 		
1395 1395
 			$original_count=count($object->lines);
1396
-		    $TTvas = array(); // tableau de tva
1396
+			$TTvas = array(); // tableau de tva
1397 1397
 		    
1398 1398
 			foreach($object->lines as $k=>&$line) 
1399 1399
 			{
@@ -1423,48 +1423,48 @@  discard block
 block discarded – undo
1423 1423
 			
1424 1424
 				if ($hideInnerLines)
1425 1425
 				{
1426
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1427
-				    {
1428
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1426
+					if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1427
+					{
1428
+						if($line->tva_tx != '0.000' && $line->product_type!=9){
1429 1429
 				            
1430
-    				        // on remplit le tableau de tva pour substituer les lignes cachées
1431
-    				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1432
-    				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1433
-    				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1434
-    				    }
1435
-    					if($line->product_type==9 && $line->rowid>0)
1436
-    					{
1437
-    					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1438
-    					    // génère des lignes d'affichage des montants HT soumis à tva
1439
-    					    $nbtva = count($TTvas);
1440
-    					    if(!empty($nbtva)){
1441
-    					        foreach ($TTvas as $tx =>$val){
1442
-    					            $l = clone $line;
1443
-    					            $l->product_type = 1;
1444
-    					            $l->special_code = '';
1445
-    					            $l->qty = 1;
1446
-    					            $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1447
-    					            $l->tva_tx = $tx;
1448
-    					            $l->total_ht = $val['total_ht'];
1449
-    					            $l->total_tva = $val['total_tva'];
1450
-    					            $l->total = $line->total_ht;
1451
-    					            $l->total_ttc = $val['total_ttc'];
1452
-    					            $TLines[] = $l;
1453
-    					            array_shift($TTvas);
1454
-    					       }
1455
-    					    }
1430
+							// on remplit le tableau de tva pour substituer les lignes cachées
1431
+							$TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1432
+							$TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1433
+							$TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1434
+						}
1435
+						if($line->product_type==9 && $line->rowid>0)
1436
+						{
1437
+							//Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1438
+							// génère des lignes d'affichage des montants HT soumis à tva
1439
+							$nbtva = count($TTvas);
1440
+							if(!empty($nbtva)){
1441
+								foreach ($TTvas as $tx =>$val){
1442
+									$l = clone $line;
1443
+									$l->product_type = 1;
1444
+									$l->special_code = '';
1445
+									$l->qty = 1;
1446
+									$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1447
+									$l->tva_tx = $tx;
1448
+									$l->total_ht = $val['total_ht'];
1449
+									$l->total_tva = $val['total_tva'];
1450
+									$l->total = $line->total_ht;
1451
+									$l->total_ttc = $val['total_ttc'];
1452
+									$TLines[] = $l;
1453
+									array_shift($TTvas);
1454
+							   }
1455
+							}
1456 1456
     					    
1457
-    					    // ajoute la ligne de sous-total
1458
-    					    $TLines[] = $line; 
1459
-    					}
1460
-				    } else {
1457
+							// ajoute la ligne de sous-total
1458
+							$TLines[] = $line; 
1459
+						}
1460
+					} else {
1461 1461
 				        
1462
-				        if($line->product_type==9 && $line->rowid>0)
1463
-				        {
1464
-				            // ajoute la ligne de sous-total
1465
-				            $TLines[] = $line; 
1466
-				        }
1467
-				    }
1462
+						if($line->product_type==9 && $line->rowid>0)
1463
+						{
1464
+							// ajoute la ligne de sous-total
1465
+							$TLines[] = $line; 
1466
+						}
1467
+					}
1468 1468
 				    
1469 1469
 					
1470 1470
 				}
@@ -1489,20 +1489,20 @@  discard block
 block discarded – undo
1489 1489
 			$nbtva = count($TTvas);
1490 1490
 			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1491 1491
 			{
1492
-			    foreach ($TTvas as $tx =>$val){
1493
-			        $l = clone $line;
1494
-			        $l->product_type = 1;
1495
-			        $l->special_code = '';
1496
-			        $l->qty = 1;
1497
-			        $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1498
-			        $l->tva_tx = $tx;
1499
-			        $l->total_ht = $val['total_ht'];
1500
-			        $l->total_tva = $val['total_tva'];
1501
-			        $l->total = $line->total_ht;
1502
-			        $l->total_ttc = $val['total_ttc'];
1503
-			        $TLines[] = $l;
1504
-			        array_shift($TTvas);
1505
-			    }
1492
+				foreach ($TTvas as $tx =>$val){
1493
+					$l = clone $line;
1494
+					$l->product_type = 1;
1495
+					$l->special_code = '';
1496
+					$l->qty = 1;
1497
+					$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1498
+					$l->tva_tx = $tx;
1499
+					$l->total_ht = $val['total_ht'];
1500
+					$l->total_tva = $val['total_tva'];
1501
+					$l->total = $line->total_ht;
1502
+					$l->total_ttc = $val['total_ttc'];
1503
+					$TLines[] = $l;
1504
+					array_shift($TTvas);
1505
+				}
1506 1506
 			}
1507 1507
 			
1508 1508
 			global $nblignes;
@@ -1514,7 +1514,7 @@  discard block
 block discarded – undo
1514 1514
 				$this->resprints = '';
1515 1515
 				return 0;
1516 1516
 			}
1517
-	    }
1517
+		}
1518 1518
 		
1519 1519
 		return 0;
1520 1520
 	}
@@ -1677,18 +1677,18 @@  discard block
 block discarded – undo
1677 1677
 		}
1678 1678
 		elseif($object->element == 'order_supplier' )
1679 1679
 		{
1680
-		    $createRight = $user->rights->fournisseur->commande->creer;
1680
+			$createRight = $user->rights->fournisseur->commande->creer;
1681 1681
 		}
1682 1682
 		elseif($object->element == 'invoice_supplier' )
1683 1683
 		{
1684
-		    $createRight = $user->rights->fournisseur->facture->creer;
1684
+			$createRight = $user->rights->fournisseur->facture->creer;
1685 1685
 		}
1686 1686
 		
1687 1687
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1688 1688
 			null;
1689 1689
 		}	
1690 1690
 		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)) 
1691
-        {
1691
+		{
1692 1692
 			if($object->element=='facture')$idvar = 'facid';
1693 1693
 			else $idvar='id';
1694 1694
 			
@@ -1735,7 +1735,7 @@  discard block
 block discarded – undo
1735 1735
 			//var_dump($line);
1736 1736
             
1737 1737
 			// HTML 5 data for js
1738
-            $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
1738
+			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
1739 1739
             
1740 1740
 			
1741 1741
 			?>
@@ -1793,8 +1793,8 @@  discard block
 block discarded – undo
1793 1793
 						}
1794 1794
 						
1795 1795
 						if ($object->element == 'order_supplier' || $object->element == 'invoice_supplier') {
1796
-						    $line->label = !empty($line->description) ? $line->description : $line->desc;
1797
-						    $line->description = '';
1796
+							$line->label = !empty($line->description) ? $line->description : $line->desc;
1797
+							$line->description = '';
1798 1798
 						}
1799 1799
 						$newlabel = $line->label;
1800 1800
 						if($line->label=='' && !$isFreeText) {
@@ -2085,17 +2085,17 @@  discard block
 block discarded – undo
2085 2085
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2086 2086
 		{
2087 2087
 		    
2088
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2089
-		    {
2090
-		        foreach ($object->lines as $line)
2091
-		        {
2092
-		            // fetch optionals attributes and labels
2093
-		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2094
-		            $extrafields=new ExtraFields($this->db);
2095
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2096
-		            $line->fetch_optionals($line->id,$extralabels);
2097
-		        }
2098
-		    }
2088
+			if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2089
+			{
2090
+				foreach ($object->lines as $line)
2091
+				{
2092
+					// fetch optionals attributes and labels
2093
+					require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2094
+					$extrafields=new ExtraFields($this->db);
2095
+					$extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2096
+					$line->fetch_optionals($line->id,$extralabels);
2097
+				}
2098
+			}
2099 2099
 		    
2100 2100
 			$TSubNc = array();
2101 2101
 			foreach ($object->lines as &$l)
@@ -2186,80 +2186,80 @@  discard block
 block discarded – undo
2186 2186
 	{
2187 2187
 		dol_include_once('/subtotal/class/subtotal.class.php');
2188 2188
 
2189
-	    $line = &$parameters['line'];
2189
+		$line = &$parameters['line'];
2190 2190
 	    
2191
-	    $ThtmlData['data-id']           = $line->id;
2192
-	    $ThtmlData['data-product_type'] = $line->product_type;
2193
-	    $ThtmlData['data-qty']          = 0; //$line->qty;
2194
-	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2191
+		$ThtmlData['data-id']           = $line->id;
2192
+		$ThtmlData['data-product_type'] = $line->product_type;
2193
+		$ThtmlData['data-qty']          = 0; //$line->qty;
2194
+		$ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2195 2195
 	    
2196
-	    if(TSubtotal::isTitle($line)){
2197
-	        $ThtmlData['data-issubtotal'] = 'title';
2198
-	    }elseif(TSubtotal::isSubtotal($line)){
2199
-	        $ThtmlData['data-issubtotal'] = 'subtotal';
2200
-	    }
2201
-	    else{
2202
-	        $ThtmlData['data-issubtotal'] = 'freetext';
2203
-	    }
2196
+		if(TSubtotal::isTitle($line)){
2197
+			$ThtmlData['data-issubtotal'] = 'title';
2198
+		}elseif(TSubtotal::isSubtotal($line)){
2199
+			$ThtmlData['data-issubtotal'] = 'subtotal';
2200
+		}
2201
+		else{
2202
+			$ThtmlData['data-issubtotal'] = 'freetext';
2203
+		}
2204 2204
 	    
2205 2205
 	    
2206
-	    // Change or add data  from hooks
2207
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2206
+		// Change or add data  from hooks
2207
+		$parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2208 2208
 	    
2209
-	    // hook 
2210
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2211
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2212
-	    if ($reshook>0)
2213
-	    {
2214
-	        $ThtmlData = $hookmanager->resArray;
2215
-	    }
2216
-
2217
-	    return $this->implodeHtmlData($ThtmlData);
2209
+		// hook 
2210
+		$reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2211
+		if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2212
+		if ($reshook>0)
2213
+		{
2214
+			$ThtmlData = $hookmanager->resArray;
2215
+		}
2216
+
2217
+		return $this->implodeHtmlData($ThtmlData);
2218 2218
 	
2219 2219
 	}
2220 2220
 	
2221 2221
 	
2222 2222
 	function implodeHtmlData($ThtmlData = array())
2223 2223
 	{
2224
-	    $data = '';
2225
-	    foreach($ThtmlData as $k => $h )
2226
-	    {
2227
-	        if(is_array($h))
2228
-	        {
2229
-	            $h = json_encode($h);
2230
-	        }
2224
+		$data = '';
2225
+		foreach($ThtmlData as $k => $h )
2226
+		{
2227
+			if(is_array($h))
2228
+			{
2229
+				$h = json_encode($h);
2230
+			}
2231 2231
 	        
2232
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2233
-	    }
2232
+			$data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2233
+		}
2234 2234
 	    
2235
-	    return $data;
2235
+		return $data;
2236 2236
 	}
2237 2237
 	
2238 2238
 	function _ajax_block_order_js($object)
2239 2239
 	{
2240
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2240
+		global $conf,$tagidfortablednd,$filepath,$langs;
2241 2241
 	    
2242
-	    /*
2242
+		/*
2243 2243
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2244 2244
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2245 2245
 	     */
2246 2246
 	    
2247
-	    $id=$object->id;
2248
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2249
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2247
+		$id=$object->id;
2248
+		$nboflines=(isset($object->lines)?count($object->lines):0);
2249
+		$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2250 2250
 	    
2251
-	    $id=$object->id;
2252
-	    $fk_element=$object->fk_element;
2253
-	    $table_element_line=$object->table_element_line;
2254
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2255
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2256
-	    $filepath=(empty($filepath)?'':$filepath);
2251
+		$id=$object->id;
2252
+		$fk_element=$object->fk_element;
2253
+		$table_element_line=$object->table_element_line;
2254
+		$nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2255
+		$tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2256
+		$filepath=(empty($filepath)?'':$filepath);
2257 2257
 	    
2258 2258
 	    
2259
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2260
-	    {
2259
+		if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2260
+		{
2261 2261
 	        
2262
-	        ?>
2262
+			?>
2263 2263
 		
2264 2264
 		
2265 2265
 			<script type="text/javascript">
Please login to merge, or discard this patch.