Completed
Push — master ( 91cbcc...8d44df )
by Alexis
13s queued 10s
created
class/actions_subtotal.class.php 1 patch
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,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;
@@ -1083,19 +1083,19 @@  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) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1095
-		    {
1096
-		        $this->resprints = ' ';
1097
-		        return 1;
1098
-		    }
1094
+			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1095
+			{
1096
+				$this->resprints = ' ';
1097
+				return 1;
1098
+			}
1099 1099
 		}
1100 1100
         
1101 1101
 		return 0;
@@ -1375,11 +1375,11 @@  discard block
 block discarded – undo
1375 1375
 		$hidedetails = (int)GETPOST('hidedetails');
1376 1376
 		
1377 1377
 		if ($hideInnerLines) { // si c une ligne de titre
1378
-	    	$fk_parent_line=0;
1378
+			$fk_parent_line=0;
1379 1379
 			$TLines =array();
1380 1380
 		
1381 1381
 			$original_count=count($object->lines);
1382
-		    $TTvas = array(); // tableau de tva
1382
+			$TTvas = array(); // tableau de tva
1383 1383
 		    
1384 1384
 			foreach($object->lines as $k=>&$line) 
1385 1385
 			{
@@ -1409,48 +1409,48 @@  discard block
 block discarded – undo
1409 1409
 			
1410 1410
 				if ($hideInnerLines)
1411 1411
 				{
1412
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1413
-				    {
1414
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1412
+					if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1413
+					{
1414
+						if($line->tva_tx != '0.000' && $line->product_type!=9){
1415 1415
 				            
1416
-    				        // on remplit le tableau de tva pour substituer les lignes cachées
1417
-    				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1418
-    				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1419
-    				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1420
-    				    }
1421
-    					if($line->product_type==9 && $line->rowid>0)
1422
-    					{
1423
-    					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1424
-    					    // génère des lignes d'affichage des montants HT soumis à tva
1425
-    					    $nbtva = count($TTvas);
1426
-    					    if(!empty($nbtva)){
1427
-    					        foreach ($TTvas as $tx =>$val){
1428
-    					            $l = clone $line;
1429
-    					            $l->product_type = 1;
1430
-    					            $l->special_code = '';
1431
-    					            $l->qty = 1;
1432
-    					            $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1433
-    					            $l->tva_tx = $tx;
1434
-    					            $l->total_ht = $val['total_ht'];
1435
-    					            $l->total_tva = $val['total_tva'];
1436
-    					            $l->total = $line->total_ht;
1437
-    					            $l->total_ttc = $val['total_ttc'];
1438
-    					            $TLines[] = $l;
1439
-    					            array_shift($TTvas);
1440
-    					       }
1441
-    					    }
1416
+							// on remplit le tableau de tva pour substituer les lignes cachées
1417
+							$TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1418
+							$TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1419
+							$TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1420
+						}
1421
+						if($line->product_type==9 && $line->rowid>0)
1422
+						{
1423
+							//Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1424
+							// génère des lignes d'affichage des montants HT soumis à tva
1425
+							$nbtva = count($TTvas);
1426
+							if(!empty($nbtva)){
1427
+								foreach ($TTvas as $tx =>$val){
1428
+									$l = clone $line;
1429
+									$l->product_type = 1;
1430
+									$l->special_code = '';
1431
+									$l->qty = 1;
1432
+									$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1433
+									$l->tva_tx = $tx;
1434
+									$l->total_ht = $val['total_ht'];
1435
+									$l->total_tva = $val['total_tva'];
1436
+									$l->total = $line->total_ht;
1437
+									$l->total_ttc = $val['total_ttc'];
1438
+									$TLines[] = $l;
1439
+									array_shift($TTvas);
1440
+							   }
1441
+							}
1442 1442
     					    
1443
-    					    // ajoute la ligne de sous-total
1444
-    					    $TLines[] = $line; 
1445
-    					}
1446
-				    } else {
1443
+							// ajoute la ligne de sous-total
1444
+							$TLines[] = $line; 
1445
+						}
1446
+					} else {
1447 1447
 				        
1448
-				        if($line->product_type==9 && $line->rowid>0)
1449
-				        {
1450
-				            // ajoute la ligne de sous-total
1451
-				            $TLines[] = $line; 
1452
-				        }
1453
-				    }
1448
+						if($line->product_type==9 && $line->rowid>0)
1449
+						{
1450
+							// ajoute la ligne de sous-total
1451
+							$TLines[] = $line; 
1452
+						}
1453
+					}
1454 1454
 				    
1455 1455
 					
1456 1456
 				}
@@ -1475,20 +1475,20 @@  discard block
 block discarded – undo
1475 1475
 			$nbtva = count($TTvas);
1476 1476
 			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1477 1477
 			{
1478
-			    foreach ($TTvas as $tx =>$val){
1479
-			        $l = clone $line;
1480
-			        $l->product_type = 1;
1481
-			        $l->special_code = '';
1482
-			        $l->qty = 1;
1483
-			        $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1484
-			        $l->tva_tx = $tx;
1485
-			        $l->total_ht = $val['total_ht'];
1486
-			        $l->total_tva = $val['total_tva'];
1487
-			        $l->total = $line->total_ht;
1488
-			        $l->total_ttc = $val['total_ttc'];
1489
-			        $TLines[] = $l;
1490
-			        array_shift($TTvas);
1491
-			    }
1478
+				foreach ($TTvas as $tx =>$val){
1479
+					$l = clone $line;
1480
+					$l->product_type = 1;
1481
+					$l->special_code = '';
1482
+					$l->qty = 1;
1483
+					$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1484
+					$l->tva_tx = $tx;
1485
+					$l->total_ht = $val['total_ht'];
1486
+					$l->total_tva = $val['total_tva'];
1487
+					$l->total = $line->total_ht;
1488
+					$l->total_ttc = $val['total_ttc'];
1489
+					$TLines[] = $l;
1490
+					array_shift($TTvas);
1491
+				}
1492 1492
 			}
1493 1493
 			
1494 1494
 			global $nblignes;
@@ -1500,7 +1500,7 @@  discard block
 block discarded – undo
1500 1500
 				$this->resprints = '';
1501 1501
 				return 0;
1502 1502
 			}
