Passed
Pull Request — master (#144)
by
unknown
03:07
created
admin/subtotal_setup.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 // Dolibarr environment
29 29
 $res = @include("../../main.inc.php"); // From htdocs directory
30 30
 if (! $res) {
31
-    $res = @include("../../../main.inc.php"); // From "custom" directory
31
+	$res = @include("../../../main.inc.php"); // From "custom" directory
32 32
 }
33 33
 
34 34
 // Libraries
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 
40 40
 // Access control
41 41
 if (! $user->admin) {
42
-    accessforbidden();
42
+	accessforbidden();
43 43
 }
44 44
 
45 45
 // Parameters
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
 // Configuration header
97 97
 $head = subtotalAdminPrepareHead();
98 98
 dol_fiche_head(
99
-    $head,
100
-    'settings',
101
-    $langs->trans("Module104777Name"),
102
-    -1,
103
-    "subtotal@subtotal"
99
+	$head,
100
+	'settings',
101
+	$langs->trans("Module104777Name"),
102
+	-1,
103
+	"subtotal@subtotal"
104 104
 );
105 105
 
106 106
 showParameters();
@@ -169,13 +169,13 @@  discard block
 block discarded – undo
169 169
 	print ajax_constantonoff('SUBTOTAL_ALLOW_DUPLICATE_BLOCK');
170 170
 	print '</td></tr>';
171 171
 
172
-    $var=!$var;
173
-    print '<tr '.$bc[$var].'>';
174
-    print '<td>'.$langs->trans("SUBTOTAL_ALLOW_DUPLICATE_LINE").'</td>';
175
-    print '<td align="center" width="20">&nbsp;</td>';
176
-    print '<td align="center" width="300">';
177
-    print ajax_constantonoff('SUBTOTAL_ALLOW_DUPLICATE_LINE');
178
-    print '</td></tr>';
172
+	$var=!$var;
173
+	print '<tr '.$bc[$var].'>';
174
+	print '<td>'.$langs->trans("SUBTOTAL_ALLOW_DUPLICATE_LINE").'</td>';
175
+	print '<td align="center" width="20">&nbsp;</td>';
176
+	print '<td align="center" width="300">';
177
+	print ajax_constantonoff('SUBTOTAL_ALLOW_DUPLICATE_LINE');
178
+	print '</td></tr>';
179 179
 	
180 180
 	$var=!$var;
181 181
 	print '<tr '.$bc[$var].'>';
@@ -272,12 +272,12 @@  discard block
 block discarded – undo
272 272
 		print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
273 273
 		print '<input type="hidden" name="action" value="set_SUBTOTAL_TFIELD_TO_KEEP_WITH_NC">';
274 274
 		$TField = array(
275
-		    'pdf_getlineqty' => $langs->trans('Qty'), 
276
-		    'pdf_getlinevatrate' => $langs->trans('VAT'), 
277
-		    'pdf_getlineupexcltax' => $langs->trans('PriceUHT'), 
278
-		    'pdf_getlinetotalexcltax' => $langs->trans('TotalHT'), 
279
-		    'pdf_getlineunit' => $langs->trans('Unit'),
280
-		    'pdf_getlineremisepercent' => $langs->trans('Discount')
275
+			'pdf_getlineqty' => $langs->trans('Qty'), 
276
+			'pdf_getlinevatrate' => $langs->trans('VAT'), 
277
+			'pdf_getlineupexcltax' => $langs->trans('PriceUHT'), 
278
+			'pdf_getlinetotalexcltax' => $langs->trans('TotalHT'), 
279
+			'pdf_getlineunit' => $langs->trans('Unit'),
280
+			'pdf_getlineremisepercent' => $langs->trans('Discount')
281 281
 		);
282 282
 		print $html->multiselectarray('SUBTOTAL_TFIELD_TO_KEEP_WITH_NC', $TField, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC), 0, 0, '', 0, 0, 'style="min-width:100px"');
283 283
 		print '<input type="submit" class="button" value="'.$langs->trans("Modify").'">';
Please login to merge, or discard this patch.
class/actions_subtotal.class.php 1 patch
Indentation   +337 added lines, -337 removed lines patch added patch discarded remove patch
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	 * @return     void
102 102
 	 */
103 103
     
104
-    var $module_number = 104777;
104
+	var $module_number = 104777;
105 105
     
