<div class="row">
    <div class="col-md-12 col-sm-12 col-xs-12">
        <div class="x_panel">
            <div class="x_title">
                <h3 class="head-title"><i class="fa fa-mail-forward"></i><small> Manage Sickbay</small></h3>
                <ul class="nav navbar-right panel_toolbox">
                    <li><a class="collapse-link"><i class="fa fa-chevron-up"></i></a></li>
                </ul>
                <div class="clearfix"></div>
            </div>

            <div class="x_content quick-link">
                <?php $this->load->view('quick-link'); ?>
            </div>
            <div class="x_content">
                <div class="" data-example-id="togglable-tabs">

                    <ul class="nav nav-tabs bordered">

                        <?php if (isset($detail)) { ?>


                            <li class="active"><a href="<?php echo site_url('academic/sickbay/index'); ?>" role="tab" data-toggle="tab" aria-expanded="true"><i class="fa fa-list-ol"></i> <?php echo $this->lang->line('list'); ?></a> </li>

                            <?php if (has_permission(ADD, 'student', 'student')) { ?>
                                <li class="<?php if (isset($add)) {
                                                echo 'active';
                                            } ?>"><a href="<?php echo site_url('academic/sickbay/add'); ?>" aria-expanded="false"><i class="fa fa-plus-square-o"></i> <?php echo $this->lang->line('add'); ?></a> </li>
                            <?php } ?>

                            <li class="active"><a href="#tab_view_student" role="tab" data-toggle="tab" aria-expanded="false"><i class="fa fa-pencil-square-o"></i> <?php echo $this->lang->line('view'); ?></a> </li>


                        <?php } else { ?>
                            <li class="active"><a href="#tab_sickbay_list" role="tab" data-toggle="tab" aria-expanded="true"><i class="fa fa-list-ol"></i> <?php echo $this->lang->line('list'); ?></a> </li>
                            <?php if (has_permission(ADD, 'student', 'student')) { ?>
                                <?php if (isset($edit)) { ?>
                                    <li class="<?php if (isset($add)) {
                                                    echo 'active';
                                                } ?>"><a href="<?php echo site_url('academic/sickbay/add'); ?>" aria-expanded="false"><i class="fa fa-plus-square-o"></i> <?php echo $this->lang->line('add'); ?></a> </li>
                                <?php } else { ?>
                                    <li class="<?php if (isset($add)) {
                                                    echo 'active';
                                                } ?>"><a href="#tab_add_sickbay" role="tab" data-toggle="tab" aria-expanded="false"><i class="fa fa-plus-square-o"></i> <?php echo $this->lang->line('add'); ?></a> </li>
                                <?php } ?>
                            <?php } ?>

                            <?php if (isset($edit)) { ?>
                                <li class="active"><a href="#tab_edit_student" role="tab" data-toggle="tab" aria-expanded="false"><i class="fa fa-pencil-square-o"></i> <?php echo $this->lang->line('edit'); ?></a> </li>
                            <?php } ?>
                        <?php } ?>


                        <li class="li-class-list">
                            <?php if ($this->session->userdata('role_id') == SUPER_ADMIN) {  ?>

                                <select class="form-control col-md-7 col-xs-12" onchange="get_dept_by_school(this.value);">
                                    <option value="<?php echo site_url('sickbay/index'); ?>">--<?php echo $this->lang->line('select_school'); ?>--</option>
                                    <?php foreach ($schools as $obj) { ?>
                                        <option value="<?php echo site_url('sickbay/index/' . $obj->id); ?>" <?php if (isset($filter_school_id) && $filter_school_id == $obj->id) {
                                                                                                                                                                                        echo 'selected="selected"';
                                                                                                                                                                                    } ?>> <?php echo $obj->school_name; ?></option>
                                    <?php } ?>
                                </select>
                                <?php echo form_close(); ?>

                            <?php } else {  ?>
                                <select class="form-control col-md-7 col-xs-12" onchange="get_student_by_class(this.value);">
                                    <?php if ($this->session->userdata('role_id') != STUDENT) { ?>
                                        <option value="<?php echo site_url('student/index'); ?>">--<?php echo $this->lang->line('select'); ?>--</option>
                                    <?php } ?>
                                    <?php $teacher_student_data = get_teacher_access_data('student'); ?>
                                    <?php $guardian_class_data = get_guardian_access_data('class'); ?>
                                    <?php foreach ($classes as $obj) { ?>
                                        <?php if ($this->session->userdata('role_id') == STUDENT) { ?>
                                            <?php if ($obj->id != $this->session->userdata('class_id')) {
                                                continue;
                                            } ?>
                                            <option value="<?php echo site_url('student/index/' . $obj->id); ?>" <?php if (isset($class_id) && $class_id == $obj->id) {
                                                                                                                        echo 'selected="selected"';
                                                                                                                    } ?>><?php echo $obj->name; ?></option>
                                        <?php } elseif ($this->session->userdata('role_id') == GUARDIAN) { ?>
                                            <?php if (!in_array($obj->id, $guardian_class_data)) {
                                                continue;
                                            } ?>
                                            <option value="<?php echo site_url('student/index/' . $obj->id); ?>" <?php if (isset($class_id) && $class_id == $obj->id) {
                                                                                                                        echo 'selected="selected"';
                                                                                                                    } ?>><?php echo $obj->name; ?></option>
                                        <?php } elseif ($this->session->userdata('role_id') == TEACHER) { ?>
                                            <?php if (!in_array($obj->id, $teacher_student_data)) {
                                                continue;
                                            } ?>
                                            <option value="<?php echo site_url('student/index/' . $obj->id); ?>" <?php if (isset($class_id) && $class_id == $obj->id) {
                                                                                                                        echo 'selected="selected"';
                                                                                                                    } ?>><?php echo $obj->name; ?></option>
                                        <?php } else { ?>
                                            <option value="<?php echo site_url('student/index/' . $obj->id); ?>" <?php if (isset($class_id) && $class_id == $obj->id) {
                                                                                                                        echo 'selected="selected"';
                                                                                                                    } ?>><?php echo $obj->name; ?></option>
                                        <?php } ?>
                                    <?php } ?>
                                </select>
                            <?php } ?>
                        </li>
                    </ul>
                    <br />

                    <div class="tab-content">
                        <div class="tab-pane fade in active" id="tab_sickbay_list">
                            <div class="x_content">
                                <table id="datatable-responsive" class="table  table-bordered dt-responsive nowrap" cellspacing="0" width="100%">
                                    <thead>
                                        <tr>
                                            <th><?php echo $this->lang->line('sl_no'); ?></th>
                                            <th><?php echo $this->lang->line('date'); ?></th>
                                            <th><?php echo $this->lang->line('school_name'); ?></th>
                                            <!-- <th><?php echo $this->lang->line('student_id'); ?></th> -->
                                            <th><?php echo $this->lang->line('name'); ?></th>
                                            <th><?php echo $this->lang->line('class'); ?></th>
                                            <th><?php echo $this->lang->line('section'); ?></th>
                                            <th><?php echo $this->lang->line('roll_no'); ?></th>
                                            <th>Attendant</th>
                                            <th>Sickness</th>
                                            <th>Treatment</th>
                                            <th><?php echo $this->lang->line('status'); ?></th>
                                            <th>action</th> 
                                        </tr>
                                    </thead>
                                    <tbody>

                                        <?php foreach ($records as $obj) { ?>

                                            <tr>
                                                <td><?php echo $obj->id; ?></td>
                                                <td><?php echo $obj->date; ?></td>
                                                <td><?php echo ($obj->school_name); ?></td>
                                                <td><?php echo $obj->name; ?></td>
                                                <td><?php echo $obj->class_name; ?></td>
                                                <td><?php echo $obj->section; ?></td>
                                                <td><?php echo $obj->roll_no; ?></td>
                                                <td><?php echo $obj->attendant; ?></td>
                                                <td><?php echo $obj->sickness; ?></td>
                                                <td><?php echo $obj->treatment; ?></td>
                                                <td><?php echo $obj->status; ?></td>
                                                <td>
                                                <!--<?php if(has_permission(EDIT, 'teacher', 'department')){ ?>-->
                                                <!--    <a href="<?php echo site_url('academic/sickbay/edit/'.$obj->id); ?>" class="btn btn-info btn-xs"><i class="fa fa-pencil-square-o"></i> <?php echo $this->lang->line('edit'); ?> </a>-->
                                                <!--<?php } ?>-->
                                                <?php if(has_permission(DELETE, 'hrm', 'employee')){ ?> 
                                                    <?php if($obj->id != 1){ ?> 
                                                        <a href="<?php echo site_url('academic/sickbay/delete/'.$obj->id); ?>" onclick="javascript: return confirm('<?php echo $this->lang->line('confirm_alert'); ?>');" class="btn btn-danger btn-xs"><i class="fa fa-trash-o"></i> <?php echo $this->lang->line('delete'); ?> </a>
                                                    <?php } ?>
                                                <?php } ?>
                                            </td>
                                            </tr>
                                        <?php } ?>

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

                        <div class="tab-pane fade in <?php if (isset($add)) {
                                                            echo 'active';
                                                        } ?>" id="tab_add_sickbay">
                            <div class="x_content">
                                <?php echo form_open_multipart(site_url('academic/sickbay/add')); ?>

                                <!--<?php $this->load->view('layout/school_list_form'); ?>-->

                                <div class="row">
                                    <div class="col-md-12 col-sm-12 col-xs-12">
                                        <h5 class="column-title"><strong>Sickbay Information:</strong></h5>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-md-6 col-sm-6 col-xs-12 ">
                                        <div class="item form-group">
                                            <?php $this->load->view('layout/school_list_form'); ?>
                                            <div class="help-block"><?php echo form_error('school_name'); ?></div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">

                                    <div class="col-md-3 col-sm-3 col-xs-12">
                                        <div class="item form-group">
                                            <label for="class_id"><?php echo $this->lang->line('class'); ?> <span class="required">*</span></label>
                                            <select class="form-control col-md-7 col-xs-12 quick-field" name="class_id" id="add_class_id" required="required" onchange="get_section_by_class(this.value, '');">
                                                <option value="">--<?php echo $this->lang->line('select'); ?>--</option>
                                                <?php foreach ($classes as $obj) { ?>
                                                    <option value="<?php echo $obj->id; ?>" <?php echo isset($post['class_id']) && $post['class_id'] == $obj->id ?  'selected="selected"' : ''; ?>><?php echo $obj->name; ?></option>
                                                <?php } ?>
                                            </select>
                                            <!-- <input class="form-control col-md-7 col-xs-12" name="class" id="add_class" value="<?php echo isset($post['class']) ?  $post['class'] : ''; ?>" placeholder="<?php echo $this->lang->line('class'); ?>" required="required" type="text" autocomplete="off"> -->
                                            <div class="help-block"><?php echo form_error('class_id'); ?></div>
                                        </div>
                                    </div>
                                    <div class="col-md-3 col-sm-3 col-xs-12">
                                        <div class="item form-group">
                                            <label for="section_id"><?php echo $this->lang->line('section'); ?> <span class="required">*</span></label>
                                            <select class="form-control col-md-7 col-xs-12 quick-field" name="section_id" id="add_section_id" required="required" onchange="get_roll_no(this.value);">
                                                <option value="">--<?php echo $this->lang->line('select'); ?>--</option>
                                            </select>
                                            <!-- <input class="form-control col-md-7 col-xs-12" name="section" id="add_section" value="<?php echo isset($post['section']) ?  $post['section'] : ''; ?>" placeholder="<?php echo $this->lang->line('section'); ?>" required="required" type="text" autocomplete="off"> -->
                                            <div class="help-block"><?php echo form_error('section'); ?></div>
                                        </div>
                                    </div>

                                    <div class="col-md-3 col-sm-3 col-xs-12">
                                        <div class="item form-group">
                                            <label for="roll_no"><?php echo $this->lang->line('roll_no'); ?> <span class="required">*</span></label>

                                            <input class="form-control col-md-7 col-xs-12" name="roll_no" id="add_roll_no" value="<?php echo isset($post['roll_no']) ?  $post['roll_no'] : ''; ?>" placeholder="<?php echo $this->lang->line('roll_no'); ?>" required="required" type="text" autocomplete="off">
                                            <div class="help-block"><?php echo form_error('roll_no'); ?></div>
                                        </div>
                                    </div>
                                    <div class="col-md-3 col-sm-3 col-xs-12">
                                        <div class="item form-group">
                                            <label for="name"><?php echo $this->lang->line('name'); ?> <span class="required">*</span></label>
                                            <input class="form-control col-md-7 col-xs-12" name="name" id="add_name" value="<?php echo isset($post['name']) ?  $post['name'] : ''; ?>" placeholder="<?php echo $this->lang->line('name'); ?>" required="required" type="text" autocomplete="off">
                                            <div class="help-block"><?php echo form_error('name'); ?></div>
                                        </div>
                                    </div>
                                    <!-- <div class="col-md-3 col-sm-3 col-xs-12">
                                        <div class="item form-group">
                                            <label for="admission_no"><?php echo $this->lang->line('student_id'); ?> <span class="required">*</span></label>
                                            <input class="form-control col-md-7 col-xs-12" name="student_id" id="add_student_id" value="<?php echo isset($post['student_id']) ?  $post['student_id'] : ''; ?>" placeholder="<?php echo $this->lang->line('student_id'); ?>" required="required" type="text" autocomplete="off">
                                            <div class="help-block"><?php echo form_error('student_id'); ?></div>
                                        </div>
                                    </div> -->

                                    <div class="col-md-3 col-sm-3 col-xs-12">
                                        <div class="item form-group">
                                            <label for="dob"><?php echo $this->lang->line('date'); ?> <span class="required">*</span></label>
                                            <input class="form-control col-md-7 col-xs-12" name="date" id="add_date" value="<?php echo isset($post['date']) ?  $post['date'] : ''; ?>" placeholder="<?php echo $this->lang->line('date'); ?>" required="required" type="date" autocomplete="off">
                                            <div class="help-block"><?php echo form_error('date'); ?></div>
                                        </div>
                                    </div>

                                    <div class="col-md-3 col-sm-3 col-xs-12">
                                        <div class="item form-group">
                                            <label for="roll_no">Attendant <span class="required">*</span></label>
                                            <!-- <input class="form-control col-md-7 col-xs-12" name="attendant" id="add_attendant" value="" placeholder="Attendant" required="required" type="text" autocomplete="off"> -->
                                            <!--<div class="help-block"><?php echo form_error('attendant'); ?></div>-->

                                            <select class="form-control col-md-7 col-xs-12 quick-field" name="attendant" id="add_attendent" required="required">
                                                <option value="">--<?php echo $this->lang->line('select'); ?>--</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="col-md-3 col-sm-3 col-xs-12">
                                        <div class="item form-group">
                                            <label for="registration_no">Sickness</label>
                                            <input class="form-control col-md-7 col-xs-12" name="sickness" id="add_sickness" value="" placeholder="Sickness" type="text" autocomplete="off">
                                            <!--<div class="help-block"><?php echo form_error('sickness'); ?></div>-->
                                        </div>
                                    </div>
                                    <div class="col-md-3 col-sm-3 col-xs-12">
                                        <div class="item form-group">
                                            <label for="treatment">Treatment</label>
                                            <input class="form-control col-md-7 col-xs-12" name="treatment" id="add_treatment" value="" placeholder="Treatment" type="text" autocomplete="off">
                                            <!--<div class="help-block"><?php echo form_error('second_language'); ?></div>-->
                                        </div>
                                    </div>
                                </div>

                                <div class="row">


                                    <div class="col-md-3 col-sm-3 col-xs-12">
                                        <div class="item form-group">
                                            <label for="gender"><?php echo $this->lang->line('status'); ?> <span class="required">*</span></label>
                                            <select class="form-control col-md-7 col-xs-12" name="status" id="add_status" required="required">
                                                <option value="">--<?php echo $this->lang->line('select'); ?>--</option>
                                                <option value="Not Feeling Well">Not Feeling Well</option>
                                                <option value="Feeling Well">Feeling Well</option>
                                                <option value="Discharged">Discharged</option>
                                            </select>
                                            <div class="help-block"><?php echo form_error('status'); ?></div>
                                        </div>
                                    </div>
                                </div>
                                <div class="ln_solid"></div>
                                <div class="form-group">
                                    <div class="col-md-6 col-md-offset-3">
                                        <input type="hidden" id="role_id" name="role_id" value="<?php echo STUDENT; ?>" />
                                        <a href="<?php echo site_url('academic/sickbay/index'); ?>" class="btn btn-primary"><?php echo $this->lang->line('cancel'); ?></a>
                                        <button id="send" type="submit" class="btn btn-success"><?php echo $this->lang->line('submit'); ?></button>
                                    </div>
                                </div>
                                <?php echo form_close(); ?>

                                <!--<div class="col-md-12 col-sm-12 col-xs-12">-->
                                <!--    <div class="instructions"><strong><?php echo $this->lang->line('instruction'); ?>: </strong> <?php echo $this->lang->line('add_student_instruction'); ?></div>-->
                                <!--</div>-->

                            </div>
                        </div>

                        <?php if (isset($edit)) { ?>

                            <div class="tab-pane fade in active" id="tab_edit_student">
                                <div class="x_content">
                                    <?php echo form_open_multipart(site_url('academic/sickbay/edit/' . $obj->id), array('name' => 'edit', 'id' => 'edit', 'class' => 'form-horizontal form-label-left'), ''); ?>

                                    <!--<?php $this->load->view('layout/school_list_edit_form'); ?>-->

                                    <div class="row">
                                        <div class="col-md-12 col-sm-12 col-xs-12">
                                            <h5 class="column-title"><strong>Sickbay Information :</strong></h5>
                                        </div>
                                    </div>
                                    
                                    
                                    
                                    <div class="row">
                                    <div class="col-md-6 col-sm-6 col-xs-12 ">
                                        <div class="item form-group">
                                            <?php $this->load->view('layout/school_list_form'); ?>
                                            <div class="help-block"><?php echo form_error('school_name'); ?></div>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">

                                    <div class="col-md-3 col-sm-3 col-xs-12">
                                        <div class="item form-group">
                                            <label for="class_id"><?php echo $this->lang->line('class'); ?> <span class="required">*</span></label>
                                            <select class="form-control col-md-7 col-xs-12 quick-field" name="class_id" id="add_class_id" required="required" onchange="get_section_by_class(this.value, '');">
                                                <option value="">--<?php echo $this->lang->line('select'); ?>--</option>
                                                <?php foreach ($classes as $obj) { ?>
                                                    <option value="<?php echo $obj->id; ?>" <?php echo isset($post['class_id']) && $post['class_id'] == $obj->id ?  'selected="selected"' : ''; ?>><?php echo $obj->name; ?></option>
                                                <?php } ?>
                                            </select>
                                            <!-- <input class="form-control col-md-7 col-xs-12" name="class" id="add_class" value="<?php echo isset($post['class']) ?  $post['class'] : ''; ?>" placeholder="<?php echo $this->lang->line('class'); ?>" required="required" type="text" autocomplete="off"> -->
                                            <div class="help-block"><?php echo form_error('class_id'); ?></div>
                                        </div>
                                    </div>
                                    <div class="col-md-3 col-sm-3 col-xs-12">
                                        <div class="item form-group">
                                            <label for="section_id"><?php echo $this->lang->line('section'); ?> <span class="required">*</span></label>
                                            <select class="form-control col-md-7 col-xs-12 quick-field" name="section_id" id="add_section_id" required="required" onchange="get_roll_no(this.value);">
                                                <option value="">--<?php echo $this->lang->line('select'); ?>--</option>
                                            </select>
                                            <!-- <input class="form-control col-md-7 col-xs-12" name="section" id="add_section" value="<?php echo isset($post['section']) ?  $post['section'] : ''; ?>" placeholder="<?php echo $this->lang->line('section'); ?>" required="required" type="text" autocomplete="off"> -->
                                            <div class="help-block"><?php echo form_error('section'); ?></div>
                                        </div>
                                    </div>

                                    <div class="col-md-3 col-sm-3 col-xs-12">
                                        <div class="item form-group">
                                            <label for="roll_no"><?php echo $this->lang->line('roll_no'); ?> <span class="required">*</span></label>

                                            <input class="form-control col-md-7 col-xs-12" name="roll_no" id="add_roll_no" value="<?php echo isset($post['roll_no']) ?  $post['roll_no'] : ''; ?>" placeholder="<?php echo $this->lang->line('roll_no'); ?>" required="required" type="text" autocomplete="off">
                                            <div class="help-block"><?php echo form_error('roll_no'); ?></div>
                                        </div>
                                    </div>
                                    <div class="col-md-3 col-sm-3 col-xs-12">
                                        <div class="item form-group">
                                            <label for="name"><?php echo $this->lang->line('name'); ?> <span class="required">*</span></label>
                                            <input class="form-control col-md-7 col-xs-12" name="name" id="add_name" value="<?php echo isset($obj->name) ?  $obj->name : ''; ?>" placeholder="<?php echo $this->lang->line('name'); ?>" required="required" type="text" autocomplete="off">
                                            <div class="help-block"><?php echo form_error('name'); ?></div>
                                        </div>
                                    </div>
                                    <!-- <div class="col-md-3 col-sm-3 col-xs-12">
                                        <div class="item form-group">
                                            <label for="admission_no"><?php echo $this->lang->line('student_id'); ?> <span class="required">*</span></label>
                                            <input class="form-control col-md-7 col-xs-12" name="student_id" id="add_student_id" value="<?php echo isset($post['student_id']) ?  $post['student_id'] : ''; ?>" placeholder="<?php echo $this->lang->line('student_id'); ?>" required="required" type="text" autocomplete="off">
                                            <div class="help-block"><?php echo form_error('student_id'); ?></div>
                                        </div>
                                    </div> -->

                                    <div class="col-md-3 col-sm-3 col-xs-12">
                                        <div class="item form-group">
                                            <label for="dob"><?php echo $this->lang->line('date'); ?> <span class="required">*</span></label>
                                            <input class="form-control col-md-7 col-xs-12" name="date" id="add_date" value="<?php echo isset($post['date']) ?  $post['date'] : ''; ?>" placeholder="<?php echo $this->lang->line('date'); ?>" required="required" type="date" autocomplete="off">
                                            <div class="help-block"><?php echo form_error('date'); ?></div>
                                        </div>
                                    </div>

                                    <div class="col-md-3 col-sm-3 col-xs-12">
                                        <div class="item form-group">
                                            <label for="roll_no">Attendant <span class="required">*</span></label>
                                            <!-- <input class="form-control col-md-7 col-xs-12" name="attendant" id="add_attendant" value="" placeholder="Attendant" required="required" type="text" autocomplete="off"> -->
                                            <!--<div class="help-block"><?php echo form_error('attendant'); ?></div>-->

                                            <select class="form-control col-md-7 col-xs-12 quick-field" name="attendant" id="add_attendent" required="required">
                                                <option value="">--<?php echo $this->lang->line('select'); ?>--</option>
                                            </select>
                                        </div>
                                    </div>
                                    <div class="col-md-3 col-sm-3 col-xs-12">
                                        <div class="item form-group">
                                            <label for="registration_no">Sickness</label>
                                            <input class="form-control col-md-7 col-xs-12" name="sickness" id="add_sickness" value="" placeholder="Sickness" type="text" autocomplete="off">
                                            <!--<div class="help-block"><?php echo form_error('sickness'); ?></div>-->
                                        </div>
                                    </div>
                                    <div class="col-md-3 col-sm-3 col-xs-12">
                                        <div class="item form-group">
                                            <label for="treatment">Treatment</label>
                                            <input class="form-control col-md-7 col-xs-12" name="treatment" id="add_treatment" value="" placeholder="Treatment" type="text" autocomplete="off">
                                            <!--<div class="help-block"><?php echo form_error('second_language'); ?></div>-->
                                        </div>
                                    </div>
                                </div>

                                <div class="row">


                                    <div class="col-md-3 col-sm-3 col-xs-12">
                                        <div class="item form-group">
                                            <label for="gender"><?php echo $this->lang->line('status'); ?> <span class="required">*</span></label>
                                            <select class="form-control col-md-7 col-xs-12" name="status" id="add_status" required="required">
                                                <option value="">--<?php echo $this->lang->line('select'); ?>--</option>
                                                <option value="Not Feeling Well">Not Feeling Well</option>
                                                <option value="Feeling Well">Feeling Well</option>
                                                <option value="Discharged">Discharged</option>
                                            </select>
                                            <div class="help-block"><?php echo form_error('status'); ?></div>
                                        </div>
                                    </div>
                                </div>
                                    
                                    

                                    
                                    


                                    <div class="ln_solid"></div>
                                    <div class="form-group">
                                        <div class="col-md-6 col-md-offset-3">
                                            <input type="hidden" name="id" id="id" value="<?php echo $obj->id; ?>" />
                                            <a href="<?php echo site_url('student/index'); ?>" class="btn btn-primary"><?php echo $this->lang->line('cancel'); ?></a>
                                            <button id="send" type="submit" class="btn btn-success"><?php echo $this->lang->line('update'); ?></button>
                                        </div>
                                    </div>
                                    <?php echo form_close(); ?>
                                </div>
                            </div>
                        <?php } ?>

                        <?php if (isset($detail)) { ?>
                            <div class="tab-pane fade in active" id="tab_view_student">
                                <div class="x_content">
                                    <?php $this->load->view('get-single-student'); ?>
                                </div>
                            </div>
                        <?php } ?>


                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<?php $this->load->view('accounting/invoice/invoice-modal'); ?>


