Passed
Pull Request — master (#114)
by
unknown
02:04
created
class/actions_subtotal.class.php 1 patch
Indentation   +188 added lines, -188 removed lines patch added patch discarded remove patch
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
 	 * @return     void
82 82
 	 */
83 83
     
84
-    var $module_number = 104777;
84
+	var $module_number = 104777;
85 85
     
86
-    function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
87
-    {
88
-      	global $langs,$db,$user, $conf;
86
+	function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
87
+	{
88
+	  	global $langs,$db,$user, $conf;
89 89
 		
90 90
 		$langs->load('subtotal@subtotal');
91 91
 		
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
 				$createRight = $user->rights->facture->creer;
101 101
 			} elseif($object->element == 'order_supplier' )
102 102
 			{
103
-			    $createRight = $user->rights->fournisseur->commande->creer;
103
+				$createRight = $user->rights->fournisseur->commande->creer;
104 104
 			} elseif($object->element == 'invoice_supplier' )
105 105
 			{
106
-			    $createRight = $user->rights->fournisseur->facture->creer;
106
+				$createRight = $user->rights->fournisseur->facture->creer;
107 107
 			}
108 108
 			
109 109
 			if ($object->statut == 0  && $createRight) {
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 					
154 154
 					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
155 155
 					
156
-	    			TSubtotal::addSubTotalLine($object, $title, $qty);
156
+					TSubtotal::addSubTotalLine($object, $title, $qty);
157 157
 				}
158 158
 				else if($action==='ask_deleteallline') {
159 159
 						$form=new Form($db);
@@ -375,36 +375,36 @@  discard block
 block discarded – undo
375 375
 		$TContext = explode(':',$parameters['context']);
376 376
 		if (
377 377
 				in_array('invoicecard',$TContext)
378
-		        || in_array('invoicesuppliercard',$TContext)
378
+				|| in_array('invoicesuppliercard',$TContext)
379 379
 				|| in_array('propalcard',$TContext)
380 380
 				|| in_array('ordercard',$TContext)
381
-		        || in_array('ordersuppliercard',$TContext)
381
+				|| in_array('ordersuppliercard',$TContext)
382 382
 				|| in_array('invoicereccard',$TContext)
383 383
 			)
384
-	        {	
384
+			{	
385 385
 				$hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] : 0;
386 386
 				$hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] : 0;
387 387
 				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0;
388 388
 				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] : $hidepricesDefaultConf;
389 389
 				
390 390
 				$var=false;
391
-		     	$out.= '<tr '.$bc[$var].'>
391
+			 	$out.= '<tr '.$bc[$var].'>
392 392
 		     			<td colspan="4" align="right">
393 393
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
394 394
 		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
395 395
 		     			</td>
396 396
 		     			</tr>';
397 397
 				
398
-		     	$var=!$var;
399
-		     	$out.= '<tr '.$bc[$var].'>
398
+			 	$var=!$var;
399
+			 	$out.= '<tr '.$bc[$var].'>
400 400
 		     			<td colspan="4" align="right">
401 401
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
402 402
 		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
403 403
 		     			</td>
404 404
 		     			</tr>';
405 405
 		     	
406
-		     	$var=!$var;
407
-		     	$out.= '<tr '.$bc[$var].'>
406
+			 	$var=!$var;
407
+			 	$out.= '<tr '.$bc[$var].'>
408 408
 		     			<td colspan="4" align="right">
409 409
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidePrice').'</label>
410 410
 		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
@@ -416,9 +416,9 @@  discard block
 block discarded – undo
416 416
 				if ( 
417 417
 					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
418 418
 					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
419
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
419
+					|| (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
420 420
 					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
421
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
421
+					|| (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
422 422
 					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
423 423
 				)
424 424
 				{
@@ -437,19 +437,19 @@  discard block
 block discarded – undo
437 437
 			}
438 438
 			
439 439
 		
440
-        return 1;
440
+		return 1;
441 441
 	} 
442 442
 	 
443
-    function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
444
-    {
443
+	function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
444
+	{
445 445
 		
446
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
447
-        {
446
+		if (in_array('invoicecard',explode(':',$parameters['context'])))
447
+		{
448 448
         	
449
-        }
449
+		}
450 450
 		
451
-        return 0;
452
-    }
451
+		return 0;
452
+	}
453 453
 	
454 454
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
455 455
 		global $conf;
@@ -498,11 +498,11 @@  discard block
 block discarded – undo
498 498
 	
499 499
 		if (
500 500
 				in_array('invoicecard',explode(':',$parameters['context']))
501
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
501
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
502 502
 				|| in_array('propalcard',explode(':',$parameters['context']))
503
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
503
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
504 504
 				|| in_array('ordercard',explode(':',$parameters['context']))
505
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
505
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
506 506
 				|| in_array('invoicereccard',explode(':',$parameters['context']))
507 507
 		) {
508 508
 			
@@ -581,20 +581,20 @@  discard block
 block discarded – undo
581 581
 				in_array('invoicecard',explode(':',$parameters['context']))
582 582
 				|| in_array('propalcard',explode(':',$parameters['context']))
583 583
 				|| in_array('ordercard',explode(':',$parameters['context']))
584
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
585
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
586
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
584
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
585
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
586
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
587 587
 			)
588
-	        {								
588
+			{								
589 589
 				if(in_array('invoicecard',explode(':',$parameters['context']))) {
590 590
 					$sessname = 'subtotal_hideInnerLines_facture';	
591 591
 					$sessname2 = 'subtotal_hidedetails_facture';
592 592
 					$sessname3 = 'subtotal_hideprices_facture';
593 593
 				}
594 594
 				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
595
-				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
596
-				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
597
-				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
595
+					$sessname = 'subtotal_hideInnerLines_facture_fournisseur';
596
+					$sessname2 = 'subtotal_hidedetails_facture_fournisseur';
597
+					$sessname3 = 'subtotal_hideprices_facture_fournisseur';
598 598
 				}
599 599
 				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
600 600
 					$sessname = 'subtotal_hideInnerLines_propal';
@@ -602,9 +602,9 @@  discard block
 block discarded – undo
602 602
 					$sessname3 = 'subtotal_hideprices_propal';
603 603
 				}
604 604
 				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
605
-				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
606
-				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
607
-				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
605
+					$sessname = 'subtotal_hideInnerLines_supplier_proposal';
606
+					$sessname2 = 'subtotal_hidedetails_supplier_proposal';
607
+					$sessname3 = 'subtotal_hideprices_supplier_proposal';
608 608
 				}
609 609
 				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
610 610
 					$sessname = 'subtotal_hideInnerLines_commande';
@@ -612,9 +612,9 @@  discard block
 block discarded – undo
612 612
 					$sessname3 = 'subtotal_hideprices_commande';
613 613
 				}
614 614
 				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
615
-				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
616
-				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
617
-				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
615
+					$sessname = 'subtotal_hideInnerLines_commande_fournisseur';
616
+					$sessname2 = 'subtotal_hidedetails_commande_fournisseur';
617
+					$sessname3 = 'subtotal_hideprices_commande_fournisseur';
618 618
 				}
