<?php 	include_once('../../config.php');   	
		include_once(ABS_PATH.'/admin/login_check.php');    
    
	    if(isset($_POST['submitF']))
			{     
			    
			    if($_POST['marchant']==1) 
			    {
			        $DPexplode = explode("DP",$_POST['Ccid']);   
			        $nwnId = trim("MT".$DPexplode[1]);
			        
                    $stmt=$conn->prepare("select  id from  UI__AdharVeri where custId=:custId");  
                    $stmt->bindValue(':custId', $_POST['Ccid'] , PDO::PARAM_STR);
                    $stmt->execute(); 
                    if($stmt->rowCount() > 0)
                    {    
                        $stmt=$conn->prepare("update  UI__AdharVeri set  custId='$nwnId' where custId=:custId");  
                        $stmt->bindValue(':custId', $_POST['Ccid'] , PDO::PARAM_STR);
                        $stmt->execute(); 
                    }
                    
                    
                    $stmt=$conn->prepare("select  id from  UI__PanVeri where custId=:custId");  
                    $stmt->bindValue(':custId', $_POST['Ccid'] , PDO::PARAM_STR);
                    $stmt->execute(); 
                    if($stmt->rowCount() > 0)
                    {    
                        $stmt=$conn->prepare("update  UI__PanVeri set  custId='$nwnId' where custId=:custId");  
                        $stmt->bindValue(':custId', $_POST['Ccid'] , PDO::PARAM_STR);
                        $stmt->execute(); 
                    }
			        
			        
			    }else
			        $nwnId = $_POST['Ccid']; 
			        
			        
    			 
    			 /*  				
        				$stmt=$conn->prepare("update  UI__Rgst set directxfer=:directxfer,mtycommision=:mtycommision,cuurentId=:cuurentId, marchant=:marchant,IMPSLimit=:IMPSLimit,NEFTLimit=:NEFTLimit,UpiLimit=:UpiLimit,idtoid=:idtoid,news=:news,impsStats=:impsStats,nm=:nm,eml=:eml,phm=:phm,Bname=:Bname,Bifsc=:Bifsc,Bnumber=:Bnumber,accHolderNm=:accHolderNm,is_active=:is_active,UPI=:UPI   where id=:cust_id  ");    
                        $stmt->bindValue(':directxfer', $_POST['directxfer'] , PDO::PARAM_STR);  
                        $stmt->bindValue(':mtycommision', $_POST['mtycommision'] , PDO::PARAM_STR);    
                        $stmt->bindValue(':cuurentId', $nwnId , PDO::PARAM_STR); 
                        $stmt->bindValue(':marchant',$_POST['marchant'], PDO::PARAM_STR); 
                        $stmt->bindValue(':IMPSLimit',$_POST['IMPSLimit'], PDO::PARAM_STR); 
                        $stmt->bindValue(':NEFTLimit',$_POST['NEFTLimit'], PDO::PARAM_STR); 
                        $stmt->bindValue(':UpiLimit',$_POST['UpiLimit'], PDO::PARAM_STR); 
                        $stmt->bindValue(':idtoid',$_POST['idtoid'], PDO::PARAM_STR); 
                        $stmt->bindValue(':news',$_POST['newsSelect'], PDO::PARAM_STR); 
                        $stmt->bindValue(':impsStats',$_POST['impsStats'], PDO::PARAM_STR); 
                        $stmt->bindValue(':nm',$_POST['nm'], PDO::PARAM_STR);  
                        $stmt->bindValue(':eml',$_POST['eml'], PDO::PARAM_STR); 
                         
                        $stmt->bindValue(':Bname',$_POST['Bname'], PDO::PARAM_STR); 
                        $stmt->bindValue(':Bifsc',$_POST['Bifsc'], PDO::PARAM_STR); 
                        $stmt->bindValue(':Bnumber',$_POST['Bnumber'], PDO::PARAM_STR); 
                        $stmt->bindValue(':accHolderNm',$_POST['accHolderNm'], PDO::PARAM_STR);  
                        $stmt->bindValue(':cust_id',$_REQUEST['id'], PDO::PARAM_STR);  
                        $stmt->bindValue(':is_active',$_POST['is_active'], PDO::PARAM_STR);    
                        $stmt->bindValue(':UPI',$_POST['UPI'], PDO::PARAM_STR);      
                        $stmt->execute();    
    			 
    			 */
			    
			    
			    if(isset($_POST['upiActive'])) 
			        $Utly = "1";
			     else   
			         $Utly = "0"; 
			         
			     
			    if(isset($_POST['BnkActive'])) 
			        $Utly .= ",1";
			     else   
			         $Utly .= ",0"; 
			         
			             
			     
			    if(isset($_POST['IdtoIdActive'])) 
			        $Utly .= ",1";
			     else   
			         $Utly .= ",0"; 
			         
			     
			       
			    if(isset($_POST['UtilitiesActive'])) 
			        $Utly .= ",1";
			     else   
			         $Utly .= ",0"; 
			         
			         
		       if(isset($_POST['instatantImps'])) 
			        $instatantImps =  1;
			     else   
			         $instatantImps =  0;
			         
			         
			           
			         
		       if(isset($_POST['DPthough'])) 
			        $DPthough =  1;
			     else   
			         $DPthough =  0;    
			       
			    if(isset($_POST['allDysroi'])) 
			        $allDysroi = "1";
			     else   
			         $allDysroi = "0";  
			                         
		        if(isset($_POST['powerPlayer'])) 
			        $powerPlayer = "1";
			     else   
			         $allDysroi = "0";   
			         
			         
			 if(isset($_POST['AutoWithdrawls'])) 
			        $AutoWithdrawls = "1";
			     else   
			         $AutoWithdrawls = "0";    
			         
			 
			         
			 if(isset($_POST['othertopup'])) 
			        $othertopup = "1";
			     else   
			         $othertopup = "0";    
			                 
			    
			         
			 if(isset($_POST['grabPlans'])) 
			        $grabPlans = "1";
			     else   
			         $grabPlans = "0";    
			                       
			                 
			     
			         
			     if(isset($_POST['P2PUser']))  
			     {        
                        $digits = 6;
                        $P2PUser = "P2P".rand(pow(10, $digits-1), pow(10, $digits)-1);   
			     }
			         
			          
    			$stmt=$conn->prepare("update  UI__Rgst set p2p=:p2p,grabPlans=:grabPlans,othertopup=:othertopup,autoWithdrawls=:AutoWithdrawls,powerPlayer=:powerPlayer,IMPSLimit=:IMPSLimit,DPthough=:DPthough,instatantImps=:instatantImps,allDysroi=:allDysroi,utilities=:utilities,dailyMonthly=:dailyMonthly,upiAllow=:upiAllow,is_active=:is_active,directxfer=:directxfer,mtycommision=:mtycommision,cuurentId=:cuurentId, marchant=:marchant,NEFTLimit=:NEFTLimit,UpiLimit=:UpiLimit,idtoid=:idtoid,news=:news,impsStats=:impsStats,nm=:nm,eml=:eml,pay2second=:pay2second,grabDays=:grabDays where id=:id  ");    
                $stmt->bindValue(':p2p', $P2PUser , PDO::PARAM_INT);
                $stmt->bindValue(':grabPlans', $grabPlans , PDO::PARAM_INT);
                $stmt->bindValue(':othertopup', $othertopup , PDO::PARAM_INT);
                $stmt->bindValue(':AutoWithdrawls', $AutoWithdrawls , PDO::PARAM_INT);
                $stmt->bindValue(':powerPlayer', $powerPlayer , PDO::PARAM_INT);
                $stmt->bindValue(':IMPSLimit', $_POST['UpiLimit'], PDO::PARAM_INT); 
                $stmt->bindValue(':DPthough', $DPthough, PDO::PARAM_INT); 
                $stmt->bindValue(':instatantImps', $instatantImps, PDO::PARAM_INT); 
                $stmt->bindValue(':allDysroi', $allDysroi , PDO::PARAM_INT); 
                $stmt->bindValue(':utilities',$Utly , PDO::PARAM_INT); 
                $stmt->bindValue(':dailyMonthly', $_POST['dailyMonthly'] , PDO::PARAM_INT); 
                $stmt->bindValue(':upiAllow', $_POST['upiAllow'] , PDO::PARAM_INT); 
                $stmt->bindValue(':is_active', $_POST['is_active'] , PDO::PARAM_INT); 
                $stmt->bindValue(':directxfer', $_POST['directxfer'] , PDO::PARAM_STR); 
                $stmt->bindValue(':mtycommision', $_POST['mtycommision'] , PDO::PARAM_STR);    
                $stmt->bindValue(':cuurentId', $nwnId , PDO::PARAM_STR); 
                $stmt->bindValue(':marchant',$_POST['marchant'], PDO::PARAM_STR); 
             
                $stmt->bindValue(':NEFTLimit',$_POST['NEFTLimit'], PDO::PARAM_STR); 
                $stmt->bindValue(':UpiLimit',$_POST['UpiLimit'], PDO::PARAM_STR); 
                $stmt->bindValue(':idtoid',$_POST['idtoid'], PDO::PARAM_STR); 
                $stmt->bindValue(':news',$_POST['newsSelect'], PDO::PARAM_STR); 
                $stmt->bindValue(':impsStats',$_POST['impsStats'], PDO::PARAM_STR); 
                $stmt->bindValue(':nm',$_POST['nm'], PDO::PARAM_STR);  
                $stmt->bindValue(':eml',$_POST['eml'], PDO::PARAM_STR);   
                $stmt->bindValue(':id',$_REQUEST['id'], PDO::PARAM_STR);  
                $stmt->bindValue(':pay2second', $_POST['pay2second'], PDO::PARAM_STR);  
                $stmt->bindValue(':grabDays', $_POST['grabDays'], PDO::PARAM_STR);  
                
                
                $stmt->execute();  
				header("Location: edit-details.php?id=".$_REQUEST['id']);  
				die;
			}   
			
    
            $stmt=$conn->prepare("select  * from  UI__Rgst where id=:id    ");  
            $stmt->bindValue(':id', $_REQUEST['id'] , PDO::PARAM_STR);
            $stmt->execute(); 
            $AllUsers = $stmt->fetch(PDO::FETCH_OBJ);   
            $sr = 1;    
            
            $instatantImps= 0;
            if($AllUsers->instatantImps==1)
                $instatantImps = 1;
                
            $grabPlans= 0;
            if($AllUsers->grabPlans==1)
                $grabPlans = 1;    
            
             $DPthough= 0;
            if($AllUsers->DPthough==1)
                $DPthough = 1;
                
            $powerPlayer = 0;
              if($AllUsers->powerPlayer==1)
                  $powerPlayer = 1;
            
            $AutoWithdrawls = 0;
              if($AllUsers->autoWithdrawls==1)
                  $AutoWithdrawls = 1;
                  
            
            if($AllUsers->utilities=="")
            {
                $UpiA = 0;
                $Bkn = 0;
                $IdToId = 0;
                $Utili = 0;
            }else
            {
                $expln =  explode(",",$AllUsers->utilities);  
                $UpiA = $expln[0];
                $Bkn = $expln[1];
                $IdToId = $expln[2];
                $Utili = $expln[3];
            }   
            
            
          
            if($AllUsers->p2p=='')
                $P2PUser = 0;
            else
                $P2PUser = 1;
                
        
