Passed
Push — master ( 9ce9eb...91cbcc )
by
unknown
02:21
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,35 +341,35 @@  discard block
 block discarded – undo
341 341
 		$TContext = explode(':',$parameters['context']);
342 342
 		if (
343 343
 				in_array('invoicecard',$TContext)
344
-		        || in_array('invoicesuppliercard',$TContext)
344
+				|| in_array('invoicesuppliercard',$TContext)
345 345
 				|| in_array('propalcard',$TContext)
346 346
 				|| in_array('ordercard',$TContext)
347
-		        || in_array('ordersuppliercard',$TContext)
347
+				|| in_array('ordersuppliercard',$TContext)
348 348
 				|| in_array('invoicereccard',$TContext)
349 349
 			)
350
-	        {	
350
+			{	
351 351
 				$hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] : 0;
352 352
 				$hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] : 0;
353 353
 				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] : 0;
354 354
 				
355 355
 				$var=false;
356
-		     	$out.= '<tr '.$bc[$var].'>
356
+			 	$out.= '<tr '.$bc[$var].'>
357 357
 		     			<td colspan="4" align="right">
358 358
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
359 359
 		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
360 360
 		     			</td>
361 361
 		     			</tr>';
362 362
 				
363
-		     	$var=!$var;
364
-		     	$out.= '<tr '.$bc[$var].'>
363
+			 	$var=!$var;
364
+			 	$out.= '<tr '.$bc[$var].'>
365 365
 		     			<td colspan="4" align="right">
366 366
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
367 367
 		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
368 368
 		     			</td>
369 369
 		     			</tr>';
370 370
 		     	
371
-		     	$var=!$var;
372
-		     	$out.= '<tr '.$bc[$var].'>
371
+			 	$var=!$var;
372
+			 	$out.= '<tr '.$bc[$var].'>
373 373
 		     			<td colspan="4" align="right">
374 374
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidePrice').'</label>
375 375
 		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
@@ -381,9 +381,9 @@  discard block
 block discarded – undo
381 381
 				if ( 
382 382
 					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
383 383
 					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
384
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
384
+					|| (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
385 385
 					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
386
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
386
+					|| (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
387 387
 					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
388 388
 				)
389 389
 				{
@@ -402,19 +402,19 @@  discard block
 block discarded – undo
402 402
 			}
403 403
 			
404 404
 		
405
-        return 1;
405
+		return 1;
406 406
 	} 
407 407
 	 
408
-    function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
409
-    {
408
+	function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
409
+	{
410 410
 		
411
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
412
-        {
411
+		if (in_array('invoicecard',explode(':',$parameters['context'])))
412
+		{
413 413
         	
414
-        }
414
+		}
415 415
 		
416
-        return 0;
417
-    }
416
+		return 0;
417
+	}
418 418
 	
419 419
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
420 420
 		global $conf;
@@ -463,11 +463,11 @@  discard block
 block discarded – undo
463 463
 	
464 464
 		if (
465 465
 				in_array('invoicecard',explode(':',$parameters['context']))
466
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
466
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
467 467
 				|| in_array('propalcard',explode(':',$parameters['context']))
468
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
468
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
469 469
 				|| in_array('ordercard',explode(':',$parameters['context']))
470
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
470
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
471 471
 				|| in_array('invoicereccard',explode(':',$parameters['context']))
472 472
 		) {
473 473
 			
@@ -546,20 +546,20 @@  discard block
 block discarded – undo
546 546
 				in_array('invoicecard',explode(':',$parameters['context']))
547 547
 				|| in_array('propalcard',explode(':',$parameters['context']))
548 548
 				|| in_array('ordercard',explode(':',$parameters['context']))
549
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
550
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
551
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
549
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
550
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
551
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
552 552
 			)
553
-	        {								
553
+			{								
554 554
 				if(in_array('invoicecard',explode(':',$parameters['context']))) {
555 555
 					$sessname = 'subtotal_hideInnerLines_facture';	
556 556
 					$sessname2 = 'subtotal_hidedetails_facture';
557 557
 					$sessname3 = 'subtotal_hideprices_facture';
558 558
 				}
559 559
 				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
560
-				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
561
-				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
562
-				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
560
+					$sessname = 'subtotal_hideInnerLines_facture_fournisseur';
561
+					$sessname2 = 'subtotal_hidedetails_facture_fournisseur';
562
+					$sessname3 = 'subtotal_hideprices_facture_fournisseur';
563 563
 				}
564 564
 				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
565 565
 					$sessname = 'subtotal_hideInnerLines_propal';
@@ -567,9 +567,9 @@  discard block
 block discarded – undo
567 567
 					$sessname3 = 'subtotal_hideprices_propal';
568 568
 				}
569 569
 				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
570
-				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
571
-				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
572
-				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
570
+					$sessname = 'subtotal_hideInnerLines_supplier_proposal';
571
+					$sessname2 = 'subtotal_hidedetails_supplier_proposal';
572
+					$sessname3 = 'subtotal_hideprices_supplier_proposal';
573 573
 				}
