<?php 
session_start();
include("connectdb.php"); 

$user_id = $_SESSION['userid'];

$transaction_id = $_GET['trid'];

function l_status($status){
	if($status == 1){
		return 'Ready';
	}else{
		return 'Pending';
	}
}

function customerName($user_id){
	global $con;
	$query = mysqli_query($con, "SELECT * FROM loyalty WHERE account_id = $user_id");
	$row = mysqli_fetch_array($query);
	$full_name =  $row['first_name'] . ' ' . $row['last_name'];
	
	return $full_name;
}


?>
<?php include("side_nav.php"); ?>
<?php include("top_nav.php"); ?>


        <!-- page content -->
        <div class="right_col" role="main">
          <div class="">
            <div class="page-title">
              <div class="title_left">
                <h3></h3>
              </div>

            </div>
            <div class="clearfix"></div>

            <div class="row">

              <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="x_panel">
                  <div class="x_title">
                    <h2>Payment Section <small></small></h2>
                    <ul class="nav navbar-right panel_toolbox">
                      <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
                      </li>
                      <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"><i class="fa fa-wrench"></i></a>
                        <ul class="dropdown-menu" role="menu">
                          <li><a href="#">Settings 1</a>
                          </li>
                          <li><a href="#">Settings 2</a>
                          </li>
                        </ul>
                      </li>
                      <li><a class="close-link"><i class="fa fa-close"></i></a>
                      </li>
                    </ul>
                    <div class="clearfix"></div>
                  </div>
                  <div class="x_content">
                    <p class="text-muted font-13 m-b-30">
                      This is the detail of one transaction selected.
                    </p>
					
					<!-- <table id="datatable-buttons" class="table table-striped table-bordered"> -->
                    <table id="datatable" class="table table-striped table-bordered">
                      <thead>
                        <tr>
							<th><b>Customer name</b></th>
							<th class="col-md-3 col-sm-3 col-xs-3" ><b>Test name</b></th>
							<th><b>Transaction id</b></th>
							<th><b>Amount</b></th>
							<th><b>Date</b></th>
							</tr>
                      </thead>
                     
                      <tbody>
					    <?php 
						    $total_price = 0;
						    $sql =  mysqli_query($con, "SELECT * FROM labtesttill WHERE transaction_id = '$transaction_id' "); 
								    while($row = mysqli_fetch_array($sql)):
									$total_price += $row['price'];
						?>
								<tr>
									<td><?php echo customerName($row['user_id']); ?></td>
									<td><?php echo $row['test_name']; ?></td>
									<td><?php echo $row['transaction_id']; ?></td>
									<td><?php echo $row['price']; ?></td>
									<td><?php echo $row['date']; ?></td>
								</tr>
						<?php endwhile; ?>
                      </tbody>
					  
                    </table>
					<h3><b>Total : <?php  echo '₦' . number_format($total_price); ?></b></h3>
                  </div>
				<div class="row" >
				  <span onclick="submitAndPrint('cash')"><button type="submit" name="submit" class="btn btn-primary" >Cash</button></span>
				  <span onclick="submitAndPrint('access')"><button type="submit" name="submit" class="btn btn-primary">Access</button></span>
				  <span onclick="submitAndPrint('gtbank')"><button type="submit" name="submit" class="btn btn-primary">Gtbank</button></span>
				  <span onclick="submitAndPrint('uba')"><button type="submit" name="submit" class="btn btn-primary">UBA</button></span>
				  <span onclick="submitAndPrint('zenith')"><button type="submit" name="submit" class="btn btn-primary">Zenith</button></span>
				</div>
				</div>
				
              </div>
            </div>
          </div>
        </div>
        <!-- /page content -->
 <!-- /footer content -->
      </div>
    </div>
    <!-- jQuery -->
    <script src="../vendors/jquery/dist/jquery.min.js"></script>
    <!-- Bootstrap -->
    <script src="../vendors/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- FastClick -->
    <!-- Custom Theme Scripts -->
    <script src="../build/js/custom.min.js"></script>
	<!-- SWEET ALERT -->
	<script src="../vendors/datatables.net/js/jquery.dataTables.min.js"></script>
    <script src="../vendors/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
    <script src="../vendors/datatables.net-buttons/js/dataTables.buttons.min.js"></script>
    <script src="../vendors/datatables.net-buttons-bs/js/buttons.bootstrap.min.js"></script>
    <script src="../vendors/datatables.net-buttons/js/buttons.flash.min.js"></script>
    <script src="../vendors/datatables.net-buttons/js/buttons.html5.min.js"></script>
    <script src="../vendors/datatables.net-buttons/js/buttons.print.min.js"></script>
    <script src="../vendors/datatables.net-fixedheader/js/dataTables.fixedHeader.min.js"></script>
    <script src="../vendors/datatables.net-keytable/js/dataTables.keyTable.min.js"></script>
    <script src="../vendors/datatables.net-responsive/js/dataTables.responsive.min.js"></script>
    <script src="../vendors/datatables.net-responsive-bs/js/responsive.bootstrap.js"></script>
    <script src="../vendors/datatables.net-scroller/js/dataTables.scroller.min.js"></script>
	</body>
</html>

<!---- Personal Dev -->
<script src="myscripts.js"></script>
<script>


$("body").delegate("#trash","click",function(event){
	var trash = $(this).attr('deleteId');
	$.ajax({
		url	:	"process.php",
		type:	"POST",
		data	:	{query_product:1, product_id:trash},
		success	:	function(){ 
			window.location = "view_products.php" ;
		}
	 })
	 
})
	
</script>
