<?php

	include 'header.php';
	include 'navbar.php';
	include 'includes/admin_API_Config.php';

	$obj = new API_Config;
	$data = array();
	$data['admin_username'] = $_SESSION['admin_username'];
	$data['typeRequest'] = 0;
	$response = json_decode($obj->call_API2("API_purchase_list.php", $data));
	error_reporting(0);
	$data = $response->data[0];
 ?>

	      <div class="row">
            <div class="col-12 grid-margin">
              <div class="card card-statistics">
                <div class="row">

                  <div class="card-col col-xl-3 col-lg-3 col-md-3 col-6">
                    <div class="card-body">
                        <div class="d-flex align-items-center justify-content-center flex-column flex-sm-row">
                          <i class="mdi mdi-account-multiple-outline text-primary mr-0 mr-sm-4 icon-lg"></i>
                          <div class="wrapper text-center text-sm-left">
                            <p class="card-text mb-0">Total Members</p>
                            <div class="fluid-container">
                              <h3 class="card-title mb-0"><?php echo $data->totalMember;?></h3>
                            </div>
                          </div>
                        </div>
                      </div>
                  </div>
                  <div class="card-col col-xl-3 col-lg-3 col-md-3 col-6">
                    <div class="card-body">
                        <div class="d-flex align-items-center justify-content-center flex-column flex-sm-row">
                          <i class="mdi mdi-checkbox-marked-circle-outline text-primary mr-0 mr-sm-4 icon-lg"></i>
                          <div class="wrapper text-center text-sm-left">
                            <p class="card-text mb-0">Total Purchase Count</p>
                            <div class="fluid-container">
                              <h3 class="card-title mb-0"><?php echo $data->totalPurchase;?></h3>
                            </div>
                          </div>
                        </div>
                      </div>
                  </div>
                  <div class="card-col col-xl-3 col-lg-3 col-md-3 col-6">
                    <div class="card-body">
                        <div class="d-flex align-items-center justify-content-center flex-column flex-sm-row">
                          <i class="mdi mdi-trophy-outline text-primary mr-0 mr-sm-4 icon-lg"></i>
                          <div class="wrapper text-center text-sm-left">
                            <p class="card-text mb-0">Total Purchase(Rs.)</p>
                            <div class="fluid-container">
                              <h3 class="card-title mb-0"><?php echo $data->totalPrice;?></h3>
                            </div>
                          </div>
                        </div>
                      </div>
                  </div>
                  <div class="card-col col-xl-3 col-lg-3 col-md-3 col-6">
                    <div class="card-body">
                        <div class="d-flex align-items-center justify-content-center flex-column flex-sm-row">
                          <i class="mdi mdi-target text-primary mr-0 mr-sm-4 icon-lg"></i>
                          <div class="wrapper text-center text-sm-left">
                            <p class="card-text mb-0">Total Paid(Rs.)</p>
                            <div class="fluid-container">
                              <h3 class="card-title mb-0"><?php echo $data->totalPaid;?></h3>
                            </div>
                          </div>
                        </div>
                      </div>
                  </div>
                
				
				</div>
			  </div>
			</div>
		  </div>
		





	 <div class="card">
            <div class="card-body">
              <h4 class="card-title">Actual Purchase List</h4>
              <div class="row">
                <div class="col-12 table-responsive">
                  <table id="order-listing" class="table">
                    <thead>
                      <tr>
                          <th>Sr. #</th>
                          <th>Member <br/>Name</th>
                          <th>Member <br/>ID</th>
                          <th>Purchase <br/>Date</th>
                          <th>Product <br/>Name</th>
                          <th>Order No</th>
                          <th>Total PV</th>
	                      <th>Product <br/> Price</th>
	                      <th>Total <br/>Paid</th>
  	                      <th>Status</th>
	                  </tr>
                    </thead>
                    <tbody>
					 <?php
					 if(!empty($response->purchaseList))
					  {
							$count = 0;
							foreach($response->purchaseList as $row)
							{
								echo "<tr>";
								echo "<td>" . ++$count . "</td>";
								echo "<td>" . ucwords($row->name) . " " . ucwords($row->last_name) . "</td>";
								echo "<td>" . $row->refer_id . "</td>";
								echo "<td>" .  date('d-m-Y H:i:s',strtotime($row->date_entered)) . "</td>";
								echo "<td>" . ucwords($row->productName) . "</td>";
								echo "<td>" . $row->order_id . "</td>";
								echo "<td>" . $row->total_PV . "</td>";
								echo "<td>" . $row->product_price. "</td>";
    							echo "<td>" . $row->total_paid . "</td>";
    							echo "<td>";

								if($row->payment_status==1 && $row->upload_volume==1)
									echo "Done";

								else
									echo "<a href=\"../API/API_uploadvolumetype2.php?refer_id=". $row->refer_id ."&package_id=". $row->id ."\" target=\"_blank\"><i class=\"icon icon-pencil s-4\">Approve</i></a>";

								echo "</td>";
								echo "</tr>";
							}
						}

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

						}

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

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


    </body>
</html>
