<?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">Estimate/Quotation</h3>
                                    </div>
                                     <div class="col-md-2"><a href="add-estimate.php"> <button class="btn btn-success btn-md">Add Return</button> </a>
                                    </div>                                    
                                </div>
                                <div class="portlet-body row">
                                  <div class="col-md-3 mt-2">
                                    <label>All Party</label>
                                     <select class="form-control" name="customer_id">
                                        <option value="">Select Party Name</option>
                                        <option value="">All Party</option>
                                        <?php $sqlct=mysqli_query($conn,"select * from ah_party");
                                        while($resct= mysqli_fetch_array($sqlct)){ ?>
                                        <option value="<?= $resct['id'];?>"><?= $resct['party_name'];?></option>
                                        <?php } ?>
                                    </select>
                                 </div>  
                                     <!-- <div class="col-md-3 mt-2">
                                    <label>Status</label>
                                    <select class="form-control">
                                        <option value="">Select Status</option>
                                        <option value="">All Estimate</option>
                                        <option value="">Open Estimate</option>
                                        <option value="">Close Estimate</option>
                                     </select>
                                </div> -->   
                                <div class="col-md-2 mt-2"> 
                                     <input type="submit" name="search" value="Find" class="btn btn-success btn-lg" style="margin-top:30px;">
                                </div>
                                   </div>
                                   <hr/>
                                   
                                <div class="portlet-body mt-3">
                                     <table id="datatable-1" class="table table-bordered table-striped table-hover">
                                        <thead>
                                            <tr>
                                                <th>#</th>
                                                <th>Party Name</th>
                                                <th>Date</th> 
                                                <th>Ref. No.</th> 
                                                 <th style="text-center">Total</th>
                                                 <th style="text-center">Invoice</th>
                                                 <th>
                                                    <center>Action</center>
                                                </th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        <?php $i=1;
                                        if(isset($_POST['search'])){
                                        $customer_id=$_POST['customer_id'];      
                                        $sqlsl=mysqli_query($conn,"select * from ah_estimate_details where customer_id='".$customer_id."'"); }else{
                                        $sqlsl=mysqli_query($conn,"select * from ah_estimate_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><?= $restpy['party_name'];?></td>
                                                <td><?= $resl['invoice_date'];?></td>
                                                <td><?= $resl['ref_no'];?></td>
                                                <td>₹ <?= $resl['total_amt'];?></td>
                                                 <td>
                                                    <center> <a href="invoice-estimate-detail.php?id=<?= $resl['id']; ?>"><button class="btn btn-success"> <i class="far fa-eye"></i></button></a></center>
                                                 </td>
                                                 <td> <center>      
                                                       <a href="edit-estimate.php?id=<?php echo $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="modaledit" data-bs-backdrop="static">
                <div class="modal-dialog dialog-lg">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title">Edit Payment-In Details</h5><button type="button" class="btn btn-label-danger btn-icon" data-bs-dismiss="modal"><i class="fa fa-times"></i></button>
                        </div>
                        <form class="g-3" action="#">
                            <div class="row modal-body">
                                <div class="mb-3 col-md-6">
                                <label class="form-label">Receipt No.</label>
                                <input type="text" placeholder="Enter Receipt No."  class="form-control">
                            </div>
                         <div class="mb-3 col-md-6">
                                <label class="form-label">Date</label>
                                <input type="date" placeholder="Choose Date"  class="form-control">
                            </div>
                            <div class="mb-3 col-md-6">
                                <label class="form-label">Customer Name</label>
                                 <select class="form-control">
                                    <option value="">Select Customer Name</option>
                                    <option value="">Customer1</option>
                                    <option value="">Customer2</option>
                                 </select>
                            </div>
                            <div class="mb-3 col-md-6">
                                <label class="form-label">Phone No.</label>
                                <input type="tel" placeholder="Enter Phone No."  class="form-control">
                            </div>
                            <div class="mb-3 col-md-6">
                                <label class="form-label">Recieved Amount(Rs.)</label>
                                <input type="text" placeholder="Enter Amount"  class="form-control" >
                            </div>
                            <div class="mb-3 col-md-6">
                                <label class="form-label">Total Amount(Rs.)</label>
                                <input type="text" value=""  class="form-control">
                            </div>
                            <div class="mb-3 col-md-12">
                                <label class="form-label">Description</label>
                                <textarea type="text" placeholder="Description" class="form-control" rows="2"></textarea>
                            </div>
                            <div class="mb-3 col-md-6">
                                <label class="form-label">Payment Type</label>
                                <select class="form-control">
                                    <option value="">Select Type</option>
                                    <option value="">Cash</option>
                                    <option value="">Cheque No.</option>
                                    <option value="">Bank A/c</option>
                                </select>
                            </div>     
                            <div class="mb-3 col-md-6">
                                <label class="form-label">Cheque No.</label>
                                <input type="text" placeholder="Enter Cheque No."  class="form-control">
                            </div>
                            <!-- <div class="mb-3 col-md-6">
                                <label class="form-label">Bank Name</label>
                                <input type="text" placeholder=""  class="form-control">
                            </div>
                            <div class="mb-3 col-md-6">
                                <label class="form-label">Transaction-Id No.</label>
                                <input type="text" placeholder="Enter Transaction No."  class="form-control">
                            </div> -->
                            <div class="mb-3 col-md-6">
                                <label class="form-label">Opening Balance</label>
                                <input type="text" placeholder=""  class="form-control">
                            </div> 
                            <div class="mb-3 col-md-6">
                                <label class="form-label"> As On</label>
                                <input type="date" value="None"   class="form-control">
                            </div> 

                            <div class="mb-3 col-md-6">
                                <label class="form-label">Images</label>
                                <input type="file" placeholder=""   class="form-control">
                            </div>  
                            </div>
                            <div class="modal-footer"><button class="btn btn-primary">Update</button></div>
                        </form>
                    </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 Payment-In 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-responsive">
                             <table class="table table-bordered">
                                <thead></thead>
                                <tbody>
                                    <tr>
                                        <td><strong>Receipt 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>Recieved Amount(Rs.):</strong></td>
                                        <td>Rs.</td> 
                                        <td><strong>Total Amount(Rs.):</strong></td>
                                        <td>Rs.</td>
                                    </tr>
                                    <tr>
                                        <td><strong>Description:</strong></td>
                                        <td colspan="3"> </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>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_estimate.php?id=' + id;
        }
    }   
</script>    
</body>

</html>