<div class="container-fluid mt-3 mb-3 bg-white">
    <div class="row">
        <div class="col-sm-12 pt-3 pb-3">
            <ul class="breadcrumb">
                <li class="breadcrumb-item"><a href="<?php echo base_url();?>Welcome">Home</a></li>
                <li class="breadcrumb-item"><a href="<?php echo base_url();?>Transport">Transport</a></li>
                <li class="breadcrumb-item">Fee</li>
                <li class="breadcrumb-item">Invoices</li>
            </ul>
            <div class="table-responsive">
                <table class="table table-bordered table-striped" id="mytable">
                    <thead>
                        <tr>
                            <th>Sl.No.</th>
                            <th>Inv. No.</th>
                            <th>Name</th>
                            <th>Father's Name</th>
                            <th>Fee Date</th>
                            <th>Est. Fee</th>
                            <th>Prev. Bal.</th>
                            <th>Prev. Extra</th>
                            <th>Discount</th>
                            <th>Received Fee</th>
                            <th>Bal. </th>
                            <th>Extra</th>
                            <th>Invoice</th>
                            <th>Edit</th>
                            <th>Delete</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $acedemic_session=$this->session->userdata("acedemic_session");
                        $invoices_data=$this->TransportModel->get_transport_invoices_comb_data($acedemic_session);
                        if($invoices_data){
                            foreach($invoices_data as $invoices){
                                $count=$count + 1;
                        ?>
                        <tr>
                            <td><?php echo $count;?></td>
                            <td><?php echo $invoices['id']; ?></td>
                            <td><?php echo $invoices['student_name']; ?></td>
                            <td><?php echo $invoices['father_name'];?></td>
                            <td><?php echo date('d-M-Y',strtotime($invoices['fee_date'])); ?></td>
                            <td><?php echo $invoices['esatimate_fee'];?></td>
                            <td><?php echo $invoices['prev_bal_added'];?></td>
                            <td><?php echo $invoices['extra_amount_used'];?></td>
                            <td><?php echo $invoices['discount'];?></td>
                            <td><?php echo $invoices['received_fee'];?></td>
                            <td><?php echo $invoices['balance_fee'];?></td>
                            <td><?php echo $invoices['extra_fee'];?></td>
                            <td>
                                <a href="<?php echo base_url();?>Transport/invoice/<?php echo $invoices['id'];?>" class="btn btn-sm btn-info" target="_blank">
                                <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-printer-fill" viewBox="0 0 16 16">
                                    <path d="M5 1a2 2 0 0 0-2 2v1h10V3a2 2 0 0 0-2-2H5zm6 8H5a1 1 0 0 0-1 1v3a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1z"/>
                                    <path d="M0 7a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2h-1v-2a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2H2a2 2 0 0 1-2-2V7zm2.5 1a.5.5 0 1 0 0-1 .5.5 0 0 0 0 1z"/>
                                </svg>
                                </a>
                            </td>
                            <td>
                                <a href="<?php echo base_url()."Transport/edit_fee/".$invoices['id']; ?>" class="btn btn-sm btn-outline-warning" target="_blank">Edit</a>
                            </td>
                            <td>
                                <button class="btn btn-outline-danger delete-transport-invoice" invoice_id="<?php echo $invoices['id'];?>" ><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-trash-fill" viewBox="0 0 16 16"><path d="M2.5 1a1 1 0 0 0-1 1v1a1 1 0 0 0 1 1H3v9a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2V4h.5a1 1 0 0 0 1-1V2a1 1 0 0 0-1-1H10a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1H2.5zm3 4a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 .5-.5zM8 5a.5.5 0 0 1 .5.5v7a.5.5 0 0 1-1 0v-7A.5.5 0 0 1 8 5zm3 .5v7a.5.5 0 0 1-1 0v-7a.5.5 0 0 1 1 0z"/></svg></button>
                            </td>
                        </tr>
                        <?php
                            }
                        }
                        ?>
                        
                    </tbody>
                </table>
            </div>
        </div>
        <div class="col-sm-12 pb-3 pt-3"><?php $this->load->view('erp/transport/quick-links');?></div>
        
    </div>
</div>

<script>
    $(document).ready(function(){
        $(document).on("click",".delete-transport-invoice",function(){
            var invoice_id=$(this).attr("invoice_id");
            alert(invoice_id);
            
            $.ajax({
                url: '<?php echo base_url(); ?>Transport/delete_invoice',
                type: 'POST',
                data: {invoice_id:invoice_id},
                success: function(response){
                    alert(response);
                    var success_data = JSON.parse(response);
                    var error=success_data.error;
                    alert(error);
                    if(error == false){
                        // var order_id=success_data.order_id;
                        var message=success_data.msg;
                        alert(message);
                        location.reload();
                        // $(".case-footer-btns").html(case_footer_data);
                        // $(".case-message-div").html("<p class='text-center text-success font-weight-bolder'>"+message+"</p>");
                    }else{
                        var message=success_data.msg;
                        alert(message);
                        location.reload();
                        // var case_footer_data='<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>';
                        // $(".case-footer-btns").html(case_footer_data);
                        // $(".case-message-div").html("<p class='text-center text-danger font-weight-bolder'>"+message+"</p>");
                    }
                },
                // error: function(jqXHR, textStatus, errorThrown) {
                //     console.log(textStatus, errorThrown);
                // }
            });
        });
    });
</script>