<div class="modal fade bs-student-modal-lg" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span></button>
                <h4 class="modal-title"><?php echo $this->lang->line('detail_information'); ?></h4>
            </div>
            <div class="modal-body fn_student_data">

            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function get_student_modal(student_id) {

        $('.fn_student_data').html('<p style="padding: 20px;"><p style="padding: 20px;text-align:center;"><img src="<?php echo IMG_URL; ?>loading.gif" /></p>');
        $.ajax({
            type: "POST",
            url: "<?php echo site_url('student/get_single_student'); ?>",
            data: {
                student_id: student_id
            },
            success: function(response) {
                if (response) {
                    $('.fn_student_data').html(response);
                }
            }
        });
    }
</script>


<div class="modal fade bs-activity-modal-lg" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span></button>
                <h4 class="modal-title"><?php echo $this->lang->line('detail_information'); ?></h4>
            </div>
            <div class="modal-body fn_activity_data">

            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function get_activity_modal(activity_id) {

        $('.fn_activity_data').html('<p style="padding: 20px;"><p style="padding: 20px;text-align:center;"><img src="<?php echo IMG_URL; ?>loading.gif" /></p>');
        $.ajax({
            type: "POST",
            url: "<?php echo site_url('student/activity/get_single_activity'); ?>",
            data: {
                activity_id: activity_id
            },
            success: function(response) {
                if (response) {
                    $('.fn_activity_data').html(response);
                }
            }
        });
    }
