<?php 	
    include_once('../../config.php');   	
    include_once(ABS_PATH.'/admin/login_check.php'); 
	
            
            if(isset($_POST['update']))
            {
                
                if($_POST['Status']==2)
                {
                 
                        $stmt=$conn->prepare("select userid,orgAmt from UI__WithDraw where id=:id   ");   
                        $stmt->bindValue(':id', $_REQUEST['id'] , PDO::PARAM_INT);
                        $stmt->execute();       
                        $All = $stmt->fetch(PDO::FETCH_OBJ);
                         
                        
                        $stmt=$conn->prepare("select  custId from UI__Rgst  where cuurentId=:cuurentId ");   
                        $stmt->bindValue(':cuurentId', $All->userid , PDO::PARAM_INT);
                        $stmt->execute();       
                        $All1 = $stmt->fetch(PDO::FETCH_OBJ);   
                         
                        
                        $stmt=$conn->prepare("insert into UI__DroiCt  (Cid,Roi,Tdate,status) values(:Cid,:Roi,:Tdate,1)  ");   
                        $stmt->bindValue(':Cid',  $All1->custId , PDO::PARAM_STR);
                        $stmt->bindValue(':Roi', $All->orgAmt , PDO::PARAM_STR);
                        $stmt->bindValue(':Tdate',  date("d-M-Y H:i") , PDO::PARAM_STR);
                        $stmt->execute();     
                }   
                
                $stmt=$conn->prepare("update    UI__WithDraw set accept=:accept   where id=:id   ");  
                $stmt->bindValue(':accept', $_POST['Status'] , PDO::PARAM_STR); 
                $stmt->bindValue(':id', $_REQUEST['id'] , PDO::PARAM_INT);
                $stmt->execute();   
                header("Location: walletRst.php");
                die;
            }      
            
            $stmt=$conn->prepare("select  * from   UI__WithDraw where id=:id ");  
            $stmt->bindValue(':id', $_REQUEST['id'] , PDO::PARAM_STR);
            $stmt->execute(); 
            $AllUsers = $stmt->fetch(PDO::FETCH_OBJ); 
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> Update Status </h3></div>    
								
								<div class="panel-options"> 

								   <input type="button"  class="btn btn-warning" name="btnback" id="btnback" value=" Back " onClick="javascript:location.href='walletRst.php';" />
								  
								</div>
							  
								 
							</div>
							
							
			  				<div class="panel-body">    
			  					<form class="form-horizontal" role="form" method="post" enctype="multipart/form-data" id="product_frm" autocomplete="off"> 
								 
								 
								 <div class="form-group">
								    <label for="inputEmail3" class="col-sm-2 control-label">Status</label>
								    <div class="col-sm-3">
								     <select  class="form-control" name="Status">
								         <option value="1" <?php if($AllUsers->accept==1) echo "selected"; ?>>Paid</option>
								         <option value="2" <?php if($AllUsers->accept==2) echo "selected"; ?>>Reject</option>
								         <option value="0" <?php if($AllUsers->accept==0) echo "selected"; ?>>Pending</option>
								     </select>
								    </div>
								 </div>
								 <hr>
								  
								   
								  
								  <div class="form-group">
										<label for="inputEmail3" class="col-sm-2 control-label">Add User</label>
										<div class="col-sm-10">
										  <input type="submit"    class="btn btn-primary"  name="update" value="Update Status">
										</div>
								  </div>   
								</form>
								
								
							
			  				</div>
			  			</div>
	  				</div>
	  				 
	  			</div>

	  			 


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

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