<script>
    $.noConflict();

    var i = 0;
    function checkXMLHTTP(xmlhttp) {
        xmlhttp = false;
        try {
            return xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                return xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp = false;
            }
        }
        if (!xmlhttp && typeof XMLHttpRequest !== 'undefined') {
            return xmlhttp = new XMLHttpRequest();
        }
    }

    function documentID(el) {
        return document.getElementById(el);
    }
</script>

<div id="container">
    <?php
    $status = $this->session->userdata('status');
    if (!$status) {
        $status = 'all';
    }
    $role_id = $this->session->userdata('role_id');
    $person_id = $this->session->userdata('person_id');
    $person_role = $this->session->userdata('person_role');
    $selected_person_role = $this->session->userdata('user_role_session');
    $per_page_view = ($this->session->userdata('session_user_view_per_page') != '') ? $this->session->userdata('session_user_view_per_page') : 10;
    $start_limit_value = $this->session->userdata('session_limit_value');
    ?>
    <div class="col-sm-10">
        <div class="row ">
            <div class="col-sm-12 padding-zero">
                <div class="col-sm-12 ">
                    <div class="col-sm-3 form-group" id="view_upper_button">
                        <a class="btn btn-sm btn-success " href="<?php echo base_url(); ?>super-admin/add-user"><i class="fa fa-user-plus" title="Add User"></i>
                        </a>
                        <?php
                        if ($selected_person_role != '') {
                            ?>
                            <a class="btn btn-sm btn-success" 
                               href="javascript:void(0)" 
                               id="change_status_button" 
                               data-target="#changeStatus"
                               data-toggle="modal">
                                <i class="fa fa-exchange" title="Change Status"></i>
                            </a>
                            <?php
                        }


                        switch ($sort_by) {
                            case 'asc':
                                ?>
                                <a href="<?php echo base_url() . 'user-descending' ?>" class="btn btn-sm btn-success" >
                                    <i class="fa fa-sort-alpha-desc" title="Short user by name"></i>
                                </a>
                                <?php
                                break;
                            case 'desc':
                                ?>
                                <a href="<?php echo base_url() . 'user-ascending' ?>" class="btn btn-sm btn-success" >
                                    <i class="fa fa-sort-alpha-asc" title="Short user by name"></i>
                                </a>
                                <?php
                                break;

                            default:
                                ?>
                                <a href="<?php echo base_url() . 'user-ascending' ?>" class="btn btn-sm btn-success" >
                                    <i class="fa fa-sort-alpha-asc" title="Short user by name"></i>
                                </a>
                                <?php
                                break;
                        }
                        ?>



                    </div>
                    <div class="col-sm-5 form-group">
                        <form action="javascript:void(0)" method="post">
                            <div class="input-group">
                                <input type="text" 
                                       class="form-control"
                                       oninput="getValueForSearch(this.value)"
                                       placeholder="Search here..." 
                                       aria-describedby="basic-addon1">
                                <span class="input-group-addon" id="basic-addon1"><i class="fa fa-search"></i></span>
                            </div>
                        </form>
                    </div>
                    <script>
                        function getValueForSearch(input) {
                            var xmlhttp;
                            xmlhttp = checkXMLHTTP(xmlhttp);

                            input = input.replace(/  +/g, ' ');
                            var searchValue;
                            if (input === '') {
                                searchValue = 'null';
                            } else {
                                searchValue = input;
                            }

                            var serverPage = '<?php echo base_url(); ?>get-all-search-value/' + searchValue;  // passing person_organization_code Field value 
                            xmlhttp.open("GET", serverPage);
                            xmlhttp.onreadystatechange = function ()
                            {
                                if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
                                {
//                                    alert(xmlhttp.responseText);
                                    documentID('user_list').innerHTML = xmlhttp.responseText;
                                }
                            };
                            xmlhttp.send(null);
                        }
                    </script>
                    <div class="col-sm-4 form-group padding-zero">
                        <form name="control_form">
                            <div class="col-sm-7 form-group ">
                                <select class="form-control" 
                                        id="header_person_role"
                                        onchange="getHeaderRoleValue(this.value)" >
                                    <option value=""> All</option>
                                    <option value="6">  Super Admin </option>
                                    <option value="1">  Admin </option>
                                    <option value="2"> Account Officer</option>
                                    <option value="4"> Organization</option>
                                    <option value="3">Individual Teacher</option>
                                    <option value="5"> Learner</option>
                                    <option value="7"> No Role</option>
                                </select>
                            </div>

                            <div class="col-sm-5 form-group ">
                                <select class="form-control"
                                        id="header_person_status"
                                        onchange="getStatusValue(this.value)">
                                    <option value=""> All</option>
                                    <option value="1"> Active</option>
                                    <option value="3"> Inactive</option>
                                    <option value="2"> Archive</option>
                                </select>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <?php
            if ($this->session->userdata('status_user_session') == ('0,3')) {
                $user_status = 3;
            } else {
                $user_status = $this->session->userdata('status_user_session');
            }
            ?>
            <script>
                documentID('header_person_role').value = '<?php echo $this->session->userdata('user_role_session'); ?>';
                documentID('header_person_status').value = '<?php echo $user_status; ?>';
            </script>


            <div class="col-sm-12 "><br></div>
            <div class="col-sm-12 form-group">
                <div class="col-sm-12 form-group">
                    <span class="pull-right form-group" >
                        <a class="btn btn-sm btn-success" href="javascript:void(0)">Export
                        </a>
                        <a class="btn btn-sm btn-success" href="javascript:void(0)">Import
                        </a> 
                        <a class="btn btn-sm btn-success" href="javascript:void(0)">Print
                        </a> 
                        <a class="btn btn-sm btn-success" href="javascript:void(0)">SMS</a>
                        <a class="btn btn-sm btn-success" href="javascript:void(0)" id="email_test" name="email_test" onclick="sendMailToUser()">Email</a>
                    </span>
                </div>
                <div class="col-sm-12"><br>
                    <?php
                    if ($this->session->userdata('message')) {
                        echo $this->session->userdata('message');
                        $this->session->unset_userdata('message');
                    }
                    ?>
                    <hr></div>
                <div class="col-sm-12" id="user_list">
                    <form name="myform" action=""  method="post">
                        <div class="col-sm-12 gray_ttc" style="border-bottom: 2px solid #8CC73F;padding-top: 10px;padding-bottom: 10px;font-weight: bold">

                            <div class="col-sm-1">
                                <div class="checkbox checkbox-success" style="margin-top: -5px">
                                    <input class="styled" type="checkbox" name="all_list" id="all_list" onchange="toggleAllUserSelection(document.myform.person_id)">
                                    <label for="checkbox1"></label>
                                </div>
                            </div>
                            <input type="hidden" id="selected_person_id" value="">
                            <div class="col-sm-1 padding-zero">Image</div>
                            <div class="col-sm-2 padding-zero">Name</div>
                            <div class="col-sm-3 padding-zero">Email</div>
                            <div class="col-sm-2 padding-zero">Mobile</div>
                            <div class="col-sm-1 padding-zero">Role</div>
                            <div class="col-sm-2 padding-zero">Action</div>
                        </div>
                        <div class="col-sm-12"><br></div> 
                        <?php
                        $i = 1;
                        foreach ($users as $value) {
                            ?>
                            <div class="col-sm-12 <?php
                            if ($i % 2 == 0) {
                                echo 'white_ttc';
                            } else {
                                echo 'gray_ttc';
                            }
                            ?> " style="padding-top: 10px;padding-bottom: 10px;">

                                <div class="col-sm-1">
                                    <div class="checkbox checkbox-success" style="margin-top: -5px">
                                        <input name="person_id"  class="email_id_check" type="checkbox" 
                                               id="person_id<?php echo $value->person_id; ?>" 
                                               value="<?php echo $value->person_id; ?>" 
                                               onchange="setUserIdList(this.value);" >
                                        <label for="checkbox2"></label>
                                    </div>
                                </div>
                                <?php
                                if ($value->person_image != NULL) {
                                    ?>
                                    <div class="col-sm-1 padding-zero h_image" id="show_image<?php echo $value->person_id; ?>">

                                        <img id="src_image"
                                             src="<?php echo base_url() . 'content-library/' . $value->url . '/' . $value->person_image_thumb; ?>" 
                                             height="50" width="50"  
                                             onmouseover="showimage('<?php echo base_url() . 'content-library/' . $value->url . '/' . $value->person_image; ?>', '<?php echo $value->person_id; ?>')"
                                             onmouseout="removeimage('<?php echo base_url() . 'content-library/' . $value->url . '/' . $value->person_image_thumb; ?>')" >

                                    </div>
                                <?php } else { ?>
                                    <div class="col-sm-1 padding-zero">

                                        <img src="<?php echo base_url() . 'image/no_profile_picture.png'; ?>" 
                                             height="50" width="50">
                                    </div>
                                <?php } ?>
                                <div class="col-sm-2 padding-zero"><a href="<?php echo base_url() . $value->url; ?>/profile"><?php echo $value->person_first_name . ' ' . $value->person_last_name; ?></a></div>
                                <div class="col-sm-3 padding-zero"><?php echo $value->person_email; ?></div>
                                <div class="col-sm-2 padding-zero"><?php echo str_replace(" ", "", $value->person_contact_number); ?></div>
                                <div class="col-sm-1 padding-zero">
                                    <?php
                                    if ($value->person_role == '1') {
                                        echo 'Admin';
                                    }
                                    if ($value->person_role == '2') {
                                        echo 'Account';
                                    }
                                    if ($value->person_role == '3') {
                                        if ($resource_person_info[$value->person_id]->resource_person_type == 3) {
                                            echo 'Teacher (Org)';
                                        } else if (($resource_person_info[$value->person_id]->resource_person_type == 1)) {
                                            echo 'Teacher (TT)';
                                        } else {
                                            echo 'Teacher';
                                        }
                                    }
                                    if ($value->person_role == '4') {
                                        echo 'Organization';
                                    }
                                    if ($value->person_role == '5') {
                                        echo 'Student';
                                    }
                                    if ($value->person_role == '6') {
                                        echo 'Super Admin';
                                    }
                                    if ($value->person_role == '8') {
                                        echo 'Quiz Editor';
                                    }
                                    if ($value->person_role == '9') {
                                        echo 'Course Editor';
                                    }
                                    ?>
                                </div>

                                <div class="col-sm-2 padding-zero" id="action<?php echo $value->person_id; ?>">
                                    <span>&nbsp;&nbsp;</span>
                                    <?php
                                    if ($value->person_status == 2 && $person_role == 6) {
                                        ?>
                                        <a href="javascript:void(0)" onclick="checkForAction('<?php echo base_url() . 'make-user-active/' . $value->person_id; ?>', 'Active', '<?php echo $value->person_id; ?>')"><i class="fa fa-archive" title="Archive"></i></a>
                                        <a href="javascript:void(0)"><i onclick="checkForDelete('<?php echo base_url() . 'delete-user/' . $value->url; ?>', 'Delete', '<?php echo $value->person_id; ?>')" class="fa fa-trash-o" title="Delete"></i></a>
                                        <?php
                                    } else if ($value->person_status == 2 && $person_role == 1) {
                                        ?>
                                        <a href="javascript:void(0)" onclick="checkForAction('<?php echo base_url() . 'make-user-active/' . $value->person_id; ?>', 'Active', '<?php echo $value->person_id; ?>')"><i class="fa fa-archive" title="Archive"></i></a>
                                        <?php
                                    } else {
                                        switch ($person_role) {
                                            case 6:
                                                if ($value->person_id == $person_id) {
                                                    ?>
                                                    <a href="<?php echo base_url(); ?>super-admin/edit-user-information/<?php echo $value->url; ?>"><i title="Edit" class="fa fa-edit"></i></a>
                                                    <a href="<?php echo base_url(); ?>super-admin/view-detail/<?php echo $value->url; ?>"><i title="View Details" class="fa fa-th"></i></a>
                                                    <?php
                                                } else {
                                                    if ($value->person_status != 1) {
                                                        ?>
                                                        <a href="javascript:void(0)" onclick="checkForAction('<?php echo base_url() . 'make-user-active/' . $value->person_id; ?>', 'Active', '<?php echo $value->person_id; ?>')"><i title="Active" class="fa fa-user-plus"></i></a>
                                                    <?php } else {
                                                        ?>
                                                        <a href="javascript:void(0)" onclick="checkForAction('<?php echo base_url() . 'make-user-inactive/' . $value->person_id; ?>', 'Inactive', '<?php echo $value->person_id; ?>')"><i title="Inactive" class="fa fa-user-times"></i></a>
                                                        <?php
                                                    }
                                                    ?>
                                                    <?php
                                                    if ($value->person_role != 6 && $value->person_role != 4) {
                                                        ?>
                                                        <a href="javascript:void(0)" class="" 
                                                           data-toggle="modal" 
                                                           data-target="#changeRole1<?php echo $value->person_id ?>">
                                                            <i title="Change Role" class="fa fa-street-view"></i>
                                                        </a>
                                                    <?php } ?>
                                                    <a href="<?php echo base_url(); ?>super-admin/edit-user-information/<?php echo $value->url; ?>"><i title="Edit" class="fa fa-edit"></i></a>
                                                    <a href="javascript:void(0)"><i onclick="checkForAction('<?php echo base_url() . 'make-user-archive/' . $value->person_id; ?>', 'Archive', '<?php echo $value->person_id; ?>')" class="fa fa-archive" title="Archive"></i></a>
                                                    <a href="javascript:void(0)"><i onclick="checkForDelete('<?php echo base_url() . 'delete-user/' . $value->url; ?>', 'Delete', '<?php echo $value->person_id; ?>')" class="fa fa-trash-o" title="Delete"></i></a>
                                                    <?php
                                                    if (in_array($value->person_role, [3, 4])) {
                                                        ?>
                                                        <a href="<?php echo base_url(); ?>admin/view-payment-method/<?php echo $value->url; ?>"><i title="Pyment Details" class="fa fa-money"></i></a>
                                                    <?php } ?>
                                                    <a href="<?php echo base_url(); ?>super-admin/view-detail/<?php echo $value->url; ?>"><i title="View Details" class="fa fa-th"></i></a>
                                                    <?php
                                                }
                                                break;
                                            case 1:
                                                if ($value->person_id == $person_id) {
                                                    ?>
                                                    <a href="<?php echo base_url(); ?>super-admin/edit-user-information/<?php echo $value->url; ?>"><i title="Edit" class="fa fa-edit"></i></a>
                                                    <a href="<?php echo base_url(); ?>super-admin/view-detail/<?php echo $value->url; ?>"><i title="View Details" class="fa fa-th"></i></a>
                                                    <?php
                                                } else {
                                                    if ($value->person_role == 6) {
                                                        ?>
                                                        <a href="<?php echo base_url(); ?>super-admin/view-detail/<?php echo $value->url; ?>"><i title="View Details" class="fa fa-th"></i></a>
                                                        <?php
                                                    } else {
                                                        if ($value->person_status != 1) {
                                                            ?>
                                                            <a href="javascript:void(0)" onclick="checkForAction('<?php echo base_url() . 'make-user-active/' . $value->person_id; ?>', 'Active', '<?php echo $value->person_id; ?>')"><i title="Active" class="fa fa-user-plus"></i></a>
                                                        <?php } else {
                                                            ?>
                                                            <a href="javascript:void(0)" onclick="checkForAction('<?php echo base_url() . 'make-user-inactive/' . $value->person_id; ?>', 'Inactive', '<?php echo $value->person_id; ?>')"><i title="Inactive" class="fa fa-user-times"></i></a>
                                                            <?php
                                                        }
                                                        if ($value->person_role != 6 && $value->person_role != 1 && $value->person_role != 4) {
                                                            ?>
                                                            <a href="javascript:void(0)" class="" data-toggle="modal" 
                                                               data-target="#changeRole1<?php echo $value->person_id ?>">
                                                                <i title="Change Role" class="fa fa-street-view"></i>
                                                            </a>
                                                        <?php } ?>
                                                        <a href="<?php echo base_url(); ?>super-admin/edit-user-information/<?php echo $value->url; ?>"><i title="Edit" class="fa fa-edit"></i></a>
                                                        <a href="javascript:void(0)"><i onclick="checkForAction('<?php echo base_url() . 'make-user-archive/' . $value->person_id; ?>', 'Archive', '<?php echo $value->person_id; ?>')" class="fa fa-archive" title="Archive"></i></a>
                                                        <?php
                                                        if (in_array($value->person_role, [3, 4])) {
                                                            ?>
                                                            <a href="<?php echo base_url(); ?>admin/view-payment-method/<?php echo $value->url; ?>"><i title="Pyment Details" class="fa fa-money"></i></a>
                                                        <?php } ?>
                                                        <a href="<?php echo base_url(); ?>super-admin/view-detail/<?php echo $value->url; ?>"><i title="View Details" class="fa fa-th"></i></a>
                                                        <?php
                                                    }
                                                }
                                                break;
                                        }
                                    }
                                    if ($value->person_id != $person_id) {
                                        $id = $this->encryption->encrypt($value->person_id);
                                        $p_id = str_replace("/", "%F2", $id);
                                    ?>
                                    <a href="<?php echo base_url(); ?>super-admin/security-reset-password/<?php echo $p_id; ?>"><i title="Send Email for Security Reset Password" class="fa fa-envelope"></i></a>
                                    <?php } ?>
                                </div>
                            </div>
                            <div class="col-sm-12"><br></div>
                            <?php
                            $i++;
                            ?>




                            <!---------------------------Start Change Role Modal -------------------------->

                            <div class="modal fade" id="changeRole1<?php echo $value->person_id ?>" tabindex="-1" role="dialog" aria-labelledby="changeRole" aria-hidden="true">
                                <div class="modal-dialog">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                            <h4 class="modal-title" id="myModalLabel">Change Role</h4>
                                        </div>
                                        <div class="modal-body form-group col-sm-12">
                                            <label for="person_role_modal_input1">User role:</label><span>*</span>
                                            <select class="form-control validate[required]"
                                                    onchange="getRoleValue(this.value, '<?php echo $value->person_id; ?>')"
                                                    name="person_role_modal_input1<?php echo $value->person_id; ?>" 
                                                    id="person_role_modal_input1<?php echo $value->person_id; ?>">
                                                <option value="">--Select User Type--</option>
                                                <?php
                                                switch ($value->person_role) {
                                                    case 1:
                                                        if ($person_role == 6) {
                                                            echo '<option value="6">Super Admin</option>';
                                                        }
                                                        break;
                                                    case 2:
                                                        if ($person_role == 6) {
                                                            echo '<option value="6">Super Admin</option>';
                                                        }
                                                        echo '<option value="1">Admin</option>';
                                                        break;
                                                    case 3:
                                                        echo '<option value="4">Organization</option>';
                                                        break;
                                                    case 5:
                                                        echo '<option value="4">Organization</option>';
                                                        echo '<option value="3">Individual Trainer</option>';
                                                        break;
                                                    case 7:
                                                        echo '<option value="6">Super Admin</option>
                                               <option value="1">Admin</option>
                                               <option value="2">Account Officer</option>
                                               <option value="4">Organization</option>
                                               <option value="3">Individual Trainer</option>
                                               <option value="5">Learner</option>';
                                                        break;
                                                }
                                                ?>
                                            </select>
                                            <span id="modal_person_role_error<?php echo $value->person_id; ?>" style="color:red"><?php echo form_error('person_role'); ?></span>
                                        </div>


                                        <div class="form-group col-sm-12" id="roleResourcePersonType<?php echo $value->person_id; ?>" style="display: none;">
                                            <label class="col-sm-4" for="resource_person_type"> Talha Training  :  &nbsp;&nbsp;</label>
                                            <div class="radio radio-success col-sm-6 margin-zero">
                                                <input type="radio"
                                                       data-errormessage-value-missing="Please Select Resourse Person Type"
                                                       class="validate[required]" 
                                                       name="resource_person_type<?php echo $value->person_id; ?>" 
                                                       id="resource_person_type<?php echo $value->person_id; ?>" 
                                                       value="1">
                                                <label for="yes">Yes</label>
                                                <span style="margin-right: 30px"></span>
                                                <input type="radio"
                                                       data-errormessage-value-missing="Please Select Resourse Person Type"
                                                       class="validate[required]" 
                                                       name="resource_person_type<?php echo $value->person_id; ?>" 
                                                       id="resource_person_type<?php echo $value->person_id; ?>" 
                                                       value="2">
                                                <label for="no">No</label>
                                            </div>
                                        </div>
                                        <span class="col-sm-12" id="modal_resource_person_type_error<?php echo $value->person_id; ?>" style="color:red; margin-top: -20px; margin-left: 20px;"></span>


                                        <div class="modal-body form-group col-sm-12" id="organization_view_modal<?php echo $value->person_id; ?>" style="display:none">
                                            <div class="form-group col-sm-6" id="organization_name_form">
                                                <input type="text" 
                                                       data-errormessage-value-missing="Organization Name is required!"
                                                       class="form-control text-input" 
                                                       name="organization_name<?php echo $value->person_id; ?>"
                                                       id="organization_name<?php echo $value->person_id; ?>"
                                                       oninput="checkOrganizationName(this.value,'<?php echo $value->person_id; ?>')"
                                                       value=""
                                                       maxlength="150"
                                                       placeholder="Please type your Organization Name">
                                                <span class="col-sm-12" id="organization_name_error<?php echo $value->person_id; ?>" style="color:red"></span>
                                            </div>

                                            <div class="form-group col-sm-6">
                                                <input name="organization_code_status_value" id="organization_code_status_value" type="hidden" value="1">
                                                <input type="text" 
                                                       data-errormessage-value-missing="Organization Code is required!"
                                                       class="form-control  text-input" 
                                                       name="organization_code<?php echo $value->person_id; ?>"
                                                       id="organization_code<?php echo $value->person_id; ?>"
                                                       oninput="checkOrganizationCode(this.value,'<?php echo $value->person_id; ?>')"
                                                       value=""
                                                       maxlength="25"
                                                       placeholder="Please type your Organization code">
                                                <span class="col-sm-12" id="organization_code_error<?php echo $value->person_id; ?>" style="color:red"></span>
                                                <input type="hidden" id="code_status<?php echo $value->person_id; ?>" value="">
                                            </div>
                                        </div>


                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
                                            <button type="button" 
                                                    id="changeRoleButton" 
                                                    onclick="return validateUserRole('<?php echo $value->person_id; ?>', '<?php echo $value->person_role; ?>')"
                                                    class="btn btn-default" >Save changes</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!---------------------------End Change Role Modal -------------------------->

                            <?php
                        }
                        ?>

                        <div class="col-sm-12"><br></div> 
                    </form>


                    <!--------------------Start Pagination---------------------------->
                    <div class="col-sm-12">
                        <?php
                        $total_page = ceil($total_user->total_user / $per_page_view);
                        if ($total_page > 1) {
                            ?>
                            <div class="col-sm-2 form-group" style="margin-top: 22px;">
                                <select onchange="getPerPageValue(this.value)"
                                        class="form-control">
                                    <option value="10">10</option>
                                    <option value="25">25</option>
                                    <option value="50">50</option>
                                    <option value="100">100</option>
                                    <option value="500">500</option>
                                </select>
                            </div>
                            <?php
                        }
                        ?>
                        <div class="col-sm-9 form-group">
                            <?php
                            if ($total_page > 1) {
                                ?>
                                <nav class="course-pagination">
                                    <ul class="pagination">
                                        <?php
                                        if ($page > 2) {
                                            ?>
                                            <li>
                                                <a <?php
                                                switch ($selected_person_role) {
                                                    case 6:
                                                        echo 'href=' . base_url() . 'super-admin-user/';
                                                        break;
                                                    case 1:
                                                        echo 'href=' . base_url() . 'admin-user/';
                                                        break;
                                                    case 2:
                                                        echo 'href=' . base_url() . 'account-officer/';
                                                        break;
                                                    case 3:
                                                        echo 'href=' . base_url() . 'individual-teacher/';
                                                        break;
                                                    case 4:
                                                        echo 'href=' . base_url() . 'organization/';
                                                        break;
                                                    case 5:
                                                        echo 'href=' . base_url() . 'learner/';
                                                        break;
                                                    case 7:
                                                        echo 'href=' . base_url() . 'no-role-user/';
                                                        break;

                                                    default:
                                                        echo 'href=' . base_url() . 'super-admin/all-user/';
                                                        break;
                                                }
                                                ?>
                                                    aria-label="Previous">
                                                    <span aria-hidden="true" title="First Page">&laquo;&laquo;</span>
                                                </a>
                                            </li>
                                            <li>
                                                <a <?php
                                                switch ($selected_person_role) {
                                                    case 6:
                                                        echo 'href=' . base_url() . 'super-admin-user/' . ($page - 1);
                                                        break;
                                                    case 1:
                                                        echo 'href=' . base_url() . 'admin-user/' . ($page - 1);
                                                        break;
                                                    case 2:
                                                        echo 'href=' . base_url() . 'account-officer/' . ($page - 1);
                                                        break;
                                                    case 3:
                                                        echo 'href=' . base_url() . 'individual-teacher/' . ($page - 1);
                                                        break;
                                                    case 4:
                                                        echo 'href=' . base_url() . 'organization/' . ($page - 1);
                                                        break;
                                                    case 5:
                                                        echo 'href=' . base_url() . 'learner/' . ($page - 1);
                                                        break;
                                                    case 7:
                                                        echo 'href=' . base_url() . 'no-role-user/' . ($page - 1);
                                                        break;

                                                    default:
                                                        echo 'href=' . base_url() . 'super-admin/all-user/' . ($page - 1);
                                                        break;
                                                }
                                                ?> 
                                                    aria-label="Previous">
                                                    <span aria-hidden="true" title="Previous Page">&laquo;</span>
                                                </a>
                                            </li>
                                        <?php } elseif ($page > 1) { ?>
                                            <li>
                                                <a <?php
                                                switch ($selected_person_role) {
                                                    case 6:
                                                        echo 'href=' . base_url() . 'super-admin-user/' . ($page - 1);
                                                        break;
                                                    case 1:
                                                        echo 'href=' . base_url() . 'admin-user/' . ($page - 1);
                                                        break;
                                                    case 2:
                                                        echo 'href=' . base_url() . 'account-officer/' . ($page - 1);
                                                        break;
                                                    case 3:
                                                        echo 'href=' . base_url() . 'individual-teacher/' . ($page - 1);
                                                        break;
                                                    case 4:
                                                        echo 'href=' . base_url() . 'organization/' . ($page - 1);
                                                        break;
                                                    case 5:
                                                        echo 'href=' . base_url() . 'learner/' . ($page - 1);
                                                        break;
                                                    case 7:
                                                        echo 'href=' . base_url() . 'no-role-user/' . ($page - 1);
                                                        break;

                                                    default:
                                                        echo 'href=' . base_url() . 'super-admin/all-user/' . ($page - 1);
                                                        break;
                                                }
                                                ?>  
                                                    aria-label="Previous">
                                                    <span aria-hidden="true" title="Previous Page">&laquo;</span>
                                                </a>
                                            </li>
                                            <?php
                                        }
                                        $count_page = 0;
                                        if ($total_page < 10) {
                                            for ($i = $page; $total_page >= $i; $i++) {
                                                ?>
                                                <li>
                                                    <a <?php
                                                    if ($page == $i) {
                                                        echo 'style="background-color:#80c12c; color:#fff;"';
                                                    }
                                                    ?>
                                                    <?php
                                                    switch ($selected_person_role) {
                                                        case 6:
                                                            echo 'href=' . base_url() . 'super-admin-user/' . $i;
                                                            break;
                                                        case 1:
                                                            echo 'href=' . base_url() . 'admin-user/' . $i;
                                                            break;
                                                        case 2:
                                                            echo 'href=' . base_url() . 'account-officer/' . $i;
                                                            break;
                                                        case 3:
                                                            echo 'href=' . base_url() . 'individual-teacher/' . $i;
                                                            break;
                                                        case 4:
                                                            echo 'href=' . base_url() . 'organization/' . $i;
                                                            break;
                                                        case 5:
                                                            echo 'href=' . base_url() . 'learner/' . $i;
                                                            break;
                                                        case 7:
                                                            echo 'href=' . base_url() . 'no-role-user/' . $i;
                                                            break;

                                                        default:
                                                            echo 'href=' . base_url() . 'super-admin/all-user/' . $i;
                                                            break;
                                                    }
                                                    ?> >
                                                            <?php echo $i ?>
                                                    </a>
                                                </li>
                                                <?php
                                            }
                                        } else if ($page + 10 <= $total_page) {
                                            $count_page = $page + 10;
                                            for ($i = $page; $count_page > $i; $i++) {
                                                ?>
                                                <li>
                                                    <a <?php
                                                    if ($page == $i) {
                                                        echo 'style="background-color:#80c12c; color:#fff;"';
                                                    }
                                                    ?>
                                                    <?php
                                                    switch ($selected_person_role) {
                                                        case 6:
                                                            echo 'href=' . base_url() . 'super-admin-user/' . $i;
                                                            break;
                                                        case 1:
                                                            echo 'href=' . base_url() . 'admin-user/' . $i;
                                                            break;
                                                        case 2:
                                                            echo 'href=' . base_url() . 'account-officer/' . $i;
                                                            break;
                                                        case 3:
                                                            echo 'href=' . base_url() . 'individual-teacher/' . $i;
                                                            break;
                                                        case 4:
                                                            echo 'href=' . base_url() . 'organization/' . $i;
                                                            break;
                                                        case 5:
                                                            echo 'href=' . base_url() . 'learner/' . $i;
                                                            break;
                                                        case 7:
                                                            echo 'href=' . base_url() . 'no-role-user/' . $i;
                                                            break;

                                                        default:
                                                            echo 'href=' . base_url() . 'super-admin/all-user/' . $i;
                                                            break;
                                                    }
                                                    ?> >
                                                            <?php echo $i ?>
                                                    </a>
                                                </li>
                                                <?php
                                            }
                                        } else {
                                            for ($i = $total_page - 10; $total_page > $i; $i++) {
                                                ?>
                                                <li>
                                                    <a <?php
                                                    if ($page == $i + 1) {
                                                        echo 'style="background-color:#80c12c; color:#fff;"';
                                                    }
                                                    ?>
                                                    <?php
                                                    switch ($selected_person_role) {
                                                        case 6:
                                                            echo 'href=' . base_url() . 'super-admin-user/' . ($i + 1);
                                                            break;
                                                        case 1:
                                                            echo 'href=' . base_url() . 'admin-user/' . ($i + 1);
                                                            break;
                                                        case 2:
                                                            echo 'href=' . base_url() . 'account-officer/' . ($i + 1);
                                                            break;
                                                        case 3:
                                                            echo 'href=' . base_url() . 'individual-teacher/' . ($i + 1);
                                                            break;
                                                        case 4:
                                                            echo 'href=' . base_url() . 'organization/' . ($i + 1);
                                                            break;
                                                        case 5:
                                                            echo 'href=' . base_url() . 'learner/' . ($i + 1);
                                                            break;
                                                        case 7:
                                                            echo 'href=' . base_url() . 'no-role-user/' . ($i + 1);
                                                            break;

                                                        default:
                                                            echo 'href=' . base_url() . 'super-admin/all-user/' . ($i + 1);
                                                            break;
                                                    }
                                                    ?> > 
                                                            <?php echo ($i + 1) ?>
                                                    </a>
                                                </li>
                                                <?php
                                            }
                                        }

                                        if ($total_page > $page + 10) {
                                            ?>
                                            <li>
                                                <a <?php
                                                switch ($selected_person_role) {
                                                    case 6:
                                                        echo 'href=' . base_url() . 'super-admin-user/' . ($page + 1);
                                                        break;
                                                    case 1:
                                                        echo 'href=' . base_url() . 'admin-user/' . ($page + 1);
                                                        break;
                                                    case 2:
                                                        echo 'href=' . base_url() . 'account-officer/' . ($page + 1);
                                                        break;
                                                    case 3:
                                                        echo 'href=' . base_url() . 'individual-teacher/' . ($page + 1);
                                                        break;
                                                    case 4:
                                                        echo 'href=' . base_url() . 'organization/' . ($page + 1);
                                                        break;
                                                    case 5:
                                                        echo 'href=' . base_url() . 'learner/' . ($page + 1);
                                                        break;
                                                    case 7:
                                                        echo 'href=' . base_url() . 'no-role-user/' . ($page + 1);
                                                        break;

                                                    default:
                                                        echo 'href=' . base_url() . 'super-admin/all-user/' . ($page + 1);
                                                        break;
                                                }
                                                ?> 

                                                    aria-label="Next">
                                                    <span aria-hidden="true" title="Next Page">&raquo;</span>
                                                </a>
                                            </li>
                                            <li>
                                                <a <?php
                                                switch ($selected_person_role) {
                                                    case 6:
                                                        echo 'href=' . base_url() . 'super-admin-user/' . $total_page;
                                                        break;
                                                    case 1:
                                                        echo 'href=' . base_url() . 'admin-user/' . $total_page;
                                                        break;
                                                    case 2:
                                                        echo 'href=' . base_url() . 'account-officer/' . $total_page;
                                                        break;
                                                    case 3:
                                                        echo 'href=' . base_url() . 'individual-teacher/' . $total_page;
                                                        break;
                                                    case 4:
                                                        echo 'href=' . base_url() . 'organization/' . $total_page;
                                                        break;
                                                    case 5:
                                                        echo 'href=' . base_url() . 'learner/' . $total_page;
                                                        break;
                                                    case 7:
                                                        echo 'href=' . base_url() . 'no-role-user/' . $total_page;
                                                        break;

                                                    default:
                                                        echo 'href=' . base_url() . 'super-admin/all-user/' . $total_page;
                                                        break;
                                                }
                                                ?>  
                                                    aria-label="Next">
                                                    <span aria-hidden="true" title="Last Page">&raquo;&raquo;</span>
                                                </a>
                                            </li>
                                        <?php } ?>
                                    </ul>
                                </nav>
                            <?php } ?>
                        </div>
                    </div>
                </div>

                <?php include 'admin_modal_view/modal_change_status.php'; ?>
                <?php include 'admin_modal_view/modal_user_import.php'; ?>

                <div class="col-sm-12 "><br></div>
                <div class="col-sm-12 gray" style="padding-left: 10px">
                    <a href="<?php echo base_url(); ?>super-admin">Dashboard</a>->> <span> All-user </span>
                </div>
                <div class="col-sm-12 "><br></div>

            </div>
        </div>
    </div>
