<?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 Expences List</h3>
                                    </div>
                                    <div class="col-md-3">
                                        <center><a href="add-expences.php"><button class="btn btn-success btn-md"><i class="fa fa-plus"></i> Add New Expences 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>Expences No.</th>
                                                <th>Expences</th>
                                                <th>Date</th>
                                                 <th style="text-center">Total</th>
                                                <th>
                                                    <center>Action</center>
                                                </th>
                                            </tr>
                                        </thead>
                                        <tbody> 
                                            <?php $i=1; 
                                            $sql="select * from ah_expences order by id DESC"; 
                                            $result = mysqli_query($conn, $sql); 
                                            while($res= mysqli_fetch_array($result)){
                                            $cid=$res['exp_cat_id'];
                                            $sqlpt=mysqli_query($conn,"SELECT * from expenses_category where id='".$cid."'");
                                            $restpy=mysqli_fetch_array($sqlpt);
                                            ?>
                                            <tr>
                                                <td><?= $i;?></td>
                                                <td><?= $res['exp_no'];?></td>
                                                <td><?= $restpy['ename'];?></td>
                                                <td><?= $res['exp_date'];?></td>
                                                <td><?= $res['total_amt'];?></td>
                                                <td>
                                                    <center>
                                                        <a href="edit-expences-detail.php?id=<?= $res['id']; ?>"><button class="btn btn-primary"> <i class="far fa-edit"></i></button></a>
                                                        <a href="javascript:delete_ptype_by_ID('<?php echo $res['id'] ?>');" class="btn btn-danger shadow btn-xs sharp"><i class="fa fa-trash"></i></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_expences.php?id=' + id;
        }
    }
    </script>
</body>

</html>