<?php
$log_id=$this->uri->segment('3');
$student_courses_data_table='student_courses_data';
$courses_table='courses';

$get_log_info=$this->SchoolModel->get_item_data($log_id,$student_courses_data_table);
if($get_log_info){
    foreach($get_log_info as $log_info){
        $sid=$log_info['sid'];
        $active_acedemic_session=$log_info['acedemic_session'];
        $active_course_id=$log_info['course_id'];
        
        $acedemic_session_table='academic_session_details';
        $all_acedemic_years=$this->SchoolModel->get_data($acedemic_session_table);




        $table='student';
        $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">Scholor Register</li>
                <li class="breadcrumb-item"><?php echo $data['student_name'];?></li>
            </ul>
            
            <div class="profile-div text-center">
                <img src="<?php echo base_url();?>assets/student-profile-pic.jpg" style="border-radius:50%;">
            </div>
            <div class="table-responsive">
                <table class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th colspan="2" class="text-center">Personal Information</th>
                        </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>
                    </thead>
                </table>
            </div>
            <div class="">
                <h3>Update Scholor Register</h3>
                <form method="post" action="#">
                    <?php 
                    if($success){
                    ?>
                    <div class="alert alert-success"><?php echo $success;?></div>
                    <?php 
                    }
                    if($error){
                    ?>
                    <div class="alert alert-danger"><?php echo $error;?></div>
                    <?php
                    }
                    ?>
                    <input type="hidden" name="sid" value="<?php echo $sid;?>">
                    <input type="hidden" name="log_id" value="<?php echo $log_id;?>">
                    <div class="form-group">
                        <label>Class</label>
                        <select class="form-control" name="course_id">
                            <?php
                            
                            $get_all_courses=$this->SchoolModel->get_data($courses_table);
                            if($get_all_courses){
                                foreach($get_all_courses as $course_info){
                            ?>
                            <option value="<?php echo $course_info['id'];?>" <?php if($active_course_id == $course_info['id']){echo "selected";}?>><?php echo $course_info['course']; echo " "; echo $course_info['subject_stream'];?></option>
                            <?php
                                }
                            }
                            ?>
                            
                            
                        </select>
                    </div>
                    
                    
                    <div class="form-group">
                        <label>Date of admission</label>
                        <input type="date" name="date_of_admission" class="form-control" value="<?php if($log_info['date_of_admission']){echo $log_info['date_of_admission']; } ?>">
                    </div>
                    <div class="form-group">
                        <label>Date of promotion</label>
                        <input type="date" name="date_of_promotion" class="form-control" value="<?php if($log_info['date_of_promotion']){echo $log_info['date_of_promotion']; } ?>">
                    </div>
                    <div class="form-group">
                        <label>Date of removal</label>
                        <input type="date" name="date_of_removal" class="form-control" value="<?php if($log_info['date_of_removal']){echo $log_info['date_of_removal']; } ?>">
                    </div>
                    <div class="form-group">
                        <label>Cause of removal</label>
                        <input type="text" name="cause_of_removal" class="form-control" placeholder="Cause of removal" value="<?php if($log_info['cause_of_removal']){echo $log_info['cause_of_removal']; } ?>">
                    </div>
                    <div class="form-group">
                        <label>Acedemic Year</label>
                        <select class="form-control" name="acedemic_year" readonly>
                            <?php 
                            if($all_acedemic_years){
                                foreach($all_acedemic_years as $acedemic_year_data){
                                    if($active_acedemic_session == $acedemic_year_data['id']){
                            ?>
                            <option value="<?php echo $acedemic_year_data['id'];?>"><?php echo $acedemic_year_data['year_long'];?></option>
                            <?php
                                    }
                                }
                            }
                            ?>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>Conduct & Work</label>
                        <input type="text" name="conduct_and_work" class="form-control" placeholder="Conduct & Work" value="<?php if($log_info['conduct_and_work']){echo $log_info['conduct_and_work']; } ?>">
                    </div>
                    
                    <div class="form-group">
                        <button type="submit" name="update_scholor_register" class="btn btn-sm btn-success">Submit</button>
                    </div>
                    
                </form>
            </div>
            
            
        </div>
    </div>
</div>

<?php
            }
        }       
    }
}
?>