<?php 
$admin = $this->session->userdata('isAdmin');
$userRole = $this->session->userdata('userRole');
$id = $this->session->userdata('id');
if(!$admin && $userRole == 1 && $id != $cvid){
redirect("dashboard/home");
$this->session->set_flashdata('message', display('Access not granted'));
}

?>


<!--  table area -->
<div class="col-sm-12">

    <div class="panel panel-bd">

        <div class="panel-heading panel-aligner">
            <div class="panel-title">
                <h4>Staff Duties/Responsibilites </h4>
            </div>
            <div class="mr-25">
                <h4>Staff Designation:</h4>
                <select id="staff-status" name="staff_status" class="form-control"  onchange="showRows()">
                    <option value="">Select Designation</option>
                    <?php foreach ($designation as $desig) { ?>
                    <?php if($desig->pos_id == $pos_id) { ?>
                    <option id="staffStatus" value="<?php echo $desig->position_name; ?>">
                        <?php echo $desig->position_name; ?>
                    </option>
                    <?php break; } ?>
                    <?php } ?>
                </select>
            </div>


        </div>
        <div class="panel-body">
            <?php echo form_open('employee/Employees/updateDuties/', 'id="updateDuties" novalidate'); ?>
            <input type="hidden" name="employee_id" value="<?php echo $cvid ?>">
            <div class="row" id="preliminary">
                <div class="table-responsive">
                    <table class="table table-bordered" id="request_table_dev_plan">
                        <thead>
                            <tr>
                                <th width="25%"><span id="junior1">DUTIES AND RESPONSIBILITES</span><span
                                        id="junior_1">SPECIAL CONTRIBUTIONS MADE TO ACTIVITIES</span></th>
                                <th width="25%"><span id="junior2">SPECIAL CONTRIBUTIONS MADE TO
                                        ACTIVITIES</span><span id="junior_2">IMPROVEMENT TO BE ON UNFAVOURABLE
                                        REPORT</span></th>
                                <th width="25%">CONDITION THAT FACILITATED YOUR PERFORMANCE</th>
                                <th width="25%">CONDITIONS THAT HINDERED ACHIEVING BETTER PERFORMANCE</th>


                            </tr>
                        </thead>
                        <tbody id="key_duties_res">
                            <?php foreach ($emp_exp as $key => $row) { 
                                     $key_goals_data_array = json_decode($row->key_duties_res, true);
        
                                     // Check if the decoded data is an array
                                        if (is_array($key_goals_data_array)) {
                                            foreach ($key_goals_data_array as $duty) { ?>
                            <tr>
                                <td><textarea name="duties_responsibilites[]" class="form-control"
                                        placeholder=""><?= $duty['duties_responsibilites'] ?? '' ?></textarea></td>
                                <td><textarea name="special_contributions[]" class="form-control"
                                        placeholder=""><?= $duty['special_contributions'] ?? '' ?></textarea></td>
                                <td><textarea name="duties_perf_circumstances[]"
                                        class="form-control"><?= $duty['duties_perf_circumstances'] ?? '' ?></textarea>
                                </td>
                                <td><textarea name="duties_perf_circumstances_bad[]"
                                        class="form-control"><?= $duty['duties_perf_circumstances_bad'] ?? '' ?></textarea>
                                </td>
                                <td width="100">
                                    <a id="add_dev_plan" class="btn btn-info btn-sm" name="add-invoice-item"
                                        onClick="key_duties_res('request_item')" tabindex="9"><i
                                            class="fa fa-plus-square" aria-hidden="true"></i></a>
                                    <a class="btn btn-danger btn-sm" value="<?php echo display('delete') ?>"
                                        onclick="deleteDevPlanRow(this)" tabindex="3"><i class="fa fa-trash"
                                            aria-hidden="true"></i></a>
                                </td>
                            </tr>
                            <?php }}} ?>
                        </tbody>
                    </table>
                </div>
            </div>

            <div class="row" id="academic_and_non_academic_1">
                <h3 class="mb-20">A: ASSESSMENT OF JOB PERFORMANCE</h3>
                <table class="table table-bordered" id="request_table">
                    <thead>
                        <tr>
                        <tr>
                            <th>RESPONSIBILITIES: TASK AND TARGET</th>
                            <th>ADD/REMOVE ROW</th>
                        </tr>
                        <tr>
                            <td><b>Briefly List the major responsibilities, in order of importance for each
                                    responsibility. Note specific goals set during period under review<b></td>

                            <!-- <th class="text-center"><?//php echo display('action') ?> <i class="text-danger"></i></th> -->
                        </tr>


                        </tr>
                    </thead>
                    <tbody id="key_goals_item">
                    <?php foreach ($emp_exp as $key => $row) { 
                               $key_goal_data_array = json_decode($row->key_goals, true);
                                
                                // Check if the decoded data is an array
                                if (is_array($key_goal_data_array)) {
                                    foreach ($key_goal_data_array as $key_goal_data) { ?>
                        <tr>
                            <td><textarea id="key_goals" name="key_goals[]" class="form-control" rows="2"
                                    placeholder=""><?php echo htmlspecialchars($key_goal_data['key_goals']);?></textarea>
                            </td>


                            <td width="100">
                                <a id="add_key_goals" class="btn btn-info btn-sm" name="add-invoice-item"
                                    onClick="add_key_goals()" tabindex="9">
                                    <i class="fa fa-plus-square" aria-hidden="true"></i>
                                </a>
                                <a class="btn btn-danger btn-sm" value="<?php echo display('delete') ?>"
                                    onclick="deleteRow(this)" tabindex="3"><i class="fa fa-trash"
                                        aria-hidden="true"></i></a>

                            </td>
                            <?php }}}?>
                        </tr>
                    </tbody>


                </table>

            </div>

            <div class="row" id="academic">
                <h3 class="mb-20">A: ASSESSMENT OF JOB PERFORMANCE</h3>
                <h4>3.1 EXPERIENCE</h4>
                <h4>(a) Teaching experience. (Please indicate institution, your designation, area of
                    specification,
                    subject(s) taught and dates)</h4>
                <table class="table table-bordered" id="request_table">
                    <thead>
                        <tr>
                        <tr>
                            <th>INSTITUTION</th>
                            <th>DESIGNATION</th>
                            <th>AREA OF SPECIALIZATIONS</th>
                            <th>SUBJECTS TAUGHT</th>
                            <th>DATE</th>
                        </tr>
                        <tr>

                            <!-- <th class="text-center"><?//php echo display('action') ?> <i class="text-danger"></i></th> -->
                        </tr>
                        </tr>
                    </thead>
                    <tbody id="add_exp_teaching">
                        <?php 
                            
                            foreach ($emp_exp as $key => $row) { 
                                $exp_teaching_data_array = json_decode($row->exp_teaching, true);
                                
                                // Check if the decoded data is an array
                                if (is_array($exp_teaching_data_array)) {
                                    foreach ($exp_teaching_data_array as $teachingExperience) { ?>
                        <tr>
                            <td><textarea id="exp_institution" name="exp_institutions[]" class="form-control" rows="1"
                                    placeholder=""><?php echo $teachingExperience['institution']; ?></textarea>
                            </td>
                            <td><input type="text" id="exp_designation" name="exp_designation[]" class="form-control "
                                    value="<?php echo $teachingExperience['designation']; ?>">
                            </td>
                            <td>
                                <input type="text" id="exp_specialization" name="exp_specialization[]"
                                    class="form-control " value="<?php echo $teachingExperience['specialization']; ?>">
                            </td>
                            <td><input type="text" id="exp_subjects" name="exp_subject[]" class="form-control "
                                    value="<?php echo $teachingExperience['subject']; ?>"></td>
                            <td><input type="text" id="exp_date" name="exp_date[]" class="form-control datepicker"
                                    value="<?php echo $teachingExperience['date']; ?>"></td>
                            <td width="100">

                                <a id="add_exp_teaching" class="btn btn-info btn-sm" name="add-invoice-item"
                                    onclick="add_exp_teaching('request_item')" tabindex="9"><i class="fa fa-plus-square"
                                        aria-hidden="true"></i></a>
                                <a class="btn btn-danger btn-sm" value="<?php echo display('delete') ?>"
                                    onclick="deleteRow(this)" tabindex="3"><i class="fa fa-trash"
                                        aria-hidden="true"></i></a>

                            </td>
                        </tr>
                        <?php } }}?>
                    </tbody>
                </table>
                <h4>(b) Professional Experience</h4>
                <table class="table table-bordered" id="request_table">
                    <thead>
                        <tr>
                        <tr>
                            <th>EMPLOYER'S NAME</th>
                            <th>DESIGNATION</th>
                            <th>NUTURE OF DUTY</th>
                            <th>FROM</th>
                            <th>TO</th>
                        </tr>
                        <tr>

                            <!-- <th class="text-center"><?//php echo display('action') ?> <i class="text-danger"></i></th> -->
                        </tr>
                        </tr>
                    </thead>
                    <tbody id="exp_professional">
                        <?php    foreach ($emp_exp as $key => $row) { 
                                $exp_professional_data_array = json_decode($row->exp_professional, true);
                                
                                // Check if the decoded data is an array
                                if (is_array($exp_professional_data_array)) {
                                    foreach ($exp_professional_data_array as $professionalExperience) { ?>
                        <tr>
                            <td><textarea id="exp_institution_professional" name="exp_institutions_professional[]"
                                    class="form-control" rows="1"
                                    placeholder=""><?php echo $professionalExperience['institution']; ?></textarea>
                            </td>
                            <td><input type="text" id="exp_designation_professional"
                                    name="exp_designation_professional[]" class="form-control "
                                    value="<?php echo $professionalExperience['designation']; ?>"></td>
                            <td><textarea id="exp_duty_professional" name="exp_duty_professional[]"
                                    class="form-control "
                                    rows="2"><?php echo $professionalExperience['duty']; ?></textarea></td>
                            <td><input type="text" id="exp_date_start_professional" name="exp_date_start_professional[]"
                                    class="form-control datepicker"
                                    value="<?php echo $professionalExperience['date_start']; ?>"></td>
                            <td><input type="text" id="exp_date_end_professional" name="exp_date_end_professional[]"
                                    class="form-control datepicker"
                                    value="<?php echo $professionalExperience['date_end']; ?>"></td>
                            <td width="100">

                                <a id="exp_professional" class="btn btn-info btn-sm" name="add-invoice-item"
                                    onClick="exp_professional('request_item')" tabindex="9"><i class="fa fa-plus-square"
                                        aria-hidden="true"></i></a>
                                <a class="btn btn-danger btn-sm" value="<?php echo display('delete') ?>"
                                    onclick="deleteRow(this)" tabindex="3"><i class="fa fa-trash"
                                        aria-hidden="true"></i></a>

                            </td>
                        </tr>
                        <?php }}} ?>
                    </tbody>
                </table>

                <h4>3.2 RESEARCH/PROJECT/INVENTION/INNOVATION/DESIGNATION</h4>
                <h4>(a) Brief Description (if any)</h4>
                <table class="table table-bordered">
                    <tbody>
                        <?php    foreach ($emp_exp as $key => $row) { 
                                $exp_description_data = $row->exp_description ?>


                        <tr>
                            <td><textarea name="brief_descriptions[]" class="form-control" rows="3"
                                    placeholder=""><?php echo $exp_description_data; ?></textarea>
                            </td>
                        </tr>
                        <?php } ?>
                    </tbody>
                </table>

                <h4>(b) Research/Project/Innovation/Design completed but not yet published or patented</h4>
                <table class="table table-bordered">
                    <thead>
                        <tr>
                        <tr>
                            <th style="text-align:center">TOPIC</th>
                            <th style="text-align:center">DATE</th>
                        </tr>

                        </tr>
                    </thead>
                    <tbody id="exp_research">
                        <?php    foreach ($emp_exp as $key => $row) { 
                                $exp_research_data_array = json_decode($row->exp_research, true);
                                
                                // Check if the decoded data is an array
                                if (is_array($exp_research_data_array)) {
                                    foreach ($exp_research_data_array as $researchProject) { ?>
                        <tr>
                            <td><textarea id="exp_researh_topic" name="exp_researh_topic[]" class="form-control"
                                    rows="2" placeholder=""><?php echo $researchProject['topic']; ?></textarea></td>
                            <td><input type="text" id="exp_researh_date" name="exp_researh_date[]"
                                    class="form-control datepicker" value="<?php echo $researchProject['date']; ?>">
                            </td>

                            <td width="100">

                                <a id="exp_research" class="btn btn-info btn-sm" name="add-invoice-item"
                                    onClick="exp_research('request_item')"><i class="fa fa-plus-square"
                                        aria-hidden="true"></i></a>
                                <a class="btn btn-danger btn-sm" value="<?php echo display('delete') ?>"
                                    onclick="deleteRow(this)"><i class="fa fa-trash" aria-hidden="true"></i></a>

                            </td>
                        </tr>
                        <?php }}} ?>
                    </tbody>
                </table>

                <h4>(c) RECOOGNISED PUBLICATIONS/EXHIBITIONS/DESIGNS (Give details of books and articles,
                    stating
                    reference). List your publications under the following broad headings. State dates of
                    publications
                    very clearly. <br /><br />

                    (i) Dissertation or Thesis <br />

                    (ii) Books and Monographs <br />

                    (iii) Articles that have already appeared in learned journals<br />

                    (iv) Papers already accepted for publication<br />

                    (v) Exhibitions/Designed/Project</h4>
                <table class="table table-bordered">
                    <tbody>
                        <?php    foreach ($emp_exp as $key => $row) { 
                                $recognized_publications_data = $row->recognized_publications ?>
                        <tr>
                            <td><textarea name="recognised_publication" class="form-control" rows="3"
                                    placeholder=""><?php echo $recognized_publications_data ?></textarea>
                            </td>
                        </tr>
                        <?php } ?>
                    </tbody>
                </table>

                <h4>3.3 Unplublished papers read at Conference (with names of conferences and date(s))</h4>
                <table class="table table-bordered">
                    <thead>
                        <tr>
                        <tr>
                            <th style="text-align:center">TITLE</th>
                            <th style="text-align:center">WHERE READ</th>
                            <th style="text-align:center">DATE</th>
                        </tr>

                        </tr>
                    </thead>
                    <tbody id="exp_research_unpublish">
                        <?php    foreach ($emp_exp as $key => $row) { 
                                $exp_research_unpublish_data_array = json_decode($row->exp_research_unpublish, true);
                                
                                // Check if the decoded data is an array
                                if (is_array($exp_research_unpublish_data_array)) {
                                    foreach ($exp_research_unpublish_data_array as $paper) { ?>
                        <tr>
                            <td><textarea name="exp_unpublish_topic[]" class="form-control" rows="1"
                                    placeholder=""><?php echo $paper['topic']; ?></textarea></td>
                            <td><textarea name="exp_unpublish_read[]" class="form-control" rows="1"
                                    placeholder=""><?php echo $paper['read']; ?></textarea></td>
                            <td><input type="text" name="exp_unpublish_date[]" class="form-control datepicker"
                                    value="<?php echo $paper['date']; ?>"></td>
                            <td width="100">

                                <a id="exp_research_unpublish" class="btn btn-info btn-sm" name="add-invoice-item"
                                    onClick="exp_research_unpublish('request_item')" tabindex="9"><i
                                        class="fa fa-plus-square" aria-hidden="true"></i></a>
                                <a class="btn btn-danger btn-sm" value="<?php echo display('delete') ?>"
                                    onclick="deleteRow(this)" tabindex="3"><i class="fa fa-trash"
                                        aria-hidden="true"></i></a>

                            </td>
                        </tr>
                        <?php } }}?>
                    </tbody>
                </table>

                <h4>3.4 Other activites within the institute</h4>
                <table class="table table-bordered">
                    <?php    foreach ($emp_exp as $key => $row) { 
                                $exp_other_activities_data = $row->exp_other_activities ?>
                    <textarea name="exp_other_activities" class="form-control"
                        placeholder="Maximum 500 words"><?php echo $exp_other_activities_data ?></textarea>
                    <?php } ?>
                </table>
                <h4>3.5 Other relevant activites outside normal institute work</h4>
                <table class="table table-bordered">
                    <?php    foreach ($emp_exp as $key => $row) { 
                                $exp_other_activities_out_data = $row->exp_other_activities_out ?>
                    <textarea name="exp_other_activities_out" class="form-control"
                        placeholder="Maximum 500 words"><?php echo $exp_other_activities_out_data ?></textarea>
                    <?php }?>
                </table>
            </div>


            <div id="general1" class="form-group form-group-margin text-right">

                <button type="submit" class="btn btn-success w-md m-b-5"><?php echo display('update') ?></button>
            </div>
            <?php echo form_close() ?>
        </div>
    </div>
</div>
</div>
<script src="<?php echo MOD_URL . 'employee/assets/js/verify.js'; ?>" type="text/javascript"></script>