?>  
<?php  include ABS_PATH.'/admin/header.php';	?>  


 <script>
	$(function() {
		$( "#datepicker" ).datepicker(); 
	}); 
  
	$(document).ready(function()
	{   

	
	$("#product_frm").validate({
		
		errorElement:'div',
		rules:{ 
			city:{
				required:true				 
			} 
			
			
			
		},
		messages:{				
			 
			 city:{
				required:"Enter city name"				 
			} 
		}
	});


	});
 


</script>
		 
		 <div class="col-md-10">

	  			<div class="row">
	  				<div class="col-md-12">
	  					<div class="content-box-large">
							<div class="panel-heading">
								<div class="panel-title"> <h3> Top Up List </h3></div>    
								
								<div class="panel-options"> 

								   <input type="button"  class="btn btn-warning" name="btnback" id="btnback" value=" Back " onClick="javascript:location.href='registered_users.php';" />
								  
								</div>
							  
								 
							</div>
							
							
			  				<div class="panel-body">    
			  					<form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" id="product_frm"> 
							   	 
							   	 
							   	 <?php 
							   	        
							   	        
                                        $stmt=$conn->prepare("select  amt, ManualSet,ManualAmt,id,ManualSet2,ManualAmt2    from  UI__DChstr  where Rid=:Rid  order by id   ");  
                                        $stmt->bindValue(':Rid', $_REQUEST['cuurentId'] , PDO::PARAM_STR);
                                        $stmt->execute(); 
                                        $AllUsers = $stmt->fetchAll(PDO::FETCH_OBJ);   
                                        
                                        foreach($AllUsers as $tp)
                                        {

							   	 ?>
							   	 
							   	 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">User Top</label>
								    <div class="col-sm-3"> 
                                            <input name="nm" class="form-control"   placeholder="Username"  readonly    value="<?php echo $tp->amt; ?>"  >  
								            
								    </div>
								 </div>
								 
								  <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Manul Days 1  </label>
								    <div class="col-sm-3"> 
                                            <input name="nm" class="form-control"    readonly    value="<?php echo $tp->ManualSet2; ?>"  >   
								    </div>
								 </div>
								 
								  <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Manul Amount 1  </label>
								    <div class="col-sm-3"> 
                                            <input name="nm" class="form-control"     readonly    value="<?php echo $tp->ManualAmt2; ?>"  >  
								            
								    </div>
								 </div>
								 
								 
								  <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Manul Days 2  </label>
								    <div class="col-sm-3"> 
                                            <input name="nm" class="form-control"    readonly    value="<?php echo $tp->ManualSet; ?>"  >   
								    </div>
								 </div>
								 
								  <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Manul Amount 2  </label>
								    <div class="col-sm-3"> 
                                            <input name="nm" class="form-control"     readonly    value="<?php echo $tp->ManualAmt; ?>"  >  
								            
								    </div>
								 </div>
								 
								   <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Update  </label>
								    <div class="col-sm-3"> 
                                            <a href="EdiTopup.php?TpId=<?php echo $tp->id; ?>&cuurentId=<?php echo $_REQUEST['cuurentId']; ?>"  class="btn btn-warning" > Edit Topup</a>
								            
								    </div>
								 </div>
								    
								 <hr> 
								 
								 <?php  } ?>
    							 
    								 	 
								 
								  <div class="form-group">
										<label for="inputEmail3" class="col-sm-2 control-label">Update</label>
										<div class="col-sm-6">
										  <input type="submit"    class="btn btn-primary"  name="submitF" value="Update">
										  <input type="hidden" value="<?php echo $AllUsers->cuurentId?>"  name="Ccid"/> 
										</div>
								  </div>   
								</form>
								
								
							
			  				</div>
			  			</div>
	  				</div>
	  				 
	  			</div>

	  			 


	  		<!--  Page content -->
		  </div>
		</div>
    </div>

<?php  include ABS_PATH.'/admin/footer.php';

    /*$stmt=$conn->prepare("select  utilities,id from  UI__Rgst   "); 
                            $stmt->execute(); 
                            $AllUsers = $stmt->fetchAll(PDO::FETCH_OBJ);   
                          
                          
                            foreach($AllUsers as $amp)
                            {
                                $tc = null;
                                $tc = explode(",",$amp->utilities); 
                                $tc[2]  = 0;  
                                $str = implode(",",$tc);
                                $stmt=$conn->prepare("update  UI__Rgst set  utilities=:utilities where id=:id "); 
                                $stmt->bindValue(':utilities', $str , PDO::PARAM_STR);
                                $stmt->bindValue(':id', $amp->id , PDO::PARAM_STR);
                                $stmt->execute();   
                            }   */
                           
                            
?>    