<?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;
	$data['order_id'] = $_GET['order_id'];
	$response = json_decode($obj->call_API("API_order_list.php", $data));
	error_reporting(0);
	$orderData   = $response->orderList[0];
    $packageData = $response->packageList[0];

	//var_dump($packageData);
	
?>

	 <div class="card">
            <div class="card-body">
              <h4 class="card-title">Order # <?php echo $_GET['order_id'];?> Summary:</h4>
		      <div class="row">

			  <table class="table">
			  <thead>
                      <tr>
                          	<th>No of Items:</th>
							<th>Total Quantity:</th>
							<th>Total Price:</th>
							<th>Discount Code:</th>
							<th>Discount Amount:</th>
							<th>Sub Total Price:</th>
							<th>GST:</th>
							<th>Grand Total:</th>
                      </tr>
                    </thead>
                    <tbody>

						<tr>
							<td><?php echo $orderData->no_of_items; ?></td>
							<td><?php echo $orderData->total_quantity; ?></td>
							<td><?php echo $orderData->total_price; ?></td>
							<td><?php echo $orderData->discount_code; ?></td>
							<td><?php echo $orderData->discount_amount; ?></td>
							<td><?php echo $orderData->subtotal_price; ?></td>
							<td><?php echo $orderData->total_tax; ?></td>
							<td><?php echo $orderData->total_amount; ?></td>
						</tr>



					</tbody>



			  </table>

			  </div>
			  <p>&nbsp;</p>

              <div class="row">
                <div class="col-12 table-responsive">
                  <table id="payment-listing" class="table">
                    <thead>
                      <tr>
                          <th>Sr. #</th>
                          <th>Product Name</th>
                          <th>Product Price</th>
						  <th>Qty</th>
						  <th>Total Price</th>
                          <th>PV</th>
  						  <th>Total PV</th>
                      </tr>
                    </thead>
                    <tbody>
					 <?php
					 if(!empty($response->packageList))
					  {
							$count = 0;
							foreach($response->packageList as $row)
							{
								echo "<tr>";
								echo "<td>" . ++$count . "</td>";
								echo "<td>" . ucwords($row->name) . " " . ucwords($row->last_name) . "</td>";
								echo "<td>" . $row->product_price . "</td>";
								echo "<td>" . $row->qty . "</td>";
								echo "<td>" . ($row->product_price * $row->qty). "</td>";
								echo "<td>" . $row->pv . "</td>";
								echo "<td>" . $row->total_PV . "</td>";
								
							
							}
						}


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

						}

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

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

   <script type="text/javascript">
        
        $(document).ready(function(){


			  $('#payment-listing').DataTable({
			  "aLengthMenu": [
				[5, 10, 15, -1],
				[5, 10, 15, "All"]
			  ],
			  "iDisplayLength": 10,
			  "language": {
				search: ""
			  }
			});

				 
			 $('#payment-listing').each(function() {
			  var datatable = $(this);
			  // SEARCH - Add the placeholder for Search and Turn this into in-line form control
			  var search_input = datatable.closest('.dataTables_wrapper').find('div[id$=_filter] input');
			  search_input.attr('placeholder', 'Search');
			  search_input.removeClass('form-control-sm');
			  // LENGTH - Inline-Form control
			  var length_sel = datatable.closest('.dataTables_wrapper').find('div[id$=_length] select');
			  length_sel.removeClass('form-control-sm');
			});

	
        });

   </script>

    </body>
</html>
