<?php

	include 'header.php';
	include 'navbar.php';
	
	require_once('includes/API_Config.php');
    
	$obj = new API_Config;
	$data = array();
	$data['refer_id'] = $_SESSION['refer_id'];
	$data['user_id'] = $_SESSION['user_id'];
	$response = json_decode($obj->call_API("API_getPurchaseList.php", $data));
	error_reporting(0);
?>


 <div class="card">
            <div class="card-body">
              <h4 class="card-title">My Purchases</h4>
              <div class="row">
                <div class="col-12 table-responsive">
                  <table id="order-listing" class="table">
                    <thead>
                      <tr>
                          <th>Sr No.</th>
                          <th>Product Name</th>
                          <th>Purchase Date</th>
                          <th>Purchased Price</th>
						  <th>Total PV</th>
                          <th>Voucher Code</th>
						  <th>Status</th>
                      </tr>
                    </thead>
                    <tbody>
                     <?php
					 if(!empty($response->data))
					  {
							$count = 0;
							foreach($response->data as $row)
							{
								echo "<tr>";
								echo "<td>" . ++$count . "</td>";
								echo "<td>" . ucwords($row->name) . "</td>";
								echo "<td>" . date('d-m-Y', strtotime($row->date_entered)) . "</td>";
								echo "<td>" . $row->product_price . "</td>";
								echo "<td>" . $row->total_PV . "</td>";
								echo "<td>" . $row->voucher_code . "</td>";
								if($row->payment_status)
									echo "<td>Active</td>";
								else
								{
									if(!empty($row->deposit_slip))
										echo "<td>Pending</td>";
									else
										echo "<td><a href='purchase-payment-info.php?order=". $row->order_id ."'>Add Payment Info</a></td>";
								}

								echo "</tr>";
							}
						}

						else
						{
							echo "<tr><td>No Data Available</td><tr>";

						}

					?>                     
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
          </div>


<?php
	include 'footer.php';
?>