</script>


<!-- bootstrap-datetimepicker -->
<link href="<?php echo VENDOR_URL; ?>datepicker/datepicker.css" rel="stylesheet">
<script src="<?php echo VENDOR_URL; ?>datepicker/datepicker.js"></script>


<!-- Super admin js START  -->
<script type="text/javascript">
    var edit = false;

    $("document").ready(function() {
        <?php if (isset($student) && !empty($student)) { ?>
            $("#edit_school_id").trigger('change');
        <?php } elseif (isset($post) && !empty($post)) { ?>
            $("#add_school_id").trigger('change');
        <?php } ?>
    });

    <?php if (isset($student) && !empty($student)) { ?>
        edit = true;
    <?php } ?>
    $(document).ready(function() {
            // Trigger the change event after the page has loaded
            $('.fn_school_id').trigger('change');
        });
    $('.fn_school_id').on('change', function() {

        var school_id = $(this).val();
        var class_id = '';
        var guardian_id = '';
        var discount_id = '';
        var type_id = '';

        <?php if (isset($edit) && !empty($edit)) { ?>
            class_id = '<?php echo $student->class_id; ?>';
            guardian_id = '<?php echo $student->guardian_id; ?>';
            discount_id = '<?php echo $student->discount_id; ?>';
            type_id = '<?php echo $student->type_id; ?>';
        <?php } elseif (isset($post) && !empty($post)) { ?>
            class_id = '<?php echo $post['class_id']; ?>';
            guardian_id = '<?php echo $post['guardian_id']; ?>';
            discount_id = '<?php echo $post['discount_id']; ?>';
            type_id = '<?php echo $post['type_id']; ?>';
        <?php } ?>

        // if (!school_id) {
        //     toastr.error('<?php echo $this->lang->line("select_school"); ?>');
        //     return false;
        // }

        $.ajax({
            type: "POST",
            url: "<?php echo site_url('ajax/get_class_by_school'); ?>",
            data: {
                school_id: school_id,
                class_id: class_id
            },
            async: false,
            success: function(response) {
                if (response) {
                    if (edit) {
                        $('#edit_class_id').html(response);
                    } else {
                        $('#add_class_id').html(response);
                    }

                    get_guardian_by_school(school_id, guardian_id);
                    get_discount_by_school(school_id, discount_id);
                    get_student_type_by_school(school_id, type_id);
                    get_nurse_by_school(school_id);

                }
            }
        });



    });

    // for attendent
    function get_nurse_by_school(school_id) {

        $.ajax({
            type: "POST",
            url: "<?php echo site_url('ajax/get_nurse_by_school'); ?>",
            data: {
                school_id: school_id


            },
            async: false,
            success: function(response) {
                if (response) {
                    $('#add_attendent').html(response);
                }
            }
        });

    }

    function get_guardian_by_school(school_id, guardian_id) {

        $.ajax({
            type: "POST",
            url: "<?php echo site_url('ajax/get_guardian_by_school'); ?>",
            data: {
                school_id: school_id,
                guardian_id: guardian_id
            },
            async: false,
            success: function(response) {
                if (response) {
                    if (edit) {
                        $('#edit_guardian_id').html(response);
                    } else {
                        $('#add_guardian_id').html(response);
                    }
                }
            }
        });
    }

    function get_discount_by_school(school_id, discount_id) {

        $.ajax({
            type: "POST",
            url: "<?php echo site_url('ajax/get_discount_by_school'); ?>",
            data: {
                school_id: school_id,
                discount_id: discount_id
            },
            async: false,
            success: function(response) {
                if (response) {
                    if (edit) {
                        $('#edit_discount_id').html(response);
                    } else {
                        $('#add_discount_id').html(response);
                    }
                }
            }
        });
    }

    function get_student_type_by_school(school_id, type_id) {

        $.ajax({
            type: "POST",
            url: "<?php echo site_url('ajax/get_student_type_by_school'); ?>",
            data: {
                school_id: school_id,
                type_id: type_id
            },
            async: false,
            success: function(response) {
                if (response) {
                    if (edit) {
                        $('#edit_type_id').html(response);
                    } else {
                        $('#add_type_id').html(response);
                    }
                }
            }
        });
    }


    $('#add_admission_date').datepicker();
    $('#edit_admission_date').datepicker();
    $('#add_dob').datepicker({
        startView: 2,
        endDate: "today"
    });
    $('#edit_dob').datepicker({
        startView: 2,
        endDate: "today"
    });

    <?php if (isset($edit)) { ?>
        get_section_by_class('<?php echo $student->class_id; ?>', '<?php echo $student->section_id; ?>');
    <?php } elseif (isset($post) && !empty($post)) { ?>
        get_section_by_class('<?php echo $post['class_id']; ?>', '<?php echo $post['section_id']; ?>');
    <?php } ?>

    function get_section_by_class(class_id, section_id) {

        var school_id = '';
        <?php if (isset($edit)) { ?>
            school_id = $('#edit_school_id').val();
        <?php } else { ?>
            school_id = $('#add_school_id').val();
        <?php } ?>


        if (!school_id) {
            toastr.error('<?php echo $this->lang->line("select_school"); ?>');
            return false;
        }

        $.ajax({
            type: "POST",
            url: "<?php echo site_url('ajax/get_section_by_class'); ?>",
            data: {
                school_id: school_id,
                class_id: class_id,
                section_id: section_id
            },
            async: false,
            success: function(response) {
                if (response) {
                    if (edit) {
                        $('#edit_section_id').html(response);
                    } else {
                        $('#add_section_id').html(response);
                    }
                }
            }
        });


    }

    // function get_roll_no(section_id) {

    //     if (!section_id) {
    //         $('#add_roll_no').val('');
    //         return false;
    //     }

    //     var school_id = $('#add_school_id').val();
    //     var class_id = $('#add_class_id').val();

    //     if (!school_id) {
    //         toastr.error("<?php echo $this->lang->line("select_school"); ?>");
    //         return false;
    //     }
    //     if (!class_id) {
    //         toastr.error("<?php echo $this->lang->line("select_class"); ?>");
    //         return false;
    //     }

    //     $.ajax({
    //         type: "POST",
    //         url: "<?php echo site_url('student/get_roll_no'); ?>",
    //         data: {
    //             school_id: school_id,
    //             class_id: class_id,
    //             section_id: section_id
    //         },
    //         async: false,
    //         success: function(response) {
    //             if (response) {
    //                 $('#add_roll_no').html(response);
    //             }
    //         }
    //     });


    // }
