<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();?>Fee/all_students">Fee</a></li>
                <li class="breadcrumb-item"><a href="<?php echo base_url();?>Fee/invoices">Invoices</a></li>
                <li class="breadcrumb-item">Deleted Fee Invoices</li>
            </ul>
            
            <div class="table-responsive">
                <table class="table table-bordered table-striped">
                    
                    <thead>
                        <tr>
                            <th>Fee No</th>
                            <tH>Sid</tH>
                            <th>Name</th>
                            <th>Father's Name</th>
                            <th>Course</th>
                            <th>Inv.</th>
                            <th>Undo</th>
                        </tr>
                    </thead>
                    <tbody>
                        
                        <?php
                        $del_table='student_fee_deleted';
                        $get_all_deleted_invoices=$this->NewFeeModel->get_data($del_table);
                        if($get_all_deleted_invoices){
                            foreach($get_all_deleted_invoices as $deleted_invoices){
                                $sid=$deleted_invoices['sid'];
                                $student_table='student';
                                $get_student_info=$this->NewFeeModel->get_item_data($sid,$student_table);
                                $course_id=$deleted_invoices['course_id'];
                                $courses_table='courses';
                                $get_course_info=$this->NewFeeModel->get_item_data($course_id,$courses_table);
                        ?>
                        <tr>
                            <td><?php echo $deleted_invoices['fee_no']; ?></td>
                            <td><?php echo $deleted_invoices['sid'];?></td>
                            <?php 
                            if($get_student_info){
                                foreach($get_student_info as $student_info){
                            ?>
                            <td><?php echo $student_info['student_name']; ?></td>
                            <td><?php echo $student_info['father_name']; ?></td>
                            <?php
                                }
                            }else{
                            ?>
                            <td>-</td>
                            <td>-</td>
                            <?php 
                            }
                            if($get_course_info){
                                foreach($get_course_info as $course_info){
                            ?>
                            <td><?php echo $course_info['course']; echo " "; echo $course_info['subject_stream'];?></td>
                            <?php
                                }
                            }else{
                            ?>
                            <td>-</td>    
                            <?php
                            }
                            ?>
                            
                            <td>
                                <a href="<?php echo base_url();?>Fee/invoice/<?php echo $deleted_invoices['fee_no']; ?>" style="text-decoration:none;" class="btn btn-sm btn-danger">
                                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-eye-fill" 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>
                                <button class="btn btn-sm btn-success" id="undo_btn" item_id="<?php echo $deleted_invoices['id'];?>">
                                    <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>
                        </tr>
                        <?php
                            }
                        }
                        
                        ?>

                    </tbody>
                </table>
            </div>
            
        </div>
    </div>
</div>

<script>
$(document).ready(function(){
    $(document).on("click","#undo_btn",function(){
        var item_id = $(this).attr("item_id");
        alert(item_id);
        
        $.ajax({
            url: '<?php echo base_url(); ?>Admin/active_inactive',
            type: 'POST',
            data: {id:id,val:val},
            success: function(data){
                location.reload();
            }
        });
    });
});
</script>