<?php
$status = $this->session->userdata('status');
$type_id = $this->session->userdata('type_id');
$person_role = $this->session->userdata('role_id');
if ($person_role == 1) {
    $person_role = 'Admin';
    $person_url = 'Admin';
} else if ($person_role == 2) {
    $person_role = 'Account Officer';
    $person_url = 'Account';
} else if ($person_role == 3) {
    $person_role = 'Resource Person';
    $person_url = 'Resource';
} else if ($person_role == 4) {
    $person_role = 'Organization';
    $person_url = 'Organization';
} else if ($person_role == 4) {
    $person_role = 'Student';
    $person_url = 'Student';
} else {
    $person_role = 'All';
    $person_url = 'All';
}

$org_person_id = $this->session->userdata('org_person_id');
?>
<!--Add / Change / Assign / Short-->
<div id="change">
    <div class="col-sm-10 col-sm-offset-3 main col-md-10 col-md-offset-2 main">

        <div class="container col-sm-8 col-sm-offset-2 col-md-offset-0 col-md-12" id="res">
            <!--<hr>-->
            <div class="">
                <a href="<?php echo base_url(); ?>super_admin">Dashboard</a>->>
                <a href="<?php echo base_url(); ?>super_admin/user_list/<?php echo $person_url; ?>/4/"><?php echo $person_role; ?> List</a>->>
                <a href="<?php echo base_url(); ?>super_admin/view_detail/Organization/<?php echo $org_person_id; ?>">Organization Detail</a>->>
                <a href="<?php echo base_url(); ?>super_admin_organization/organization_resource_person/<?php echo $org_person_id; ?>">Resource Person List</a>->>
                <span>Resource Person Detail</span>
                <div>
                    <?php
                    $message = $this->session->userdata('message');
                    if ($message) {
                        echo $message;
                    }
                    ?>
                </div>
            </div>
            <!--<hr>-->

            <!--<div class="col-lg-12 col-md-12 col-sm-12 ">-->
            <div class="col-lg-12 col-md-12 col-sm-12 " style="background-color:#b2b2b2; margin-top: 20px;margin-bottom: 10px; " >
                <div class="col-sm-4 col-md-4">
                    <h4> <?php
                        $person_role = $this->session->userdata('role_id');
                        if ($person_role == 1) {
                            echo 'Admin';
                        } else if ($person_role == 2) {
                            echo 'Account Officer';
                        } else if ($person_role == 3) {
                            echo 'Resource Person';
                        } else if ($person_role == 4) {
                            echo 'Organization';
                        } else if ($person_role == 4) {
                            echo 'Student';
                        }
                        ?>  Information</h4> 
                </div>
                <div class="col-sm-6 col-md-6" style="float: right;margin-top: 5px; ">
                    <?php if ($person_info->person_role == 4) { ?>
                        <a style="float: right;" href="<?php echo base_url(); ?>super_admin_organization/organization_resource_person/<?php
                        echo $person_info->person_id;
                        ?>" class="btn btn-sm btn-success"> Resource Person 
                        </a>
                        <a style="float: right;" href="<?php echo base_url(); ?>super_admin_organization/add_trainer/<?php
                        echo $person_info->person_id;
                        ?>" class="btn btn-sm btn-success"> Add Trainer 
                        </a>
                    <?php } ?>
                </div>
            </div>
            <!--</div>-->
            <!--    
            Only List with Pagination 
            Change Status / Edit / Delete
            -->
            <div class="col-lg-12 col-md-8 col-sm-7" id="student_list">
                <div class="row">
                    <div class="col-xs-2 col-md-2">
                        <a href="<?php echo base_url(); ?>super_admin_student/student_list" class="thumbnail">
                            <img src="<?php echo base_url() . $person_info->person_image_thumb; ?>" alt="..." width="100px" height="100px">
                        </a>
                    </div>
                    <div class="col-lg-5 col-md-5 col-sm-5">
                        <div class="span10">
                            <div class="col-sm-3 col-md-3">Name</div>
                            <div class="col-sm-3 col-md-6"><?php echo $person_info->person_first_name . $person_info->person_last_name; ?></div>
                        </div>
                        <br><br>
                        <div class="span10">
                            <div class="col-sm-3 col-md-3">Email</div>
                            <div class="col-sm-3 col-md-6"><?php echo $person_info->person_email; ?></div>
                        </div>
                        <br><br>
                        <div class="span10">
                            <div class="col-sm-3 col-md-3">Contact Number</div>
                            <div class="col-sm-3 col-md-6"><?php echo $person_info->person_contact_number; ?></div>
                        </div>
                    </div>

                    <div class="col-lg-5 col-md-5 col-sm-5">
                        <div class="span10">
                            <div class="col-sm-3 col-md-3">Person ID</div>
                            <div class="col-sm-3 col-md-6"><?php echo $person_info->person_id; ?></div>
                        </div>
                        <br><br>
                        <div class="span10">
                            <div class="col-sm-3 col-md-3">Email</div>
                            <div class="col-sm-3 col-md-6"><?php echo $person_info->person_country; ?></div>
                        </div>
                        <br><br>
                        <div class="span10">
                            <div class="col-sm-3 col-md-3">Contact Number</div>
                            <div class="col-sm-3 col-md-6"><?php echo $person_info->person_city; ?></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>  
    </div>


    <div class="col-sm-10 col-sm-offset-3 main col-md-10 col-md-offset-2 main">
        <div class="table-responsive col-sm-12">
            <div role="tabpanel">
                <!-- Nav tabs -->
                <ul class="nav nav-tabs" role="tablist">
                    <li role="presentation" class="<?php
                    if ($tab == '1') {
                        echo 'active';
                    }
                    ?>"><a href="#person" aria-controls="person" role="tab" data-toggle="tab">Person Information</a></li>
                    <li role="presentation" class="<?php
                    if ($tab == '2') {
                        echo 'active';
                    }
                    ?>"><a href="#course" aria-controls="course" role="tab" data-toggle="tab" disable>Select Course</a></li>

                    <li role="presentation" class="<?php
                    if ($tab == '3') {
                        echo 'active';
                    }
                    ?>"><a href="#payment" aria-controls="payment" role="tab" data-toggle="tab" disable>Payment Information</a></li>
                </ul>

                <div class="tab-content">
                    <div role="tabpanel" class="tab-pane  col-sm-12 <?php
                    if ($tab == '1') {
                        echo 'active';
                    }
                    ?>" id="person">
                         <?php
                         if ($tab == '1') {
                             echo $person_work_details_view;
                         } else {
                             echo $person_work_details_view;
                         }
                         ?>
                    </div>

                    <div role="tabpanel" class="tab-pane col-sm-12 <?php
                    if ($tab == '2') {
                        echo 'active';
                    }
                    ?>" id="course">
                         <?php
                         if ($tab == '2') {
                             echo $person_education_details_view;
                         } else {
                             echo $person_education_details_view;
                         }
                         ?>
                    </div>

                    <div role="tabpanel" class="tab-pane col-sm-12 <?php
                    if ($tab == '3') {
                        echo 'active';
                    }
                    ?>" id="payment">
                         <?php
                         if ($tab == '3') {
                             echo $payment_details_information_view;
                         } else {
                             echo $payment_details_information_view;
                         }
                         ?>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        document.forms['pagination'].elements['per_page'].value = '<?php echo $limit ?>';
        document.forms['control_form'].elements['student_status'].value = '<?php echo $status; ?>';
        document.forms['control_form'].elements['student_role_id2'].value = '<?php echo $type_id; ?>';
    </script>


    <SCRIPT LANGUAGE="JavaScript">

        studentList = '';

        /*
         * Set All Student ID to Javascript studentList variable 
         */
        function toggleAllStudentSelection(field) {
            allStudent = document.getElementById("all_student").checked;
            if (allStudent) {
                for (i = 0; i < field.length; i++) {
                    field[i].checked = true;
                    studentList += field[i].value + '.';
                }
                document.getElementById('change_role_button').disabled = false;
                document.getElementById('assign_course').disabled = false;
                document.getElementById('change_status_button').disabled = false;
            } else {
                for (i = 0; i < field.length; i++)
                    field[i].checked = false;
                studentList = '';
                document.getElementById('change_role_button').disabled = true;
                document.getElementById('assign_course').disabled = true;
                document.getElementById('change_status_button').disabled = true;
            }
        }


        /*
         * Set single Student ID to Javascript studentList variable 
         */
        function setStudentIdList(studentID)
        {
            if ($("#student_id" + studentID).is(":checked")) {
                studentList += studentID + '.';
            } else {
                studentList = studentList.replace(studentID + ".", "");
            }
            if (studentList) {
                document.getElementById('change_role_button').disabled = false;
                document.getElementById('assign_course').disabled = false;
                document.getElementById('change_status_button').disabled = false;
            } else {
                document.getElementById('change_role_button').disabled = true;
                document.getElementById('assign_course').disabled = true;
                document.getElementById('change_status_button').disabled = true;
            }
        }


        /*
         * Delete Action Confirmation
         */
        function checkAction(action) {
            message = 'do you want to ' + action + '!!';
            chk = confirm(message);
            if (chk) {
                return true;
            } else {
                return false;
            }
        }

        /*
         * Change Student Role Using JavaScript studentList variable (From Modal)
         */
        function setStudentRole()
        {
            studentRoleId = document.getElementById("student_role_id").value;
            serverPage = '<?php echo base_url(); ?>smis/set_students_role/' + studentList + '/' + studentRoleId;
            xmlhttp.open("GET", serverPage);
            xmlhttp.onreadystatechange = function ()
            {
                if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
                {
                    document.getElementById('res').innerHTML = xmlhttp.responseText;
                    localtion.reload();
                }
            };
            xmlhttp.send(null);
        }


        /*
         * Change Student Status Using JavaScript studentList variable (From Modal)
         */
        function changeStudentsStatus()
        {
            studentStatus = document.getElementById("change_status").value;
            serverPage = '<?php echo base_url(); ?>super_admin/change_students_status/' + studentList + '/' + studentStatus;
            xmlhttp.open("GET", serverPage);
            xmlhttp.onreadystatechange = function ()
            {
                if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
                {
                    document.getElementById(objID).innerHTML = xmlhttp.responseText;
                    localtion.reload();
                }
            };
            xmlhttp.send(null);
        }

        /*
         * Select Course By category Id
         */

        function selectCategoryCourse(categoryID, objID) {
            serverPage = '<?php echo base_url(); ?>cmis/select_all_available_course_by_cateogy_id/' + categoryID;
            xmlhttp.open("GET", serverPage);
            xmlhttp.onreadystatechange = function ()
            {
                //                alert(xmlhttp.readyState);
                //                alert(xmlhttp.status);
                if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
                {
                    document.getElementById(objID).innerHTML = xmlhttp.responseText;
                    localtion.reload();
                }
            };
            xmlhttp.send(null);
        }

        /*
         * Assign Course to Student Using JavaScript studentList variable (From Modal)
         */
        function assignCourse()
        {
            courseID = document.getElementById("course_id").value;
            serverPage = '<?php echo base_url(); ?>smis/assign_course_to_student/' + studentList + '/' + courseID;
            xmlhttp.open("GET", serverPage);
            xmlhttp.onreadystatechange = function ()
            {
                alert(xmlhttp.readyState + xmlhttp.status);
                if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
                {
                    alert(xmlhttp.responseText);
                    location.reload();
                }
            };
            xmlhttp.send(null);
        }



        /*
         * Select Student By Student Type and Status 
         */
        function selectStudent(roleID, studentStatus, objID) {
            if (roleID === '') {
                serverPage = '<?php echo base_url(); ?>super_admin/select_student_list/' + null + '/' + studentStatus + '/' + 0;
            } else {
                serverPage = '<?php echo base_url(); ?>super_admin/select_student_list/' + roleID + '/' + studentStatus + '/' + 0;
            }

            xmlhttp.open("GET", serverPage);
            xmlhttp.onreadystatechange = function ()
            {
                if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
                {
                    document.getElementById(objID).innerHTML = xmlhttp.responseText;
                }
            };
            xmlhttp.send(null);
        }


        /*
         * Set Per Page List Value
         */
        function setPerPage(perPage) {

            serverPage = '<?php echo base_url(); ?>smis/set_per_page/' + perPage;
            xmlhttp.open("GET", serverPage);
            xmlhttp.onreadystatechange = function ()
            {
                if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
                {
                    location.reload();
                }
            };
            xmlhttp.send(null);
        }


        /*
         * Send Mail To Selected Student using studentList
         */
        function sendMailToStudent() {
            if (studentList === '') {
                studentList = '';
                window.location = '<?php echo base_url(); ?>smis/send_mail_to_student/' + studentList;
            } else {
                window.location = '<?php echo base_url(); ?>smis/send_mail_to_student/' + studentList;
            }
        }


        /*
         * Print Student List
         */
        function printPreview(divName) {
            serverPage = '<?php echo base_url(); ?>super_admin/make_print_data/' + studentList;
            xmlhttp.open("GET", serverPage);
            xmlhttp.onreadystatechange = function ()
            {
                if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
                {
                    window = document.getElementById('print_preview').innerHTML = xmlhttp.responseText;
                }
            };
            xmlhttp.send(null);
        }

    </script>
</div>
