<?php 	include_once('../../config.php');   	
		include_once(ABS_PATH.'/admin/login_check.php');    
 
  
			if(isset($_POST['submitF']))
			{     
			         
			     if($_FILES['qrcode']['name']!='')
			     {    
                    $stmt=$conn->prepare("select  UPI4 from  UI__Rgst where id=:id    ");  
                    $stmt->bindValue(':id', $_REQUEST['id'] , PDO::PARAM_STR);
                    $stmt->execute(); 
                    $UPI4 = $stmt->fetch(PDO::FETCH_OBJ);  
                    
                    if($UPI4->UPI4!='')
                        unlink(ABS_PATH."/uploads/QrCode/".$UPI4->UPI4); 
                        
                    
                    $ext = explode('.',$_FILES['qrcode']['name']);//explode file name from dot(.)  
                    $Fname =  substr(md5(uniqid()),26).".". $ext[count($ext) - 1];  
                    $target_path = ABS_PATH."/uploads/QrCode/".$Fname;//set the target path with a new name of image 
                    move_uploaded_file($_FILES['qrcode']['tmp_name'], $target_path); 

                    $stmt=$conn->prepare("update  UI__Rgst set UPI4=:UPI4   where id=:id  ");  
                    $stmt->bindValue(':UPI4', $Fname , PDO::PARAM_STR);
                    $stmt->bindValue(':id',$_REQUEST['id'], PDO::PARAM_INT);   
                    $stmt->execute();    
                    header("Location: editMar-details.php?id=".$_REQUEST['id']); 
                    die; 
			     }  
			     
    			$stmt=$conn->prepare("update  UI__Rgst set UPI3=:UPI3,mtycommision=:mtycommision,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(':UPI3', $_POST['UPI3'] , PDO::PARAM_STR);
                $stmt->bindValue(':mtycommision', $_POST['mtycommision'] , 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(':phm',$_POST['phm'], 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();    
				header("Location: editMar-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;    
		 
?>  
<?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> Edit User Details</h3></div>    
								
								<div class="panel-options"> 

								   <input type="button"  class="btn btn-warning" name="btnback" id="btnback" value=" Back " onClick="javascript:location.href='marchants.php';" />
								  
								</div>
							  
								 
							</div>
							
							
			  				<div class="panel-body">    
			  					<form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" id="product_frm"> 
							   	 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Name</label>
								    <div class="col-sm-6">
								      <input name="nm" class="form-control"   placeholder="Username"   required  value="<?php echo $AllUsers->nm; ?>"  >
								    </div>
								 </div>
								 <hr>
								   
								 
								 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Email</label>
								    <div class="col-sm-6">
								      <input name="eml" class="form-control"   placeholder="Username"   required  value="<?php echo $AllUsers->eml; ?>"  >
								    </div>
								 </div>
								 <hr>
								 
								 
								 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Phone No</label>
								    <div class="col-sm-6">
								      <input name="phm" class="form-control"   type="number" placeholder="Username"  required value="<?php echo $AllUsers->phm; ?>"  >
								    </div>
								 </div>
								 <hr>
								  
								  
								  <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Sponsor Id</label>
								    <div class="col-sm-6">
								      <input  class="form-control"      value="<?php echo  $AllUsers->refId; ?>"  >
								    </div>
								 </div>
								 <hr>
								 
								 
								  <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Bank Name </label>
								    <div class="col-sm-6">
								      <input  class="form-control"   name="Bname"   value="<?php echo  $AllUsers->Bname; ?>"  >
								    </div>
								 </div>
								 <hr>
								 
								  <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Bank IFSC </label>
								    <div class="col-sm-6">
								      <input  class="form-control"    name="Bifsc"  value="<?php echo  $AllUsers->Bifsc; ?>"  >
								    </div>
								 </div>
								 <hr>
								 
								 
								  <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Bank Account No</label>
								    <div class="col-sm-6">
								      <input  class="form-control"  name="Bnumber"  value="<?php echo  $AllUsers->Bnumber; ?>"  >
								    </div>
								 </div>
								 <hr>
								 
								  <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Acc  Holder Name </label>
								    <div class="col-sm-6">
								      <input  class="form-control"    name="accHolderNm"  value="<?php echo  $AllUsers->accHolderNm; ?>"  >
								    </div>
								 </div>
								 <hr>  
								 
								 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Branch</label>
								    <div class="col-sm-6">
								      <input  class="form-control"     name="Bbranch"  value="<?php echo  $AllUsers->Bbranch; ?>"  >
								    </div>
								 </div>
								 <hr>   
								 
								 
							 
								 
								  <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Profile Pic</label>
								    <div class="col-sm-6">
								       <img src="<?php echo ROOTPATH;?>/uploads/<?php echo $AllUsers->profilePic;?>" width="200" />
								    </div>
								 </div>
								 <hr>
								 
								  
								  <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Status</label>
								    <div class="col-sm-6">
								       <select name="is_active" class="form-control">
								           <option <?php if($AllUsers->is_active==1) echo"selected"; ?> value="1">Active</option>
								           <option <?php if($AllUsers->is_active==0) echo"selected"; ?> value="0">Inactive</option>
								       </select>
								    </div>
								 </div>
								 <hr>
								 
								 
								  <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">IMPS</label>
								    <div class="col-sm-6">
								       <select name="impsStats" class="form-control">
								           <option <?php if($AllUsers->impsStats==0) echo"selected"; ?> value="0">Active</option>
								           <option <?php if($AllUsers->impsStats==1) echo"selected"; ?> value="1">Inactive</option>
								       </select>
								    </div>
								 </div>
								 <hr>
								 
								  <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Id to Id</label>
								    <div class="col-sm-6">
								       <select name="idtoid" class="form-control">
								           <option <?php if($AllUsers->idtoid==0) echo"selected"; ?> value="0">Active</option>
								           <option <?php if($AllUsers->idtoid==1) echo"selected"; ?> value="1">Inactive</option>
								       </select>
								    </div>
								 </div>
								 <hr>
								 
								  <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">News</label>
								    <div class="col-sm-6">
								       <select name="newsSelect" class="form-control">
								           <option <?php if($AllUsers->news==0) echo"selected"; ?> value="0">Normal</option>
								           <option <?php if($AllUsers->news==1) echo"selected"; ?> value="1">Special</option>
								       </select>
								    </div>
								 </div>
								 <hr>
								 
							  <div class="form-group">
							    <label for="inputEmail3" class="col-sm-2 control-label">UPI</label>
							    <div class="col-sm-6"> 
							       <input  class="form-control" name="UPI"  value="<?php echo  $AllUsers->UPI; ?>"  >
							    </div>
							 </div>
							 <hr>
								 
							 <div class="form-group">
							    <label for="inputEmail3" class="col-sm-2 control-label">Total Credit</label>
							    <div class="col-sm-6"> 
							       <input  class="form-control"  readonly value="<?php echo  totalCredit($AllUsers->cuurentId); ?>"  >
							    </div>
							 </div>
							 <hr>
							 
							 <div class="form-group">
							    <label for="inputEmail3" class="col-sm-2 control-label">Total Debit</label>
							    <div class="col-sm-6"> 
							       <input  class="form-control"  readonly value="<?php echo  totalDebit($AllUsers->cuurentId); ?>"  >
							    </div>
							 </div>
							 <hr>
							 
						 	 <div class="form-group">
							    <label for="inputEmail3" class="col-sm-2 control-label">Total Wallet</label>
							    <div class="col-sm-6"> 
							       <input  class="form-control"  readonly value="<?php echo  GetBalance($AllUsers->cuurentId); ?>"  >
							    </div>
							 </div>
							 <hr>
							   
						 	 
						 	 <div class="form-group"> 
						 	      <?php   
                                    $stmt=$conn->prepare("select  Tamt from  UI__Bns where Rid=:id ");  
                                    $stmt->bindValue(':id',  $AllUsers->cuurentId  , PDO::PARAM_STR);
                                    $stmt->execute(); 
                                    $tRpay = $stmt->fetchAll(PDO::FETCH_OBJ);
                                    
                                    foreach($tRpay as $mp)
                                        $tLpay +=$mp->Tamt; 
						 	       ?> 
						 	     
							    <label for="inputEmail3" class="col-sm-2 control-label">Total Level Pay</label>
							    <div class="col-sm-6"> 
							       <input  class="form-control"  readonly value="<?php echo $tLpay; ?>"  >
							    </div>
							 </div>
							 <hr>
							 
						 	 
						 	 <div class="form-group">
						 	    <?php   
                                    $stmt=$conn->prepare("select  amount from  UI__DailyROIGene where custId=:id ");  
                                    $stmt->bindValue(':id',  $AllUsers->cuurentId  , PDO::PARAM_STR);
                                    $stmt->execute(); 
                                    $tLpayR = $stmt->fetchAll(PDO::FETCH_OBJ);
                                    
                                    foreach($tLpayR as $mp)
                                        $tDpay +=$mp->amount;

						 	     ?>
						 	     
							    <label for="inputEmail3" class="col-sm-2 control-label">Total Daily Pay</label>
							    <div class="col-sm-6"> 
							       <input  class="form-control"  readonly value="<?php echo $tDpay; ?>"  >
							    </div>
							 </div>
							 <hr>
							 
							 
							  <div class="form-group">
							    <label for="inputEmail3" class="col-sm-2 control-label">UPI Limit</label>
							    <div class="col-sm-6"> 
							       <input  class="form-control" name="UpiLimit"  value="<?php echo  $AllUsers->UpiLimit; ?>"  >
							    </div>
							 </div>
							 <hr>
							 
							 
							 <div class="form-group">
							    <label for="inputEmail3" class="col-sm-2 control-label">NEFT Limit</label>
							    <div class="col-sm-6"> 
							       <input  class="form-control" name="NEFTLimit"  value="<?php echo  $AllUsers->NEFTLimit; ?>"  >
							    </div>
							 </div>
							 <hr>
							 
							 <div class="form-group">
							    <label for="inputEmail3" class="col-sm-2 control-label">IMPS Limit</label>
							    <div class="col-sm-6"> 
							       <input  class="form-control" name="IMPSLimit"  value="<?php echo  $AllUsers->IMPSLimit; ?>"  >
							    </div>
							 </div>
							 <hr>
							 
							 
							 
							 <div class="form-group">
							    <label for="inputEmail3" class="col-sm-2 control-label">Enter Custom UPI</label>
							    <div class="col-sm-6"> 
							       <input  class="form-control" name="UPI3"  value="<?php echo  $AllUsers->UPI3; ?>"  >
							    </div>
							 </div>
							 <hr>
							 
							 
							  <div class="form-group">
							    <label for="inputEmail3" class="col-sm-2 control-label">Upload Qr</label>
							    <div class="col-sm-6">   
							       <input type="file" name="qrcode" class="form-control"   />
 							    </div>
							 </div>
							 <hr>
							 
							 
							 
							 
							 
							 
							  <div class="form-group">
							    <label for="inputEmail3" class="col-sm-2 control-label">Marchant Commission </label>
							    <div class="col-sm-6"> 
							       <input  class="form-control" name="mtycommision"  value="<?php if($AllUsers->mtycommision=='') echo 0; else echo $AllUsers->mtycommision;  ?>"  >
							    </div>
							 </div>
							 <hr>
							 
							        	 
								 
								  <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';	?>    