<?php 
$acedemic_session=$this->session->userdata('acedemic_session');
$acedemic_session_table='academic_session_details';
$acedemic_session_data=$this->SchoolModel->get_item_data($acedemic_session,$acedemic_session_table);

$sid=$this->uri->segment('3');



$student_course_data=$this->SchoolModel->student_course_data($sid,$acedemic_session);

$table='student';
$profile_pic='';
$student_data_table='student_data';
$get_student_profile_pic_data=$this->SchoolModel->get_student_data($sid,$student_data_table);
if($get_student_profile_pic_data){
    foreach($get_student_profile_pic_data as $student_profile_pic_data){
        $profile_pic=$student_profile_pic_data['profile_pic'];
    }
}else{
    
}
$student_information=$this->SchoolModel->get_item_data($sid,$table);
if($student_information){
    foreach($student_information as $data){
?>
<div class="container mt-3 mb-3 pt-3 pb-3 bg-white">
    <div class="row">
        <div class="col-sm-12">
            
            <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();?>School/view_all_students">Students</a></li>
                <li class="breadcrumb-item"><?php echo $data['student_name'];?></li>
            </ul>
            <div class="profile-div text-center pb-3">
                <?php
                if($profile_pic !=''){
                ?>
                <img src="<?php echo base_url();?>student-data/profile-img/<?php echo $profile_pic;?>" style="border-radius:50%;width:200px;">
                <?php
                }else{
                ?>
                <img src="<?php echo base_url();?>assets/student-profile-pic.jpg" style="border-radius:50%;">
                <?php
                }
                ?>
            </div>
            
            <div class="table-responsive">
                <table class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <?php
                            if($acedemic_session_data){
                                foreach($acedemic_session_data as $session_data){
                            ?>
                            <th colspan="2" class="text-center">Personal Information (<?php echo $session_data['year_long']; ?>)</th>
                            <?php
                                }
                            }
                            ?>
                            
                        </tr>
                        <tr>
                            <th>Name</th>
                            <td><?php echo $data['student_name'];?></td>
                        </tr>
                        <tr>
                            <th>Father's Name</th>
                            <td><?php echo $data['father_name'];?></td>
                        </tr>
                        <tr>
                            <th>D.O.B.</th>
                            <td><?php if($data['dob']){echo date('d-M-Y',strtotime($data['dob']));}else{ echo "----";}?></td>
                        </tr>
                        <tr>
                            <th>Contact No.:</th>
                            <td><?php echo $data['contact_no']; echo ","; echo $data['alternate_no'];?></td>
                        </tr>
                        <tr>
                            <th>Address : </th>
                            <td><?php echo $data['address'];?></td>
                        </tr>
                        <tr>
                            <th>Class : </th>
                            <?php 
                            $courses_table='courses';
                            if($student_course_data){
                                foreach($student_course_data as $course_data){
                                    $course_id=$course_data['course_id'];
                                    $get_course_info=$this->SchoolModel->get_item_data($course_id,$courses_table);
                                    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
                            }
                            ?>
                        </tr>
                    </thead>
                </table>
            </div>
            
        </div>
    </div>
</div>

<?php
    }   
}
?>