<?php
include("sess_page.php");
include("include/protect.php");
include("include/dbconnect.php");
$uname=$_SESSION['uname'];
extract($_POST);
if(isset($btn))
{

$select = mysql_query("SELECT * FROM user_purchase where uname='$uname' && status=1 && month1='$month1' && year1=$year1 ORDER BY pid DESC");
$num=mysql_num_rows($select);
}
?>
<html>
<head>
<title><?php include("include/title.php"); ?></title>
<link href="style.css" rel="stylesheet" type="text/css">
<script language="javascript">
function confirm_st()
{
	if(!confirm("Are you sure to continue?"))
	{
	return false;
	}
return true;
}
</script>
<script language="javascript">
function rateWin(id)
{
window.open("rating.php?pid="+id,"Rating","width=400,height=500,menubar=0,toolbar=0,statusbar=0,scrollbars=1");
}
function reviewWin(id)
{
window.open("reviews.php?pid="+id,"Rating","width=400,height=500,menubar=0,toolbar=0,statusbar=0,scrollbars=1");
}
function reviewWin(id)
{
window.open("add_review.php?pid="+id,"Rating","width=400,height=500,menubar=0,toolbar=0,statusbar=0,scrollbars=1");
}
</script>
<link rel="stylesheet" href="../css/bootstrap.min.css">
    <!-- Site CSS -->
    <link rel="stylesheet" href="../css/style.css">
    <!-- Responsive CSS -->
    <link rel="stylesheet" href="../css/responsive.css">
    <!-- Custom CSS -->
    <link rel="stylesheet" href="../css/custom.css">
</head>

