<?php  include 'topmost.php';
error_reporting(0);
$app = getAppSource();

 ?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <link rel="stylesheet" href="style.css">
        <title>myOutlet App</title>
        <link rel="shortcut icon"  href="../img/undraw_rocket.svg">

        <style type="text/css">
            * {
    font-size: 12px;
    font-family: 'Times New Roman';
    margin:0;
}
@media print{
    td,
th,
tr,
table {
    border-top: 2px solid black !important;
    border-collapse: collapse;
}

}
td,
th,
tr,
table {
    border-top: 1px solid black;
    border-collapse: collapse;
}

/*td.description,
th.description {
    width: 75px;
    max-width: 75px;
}
*/
td.quantity,
th.quantity {
    width: 40px;
    max-width: 40px;
    word-break: break-all;
}

/*td.price,
th.price {
    width: 40px;
    max-width: 40px;
    word-break: break-all;
}*/

.centered {
    text-align: center;
    align-content: center;
}

.ticket {
    width: 250px;
    max-width: 200px;
}

img {
    max-width: inherit;
    width: inherit;
}

@media print {
    .hidden-print,
    .hidden-print * {
        display: none !important;
    }
}
*{
    font-weight:bolder;
}

.mySize{
    font-size: 15px;
}

@media print{
    .forceIt{
        width:500px;
    }
}

        </style>
    </head>
    <body onload="loader()">
        <div style="width:250px;" class="forceIt">
            <center><img src="../<?php echo $app['comp_logo'];  ?>" alt="Logo" style='height:80px;width:80px;'></center>
            <p class="centered"><b><?php echo strtoupper($app['comp_name']);  ?></b>
                <br><?php echo strtoupper($app['comp_addr']);  ?>
                <br><?php echo strtoupper($app['comp_phone']);  ?>
<br><b>Receipt No:<?php echo $_GET['no'];  ?></b>
            </p>
<?php $zumba= QueryDB("SELECT * FROM  payment where receipt_id ='".$_GET['no']."' and pay_status=1 "); $cloud =$zumba->fetch(PDO::FETCH_ASSOC);?>

<table width="100%" border="1" style="line-height: 25px;"><tr>
<th  style="text-align: left;">ITEM</th>
<th style="text-align: left;">cost</th>
<th style="text-align: left;">Total</th>
</tr>
<?php $addTotal = 0; for($p=0;$p<count(explode(',',$cloud['item']));$p++){
echo '<tr><td style="">'.getProductName(explode(',',$cloud['item'])[$p]).' ('.(explode(',',$cloud['qty'])[$p]).')</td><td>'.(explode(',',$cloud['s_price'])[$p]).'</td><td>'.(explode(',',$cloud['bulk_price'])[$p]).'</td></tr>';
$addTotal+=(explode(',',$cloud['bulk_price'])[$p]);
}
echo '<tr><th>TOTAL COST</th><th colspan="2" style="font-size:18px;">'.number_format($addTotal,2).'</th></tr>';
?></table>
<table width="100%" border="1" style="line-height: 25px;">
<?php foreach(QueryDB("SELECT * FROM  payment where receipt_id ='".$_GET['no']."' ")as $level2){ if($level2['pay_status']==1){?>
<tr><td>PAID</td><td colspan="2" style="text-align: right;font-size:16px;">&#8358; <?php echo number_format($level2['amt_paid'],2); ?>
 <br><span style="font-size:14px;"><?php  echo $level2['date_paid'];  echo '('.pay_MTH($level2['pay_mth']).')';?></span></td></tr><?php }else if($level2['pay_status']==0){ echo '<tr><td>DEBT</td><td colspan="2" style="text-align: right;font-size:16px;">&#8358;'.number_format($level2['out_standing'],2).'</td></tr>'; }?>
<?php } ?>
<tr><td>BUYER</td><td style="font-size:15px;"><?php echo strtoupper(get_cus_Name($cloud['cus_id']));?></td></tr>
<tr><td>Pchs. Type</td><td style="font-size:14px;"><?php echo strtoupper(get_cus_type($cloud['type']));?></td></tr>

<tr><td colspan="2"><b>ADDRESS/COMPANY</b>
<br> <?php echo strtoupper(organization($_GET['no']));    ?></td></tr>

<tr><td>BILLER</td> <td><?php echo strtoupper(get_staff_name($cloud['onboarded'])); ?>
</td></tr>
<tr><td colspan="2">ITEM(S) SUPPLIED  OKAY.</td></tr>


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


    <style type="text/css">
        a{color: black;text-decoration: none;}
    </style>

<button id="btnPrint" class="hidden-print" ><a href="index">Back</a></button>
<button id="btnPrint" class="hidden-print"><a href="brown?no=<?php echo $_GET['no'];  ?>">Type 2</a></button>
        <!-- <script src="script.js"></script> -->
    </body>
    <script type="text/javascript">

// function loader(){
// window.onload =  window.print();
// window.close();
// }
    </script>
</html>