574 574
 				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
575 575
 					$sessname = 'subtotal_hideInnerLines_commande';
@@ -577,9 +577,9 @@  discard block
 block discarded – undo
577 577
 					$sessname3 = 'subtotal_hideprices_commande';
578 578
 				}
579 579
 				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
580
-				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
581
-				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
582
-				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
580
+					$sessname = 'subtotal_hideInnerLines_commande_fournisseur';
581
+					$sessname2 = 'subtotal_hidedetails_commande_fournisseur';
582
+					$sessname3 = 'subtotal_hideprices_commande_fournisseur';
583 583
 				}
584 584
 				else {
585 585
 					$sessname = 'subtotal_hideInnerLines_unknown';
@@ -601,17 +601,17 @@  discard block
 block discarded – undo
601 601
 				foreach($object->lines as &$line) {
602 602
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
603 603
 					    
604
-                        if($line->qty>=90) {
605
-                            $line->modsubtotal_total = 1;
606
-                        }
607
-                        else{
608
-                            $line->modsubtotal_title = 1;
609
-                        }
604
+						if($line->qty>=90) {
605
+							$line->modsubtotal_total = 1;
606
+						}
607
+						else{
608
+							$line->modsubtotal_title = 1;
609
+						}
610 610
                         
611 611
 						$line->total_ht = $this->getTotalLineFromObject($object, $line, '');
612 612
 					}
613
-	        	}
614
-	        }
613
+				}
614
+			}
615 615
 			
616 616
 		}
617 617
 		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
 				 */
629 629
 				else if($object->element=='invoice_supplier')
630 630
 				{
631
-				    $object->deleteline($idLine);
631
+					$object->deleteline($idLine);
632 632
 				}
633 633
 				/**
634 634
 				 * @var $object Propal
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 				 */
652 652
 				else if($object->element=='order_supplier')
653 653
 				{
654
-				    $object->deleteline($idLine);
654
+					$object->deleteline($idLine);
655 655
 				}
