<?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 row">
                                     <div class="col-md-10">
                                        <h3 class="portlet-title">Delivery Challan</h3>
                                    </div>
                                     <div class="col-md-2"><a href="add-delivery-challan.php"> <button class="btn btn-success btn-md">Add Delivery Challan</button> </a>
                                    </div>                                    
                                </div>
                                 
                                <div class="portlet-body row">
                                <div class="col-md-3 mt-2">
                                    <label>Party Name</label>
                                    <select class="form-control">
                                        <option value="">Select Party Name</option>
                                        <option value="">All Party</option>
                                        <option value="">Party1</option>
                                        <option value="">Party2</option>
                                    </select>
                                </div>  
                                <div class="col-md-2 mt-2">
                                    <label>Status</label>
                                    <select class="form-control">
                                        <option value="">Select Status</option>
                                        <option value="">All </option>
                                        <option value="">Open Challan</option>
                                        <option value="">Closed Challan</option>
                                     </select>
                                </div>  
                                <div class="col-md-2 mt-2"> 
                                     <input type="button" value="Find" class="btn btn-success btn-lg" style="margin-top:30px;">
                                </div>
                                </div>
                                <div class="portlet-body mt-3 table-responsive">
                                     <table id="datatable-1" class="table table-bordered table-striped table-hover">
                                        <thead>
                                            <tr>
                                                <th>#</th>
                                                <th>Challan No</th>
                                                <th>Invoice Date</th>
                                                <th>Due Date</th>
                                                <th>Party Name</th>
                                                 <th style="text-center">Total</th>
                                                <th>
                                                    <center>Action</center>
                                                </th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php $i=1;
                                        $sqlsl=mysqli_query($conn,"select * from ah_sale_delivery_challan_details");
                                         while($resl= mysqli_fetch_array($sqlsl)){
                                         $cid=$resl['customer_id'];
                                         $sqlpt=mysqli_query($conn,"SELECT * from ah_party where id='".$cid."'");
                                         $restpy=mysqli_fetch_array($sqlpt); ?>
                                            <tr>
                                               <td><?php echo $i; $i++; ?>.</td>
                                                <td><?= $resl['challan_no'];?></td>
                                                <td><?= $resl['invoice_date'];?></td>
                                                <td><?= $resl['due_date'];?></td>
                                                <td><?= $restpy['party_name'];?></td>
                                                <td>₹ <?= $resl['total_amt'];?></td>
                                             <td>
                                                    <center> 
                                                       <a href="edit-delivery-challan.php?id=<?= $resl['id']; ?>"> <button class="btn btn-primary"> <i class="far fa-edit"></i></button></a>
                                                        <a href="javascript:delete_ptype_by_ID('<?php echo $resl['id'] ?>');" class="btn btn-danger shadow btn-xs sharp"><i class="fa fa-trash"></i></a>
                                                    </center>
                                                </td>
                                            </tr><?php } ?>
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
 
            <div class="modal fade" id="modalview" data-bs-backdrop="static">
                <div class="modal-dialog dialog-lg">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title">View Delivery Challan Details</h5><button type="button" class="btn btn-label-danger btn-icon" data-bs-dismiss="modal"><i class="fa fa-times"></i></button>
                        </div>

                        <div class="modal-body">
                             <table class="table table-bordered">
                                <thead></thead>
                                <tbody>
                                    <tr>
                                        <td><strong>Challan No.:</strong></td>
                                        <td>101</td> 
                                        <td><strong>Date:</strong></td>
                                        <td>20-09-2024</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Customer Name:</strong></td>
                                        <td></td> 
                                        <td><strong>Phone No.:</strong></td>
                                        <td></td>
                                    </tr> 
                                    <tr>
                                        <td><strong>Due Date:</strong></td>
                                        <td></td> 
                                        <td><strong>Iten Name:</strong></td>
                                        <td></td>
                                    </tr> 
                                    <tr>
                                        <td><strong>QTY:</strong></td>
                                        <td></td> 
                                        <td><strong>Unit:</strong></td>
                                        <td></td>
                                    </tr> 
                                    <tr>
                                        <td><strong>Rate(Price/Unit):</strong></td>
                                        <td></td> 
                                        <td><strong>Tax Type:</strong></td>
                                        <td></td>
                                    </tr> 
                                    <tr>
                                        <td><strong>Sub Total(Rs.):</strong></td>
                                        <td>Rs.</td> 
                                        <td><strong>Discount(Rs.):</strong></td>
                                        <td>Rs.</td>
                                    </tr> 
                                    <tr>
                                        <td><strong>Tax(Rs.):</strong></td>
                                        <td>Rs.</td> 
                                        <td><strong>Total Amount(Rs.):</strong></td>
                                        <td>Rs.</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Date:</strong></td>
                                        <td>Rs.</td> 
                                        <td><strong>Balance Due:</strong></td>
                                        <td>Rs.</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Payment Type:</strong></td>
                                        <td>Cash</td> 
                                        <td><strong>Cheque No.:</strong></td>
                                        <td></td>
                                    </tr>   <!--  
                                    <tr>
                                        <td><strong>Bank Name:</strong></td>
                                        <td> </td> 
                                        <td><strong>Transaction-Id No.:</strong></td>
                                        <td></td>
                                    </tr> -->    
                                    <tr>
                                        <td><strong>Opening Balance:</strong></td>
                                        <td> </td> 
                                        <td><strong>As On:</strong></td>
                                        <td></td>
                                    </tr>
                                    <tr>
                                        <td><strong>Description:</strong></td>
                                        <td colspan="3"> </td>  
                                    </tr>       
                                    <tr>
                                        <td><strong>Images:</strong></td>
                                        <td colspan="3">  <img src="" style="width:60px;">  <img src="" style="width:60px;"></td>
                                    </tr>  
                                </tbody>
                            </table>
                        </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_delivery_challan.php?id=' + id;
        }
    }   
</script>    
</body>

</html>