</div>
<script>
    function sendMailToUser() {
        var xmlhttp = false;
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp = false;
            }
        }
        if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
            xmlhttp = new XMLHttpRequest();
        }
        var url= '<?php echo base_url();?>'+'encypt-data';
      //  var message_id=messageId;
     //   alert(message_id);
        
        var formdata = new FormData();
        formdata.append("person_id",list_array);
      
        
        xmlhttp.addEventListener("load", function () {
            //alert(xmlhttp.responseText);
          var url= '<?php echo base_url().'super-admin-send-email-temp/' ?>'+xmlhttp.responseText;
             window.location.href = url;
              
            }, false);
            xmlhttp.addEventListener("error", function () {
                alert("not sent");
            }, false);
            xmlhttp.addEventListener("abort", function () {
                alert("Aborted");
            }, false);

            xmlhttp.open("POST", url);
            xmlhttp.send(formdata);

    }
</script>
<script>
    var list = '';
    var list_array = new Array();
    function toggleAllUserSelection(field) {
        var allList = document.getElementById("all_list").checked;
        if (allList) {
            for (i = 0; i < field.length; i++) {
                field[i].checked = true;
                list += field[i].value + '.';
                list_array.push(field[i].value);
            }
        } else {
            for (i = 0; i < field.length; i++)
                field[i].checked = false;
            list = '';
            list_array = [];
        }
    }
    function setUserIdList(userID) {
        if (document.getElementById("person_id" + userID).checked) {
            list += userID + '.';
            list_array.push(userID);
        } else {
            list = list.replace(userID + ".", "");
            var index = list_array.indexOf(userID);
            list_array.splice(index, 1);
        }
    }


    function getPerPageValue(inputValue) {
        var xmlhttp;
        xmlhttp = checkXMLHTTP(xmlhttp);

        var serverPage = '<?php echo base_url(); ?>get-perpage-value/' + inputValue;  // passing person_organization_code Field value 
        xmlhttp.open("GET", serverPage);
        xmlhttp.onreadystatechange = function ()
        {
            if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
            {
                documentID('user_list').innerHTML = xmlhttp.responseText;
                documentID('perPageValue').value = inputValue;
            }
        };
        xmlhttp.send(null);
    }



    function getHeaderRoleValue(roleInput) {
        var xmlhttp;
        var personRole;
        xmlhttp = checkXMLHTTP(xmlhttp);
        if (roleInput === '') {
            personRole = 'null';
        } else {
            personRole = roleInput;
        }

        var serverPage = '<?php echo base_url(); ?>get-header-role-value/' + personRole;  // passing person_organization_code Field value 
        xmlhttp.open("GET", serverPage);
        xmlhttp.onreadystatechange = function ()
        {
            if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
            {
                documentID('user_list').innerHTML = xmlhttp.responseText;
                getViewUpperButton(personRole);
            }
        };
        xmlhttp.send(null);
    }

    function getViewUpperButton() {
        var xmlhttp5;
        xmlhttp5 = checkXMLHTTP(xmlhttp5);

        var serverPage = '<?php echo base_url(); ?>get-view-upper-button';  // passing person_organization_code Field value 
        xmlhttp5.open("GET", serverPage);
        xmlhttp5.onreadystatechange = function ()
        {
            if (xmlhttp5.readyState === 4 && xmlhttp5.status === 200)
            {
                documentID('view_upper_button').innerHTML = xmlhttp5.responseText;
            }
        };
        xmlhttp5.send(null);
    }


    function getStatusValue(statusInput) {
        var xmlhttp;
        xmlhttp = checkXMLHTTP(xmlhttp);

        var personStatus;
        if (statusInput === '') {
            personStatus = 'null';
        } else {
            personStatus = statusInput;
        }

        var serverPage = '<?php echo base_url(); ?>get-user-status-value/' + personStatus;  // passing person_organization_code Field value 
        xmlhttp.open("GET", serverPage);
        xmlhttp.onreadystatechange = function ()
        {
            if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
            {
                documentID('user_list').innerHTML = xmlhttp.responseText;
            }
        };
        xmlhttp.send(null);
    }

