<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">Home</li>
                <li class="breadcrumb-item">Transport</li>
                <li class="breadcrumb-item">Students</li>
                <li class="breadcrumb-item">Add New Student</li>
            </ul>
        </div>
        <?php
        
        ?>
        <div class="col-sm-12">
            <div class="table-responsive">
                <table class="table table-bordered table-striped" id="mytable">
                    <thead>
                        <tr>
                            <th>#</th>
                            <th>Student's Name</th>
                            <th>Father's Name</th>
                            <th>Mob. No.</th>
                            <th>Course</th>
                            <th>Allot Transport</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php 
                        $active_acedemic_session='';
                        $aceemic_session_table='academic_session_details';
                        $get_active_acedemic_session=$this->TransportModel->get_data($aceemic_session_table);
                        if($get_active_acedemic_session){
                            foreach($get_active_acedemic_session as $acedemic_sesion_data){
                                if($acedemic_sesion_data['status'] ==1){
                                    $active_acedemic_session=$acedemic_sesion_data['id'];
                                }        
                            }
                        }
                        
                        $count=0;
                        $get_current_session_students=$this->TransportModel->get_student_courses_data($active_acedemic_session);
                        if($get_current_session_students){
                            foreach($get_current_session_students as $students){
                                $sid=$students['sid'];
                                $course_id=$students['course_id'];
                                $student_table='student';
                                $subject_stream='';
                                $course='';
                                $courses_table='courses';
                                $get_course_info=$this->TransportModel->get_item_data($course_id,$courses_table);
                                foreach($get_course_info as $course_info){
                                    $course=$course_info['course'];
                                    $subject_stream=$course_info['subject_stream'];
                                }
                                        
                                $check_student_data=$this->TransportModel->get_item_data($sid,$student_table);
                                if($check_student_data){
                                    foreach($check_student_data as $student_data){
                                        $count=$count + 1;
                        ?>
                        <tr>
                            <td><?php echo $count;?></td>
                            <td><?php echo $student_data['student_name'];?></td>
                            <td><?php echo $student_data['father_name'];?></td>
                            <td><?php echo $student_data['contact_no'];?></td>
                            <td><?php echo $course; echo "  "; echo $subject_stream;  echo " ".$students['section']; ?></td>
                            <td>
                                <?php
                                $check_student_exist=$this->TransportModel->get_student_info_for_ac_sesssion($sid,$active_acedemic_session);
                                if($check_student_exist){
                                    foreach($check_student_exist as $student_exist){
                                ?>
                                <button class="btn btn-sm btn-success"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-check-all" viewBox="0 0 16 16"><path d="M8.97 4.97a.75.75 0 0 1 1.07 1.05l-3.99 4.99a.75.75 0 0 1-1.08.02L2.324 8.384a.75.75 0 1 1 1.06-1.06l2.094 2.093L8.95 4.992a.252.252 0 0 1 .02-.022zm-.92 5.14.92.92a.75.75 0 0 0 1.079-.02l3.992-4.99a.75.75 0 1 0-1.091-1.028L9.477 9.417l-.485-.486-.943 1.179z"/></svg></button>
                                <?php
                                    }
                                }else{
                                ?>
                                <a href="<?php echo base_url();?>transport/add_student/<?php echo $sid;?>" class="btn btn-sm btn-info">
                                    <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-plus-circle-fill" viewBox="0 0 16 16">
                                        <path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0zM8.5 4.5a.5.5 0 0 0-1 0v3h-3a.5.5 0 0 0 0 1h3v3a.5.5 0 0 0 1 0v-3h3a.5.5 0 0 0 0-1h-3v-3z"/>
                                    </svg>
                                </a>
                                <?php
                                }
                                ?>
                                
                                
                            </td>
                        </tr>                        
                        
                        <?php
                                    }
                                }
                            }
                        }
                        ?>
                    
                    
                    <!--<tr></tr>-->
                    </tbody>
                </table>
            </div>
        </div>
        
        <div class="col-sm-12">
            <?php $this->load->view('erp/transport/quick-links');?>
        </div>
        
    </div>
</div>