<?php include("includes/db_config.php"); ?>
<!DOCTYPE html>
<html lang="en" dir="ltr" data-theme="light">
<meta http-equiv="content-type" content="text/html;charset=utf-8" />

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <?php include("includes/css.php");?>
    <style>
        .modal-body .form-label{font-weight:600;}.viewptdt .form-label{font-weight:600;}.viewptdt label{margin-top:10px;}
    </style>
</head>

<body class="preload-active aside-active aside-mobile-minimized aside-desktop-maximized">
    <div class="holder">
        <?php include("includes/sidebar.php");?>
        <div class="wrapper">

            <?php include("includes/header.php");?>
            <div class="content">
                <div class="container-fluid g-5">                    
                    <div class="row">
                        <div class="col-12">
                            <div class="portlet">
                                <div class="portlet-header portlet-header-bordered">
                                     <div class="col-md-9">
                                        <h3 class="portlet-title">All Balance Details</h3>
                                    </div>
                                    <!-- <div class="col-md-3">
                                        <center><a href="add-sale-detail.php"><button class="btn btn-success btn-md"><i class="fa fa-plus"></i> Add Balance Details</button></a></center>
                                    </div> -->
                                 </div>
                                <div class="portlet-body table-responsive">
                                    <table id="datatable-1" class="table table-bordered table-striped table-hover">
                                        <thead>
                                            <tr>
                                                <th>#</th>
                                                <th>Type</th>
                                                
                                                <th>
                                                    <center>Action</center>
                                                </th>
                                            </tr>
                                        </thead>
                                        <tbody> 
                                            <?php $i=1; $id=$_GET['id'];
                                            $sql="select * from tbl_ah_items where id='".$id."' order by id DESC"; 
                                            while($res= mysqli_fetch_array($result)){
                                            $sql_query = mysqli_query($conn,"SELECT * FROM ah_item_tracking_details WHERE item_id = '".$id."'");
                                              $row = mysqli_fetch_array($sql_query);
                                              $stocksql="select * from stock_transactions where item_id='".$id."' and
                                              item_tracking_id = '".$row['id']."'  order by id DESC"; 
                                            $results = mysqli_query($conn, $stocksql); 
                                            while($res1= mysqli_fetch_array($results)){ ?>
                                            <tr>
                                                <td><?= $i;?></td>
                                                <td><?= $res1['type'];?></td>
                                                <td><?= $res1['bill_no'];?></td>
                                                <td><?= $res1['bill_date'];?></td>
                                                <td><?= $res1tpy['party_name'];?></td>
                                                <td><?= $res1['received_amount'];?></td>
                                                <td><?= $res1['balance'];?></td>
                                                <td><?= $res1['total_amt'];?></td>
                                                <td>
                                                    <center>
                                                         <a href="manage-stocks.php?id=<?= $res['id']; ?>"><button class="btn btn-success"> <i class="far fa-print"></i></button></a>
                                                    </center>
                                                </td>
                                            </tr>
                                            <?php $i++; } ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
          
       
            <?php include("includes/footer.php");?>
        </div>
    </div>
    <?php include("includes/js.php");?>
    <script type="text/javascript">
      function delete_ptype_by_ID(id) {
        if (confirm('Do You Want to Deleting This \nContinue anyway?')) {
            window.location.href = 'delete_sales.php?id=' + id;
        }
    }
    </script>
</body>

</html>