<?php
include('../../connection/conn.php');
?>

<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>jQuery.Print</title>
<meta name="description" content="jQuery.print is a plugin for printing specific parts of a page">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="css/normalize.min.css">
<style type='text/css'>
        .a {
            background: black;
            color: white;
        }
        .b {
            color: #aaa;
        }
        </style>
    


<style>
.button {
  padding: 65px 45px;
  font-size: 24px;
  text-align: center;
  cursor: pointer;
  outline: none;
  color: #fff;
  background-color: #4CAF50;
  border: none;
  border-radius: 15px;
  box-shadow: 0 9px #999;
  margin: 20% auto;
  margin-left: 40%;
}

.button:hover {background-color: #3e8e41}

.button:active {
  background-color: #3e8e41;
  box-shadow: 0 5px #666;
  transform: translateY(4px);
}
</style>


</head>
<body>

        
<button class="print-link no-print button">GENERATE RECIEPT</button>

        
        
    
<div id="content_holder" hidden>
<div id="ele1" class="" >
<?php
//$Bar = new Picqer\Barcode\BarcodeGeneratorHTML();
//$code = $Bar->getBarcode($code, $Bar::TYPE_CODE_128);
echo "<div style='text-align:center; margin-top:-400px; margin:0% auto;'>";
echo "<p><img src='../../library/images/images/servair_lincoln.jpg' width='60%'></p>";

echo "<h1 style='font-size:12px; font-family:sans-serif;'>SERVAIR GHANA COMPANY LTD</h1>
<p style='font-size:10px; font-family:sans-serif;'>AIRPORT CITY 2
<br>P.O.Box KA 18108 KIA
<br>Accra - Ghana
<br>TEL: 0302730367 / 0577707889
<br>".date('l jS \of F Y h:i:s A')."</p>";

if(!empty($firstname)){ 
echo "<p>".$firstname." ".$middlename." ".$lastname."</p>";
}
else{
$query=mysqli_query($conn, "SELECT * FROM sales WHERE TransactionId = '$transactionid'"); 
while($spec=mysqli_fetch_assoc($query)){ 
$paymentmode = $spec['PaymentMode'];    
}

if($paymentmode == 'Cash'){
echo "<p style='font-size:12px;'>Cash Transaction</p>";
}else{
echo "<p style='font-size:12px;'>Coupon Transaction</p>";
}
    
}
echo "</div>";


echo "<table style=' width:98%; margin: 0% auto; font-size:11px; text-align:center; border-bottom:1px dashed black; '>
<tr style='border-bottom:1px dashed black;'>
<th style='border:none; width:10px; padding:10px;'>Qty</th>
<th style='border:none;'>Description</th>
<th style='border:none; '>Price</th>
<th style='border:none; '>Total</th>
</tr>
";
    


$query=mysqli_query($conn, "SELECT * FROM sales WHERE TransactionId = '$transactionid'"); 
while($spec=mysqli_fetch_assoc($query)){ 
echo "<tr>";
echo "<td style='padding:2px;'>".$spec['Quantity']." x</td>"; 
echo "<td>".$spec['DishName']."</td>";
echo "<td>".$spec['Price']."</td>";
echo "<td>".$spec['Total']."</td>";
echo "</tr>";
$amountpaid = $spec['AmountPaid'];
$balancechange = $spec['BalanceChange'];
$paymentmode = $spec['PaymentMode'];
}   
    
echo "</table>";
    
echo "<table style=' width:98%; margin: 3% auto; font-size:12px; text-align:center;'>";
echo "<tr>";
echo "<td style='width:10px;'><b>Subtotal</b></td>"; 
echo "<td style='text-align:right;'>".$total."</td>"; 
echo "</tr>";
    
echo "<tr>";
echo "<td style='width:10px; padding:10px 0px 0px;'>Tax</td>";  
echo "<td style='text-align:right;'>0.00</td>"; 
echo "</tr>";
    
echo "<tr>";
echo "<td style='width:10px;'><b>Total</b></td>";  
echo "<td style='text-align:right;'><b>GH¢</b> ".$total."</td>"; 
echo "</tr>";
echo "</table>";
    
if($paymentmode == 'Cash'){
echo "<table style=' width:98%; margin: 3% auto; font-size:12px; text-align:center;'>";
echo "<tr>";
echo "<td style='width:140px; text-align:left;'><b>Tendered amount</b></td>";  
echo "<td style='text-align:right;'>".$amountpaid."</td>"; 
echo "</tr>";
    
echo "<tr>";
echo "<td style='width:10px; padding:0px 0px 0px; text-align:left;'>Payment total</td>";  
echo "<td style='text-align:right;'>".$total."</td>"; 
echo "</tr>";
    
echo "<tr>";
echo "<td style='width:10px; text-align:left;'><b>Change</b></td>";  
echo "<td style='text-align:right;'><b>GH¢</b> ".$balancechange."</td>"; 
echo "</tr>";

echo "</table>";    
}    
    
if(!empty($firstname)){ 
    
$query=mysqli_query($conn, "SELECT * FROM card_loading_transactions WHERE TransactionId = '$transactionid'"); 
while($spec=mysqli_fetch_assoc($query)){
$creditbefore = $spec['CreditBefore'];  
$amountloaded = $spec['AmountLoaded']; 
$creditafter = $spec['CreditAfter'];
}
    
if(!empty($amountloaded)){
echo "<table style=' width:98%; margin: 3% auto; font-size:12px; text-align:center;'>";
echo "<tr>";
echo "<td style='width:140px; text-align:left;'><b>Credit balance b/f</b></td>";  
echo "<td style='text-align:right;'>".$creditbefore."</td>"; 
echo "</tr>";
    
echo "<tr>";
echo "<td style='width:10px; padding:0px 0px 0px; text-align:left;'>Amount loaded</td>";  
echo "<td style='text-align:right;'>".$amountloaded."</td>"; 
echo "</tr>";
    
echo "<tr>";
echo "<td style='width:10px; text-align:left;'><b>New card balance</b></td>";  
echo "<td style='text-align:right;'><b>GH¢</b> ".$creditafter."</td>"; 
echo "</tr>";
    

echo "</table>";
    
    
    
echo "<table style=' width:98%; margin: 3% auto; font-size:12px; text-align:center;'>";
echo "<tr>";
echo "<td style='width:140px; text-align:left;'><b>Total Items Bought</b></td>";  
echo "<td style='text-align:right;'>".$total."</td>"; 
echo "</tr>";
    
$query=mysqli_query($conn, "SELECT * FROM sales WHERE TransactionId = '$transactionid' GROUP BY Transactionid"); 
while($spec=mysqli_fetch_assoc($query)){
$creditbefore = $spec['Credit'];
$buyer_id = $spec['accountid'];
}
    
$query=mysqli_query($conn, "SELECT * FROM accounts WHERE id = '$buyer_id'"); 
while($spec=mysqli_fetch_assoc($query)){
$credit = $spec['Credit'];    
}

    
echo "<tr>";
echo "<td style='width:10px; text-align:left;'><b>Credit Remaining</b></td>";  
echo "<td style='text-align:right;'><b>GH¢</b> ".$credit."</td>"; 
echo "</tr>";

echo "</table>";
}
else{ 
    
$query=mysqli_query($conn, "SELECT * FROM sales WHERE TransactionId = '$transactionid' GROUP BY Transactionid"); 
while($spec=mysqli_fetch_assoc($query)){
$creditbefore = $spec['Credit'];
$buyer_id = $spec['accountid'];
}

echo "<table style=' width:98%; margin: 3% auto; font-size:12px; text-align:center;'>";
echo "<tr>";
echo "<td style='width:140px; text-align:left;'><b>Credit balance b/f</b></td>";  
echo "<td style='text-align:right;'>".$creditbefore."</td>"; 
echo "</tr>";
    
echo "<tr>";
echo "<td style='width:10px; padding:0px 0px 0px; text-align:left;'>Total Items Bought</td>";  
echo "<td style='text-align:right;'>".$total."</td>"; 
echo "</tr>";
    
$query=mysqli_query($conn, "SELECT * FROM accounts WHERE id = '$buyer_id'"); 
while($spec=mysqli_fetch_assoc($query)){
$credit = $spec['Credit'];    
}
echo "<tr>";
echo "<td style='width:10px; text-align:left;'><b>Credit Remaining</b></td>";  
echo "<td style='text-align:right;'><b>GH¢</b> ".$credit."</td>"; 
echo "</tr>";

    


echo "</table>";
        
}
}
    
echo "<div style='text-align:center; margin-top:20px; font-size:11px;'>";
echo "<span ><b>Vendor</b><br> ".$vendor."</span>";
//echo "<h1 style='margin-left:25px; font-size:8px;'>".$Bar->getBarcode($transactionid, $Bar::TYPE_CODE_128)."</h1>"; 
//echo "<span>".$transactionid."</span>";
    
    
echo "<p>For enquiries and concerns, please call <br>0302730367 / 0577707889<br>Thank you for your business</p>";
echo "</div>";
?>
</div>

</div>
           
        
        
        
<script src="../../library/frameworks/plugins/jquery-ui-1.11.4.custom/jquery-1.11.2.min.js"></script>
<script src="../jQuery.print.js"></script>
<script>
$(document).ready(function(){ 
$('.button').click(function(){ 
$('#ele1').print();
//window.location = "../../servair/search.php";
})
});
</script>
</body>
</html>