</script>

<SCRIPT LANGUAGE="JavaScript">
    function showimage(src, ID) {
        var img = document.createElement("img");
        img.src = src;
        img.width = 50;
        img.height = 50;
        document.getElementById('show_image' + ID).appendChild(img);
    }

    function checkOrganizationName(input, ID) {
        if (input != '') {
            documentID('organization_name_error' + ID).innerHTML = '';
        }
    }

    function checkOrganizationCode(input, ID) {
        var xmlhttp;
        xmlhttp = checkXMLHTTP(xmlhttp);
        if (input != '') {
            documentID('organization_code_error' + ID).innerHTML = '';

            var serverPage = '<?php echo base_url(); ?>super_admin/check_user_organization_code/' + input;  // passing person_organization_code Field value 
            xmlhttp.open("GET", serverPage);
            xmlhttp.onreadystatechange = function ()
            {
                if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
                {
                    //                                            alert(xmlhttp.status);
                    if (xmlhttp.responseText == 1) {
                        documentID('organization_code_error' + ID).innerHTML = 'Organization Code Exists';
                        documentID('code_status' + ID).value = 1;
                    } else if (xmlhttp.responseText == 2)
                    {
                        documentID('organization_code_error' + ID).innerHTML = '';
                    }
                }
            };
            xmlhttp.send(null);
        }
    }

    function validateUserRole(ID, personRole) {
        var spaceRegx = / +/g;
        var xmlhttp;
        xmlhttp = checkXMLHTTP(xmlhttp);
        var formdata = new FormData();
        var userRole = documentID('person_role_modal_input1' + ID).value;
        if (userRole === '') {
            documentID('modal_person_role_error' + ID).innerHTML = "Please select Person Role";
            return false;
        } else {
            documentID('modal_person_role_error' + ID).innerHTML = '';

            if (userRole == '3') {
                var resourcePersonName = document.getElementsByName('resource_person_type' + ID);
                var resourcePersonType = '';
                for (var i = 0; i < resourcePersonName.length; i++) {
                    if (resourcePersonName[i].checked) {
                        resourcePersonType = resourcePersonName[i].value;
                    }
                }
                if (resourcePersonType === '') {
                    documentID('modal_resource_person_type_error' + ID).innerHTML = "Please select resource person type";
                    return false;
                } else {
                    documentID('modal_resource_person_type_error' + ID).innerHTML = '';
                    formdata.append("resource_person_type", resourcePersonType);
                }
            }
            if (userRole == '4') {
                var organizationName = documentID('organization_name' + ID).value;
                var organizationCode = documentID('organization_code' + ID).value;
                var codeStatus = documentID('code_status' + ID).value;

                if (organizationName === '') {
                    documentID('organization_name_error' + ID).innerHTML = 'Please select organization name';
                    return false;
                } else {
                    documentID('organization_name_error' + ID).innerHTML = '';
                    formdata.append("organization_name", organizationName);
                }

                if (organizationCode === '') {
                    documentID('organization_code_error' + ID).innerHTML = 'Please select organization Code';
                    return false;
                } else if (codeStatus == '1') {
                    documentID('organization_code_error' + ID).innerHTML = 'Organization Code Exists';
                    return false;
                } else if (spaceRegx.test(organizationCode)) {
                    documentID('organization_code_error' + ID).innerHTML = 'no Space allow';
                    return false;
                } else {
                    documentID('organization_code_error' + ID).innerHTML = '';
                    formdata.append("organization_code", organizationCode);
                }
            }
        }

        formdata.append("person_role", userRole);


        xmlhttp.addEventListener("load", function () {
            var errorMessage = xmlhttp.responseText;
            if (errorMessage == 'success') {
                var url = '';

                switch (userRole) {
                    case '6':
                        url = '<?php echo base_url() . 'super-admin-user'; ?>';
                        break;
                    case '1':
                        url = '<?php echo base_url() . 'admin-user'; ?>';
                        break;
                    case '2':
                        url = '<?php echo base_url() . 'account-officer'; ?>';
                        break;
                    case '3':
                        url = '<?php echo base_url() . 'individual-teacher'; ?>';
                        break;
                    case '4':
                        url = '<?php echo base_url() . 'organization'; ?>';
                        break;
                    case '5':
                        url = '<?php echo base_url() . 'learner'; ?>';
                        break;
                }

                window.location.href = url;
//                location.reload();
            } else {
                if (errorMessage.indexOf('startRole>') === 0) {
                    documentID('modal_person_role_error' + ID).innerHTML = "Please select Person Role";
                } else {
                    if (errorMessage.indexOf('startResourcePersonType>') === 0) {
                        documentID('modal_resource_person_type_error' + ID).innerHTML = "Please select resource person type";
                    } else {
                        documentID('modal_resource_person_type_error' + ID).innerHTML = "";
                    }

                    if (errorMessage.indexOf('startOrgName>') === 0) {
                        documentID('organization_name_error' + ID).innerHTML = errorMessage.substring((errorMessage.indexOf("startOrgCode>") + ("startOrgCode>").length), errorMessage.indexOf("<endOrgCode"));
                    } else {
                        documentID('organization_name_error' + ID).innerHTML = "";
                    }

                    if (errorMessage.indexOf('startOrgCode>') === 0) {
                        documentID('organization_code_error' + ID).innerHTML = errorMessage.substring((errorMessage.indexOf("startOrgCode>") + ("startOrgCode>").length), errorMessage.indexOf("<endOrgCode"));
                    } else {
                        documentID('organization_code_error' + ID).innerHTML = "";
                    }
                }
            }

            xmlhttp.send(null);
        }, false);

        xmlhttp.open("POST", '<?php echo base_url() . 'change-user-role/' ?>' + ID + '/' + personRole);
        xmlhttp.send(formdata);
        return true;
    }


