<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">Opening Fee</li>
                <li class="breadcrumb-item"><a href="<?php echo base_url();?>OpeningFee/all_invoices">Opening Fee Invoice</a></li>
                <li class="breadcrumb-item">Opening Fee Deleted Invoices</li>
            </ul>
            
            <div class="table-responsive">
                <table class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Student Name</th>
                            <th>Father's Name</th>
                            <th>Contact No.</th>
                            <th>Est. Fee</th>
                            <th>Discount</th>
                            <th>Received</th>
                            <th>Bal. Fee</th>
                            <th>Fee Note</th>
                            <th>Date</th>
                            <th>Invoice</th>
                            <th>Del At</th>
                            <th>Del By</th>
                            <?php 
                            if($this->session->userdata('all_permission') ==1){
                            ?>
                                <th>Undo</th>    
                            <?php
                            }
                            ?>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $del_fee_table='opening_balance_fee_deleted';
                        $get_deleted_opening_fee_invoices=$this->OpeningBalanceModel->get_data($del_fee_table);
                        if($get_deleted_opening_fee_invoices){
                            foreach($get_deleted_opening_fee_invoices as $data){
                        ?>
                        <tr>
                            <?php
                                $sid=$data['sid'];
                                $student_table='student';
                                $get_student_info=$this->WelcomeModel->get_item_data($sid,$student_table);
                                if($get_student_info){
                                    foreach($get_student_info as $info){
                                        
                                        ?>
                                        <td><?php echo $data['id'];?></td>
                                        <td><?php echo $info['student_name'];?></td>
                                        <td><?php echo $info['father_name'];?></td>
                                        <td><?php echo $info['contact_no'];?></td>
                                <?php
                                    }
                                }
                                ?>
                            <td><?php echo $data['estimate_amount']?></td>
                                        <td><?php echo $data['discount']?></td>
                                        <td><?php echo $data['received_amount']?></td>
                                        <td><?php echo $data['balance_amount'];?></td>
                                        <td></td>
                                        <td><?php echo date('d-M-Y',strtotime($data['fee_date']));?></td>
                                        <td class="text-center">
                                            <a href="<?php echo base_url();?>OpeningFee/invoice/<?php echo $data['id']; ?>">
                                                <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-eye-fill text-danger" viewBox="0 0 16 16">
                                                    <path d="M10.5 8a2.5 2.5 0 1 1-5 0 2.5 2.5 0 0 1 5 0z"/>
                                                    <path d="M0 8s3-5.5 8-5.5S16 8 16 8s-3 5.5-8 5.5S0 8 0 8zm8 3.5a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7z"/>
                                                </svg>
                                            </a>
                                        </td>
                                        <td></td>
                            <td></td>
                                        <?php 
                                        if($this->session->userdata('all_permission') ==1){
                                        ?>
                                        <td><button class="text-danger btn btn-sm" id="item_to_trash" item_id="<?php echo $data['inv_no'];?>"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-reply-fill" viewBox="0 0 16 16">
  <path d="M5.921 11.9 1.353 8.62a.719.719 0 0 1 0-1.238L5.921 4.1A.716.716 0 0 1 7 4.719V6c1.5 0 6 0 7 8-2.5-4.5-7-4-7-4v1.281c0 .56-.606.898-1.079.62z"/>
</svg></button></td>
                                
                                        <?php
                                        }
                                        ?>
                            
                           
                        </tr>
                        <?php
                        
                            }
                        }
                        
                        ?>
                    </tbody>
                </table>
            </div>
            
        </div>
    </div>
</div>

<script>
    $(document).ready(function(){
    
    
        $(document).on("click","#item_to_trash",function(){
            
        
            var item_id = $(this).attr("item_id");
            
            $.ajax({
                url: '<?php echo base_url(); ?>OpeningFee/undo_deleted_invoice',
                type: 'POST',
                data: {item_id:item_id},
                success: function(data){
                    
                    alert(data);
                    
                }
            });
        
        
    });
    });
</script>