656 656
 				/**
657 657
 				 * @var $object Facturerec
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 		
696 696
 		foreach($object->lines as $l) {
697 697
 		
698
-		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
698
+			$lid = (!empty($l->rowid) ? $l->rowid : $l->id);
699 699
 			if($lid == $lineid) {
700 700
 
701 701
 				$found = true;
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 			
705 705
 			if($found) {
706 706
 				
707
-			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
707
+				$Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
708 708
 				
709 709
 				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
710 710
 					break; // end of story
@@ -783,17 +783,17 @@  discard block
 block discarded – undo
783 783
 			if($l->rang>=$rang) {
784 784
 				return price($total);
785 785
 			}
786
-                        if (TSubtotal::isSubtotal($l)){
787
-                            $total = 0;
788
-                        } else  if ($l->situation_percent > 0 ){
786
+						if (TSubtotal::isSubtotal($l)){
787
+							$total = 0;
788
+						} else  if ($l->situation_percent > 0 ){
789 789
                            
790 790
         	
791 791
 		 	$prev_progress = $l->get_prev_progress($object->id);
792 792
 		 	$progress = ($l->situation_percent - $prev_progress) /100;
793
-                        $total += ($l->total_ht/($l->situation_percent/100)) * $progress;
793
+						$total += ($l->total_ht/($l->situation_percent/100)) * $progress;
794 794
                         
795
-                    }
796
-                }
795
+					}
796
+				}
797 797
                 
798 798
 		return price($total);
799 799
 	}
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
 		if(method_exists('Closure','bind')) {
826 826
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
827 827
 			$sweetsThief = function ($pdf) {
828
-		    		return $pdf->bMargin ;
828
+					return $pdf->bMargin ;
829 829
 			};
830 830
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
831 831
 	
@@ -888,11 +888,11 @@  discard block
 block discarded – undo
888 888
 				else
889 889
 				{
890 890
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
891
-                                        if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
892
-                                                $total_to_print = $this->getTotalToPrintSituation($object, $line);
893
-                                        } else {
894
-                                            	$total_to_print = price($total);
895
-                                        }
891
+										if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
892
+												$total_to_print = $this->getTotalToPrintSituation($object, $line);
893
+										} else {
894
+												$total_to_print = price($total);
895
+										}
896 896
                                             
897 897
 					$line->total_ht = $total;
898 898
 					$line->total = $total;
@@ -1082,19 +1082,19 @@  discard block
 block discarded – undo
1082 1082
 			}
1083 1083
 		}
1084 1084
 		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1085
-		    if(is_array($parameters)) $i = & $parameters['i'];
1086
-		    else $i = (int)$parameters;
1087
-		    $this->resprints = price($object->lines[$i]->total_ht);
1085
+			if(is_array($parameters)) $i = & $parameters['i'];
1086
+			else $i = (int)$parameters;
1087
+			$this->resprints = price($object->lines[$i]->total_ht);
1088 1088
 		}
1089 1089
 		if (!empty($hideprices)
1090
-		    || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1091
-		    )
1090
+			|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1091
+			)
1092 1092
 		{
1093
-		    if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1094
-		    {
1095
-		        $this->resprints = ' ';
1096
-		        return 1;
1097
-		    }
1093
+			if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1094
+			{
1095
+				$this->resprints = ' ';
1096
+				return 1;
1097
+			}
1098 1098
 		}
1099 1099
         
1100 1100
 		return 0;
@@ -1374,11 +1374,11 @@  discard block
 block discarded – undo
1374 1374
 		$hidedetails = (int)GETPOST('hidedetails');
1375 1375
 		
1376 1376
 		if ($hideInnerLines) { // si c une ligne de titre
1377
-	    	$fk_parent_line=0;
1377
+			$fk_parent_line=0;
1378 1378
 			$TLines =array();
1379 1379
 		
1380 1380
 			$original_count=count($object->lines);
1381
-		    $TTvas = array(); // tableau de tva
1381
+			$TTvas = array(); // tableau de tva
1382 1382
 		    
1383 1383
 			foreach($object->lines as $k=>&$line) 
1384 1384
 			{
@@ -1408,48 +1408,48 @@  discard block
 block discarded – undo
1408 1408
 			
1409 1409
 				if ($hideInnerLines)
1410 1410
 				{
1411
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1412
-				    {
1413
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1411
+					if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1412
+					{
1413
+						if($line->tva_tx != '0.000' && $line->product_type!=9){
1414 1414
 				            
1415
-    				        // on remplit le tableau de tva pour substituer les lignes cachées
1416
-    				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1417
-    				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1418
-    				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1419
-    				    }
1420
-    					if($line->product_type==9 && $line->rowid>0)
1421
-    					{
1422
-    					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1423
-    					    // génère des lignes d'affichage des montants HT soumis à tva
1424
-    					    $nbtva = count($TTvas);
1425
-    					    if(!empty($nbtva)){
1426
-    					        foreach ($TTvas as $tx =>$val){
1427
-    					            $l = clone $line;
1428
-    					            $l->product_type = 1;
1429
-    					            $l->special_code = '';
1430
-    					            $l->qty = 1;
1431
-    					            $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1432
-    					            $l->tva_tx = $tx;
1433
-    					            $l->total_ht = $val['total_ht'];
1434
-    					            $l->total_tva = $val['total_tva'];
1435
-    					            $l->total = $line->total_ht;
1436
-    					            $l->total_ttc = $val['total_ttc'];
1437
-    					            $TLines[] = $l;
1438
-    					            array_shift($TTvas);
1439
-    					       }
1440
-    					    }
1415
+							// on remplit le tableau de tva pour substituer les lignes cachées
1416
+							$TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1417
+							$TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1418
+							$TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1419
+						}
1420
+						if($line->product_type==9 && $line->rowid>0)
1421
+						{
1422
+							//Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1423
+							// génère des lignes d'affichage des montants HT soumis à tva
1424
+							$nbtva = count($TTvas);
1425
+							if(!empty($nbtva)){
1426
+								foreach ($TTvas as $tx =>$val){
1427
+									$l = clone $line;
1428
+									$l->product_type = 1;
1429
+									$l->special_code = '';
1430
+									$l->qty = 1;
1431
+									$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1432
+									$l->tva_tx = $tx;
1433
+									$l->total_ht = $val['total_ht'];
1434
+									$l->total_tva = $val['total_tva'];
1435
+									$l->total = $line->total_ht;
1436
+									$l->total_ttc = $val['total_ttc'];
1437
+									$TLines[] = $l;
1438
+									array_shift($TTvas);
1439
+							   }
1440
+							}
1441 1441
     					    
1442
-    					    // ajoute la ligne de sous-total
1443
-    					    $TLines[] = $line; 
1444
-    					}
1445
-				    } else {
1442
+							// ajoute la ligne de sous-total
1443
+							$TLines[] = $line; 
1444
+						}
1445
+					} else {
1446 1446
 				        
1447
-				        if($line->product_type==9 && $line->rowid>0)
1448
-				        {
1449
-				            // ajoute la ligne de sous-total
1450
-				            $TLines[] = $line; 
1451
-				        }
1452
-				    }
1447
+						if($line->product_type==9 && $line->rowid>0)
1448
+						{
1449
+							// ajoute la ligne de sous-total
1450
+							$TLines[] = $line; 
1451
+						}
1452
+					}
1453 1453
 				    
1454 1454
 					
1455 1455
 				}
@@ -1474,20 +1474,20 @@  discard block
 block discarded – undo
1474 1474
 			$nbtva = count($TTvas);
1475 1475
 			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1476 1476
 			{
1477
-			    foreach ($TTvas as $tx =>$val){
1478
-			        $l = clone $line;
1479
-			        $l->product_type = 1;
1480
-			        $l->special_code = '';
1481
-			        $l->qty = 1;
1482
-			        $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1483
-			        $l->tva_tx = $tx;
1484
-			        $l->total_ht = $val['total_ht'];
1485
-			        $l->total_tva = $val['total_tva'];
1486
-			        $l->total = $line->total_ht;
1487
-			        $l->total_ttc = $val['total_ttc'];
1488
-			        $TLines[] = $l;
1489
-			        array_shift($TTvas);
1490
-			    }
1477
+				foreach ($TTvas as $tx =>$val){
1478
+					$l = clone $line;
1479
+					$l->product_type = 1;
1480
+					$l->special_code = '';
1481
+					$l->qty = 1;
1482
+					$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1483
+					$l->tva_tx = $tx;
1484
+					$l->total_ht = $val['total_ht'];
1485
+					$l->total_tva = $val['total_tva'];
1486
+					$l->total = $line->total_ht;
1487
+					$l->total_ttc = $val['total_ttc'];
1488
+					$TLines[] = $l;
1489
+					array_shift($TTvas);
1490
+				}
1491 1491
 			}
1492 1492
 			
1493 1493
 			global $nblignes;
@@ -1499,7 +1499,7 @@  discard block
 block discarded – undo
1499 1499
 				$this->resprints = '';
1500 1500
 				return 0;
1501 1501
 			}
1502
-	    }
1502
+		}
1503 1503
 		
1504 1504
 		return 0;
1505 1505
 	}
@@ -1662,18 +1662,18 @@  discard block
 block discarded – undo
1662 1662
 		}
1663 1663
 		elseif($object->element == 'order_supplier' )
1664 1664
 		{
1665
-		    $createRight = $user->rights->fournisseur->commande->creer;
1665
+			$createRight = $user->rights->fournisseur->commande->creer;
1666 1666
 		}
1667 1667
 		elseif($object->element == 'invoice_supplier' )
1668 1668
 		{
1669
-		    $createRight = $user->rights->fournisseur->facture->creer;
1669
+			$createRight = $user->rights->fournisseur->facture->creer;
1670 1670
 		}
1671 1671
 		
1672 1672
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1673 1673
 			null;
1674 1674
 		}	
1675 1675
 		else if (in_array('invoicecard',$contexts) || in_array('invoicesuppliercard',$contexts) || in_array('propalcard',$contexts) || in_array('supplier_proposalcard',$contexts) || in_array('ordercard',$contexts) || in_array('ordersuppliercard',$contexts) || in_array('invoicereccard',$contexts)) 
1676
-        {
1676
+		{
1677 1677
 			if($object->element=='facture')$idvar = 'facid';
1678 1678
 			else $idvar='id';
1679 1679
 			
@@ -1720,7 +1720,7 @@  discard block
 block discarded – undo
1720 1720
 			//var_dump($line);
1721 1721
             
1722 1722
 			// HTML 5 data for js
1723
-            $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
1723
+			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
1724 1724
             
1725 1725
 			
1726 1726
 			?>
@@ -1778,8 +1778,8 @@  discard block
 block discarded – undo
1778 1778
 						}
1779 1779
 						
1780 1780
 						if ($object->element == 'order_supplier' || $object->element == 'invoice_supplier') {
1781
-						    $line->label = !empty($line->description) ? $line->description : $line->desc;
1782
-						    $line->description = '';
1781
+							$line->label = !empty($line->description) ? $line->description : $line->desc;
1782
+							$line->description = '';
1783 1783
 						}
1784 1784
 						$newlabel = $line->label;
1785 1785
 						if($line->label=='' && !$isFreeText) {
@@ -2070,17 +2070,17 @@  discard block
 block discarded – undo
2070 2070
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2071 2071
 		{
2072 2072
 		    
2073
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2074
-		    {
2075
-		        foreach ($object->lines as $line)
2076
-		        {
2077
-		            // fetch optionals attributes and labels
2078
-		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2079
-		            $extrafields=new ExtraFields($this->db);
2080
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2081
-		            $line->fetch_optionals($line->id,$extralabels);
2082
-		        }
2083
-		    }
2073
+			if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2074
+			{
2075
+				foreach ($object->lines as $line)
2076
+				{
2077
+					// fetch optionals attributes and labels
2078
+					require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2079
+					$extrafields=new ExtraFields($this->db);
2080
+					$extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2081
+					$line->fetch_optionals($line->id,$extralabels);
2082
+				}
2083
+			}
2084 2084
 		    
2085 2085
 			$TSubNc = array();
2086 2086
 			foreach ($object->lines as &$l)
@@ -2171,80 +2171,80 @@  discard block
 block discarded – undo
2171 2171
 	{
2172 2172
 		dol_include_once('/subtotal/class/subtotal.class.php');
2173 2173
 
2174
-	    $line = &$parameters['line'];
2174
+		$line = &$parameters['line'];
2175 2175
 	    
2176
-	    $ThtmlData['data-id']           = $line->id;
2177
-	    $ThtmlData['data-product_type'] = $line->product_type;
2178
-	    $ThtmlData['data-qty']          = 0; //$line->qty;
2179
-	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2176
+		$ThtmlData['data-id']           = $line->id;
2177
+		$ThtmlData['data-product_type'] = $line->product_type;
2178
+		$ThtmlData['data-qty']          = 0; //$line->qty;
2179
+		$ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2180 2180
 	    
2181
-	    if(TSubtotal::isTitle($line)){
2182
-	        $ThtmlData['data-issubtotal'] = 'title';
2183
-	    }elseif(TSubtotal::isSubtotal($line)){
2184
-	        $ThtmlData['data-issubtotal'] = 'subtotal';
2185
-	    }
2186
-	    else{
2187
-	        $ThtmlData['data-issubtotal'] = 'freetext';
2188
-	    }
2181
+		if(TSubtotal::isTitle($line)){
2182
+			$ThtmlData['data-issubtotal'] = 'title';
2183
+		}elseif(TSubtotal::isSubtotal($line)){
2184
+			$ThtmlData['data-issubtotal'] = 'subtotal';
2185
+		}
2186
+		else{
2187
+			$ThtmlData['data-issubtotal'] = 'freetext';
2188
+		}
2189 2189
 	    
2190 2190
 	    
2191
-	    // Change or add data  from hooks
2192
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2191
+		// Change or add data  from hooks
2192
+		$parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2193 2193
 	    
2194
-	    // hook 
2195
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2196
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2197
-	    if ($reshook>0)
2198
-	    {
2199
-	        $ThtmlData = $hookmanager->resArray;
2200
-	    }
2201
-
2202
-	    return $this->implodeHtmlData($ThtmlData);
2194
+		// hook 
2195
+		$reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2196
+		if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2197
+		if ($reshook>0)
2198
+		{
2199
+			$ThtmlData = $hookmanager->resArray;
2200
+		}
2201
+
2202
+		return $this->implodeHtmlData($ThtmlData);
2203 2203
 	
2204 2204
 	}
2205 2205
 	
2206 2206
 	
2207 2207
 	function implodeHtmlData($ThtmlData = array())
2208 2208
 	{
2209
-	    $data = '';
2210
-	    foreach($ThtmlData as $k => $h )
2211
-	    {
2212
-	        if(is_array($h))
2213
-	        {
2214
-	            $h = json_encode($h);
2215
-	        }
2209
+		$data = '';
2210
+		foreach($ThtmlData as $k => $h )
2211
+		{
2212
+			if(is_array($h))
2213
+			{
2214
+				$h = json_encode($h);
2215
+			}
2216 2216
 	        
2217
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2218
-	    }
2217
+			$data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2218
+		}
2219 2219
 	    
2220
-	    return $data;
2220
+		return $data;
2221 2221
 	}
2222 2222
 	
2223 2223
 	function _ajax_block_order_js($object)
2224 2224
 	{
2225
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2225
+		global $conf,$tagidfortablednd,$filepath,$langs;
2226 2226
 	    
2227
-	    /*
2227
+		/*
2228 2228
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2229 2229
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2230 2230
 	     */
