<?php 	
            include_once('../../config.php');   
			if(isset($_POST['submit']))
			{     
                $amount = $_POST['withdrawAmt'];
                $Gdate = date("D-m-Y H:i");
                $adminD = date("Y-m-d");
		 	    mysql_query("update wallet set amount = amount - $_POST[withdrawAmt] where custId  = '$_POST[withdrawCustId]' ");
		 	    
		 	    $bal = $_POST['amount'] - $_POST['withdrawAmt']; 
                mysql_query("insert into biddings (custId,Points,Gdate,gametype,bazarId,balance,adminDate,optionType,Bname) values('$_POST[withdrawCustId]',$amount,'$Gdate',0,0,$bal,'$adminD',25,'Withdraw Points')  ");   
 
		 	    $_SESSION['WithdwarRequest'] = "Withdwaw Done";
			    header("Location: addWithdraw.php ");  
			    die;
			}  
			
			$SingleCloseResult = mysql_query("select * from  players where custId = '$_REQUEST[id]'   "); 
			$SingleClose  = mysql_fetch_object($SingleCloseResult);  
?>  
<?php  include ABS_PATH.'/admin/header.php';	?>  


 <script>
	$(function() {
		$( "#datepicker" ).datepicker(); 
		$("#ShowSingleAn").hide();
		$("#ShowJodi").hide();
		$("#ShowPanni").hide();
		
            $('#OptionSelect').on('change', function() 
            {
                if($(this).val()==1)
                {
                    $("#ShowSingleAn").show(500);
                	$("#ShowJodi").hide(500);
            		$("#ShowPanni").hide(500);
            		$("#AddValue").val(1);
                    
                }else if($(this).val()=='')
                {
                    
                    $("#ShowSingleAn").hide(500);
                	$("#ShowJodi").hide(500);
            		$("#ShowPanni").hide(500);
                }
            });

	}); 
  
	$(document).ready(function()
	{   

        	$("#ShowDetails").hide();
        	$("#product_frm").validate({
        		
        		errorElement:'div',
        		rules:{ 
        			withdrawAmt:{
        				number:true				 
        			} 
        			
        			
        			
        		},
        		messages:{				
        			 
        			 withdrawAmt:{
        				required:"Enter amount name"				 
        			} 
        		}
        	});

        
        $("#CheckDetails").click(function()
        {    
             
            
                $.ajax({
                    type: 'POST',
                    url: "../ajax/default.php",
                    //async: false,			 
                    data: {ShowUserDetail:1,mob:$("#MobileSelect").val()},	  
                    success: function(ajaxresult)
                    {	   	 	
                        var myArray = JSON.parse(ajaxresult); 
                        $("#playername").val(myArray.name);
                        $("#amount").val(myArray.wallet);   
                        $("#withdrawCustId").val(myArray.custId);   
                        $("#ShowDetails").show(500); 
                    },
                    error: function(XMLHttpRequest, textStatus, errorThrown) 
                    { 
                        
                    }
            	}); 
        }); 


	});
 


</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> Add Withdraw Request  </h3> <Br> <span style="color:green"><?php echo $_SESSION['WithdwarRequest']; unset($_SESSION['WithdwarRequest']);?></span></div>    
								
								<div class="panel-options"> 

								   <input type="button"  class="btn btn-warning" name="btnback" id="btnback" value=" Back " onClick="javascript:location.href='WithdrawRequest.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">Mobile</label>
								    <div class="col-sm-3"> 
								        
								        
								        <input type="text" id="MobileSelect" name="MobileSelect" placeholder="Enter Mobile" class="form-control" />
								        <a  href="javascript:void(0);" id="CheckDetails">Check Details</a>
								        
								    </div>
								 </div>
								 <hr>
								 
							 
								 <div id="ShowDetails">
    								 <div class="form-group">
    								    <label for="inputEmail3" class="col-sm-2 control-label">Name</label>
    								    <div class="col-sm-3"> 
    								        <input type="text"   class="form-control"  name="playername" id="playername"  readonly="readonly"/>
    								    </div>
    								 </div>
    								 <hr>
    								 
    								 <div class="form-group">
    								    <label for="inputEmail3" class="col-sm-2 control-label">Wallet</label>
    								    <div class="col-sm-3"> 
    								        <input type="text"  class="form-control" name="amount" id="amount"  readonly="readonly"/>
    								    </div>
    								 </div>
    								 <hr>
    								 
    								 <div class="form-group">
    								    <label for="inputEmail3" class="col-sm-2 control-label">Withdraw Amount</label>
    								    <div class="col-sm-3"> 
    								        <input type="text"   class="form-control" name="withdrawAmt"  id="withdrawAmt"/>
    								    </div>
    								 </div>
    								 <hr>
								 
								  
								  
								  
								  
								  <div class="form-group">
										<label for="inputEmail3" class="col-sm-2 control-label">Withdraw</label>
										<div class="col-sm-10">
										  <input type="submit"    class="btn btn-primary"  name="submit" value="Withdraw"> 
										  <input type="hidden" id="withdrawCustId" name="withdrawCustId" value=""  />
										</div>
								  </div>   
								  </div>
								</form>
								
								
							
			  				</div>
			  			</div>
	  				</div>
	  				 
	  			</div>

	  			 


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

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