<?php
ob_start();
session_start();
include "config/config.php";

$ids = $_GET['id'];
$statement = $pdo->prepare("SELECT * FROM tbl_sales e where e.id=?");
$statement->execute(array($ids));
$datas = $statement->fetchAll(PDO::FETCH_ASSOC);
$totalData = $statement->rowCount();
if($totalData>0){
    
    $invoice_no = $datas[0]['invoice_no'];
    $invoice_date = date('d-m-Y', strtotime($datas[0]['date']));
    
$statement_items = $pdo->prepare("SELECT * FROM tbl_sale_items e where e.sale_id=?");
$statement_items->execute(array($ids));
$items_datas = $statement_items->fetchAll(PDO::FETCH_ASSOC);
$items_totalData = $statement_items->rowCount();

?>

<center>Pro-Forma Invoice</center>

<hr>

<table style="width: 100%;">
    <thead>
        <tr>
            <th style="width: 50%;">Transaction Id:</th>
            <td style="width: 50%;"><?=$invoice_no?></th>
        </tr>
        <tr>
            <th style="width: 50%;">Transaction Date:</th>
            <td style="width: 50%;"><?=$invoice_date?></th>
        </tr>
        <tr>
            <th style="width: 50%;">Customer Account:</th>
            <td style="width: 50%;"><?=$invoice_no?></th>
        </tr>
        <tr>
            <th style="width: 50%;">Customer Name:</th>
            <td style="width: 50%;"><?=$invoice_no?></th>
        </tr>
        <tr>
            <th style="width: 50%;">Customer Mobile:</th>
            <td style="width: 50%;"><?=$invoice_no?></th>
        </tr>
        <tr>
            <th style="width: 50%;">Gold Rate:</th>
            <td style="width: 50%;"><?=$invoice_no?></th>
        </tr><tr>
            <th style="width: 50%;">Platinum Rate:</th>
            <td style="width: 50%;"></th>
        </tr>
    </thead>
</table>

<hr>

<table style="width: 100%;">
    <thead>
        <tr>
            <th>
                Desc.
            </th>
            
            <th>
                Qty<br>
                (Nos)
            </th>
            
            <th>
                G.Wt.<br>
                (Grm)
            </th>
            
            <th>
                N.Wt.<br>
                (Grm)
            </th>
            
            <th>
                Rate<br>
                (Grm)
            </th>
            
            <th>
                VA
            </th>
            
            <th>
                Amount
            </th>
        </tr>
    </thead>
    <tbody>
<?php if($items_totalData>0){ 
    $i=1;
    foreach($items_datas as $items){ ?>
    
    
        <tr>
            <td style="text-align: center;"><?=$items['product_name']?></td>
            <td style="text-align: center;"><?=$items['quantity']?></td>
            <td style="text-align: center;"><?=$items['cross_weight']?></td>
            <td style="text-align: center;"><?=$items['hsn_code']?></td>
            
            
            <td style="text-align: center;"><?=number_format($items['selling_price'],2)?></td>
            <td style="text-align: center;"><?=number_format($items['selling_price'],2)?></td>
            <td style="text-align: center;"><?=number_format($items['selling_price'],2)?></td>
        </tr>
        
        
<?php }}else{ ?>
        <tr>
            <td colspan="7"><b style="color: red;">No Products Found</b></td>
        </tr>
<?php } ?>
    </tbody>
</table>




<?php } ?>