2231 2231
 	    
2232
-	    $id=$object->id;
2233
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2234
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2232
+		$id=$object->id;
2233
+		$nboflines=(isset($object->lines)?count($object->lines):0);
2234
+		$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2235 2235
 	    
2236
-	    $id=$object->id;
2237
-	    $fk_element=$object->fk_element;
2238
-	    $table_element_line=$object->table_element_line;
2239
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2240
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2241
-	    $filepath=(empty($filepath)?'':$filepath);
2236
+		$id=$object->id;
2237
+		$fk_element=$object->fk_element;
2238
+		$table_element_line=$object->table_element_line;
2239
+		$nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2240
+		$tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2241
+		$filepath=(empty($filepath)?'':$filepath);
2242 2242
 	    
2243 2243
 	    
2244
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2245
-	    {
2244
+		if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2245
+		{
2246 2246
 	        
2247
-	        ?>
2247
+			?>
2248 2248
 		
2249 2249
 		
2250 2250
 			<script type="text/javascript">
Please login to merge, or discard this patch.
lib/subtotal.lib.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -25,25 +25,25 @@  discard block
 block discarded – undo
25 25
 
26 26
 function subtotalAdminPrepareHead()
27 27
 {
28
-    global $langs, $conf;
28
+	global $langs, $conf;
29 29
 
30
-    $langs->load("subtotal@subtotal");
30
+	$langs->load("subtotal@subtotal");
31 31
 
32
-    $h = 0;
33
-    $head = array();
32
+	$h = 0;
33
+	$head = array();
34 34
 
35
-    $head[$h][0] = dol_buildpath("/subtotal/admin/subtotal_setup.php", 1);
36
-    $head[$h][1] = $langs->trans("Parameters");
37
-    $head[$h][2] = 'settings';
38
-    $h++;
39
-    $head[$h][0] = dol_buildpath("/subtotal/admin/subtotal_about.php", 1);
40
-    $head[$h][1] = $langs->trans("About");
41
-    $head[$h][2] = 'about';
42
-    $h++;
35
+	$head[$h][0] = dol_buildpath("/subtotal/admin/subtotal_setup.php", 1);
36
+	$head[$h][1] = $langs->trans("Parameters");
37
+	$head[$h][2] = 'settings';
38
+	$h++;
39
+	$head[$h][0] = dol_buildpath("/subtotal/admin/subtotal_about.php", 1);
40
+	$head[$h][1] = $langs->trans("About");
41
+	$head[$h][2] = 'about';
42
+	$h++;
43 43
 
44
-    complete_head_from_modules($conf, $langs, $object, $head, $h, 'subtotal', $showLabel=false);
44
+	complete_head_from_modules($conf, $langs, $object, $head, $h, 'subtotal', $showLabel=false);
45 45
 
46
-    return $head;
46
+	return $head;
47 47
 }
48 48
 
49 49
 function getHtmlSelectTitle(&$object, $showLabel=false)
@@ -242,17 +242,17 @@  discard block
 block discarded – undo
242 242
 			$classname = ucfirst($element);
243 243
 			
244 244
 			switch ($element) {
245
-			    case 'supplier_proposal':
246
-			        $classname = 'SupplierProposal';
247
-			        break;
245
+				case 'supplier_proposal':
246
+					$classname = 'SupplierProposal';
247
+					break;
248 248
 			        
249
-			    case 'order_supplier':
250
-			        $classname = 'CommandeFournisseur';
251
-			        break;
249
+				case 'order_supplier':
250
+					$classname = 'CommandeFournisseur';
251
+					break;
252 252
 			        
253
-			    case 'invoice_supplier':
254
-			        $classname = 'FactureFournisseur';
255
-			        break;
253
+				case 'invoice_supplier':
254
+					$classname = 'FactureFournisseur';
255
+					break;
256 256
 			}
257 257
 			
258 258
 			$object = new $classname($db); // Propal | Commande | Facture
@@ -325,14 +325,14 @@  discard block
 block discarded – undo
325 325
 		else $res = $line->update($user);
326 326
 	}
327 327
 	else {
328
-	    if(in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
329
-	        if(empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
328
+		if(in_array($object->element, array('invoice_supplier', 'order_supplier', 'supplier_proposal'))) {
329
+			if(empty($line->label)) $line->label = $line->description; // supplier lines don't have the field label
330 330
 	        
331
-	        require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
332
-	        $extrafields=new ExtraFields($object->db);
333
-	        $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
334
-	        $line->fetch_optionals($line->id,$extralabels);
335
-	    }
331
+			require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
332
+			$extrafields=new ExtraFields($object->db);
333
+			$extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
334
+			$line->fetch_optionals($line->id,$extralabels);
335
+		}
336 336
 		$line->array_options['options_subtotal_nc'] = 0;
337 337
 		if($object->element == 'order_supplier') $line->update($user);
338 338
 		$res = TSubtotal::doUpdateLine($object, $line->id, $line->desc, $line->subprice, $line->qty, $line->remise_percent, $line->date_start, $line->date_end, $line->tva_tx, $line->product_type, $line->localtax1_tx, $line->localtax2_tx, 'HT', $line->info_bits, $line->fk_parent_line, $line->skip_update_total, $line->fk_fournprice, $line->pa_ht, $line->label, $line->special_code, $line->array_options, $line->situation_percent, $line->fk_unit);
Please login to merge, or discard this patch.