1503
-	    }
1503
+		}
1504 1504
 		
1505 1505
 		return 0;
1506 1506
 	}
@@ -1663,18 +1663,18 @@  discard block
 block discarded – undo
1663 1663
 		}
1664 1664
 		elseif($object->element == 'order_supplier' )
1665 1665
 		{
1666
-		    $createRight = $user->rights->fournisseur->commande->creer;
1666
+			$createRight = $user->rights->fournisseur->commande->creer;
1667 1667
 		}
1668 1668
 		elseif($object->element == 'invoice_supplier' )
1669 1669
 		{
1670
-		    $createRight = $user->rights->fournisseur->facture->creer;
1670
+			$createRight = $user->rights->fournisseur->facture->creer;
1671 1671
 		}
1672 1672
 		
1673 1673
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1674 1674
 			null;
1675 1675
 		}	
1676 1676
 		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)) 
1677
-        {
1677
+		{
1678 1678
 			if($object->element=='facture')$idvar = 'facid';
1679 1679
 			else $idvar='id';
1680 1680
 			
@@ -1721,7 +1721,7 @@  discard block
 block discarded – undo
1721 1721
 			//var_dump($line);
1722 1722
             
1723 1723
 			// HTML 5 data for js
1724
-            $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
1724
+			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
1725 1725
             
1726 1726
 			
1727 1727
 			?>
@@ -1779,8 +1779,8 @@  discard block
 block discarded – undo
1779 1779
 						}
1780 1780
 						
1781 1781
 						if ($object->element == 'order_supplier' || $object->element == 'invoice_supplier') {
1782
-						    $line->label = !empty($line->description) ? $line->description : $line->desc;
1783
-						    $line->description = '';
1782
+							$line->label = !empty($line->description) ? $line->description : $line->desc;
1783
+							$line->description = '';
1784 1784
 						}
1785 1785
 						$newlabel = $line->label;
1786 1786
 						if($line->label=='' && !$isFreeText) {
@@ -2071,17 +2071,17 @@  discard block
 block discarded – undo
2071 2071
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2072 2072
 		{
2073 2073
 		    
2074
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2075
-		    {
2076
-		        foreach ($object->lines as $line)
2077
-		        {
2078
-		            // fetch optionals attributes and labels
2079
-		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2080
-		            $extrafields=new ExtraFields($this->db);
2081
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2082
-		            $line->fetch_optionals($line->id,$extralabels);
2083
-		        }
2084
-		    }
2074
+			if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2075
+			{
2076
+				foreach ($object->lines as $line)
2077
+				{
2078
+					// fetch optionals attributes and labels
2079
+					require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2080
+					$extrafields=new ExtraFields($this->db);
2081
+					$extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2082
+					$line->fetch_optionals($line->id,$extralabels);
2083
+				}
2084
+			}
2085 2085
 		    
2086 2086
 			$TSubNc = array();
2087 2087
 			foreach ($object->lines as &$l)
@@ -2172,80 +2172,80 @@  discard block
 block discarded – undo
2172 2172
 	{
2173 2173
 		dol_include_once('/subtotal/class/subtotal.class.php');
2174 2174
 
2175
-	    $line = &$parameters['line'];
2175
+		$line = &$parameters['line'];
2176 2176
 	    
2177
-	    $ThtmlData['data-id']           = $line->id;
2178
-	    $ThtmlData['data-product_type'] = $line->product_type;
2179
-	    $ThtmlData['data-qty']          = 0; //$line->qty;
2180
-	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2177
+		$ThtmlData['data-id']           = $line->id;
2178
+		$ThtmlData['data-product_type'] = $line->product_type;
2179
+		$ThtmlData['data-qty']          = 0; //$line->qty;
2180
+		$ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2181 2181
 	    
2182
-	    if(TSubtotal::isTitle($line)){
2183
-	        $ThtmlData['data-issubtotal'] = 'title';
2184
-	    }elseif(TSubtotal::isSubtotal($line)){
2185
-	        $ThtmlData['data-issubtotal'] = 'subtotal';
2186
-	    }
2187
-	    else{
2188
-	        $ThtmlData['data-issubtotal'] = 'freetext';
2189
-	    }
2182
+		if(TSubtotal::isTitle($line)){
2183
+			$ThtmlData['data-issubtotal'] = 'title';
2184
+		}elseif(TSubtotal::isSubtotal($line)){
2185
+			$ThtmlData['data-issubtotal'] = 'subtotal';
2186
+		}
2187
+		else{
2188
+			$ThtmlData['data-issubtotal'] = 'freetext';
2189
+		}
2190 2190
 	    
2191 2191
 	    
2192
-	    // Change or add data  from hooks
2193
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2192
+		// Change or add data  from hooks
2193
+		$parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2194 2194
 	    
2195
-	    // hook 
2196
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2197
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2198
-	    if ($reshook>0)
2199
-	    {
2200
-	        $ThtmlData = $hookmanager->resArray;
2201
-	    }
2202
-
2203
-	    return $this->implodeHtmlData($ThtmlData);
2195
+		// hook 
2196
+		$reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2197
+		if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2198
+		if ($reshook>0)
2199
+		{
2200
+			$ThtmlData = $hookmanager->resArray;
2201
+		}
2202
+
2203
+		return $this->implodeHtmlData($ThtmlData);
2204 2204
 	
2205 2205
 	}
2206 2206
 	
2207 2207
 	
2208 2208
 	function implodeHtmlData($ThtmlData = array())
2209 2209
 	{
2210
-	    $data = '';
2211
-	    foreach($ThtmlData as $k => $h )
2212
-	    {
2213
-	        if(is_array($h))
2214
-	        {
2215
-	            $h = json_encode($h);
2216
-	        }
2210
+		$data = '';
2211
+		foreach($ThtmlData as $k => $h )
2212
+		{
2213
+			if(is_array($h))
2214
+			{
2215
+				$h = json_encode($h);
2216
+			}
2217 2217
 	        
2218
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2219
-	    }
2218
+			$data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2219
+		}
2220 2220
 	    
2221
-	    return $data;
2221
+		return $data;
2222 2222
 	}
2223 2223
 	
2224 2224
 	function _ajax_block_order_js($object)
2225 2225
 	{
2226
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2226
+		global $conf,$tagidfortablednd,$filepath,$langs;
2227 2227
 	    
2228
-	    /*
2228
+		/*
2229 2229
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2230 2230
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2231 2231
 	     */
2232 2232
 	    
2233
-	    $id=$object->id;
2234
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2235
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2233
+		$id=$object->id;
2234
+		$nboflines=(isset($object->lines)?count($object->lines):0);
2235
+		$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2236 2236
 	    
2237
-	    $id=$object->id;
2238
-	    $fk_element=$object->fk_element;
2239
-	    $table_element_line=$object->table_element_line;
2240
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2241
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2242
-	    $filepath=(empty($filepath)?'':$filepath);
2237
+		$id=$object->id;
2238
+		$fk_element=$object->fk_element;
2239
+		$table_element_line=$object->table_element_line;
2240
+		$nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2241
+		$tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2242
+		$filepath=(empty($filepath)?'':$filepath);
2243 2243
 	    
2244 2244
 	    
2245
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2246
-	    {
2245
+		if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2246
+		{
2247 2247
 	        
2248
-	        ?>
2248
+			?>
2249 2249
 		
2250 2250
 		
2251 2251
 			<script type="text/javascript">
Please login to merge, or discard this patch.