Passed
Pull Request — master (#119)
by
unknown
03:45
created
class/actions_subtotal.class.php 1 patch
Indentation   +224 added lines, -224 removed lines patch added patch discarded remove patch
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
 	 * @return     void
82 82
 	 */
83 83
     
84
-    var $module_number = 104777;
84
+	var $module_number = 104777;
85 85
     
86
-    function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
87
-    {
88
-      	global $langs,$db,$user, $conf;
86
+	function formObjectOptions($parameters, &$object, &$action, $hookmanager) 
87
+	{
88
+	  	global $langs,$db,$user, $conf;
89 89
 		
90 90
 		$langs->load('subtotal@subtotal');
91 91
 		
@@ -100,10 +100,10 @@  discard block
 block discarded – undo
100 100
 				$createRight = $user->rights->facture->creer;
101 101
 			} elseif($object->element == 'order_supplier' )
102 102
 			{
103
-			    $createRight = $user->rights->fournisseur->commande->creer;
103
+				$createRight = $user->rights->fournisseur->commande->creer;
104 104
 			} elseif($object->element == 'invoice_supplier' )
105 105
 			{
106
-			    $createRight = $user->rights->fournisseur->facture->creer;
106
+				$createRight = $user->rights->fournisseur->facture->creer;
107 107
 			}
108 108
 			
109 109
 			if ($object->statut == 0  && $createRight) {
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 					
154 154
 					if (!empty($conf->global->SUBTOTAL_AUTO_ADD_SUBTOTAL_ON_ADDING_NEW_TITLE) && $qty < 10) TSubtotal::addSubtotalMissing($object, $qty);
155 155
 					
156
-	    			TSubtotal::addSubTotalLine($object, $title, $qty);
156
+					TSubtotal::addSubTotalLine($object, $title, $qty);
157 157
 				}
158 158
 				else if($action==='ask_deleteallline') {
159 159
 						$form=new Form($db);
@@ -375,36 +375,36 @@  discard block
 block discarded – undo
375 375
 		$TContext = explode(':',$parameters['context']);
376 376
 		if (
377 377
 				in_array('invoicecard',$TContext)
378
-		        || in_array('invoicesuppliercard',$TContext)
378
+				|| in_array('invoicesuppliercard',$TContext)
379 379
 				|| in_array('propalcard',$TContext)
380 380
 				|| in_array('ordercard',$TContext)
381
-		        || in_array('ordersuppliercard',$TContext)
381
+				|| in_array('ordersuppliercard',$TContext)
382 382
 				|| in_array('invoicereccard',$TContext)
383 383
 			)
384
-	        {	
384
+			{	
385 385
 				$hideInnerLines	= isset( $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideInnerLines_'.$parameters['modulepart']] : 0;
386 386
 				$hidedetails	= isset( $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hidedetails_'.$parameters['modulepart']] : 0;
387 387
 				$hidepricesDefaultConf = !empty($conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED)?$conf->global->SUBTOTAL_HIDE_PRICE_DEFAULT_CHECKED:0;
388 388
 				$hideprices= isset( $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] ) ?  $_SESSION['subtotal_hideprices_'.$parameters['modulepart']] : $hidepricesDefaultConf;
389 389
 				
390 390
 				$var=false;
391
-		     	$out.= '<tr '.$bc[$var].'>
391
+			 	$out.= '<tr '.$bc[$var].'>
392 392
 		     			<td colspan="4" align="right">
393 393
 		     				<label for="hideInnerLines">'.$langs->trans('HideInnerLines').'</label>
394 394
 		     				<input type="checkbox" onclick="if($(this).is(\':checked\')) { $(\'#hidedetails\').prop(\'checked\', \'checked\')  }" id="hideInnerLines" name="hideInnerLines" value="1" '.(( $hideInnerLines ) ? 'checked="checked"' : '' ).' />
395 395
 		     			</td>
396 396
 		     			</tr>';
397 397
 				
398
-		     	$var=!$var;
399
-		     	$out.= '<tr '.$bc[$var].'>
398
+			 	$var=!$var;
399
+			 	$out.= '<tr '.$bc[$var].'>
400 400
 		     			<td colspan="4" align="right">
401 401
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidedetails').'</label>
402 402
 		     				<input type="checkbox" id="hidedetails" name="hidedetails" value="1" '.(( $hidedetails ) ? 'checked="checked"' : '' ).' />
403 403
 		     			</td>
404 404
 		     			</tr>';
405 405
 		     	
406
-		     	$var=!$var;
407
-		     	$out.= '<tr '.$bc[$var].'>
406
+			 	$var=!$var;
407
+			 	$out.= '<tr '.$bc[$var].'>
408 408
 		     			<td colspan="4" align="right">
409 409
 		     				<label for="hidedetails">'.$langs->trans('SubTotalhidePrice').'</label>
410 410
 		     				<input type="checkbox" id="hideprices" name="hideprices" value="1" '.(( $hideprices ) ? 'checked="checked"' : '' ).' />
@@ -416,9 +416,9 @@  discard block
 block discarded – undo
416 416
 				if ( 
417 417
 					(in_array('propalcard',$TContext) && !empty($conf->global->SUBTOTAL_PROPAL_ADD_RECAP))
418 418
 					|| (in_array('ordercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
419
-				    || (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
419
+					|| (in_array('ordersuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_COMMANDE_ADD_RECAP))
420 420
 					|| (in_array('invoicecard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
421
-				    || (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
421
+					|| (in_array('invoicesuppliercard',$TContext) && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP))
422 422
 					|| (in_array('invoicereccard',$TContext)  && !empty($conf->global->SUBTOTAL_INVOICE_ADD_RECAP ))
423 423
 				)
424 424
 				{
@@ -437,19 +437,19 @@  discard block
 block discarded – undo
437 437
 			}
438 438
 			
439 439
 		
440
-        return 1;
440
+		return 1;
441 441
 	} 
442 442
 	 
443
-    function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
444
-    {
443
+	function formEditProductOptions($parameters, &$object, &$action, $hookmanager) 
444
+	{
445 445
 		
446
-    	if (in_array('invoicecard',explode(':',$parameters['context'])))
447
-        {
446
+		if (in_array('invoicecard',explode(':',$parameters['context'])))
447
+		{
448 448
         	
449
-        }
449
+		}
450 450
 		
451
-        return 0;
452
-    }
451
+		return 0;
452
+	}
453 453
 	
454 454
 	function ODTSubstitutionLine(&$parameters, &$object, $action, $hookmanager) {
455 455
 		global $conf;
@@ -498,11 +498,11 @@  discard block
 block discarded – undo
498 498
 	
499 499
 		if (
500 500
 				in_array('invoicecard',explode(':',$parameters['context']))
501
-		        || in_array('invoicesuppliercard',explode(':',$parameters['context']))
501
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
502 502
 				|| in_array('propalcard',explode(':',$parameters['context']))
503
-		        || in_array('supplier_proposalcard',explode(':',$parameters['context']))
503
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
504 504
 				|| in_array('ordercard',explode(':',$parameters['context']))
505
-		        || in_array('ordersuppliercard',explode(':',$parameters['context']))
505
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
506 506
 				|| in_array('invoicereccard',explode(':',$parameters['context']))
507 507
 		) {
508 508
 			
@@ -581,20 +581,20 @@  discard block
 block discarded – undo
581 581
 				in_array('invoicecard',explode(':',$parameters['context']))
582 582
 				|| in_array('propalcard',explode(':',$parameters['context']))
583 583
 				|| in_array('ordercard',explode(':',$parameters['context']))
584
-			    || in_array('ordersuppliercard',explode(':',$parameters['context']))
585
-			    || in_array('invoicesuppliercard',explode(':',$parameters['context']))
586
-			    || in_array('supplier_proposalcard',explode(':',$parameters['context']))
584
+				|| in_array('ordersuppliercard',explode(':',$parameters['context']))
585
+				|| in_array('invoicesuppliercard',explode(':',$parameters['context']))
586
+				|| in_array('supplier_proposalcard',explode(':',$parameters['context']))
587 587
 			)
588
-	        {								
588
+			{								
589 589
 				if(in_array('invoicecard',explode(':',$parameters['context']))) {
590 590
 					$sessname = 'subtotal_hideInnerLines_facture';	
591 591
 					$sessname2 = 'subtotal_hidedetails_facture';
592 592
 					$sessname3 = 'subtotal_hideprices_facture';
593 593
 				}
594 594
 				elseif(in_array('invoicesuppliercard',explode(':',$parameters['context']))) {
595
-				    $sessname = 'subtotal_hideInnerLines_facture_fournisseur';
596
-				    $sessname2 = 'subtotal_hidedetails_facture_fournisseur';
597
-				    $sessname3 = 'subtotal_hideprices_facture_fournisseur';
595
+					$sessname = 'subtotal_hideInnerLines_facture_fournisseur';
596
+					$sessname2 = 'subtotal_hidedetails_facture_fournisseur';
597
+					$sessname3 = 'subtotal_hideprices_facture_fournisseur';
598 598
 				}
599 599
 				elseif(in_array('propalcard',explode(':',$parameters['context']))) {
600 600
 					$sessname = 'subtotal_hideInnerLines_propal';
@@ -602,9 +602,9 @@  discard block
 block discarded – undo
602 602
 					$sessname3 = 'subtotal_hideprices_propal';
603 603
 				}
604 604
 				elseif(in_array('supplier_proposalcard',explode(':',$parameters['context']))) {
605
-				    $sessname = 'subtotal_hideInnerLines_supplier_proposal';
606
-				    $sessname2 = 'subtotal_hidedetails_supplier_proposal';
607
-				    $sessname3 = 'subtotal_hideprices_supplier_proposal';
605
+					$sessname = 'subtotal_hideInnerLines_supplier_proposal';
606
+					$sessname2 = 'subtotal_hidedetails_supplier_proposal';
607
+					$sessname3 = 'subtotal_hideprices_supplier_proposal';
608 608
 				}
609 609
 				elseif(in_array('ordercard',explode(':',$parameters['context']))) {
610 610
 					$sessname = 'subtotal_hideInnerLines_commande';
@@ -612,9 +612,9 @@  discard block
 block discarded – undo
612 612
 					$sessname3 = 'subtotal_hideprices_commande';
613 613
 				}
614 614
 				elseif(in_array('ordersuppliercard',explode(':',$parameters['context']))) {
615
-				    $sessname = 'subtotal_hideInnerLines_commande_fournisseur';
616
-				    $sessname2 = 'subtotal_hidedetails_commande_fournisseur';
617
-				    $sessname3 = 'subtotal_hideprices_commande_fournisseur';
615
+					$sessname = 'subtotal_hideInnerLines_commande_fournisseur';
616
+					$sessname2 = 'subtotal_hidedetails_commande_fournisseur';
617
+					$sessname3 = 'subtotal_hideprices_commande_fournisseur';
618 618
 				}
619 619
 				else {
620 620
 					$sessname = 'subtotal_hideInnerLines_unknown';
@@ -636,17 +636,17 @@  discard block
 block discarded – undo
636 636
 				foreach($object->lines as &$line) {
637 637
 					if ($line->product_type == 9 && $line->special_code == $this->module_number) {
638 638
 					    
639
-                        if($line->qty>=90) {
640
-                            $line->modsubtotal_total = 1;
641
-                        }
642
-                        else{
643
-                            $line->modsubtotal_title = 1;
644
-                        }
639
+						if($line->qty>=90) {
640
+							$line->modsubtotal_total = 1;
641
+						}
642
+						else{
643
+							$line->modsubtotal_title = 1;
644
+						}
645 645
                         
646 646
 						$line->total_ht = $this->getTotalLineFromObject($object, $line, '');
647 647
 					}
648
-	        	}
649
-	        }
648
+				}
649
+			}
650 650
 			
651 651
 		}
652 652
 		else if($action === 'confirm_delete_all_lines' && GETPOST('confirm')=='yes') {
@@ -663,7 +663,7 @@  discard block
 block discarded – undo
663 663
 				 */
664 664
 				else if($object->element=='invoice_supplier')
665 665
 				{
666
-				    $object->deleteline($idLine);
666
+					$object->deleteline($idLine);
667 667
 				}
668 668
 				/**
669 669
 				 * @var $object Propal
@@ -686,7 +686,7 @@  discard block
 block discarded – undo
686 686
 				 */
687 687
 				else if($object->element=='order_supplier')
688 688
 				{
689
-				    $object->deleteline($idLine);
689
+					$object->deleteline($idLine);
690 690
 				}
691 691
 				/**
692 692
 				 * @var $object Facturerec
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 		
731 731
 		foreach($object->lines as $l) {
732 732
 		
733
-		    $lid = (!empty($l->rowid) ? $l->rowid : $l->id);
733
+			$lid = (!empty($l->rowid) ? $l->rowid : $l->id);
734 734
 			if($lid == $lineid) {
735 735
 
736 736
 				$found = true;
@@ -739,7 +739,7 @@  discard block
 block discarded – undo
739 739
 			
740 740
 			if($found) {
741 741
 				
742
-			    $Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
742
+				$Tab[] = (!empty($l->rowid) ? $l->rowid : $l->id);
743 743
 				
744 744
 				if($l->special_code==$this->module_number && (($l->qty==99 && $qty_line==1) || ($l->qty==98 && $qty_line==2))   ) {
745 745
 					break; // end of story
@@ -818,17 +818,17 @@  discard block
 block discarded – undo
818 818
 			if($l->rang>=$rang) {
819 819
 				return price($total);
820 820
 			}
821
-                        if (TSubtotal::isSubtotal($l)){
822
-                            $total = 0;
823
-                        } else  if ($l->situation_percent > 0 ){
821
+						if (TSubtotal::isSubtotal($l)){
822
+							$total = 0;
823
+						} else  if ($l->situation_percent > 0 ){
824 824
                            
825 825
         	
826 826
 		 	$prev_progress = $l->get_prev_progress($object->id);
827 827
 		 	$progress = ($l->situation_percent - $prev_progress) /100;
828
-                        $total += ($l->total_ht/($l->situation_percent/100)) * $progress;
828
+						$total += ($l->total_ht/($l->situation_percent/100)) * $progress;
829 829
                         
830
-                    }
831
-                }
830
+					}
831
+				}
832 832
                 
833 833
 		return price($total);
834 834
 	}
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
 		if(method_exists('Closure','bind')) {
861 861
 			$pageBreakOriginalValue = $pdf->AcceptPageBreak();
862 862
 			$sweetsThief = function ($pdf) {
863
-		    		return $pdf->bMargin ;
863
+					return $pdf->bMargin ;
864 864
 			};
865 865
 			$sweetsThief = Closure::bind($sweetsThief, null, $pdf);
866 866
 	
@@ -923,11 +923,11 @@  discard block
 block discarded – undo
923 923
 				else
924 924
 				{
925 925
 					list($total, $total_tva, $total_ttc, $TTotal_tva) = $this->getTotalLineFromObject($object, $line, '', 1);
926
-                                        if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
927
-                                                $total_to_print = $this->getTotalToPrintSituation($object, $line);
928
-                                        } else {
929
-                                            	$total_to_print = price($total);
930
-                                        }
926
+										if(get_class($object) == 'Facture' && $object->type==Facture::TYPE_SITUATION){//Facture de situation
927
+												$total_to_print = $this->getTotalToPrintSituation($object, $line);
928
+										} else {
929
+												$total_to_print = price($total);
930
+										}
931 931
                                             
932 932
 					$line->total_ht = $total;
933 933
 					$line->total = $total;
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
 	}
1079 1079
 	
1080 1080
 	function pdf_getlinetotalexcltax($parameters=array(), &$object, &$action='') {
1081
-	    global $conf, $hideprices, $hookmanager;
1081
+		global $conf, $hideprices, $hookmanager;
1082 1082
 		
1083 1083
 		if(is_array($parameters)) $i = & $parameters['i'];
1084 1084
 		else $i = (int)$parameters;
@@ -1117,7 +1117,7 @@  discard block
 block discarded – undo
1117 1117
 			}
1118 1118
 		}
1119 1119
 		if ((int)GETPOST('hideInnerLines') && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES)){
1120
-		    $this->resprints = price($object->lines[$i]->total_ht);
1120
+			$this->resprints = price($object->lines[$i]->total_ht);
1121 1121
 		}
1122 1122
 		
1123 1123
 		// Si la gestion C/NC est active et que je suis sur un ligne dont l'extrafield est coché
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
 	}
1247 1247
 	
1248 1248
 	function pdf_getlineupexcltax($parameters=array(), &$object, &$action='') {
1249
-	    global $conf,$hideprices,$hookmanager;
1249
+		global $conf,$hideprices,$hookmanager;
1250 1250
 
1251 1251
 		if($this->isModSubtotalLine($parameters,$object) ){
1252 1252
 			$this->resprints = ' ';
@@ -1268,32 +1268,32 @@  discard block
 block discarded – undo
1268 1268
 		(!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))
1269 1269
 		)
1270 1270
 		{
1271
-		    // alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1272
-		    if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1273
-		    {
1274
-		        $this->resprints = ' ';
1271
+			// alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1272
+			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1273
+			{
1274
+				$this->resprints = ' ';
1275 1275
 		        
1276
-		        // currentcontext à modifier celon l'appel
1277
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1278
-		        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)
1276
+				// currentcontext à modifier celon l'appel
1277
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1278
+				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)
1279 1279
 		        
1280
-		    }
1280
+			}
1281 1281
 		}
1282 1282
 		// Cache le prix pour les lignes standards dolibarr qui sont dans un ensemble
1283 1283
 		else if (!empty($hideprices))
1284 1284
 		{
1285 1285
 		    
1286
-		    // Check if a title exist for this line && if the title have subtotal
1287
-		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1288
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1289
-		    {
1286
+			// Check if a title exist for this line && if the title have subtotal
1287
+			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1288
+			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1289
+			{
1290 1290
 		        
1291
-		        $this->resprints = ' ';
1291
+				$this->resprints = ' ';
1292 1292
 		        
1293
-		        // currentcontext à modifier celon l'appel
1294
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1295
-		        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)
1296
-		    }
1293
+				// currentcontext à modifier celon l'appel
1294
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlineupexcltax', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1295
+				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)
1296
+			}
1297 1297
 		}
1298 1298
 		
1299 1299
 		return 0;
@@ -1330,7 +1330,7 @@  discard block
 block discarded – undo
1330 1330
 	}
1331 1331
 	
1332 1332
 	function pdf_getlinevatrate($parameters=array(), &$object, &$action='') {
1333
-	    global $conf,$hideprices,$hookmanager;
1333
+		global $conf,$hideprices,$hookmanager;
1334 1334
 	    
1335 1335
 		if($this->isModSubtotalLine($parameters,$object) ){
1336 1336
 			$this->resprints = ' ';
@@ -1355,31 +1355,31 @@  discard block
 block discarded – undo
1355 1355
 		(!empty($object->lines[$i]->array_options['options_subtotal_nc']) || TSubtotal::hasNcTitle($object->lines[$i]))
1356 1356
 		)
1357 1357
 		{
1358
-		    // alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1359
-		    if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1360
-		    {
1361
-		        $this->resprints = ' ';
1358
+			// alors je dois vérifier si la méthode fait partie de la conf qui l'exclue
1359
+			if (!in_array(__FUNCTION__, explode(',', $conf->global->SUBTOTAL_TFIELD_TO_KEEP_WITH_NC)))
1360
+			{
1361
+				$this->resprints = ' ';
1362 1362
 		        
1363
-		        // currentcontext à modifier celon l'appel
1364
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1365
-		        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)
1366
-		    }
1363
+				// currentcontext à modifier celon l'appel
1364
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hide_nc', 'i' => $i);
1365
+				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)
1366
+			}
1367 1367
 		}
1368 1368
 		// Cache le prix pour les lignes standards dolibarr qui sont dans un ensemble
1369 1369
 		else if (!empty($hideprices))
1370 1370
 		{
1371 1371
 		    
1372
-		    // Check if a title exist for this line && if the title have subtotal
1373
-		    $lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1374
-		    if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1375
-		    {
1372
+			// Check if a title exist for this line && if the title have subtotal
1373
+			$lineTitle = TSubtotal::getParentTitleOfLine($object, $i);
1374
+			if(TSubtotal::getParentTitleOfLine($object, $i) && TSubtotal::titleHasTotalLine($object, $lineTitle, true))
1375
+			{
1376 1376
 		        
1377
-		        $this->resprints = ' ';
1377
+				$this->resprints = ' ';
1378 1378
 		        
1379
-		        // currentcontext à modifier celon l'appel
1380
-		        $params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1381
-		        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)
1382
-		    }
1379
+				// currentcontext à modifier celon l'appel
1380
+				$params = array('parameters' => $parameters, 'currentmethod' => 'pdf_getlinevatrate', 'currentcontext'=>'subtotal_hideprices', 'i' => $i);
1381
+				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)
1382
+			}
1383 1383
 		}
1384 1384
 		
1385 1385
 		return 0;
@@ -1508,11 +1508,11 @@  discard block
 block discarded – undo
1508 1508
 		$hidedetails = (int)GETPOST('hidedetails');
1509 1509
 		
1510 1510
 		if ($hideInnerLines) { // si c une ligne de titre
1511
-	    	$fk_parent_line=0;
1511
+			$fk_parent_line=0;
1512 1512
 			$TLines =array();
1513 1513
 		
1514 1514
 			$original_count=count($object->lines);
1515
-		    $TTvas = array(); // tableau de tva
1515
+			$TTvas = array(); // tableau de tva
1516 1516
 		    
1517 1517
 			foreach($object->lines as $k=>&$line) 
1518 1518
 			{
@@ -1542,48 +1542,48 @@  discard block
 block discarded – undo
1542 1542
 			
1543 1543
 				if ($hideInnerLines)
1544 1544
 				{
1545
-				    if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1546
-				    {
1547
-				        if($line->tva_tx != '0.000' && $line->product_type!=9){
1545
+					if(!empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1546
+					{
1547
+						if($line->tva_tx != '0.000' && $line->product_type!=9){
1548 1548
 				            
1549
-    				        // on remplit le tableau de tva pour substituer les lignes cachées
1550
-    				        $TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1551
-    				        $TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1552
-    				        $TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1553
-    				    }
1554
-    					if($line->product_type==9 && $line->rowid>0)
1555
-    					{
1556
-    					    //Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1557
-    					    // génère des lignes d'affichage des montants HT soumis à tva
1558
-    					    $nbtva = count($TTvas);
1559
-    					    if(!empty($nbtva)){
1560
-    					        foreach ($TTvas as $tx =>$val){
1561
-    					            $l = clone $line;
1562
-    					            $l->product_type = 1;
1563
-    					            $l->special_code = '';
1564
-    					            $l->qty = 1;
1565
-    					            $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1566
-    					            $l->tva_tx = $tx;
1567
-    					            $l->total_ht = $val['total_ht'];
1568
-    					            $l->total_tva = $val['total_tva'];
1569
-    					            $l->total = $line->total_ht;
1570
-    					            $l->total_ttc = $val['total_ttc'];
1571
-    					            $TLines[] = $l;
1572
-    					            array_shift($TTvas);
1573
-    					       }
1574
-    					    }
1549
+							// on remplit le tableau de tva pour substituer les lignes cachées
1550
+							$TTvas[$line->tva_tx]['total_tva'] += $line->total_tva;
1551
+							$TTvas[$line->tva_tx]['total_ht'] += $line->total_ht;
1552
+							$TTvas[$line->tva_tx]['total_ttc'] += $line->total_ttc; 
1553
+						}
1554
+						if($line->product_type==9 && $line->rowid>0)
1555
+						{
1556
+							//Cas où je doit cacher les produits et afficher uniquement les sous-totaux avec les titres
1557
+							// génère des lignes d'affichage des montants HT soumis à tva
1558
+							$nbtva = count($TTvas);
1559
+							if(!empty($nbtva)){
1560
+								foreach ($TTvas as $tx =>$val){
1561
+									$l = clone $line;
1562
+									$l->product_type = 1;
1563
+									$l->special_code = '';
1564
+									$l->qty = 1;
1565
+									$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1566
+									$l->tva_tx = $tx;
1567
+									$l->total_ht = $val['total_ht'];
1568
+									$l->total_tva = $val['total_tva'];
1569
+									$l->total = $line->total_ht;
1570
+									$l->total_ttc = $val['total_ttc'];
1571
+									$TLines[] = $l;
1572
+									array_shift($TTvas);
1573
+							   }
1574
+							}
1575 1575
     					    
1576
-    					    // ajoute la ligne de sous-total
1577
-    					    $TLines[] = $line; 
1578
-    					}
1579
-				    } else {
1576
+							// ajoute la ligne de sous-total
1577
+							$TLines[] = $line; 
1578
+						}
1579
+					} else {
1580 1580
 				        
1581
-				        if($line->product_type==9 && $line->rowid>0)
1582
-				        {
1583
-				            // ajoute la ligne de sous-total
1584
-				            $TLines[] = $line; 
1585
-				        }
1586
-				    }
1581
+						if($line->product_type==9 && $line->rowid>0)
1582
+						{
1583
+							// ajoute la ligne de sous-total
1584
+							$TLines[] = $line; 
1585
+						}
1586
+					}
1587 1587
 				    
1588 1588
 					
1589 1589
 				}
@@ -1608,20 +1608,20 @@  discard block
 block discarded – undo
1608 1608
 			$nbtva = count($TTvas);
1609 1609
 			if(!empty($nbtva) && $hideInnerLines && !empty($conf->global->SUBTOTAL_REPLACE_WITH_VAT_IF_HIDE_INNERLINES))
1610 1610
 			{
1611
-			    foreach ($TTvas as $tx =>$val){
1612
-			        $l = clone $line;
1613
-			        $l->product_type = 1;
1614
-			        $l->special_code = '';
1615
-			        $l->qty = 1;
1616
-			        $l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1617
-			        $l->tva_tx = $tx;
1618
-			        $l->total_ht = $val['total_ht'];
1619
-			        $l->total_tva = $val['total_tva'];
1620
-			        $l->total = $line->total_ht;
1621
-			        $l->total_ttc = $val['total_ttc'];
1622
-			        $TLines[] = $l;
1623
-			        array_shift($TTvas);
1624
-			    }
1611
+				foreach ($TTvas as $tx =>$val){
1612
+					$l = clone $line;
1613
+					$l->product_type = 1;
1614
+					$l->special_code = '';
1615
+					$l->qty = 1;
1616
+					$l->desc = $langs->trans('AmountBeforeTaxesSubjectToVATX%', $langs->transnoentitiesnoconv('VAT'), price($tx));
1617
+					$l->tva_tx = $tx;
1618
+					$l->total_ht = $val['total_ht'];
1619
+					$l->total_tva = $val['total_tva'];
1620
+					$l->total = $line->total_ht;
1621
+					$l->total_ttc = $val['total_ttc'];
1622
+					$TLines[] = $l;
1623
+					array_shift($TTvas);
1624
+				}
1625 1625
 			}
1626 1626
 			
1627 1627
 			global $nblignes;
@@ -1633,7 +1633,7 @@  discard block
 block discarded – undo
1633 1633
 				$this->resprints = '';
1634 1634
 				return 0;
1635 1635
 			}
1636
-	    }
1636
+		}
1637 1637
 		
1638 1638
 		return 0;
1639 1639
 	}
@@ -1796,18 +1796,18 @@  discard block
 block discarded – undo
1796 1796
 		}
1797 1797
 		elseif($object->element == 'order_supplier' )
1798 1798
 		{
1799
-		    $createRight = $user->rights->fournisseur->commande->creer;
1799
+			$createRight = $user->rights->fournisseur->commande->creer;
1800 1800
 		}
1801 1801
 		elseif($object->element == 'invoice_supplier' )
1802 1802
 		{
1803
-		    $createRight = $user->rights->fournisseur->facture->creer;
1803
+			$createRight = $user->rights->fournisseur->facture->creer;
1804 1804
 		}
1805 1805
 		
1806 1806
 		if($line->special_code!=$this->module_number || $line->product_type!=9) {
1807 1807
 			null;
1808 1808
 		}	
1809 1809
 		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)) 
1810
-        {
1810
+		{
1811 1811
 			if($object->element=='facture')$idvar = 'facid';
1812 1812
 			else $idvar='id';
1813 1813
 			
@@ -1854,7 +1854,7 @@  discard block
 block discarded – undo
1854 1854
 			//var_dump($line);
1855 1855
             
1856 1856
 			// HTML 5 data for js
1857
-            $data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
1857
+			$data = $this->_getHtmlData($parameters, $object, $action, $hookmanager);
1858 1858
             
1859 1859
 			
1860 1860
 			?>
@@ -1912,8 +1912,8 @@  discard block
 block discarded – undo
1912 1912
 						}
1913 1913
 						
1914 1914
 						if ($object->element == 'order_supplier' || $object->element == 'invoice_supplier') {
1915
-						    $line->label = !empty($line->description) ? $line->description : $line->desc;
1916
-						    $line->description = '';
1915
+							$line->label = !empty($line->description) ? $line->description : $line->desc;
1916
+							$line->description = '';
1917 1917
 						}
1918 1918
 						$newlabel = $line->label;
1919 1919
 						if($line->label=='' && !$isFreeText) {
@@ -2204,17 +2204,17 @@  discard block
 block discarded – undo
2204 2204
 		if ($object->statut == 0 && !empty($conf->global->SUBTOTAL_MANAGE_COMPRIS_NONCOMPRIS) && $action != 'editline')
2205 2205
 		{
2206 2206
 		    
2207
-		    if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2208
-		    {
2209
-		        foreach ($object->lines as $line)
2210
-		        {
2211
-		            // fetch optionals attributes and labels
2212
-		            require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2213
-		            $extrafields=new ExtraFields($this->db);
2214
-		            $extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2215
-		            $line->fetch_optionals($line->id,$extralabels);
2216
-		        }
2217
-		    }
2207
+			if($object->element == 'invoice_supplier' || $object->element == 'order_supplier')
2208
+			{
2209
+				foreach ($object->lines as $line)
2210
+				{
2211
+					// fetch optionals attributes and labels
2212
+					require_once(DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php');
2213
+					$extrafields=new ExtraFields($this->db);
2214
+					$extralabels=$extrafields->fetch_name_optionals_label($object->table_element_line,true);
2215
+					$line->fetch_optionals($line->id,$extralabels);
2216
+				}
2217
+			}
2218 2218
 		    
2219 2219
 			$TSubNc = array();
2220 2220
 			foreach ($object->lines as &$l)
@@ -2305,80 +2305,80 @@  discard block
 block discarded – undo
2305 2305
 	{
2306 2306
 		dol_include_once('/subtotal/class/subtotal.class.php');
2307 2307
 
2308
-	    $line = &$parameters['line'];
2308
+		$line = &$parameters['line'];
2309 2309
 	    
2310
-	    $ThtmlData['data-id']           = $line->id;
2311
-	    $ThtmlData['data-product_type'] = $line->product_type;
2312
-	    $ThtmlData['data-qty']          = 0; //$line->qty;
2313
-	    $ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2310
+		$ThtmlData['data-id']           = $line->id;
2311
+		$ThtmlData['data-product_type'] = $line->product_type;
2312
+		$ThtmlData['data-qty']          = 0; //$line->qty;
2313
+		$ThtmlData['data-level']        = TSubtotal::getNiveau($line);
2314 2314
 	    
2315
-	    if(TSubtotal::isTitle($line)){
2316
-	        $ThtmlData['data-issubtotal'] = 'title';
2317
-	    }elseif(TSubtotal::isSubtotal($line)){
2318
-	        $ThtmlData['data-issubtotal'] = 'subtotal';
2319
-	    }
2320
-	    else{
2321
-	        $ThtmlData['data-issubtotal'] = 'freetext';
2322
-	    }
2315
+		if(TSubtotal::isTitle($line)){
2316
+			$ThtmlData['data-issubtotal'] = 'title';
2317
+		}elseif(TSubtotal::isSubtotal($line)){
2318
+			$ThtmlData['data-issubtotal'] = 'subtotal';
2319
+		}
2320
+		else{
2321
+			$ThtmlData['data-issubtotal'] = 'freetext';
2322
+		}
2323 2323
 	    
2324 2324
 	    
2325
-	    // Change or add data  from hooks
2326
-	    $parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2325
+		// Change or add data  from hooks
2326
+		$parameters = array_replace($parameters , array(  'ThtmlData' => $ThtmlData )  );
2327 2327
 	    
2328
-	    // hook 
2329
-	    $reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2330
-	    if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2331
-	    if ($reshook>0)
2332
-	    {
2333
-	        $ThtmlData = $hookmanager->resArray;
2334
-	    }
2335
-
2336
-	    return $this->implodeHtmlData($ThtmlData);
2328
+		// hook 
2329
+		$reshook = $hookmanager->executeHooks('subtotalLineHtmlData',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
2330
+		if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
2331
+		if ($reshook>0)
2332
+		{
2333
+			$ThtmlData = $hookmanager->resArray;
2334
+		}
2335
+
2336
+		return $this->implodeHtmlData($ThtmlData);
2337 2337
 	
2338 2338
 	}
2339 2339
 	
2340 2340
 	
2341 2341
 	function implodeHtmlData($ThtmlData = array())
2342 2342
 	{
2343
-	    $data = '';
2344
-	    foreach($ThtmlData as $k => $h )
2345
-	    {
2346
-	        if(is_array($h))
2347
-	        {
2348
-	            $h = json_encode($h);
2349
-	        }
2343
+		$data = '';
2344
+		foreach($ThtmlData as $k => $h )
2345
+		{
2346
+			if(is_array($h))
2347
+			{
2348
+				$h = json_encode($h);
2349
+			}
2350 2350
 	        
2351
-	        $data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2352
-	    }
2351
+			$data .= $k . '="'.dol_htmlentities($h, ENT_QUOTES).'" ';
2352
+		}
2353 2353
 	    
2354
-	    return $data;
2354
+		return $data;
2355 2355
 	}
2356 2356
 	
2357 2357
 	function _ajax_block_order_js($object)
2358 2358
 	{
2359
-	    global $conf,$tagidfortablednd,$filepath,$langs;
2359
+		global $conf,$tagidfortablednd,$filepath,$langs;
2360 2360
 	    
2361
-	    /*
2361
+		/*
2362 2362
 	     * this part of js is base on dolibarr htdocs/core/tpl/ajaxrow.tpl.php 
2363 2363
 	     * for compatibility reasons we don't use tableDnD but jquery sortable
2364 2364
 	     */
2365 2365
 	    
2366
-	    $id=$object->id;
2367
-	    $nboflines=(isset($object->lines)?count($object->lines):0);
2368
-	    $forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2366
+		$id=$object->id;
2367
+		$nboflines=(isset($object->lines)?count($object->lines):0);
2368
+		$forcereloadpage=empty($conf->global->MAIN_FORCE_RELOAD_PAGE)?0:1;
2369 2369
 	    
2370
-	    $id=$object->id;
2371
-	    $fk_element=$object->fk_element;
2372
-	    $table_element_line=$object->table_element_line;
2373
-	    $nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2374
-	    $tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2375
-	    $filepath=(empty($filepath)?'':$filepath);
2370
+		$id=$object->id;
2371
+		$fk_element=$object->fk_element;
2372
+		$table_element_line=$object->table_element_line;
2373
+		$nboflines=(isset($object->lines)?count($object->lines):(empty($nboflines)?0:$nboflines));
2374
+		$tagidfortablednd=(empty($tagidfortablednd)?'tablelines':$tagidfortablednd);
2375
+		$filepath=(empty($filepath)?'':$filepath);
2376 2376
 	    
2377 2377
 	    
2378
-	    if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2379
-	    {
2378
+		if (GETPOST('action','aZ09') != 'editline' && $nboflines > 1)
2379
+		{
2380 2380
 	        
2381
-	        ?>
2381
+			?>
2382 2382
 		
2383 2383
 		
2384 2384
 			<script type="text/javascript">
Please login to merge, or discard this patch.