<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
    <div class="">
        <a href="<?php echo base_url(); ?>super_admin">Dashboard <?php // echo $person_role;        ?></a>->>
        <a href="<?php echo base_url(); ?>super_admin/user_list/<?php echo $role_name . '/' . $this->session->userdata('role_id'); ?>"><?php echo $role_name; ?> List</a>->>
        <a href="<?php echo base_url(); ?>super_admin/view_detail/<?php echo $role_name . '/' . $person_id; ?>"><?php echo $role_name; ?> Detail</a>->>
        <span>Work Experience Details</span>
    </div>
    <a style="float: left;" onclick="addWork();" class="btn btn-sm btn-success"> Add Work Experience</a>
    <p>
        <?php
        $message = $this->session->userdata('message');
        $this->session->unset_userdata('message');
        if ($message) {
            echo $message;
        }
        ?>
    </p>

    <div class="table-responsive col-sm-8" style="display:none;" id="work_form">
        <script>
            function addWork() {
                var educationForm = document.getElementById('work_form');
                educationForm.setAttribute("style", 'display:block; ');
            }
        </script>

        <h1 class="page-header">Add Work Experience </h1>
        <form class="cmxform" id="formID2" action="<?php echo base_url(); ?>super_admin_profile/work_details/<?php echo $role_name . '/' . $person_id; ?>" method="post" name="add_work_details" enctype="multipart/form-data" >
            <input type="hidden" name="person_id" id="person_id" value="<?php echo $person_id ?>">
            <div class="form-group col-sm-12">
                <div class="form-group col-sm-8">
                    <label for="company_name">Company  Name</label><span class="required"> * </span>
                    <input  type="text" data-errormessage-value-missing="Company  Name is required!" class="form-control validate[required]" id="company_name" name="company_name" value="<?php echo set_value('company_name'); ?>" placeholder="Enter Company name">
                </div>
                <div class="form-group col-sm-8" style="color: red"><?php echo form_error('company_name'); ?>  </div>

                <div class="form-group col-sm-8">
                    <label for="designation">Designation</label><span class="required"> * </span>
                    <input type="text" data-errormessage-value-missing="Designation is required!" class="form-control validate[required]" id="designation" name="designation" value="<?php echo set_value('designation'); ?>" placeholder="Enter Designation" >
                </div>
                <div class="form-group col-sm-8" style="color: red"><?php echo form_error('designation'); ?>  </div>

                <div class="form-group col-sm-8">
                    <label for="company_address">Company Address </label><span class="required"> * </span>
                    <textarea name="company_address" data-errormessage-value-missing="Company Address is required!" class="form-control validate[required]" ><?php echo set_value('company_address'); ?></textarea>
                </div>
                <div class="form-group col-sm-8" style="color: red"><?php echo form_error('company_address'); ?>  </div>

                <div class="form-group col-sm-8">
                    <label for="company_website_url">Company Website URL</label><span class="required"> * </span>
                    <input type="text" data-errormessage-value-missing="Company  Website URL is required!" class="form-control validate[required],custom[url]" id="company_website_url" name="company_website_url" value="<?php echo set_value('company_website_url'); ?>" placeholder="Enter company website url" >
                </div>
                <div class="form-group col-sm-8" style="color: red"><?php echo form_error('company_website_url'); ?>  </div>

                <div class="form-group col-sm-8">
                    <label for="job_start_date">Job Start Date</label><span class="required"> * </span>
                    <input type="date" data-errormessage-value-missing="Job Start Date is required!" class="form-control validate[required]" id="job_start_date" name="job_start_date" value="<?php echo set_value('job_start_date'); ?>" >
                </div>
                <div class="form-group col-sm-8" style="color: red"><?php echo form_error('job_start_date'); ?>  </div>

                <div class="form-group col-sm-8">
                    <label for="job_end_date">Job End Date</label><span class="required"> * </span>
                    <input type="date" data-errormessage-value-missing="Job End Date is required!" class="form-control validate[required]" id="end_time_period" name="job_end_date" value="<?php echo set_value('job_end_date'); ?>">
                </div>
                <div class="form-group col-sm-8" style="color: red"><?php echo form_error('job_end_date'); ?>  </div>

                <div class="form-group col-sm-8">
                    <label for="work_currently_here">Work Currently Here</label><span class="required"> * </span><br>
                    <input data-errormessage-value-missing="Work Currently Here is required!" class="validate[required]" type="radio" name="work_currently_here" id="status" value="1"  />Yes
                    <input data-errormessage-value-missing="Work Currently Here is required!" class="validate[required]" type="radio" name="work_currently_here" id="status" value="0" />No
                </div>
                <div class="form-group col-sm-8" style="color: red"><?php echo form_error('work_currently_here'); ?>  </div>

                <div class="form-group col-sm-8">
                    <label for="job_responsibility_details">Job Responsibility  </label>
                    <textarea name="job_responsibility_details" class="form-control" ><?php echo set_value('job_responsibility_details'); ?></textarea>
                </div>
                <div class="form-group col-sm-8" style="color: red"><?php echo form_error('job_responsibility_details'); ?>  </div>

                <div class="form-group col-sm-8">
                    <label for="person_work_view_status">Who can see my Education details</label><span class="required"> * </span>
                    <select data-errormessage-value-missing="Who can see my Education details is required!" 
                            class="form-control validate[required]" 
                            id="person_work_view_status"  name="person_work_view_status" >
                        <option value="">--Select User--</option>
                        <option value="1">Public</option>
                        <option value="2">Talha Training User</option>
                        <option value="3">My Link</option>
                        <option value="4">Only Me</option>
                    </select>
                </div>
                <div class="form-group col-sm-8" style="color: red"><?php echo form_error('work_details_status'); ?>  </div>

            </div>


            <div class="checkbox col-sm-6" >
                <button type="submit" id="submit" class="btn btn-default">Submit</button>
                <button type="reset" class="btn btn-default">Reset</button>
            </div>
        </form>
    </div>

    <div class="table-responsive col-sm-8">

    </div>

    <div class="table-responsive col-lg-11 col-md-8 col-sm-7" id="user_list">
        <form name="myform" action=""  method="post">
            <table class="table table-striped">
                <thead>
                    <tr>
                        <th>Work Information</th>
                        <th>Address</th>
                        <th>Start Date</th>
                        <th>End Date</th>
                        <th>Job Status</th>
                        <th>View Status</th>
                        <th>Status</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody>
                    <?php
                    $i = 1;
                    foreach ($person_work_info as $v_work) {
                        ?>
                        <tr>
                            <td>
                                <?php
                                echo 'Company Name: ' . $v_work->company_name . '<br>';
                                echo 'Designation: ' . $v_work->designation . '<br>';
                                ?>
                            </td>
                            <td>
                                <?php
                                echo 'Address: <br>' . $v_work->company_address . '<br>';
                                echo 'Web Address: ' . $v_work->company_website_url . '<br>';
                                ?>
                            </td>
                            <td><?php echo $v_work->job_start_date; ?></td>
                            <td><?php echo $v_work->job_end_date; ?></td>

                            <td>
                                <?php
                                if ($v_work->work_currently_here == '0') {
                                    echo "<p style='color:Green;'>Currently not here";
                                } else if ($v_work->work_currently_here == '1') {
                                    echo "<p'>Currently Here";
                                }
                                ?>
                            </td>
                            <td><?php
                                if ($v_work->person_work_view_status == '1') {
                                    echo "<p style='color:Green;'>Public";
                                } else if ($v_work->person_work_view_status == '2') {
                                    echo "<p'>All Talhatraining User";
                                } else if ($v_work->person_work_view_status == '3') {
                                    echo "<p'>My Link";
                                } else if ($v_work->person_work_view_status == '4') {
                                    echo "<p'>Only Me";
                                }
                                ?>
                            </td>
                            <td><?php
                                if ($v_work->work_details_status == '1') {
                                    echo '<p style="color:limegreen;">Active</p>';
                                    ?>
                                    <a href="<?php echo base_url(); ?>super_admin_profile/inactive_work_detail_information/<?php echo $role_name . '/' . $person_id . '/' . $v_work->person_work_details_id; ?>"><i class="fa fa-user-times" title="Inactive"></i></a>
                                    <?php
                                } else if ($v_work->work_details_status == '0') {
                                    echo '<p style="color:red;">Inactive</p>';
                                    ?>
                                    <a href="<?php echo base_url(); ?>super_admin_profile/active_work_detail_information/<?php echo $role_name . '/' . $person_id . '/' . $v_work->person_work_details_id; ?>">
                                        <i class="fa fa-user-plus" title="Active"></i>
                                    </a>
                                    <?php
                                } else if ($v_work->work_details_status == '2') {
                                    echo '<p style="color:blue;">Archived';
                                    ?>
                                    <a href="<?php echo base_url(); ?>super_admin_profile/active_work_detail_information/<?php echo $role_name . '/' . $person_id . '/' . $v_work->person_work_details_id; ?>"><i class="fa fa-user-plus" title="Active"></i> </a>
                                <?php } ?>
                            </td>
                            <td>
                                <a href="<?php echo base_url(); ?>super_admin_profile/edit_work_information/<?php echo $role_name . '/' . $person_id . '/' . $v_work->person_work_details_id; ?>"><div class="span1"><i class="fa fa-edit">Edit</i></div></a>
                                <a href="#" onclick="viewDetail('detail', '<?php echo $v_work->person_work_details_id; ?>');">
                                    <div class="span1"><i class="fa fa-edit" id="view_action<?php echo $v_work->person_work_details_id; ?>">View</i></div></a>
                                <?php if ($v_work->work_details_status != 2) { ?>
                                    <a href="<?php echo base_url(); ?>super_admin_profile/delete_work_detail_information/<?php echo $role_name . '/' . $person_id . '/' . $v_work->person_work_details_id; ?>" onclick="deleteEducationInformation();"><div class="span1"><i class="fa fa-edit">Archive</i></div></a>
                                <?php } ?>
                            </td>

                    <script>

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

                    </script>

                    </tr>
                    <tr style="display: none;" id="detail<?php echo $v_work->person_work_details_id; ?>">
                        <td colspan="5">Job Responsibility Details: <?php echo $v_work->job_responsibility_details; ?></td>
                    </tr>
                <?php } ?>
                <script>
                    function viewDetail(objID, eID) {
                        var formStatus = document.getElementById('form_status').value;
                        if (formStatus == '') {
                            var detail = document.getElementById(objID + eID);
                            detail.setAttribute("style", 'display:block; ');
                            document.getElementById('view_action' + eID).innerHTML = 'Hide';
                            document.getElementById('form_status').value = '1';
                        } else if (formStatus == '1') {
                            var detail = document.getElementById(objID + eID);
                            detail.setAttribute("style", 'display: none; ');
                            document.getElementById('view_action' + eID).innerHTML = 'View';
                            document.getElementById('form_status').value = '';
                        }
                    }
                </script>
                </tbody>
            </table>
            <input type="hidden" name="form_status" id="form_status" value="">
            <br>
        </form>

    </div>


</div>
</div>


<script type="text/javascript">
    document.forms['userForm'].elements['person_work_view_status'].value = '<?php echo set_value('person_work_view_status'); ?>';
</script>