106
-    function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
107
-    {
108
-      	global $langs,$db,$user, $conf;
106
+	function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
107
+	{
108
+	  	global $langs,$db,$user, $conf;
109 109
 		
110 110
 		$langs->load('subtotal@subtotal');
111 111
 		
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
 				$createRight = $user->rights->facture->creer;
121 121
 			} elseif($object->element == 'order_supplier' )
122 122
 			{
123
-			    $createRight = $user->rights->fournisseur->commande->creer;
123
+				$createRight = $user->rights->fournisseur->commande->creer;
124 124
 			} elseif($object->element == 'invoice_supplier' )
125 125
 			{
126
-			    $createRight = $user->rights->fournisseur->facture->creer;
126
+				$createRight = $user->rights->fournisseur->facture->creer;
127 127
 			}
128 128
 			elseif($object->element == 'shipping')
129 129
 			{
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 					
178 178
 					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
179 179
 					
180
-	    			TSubtotal::addSubTotalLine($object, $title, $qty);
180
+					TSubtotal::addSubTotalLine($object, $title, $qty);
181 181
 				}
182 182
 				else if($action==='ask_deleteallline') {
183 183
 						$form=new Form($db);
@@ -399,36 +399,36 @@  discard block
 block discarded – undo
399 399
 		$TContext = explode(':',$parameters['context']);
400 400
 		if (
401 401
 				in_array('invoicecard',$TContext)
402
-		        || in_array('invoicesuppliercard',$TContext)
402
+				|| in_array('invoicesuppliercard',$TContext)
403 403
 				|| in_array('propalcard',$TContext)
404 404
 				|| in_array('ordercard',$TContext)
405
-		        || in_array('ordersuppliercard',$TContext)
405
+				|| in_array('ordersuppliercard',$TContext)
406 406
 				|| in_array('invoicereccard',$TContext)
407 407
 			)
408
-	        {	
409
-	            $hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
410
-	            $hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
408
+			{	
409
+				$hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']][$object->id] : 0;
410
+				$hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']][$object->id] : 0;
411 411
 				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0;
412 412
 				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']][$object->id] : $hidepricesDefaultConf;
413 413
 				
414 414
 				$var=false;
415
-		     	$out.= '<tr '.$bc[$var].'>
415
+			 	$out.= '<tr '.$bc[$var].'>
416 416
 		     			<td colspan="4" align="right">
417 417
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
418 418
 		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
419 419
 		     			</td>
420 420
 		     			</tr>';
421 421
 				
422
-		     	$var=!$var;
423
-		     	$out.= '<tr '.$bc[$var].'>
422
+			 	$var=!$var;
423
+			 	$out.= '<tr '.$bc[$var].'>
424 424
 		     			<td colspan="4" align="right">
425 425
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
426 426
 		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
427 427
 		     			</td>
428 428
 		     			</tr>';
429 429
 		     	
430
-		     	$var=!$var;
431
-		     	$out.= '<tr '.$bc[$var].'>
430
+			 	$var=!$var;
431
+			 	$out.= '<tr '.$bc[$var].'>
432 432
 		     			<td colspan="4" align="right">
433 433
 		     				<label for="hideprices">'.$langs->trans('SubTotalhidePrice').'</label>
434 434
 		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
@@ -440,9 +440,9 @@  discard block
 block discarded – undo
440 440
 				if ( 
441 441
 					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
442 442
 					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
443
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
443
+					|| (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
444 444
 					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
445
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
445
+					|| (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
446 446
 					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
447 447
 				)
448 448
 				{
@@ -461,19 +461,19 @@  discard block
 block discarded – undo
461 461
 			}
462 462
 			
463 463
 		
464
-        return 1;
464
+		return 1;
465 465
 	} 
466 466
 	 
467
-    function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
468
-    {
467
+	function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
468
+	{
469 469
 		
470
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
471
-        {
470
+		if (in_array('invoicecard',explode(':',$parameters['context'])))
471
+		{
472 472
         	
473
-        }
473
+		}
474 474
 		
475
-        return 0;
476
-    }
475
+		return 0;
476
+	}
477 477
 	
478 478
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
479 479
 		global $conf;
@@ -484,14 +484,14 @@  discard block
 block discarded – undo
484 484
 			$object = &$parameters['object'];
485 485
 			$substitutionarray = &$parameters['substitutionarray'];
486 486
 			
487
-            $substitutionarray['line_not_modsubtotal'] = true;
488
-            $substitutionarray['line_modsubtotal'] = false;
489
-            $substitutionarray['line_modsubtotal_total'] = false;
490
-            $substitutionarray['line_modsubtotal_title'] = false;
487
+			$substitutionarray['line_not_modsubtotal'] = true;
488
+			$substitutionarray['line_modsubtotal'] = false;
489
+			$substitutionarray['line_modsubtotal_total'] = false;
490
+			$substitutionarray['line_modsubtotal_title'] = false;
491 491
 
492 492
 			if($line->product_type == 9 && $line->special_code == $this->module_number) {
493 493
 				$substitutionarray['line_modsubtotal'] = 1;	
494
-                $substitutionarray['line_not_modsubtotal'] = false;
494
+				$substitutionarray['line_not_modsubtotal'] = false;
495 495
 				
496 496
 				$substitutionarray['line_price_ht']
497 497
 					 = $substitutionarray['line_price_vat'] 
@@ -505,7 +505,7 @@  discard block
 block discarded – undo
505 505
 					$substitutionarray['line_modsubtotal_total'] = true;
506 506
 					
507 507
 					//list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
508
-                    $TInfo = $this->getTotalLineFromObject($object, $line, '', 1);
508
+					$TInfo = $this->getTotalLineFromObject($object, $line, '', 1);
509 509
 
510 510
 					$substitutionarray['line_price_ht'] = price($TInfo[0]);
511 511
 					$substitutionarray['line_price_vat'] = price($TInfo[1]);
@@ -529,11 +529,11 @@  discard block
 block discarded – undo
529 529
 	
530 530
 		if (
531 531
 				in_array('invoicecard',explode(':',$parameters['context']))
532
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
532
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
533 533
 				|| in_array('propalcard',explode(':',$parameters['context']))
534
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
534
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
535 535
 				|| in_array('ordercard',explode(':',$parameters['context']))
536
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
536
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
537 537
 				|| in_array('invoicereccard',explode(':',$parameters['context']))
538 538
 		) {
539 539
 			
@@ -612,20 +612,20 @@  discard block
 block discarded – undo
612 612
 				in_array('invoicecard',explode(':',$parameters['context']))
613 613
 				|| in_array('propalcard',explode(':',$parameters['context']))
614 614
 				|| in_array('ordercard',explode(':',$parameters['context']))
615
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
616
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
617
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
615
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
616
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
617
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
618 618
 			)
619
-	        {								
619
+			{								
620 620
 				if(in_array('invoicecard',explode(':',$parameters['context']))) {
621 621
 					$sessname = 'subtotal_hideInnerLines_facture';	
622 622
 					$sessname2 = 'subtotal_hidedetails_facture';
623 623
 					$sessname3 = 'subtotal_hideprices_facture';
624 624
 				}
625 625
 				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
626
-				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
627
-				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
628
-				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
626
+					$sessname = 'subtotal_hideInnerLines_facture_fournisseur';
627
+					$sessname2 = 'subtotal_hidedetails_facture_fournisseur';
628
+					$sessname3 = 'subtotal_hideprices_facture_fournisseur';
629 629
 				}
630 630
 				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
631 631
 					$sessname = 'subtotal_hideInnerLines_propal';
@@ -633,9 +633,9 @@  discard block
 block discarded – undo
633 633
 					$sessname3 = 'subtotal_hideprices_propal';
634 634
 				}
635 635
 				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
636
-				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
637
-				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
638
-				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
636
+					$sessname = 'subtotal_hideInnerLines_supplier_proposal';
637
+					$sessname2 = 'subtotal_hidedetails_supplier_proposal';
638
+					$sessname3 = 'subtotal_hideprices_supplier_proposal';
639 639
 				}
640 640
 				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
641 641
 					$sessname = 'subtotal_hideInnerLines_commande';
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
 					$sessname3 = 'subtotal_hideprices_commande';
644 644
 				}
645 645
 				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
646
-				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
647
-				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
648
-				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
646
+					$sessname = 'subtotal_hideInnerLines_commande_fournisseur';
647
+					$sessname2 = 'subtotal_hidedetails_commande_fournisseur';
648
+					$sessname3 = 'subtotal_hideprices_commande_fournisseur';
649 649
 				}
650 650
 				else {
651 651
 					$sessname = 'subtotal_hideInnerLines_unknown';
@@ -670,17 +670,17 @@  discard block
 block discarded – undo
670 670
 				foreach($object->lines as &$line) {
671 671
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
672 672
 					    
673
-                        if($line->qty>=90) {
674
-                            $line->modsubtotal_total = 1;
675
-                        }
676
-                        else{
677
-                            $line->modsubtotal_title = 1;
678
-                        }
673
+						if($line->qty>=90) {
674
+							$line->modsubtotal_total = 1;
675
+						}
676
+						else{
677
+							$line->modsubtotal_title = 1;
678
+						}
679 679
                         
680 680
 						$line->total_ht = $this->getTotalLineFromObject($object, $line, '');
681 681
 					}
682
-	        	}
683
-	        }
682
+				}
683
+			}
684 684
 			