</script>

<!-- datatable with buttons -->
<script type="text/javascript">
    $(document).ready(function() {
        $('#datatable-responsive').DataTable({
            dom: 'Bfrtip',
            iDisplayLength: 15,
            buttons: [
                'copyHtml5',
                'excelHtml5',
                'csvHtml5',
                'pdfHtml5',
                'pageLength'
            ],
            search: true,
            responsive: true
        });
    });



    function check_guardian_type(guardian_type) {

        $('#add_relation_with').val('');
        $('#add_gud_name').val('');
        $('#add_gud_phone').val('');
        $('#add_gud_present_address').val('');
        $('#add_gud_permanent_address').val('');
        $('#add_gud_religion').val('');
        $('#add_gud_profession').val('');
        $('#add_gud_national_id').val('');
        $('#add_gud_email').val('');
        $('#add_gud_other_info').val('');

        if (guardian_type == 'father') {

            $('#add_relation_with').val('<?php echo $this->lang->line('father'); ?>');
            $('.fn_existing_guardian').hide();
            $('.fn_except_exist').show();
            $('#guardian_id').prop('required', false);
            $('#add_gud_name').prop('required', true);
            $('#add_gud_phone').prop('required', true);
            $('#add_gud_email').prop('required', true);

            var f_name = $('#add_father_name').val();
            var f_phone = $('#add_father_phone').val();
            var f_education = $('#add_father_education').val();
            var f_profession = $('#add_father_profession').val();
            var f_designation = $('#add_father_designation').val();

            $('#add_gud_name').val(f_name);
            $('#add_gud_phone').val(f_phone);
            $('#add_gud_profession').val(f_profession);

        } else if (guardian_type == 'mother') {

            $('#add_relation_with').val('<?php echo $this->lang->line('mother'); ?>');
            $('.fn_existing_guardian').hide();
            $('.fn_except_exist').show();
            $('#guardian_id').prop('required', false);
            $('#add_gud_name').prop('required', true);
            $('#add_gud_phone').prop('required', true);
            $('#add_gud_email').prop('required', true);

            var m_name = $('#add_mother_name').val();
            var m_phone = $('#add_mother_phone').val();
            var m_education = $('#add_mother_education').val();
            var m_profession = $('#add_mother_profession').val();
            var m_designation = $('#add_mother_designation').val();

            $('#add_gud_name').val(m_name);
            $('#add_gud_phone').val(m_phone);
            $('#add_gud_profession').val(m_profession);

        } else if (guardian_type == 'other') {
            $('#add_relation_with').val('<?php echo $this->lang->line('other'); ?>');
            $('.fn_existing_guardian').hide();
            $('.fn_except_exist').show();
            $('#guardian_id').prop('required', false);
            $('#add_gud_name').prop('required', true);
            $('#add_gud_phone').prop('required', true);
            $('#add_gud_email').prop('required', false);

        } else if (guardian_type == 'exist_guardian') {
            $('.fn_existing_guardian').show();
            $('.fn_except_exist').hide();
            $('#guardian_id').prop('required', true);
            $('#add_gud_name').prop('required', false);
            $('#add_gud_phone').prop('required', false);
            $('#add_gud_email').prop('required', false);

        } else {
            $('#add_relation_with').val('');
            $('.fn_existing_guardian').hide();
            $('.fn_except_exist').show();
            $('#guardian_id').prop('required', false);
            $('#add_gud_name').prop('required', true);
            $('#add_gud_phone').prop('required', true);
            $('#add_gud_email').prop('required', false);
        }

    }

    function get_guardian_by_id(guardian_id) {

        $.ajax({
            type: "POST",
            dataType: "json",
            url: "<?php echo site_url('ajax/get_guardian_by_id'); ?>",
            data: {
                guardian_id: guardian_id
            },
            async: true,
            success: function(response) {
                if (response) {
                    $('#add_gud_name').val(response.name);
                    $('#add_gud_phone').val(response.phone);
                    $('#add_gud_present_address').val(response.present_address);
                    $('#add_gud_permanent_address').val(response.permanent_address);
                    $('#add_gud_religion').val(response.religion);
                    $('#add_gud_profession').val(response.profession);
                    $('#add_gud_national_id').val(response.national_id);
                    $('#add_gud_email').val(response.email);
                    $('#add_gud_other_info').val(response.other_info);
                } else {
                    $('#add_relation_with').val('');
                    $('#add_gud_name').val('');
                    $('#add_gud_phone').val('');
                    $('#add_gud_present_address').val('');
                    $('#add_gud_permanent_address').val('');
                    $('#add_gud_religion').val('');
                    $('#add_gud_profession').val('');
                    $('#add_gud_national_id').val('');
                    $('#add_gud_email').val('');
                    $('#add_gud_other_info').val('');
                }
            }
        });

    }


    $('#same_as_guardian').on('click', function() {

        if ($(this).is(":checked")) {
            var present = $('#add_gud_present_address').val();
            var permanent = $('#add_gud_permanent_address').val();
            $('#add_present_address').val(present);
            $('#add_permanent_address').val(permanent);
        } else {
            $('#add_present_address').val('');
            $('#add_permanent_address').val('');
        }
    });


    /* Menu Filter Start */
    // function get_student_by_class(url) {
    //     if (url) {
    //         window.location.href = url;
    //     }
    // }


    // <?php if (isset($filter_class_id)) { ?>
    //     get_class_by_school('<?php echo $filter_school_id; ?>', '<?php echo $filter_class_id; ?>');
    // <?php } ?>

    // function get_class_by_school(school_id, class_id) {


    //     $.ajax({
    //         type: "POST",
    //         url: "<?php echo site_url('ajax/get_class_by_school'); ?>",
    //         data: {
    //             school_id: school_id,
    //             class_id: class_id
    //         },
    //         async: false,
    //         success: function(response) {
    //             if (response) {
    //                 $('#filter_class_id').html(response);
    //             }
    //         }
    //     });
    // }

    function update_status_type(student_id, status) {


        $.ajax({
            type: "POST",
            url: "<?php echo site_url('ajax/update_student_status_type'); ?>",
            data: {
                student_id: student_id,
                status: status
            },
            async: false,
            success: function(response) {
                if (response) {
                    toastr.success('<?php echo $this->lang->line('update_success'); ?>');
                    location.reload();
                    return false;
                }
            }
        });
    }

    $("#add").validate();
    $("#edit").validate();

    function get_dept_by_school(url) {
        if (url) {
            window.location.href = url;
        }
    }
</script>