<?php 	include_once('../../config.php');   	
		include_once(ABS_PATH.'/admin/login_check.php');    
?>  
<?php  include ABS_PATH.'/admin/header.php';	?>  

<script>
var URL  = '<?php echo ROOTPATH;?>';  
function del_record(val)
{

    
	var r = confirm("Do you really want to delete record !");
	if (r == true) {    
	$.ajax({
	type: 'POST',
	    url: URL+"/admin/ajax/default.php",
	//async: false,			 
	data: {del_Pin:1,val:val},	  
	success: function(ajaxresult){	     
		location.reload();	 	
	},
	error: function(XMLHttpRequest, textStatus, errorThrown) { 
	alert('Error');
	}
	});
	
	}	
	
}

</script>
		 
		<div class="col-md-10">  
  			<div class="content-box-large">
  				<div class="panel-heading">
					<div class="panel-title"><h3>Pin List </h3></div>
					
					<div align="right"> 
								    <a  class="btn btn-warning"  href="add_wallet.php" > Create Pins </a>
			         </div>  
			
				</div>
				
  				<div class="panel-body">
  					<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="example">
						<thead>
							<tr>
								<th>Sr</th> 
								<th>Random No</th>  
								<th>Transfered </th>    
								<th>Untransfered</th>  
								<th>Pin Status</th> 
								<th>Plan</th> 
								<th>Created Date</th> 
								<th>Action</th> 
							</tr>
						</thead>
						<tbody>
							<?php
                                    $stmt=$conn->prepare("select  * from  UI__PnMX group by PhNo order by id  ");  
                                    //$stmt->bindValue(':Ttime', $InTime , PDO::PARAM_STR);
                                    $stmt->execute(); 
                                    $AllUsers = $stmt->fetchAll(PDO::FETCH_OBJ); 
                                     
                                    
                                  $sr=1; 
								  foreach($AllUsers as $users)
								  {   
							   
							        
                                    $stmt=$conn->prepare("select id from  UI__PnMX  where PhNo=:PhNo   ");  
                                    $stmt->bindValue(':PhNo', $users->PhNo , PDO::PARAM_STR);
									$stmt->execute(); 
                                    $Rwcount = $stmt->rowCount();
                                    
                                    
                                    
                                    $stmt=$conn->prepare("select  * from  UI__PnMX  where PhNo=:PhNo and Transfered!='' ");  
                                    $stmt->bindValue(':PhNo', $users->PhNo , PDO::PARAM_STR);
									$stmt->execute(); 
									    
                                     
                                     if($users->AMMT==1)
                                        $plan = "5000";  

							?>
							<tr class="odd gradeX">
								<td><?php echo $sr++;?> </td>
								<td><?php echo $users->PhNo.' ('.$Rwcount.')';?></td>
								<td><?php   echo $stmt->rowCount();?></td> 
								<td><?php echo  $Rwcount-$stmt->rowCount();?></td>  
								<td><?php  if($users->exp==1) echo "Used"; else echo "Active";?>  </td> 
								<td><?php echo $plan;?>  </td> 
								<td><?php echo $users->createdOn;?>  </td>    								 
								<td> 
								        <a href="javascript:void(0);" onclick="del_record(<?php echo  $users->PhNo;?>);"> Delete </a> /
								        <a href="VieDetails.php?Rd=<?php echo $users->PhNo;?>"> View Details </a> 
								</td> 
							</tr>  
							<?php } ?>
						</tbody>
					</table>
  				</div>
  			</div>



		  </div>
		</div>
    </div>

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