<?php
require_once '../includes/core.php';
require '../includes/connect.php';


$count = @current(@mysql_fetch_assoc(@mysql_query("SELECT count('user_id') FROM users")));






if (loggedinadmin()){


$adminname = getfield1('name','admin','admin-id');
$admin_id = getfield1('admin-id','admin','admin-id');
$password = getfield1('password','admin','admin-id');

}else{ 
	header('Location:../loginexec.php');
}



?>






<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Admin - Dashboard</title>

<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/datepicker3.css" rel="stylesheet">
<link href="css/styles.css" rel="stylesheet">

<link rel="icon" type="image/png" href="../assets/img/favicon.png">

<!--Icons-->
<script src="js/lumino.glyphs.js"></script>

<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<script src="js/respond.min.js"></script>
<![endif]-->



</head>

<body>

    <?php include ('includes/header.php')  ?>

    <?php include ('includes/leftnav.php')  ?>
	
	
		
	<div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main" style="margin-top: 20px">			
		<div class="row">
			<ol class="breadcrumb">
				<li><a href="#"><svg class="glyph stroked home"><use xlink:href="#stroked-home"></use></svg></a></li>
				<li class="active">home</li>
			</ol>
		</div><!--/.row-->
		
		
		<div class="row">
			<div class="col-lg-12">
				<h1 class="page-header">All Orders</h1>
			</div>
		</div><!--/.row-->
		
		<div class="row">
			
			<div class="col-md-12">
				<div class="panel panel-primary">
					<div class="panel-heading">
					

</div>
					</div>
					<div class="panel-body">






<?php



$page=mysql_real_escape_string($_REQUEST['p']);
$limit=10;
if($page=='')
{
 $page=1;
 $start=0;
}
else
{
 $start=$limit*($page-1);
}



$query=mysql_query("SELECT * FROM orders order by id DESC limit $start, $limit")or die(mysql_error());

$tot=mysql_query("SELECT * FROM orders order by id DESC")or die(mysql_error());
$total=mysql_num_rows($tot);
$num_page=ceil($total/$limit);


echo'                 	
                    <table class="table table-bordered">
    <thead>
      <tr>
         <th>Id</th>
        <th>Name</th>
         <th>Email</th>
        <th>Service Type</th>
        <th>Amount</th>
        <th>Payment Status</th>

        <th>Date</th>

        
<th>Action</th>
       
       
      </tr>
    </thead>
    <tbody>
     ';





while($res=mysql_fetch_array($query))
{



	$id = mysql_real_escape_string($res['id']);
	$uid = mysql_real_escape_string($res['id']);
	$userid = mysql_real_escape_string($res['user_id']);

	$useremail = @current(@mysql_fetch_assoc(@mysql_query("SELECT email FROM users WHERE `user_id` = '$userid'")));



			
				echo "<tr align='center'>";	
				
				echo"<td><font color='#1c1c1c'>" .$res['id']."</font></td>";
					echo"<td><font color='#1c1c1c'>" .$res['name']."</font></td>";
						echo"<td><font color='#1c1c1c'>" .$res['email']."</font></td>";
				

				echo"<td ><font color='black'>" .$res['item_name']."</font></td>";

				echo"<td ><font color='black'>$" .$res['item_price']."</font></td>";
				

				echo"<td ><font>";
				
				if ($res['payment_status'] === 'succeeded') {
				echo "<span class='btn btn-success' ><a href='#' style='color:#fff'>" .$res['payment_status']." </a></span>";
			}elseif ($res['payment_status'] === 'pending') {
				echo "<span class='btn btn-danger' ><a href='#' style='color:#fff'>" .$res['payment_status']." </a></span>";
			}


				echo"</font></td>";


				echo"<td ><font color='black'>". $res['created']. "</font></td>";
				

				

				echo"<td> <a href ='mesdel.php?id=$id' onclick=\"return confirm('Confirm you want to Delete this')\" class='btn btn-danger'>Delete</a>";
				
				
				
			






				echo "</tr>";


}
echo'</table>


 </tbody>';


function pagination($page,$num_page)
{
  echo'<ul style="list-style-type:none;">';
  for($i=1;$i<=$num_page;$i++)
  {
     if($i==$page)
{
 echo'<li style="float:left;padding:5px;">'.$i.'</li>';
}
else
{
 echo'<li style="float:left;padding:5px;"><a href="match.php?p='.$i.'">'.$i.'</a></li>';
}
  }
  echo'</ul>';
}
if($num_page>1)
{
 pagination($page,$num_page);
}
?> 




<?php	
		
	if (isset ($_POST['conf']) && isset ($_POST['submit']) )
	{
		$errors = array();
		
		
		$conf = $_POST['conf'];
		

	   
			
									
									  $query = "UPDATE `makedonation` SET `status`='paid' WHERE `id`='$conf'";
										if($query_run = mysql_query($query)){
										header('Location:match.php');									
										}else
											{
												echo '<div style="background:transparent; width:500px; height:40px; position:absolute;top:730px;left:750px;z-index:9999;"><span style="font-family:Arabic Typesetting; color:red; font-size:30px; position:absolute; margin-top:5; margin-left:3;">submission is not successful</span></div>';
											}
												
									
							}
	
	



	
	
	
?>	












					



























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





			
			
			

		</div><!--/.row-->




		
		
		
	
								
	
	</div>	<!--/.main-->

	<script src="js/jquery-1.11.1.min.js"></script>
	<script src="js/bootstrap.min.js"></script>
	<script src="js/chart.min.js"></script>
	<script src="js/chart-data.js"></script>
	<script src="js/easypiechart.js"></script>
	<script src="js/easypiechart-data.js"></script>
	<script src="js/bootstrap-datepicker.js"></script>
	<script>
		$('#calendar').datepicker({
		});

		!function ($) {
		    $(document).on("click","ul.nav li.parent > a > span.icon", function(){          
		        $(this).find('em:first').toggleClass("glyphicon-minus");      
		    }); 
		    $(".sidebar span.icon").find('em:first').addClass("glyphicon-plus");
		}(window.jQuery);

		$(window).on('resize', function () {
		  if ($(window).width() > 768) $('#sidebar-collapse').collapse('show')
		})
		$(window).on('resize', function () {
		  if ($(window).width() <= 767) $('#sidebar-collapse').collapse('hide')
		})
	</script>	
</body>

</html>