685 685
 		}
686 686
 		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 				 */
698 698
 				else if($object->element=='invoice_supplier')
699 699
 				{
700
-				    $object->deleteline($idLine);
700
+					$object->deleteline($idLine);
701 701
 				}
702 702
 				/**
703 703
 				 * @var $object Propal
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
 				 */
721 721
 				else if($object->element=='order_supplier')
722 722
 				{
723
-				    $object->deleteline($idLine);
723
+					$object->deleteline($idLine);
724 724
 				}
725 725
 				/**
726 726
 				 * @var $object Facturerec
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 		
796 796
 		foreach($object->lines as $l) {
797 797
 		
798
-		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
798
+			$lid = (!empty($l->rowid) ? $l->rowid : $l->id);
799 799
 			if($lid == $lineid) {
800 800
 
801 801
 				$found = true;
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
 			
805 805
 			if($found) {
806 806
 				
807
-			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
807
+				$Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
808 808
 				
809 809
 				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
810 810
 					break; // end of story
@@ -845,39 +845,39 @@  discard block
 block discarded – undo
845 845
 		foreach($TLineReverse as $l)
846 846
 		{
847 847
 			//print $l->rang.'>='.$rang.' '.$total.'<br/>';
848
-            if ($l->rang>=$rang) continue;
849
-            if (!empty($title_break) && $title_break->id == $l->id) break;
850
-            elseif (!TSubtotal::isModSubtotalLine($l))
851
-            {
852
-                // TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF
853
-                if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION)
854
-                {
855
-                    if ($l->situation_percent > 0)
856
-                    {
857
-                        $prev_progress = 0;
858
-                        $progress = 1;
859
-                        if (method_exists($l, 'get_prev_progress'))
860
-                        {
861
-                            $prev_progress = $l->get_prev_progress($object->id);
862
-                            $progress = ($l->situation_percent - $prev_progress) / 100;
863
-                        }
864
-
865
-                        $result = $sign * ($l->total_ht / ($l->situation_percent / 100)) * $progress;
866
-                        $total+= $result;
867
-                        // TODO check si les 3 lignes du dessous sont corrects
868
-                        $total_tva += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
869
-                        $TTotal_tva[$l->tva_tx] += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
870
-                        $total_ttc += $sign * ($l->total_tva / ($l->total_ttc / 100)) * $progress;
871
-                    }
872
-                }
873
-                else
874
-                {
875
-                    $total += $l->total_ht;
876
-                    $total_tva += $l->total_tva;
877
-                    $TTotal_tva[$l->tva_tx] += $l->total_tva;
878
-                    $total_ttc += $l->total_ttc;
879
-                }
880
-            }
848
+			if ($l->rang>=$rang) continue;
849
+			if (!empty($title_break) && $title_break->id == $l->id) break;
850
+			elseif (!TSubtotal::isModSubtotalLine($l))
851
+			{
852
+				// TODO retirer le test avec $builddoc quand Dolibarr affichera le total progression sur la card et pas seulement dans le PDF
853
+				if ($builddoc && $object->element == 'facture' && $object->type==Facture::TYPE_SITUATION)
854
+				{
855
+					if ($l->situation_percent > 0)
856
+					{
857
+						$prev_progress = 0;
858
+						$progress = 1;
859
+						if (method_exists($l, 'get_prev_progress'))
860
+						{
861
+							$prev_progress = $l->get_prev_progress($object->id);
862
+							$progress = ($l->situation_percent - $prev_progress) / 100;
863
+						}
864
+
865
+						$result = $sign * ($l->total_ht / ($l->situation_percent / 100)) * $progress;
866
+						$total+= $result;
867
+						// TODO check si les 3 lignes du dessous sont corrects
868
+						$total_tva += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
869
+						$TTotal_tva[$l->tva_tx] += $sign * ($l->total_tva / ($l->situation_percent / 100)) * $progress;
870
+						$total_ttc += $sign * ($l->total_tva / ($l->total_ttc / 100)) * $progress;
871
+					}
872
+				}
873
+				else
874
+				{
875
+					$total += $l->total_ht;
876
+					$total_tva += $l->total_tva;
877
+					$TTotal_tva[$l->tva_tx] += $l->total_tva;
878
+					$total_ttc += $l->total_ttc;
879
+				}
880
+			}
881 881
 		}
882 882
 		if (!$return_all) return $total;
883 883
 		else return array($total, $total_tva, $total_ttc, $TTotal_tva);
@@ -915,7 +915,7 @@  discard block
 block discarded – undo
915 915
 		if(method_exists('Closure','bind')) {
916 916
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
917 917
 			$sweetsThief = function ($pdf) {
918
-		    		return $pdf->bMargin ;
918
+					return $pdf->bMargin ;
919 919
 			};
920 920
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
921 921
 	
@@ -986,7 +986,7 @@  discard block
 block discarded – undo
986 986
 					$TTotal_tva = $TInfo[3];
987 987
 					$total_to_print = price($TInfo[0]);
988 988
 
989
-                    $line->total_ht = $TInfo[0];
989
+					$line->total_ht = $TInfo[0];
990 990
 					$line->total = $TInfo[0];
991 991
 					if (!TSubtotal::isModSubtotalLine($line)) $line->total_tva = $TInfo[1];
992 992
 					$line->total_ttc = $TInfo[2];
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
 	}
1144 1144
 	
1145 1145
 	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1146
-	    global $conf, $hideprices, $hookmanager;
1146
+		global $conf, $hideprices, $hookmanager;
1147 1147
 		
1148 1148
 		if(is_array($parameters)) $i = & $parameters['i'];
1149 1149
 		else $i = (int)$parameters;
@@ -1182,7 +1182,7 @@  discard block
 block discarded – undo
1182 1182
 			}
1183 1183
 		}
1184 1184
 		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1185
-		    $this->resprints = price($object->lines[$i]->total_ht);
1185
+			$this->resprints = price($object->lines[$i]->total_ht);
1186 1186
 		}
1187 1187
 		
1188 1188
 		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
@@ -1311,7 +1311,7 @@  discard block
 block discarded – undo
1311 1311
 	}
1312 1312
 	
1313 1313
 	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1314
-	    global $conf,$hideprices,$hookmanager;
1314
+		global $conf,$hideprices,$hookmanager;
1315 1315
 
1316 1316
 		if(is_array($parameters)) $i = & $parameters['i'];
1317 1317
 		else $i = (int)$parameters;
@@ -1319,18 +1319,18 @@  discard block
 block discarded – undo
1319 1319
 		if($this->isModSubtotalLine($parameters,$object) ) {
1320 1320
 			$this->resprints = ' ';
1321 1321
 
1322
-            $line = $object->lines[$i];
1322
+			$line = $object->lines[$i];
1323 1323
 
1324
-            // On récupère les montants du bloc pour les afficher dans la ligne de sous-total
1325
-            if(TSubtotal::isSubtotal($line)) {
1326
-                $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1324
+			// On récupère les montants du bloc pour les afficher dans la ligne de sous-total
1325
+			if(TSubtotal::isSubtotal($line)) {
1326
+				$parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1327 1327
 
1328
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1329
-                if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1330
-                    $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1331
-                    $this->resprints = price($TTotal['total_unit_subprice']);
1332
-                }
1333
-            }
1328
+				if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1329
+				if(! empty($parentTitle->array_options['options_show_total_ht'])) {
1330
+					$TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1331
+					$this->resprints = price($TTotal['total_unit_subprice']);
1332
+				}
1333
+			}
1334 1334
 		
1335 1335
 			if((float)DOL_VERSION<=3.6) {
1336 1336
 				return '';
@@ -1346,58 +1346,58 @@  discard block
 block discarded – undo
1346 1346
 		(!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))
1347 1347
 		)
1348 1348
 		{
1349
-		    // alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1350
-		    if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1351
-		    {
1352
-		        $this->resprints = ' ';
1349
+			// alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1350
+			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1351
+			{
1352
+				$this->resprints = ' ';
1353 1353
 		        
1354
-		        // currentcontext à modifier celon l'appel
1355
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1356
-		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1354
+				// currentcontext à modifier celon l'appel
1355
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1356
+				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1357 1357
 		        
1358
-		    }
1358
+			}
1359 1359
 		}
1360 1360
 		// Cache le prix pour les lignes standards dolibarr qui sont dans un ensemble
1361 1361
 		else if (!empty($hideprices))
1362 1362
 		{
1363 1363
 		    
1364
-		    // Check if a title exist for this line && if the title have subtotal
1365
-		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1366
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1367
-		    {
1364
+			// Check if a title exist for this line && if the title have subtotal
1365
+			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1366
+			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1367
+			{
1368 1368
 		        
1369
-		        $this->resprints = ' ';
1369
+				$this->resprints = ' ';
1370 1370
 		        
1371
-		        // currentcontext à modifier celon l'appel
1372
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1373
-		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1374
-		    }
1371
+				// currentcontext à modifier celon l'appel
1372
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1373
+				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1374
+			}
1375 1375
 		}
1376 1376
 		
1377 1377
 		return 0;
1378 1378
 	}
1379 1379
 	
1380 1380
 	function pdf_getlineremisepercent($parameters=array(), &$object, &$action='') {
1381
-	    global $conf,$hideprices,$hookmanager;
1381
+		global $conf,$hideprices,$hookmanager;
1382 1382
 
1383
-        if(is_array($parameters)) $i = & $parameters['i'];
1384
-        else $i = (int) $parameters;
1383
+		if(is_array($parameters)) $i = & $parameters['i'];
1384
+		else $i = (int) $parameters;
1385 1385
 
1386 1386
 		if($this->isModSubtotalLine($parameters,$object) ) {
1387 1387
 			$this->resprints = ' ';
1388 1388
 
1389
-            $line = $object->lines[$i];
1389
+			$line = $object->lines[$i];
1390 1390
 
1391
-            // Affichage de la remise 
1392
-            if(TSubtotal::isSubtotal($line)) {
1393
-                $parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1391
+			// Affichage de la remise 
1392
+			if(TSubtotal::isSubtotal($line)) {
1393
+				$parentTitle = TSubtotal::getParentTitleOfLine($object, $i);
1394 1394
 
1395
-                if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1396
-                if(! empty($parentTitle->array_options['options_show_reduc'])) {
1397
-                    $TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1398
-                    $this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
1399
-                }
1400
-            }
1395
+				if(empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1396
+				if(! empty($parentTitle->array_options['options_show_reduc'])) {
1397
+					$TTotal = TSubtotal::getTotalBlockFromTitle($object, $parentTitle);
1398
+					$this->resprints = price((1-$TTotal['total_ht'] / $TTotal['total_subprice'])*100, 0, '', 1, 2, 2).'%';
1399
+				}
1400
+			}
1401 1401
 		
1402 1402
 			if((float)DOL_VERSION<=3.6) {
1403 1403
 				return '';
@@ -1407,15 +1407,15 @@  discard block
 block discarded – undo
1407 1407
 			}
1408 1408
 		}
1409 1409
 		elseif (!empty($hideprices)
1410
-		        || (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1411
-		        )
1412
-		    {
1413
-		        if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1414
-		        {
1415
-		            $this->resprints = ' ';
1416
-		            return 1;
1417
-		        }
1418
-		    }
1410
+				|| (!empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && (!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i])) )
1411
+				)
1412
+			{
1413
+				if (!empty($hideprices) || !in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1414
+				{
1415
+					$this->resprints = ' ';
1416
+					return 1;
1417
+				}
1418
+			}
1419 1419
 		
1420 1420
 		return 0;
1421 1421
 	}
@@ -1451,7 +1451,7 @@  discard block
 block discarded – undo
1451 1451
 	}
1452 1452
 	
1453 1453
 	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
1454
-	    global $conf,$hideprices,$hookmanager;
1454
+		global $conf,$hideprices,$hookmanager;
1455 1455
 	    
1456 1456
 		if($this->isModSubtotalLine($parameters,$object) ){
1457 1457
 			$this->resprints = ' ';
@@ -1476,31 +1476,31 @@  discard block
 block discarded – undo
1476 1476
 		(!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))
1477 1477
 		)
1478 1478
 		{
1479
-		    // alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1480
-		    if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1481
-		    {
1482
-		        $this->resprints = ' ';
1479
+			// alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1480
+			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1481
+			{
1482
+				$this->resprints = ' ';
1483 1483
 		        
1484
-		        // currentcontext à modifier celon l'appel
1485
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1486
-		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1487
-		    }
1484
+				// currentcontext à modifier celon l'appel
1485
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1486
+				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1487
+			}
1488 1488
 		}
1489 1489
 		// Cache le prix pour les lignes standards dolibarr qui sont dans un ensemble
1490 1490
 		else if (!empty($hideprices))
1491 1491
 		{
1492 1492
 		    
1493
-		    // Check if a title exist for this line && if the title have subtotal
1494
-		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1495
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1496
-		    {
1493
+			// Check if a title exist for this line && if the title have subtotal
1494
+			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1495
+			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1496
+			{
1497 1497
 		        
1498
-		        $this->resprints = ' ';
1498
+				$this->resprints = ' ';
1499 1499
 		        
1500
-		        // currentcontext à modifier celon l'appel
1501
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1502
-		        return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1503
-		    }
1500
+				// currentcontext à modifier celon l'appel
1501
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1502
+				return $this->callHook($object, $hookmanager, $action, $params); // return 1 (qui est la valeur par défaut) OU -1 si erreur OU overrideReturn (contient -1 ou 0 ou 1)
1503
+			}
1504 1504
 		}
1505 1505
 		
1506 1506
 		return 0;
@@ -1624,33 +1624,33 @@  discard block
 block discarded – undo
1624 1624
 		
1625 1625
 		$this->add_numerotation($object);	
1626 1626
 		
1627
-        foreach($object->lines as $k => &$l) {
1628
-            if(TSubtotal::isSubtotal($l)) {
1629
-                $parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1630
-                if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1631
-                if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_reduc'])) {
1632
-                    $l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1633
-                }
1634
-            }
1627
+		foreach($object->lines as $k => &$l) {
1628
+			if(TSubtotal::isSubtotal($l)) {
1629
+				$parentTitle = TSubtotal::getParentTitleOfLine($object, $k);
1630
+				if(is_object($parentTitle) && empty($parentTitle->array_options)) $parentTitle->fetch_optionals();
1631
+				if(! empty($parentTitle->id) && ! empty($parentTitle->array_options['options_show_reduc'])) {
1632
+					$l->remise_percent = 100;    // Affichage de la réduction sur la ligne de sous-total
1633
+				}
1634
+			}
1635 1635
 
1636 1636
 
1637
-            // Pas de hook sur les colonnes du PDF expédition, on unset les bonnes variables
1638
-            if(($object->element == 'shipping' || $object->element == 'delivery') && $this->isModSubtotalLine($k, $object))
1637
+			// Pas de hook sur les colonnes du PDF expédition, on unset les bonnes variables
1638
+			if(($object->element == 'shipping' || $object->element == 'delivery') && $this->isModSubtotalLine($k, $object))
1639 1639
 			{
1640 1640
 				$l->qty = $l->qty_asked;
1641 1641
 				unset($l->qty_asked, $l->qty_shipped, $l->volume, $l->weight);
1642 1642
 			}
1643
-        }
1643
+		}
1644 1644
 
1645 1645
 		$hideInnerLines = (int)GETPOST('hideInnerLines');
1646 1646
 		$hidedetails = (int)GETPOST('hidedetails');
1647 1647
 
1648 1648
 		if ($hideInnerLines) { // si c une ligne de titre
1649
-	    	$fk_parent_line=0;
1649
+			$fk_parent_line=0;
1650 1650
 			$TLines =array();
1651 1651
 		
1652 1652
 			$original_count=count($object->lines);
1653
-		    $TTvas = array(); // tableau de tva
1653
+			$TTvas = array(); // tableau de tva
1654 1654
 		    
1655 1655
 			foreach($object->lines as $k=>&$line) 
1656 1656
 			{
@@ -1691,48 +1691,48 @@  discard block
 block discarded – undo
1691 1691
 			
1692 1692
 				if ($hideInnerLines)
1693 1693
 				{
1694
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1695
-				    {
1696
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1694
+					if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1695
+					{
1696
+						if($line->tva_tx != '0.000' && $line->product_type!=9){
1697 1697
 				            
1698
-    				        // on remplit le tableau de tva pour substituer les lignes cachées
1699
-    				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1700
-    				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1701
-    				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1702
-    				    }
1703
-    					if($line->product_type==9 && $line->rowid>0)
1704
-    					{
1705
-    					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1706
-    					    // génère des lignes d'affichage des montants HT soumis à tva
1707
-    					    $nbtva = count($TTvas);
1708
-    					    if(!empty($nbtva)){
1709
-    					        foreach ($TTvas as $tx =>$val){
1710
-    					            $l = clone $line;
1711
-    					            $l->product_type = 1;
1712
-    					            $l->special_code = '';
1713
-    					            $l->qty = 1;
1714
-    					            $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1715
-    					            $l->tva_tx = $tx;
1716
-    					            $l->total_ht = $val['total_ht'];
1717
-    					            $l->total_tva = $val['total_tva'];
1718
-    					            $l->total = $line->total_ht;
1719
-    					            $l->total_ttc = $val['total_ttc'];
1720
-    					            $TLines[] = $l;
1721
-    					            array_shift($TTvas);
1722
-    					       }
1723
-    					    }
1698
+							// on remplit le tableau de tva pour substituer les lignes cachées
1699
+							$TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1700
+							$TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1701
+							$TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1702
+						}
1703
+						if($line->product_type==9 && $line->rowid>0)
1704
+						{
1705
+							//Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1706
+							// génère des lignes d'affichage des montants HT soumis à tva
1707
+							$nbtva = count($TTvas);
1708
+							if(!empty($nbtva)){
1709
+								foreach ($TTvas as $tx =>$val){
1710
+									$l = clone $line;
1711
+									$l->product_type = 1;
1712
+									$l->special_code = '';
1713
+									$l->qty = 1;
1714
+									$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1715
+									$l->tva_tx = $tx;
1716
+									$l->total_ht = $val['total_ht'];
1717
+									$l->total_tva = $val['total_tva'];
1718
+									$l->total = $line->total_ht;
1719
+									$l->total_ttc = $val['total_ttc'];
1720
+									$TLines[] = $l;
1721
+									array_shift($TTvas);
1722
+							   }
1723
+							}
1724 1724
     					    
1725
-    					    // ajoute la ligne de sous-total
1726
-    					    $TLines[] = $line; 
1727
-    					}
1728
-				    } else {
1725
+							// ajoute la ligne de sous-total
1726
+							$TLines[] = $line; 
1727
+						}
1728
+					} else {
1729 1729
 				        
1730
-				        if($line->product_type==9 && $line->rowid>0)
1731
-				        {
1732
-				            // ajoute la ligne de sous-total
1733
-				            $TLines[] = $line; 
1734
-				        }
1735
-				    }
1730
+						if($line->product_type==9 && $line->rowid>0)
1731
+						{
1732
+							// ajoute la ligne de sous-total
1733
+							$TLines[] = $line; 
1734
+						}
1735
+					}
1736 1736
 				    
1737 1737
 					
1738 1738
 				}
@@ -1757,20 +1757,20 @@  discard block
 block discarded – undo
1757 1757
 			$nbtva = count($TTvas);
1758 1758
 			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1759 1759
 			{
1760
-			    foreach ($TTvas as $tx =>$val){
1761
-			        $l = clone $line;
1762
-			        $l->product_type = 1;
1763
-			        $l->special_code = '';
1764
-			        $l->qty = 1;
1765
-			        $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1766
-			        $l->tva_tx = $tx;
1767
-			        $l->total_ht = $val['total_ht'];
1768
-			        $l->total_tva = $val['total_tva'];
1769
-			        $l->total = $line->total_ht;
1770
-			        $l->total_ttc = $val['total_ttc'];
1771
-			        $TLines[] = $l;
1772
-			        array_shift($TTvas);
1773
-			    }
1760
+				foreach ($TTvas as $tx =>$val){
1761
+					$l = clone $line;
1762
+					$l->product_type = 1;
1763
+					$l->special_code = '';
1764
+					$l->qty = 1;
1765
+					$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1766
+					$l->tva_tx = $tx;
1767
+					$l->total_ht = $val['total_ht'];
1768
+					$l->total_tva = $val['total_tva'];
1769
+					$l->total = $line->total_ht;
1770
+					$l->total_ttc = $val['total_ttc'];
1771
+					$TLines[] = $l;
1772
+					array_shift($TTvas);
1773
+				}
1774 1774
 			}
1775 1775
 			
1776 1776
 			global $nblignes;
@@ -1782,7 +1782,7 @@  discard block
 block discarded – undo
1782 1782
 				$this->resprints = '';
1783 1783
 				return 0;
1784 1784
 			}
1785
-	    }
1785
+		}
1786 1786
 		
1787 1787
 		return 0;
1788 1788
 	}
@@ -1974,11 +1974,11 @@  discard block
 block discarded – undo
1974 1974
 		}
1975 1975
 		elseif($object->element == 'order_supplier' )
1976 1976
 		{
1977
-		    $createRight = $user->rights->fournisseur->commande->creer;
1977
+			$createRight = $user->rights->fournisseur->commande->creer;
1978 1978
 		}
1979 1979
 		elseif($object->element == 'invoice_supplier' )
1980 1980
 		{
1981
-		    $createRight = $user->rights->fournisseur->facture->creer;
1981
+			$createRight = $user->rights->fournisseur->facture->creer;
1982 1982
 		}
1983 1983
 		elseif($object->element == 'commande' && in_array('ordershipmentcard', $contexts))
1984 1984
 		{
@@ -2007,27 +2007,27 @@  discard block
 block discarded – undo
2007 2007
 			$line = $originline;
2008 2008
 		}
2009 2009
  		if($object->element=='facture')$idvar = 'facid';
2010
-        else $idvar='id';
2010
+		else $idvar='id';
2011 2011
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
2012 2012
 			if ($object->statut == 0  && $createRight && !empty($conf->global->SUBTOTAL_ALLOW_DUPLICATE_LINE) && $object->element !== 'invoice_supplier')
2013
-            {
2014
-                if(!(TSubtotal::isModSubtotalLine($line)) && ( $line->fk_prev_id === null ) && !($action == "editline" && GETPOST('lineid') == $line->id)) {
2015
-                    echo '<a name="duplicate-'.$line->id.'" href="' . $_SERVER['PHP_SELF'] . '?' . $idvar . '=' . $object->id . '&action=duplicate&lineid=' . $line->id . '"><i class="fa fa-clone" aria-hidden="true"></i></a>';
2013
+			{
2014
+				if(!(TSubtotal::isModSubtotalLine($line)) && ( $line->fk_prev_id === null ) && !($action == "editline" && GETPOST('lineid') == $line->id)) {
2015
+					echo '<a name="duplicate-'.$line->id.'" href="' . $_SERVER['PHP_SELF'] . '?' . $idvar . '=' . $object->id . '&action=duplicate&lineid=' . $line->id . '"><i class="fa fa-clone" aria-hidden="true"></i></a>';
2016 2016
 
2017
-                    ?>
2017
+					?>
2018 2018
                         <script type="text/javascript">
2019 2019
                             $(document).ready(function() {
2020 2020
                                 $("a[name='duplicate-<?php echo $line->id; ?>']").prependTo($('#row-<?php echo $line->id; ?>').find('.linecoledit'));
2021 2021
                             });
2022 2022
                         </script>
2023 2023
                     <?php
2024
-                }
2024
+				}
2025 2025
 
2026
-            }
2026
+			}
2027 2027
 			return 0;
2028 2028
 		}
2029 2029
 		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)) 
2030
-        {
2030
+		{
2031 2031
 
2032 2032
 
2033 2033
 			if((float)DOL_VERSION <= 3.4)
@@ -2075,7 +2075,7 @@  discard block
 block discarded – undo
2075 2075
 			//var_dump($line);
2076 2076
             
2077 2077
 			// HTML 5 data for js
2078
-            $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2078
+			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
2079 2079
             
2080 2080
 			
2081 2081
 			?>
@@ -2137,8 +2137,8 @@  discard block
 block discarded – undo
2137 2137
 						}
2138 2138
 						
2139 2139
 						if ($object->element == 'order_supplier' || $object->element == 'invoice_supplier') {
2140
-						    $line->label = !empty($line->description) ? $line->description : $line->desc;
2141
-						    $line->description = '';
2140
+							$line->label = !empty($line->description) ? $line->description : $line->desc;
2141
+							$line->description = '';
2142 2142
 						}
2143 2143
 						$newlabel = $line->label;
2144 2144
 						if($line->label=='' && !$isFreeText) {
@@ -2172,38 +2172,38 @@  discard block
 block discarded – undo
2172 2172
 						
2173 2173
 
2174 2174
 						echo '<div class="subtotal_underline" style="margin-left:24px; line-height: 25px;">';
2175
-                        echo '<div>';
2176
-                        echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2177
-                        echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2178
-                        echo '</div>';
2179
-
2180
-                        if (TSubtotal::isTitle($line))
2181
-                        {
2182
-                            $form = new Form($db);
2183
-                            echo '<div>';
2184
-                            echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2185
-                            echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2186
-                            if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2187
-                            echo '</select>';
2188
-                            echo '</div>';
2189
-
2190
-                            if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
2191
-                            {
2192
-                                echo '<div>';
2193
-                                echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%';
2194
-                                echo '</div>';
2195
-                            }
2196
-                            echo '<div>';
2197
-                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showTotalHT" id="subtotal-showTotalHT" value="9" '.(($line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2198
-                            echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2199
-                            echo '</div>';
2200
-
2201
-                            echo '<div>';
2202
-                            echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2203
-                            echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2204
-                            echo '</div>';
2205
-                        }
2206
-                        else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2175
+						echo '<div>';
2176
+						echo '<input style="vertical-align:sub;"  type="checkbox" name="line-pagebreak" id="subtotal-pagebreak" value="8" '.(($line->info_bits > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2177
+						echo '<label for="subtotal-pagebreak">'.$langs->trans('AddBreakPageBefore').'</label>';
2178
+						echo '</div>';
2179
+
2180
+						if (TSubtotal::isTitle($line))
2181
+						{
2182
+							$form = new Form($db);
2183
+							echo '<div>';
2184
+							echo '<label for="subtotal_tva_tx">'.$form->textwithpicto($langs->trans('subtotal_apply_default_tva'), $langs->trans('subtotal_apply_default_tva_help')).'</label>';
2185
+							echo '<select id="subtotal_tva_tx" name="subtotal_tva_tx" class="flat"><option selected="selected" value="">-</option>';
2186
+							if (empty($readonlyForSituation)) echo str_replace('selected', '', $form->load_tva('subtotal_tva_tx', '', $parameters['seller'], $parameters['buyer'], 0, 0, '', true));
2187
+							echo '</select>';
2188
+							echo '</div>';
2189
+
2190
+							if (!empty($conf->global->INVOICE_USE_SITUATION) && $object->element == 'facture' && $object->type == Facture::TYPE_SITUATION)
2191
+							{
2192
+								echo '<div>';
2193
+								echo '<label for="subtotal_progress">'.$langs->trans('subtotal_apply_progress').'</label> <input id="subtotal_progress" name="subtotal_progress" value="" size="1" />%';
2194
+								echo '</div>';
2195
+							}
2196
+							echo '<div>';
2197
+							echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showTotalHT" id="subtotal-showTotalHT" value="9" '.(($line->array_options['options_show_total_ht'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2198
+							echo '<label for="subtotal-showTotalHT">'.$langs->trans('ShowTotalHTOnSubtotalBlock').'</label>';
2199
+							echo '</div>';
2200
+
2201
+							echo '<div>';
2202
+							echo '<input style="vertical-align:sub;"  type="checkbox" name="line-showReduc" id="subtotal-showReduc" value="1" '.(($line->array_options['options_show_reduc'] > 0) ? 'checked="checked"' : '') .' />&nbsp;';
2203
+							echo '<label for="subtotal-showReduc">'.$langs->trans('ShowReducOnSubtotalBlock').'</label>';
2204
+							echo '</div>';
2205
+						}
2206
+						else if ($isFreeText) echo TSubtotal::getFreeTextHtml($line, (bool) $readonlyForSituation);
2207 2207
 						echo '</div>';
2208 2208
 
2209 2209
 						if (TSubtotal::isTitle($line))
@@ -2743,17 +2743,17 @@  discard block
 block discarded – undo
2743 2743
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2744 2744
 		{
2745 2745
 		    
2746
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2747
-		    {
2748
-		        foreach ($object->lines as $line)
2749
-		        {
2750
-		            // fetch optionals attributes and labels
2751
-		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2752
-		            $extrafields=new ExtraFields($this->db);
2753
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2754
-		            $line->fetch_optionals($line->id,$extralabels);
2755
-		        }
2756
-		    }
2746
+			if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2747
+			{
2748
+				foreach ($object->lines as $line)
2749
+				{
2750
+					// fetch optionals attributes and labels
2751
+					require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2752
+					$extrafields=new ExtraFields($this->db);
2753
+					$extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2754
+					$line->fetch_optionals($line->id,$extralabels);
2755
+				}
2756
+			}
2757 2757
 		    
2758 2758
 			$TSubNc = array();
2759 2759
 			foreach ($object->lines as &$l)
@@ -2844,80 +2844,80 @@  discard block
 block discarded – undo
2844 2844
 	{
2845 2845
 		dol_include_once('/subtotal/class/subtotal.class.php');
2846 2846
 
2847
-	    $line = &$parameters['line'];
2847
+		$line = &$parameters['line'];
2848 2848
 	    
2849
-	    $ThtmlData['data-id']           = $line->id;
2850
-	    $ThtmlData['data-product_type'] = $line->product_type;
2851
-	    $ThtmlData['data-qty']          = 0; //$line->qty;
2852
-	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2849
+		$ThtmlData['data-id']           = $line->id;
2850
+		$ThtmlData['data-product_type'] = $line->product_type;
2851
+		$ThtmlData['data-qty']          = 0; //$line->qty;
2852
+		$ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2853 2853
 	    
2854
-	    if(TSubtotal::isTitle($line)){
2855
-	        $ThtmlData['data-issubtotal'] = 'title';
2856
-	    }elseif(TSubtotal::isSubtotal($line)){
2857
-	        $ThtmlData['data-issubtotal'] = 'subtotal';
2858
-	    }
2859
-	    else{
2860
-	        $ThtmlData['data-issubtotal'] = 'freetext';
2861
-	    }
2854
+		if(TSubtotal::isTitle($line)){
2855
+			$ThtmlData['data-issubtotal'] = 'title';
2856
+		}elseif(TSubtotal::isSubtotal($line)){
2857
+			$ThtmlData['data-issubtotal'] = 'subtotal';
2858
+		}
2859
+		else{
2860
+			$ThtmlData['data-issubtotal'] = 'freetext';
2861
+		}
2862 2862
 	    
2863 2863
 	    
2864
-	    // Change or add data  from hooks
2865
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2864
+		// Change or add data  from hooks
2865
+		$parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2866 2866
 	    
2867
-	    // hook 
2868
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2869
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2870
-	    if ($reshook>0)
2871
-	    {
2872
-	        $ThtmlData = $hookmanager->resArray;
2873
-	    }
2874
-
2875
-	    return $this->implodeHtmlData($ThtmlData);
2867
+		// hook 
2868
+		$reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2869
+		if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2870
+		if ($reshook>0)
2871
+		{
2872
+			$ThtmlData = $hookmanager->resArray;
2873
+		}
2874
+
2875
+		return $this->implodeHtmlData($ThtmlData);
2876 2876
 	
2877 2877
 	}
2878 2878
 	
2879 2879
 	
2880 2880
 	function implodeHtmlData($ThtmlData = array())
2881 2881
 	{
2882
-	    $data = '';
2883
-	    foreach($ThtmlData as $k => $h )
2884
-	    {
2885
-	        if(is_array($h))
2886
-	        {
2887
-	            $h = json_encode($h);
2888
-	        }
2882
+		$data = '';
2883
+		foreach($ThtmlData as $k => $h )
2884
+		{
2885
+			if(is_array($h))
2886
+			{
2887
+				$h = json_encode($h);
2888
+			}
2889 2889
 	        
2890
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2891
-	    }
2890
+			$data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2891
+		}
2892 2892
 	    
2893
-	    return $data;
2893
+		return $data;
2894 2894
 	}
2895 2895
 	
2896 2896
 	function _ajax_block_order_js($object)
2897 2897
 	{
2898
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2898
+		global $conf,$tagidfortablednd,$filepath,$langs;
2899 2899
 	    
2900
-	    /*
2900
+		/*
2901 2901
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2902 2902
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2903 2903
 	     */
2904 2904
 	    
2905
-	    $id=$object->id;
2906
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2907
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2905
+		$id=$object->id;
2906
+		$nboflines=(isset($object->lines)?count($object->lines):0);
2907
+		$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2908 2908
 	    
2909
-	    $id=$object->id;
2910
-	    $fk_element=$object->fk_element;
2911
-	    $table_element_line=$object->table_element_line;
2912
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2913
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2914
-	    $filepath=(empty($filepath)?'':$filepath);
2909
+		$id=$object->id;
2910
+		$fk_element=$object->fk_element;
2911
+		$table_element_line=$object->table_element_line;
2912
+		$nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2913
+		$tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2914
+		$filepath=(empty($filepath)?'':$filepath);
2915 2915
 	    
2916 2916
 	    
2917
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2918
-	    {
2917
+		if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2918
+		{
2919 2919
 	        
2920
-	        ?>
2920
+			?>
2921 2921
 		
2922 2922
 		
2923 2923
 			<script type="text/javascript">
Please login to merge, or discard this patch.