619 619
 				else {
620 620
 					$sessname = 'subtotal_hideInnerLines_unknown';
@@ -636,17 +636,17 @@  discard block
 block discarded – undo
636 636
 				foreach($object->lines as &$line) {
637 637
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
638 638
 					    
639
-                        if($line->qty>=90) {
640
-                            $line->modsubtotal_total = 1;
641
-                        }
642
-                        else{
643
-                            $line->modsubtotal_title = 1;
644
-                        }
639
+						if($line->qty>=90) {
640
+							$line->modsubtotal_total = 1;
641
+						}
642
+						else{
643
+							$line->modsubtotal_title = 1;
644
+						}
645 645
                         
646 646
 						$line->total_ht = $this->getTotalLineFromObject($object, $line, '');
647 647
 					}
648
-	        	}
649
-	        }
648
+				}
649
+			}
650 650
 			
651 651
 		}
652 652
 		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 				 */
664 664
 				else if($object->element=='invoice_supplier')
665 665
 				{
666
-				    $object->deleteline($idLine);
666
+					$object->deleteline($idLine);
667 667
 				}
668 668
 				/**
669 669
 				 * @var $object Propal
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 				 */
687 687
 				else if($object->element=='order_supplier')
688 688
 				{
689
-				    $object->deleteline($idLine);
689
+					$object->deleteline($idLine);
690 690
 				}
