
<!-- Toastr CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.css">

<!-- jQuery (required for Toastr) -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>

<!-- Toastr JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/latest/toastr.min.js"></script>

<style>
/* CSS for the popup */
.popup {
    display: none;
    /* Hidden by default */
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    padding: 20px;
    background-color: white;
    box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.popup.visible {
    display: block;
    /* Show the popup when visible */
}

.popup-overlay {
    display: none;
    /* Hidden by default */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

.popup-overlay.visible {
    display: block;
    /* Show the overlay when visible */
}
</style>
<div class="se-pre-con"></div>
<div class="row box-panel">

    <div class="">
        <div class="panel-heading">
            <div class="panel-title">

            </div>
        </div>
        <div class="panel-body panel-body-new">
            <!-- Top Block Start -->
            <!-- Popup notice -->
            <div class="popup" id="popup">
                <p>For a better experience, please use a laptop or switch to desktop view on your mobile device.</p>
                <button onclick="closePopup()">Close</button>
            </div>


            <?php 

            $employee_id = $this->session->userdata['employee_id'];
            $isAdmin = $this->session->userdata['isAdmin'];
            $isLogin = $this->session->userdata['isLogIn'];

            if($isLogin && $isAdmin){ 

          ?>
            <div class="popup-overlay" id="popup-overlay"></div>


            <div class="row">
                <!-- HRM Box for admin -->
                <div class="col-xs-12 col-sm-6 col-md-3">
                    <div class="small-box bg-green whitecolor">
                        <div class="inner">
                            <h4><span class="count-number"><?php echo (!empty($ttle_empl)?$ttle_empl:0);?></span></h4>

                            <p><?php echo display('total_employee')?></p>

                            <div class="icon">
                                <i class="fa fa-users"></i>
                            </div>
                        </div>
                        <?php if($this->permission->method('employee','read')->access()){ ?>
                        <a href="<?php echo base_url('employee/employees/manageemployee') ?>"
                            class="small-box-footer"><?php echo display('total_employee')?></a>
                        <?php }else{?>
                        <a href="javascript:void(0)" class="small-box-footer"><?php echo display('total_employee')?></a>
                        <?php }?>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6 col-md-3">
                    <div class="small-box bg-pase whitecolor">
                        <div class="inner">
                            <h4><span class="count-number"><?php echo (!empty($present_empl)?$present_empl:0);?></span>
                            </h4>

                            <p><?php echo display('todays_present')?></p>

                            <div class="icon">
                                <i class="fa fa-user-plus"></i>
                            </div>
                        </div>
                        <a href="javascript:void(0)" class="small-box-footer"><?php echo display('todays_present')?></a>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6 col-md-3">
                    <div class="small-box bg-bringal whitecolor">
                        <div class="inner">
                            <h4><span class="count-number"><?php 
                            
                            $prandleave = (!empty($present_empl)?$present_empl:0) + (!empty($todys_leave)?$todys_leave:0);
                            echo $ttle_empl - $prandleave;
                            ?></span></h4>

                            <p><?php echo display('todays_absent')?></p>

                            <div class="icon">
                                <i class="fa fa-user-times"></i>
                            </div>
                        </div>
                        <a href="javascript:void(0)" class="small-box-footer"><?php echo display('todays_absent')?></a>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6 col-md-3">
                    <div class="small-box bg-darkgreen whitecolor">
                        <div class="inner">
                            <h4><span class="count-number"><?php echo (!empty($todys_leave)?$todys_leave:0);?></span>
                            </h4>

                            <p><?php echo display('todays_leave')?></p>

                            <div class="icon">
                                <i class="fa fa-user-o"></i>
                            </div>
                        </div>
                        <a href="javascript:void(0)" class="small-box-footer"><?php echo display('todays_leave')?></a>
                    </div>
                </div>

                <!-- End of HRM Boxes for admin -->

                <!-- Top Block End -->

                <!-- Start of HRM Boxes for employee -->
            </div>

            <?php }else if($isLogin && $employee_id){?>
                <?php $row  = $emp_details;
                
                ?>
<div class="row">
    <div class="col-12 col-md-6"></div>  
    <div class="col-12 col-md-6 d-flex flex-column flex-md-row align-items-md-end">
        <div class="col-12 col-sm-6 col-md-4 mt-2 mt-md-2" style="margin-top:2px">
            <a href="<?php echo base_url(); ?>employee/Employees_performance/emp_performance_list/" class="btn btn-primary w-100"><?php echo "View Appraisal Score"; ?></a>
        </div> 
        <div class="col-12 col-sm-6 col-md-6 mt-2 mt-md-2" style="margin-top:2px">
            <a href="<?php echo base_url(); ?>employee/Employees/duties/<?php echo $row->employee_id; ?>" class="btn btn-primary w-100"><?php echo "Duties and Responsibilities"; ?></a>
        </div>
    </div>
</div>

  <br><br>
                <!-- HRM Box -->
                <div class="col-xs-12 col-sm-6 col-md-3">
                    <div class="small-box bg-green whitecolor">
                        <div class="inner">
                            <h4><span
                                    class="count-number"><?php echo (!empty($employee_box_data['total'])?$employee_box_data['total']:0);?></span>
                            </h4>

                            <p>Total Points</p>

                            <div class="icon">
                                <i class="fa fa-users"></i>
                            </div>
                        </div>
                        <a href="javascript:void(0)" class="small-box-footer">Total Points</a>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6 col-md-3">
                    <div class="small-box bg-pase whitecolor">
                        <div class="inner">
                            <h4><span
                                    class="count-number"><?php echo (!empty($employee_box_data['attendence'])?$employee_box_data['attendence']:0);?></span>
                            </h4>

                            <p>Current Year Attendance</p>

                            <div class="icon">
                                <i class="fa fa-user-plus"></i>
                            </div>
                        </div>
                        <a href="javascript:void(0)" class="small-box-footer">Attendance Points</a>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6 col-md-3">
                    <div class="small-box bg-bringal whitecolor">
                        <div class="inner">
                            <h4><span
                                    class="count-number"><?php echo (!empty($employee_box_data['management'])?$employee_box_data['management']:0);?></span>
                            </h4>

                            <p>Current Year Management</p>

                            <div class="icon">
                                <i class="fa fa-user-times"></i>
                            </div>
                        </div>
                        <a href="javascript:void(0)" class="small-box-footer">Management Points</a>
                    </div>
                </div>
                <div class="col-xs-12 col-sm-6 col-md-3">
                    <div class="small-box bg-darkgreen whitecolor">
                        <div class="inner">
                            <h4><span
                                    class="count-number"><?php echo (!empty($employee_box_data['collaborative'])?$employee_box_data['collaborative']:0);?></span>
                            </h4>

                            <p>Current Year Collaborative</p>

                            <div class="icon">
                                <i class="fa fa-user-o"></i>
                            </div>
                        </div>
                        <a href="javascript:void(0)" class="small-box-footer">Collaborative Points</a>
                    </div>
                </div>


                <!-- End of HRM Boxes for employee -->

                <!-- Top Block End -->

                <!-- Second block start -->
            </div>
           

            <div class="row">
                <div class="col-sm-12 col-md-4 employee-cv">

                    <div class="card-header resume">

                        <div><img
                                src="<?php if($row->picture){echo base_url().$row->picture;}else{echo base_url().'assets/img/user/default.jpg';} ?>"
                                width=100px; height=100px; class="img-circle" /></div>

                    </div>
                    <div class="card-content">
                        <div class="card-content-member">
                            <h4 class="m-t-0"><?php echo $row->first_name."  " .$row->last_name; ?></h4>

                            <h5>Department: <?php $dept=$this->db->select('department_name')->from('department')->where('dept_id',$row->parent_id)->get()->row();
                echo $dept->department_name;
                ?></h5>
                            <!-- <p class="m-0"><i class="fa fa-mobile" aria-hidden="true"></i>
                    <?php //echo $row->phone ;?></p> -->
                        </div>
                        <div class="card-content-languages">
                            <div class="card-content-languages-group"></div>
                            <div class="card-content-languages-group">
                                <table class="table table-hover" width="100%">
                                    <caption class="resumecaption"><?php echo display('personal_information')?>
                                    </caption>
                                    <tr>
                                        <th><?php echo display('name')?></th>
                                        <td><?php echo $row->first_name." " .$row->last_name;?></td>
                                    </tr>
                                    <!-- <tr>
                            <th><?php echo display('phone')?></th>
                            <td><?php echo $row->phone ;?></td>
                            </tr> -->
                                    <tr>
                                        <th><?php echo display('email')?></th>
                                        <td><?php echo $row->email  ;?></td>
                                    </tr>
                                    <tr>
                                        <th><?php //echo display('')?>State</th>
                                        <td><?php echo $row->state ;?></td>
                                    </tr>
                                    <tr>
                                        <th><?php echo display('city')?></th>
                                        <td><?php echo $row->city ;?></td>
                                    </tr>
                                    <tr>
                                        <th><?php echo display('zip')?></th>
                                        <td><?php echo $row->zip ;?></td>
                                    </tr>
                                </table>

                            </div>
                            <div class="card-content-languages-group">
                                <!-- <table class="table table-hover" width="100%">
                            <caption class="resumecaption"><?php echo display('biographicalinfo')?></caption>
                            <tr>
                                <th><?php echo display('dob')?></th>
                                <td><?php echo $row->dob;?></td>
                            </tr>
                            <tr>
                            <th><?php echo display('gender')?></th>
                            <td><?php if($row->gender ==1){
                            echo 'Male';
                            }else if($row->gender == 2){
                                echo 'Female';
                            }else{
                                echo 'Other';
                            }
                            ?></td>
                            </tr>
                                <tr>
                                    <th><?php echo display('marital_status')?></th>
                                    <td><?php 
                                    if($row->marital_status ==1){
                                    echo 'Single';
                                }else if($row->marital_status ==2){
                                    echo 'Married';
                                }else if($row->marital_status ==3){
                                echo 'Divorced';
                            }else if($row->marital_status ==4){
                                            echo 'Widowed';
                        }else{
                            echo 'Other';
                        } ;?></td>
                                            </tr>
                                            <tr>

                                                <th><?php echo display('ethnic_group')?> </th>
                                                <td><?php echo $row->ethnic_group ;?></td>
                                            </tr>



                                            <tr>

                                                <th><?php echo display('sos')?></th>
                                                <td><?php echo $row->sos ;?></td>
                                            </tr>
                                            <tr>

                                                <th><?php echo "Work in City";?></th>
                                                <td><?php if($row->work_in_state != ''){
                            echo $row->work_in_state;
                        }else{
                            echo '';
                        } ?></td>
                                            </tr>
                                            <tr>

                                                <th><?php echo "City of Residence";?></th>
                                                <td><?php if($row->live_in_state ==1){
                            echo 'Yes';
                        }else{
                            echo 'No';
                        }?></td>
                                            </tr>
                                        </table> -->

                            </div>
                        </div>
                        <div class="card-footer">
                            <div class="card-footer-stats">
                                <div>
                                    <p></p><span class="stats-small"></span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-sm-12 col-md-8 employee-cv-info">
                    <div class="row">
                        <div class="col-sm-12 col-md-12 rating-block">

                            <table class="table table-hover" width="100%">


                                <caption class="resumecaption"><?php echo display('positional_information')?></caption>
                                <tr>
                                    <th><?php echo display('division')?></th>
                                    <td><?php echo $row->department_name;?></td>
                                </tr>
                                <tr>
                                    <th><?php echo display('designation')?></th>
                                    <td><?php echo $row->position_name;?></td>
                                </tr>
                                <tr>
                                    <th><?php echo display('duty_type')?></th>
                                    <td><?php
                                    if($row->duty_type == 1){
                                        echo 'Full Time';
                                    }else if($row->duty_type == 2){
                                    echo 'Part Time';
                                }else if($row->duty_type == 3){
                                    echo 'Contructual';
                                }else{
                                    echo 'Other';
                                }?></td>
                                </tr>

                                <tr>
                                    <th><?php echo display('')?>Date of Employment</th>
                                    <td><?php echo $row->date_of_employment;?></td>
                                </tr>
                                <tr>
                                    <th><?php echo "";?>Date and Grade of Last Promotion</th>
                                    <td><?php echo $row->date_of_last_promotion;?></td>
                                </tr>
                                <tr>
                                    <th><?php echo display('rate_type')?></th>
                                    <td><?php if($row->rate_type == 1){
                                    echo 'Hourly';
                                }else{
                                    echo 'Salary';
                                }?></td>
                                </tr>
                                <tr>
                                    <th><?php //echo display('s_rate')?>Appointment Confirmed</th>
                                    <td><?php echo $row->appointment_confirmed;?></td>
                                </tr>
                                <!-- <tr>
                                        <th><?php echo display('pay_frequency')?></th>
                                                    <td><?php 
                                    if($row->pay_frequency == 1){
                                    echo 'Weekly';
                                }else if($row->pay_frequency == 2){
                                    echo 'Biweekly';
                                }else if($row->pay_frequency == 4){
                                    echo 'Monthly';
                                }else{
                                    echo 'Annual';
                                }?></td>
                                    </tr> -->
                                <tr>
                                    <th><?php //echo display('home_department')?>Qualification</th>
                                    <td><?php echo $row->qualification;?></td>
                                </tr>


                                <tr>
                                    <th><?php echo display('super_visor_name')?></th>
                                    <td><?php
                                    $supervisor = $this->db->select('first_name,last_name')->from('employee_history')->where('employee_id',$row->super_visor_id)->get()->row();
                                                            echo (!empty($supervisor)?$supervisor->first_name.' '.$supervisor->last_name:'Self');
                                                ?></td>
                                </tr>
                                <tr>
                                    <th><?php echo "Ist Supervisor";?></th>
                                    <td><?php
                                    if($row->is_super_visor==1){echo 'Yes';}else{
                                                                    echo 'No';
                                                                    } 
                                                ?></td>
                                </tr>
                            </table>

                        </div>
                    </div>
                </div>
                <div>
                    <h4>Academic Qualifications</h4>

                    <div class="table-responsive">
                        <table class="table table-bordered">
                            <thead>
                                <tr>
                                    <th>Name of Institution</th>
                                    <th>Duration (From)</th>
                                    <th>Duration (To)</th>
                                    <th>Qualification(s) Obtained</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php 
                                foreach ($academic as $index => $item):
                                    if($item->user_email == $row->email) {
                                ?>
                                <tr>
                                    <td>
                                        <input type="text" name="academic_id[]" style="display:none" 
                                        value="<?php echo isset($item->id) ? $item->id : ''; ?>" >
                                        <textarea type="text" name="academic_institution[]" class="form-control"
                                            readonly>
                                 <?php echo isset($item->institution) ? $item->institution : ''; ?>
                            </textarea>
                                    </td>
                                    <td>
                                        <input type="date" name="academic_duration_from[]" class="form-control"
                                            value="<?php echo isset($item->duration_from) ? $item->duration_from : ''; ?>"
                                            readonly>
                                    </td>
                                    <td>
                                        <input type="date" name="academic_duration_to[]" class="form-control"
                                            value="<?php echo isset($item->duration_to) ? $item->duration_to : ''; ?>"
                                            readonly>
                                    </td>
                                    <td>
                                        <textarea type="text" name="academic_qualification[]" class="form-control"
                                            readonly>
                                <?php echo isset($item->qualification) ? $item->qualification : ''; ?>
                            </textarea>
                                    </td>

                                    <td>
                                        <button type="button" class="btn btn-primary edit-btn">Edit</button>
                                    </td>
                                </tr>
                                <?php }endforeach; ?>
                            </tbody>

                        </table>

                        <div class="table-responsive">
                            <table class="table table-bordered">
                                <thead>
                                    <tr>
                                        <th>Qualifications</th>
                                        <th>Awarding Body/Society</th>
                                        <th>Date of Award</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php foreach ($professional as $index => $item):
                                             if($item->user_email == $row->email) { ?>
                                    <tr>
                                        <td>
                                        <input type="text" id="professional" name="professional_id[]" style="display:none" 
                                        value="<?php echo isset($item->id) ? $item->id : ''; ?>" >
                                            <textarea type="text" name="professional_qualification[]"
                                                class="form-control" readonly>
                                <?php echo isset($item->qualification) ? $item->qualification : ''; ?>
                            </textarea>
                                        </td>
                                        <td>
                                            <textarea type="text" name="professional_awarding_body[]"
                                                class="form-control" readonly>
                                    <?php echo isset($item->awarding_body) ? $item->awarding_body : ''; ?>
                                </textarea>
                                        </td>
                                        <td>
                                            <input type="date" name="professional_date_of_award[]" class="form-control"
                                                value="<?php echo isset($item->date_of_award) ? $item->date_of_award : ''; ?>"
                                                readonly>
                                        </td>
                                        <td>
                                            <button type="button" class="btn btn-primary edit-btn">Edit</button>
                                        </td>
                                    </tr>
                                    <?php } endforeach; ?>
                                </tbody>


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

            </div>




            <?php }?>

            <hr>

            <!-- New Design for chart report from 22nd November 2020 -->

            <?php

            if($isLogin && $isAdmin){

            ?>

            <div class="row">

                <div class="col-sm-12 col-md-5 attendance-chart">
                    <div class="panel panel-bd">
                        <div class="panel-heading">
                            <div class="panel-body">
                                <canvas id="bar-chart-attendance" class="chartcontent" height="220"></canvas>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="col-sm-12 col-md-5 recruited-chart">
                    <div class="panel panel-bd">
                        <div class="panel-heading">
                            <div class="panel-body">
                                <canvas id="bar-chart-recruitment" class="chartcontent" height="220"></canvas>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="col-sm-12 col-md-2 latest-notice">
                    <div class="panel panel-bd lobidisable">
                        <div class="panel-heading">
                            <div class="panel-title">
                                <h4><?php echo display('latest_notice')?></h4>
                            </div>
                        </div>
                        <div class="panel-body">
                            <div class="divContinuedAbsent">
                                <?php foreach($notice as $notices){?>
                                <div class="leftdivcontent"><span data-empid="61"></span><a
                                        href="<?php echo base_url("noticeboard/Notice_controller/view_details/".$notices['notice_id']) ?>"><b><?php echo  $notices['notice_date'].' - '.$notices['notice_type'];?>
                                        </b></a></div>
                                <?php }?>


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

            </div>

            <div class="row">

                <div class="col-sm-12 col-md-5 absent-chart">
                    <div class="panel panel-bd">
                        <div class="panel-heading">
                            <div class="panel-body">
                                <canvas id="bar-chart-absent" class="chartcontent" height="220"></canvas>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="col-sm-12 col-md-5 locan-payment-chart">
                    <div class="panel panel-bd">
                        <div class="panel-heading">
                            <div class="panel-body">
                                <canvas id="piechart" height="175"></canvas>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="col-sm-12 col-md-2 new-recruited">
                    <div class="panel panel-bd lobidisable">
                        <div class="panel-heading">
                            <div class="panel-title">
                                <h4><?php echo display('new_recruited_employee')?></h4>
                            </div>
                        </div>
                        <div class="panel-body">
                            <div class="divContinuedAbsent">
                                <?php foreach($latestrecruitedemple as $recruitempl){?>
                                <div class="leftdivcontent"><span
                                        data-empid="61"></span><b><?php echo $recruitempl['first_name'].' '.$recruitempl['last_name']?>
                                    </b><br><span><?php echo display('hire_date')?>:
                                    </span><b><?php echo $recruitempl['hire_date'];?></b></div>
                                <?php }?>

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

            </div>

            <div class="row">

                <div class="col-sm-12 col-md-6 absent-chart">
                    <div class="panel panel-bd">
                        <div class="panel-heading">
                            <div class="panel-body">
                                <canvas id="bar-chart-loanyear" class="chartcontent" height="220"></canvas>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="col-sm-12 col-md-6 locan-payment-chart">
                    <div class="panel panel-bd">
                        <div class="panel-heading">
                            <div class="panel-body">
                                <canvas id="scatter" class="chartcontent" height="220"></canvas>
                            </div>
                        </div>
                    </div>
                </div>

            </div>

            <div class="row">
                <!-- Table to show used license/customer -->
                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 absent-chart">
                    <div class="panel panel-bd lobidrag">
                        <div class="panel-heading">
                            <div class="panel-title">
                                <h4><?php echo display('employee_point') ?></h4>
                            </div>
                        </div>

                        <div class="panel-body scroller">
                            <div class="table-responsive">
                                <table class="table table-striped">
                                    <thead>
                                        <tr>
                                            <th><?php echo display('cid') ?></th>
                                            <th><?php echo display('employee_name') ?></th>
                                            <th><?php echo display('attendence_point') ?></th>
                                            <th><?php echo display('collaborative_point') ?></th>
                                            <th><?php echo display('management_point') ?></th>
                                            <th><?php echo display('total')." ".display('point') ?></th>
                                            <th><?php echo display('date') ?></th>
                                        </tr>
                                    </thead>
                                    <tbody>


                                        <?php if (!empty($employee_points)) { ?>
                                        <?php $sl = 1; ?>
                                        <?php foreach ($employee_points as $que) {
                                                    ?>
                                        <tr class="<?php echo ($sl & 1)?"odd gradeX":"even gradeC" ?>">
                                            <td><?php echo $sl; ?></td>
                                            <td><?php echo $que->firstname.' '.$que->lastname; ?></td>
                                            <td><?php echo $que->attendence!=null?$que->attendence:0; ?>
                                            </td>
                                            <td><?php echo $que->collaborative!=null?$que->collaborative:0; ?>
                                            </td>
                                            <td><?php echo $que->management!=null?$que->management:0; ?>
                                            </td>
                                            <td><?php echo $que->total; ?></td>
                                            <td><?php echo date('F, Y', strtotime($que->date)); ?></td>
                                        </tr>
                                        <?php $sl++; ?>
                                        <?php } ?>
                                        <?php } ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <?php }else if($isLogin && $employee_id){ ?>

            <div class="row">
                <!-- Single Bar Chart -->
                <div class="col-sm-7 col-md-7 absent-chart">
                    <div class="panel panel-bd lobidisable">
                        <div class="panel-heading">
                            <div class="panel-title">
                                <h4>Yearly Points</h4>
                            </div>
                        </div>
                        <div class="panel-body">
                            <canvas id="singelBarChart" height="160"></canvas>
                        </div>
                    </div>
                </div>
                <!-- Pie Chart -->
                <div class="col-sm-5 col-md-5 absent-chart">
                    <div class="panel panel-bd lobidisable">
                        <div class="panel-heading">
                            <div class="panel-title">
                                <h4>Last 30 Days Points Chart</h4>
                            </div>
                        </div>
                        <div class="panel-body">
                            <canvas id="pieChart" height="235"></canvas>
                        </div>
                    </div>
                </div>
            </div>


            <div class="row">

                <!-- Line Chart -->
                <div class="col-sm-12 col-md-12 absent-chart">
                    <div class="panel panel-bd lobidisable">
                        <div class="panel-heading">
                            <div class="panel-title">
                                <h4>Monthly Attendance</h4>
                            </div>
                        </div>
                        <div class="panel-body">
                            <canvas id="lineChart" class="chartcontent" height="80"></canvas>
                        </div>
                    </div>
                </div>

            </div>

            <?php 
            }
        ?>

            <!-- End of New Design for chart report-->

            <!-- Forth part end -->
        </div>
    </div>

    <input type="hidden" name="" id="attendancelabel" value="<?php echo $attendanclabel;?>">
    <input type="hidden" name="" id="attendancedata" value="<?php echo $attendancdata;?>">
    <input type="hidden" name="" id="month" value='<?php echo $month;?>'>
    <input type="hidden" name="" id="recruitedemp" value="<?php echo $recruitedemp;?>">
    <input type="hidden" name="" id="abdfftdaylabel" value="<?php echo $abdfftdaylabel;?>">
    <input type="hidden" name="" id="abdfftdayval" value="<?php echo $abdfftdayval?>">
    <input type="hidden" name="" id="loanpayemntamnt"
        value="<?php echo (!empty($lnamountpaid->amount)?$lnamountpaid->amount:1);?>">
    <input type="hidden" name="" id="loanreceivedamnt"
        value="<?php echo (!empty($lnamountpaid->amount)?$lnamountpaid->amount:1);?>">
    <input type="hidden" name="" id="loanstatisticpayment" value="<?php echo $loanstatisticpayment;?>">
    <input type="hidden" name="" id="loanstatisticreceived" value="<?php echo $loanstatisticreceived;?>">
    <input type="hidden" name="" id="awardedempl" value="<?php echo $awardedempl;?>">
    <input type="hidden" name="" id="presentitle" value="<?php echo display('attendance_last_30days')?>">
    <input type="hidden" name="" id="attendancetitle" value="<?php echo display('attendance')?>">
    <input type="hidden" name="" id="employeetitle" value="<?php echo display('employee')?>">
    <input type="hidden" name="" id="absenttitle" value="<?php echo display('absent_15days')?>">
    <input type="hidden" name="" id="absent" value="<?php echo display('absent')?>">
    <input type="hidden" name="" id="recruitedtitle" value="<?php echo display('recruited')?>">
    <input type="hidden" name="" id="recruitedyeartitle" value="<?php echo display('recruited_current_year')?>">
    <input type="hidden" name="" id="loanpaymenttitle" value="<?php echo display('loanpayment')?>">
    <input type="hidden" name="" id="loanreceivettitle" value="<?php echo display('loanreceive')?>">
    <input type="hidden" name="" id="paymentrecvtitle"
        value="<?php echo display('loanpayment').' '.display('loanreceive')?>">
    <input type="hidden" name="" id="awardedtitle" value="<?php echo display('awarded')?>">
    <input type="hidden" name="" id="awardedcurrnttitle"
        value="<?php echo display('awarded').' '.display('current_year')?>">
</div>




<script src="<?php echo base_url('assets/plugins/counterup/chart.min.js') ?>" type="text/javascript">
</script>

<?php if($isLogin && $isAdmin){?>
<script src="<?php echo base_url('assets/js/dashboardchart.js') ?>" type="text/javascript"></script>
<?php }?>

<?php if($isLogin && $employee_id){?>
<script src="<?php echo base_url('assets/js/employee-dashboardchart.js') ?>" type="text/javascript">
</script>
<script>
// Function to detect if the device is mobile
function isMobileDevice() {
    return /Mobi|Android/i.test(navigator.userAgent);
}

// Function to show the popup
function showPopup() {
    document.getElementById('popup').classList.add('visible');
    document.getElementById('popup-overlay').classList.add('visible');
}

// Function to close the popup
function closePopup() {
    document.getElementById('popup').classList.remove('visible');
    document.getElementById('popup-overlay').classList.remove('visible');
}

// Check if the device is mobile and show the popup if true
if (isMobileDevice()) {
    showPopup();
}

$(document).ready(function() {
    // Handle Edit/Save button clicks for both Academic and Professional sections
    $('.edit-btn').click(function() {
        var $btn = $(this);
        var $row = $btn.closest('tr');

        if ($btn.text() === 'Edit') {
            // Make fields editable
            $row.find('textarea, input').prop('readonly', false);
            $btn.text('Save');
        } else {
            // Make fields read-only and save data via AJAX
            $row.find('textarea, input').prop('readonly', true);
            $btn.text('Edit');

            // Determine the context (Academic or Professional) by checking the existence of specific input field names
            var isAcademic = $row.find('input[name="academic_id[]"]').length > 0;
            var data = {};

            if (isAcademic) {
                // Collect data for Academic Qualifications
                data = {
                    id: $row.find('input[name="academic_id[]"]').val(),
                    institution: $row.find('textarea[name="academic_institution[]"]').val(),
                    duration_from: $row.find('input[name="academic_duration_from[]"]').val(),
                    duration_to: $row.find('input[name="academic_duration_to[]"]').val(),
                    qualification: $row.find('textarea[name="academic_qualification[]"]').val(),
                };

                // Send the data via AJAX for Academic
                $.ajax({
                    url: '<?php echo site_url('dashboard/Home/academicUpdate') ?>',
                    method: 'POST',
                    data: data,
                    success: function(response) {
                        var parsedResponse = JSON.parse(response);
                        toastr.success(parsedResponse.success);
                    },
                    error: function(xhr, status, error) {
                        toastr.error('Failed to save academic data');
                    }
                });

            } 
            else {
                // Collect data for Professional Qualifications
                data = {
                    id: $row.find('input[name="professional_id[]"]').val(),
                    qualification: $row.find('textarea[name="professional_qualification[]"]').val(),
                    awarding_body: $row.find('textarea[name="professional_awarding_body[]"]').val(),
                    date_of_award: $row.find('input[name="professional_date_of_award[]"]').val(),
                };

                // Send the data via AJAX for Professional
                $.ajax({
                    url: '<?php echo site_url('dashboard/Home/professionUpdate') ?>',
                    method: 'POST',
                    data: data,
                    success: function(response) {
                        var parsedResponse = JSON.parse(response);
                        toastr.success(parsedResponse.success);
                        console.log(response)
                    },
                    error: function(xhr, status, error) {
                        toastr.error('Failed to save professional data');
                    }
                });
            }
        }
    });
});


</script>

<?php }?>