<body>
<form id="form1" name="form1" method="post" action="">
<header class="main-header">
        <!-- Start Navigation -->
        <nav class="navbar navbar-expand-lg navbar-light bg-light navbar-default bootsnav">
            <div class="container">
                <!-- Start Header Navigation -->
                <div class="navbar-header">
                    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar-menu" aria-controls="navbars-rs-food" aria-expanded="false" aria-label="Toggle navigation">
                    <i class="fa fa-bars"></i>
                </button>
                    <a class="navbar-brand" href="index.html"><img src="../images/logo.png" class="logo" alt=""></a>
                </div>
                <!-- End Header Navigation -->

                <!-- Collect the nav links, forms, and other content for toggling -->
                <div class="collapse navbar-collapse" id="navbar-menu">
                    <ul class="nav navbar-nav ml-auto" data-in="fadeInDown" data-out="fadeOutUp">
                        <li class="nav-item  "><a class="nav-link" href="user_page.php">Home</a></li>
						<li class="nav-item  "><a class="nav-link" href="user_parchase_order.php">Products</a></li>
						<li class="nav-item "><a class="nav-link" href="user_purch_view.php">View Cart</a></li>
                        <li class="nav-item active"><a class="nav-link" href="view_purchase.php">Purchases Details</a></li>
                        <li class="nav-item"><a class="nav-link" href="../index.html" >Logout</a></li>
                    </ul>
                </div>
                <!-- /.navbar-collapse -->

               
                <!-- End Atribute Navigation -->
            </div>
            <!-- Start Side Menu -->
            <div class="side">
                <a href="#" class="close-side"><i class="fa fa-times"></i></a>
                <li class="cart-box">
                    <ul class="cart-list">
                        <li>
                            <a href="#" class="photo"><img src="../images/bg2.jpg" class="cart-thumb" alt="" /></a>
                            <h6><a href="#">Delica omtantur </a></h6>
                            <p>1x - <span class="price">$80.00</span></p>
                        </li>
                        <li>
                            <a href="#" class="photo"><img src="../images/bg1.jpg" class="cart-thumb" alt="" /></a>
                            <h6><a href="#">Omnes ocurreret</a></h6>
                            <p>1x - <span class="price">$60.00</span></p>
                        </li>
                        <li>
                            <a href="#" class="photo"><img src="../images/bg1.jpg" class="cart-thumb" alt="" /></a>
                            <h6><a href="#">Agam facilisis</a></h6>
                            <p>1x - <span class="price">$40.00</span></p>
                        </li>
                        <li class="total">
                            <a href="#" class="btn btn-default hvr-hover btn-cart">VIEW CART</a>
                            <span class="float-right"><strong>Total</strong>: $180.00</span>
                        </li>
                    </ul>
                </li>
            </div>
            <!-- End Side Menu -->
        </nav>
        <!-- End Navigation -->
    </header>
    <!-- End Main Top -->

    <!-- Start Top Search -->
    <div class="top-search">
        <div class="container">
            <div class="input-group">
                <span class="input-group-addon"><i class="fa fa-search"></i></span>
                <input type="text" class="form-control" placeholder="Search">
                <span class="input-group-addon close-search"><i class="fa fa-times"></i></span>
            </div>
        </div>
    </div>
    <!-- End Top Search -->

    <!-- Start Slider -->
    <div id="slides-shop" class="cover-slides">
        <ul class="slides-container">
            <li class="text-center">
                <img src="../images/bg1.jpg" alt="">
                <div class="container">
                    <div class="row">
                        <div class="col-md-12">
                            <h1 class="m-b-20"><strong>Welcome To <br> Freshshop</strong></h1>
                            <p class="m-b-40">See how your users experience your website in realtime or view <br> trends to see any changes in performance over time.</p>
                           
                        </div>
                    </div>
                </div>
            </li>
            
            <li class="text-center">
                <img src="../images/bg3.jpg" alt="">
                <div class="container">
                    <div class="row">
                        <div class="col-md-12">
                            <h1 class="m-b-20"><strong>Welcome To <br> Freshshop</strong></h1>
                            <p class="m-b-40">See how your users experience your website in realtime or view <br> trends to see any changes in performance over time.</p>
                            
                        </div>
                    </div>
                </div>
            </li>
        </ul>
        
    </div>
    <!-- End Slider -->
  <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
    
    <tr>
      <td align="center" valign="top"><p class="txt1">&nbsp;</p>
        <p class="txt1"><strong>Purchase Details </strong></p><p>&nbsp;</p>
        <p class="txt1"><strong>Search by</strong>&nbsp;<p>&nbsp;</p>
          <select name="month1" class="form-control">
		   <option value="0">-MONTH-</option>
		  <?php
		  $mq=mysql_query("select distinct(month1) from user_purchase where uname='$uname'");
		  while($mr=mysql_fetch_array($mq))
		  {
		  ?>
		  <option <?php if($month1==$mr['month1']) echo "selected"; ?>><?php echo $mr['month1']; ?></option>
		  <?php
		  }
		  ?>
          </select>
          &nbsp;
          <select name="year1" class="form-control">
		   <option value="0">-YEAR-</option>
		  <?php
		  $yq=mysql_query("select distinct(year1) from user_purchase where uname='$uname'");
		  while($yr=mysql_fetch_array($yq))
		  {
		  ?>
		  <option <?php if($year1==$yr['year1']) echo "selected"; ?>><?php echo $yr['year1']; ?></option>
		  <?php
		  }
		  ?>
          </select>
          &nbsp;<p>&nbsp;</p>
          <input type="submit" name="btn" value="Submit" class="btn hvr-hover">
        </p>
		</p>&nbsp;</p>
        <p class="txt1">
          <?php
	  if($num!=0)
	  {
	  ?>
        </p>
        <table width="70%" height="78" border="0" align="center" class="table">
		<thead class="thead-dark">
          <tr align="center" bgcolor="#999999">
            <th scope="col">Sno:</th>
            <th scope="col">Product Name </th>
            <th scope="col">Price</th>
            <th scope="col">quantity</th>
            <th scope="col">Amount</th>
            <th scope="col">Date / Time</th>
            <th scope="col">Delivery</th>
			<th scope="col">Action</th>
          </tr>
		  </thead>
		  <?php
		  $p = 0;
		  while($row = mysql_fetch_array($select)){
		  $p++;
		  ?>
          <tr align="center" bgcolor="#CCCCFF">
            <td scope="col"><?php echo $p; ?></td>
            <td scope="col"><?php echo $row['pname']; ?></td>
            <td scope="col"><?php echo $row['price']; ?></td>
            <td scope="col"><?php echo $row['uqut']; ?></td>
            <td scope="col"><?php  
			$total = $row['price'] * $row['uqut']; 
			echo $total;
			$tot[]=$total;
			?></td>
            <td scope="col"><?php echo $row['rdate']; ?></td>
            <td scope="col"><?php 
			if($row['delivery_status']=="1")
			{
			
			echo "Delivered";
			}
			else
			{
			echo "Not Delivered";
			}
			?></td>
			<td><a href="javascript:rateWin('<?php echo $row[$id]; ?>')">Rating</a></td>
			<td><?php echo '<a href="rating.php?pid='.$row['id'].'">View Graph</a>'; ?></td>
          </tr>
		  <?php
		  }
		  ?>
        </table>
		<?php
		}
		else
		{
		echo '<p class="style1">No data Found!</p>';
		}
		?>
        </td>
    </tr>
    <tr>
      <td align="center" >&nbsp;</td>
    </tr>
  </table>
</form>
<div class="footer-copyright">
        <p class="footer-company">&nbsp;</p>
    </div>
<script src="../js/jquery-3.2.1.min.js"></script>
    <script src="../js/popper.min.js"></script>
    <script src="../js/bootstrap.min.js"></script>
    <!-- ALL PLUGINS -->
    <script src="../js/jquery.superslides.min.js"></script>
    <script src="../js/bootstrap-select.js"></script>
    <script src="../js/inewsticker.js"></script>
    <script src="../js/bootsnav.js."></script>
    <script src="../js/images-loded.min.js"></script>
    <script src="../js/isotope.min.js"></script>
    <script src="../js/owl.carousel.min.js"></script>
    <script src="../js/baguetteBox.min.js"></script>
    <script src="../js/form-validator.min.js"></script>
    <script src="../js/contact-form-script.js"></script>
    <script src="../js/custom.js"></script>
</body>
</html>