691 691
 				/**
692 692
 				 * @var $object Facturerec
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 		
731 731
 		foreach($object->lines as $l) {
732 732
 		
733
-		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
733
+			$lid = (!empty($l->rowid) ? $l->rowid : $l->id);
734 734
 			if($lid == $lineid) {
735 735
 
736 736
 				$found = true;
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
 			
740 740
 			if($found) {
741 741
 				
742
-			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
742
+				$Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
743 743
 				
744 744
 				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
745 745
 					break; // end of story
@@ -818,17 +818,17 @@  discard block
 block discarded – undo
818 818
 			if($l->rang>=$rang) {
819 819
 				return price($total);
820 820
 			}
821
-                        if (TSubtotal::isSubtotal($l)){
822
-                            $total = 0;
823
-                        } else  if ($l->situation_percent > 0 ){
821
+						if (TSubtotal::isSubtotal($l)){
822
+							$total = 0;
823
+						} else  if ($l->situation_percent > 0 ){
824 824
                            
825 825
         	
826 826
 		 	$prev_progress = $l->get_prev_progress($object->id);
827 827
 		 	$progress = ($l->situation_percent - $prev_progress) /100;
828
-                        $total += ($l->total_ht/($l->situation_percent/100)) * $progress;
828
+						$total += ($l->total_ht/($l->situation_percent/100)) * $progress;
829 829
                         
830
-                    }
831
-                }
830
+					}
831
+				}
832 832
                 
833 833
 		return price($total);
834 834
 	}
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 		if(method_exists('Closure','bind')) {
861 861
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
862 862
 			$sweetsThief = function ($pdf) {
863
-		    		return $pdf->bMargin ;
863
+					return $pdf->bMargin ;
864 864
 			};
865 865
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
866 866
 	
@@ -923,11 +923,11 @@  discard block
 block discarded – undo
923 923
 				else
924 924
 				{
925 925
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
926
-                                        if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
927
-                                                $total_to_print = $this->getTotalToPrintSituation($object, $line);
928
-                                        } else {
929
-                                            	$total_to_print = price($total);
930
-                                        }
926
+										if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
927
+												$total_to_print = $this->getTotalToPrintSituation($object, $line);
928
+										} else {
929
+												$total_to_print = price($total);
930
+										}
931 931
                                             
932 932
 					$line->total_ht = $total;
933 933
 					$line->total = $total;
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
 	}
1079 1079
 	
1080 1080
 	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1081
-	    global $conf, $hideprices, $hookmanager;
1081
+		global $conf, $hideprices, $hookmanager;
1082 1082
 		
1083 1083
 		if(is_array($parameters)) $i = & $parameters['i'];
1084 1084
 		else $i = (int)$parameters;
@@ -1117,7 +1117,7 @@  discard block
 block discarded – undo
1117 1117
 			}
1118 1118
 		}
1119 1119
 		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1120
-		    $this->resprints = price($object->lines[$i]->total_ht);
1120
+			$this->resprints = price($object->lines[$i]->total_ht);
1121 1121
 		}
1122 1122
 		
1123 1123
 		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
@@ -1460,11 +1460,11 @@  discard block
 block discarded – undo
1460 1460
 		$hidedetails = (int)GETPOST('hidedetails');
1461 1461
 		
1462 1462
 		if ($hideInnerLines) { // si c une ligne de titre
1463
-	    	$fk_parent_line=0;
1463
+			$fk_parent_line=0;
1464 1464
 			$TLines =array();
1465 1465
 		
1466 1466
 			$original_count=count($object->lines);
1467
-		    $TTvas = array(); // tableau de tva
1467
+			$TTvas = array(); // tableau de tva
1468 1468
 		    
1469 1469
 			foreach($object->lines as $k=>&$line) 
1470 1470
 			{
@@ -1494,48 +1494,48 @@  discard block
 block discarded – undo
1494 1494
 			
1495 1495
 				if ($hideInnerLines)
1496 1496
 				{
1497
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1498
-				    {
1499
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1497
+					if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1498
+					{
1499
+						if($line->tva_tx != '0.000' && $line->product_type!=9){
1500 1500
 				            
1501
-    				        // on remplit le tableau de tva pour substituer les lignes cachées
1502
-    				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1503
-    				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1504
-    				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1505
-    				    }
1506
-    					if($line->product_type==9 && $line->rowid>0)
1507
-    					{
1508
-    					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1509
-    					    // génère des lignes d'affichage des montants HT soumis à tva
1510
-    					    $nbtva = count($TTvas);
1511
-    					    if(!empty($nbtva)){
1512
-    					        foreach ($TTvas as $tx =>$val){
1513
-    					            $l = clone $line;
1514
-    					            $l->product_type = 1;
1515
-    					            $l->special_code = '';
1516
-    					            $l->qty = 1;
1517
-    					            $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1518
-    					            $l->tva_tx = $tx;
1519
-    					            $l->total_ht = $val['total_ht'];
1520
-    					            $l->total_tva = $val['total_tva'];
1521
-    					            $l->total = $line->total_ht;
1522
-    					            $l->total_ttc = $val['total_ttc'];
1523
-    					            $TLines[] = $l;
1524
-    					            array_shift($TTvas);
1525
-    					       }
1526
-    					    }
1501
+							// on remplit le tableau de tva pour substituer les lignes cachées
1502
+							$TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1503
+							$TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1504
+							$TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1505
+						}
1506
+						if($line->product_type==9 && $line->rowid>0)
1507
+						{
1508
+							//Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1509
+							// génère des lignes d'affichage des montants HT soumis à tva
1510
+							$nbtva = count($TTvas);
1511
+							if(!empty($nbtva)){
1512
+								foreach ($TTvas as $tx =>$val){
1513
+									$l = clone $line;
1514
+									$l->product_type = 1;
1515
+									$l->special_code = '';
1516
+									$l->qty = 1;
1517
+									$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1518
+									$l->tva_tx = $tx;
1519
+									$l->total_ht = $val['total_ht'];
1520
+									$l->total_tva = $val['total_tva'];
1521
+									$l->total = $line->total_ht;
1522
+									$l->total_ttc = $val['total_ttc'];
1523
+									$TLines[] = $l;
1524
+									array_shift($TTvas);
1525
+							   }
1526
+							}
1527 1527
     					    
1528
-    					    // ajoute la ligne de sous-total
1529
-    					    $TLines[] = $line; 
1530
-    					}
1531
-				    } else {
1528
+							// ajoute la ligne de sous-total
1529
+							$TLines[] = $line; 
1530
+						}
1531
+					} else {
1532 1532
 				        
1533
-				        if($line->product_type==9 && $line->rowid>0)
1534
-				        {
1535
-				            // ajoute la ligne de sous-total
1536
-				            $TLines[] = $line; 
1537
-				        }
1538
-				    }
1533
+						if($line->product_type==9 && $line->rowid>0)
1534
+						{
1535
+							// ajoute la ligne de sous-total
1536
+							$TLines[] = $line; 
1537
+						}
1538
+					}
1539 1539
 				    
1540 1540
 					
1541 1541
 				}
@@ -1560,20 +1560,20 @@  discard block
 block discarded – undo
1560 1560
 			$nbtva = count($TTvas);
1561 1561
 			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1562 1562
 			{
1563
-			    foreach ($TTvas as $tx =>$val){
1564
-			        $l = clone $line;
1565
-			        $l->product_type = 1;
1566
-			        $l->special_code = '';
1567
-			        $l->qty = 1;
1568
-			        $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1569
-			        $l->tva_tx = $tx;
1570
-			        $l->total_ht = $val['total_ht'];
1571
-			        $l->total_tva = $val['total_tva'];
1572
-			        $l->total = $line->total_ht;
1573
-			        $l->total_ttc = $val['total_ttc'];
1574
-			        $TLines[] = $l;
1575
-			        array_shift($TTvas);
1576
-			    }
1563
+				foreach ($TTvas as $tx =>$val){
1564
+					$l = clone $line;
1565
+					$l->product_type = 1;
1566
+					$l->special_code = '';
1567
+					$l->qty = 1;
1568
+					$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1569
+					$l->tva_tx = $tx;
1570
+					$l->total_ht = $val['total_ht'];
1571
+					$l->total_tva = $val['total_tva'];
1572
+					$l->total = $line->total_ht;
1573
+					$l->total_ttc = $val['total_ttc'];
1574
+					$TLines[] = $l;
1575
+					array_shift($TTvas);
1576
+				}
1577 1577
 			}
1578 1578
 			
1579 1579
 			global $nblignes;
@@ -1585,7 +1585,7 @@  discard block
 block discarded – undo
1585 1585
 				$this->resprints = '';
1586 1586
 				return 0;
1587 1587
 			}
1588
-	    }
1588
+		}
1589 1589
 		
1590 1590
 		return 0;
1591 1591
 	}
@@ -1748,18 +1748,18 @@  discard block
 block discarded – undo
1748 1748
 		}
1749 1749
 		elseif($object->element == 'order_supplier' )
1750 1750
 		{
1751
-		    $createRight = $user->rights->fournisseur->commande->creer;
1751
+			$createRight = $user->rights->fournisseur->commande->creer;
1752 1752
 		}
1753 1753
 		elseif($object->element == 'invoice_supplier' )
1754 1754
 		{
1755
-		    $createRight = $user->rights->fournisseur->facture->creer;
1755
+			$createRight = $user->rights->fournisseur->facture->creer;
1756 1756
 		}
1757 1757
 		
1758 1758
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1759 1759
 			null;
1760 1760
 		}	
1761 1761
 		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)) 
1762
-        {
1762
+		{
1763 1763
 			if($object->element=='facture')$idvar = 'facid';
1764 1764
 			else $idvar='id';
1765 1765
 			
@@ -1806,7 +1806,7 @@  discard block
 block discarded – undo
1806 1806
 			//var_dump($line);
1807 1807
             
1808 1808
 			// HTML 5 data for js
1809
-            $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
1809
+			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
1810 1810
             
1811 1811
 			
1812 1812
 			?>
@@ -1864,8 +1864,8 @@  discard block
 block discarded – undo
1864 1864
 						}
1865 1865
 						
1866 1866
 						if ($object->element == 'order_supplier' || $object->element == 'invoice_supplier') {
1867
-						    $line->label = !empty($line->description) ? $line->description : $line->desc;
1868
-						    $line->description = '';
1867
+							$line->label = !empty($line->description) ? $line->description : $line->desc;
1868
+							$line->description = '';
1869 1869
 						}
1870 1870
 						$newlabel = $line->label;
1871 1871
 						if($line->label=='' && !$isFreeText) {
@@ -2156,17 +2156,17 @@  discard block
 block discarded – undo
2156 2156
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2157 2157
 		{
2158 2158
 		    
2159
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2160
-		    {
2161
-		        foreach ($object->lines as $line)
2162
-		        {
2163
-		            // fetch optionals attributes and labels
2164
-		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2165
-		            $extrafields=new ExtraFields($this->db);
2166
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2167
-		            $line->fetch_optionals($line->id,$extralabels);
2168
-		        }
2169
-		    }
2159
+			if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2160
+			{
2161
+				foreach ($object->lines as $line)
2162
+				{
2163
+					// fetch optionals attributes and labels
2164
+					require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2165
+					$extrafields=new ExtraFields($this->db);
2166
+					$extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2167
+					$line->fetch_optionals($line->id,$extralabels);
2168
+				}
2169
+			}
2170 2170
 		    
2171 2171
 			$TSubNc = array();
2172 2172
 			foreach ($object->lines as &$l)
@@ -2257,80 +2257,80 @@  discard block
 block discarded – undo
2257 2257
 	{
2258 2258
 		dol_include_once('/subtotal/class/subtotal.class.php');
2259 2259
 
2260
-	    $line = &$parameters['line'];
2260
+		$line = &$parameters['line'];
2261 2261
 	    
2262
-	    $ThtmlData['data-id']           = $line->id;
2263
-	    $ThtmlData['data-product_type'] = $line->product_type;
2264
-	    $ThtmlData['data-qty']          = 0; //$line->qty;
2265
-	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2262
+		$ThtmlData['data-id']           = $line->id;
2263
+		$ThtmlData['data-product_type'] = $line->product_type;
2264
+		$ThtmlData['data-qty']          = 0; //$line->qty;
2265
+		$ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2266 2266
 	    
2267
-	    if(TSubtotal::isTitle($line)){
2268
-	        $ThtmlData['data-issubtotal'] = 'title';
2269
-	    }elseif(TSubtotal::isSubtotal($line)){
2270
-	        $ThtmlData['data-issubtotal'] = 'subtotal';
2271
-	    }
2272
-	    else{
2273
-	        $ThtmlData['data-issubtotal'] = 'freetext';
2274
-	    }
2267
+		if(TSubtotal::isTitle($line)){
2268
+			$ThtmlData['data-issubtotal'] = 'title';
2269
+		}elseif(TSubtotal::isSubtotal($line)){
2270
+			$ThtmlData['data-issubtotal'] = 'subtotal';
2271
+		}
2272
+		else{
2273
+			$ThtmlData['data-issubtotal'] = 'freetext';
2274
+		}
2275 2275
 	    
2276 2276
 	    
2277
-	    // Change or add data  from hooks
2278
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2277
+		// Change or add data  from hooks
2278
+		$parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2279 2279
 	    
2280
-	    // hook 
2281
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2282
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2283
-	    if ($reshook>0)
2284
-	    {
2285
-	        $ThtmlData = $hookmanager->resArray;
2286
-	    }
2287
-
2288
-	    return $this->implodeHtmlData($ThtmlData);
2280
+		// hook 
2281
+		$reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2282
+		if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2283
+		if ($reshook>0)
2284
+		{
2285
+			$ThtmlData = $hookmanager->resArray;
2286
+		}
2287
+
2288
+		return $this->implodeHtmlData($ThtmlData);
2289 2289
 	
2290 2290
 	}
2291 2291
 	
2292 2292
 	
2293 2293
 	function implodeHtmlData($ThtmlData = array())
2294 2294
 	{
2295
-	    $data = '';
2296
-	    foreach($ThtmlData as $k => $h )
2297
-	    {
2298
-	        if(is_array($h))
2299
-	        {
2300
-	            $h = json_encode($h);
2301
-	        }
2295
+		$data = '';
2296
+		foreach($ThtmlData as $k => $h )
2297
+		{
2298
+			if(is_array($h))
2299
+			{
2300
+				$h = json_encode($h);
2301
+			}
2302 2302
 	        
2303
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2304
-	    }
2303
+			$data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2304
+		}
2305 2305
 	    
2306
-	    return $data;
2306
+		return $data;
2307 2307
 	}
2308 2308
 	
2309 2309
 	function _ajax_block_order_js($object)
2310 2310
 	{
2311
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2311
+		global $conf,$tagidfortablednd,$filepath,$langs;
2312 2312
 	    
2313
-	    /*
2313
+		/*
2314 2314
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2315 2315
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2316 2316
 	     */
2317 2317
 	    
2318
-	    $id=$object->id;
2319
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2320
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2318
+		$id=$object->id;
2319
+		$nboflines=(isset($object->lines)?count($object->lines):0);
2320
+		$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2321 2321
 	    
2322
-	    $id=$object->id;
2323
-	    $fk_element=$object->fk_element;
2324
-	    $table_element_line=$object->table_element_line;
2325
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2326
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2327
-	    $filepath=(empty($filepath)?'':$filepath);
2322
+		$id=$object->id;
2323
+		$fk_element=$object->fk_element;
2324
+		$table_element_line=$object->table_element_line;
2325
+		$nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2326
+		$tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2327
+		$filepath=(empty($filepath)?'':$filepath);
2328 2328
 	    
2329 2329
 	    
2330
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2331
-	    {
2330
+		if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2331
+		{
2332 2332
 	        
2333
-	        ?>
2333
+			?>
2334 2334
 		
2335 2335
 		
2336 2336
 			<script type="text/javascript">
Please login to merge, or discard this patch.