//    function changeUsersRole(userRoleId) {
//        if (userRoleId === '') {
//            documentID('header_person_role_error').innerHTML = 'Please select Person role';
//            return false;
//        } else {
//            documentID('header_person_role_error').innerHTML = '';
//        }
//
//        if (list_array.length <= 0) {
//            documentID('header_person_role_error').innerHTML = 'Please select at least one user';
//            return false;
//        } else {
//            documentID('header_person_role_error').innerHTML = '';
//        }
//
//        var xmlhttp;
//        xmlhttp = checkXMLHTTP(xmlhttp);
//        var serverPage = '<?php echo base_url(); ?>change-header-role-status/' + list_array + '/' + userRoleId;
//        xmlhttp.open("GET", serverPage);
//        xmlhttp.onreadystatechange = function ()
//        {
//            if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
//            {
//                var message = xmlhttp.responseText;
//                if (message === 'success') {
//                    var url = '';
//                    switch (userRoleId) {
//                        case '6':
//                            url = '<?php echo base_url() . 'super-admin-user'; ?>';
//                            break;
//                        case '1':
//                            url = '<?php echo base_url() . 'admin-user'; ?>';
//                            break;
//                        case '2':
//                            url = '<?php echo base_url() . 'account-officer'; ?>';
//                            break;
//                        case '3':
//                            url = '<?php echo base_url() . 'individual-teacher'; ?>';
//                            break;
//                        case '4':
//                            url = '<?php echo base_url() . 'organization'; ?>';
//                            break;
//                        case '5':
//                            url = '<?php echo base_url() . 'learner'; ?>';
//                            break;
//                    }
//                    window.location.href = url;
//                }
//            }
//        };
//        xmlhttp.send(null);
//    }

    function getRoleValue(input, ID) {
        if (input == 4) {
            documentID('organization_view_modal' + ID).style.display = 'block';
            documentID('roleResourcePersonType' + ID).style.display = 'none';
        } else if ((input == 3)) {
            documentID('roleResourcePersonType' + ID).style.display = 'block';
            documentID('organization_view_modal' + ID).style.display = 'none';
        } else {
            documentID('roleResourcePersonType' + ID).style.display = 'none';
            documentID('organization_view_modal' + ID).style.display = 'none';
        }
    }


    document.forms['control_form'].elements['user_role_id2'].value = '<?php echo $role_id; ?>';
    document.forms['control_form'].elements['user_status'].value = '<?php echo $status; ?>';


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



    function changeUsersStatus(inputStatus, loginPersonID) {
        if (inputStatus === '') {
            documentID('header_person_status_error').innerHTML = 'Please select person status';
            return false;
        } else {
            documentID('header_person_status_error').innerHTML = '';
        }

        if (list_array.length <= 0) {
            documentID('header_person_status_error').innerHTML = 'Please select at least one user';
            return false;
        } else {
            documentID('header_person_status_error').innerHTML = '';
        }

        if (list_array.indexOf(loginPersonID) >= 0) {
            documentID('header_person_status_error').innerHTML = 'You can not change own status';
            return false;
        } else {
            documentID('header_person_status_error').innerHTML = '';
        }

        var xmlhttp;
        xmlhttp = checkXMLHTTP(xmlhttp);
        var serverPage = '<?php echo base_url(); ?>change-header-status/' + list_array + '/' + inputStatus + '/' + <?php echo $person_id; ?>;
        xmlhttp.open("GET", serverPage);
        xmlhttp.onreadystatechange = function ()
        {
            if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
            {
                var message = xmlhttp.responseText;
                if (message === 'super_admin') {
                    documentID('header_person_status_error').innerHTML = 'You can not change super admin status';
                    return false;
                } else if (message === 'self_id') {
                    documentID('header_person_status_error').innerHTML = 'You can not change own status';
                    return false;
                } else {
                    location.reload();
                }
            }
        };
        xmlhttp.send(null);
    }



    function checkForAction(url, action, ID) { // check for Active Inactives
        var xmlhttp;
        xmlhttp = checkXMLHTTP(xmlhttp);

        swal({
            title: "",
            text: "Are you sure you want to " + action + " this Person?",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: '#80c12c',
            confirmButtonText: 'Yes',
            cancelButtonText: "No",
            closeOnConfirm: true,
            closeOnCancel: true
        },
                function (isConfirm) {
                    if (isConfirm) {
                        xmlhttp.open("GET", url);
                        xmlhttp.onreadystatechange = function ()
                        {
                            if (xmlhttp.readyState === 4 && xmlhttp.status === 200)
                            {
                                document.getElementById("action" + ID).innerHTML = xmlhttp.responseText;
                            }
                        };
                        xmlhttp.send(null);
                    }
                });
    }
    function checkForDelete(url, action, ID) {
        swal({
            title: "",
            text: "Are you sure you want to " + action + " this Person?",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: '#80c12c',
            confirmButtonText: 'Yes',
            cancelButtonText: "No",
            closeOnConfirm: true,
            closeOnCancel: true
        },
                function (isConfirm) {
                    if (isConfirm) {
                        window.location = url;
                    }
                });
    }
    $(document.forms['changeStatus']).submit(function (event) {
        event.preventDefault();
    });


</script>
