<?php  ob_start(); session_start(); 
include 'dbconn.php';
include 'inc/functions.php';
include 'xyz.php';
// if(!isset($_SESSION['receipt_id'])){  header('location:index.php'); die(); 
//  }
// error_reporting(0);

$beginTransaction =QueryDB("SELECT * FROM  partners where receipt_id ='".$_GET['no']."'  "); 
$feedback =$beginTransaction->fetch(PDO::FETCH_ASSOC);
$app = getAppBranchSource($feedback['branchcode']);



 ?>

<!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;
    text-align: center;
}

}
td,
th,
tr,
table {
    border-top: 2px solid black !important;
    border-collapse: collapse;
    text-align: center;
}

/*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;
}

        </style>
    </head>
    <body onload="loader()">
        <div style="width:600px;margin:auto;">
           
<table style="border:none">
    <tr><td><img src="<?php echo str_replace('../','',$app['logo']);  ?>" alt="Logo" style='height:80px;width:80px;'></td><td width="100%">
        <div style="line-height: 15px;">
<h1 style="font-size:20px;"><?php echo strtoupper(get_branch_name($feedback['branchcode']));  ?></h1>
            <p class="centered" style=""><br><?php echo strtoupper($app['address']);  ?><br><?php echo strtoupper($app['phone']);  ?><br><b>RECEIPT NO:<?php echo $_GET['no'];?></b></p>
        </div>
</td></tr>

</table>



<?php $zumba= QueryDB("SELECT * FROM  partners where receipt_id ='".$_GET['no']."'  "); $cloud =$zumba->fetch(PDO::FETCH_ASSOC);
?>

<table width="100%" border="2" style="line-height: 30px;"><tr>
<th  style="text-align: center;font-size:15px">ITEM</th>
<th  style="text-align: center;font-size:15px">QTY</th>
<th style="text-align: center;font-size:15px;">COST</th>
<th style="text-align: center;font-size:15px">TOTAL</th>
</tr>
<?php $addTotal = 0; for($p=0;$p<count(explode(',',$cloud['item']));$p++){
    $vProd = getProduct(explode(',',$cloud['item'])[$p]);
echo '<tr><td style="">'.$sized_by[$vProd['size']].'-'.getProductName(explode(',',$cloud['item'])[$p]).','.$colored_by[$vProd['color']].'</td><td>'.(explode(',',$cloud['qty'])[$p]).'</td><td>'.number_format(explode(',',$cloud['s_price'])[$p],2).'</td><td>'.number_format(explode(',',$cloud['bulk_price'])[$p],2).'</td></tr>';
$addTotal+=(explode(',',$cloud['bulk_price'])[$p]);
}



echo '<tr><th>TOTAL COST</th><th colspan="3" style="font-size:18px;">&#8358;'.number_format($addTotal,2).'<br/><span style="font-size:12px;">'.strtoupper(remAND(convertNumberToWord($addTotal))).' NAIRA</span></th></tr>';
?></table>
<table width="100%" border="2" style="line-height: 25px;">
<?php foreach(QueryDB("SELECT * FROM  partners where receipt_id ='".$_GET['no']."' ")as $level2){
 echo '<tr><td>DEBT</td><td colspan="2" style="text-align: right;font-size:16px;">&#8358;'.number_format($level2['amt'],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><i>Through</i></td><td style="font-size:14px;">PARTNERS & ASSOCIATES &nbsp;&nbsp;
    <span>&raquo;STATUS:</span>
<strong><?php  echo stateMsg($cloud['status']); ?>&nbsp;(<?php echo $cloud['status_date']; ?>)</strong></td>
</tr>

<tr><td colspan="2"><b>PARTNER SIGN</b>
<br> <br>
_________________________________
</td></tr>

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


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


    <style type="text/css">
        a{color: black;text-decoration: none;}
    </style>
<center>
<button id="btnPrint" class="hidden-print" ><a href="<?php echo $_SERVER['HTTP_REFERER']; ?>">Back</a></button>
</center>
        <!-- <script src="script.js"></script> -->
    </body>
    <script type="text/javascript">

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