<?php 
if (empty($Content)) { ?>
<div class="alert alert-danger" role="alert">
    <button class="close" data-dismiss="alert"></button>
    <strong>Danger: </strong>you can not view this employee! 
    <br>
    This employee is not available.
</div>
<?php die(); } 

include("Views/HRM/UploadDocument.php");
include("Views/HRM/addDocumentType.php");

if ($permissions->hasPermission('editEmployees')) {
    include("Views/HRM/EditEmployee.php");
    include("Views/HRM/addLocation.php");
    include("Views/HRM/addNationality.php");
}
?>


<style>
    .divClass{
        border: 1px solid #4c0870;
        margin-bottom: 10px;
    }


    .table.dataTable{
        width:100% !important;
    }
    .b-r {
        border-left-width: 1px;
    }
    .bg-master-lighter {
        border:none;
        background-color:#fff;
        border-top:1px solid #ddd;  
    }
    .profile-pic {
        text-align: center;
        border-radius: 100%;
        -moz-border-radius: 100%;
        -webkit-border-radius: 100%;
        /*width: auto;*/
        /*height: auto;*/
        border: 5px solid #4c0870;
        overflow: hidden;
        margin: 0 auto;
        background: #fafafa;
    }
    .profile-pic img {
        width: 188px;
        height: 188px;
        margin-top: 6px;
        border-radius: 100%;
        -moz-border-radius: 100%;
        -webkit-border-radius: 100%;
        overflow: hidden;
        -webkit-transition: all .3s ease-in-out;
        -moz-transition: all .3s ease-in-out;
        transition: all .3s ease-in-out;
    }
    .table thead tr >th{
        background-color:#4c0870;
        color:#fff;
    }
    .table thead tr th[class*='sorting_'] {
        color: #fff;
    }
    .table tbody tr td{
        font-size: 17px;
        font-weight: bold;
    }
    .bg-master-lighter {
        border:none;
        background-color:#fff;
        border-top:1px solid #ddd;  
    }

    #tableWithSearch_length{
        display: none;
    }

    a .btn.btn-success{
        border: 4px solid;
        border-radius: 8px;
    }
    h3{
        font-size: 20px !important;

    }
</style>

<?php
if (file_exists(upload_path.'employees/' . $employee_ID . '.jpg')) {
    $filename =upload_url.'employees/' . $employee_ID . '.jpg';
} else {
    $filename = SITE_LINK.'img/profiles/avatar.jpg';
}
//echo"<pre>";
//die(print_r($Content));
?>

<div class="wrapper">
    <div class="panel invoice">
        <div class="panel-body">
            <?php echo Forms::ModalLoader('MainEmployeeLoader') ?>
            <div id="DeleteAlert"></div>
            <div class="row">
                <input type="hidden" value="<?php echo!empty($_GET['modal']) ? 1 : 0; ?>" id="is_modal_shown"/>
                <a href="javascript:void(0)" id="print_data"  class="mainPageLinks" ><button type='button'  class='btn btn-success pull-right' ><i class='fa fa-print'></i> <?php print CommonLanguage::getMessage('print'); ?></button></a>
                <a href="#" class="mainPageLinks" data-toggle="modal" data-target="#document-modal" ><button type='button' class='btn btn-success pull-right' ><i class='fa fa-paperclip'></i> <?php print CommonLanguage::getMessage('upload_file'); ?></button></a>
                <?php if ($permissions->hasPermission('editEmployees')) { ?>  <a href="#" class="mainPageLinks" data-toggle="modal" data-target="#Edit_Employee" ><button type='button' class='btn btn-success pull-right' ><i class='fa fa-pencil'></i> <?php print CommonLanguage::getMessage('Edit') ?></button></a><?php } ?>
                <br>
                <div class="col-xs-10 col-sm-10 col-md-10 col-lg-10">
                    <h1><?php print CommonLanguage::getMessage('employee_info') . ' &#91; ' . $Content[0]["Employee_Name"] . ' - ' . $Content[0]["Employee_Work_ID"] . ' &#93;'; ?></h1>

                </div>

                <div class=" col-xs-2 col-sm-2 col-md-2 profile-col pull-right" style="display: contents;">
                    <div class="profile-pic" style="margin-bottom: 10px;">
                        <div class="profile-border" >
                            <img id="EmployeeImagePreview" src="<?php echo $filename; ?>" data-src="<?php echo $filename; ?>" alt="" >


                        </div>
                    </div>
                    <?php if(file_exists(dirBase.'uploads/employees/' . $Content[0]["Employee_ID"]. '.jpg')){?>
                    <span class="fa fa-trash red-star delete_employee_image" data-view="1" data-content="<?php echo $Content[0]["Employee_ID"]; ?>" style="cursor:pointer;"></span>
                    <?php }?>
                </div>
            </div>
            <div class="col-sm-12 col-md-12 col-lg-12 divClass"  >
                <div class="col-sm-4 col-md-4 col-lg-4">
                    <h3 class="text-left" style="border:6px solid #4c0870;background-color: #4c0870;color: #fff;"><?php echo CommonLanguage::getMessage('hr_pers') ?></h3>

                </div>
                <div class="col-sm-12 col-md-12 col-lg-12">
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('gender'); ?></label>
                            <div class="col-sm-4 "> <?php echo CommonLanguage::getMessage($Content[0]["Gender_Name"]); ?></div>
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('blood_type'); ?></label>

                            <div class="col-sm-4 "><?php echo $Content[0]["BloodType_Name"]; ?></div>  

                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label "><?php print CommonLanguage::getMessage('dob'); ?></label>
                            <div class="col-sm-4 "> <?php echo $Content[0]["Employee_DOB"]; ?></div>
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('marital_status'); ?></label>
                            <div class="col-sm-4 "><?php echo CommonLanguage::getMessage($Content[0]['Merital_Status_Name']); ?></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('country'); ?></label>
                            <div class="col-sm-4 "><?php echo $Content[0]["Country_Name"]; ?></div>
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('city'); ?></label>
                            <div class="col-sm-4 " ><?php echo $Content[0]["Name"]; ?></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('home_phone'); ?></label>
                            <div class="col-sm-4 "><?php echo $Content[0]["Employee_HomePhone"]; ?></div>
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('mobile_phone'); ?></label>
                            <div class="col-sm-4 "><?php echo $Content[0]["Employee_MobilePhone"]; ?></div>

                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label "><?php print CommonLanguage::getMessage('social_security'); ?></label>
                            <div class="col-sm-4 "><?php echo $Content[0]["Employee_SocialSecurity"] == 0 ? CommonLanguage::getMessage("not_ssnf") : $Content[0]["Employee_SocialSecurity"]; ?></div>
                            <label class="col-sm-2 control-label social_security <?php echo $Content[0]["Employee_SocialSecurity"] == 0 ? 'hidden' : '' ?>"><?php print CommonLanguage::getMessage('social_security_date'); ?></label>
                            <div class="col-sm-4 social_security <?php echo $Content[0]["Employee_SocialSecurity"] == 0 ? 'hidden' : '' ?>"><?php echo $Content[0]["Employee_SocialSecurity_Date"]; ?></div>

                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label "><?php print CommonLanguage::getMessage('record_number'); ?></label>
                            <div class="col-sm-4 "><?php echo $Content[0]["Employee_RecordNumber"]; ?></div>

                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('nationality'); ?></label>
                            <div class="col-sm-4 "><?php echo $Content[0]["Nationality_Name"]; ?></div>  

                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('Email'); ?></label>
                            <div class="col-sm-4 "><?php echo $Content[0]["Employee_Email"]; ?></div>

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


            <div class="col-sm-12 col-md-12 col-lg-12 divClass"  >
                <div class="col-sm-4 col-md-4 col-lg-4">
                    <h3 class="text-left" style="border:6px solid #4c0870;background-color: #4c0870;color: #fff;"><?php echo CommonLanguage::getMessage('hr_pers_prob') ?></h3>
                </div>
                <div class="col-sm-12 col-md-12 col-lg-12">
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('child_prob'); ?></label>
                            <div class="col-sm-4 "> <?php echo $Content[0]["Employee_Problem"]; ?></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-12 col-md-12 col-lg-12 divClass"  >
                <div class="col-sm-4 col-md-4 col-lg-4">
                    <h3 class="text-left" style="border:6px solid #4c0870;background-color: #4c0870;color: #fff;"><?php echo CommonLanguage::getMessage('hr_pers_edu') ?></h3>
                </div>

                <div class="col-sm-12 col-md-12 col-lg-12">
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('emp_edu'); ?></label>
                            <div class="col-sm-4 "> <?php echo $Content[0]["Employee_Education"]; ?></div>
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('emp_major'); ?></label>
                            <div class="col-sm-4 "><?php echo $Content[0]["Employee_Major"]; ?></div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-12 col-md-12 col-lg-12 divClass"  >
                <div class="col-sm-4 col-md-4 col-lg-4">
                    <h3 class="text-left" style="border:6px solid #4c0870;background-color: #4c0870;color: #fff;"><?php echo CommonLanguage::getMessage('hr_pers_wife') ?></h3>
                </div>
                <div class="col-sm-12 col-md-12 col-lg-12">
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('Employee_Wife_Name'); ?></label>
                            <div class="col-sm-4 "> <?php echo $Content[0]["Employee_Wife_Name"]; ?></div>
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('dob') . ' / ' . CommonLanguage::getMessage('address'); ?></label>
                            <div class="col-sm-4 "><?php echo $Content[0]["Employee_Wife_DOB"] . ' / ' . $Content[0]["Employee_Wife_Address"]; ?></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('Employee_Wife_Phone'); ?></label>
                            <div class="col-sm-4 "> <?php echo $Content[0]["Employee_Wife_Phone"]; ?></div>
                            <label class="col-sm-2 control-label "><?php print CommonLanguage::getMessage('wife_works'); ?></label>
                            <div class="col-sm-4 ">
                                <?php
                                if (!empty($Wife_IS_Work)) {
                                    switch ($Wife_IS_Work[0]["Wife_Works"]) {
                                        case 0:
                                            echo CommonLanguage::getMessage('no');
                                            break;
                                        case 1:
                                            echo CommonLanguage::getMessage('yes');
                                            break;
                                        case 2:
                                            echo CommonLanguage::getMessage('others');
                                            break;
                                        case 3:
                                            echo CommonLanguage::getMessage('husband_foreign_nationality');
                                            break;
                                    }
                                }
                                ?>  
                            </div>
                        </div>

                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('work_address'); ?></label>
                            <div class="col-sm-4 "><?php echo $Content[0]["Employee_Wife_Work"]; ?></div>

                            <label class="col-sm-2 control-label "><?php print CommonLanguage::getMessage('child_prob'); ?></label>
                            <div class="col-sm-4 "><?php echo $Content[0]["Employee_Wife_Problem"] ?></div>


                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('Wife_SSNF'); ?></label>
                            <div class="col-sm-4 "><?php echo $Content[0]["Employee_Wife_SSNF"] == 0 ? CommonLanguage::getMessage('no') : CommonLanguage::getMessage('yes'); ?></div>

                            <label class="col-sm-2 control-label "><?php print CommonLanguage::getMessage('nationality'); ?></label>
                            <div class="col-sm-4 "><?php echo $Content[0]["Wife_Nationality"] ?></div>


                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-12 col-md-12 col-lg-12 divClass"  >
                <div class="col-sm-4 col-md-4 col-lg-4">
                    <h3 class="text-left" style="border:6px solid #4c0870;background-color: #4c0870;color: #fff;"><?php echo CommonLanguage::getMessage('hr_pers_child') ?></h3>
                </div>
                <!--                <div class="col-sm-12 col-md-12 col-lg-12 ">
                                    <table class="table table-bordered table-hover demo-table-search" id="tableWithSearch1">
                                        <thead>
                                            <tr>
                                                <th class="text-center" style="width:10%" ><?php print CommonLanguage::getMessage('employee_name'); ?></th>
                                                <th class="text-center" style="width:5%"><?php print CommonLanguage::getMessage('wife_works'); ?></th>
                                                <th class="text-center" style="width:5%"><?php print CommonLanguage::getMessage('nb_of_child'); ?></th>
                                                <th class="text-center" ><?php print CommonLanguage::getMessage('child_name'); ?></th>
                                                <th class="text-center" style="width:10%"><?php print CommonLanguage::getMessage('child_dob'); ?></th>
                                                <th class="text-center" style="width:20%"><?php print CommonLanguage::getMessage('child_school'); ?></th>
                                                <th class="text-center" style="width:15%"><?php print CommonLanguage::getMessage('child_school_type'); ?></th>
                                                <th class="text-center" style="width:15%"><?php print CommonLanguage::getMessage('child_class'); ?></th>
                                                <th class="text-center" style="width:15%"><?php print CommonLanguage::getMessage('child_prob'); ?></th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                        </tbody>
                                    </table>
                
                                </div>-->
                <div class="col-sm-12 col-md-12 col-lg-12 ">
                    <?php
                    foreach ($child_emp as $child) {
                        ?>
                        <div class="row">
                            <div class="form-group">
                                <label class="col-xs-1 control-label"><?php print CommonLanguage::getMessage('child_name'); ?></label>
                                <div class="col-xs-1 "><?php echo $child["child_name"]; ?></div>

                                <label class="col-xs-1 control-label "><?php print CommonLanguage::getMessage('dob'); ?></label>
                                <div class="col-xs-1 "><?php echo $child["child_dob"] ?></div>
                                <label class="col-xs-1 control-label "><?php print CommonLanguage::getMessage('child_prob'); ?></label>
                                <div class="col-xs-1 "><?php echo $child["child_problem"] ?></div>
                                <label class="col-xs-1 control-label "><?php print CommonLanguage::getMessage('child_school'); ?></label>
                                <div class="col-xs-1 "><?php echo $child["child_school"] ?></div>
                                <label class="col-xs-1 control-label "><?php print CommonLanguage::getMessage('child_school_type'); ?></label>
                                <div class="col-xs-1 "><?php echo $child["school_type_name"] ?></div>
                                <label class="col-xs-1 control-label "><?php print CommonLanguage::getMessage('child_class'); ?></label>
                                <div class="col-xs-1 "><?php echo $child["child_class"] ?></div>



                            </div>
                        </div>
                    <?php } ?>
                </div>
            </div>

            <div class="col-sm-12 col-md-12 col-lg-12 divClass"      >
                <div class="col-sm-4 col-md-4 col-lg-4" >
                    <h3 class="text-left" style="border:6px solid #4c0870;background-color: #4c0870;color: #fff;"><?php echo CommonLanguage::getMessage('hr_pers_work') ?></h3>
                </div>  
                <div class="col-sm-12 col-md-12 col-lg-12">
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label "><?php print CommonLanguage::getMessage('work_id'); ?></label>
                            <div class="col-sm-4 "><?php echo $Content[0]["Employee_Work_ID"]; ?></div>
                            <label class="col-sm-2 control-label "><?php print CommonLanguage::getMessage('job'); ?></label>
                            <div class="col-sm-4 "><?php echo $Content[0]["Job_Name"] . ' &raquo; ' . $Content[0]["Paygrade_Name"]; ?></div>
                        </div>
                    </div>

                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('department'); ?></label>
                            <div class="col-sm-4 "><?php echo $Content[0]["Branch_Name"]; ?></div>
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('shift'); ?></label>
                            <div class="col-sm-4 "><?php echo $Content[0]["Shift_Name"]; ?></div>                            
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">

                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('Location'); ?></label>
                            <div class="col-sm-4 "><?php echo $Content[0]["Location_Name"]; ?></div>       
                            <label class="col-sm-2 control-label "><?php print CommonLanguage::getMessage('start_date'); ?></label>
                            <div class="col-sm-4 "><?php echo $Content[0]["Employee_StartDate"] ?></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">

                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('basic_salary'); ?></label>
                            <div class="col-sm-4 "><?php echo empty($Content[0]["basic_salary"]) ? (CommonFunctions::public_round_number($Content[0]["Paygrade_Value"]) . ' ' . $Content[0]['Currency_Symbol']) : (CommonFunctions::public_round_number($Content[0]['basic_salary']) . ' ' . $Content[0]['basic_currency_symbol']); ?></div>       
                            <label class="col-sm-2 control-label "><?php print CommonLanguage::getMessage('emp_type'); ?></label>
                            <div class="col-sm-4 "><?php
                                switch ($Content[0]["IS_Employee"]) {
                                    case 0:
                                        echo CommonLanguage::getMessage('not_IS_Employee');
                                        break;
                                    case 1:
                                        echo CommonLanguage::getMessage('IS_Employee');
                                        break;
                                    case 2:
                                        echo CommonLanguage::getMessage('sing_emp');
                                        break;
                                    case 3:
                                        echo CommonLanguage::getMessage('temp_emp');
                                    case 4:
                                        echo CommonLanguage::getMessage('retired_emp');
                                    case 5:
                                        echo CommonLanguage::getMessage('daily_emp');

                                        break;
                                }
                                ?></div>
                        </div>
                    </div>


                    <div class="row">
                        <div class="form-group">

                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('emp_alert_allusion'); ?></label>
                            <div class="col-sm-4 "><?php echo ($allw_war['allus']); ?></div>       



                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('emp_alert_warning'); ?></label>
                            <div class="col-sm-4 "><?php echo ($allw_war['war']); ?></div>       

                        </div>

                    </div>

                    <div class="row">


                        <div class="form-group">

                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('job_desc_file'); ?></label>
                            <div class="col-sm-4 "><a id="job_file" href="<?php echo empty($job_desc) ? 'javascript:void(0)' : upload_url.'Documents/' . $job_desc['Document_File_Name'] ?>" target="_blank" > <?php echo empty($job_desc) ? CommonLanguage::getMessage('no_document') : CommonLanguage::getMessage('job_desc'); ?></a>&nbsp;&nbsp;<i style="cursor:pointer;" class="fa fa-trash-o <?php echo empty($job_desc) ? "hidden" : " " ?>" id='delete_doc' data-id="<?php echo empty($job_desc) ? '' : $job_desc['Entry_ID'] ?>"></i></div>       

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

            </div>








            <div class="col-sm-12 col-md-12 col-lg-12 divClass" >
                <div class="col-sm-4 col-md-4 col-lg-4">
                    <h3 class="text-left" style="border:6px solid #4c0870;background-color: #4c0870;color: #fff;"><?php echo CommonLanguage::getMessage('hr_pers_abs2') ?></h3>
                </div>
                <div class="col-sm-12 col-md-12 col-lg-12">
                    <div class="row">
                        <div class="form-group">

                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('accrued_leave'); ?></label>
                            <div class="col-sm-2 "><?php echo $Accrued_Leave['remain'] + $Accrued_Leave['taken'] . ' ' . CommonLanguage::getMessage('days_nb'); ?></div>       
                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('remain_accrued_leave'); ?></label>
                            <div class="col-sm-2 "><?php echo $Accrued_Leave['remain'] . ' ' . CommonLanguage::getMessage('days_nb'); ?></div>       


                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('taken_accrued_leave'); ?></label>
                            <div class="col-sm-2 "><?php echo $Accrued_Leave['taken'] . ' ' . CommonLanguage::getMessage('days_nb'); ?></div>       

                        </div>


                    </div>

                    <div class="row">

                        <div class="form-group">

                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('delete_trs_dys'); ?></label>
                            <div class="col-sm-2 "><?php echo $remainig_trs_dys['remain'] + $remainig_trs_dys['taken'] . ' ' . CommonLanguage::getMessage('days_nb'); ?></div>       

                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('remaining_trs_dys'); ?></label>
                            <div class="col-sm-2 "><?php echo $remainig_trs_dys['remain'] . ' ' . CommonLanguage::getMessage('days_nb'); ?></div>       


                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('taken_trs_dys'); ?></label>
                            <div class="col-sm-2 "><?php echo $remainig_trs_dys['taken'] . ' ' . CommonLanguage::getMessage('days_nb'); ?></div>       

                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">

                            <label class="col-sm-2 control-label"><?php print CommonLanguage::getMessage('emp_absence_taken'); ?></label>
                            <div class="col-sm-4 "><?php echo ($absence_taken); ?></div>       

                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-12 col-md-12 col-lg-12 divClass" >
                <div class="col-sm-4 col-md-4 col-lg-4">
                    <h3 class="text-left" style="border:6px solid #4c0870;background-color: #4c0870;color: #fff;"><?php echo CommonLanguage::getMessage('hr_pers_abs') ?></h3>
                </div>
                <div class="col-sm-12 col-md-12 col-lg-12  ">
                    <table class="table table-bordered table-hover demo-table-search" id="tableAbsence">
                        <thead>
                        <th  class="text-center"><?php print CommonLanguage::getMessage('absence_reason_name'); ?></th>
                        <th  class="text-center"><?php print CommonLanguage::getMessage('start_date'); ?></th>
                        <th  class="text-center"><?php print CommonLanguage::getMessage('end_date'); ?></th>
                        <th  class="text-center" style="width:20%"><?php print CommonLanguage::getMessage('Action'); ?></th>
                        </thead>
                        <tbody>
                            <?php
                            $count = count($array);
                            for ($x = 0; $x < $count; $x++) {
                                $CurItem = $array[$x];
                                ?>
                                <tr>
                                    <td class='v-align-middle text-center ' ><?php echo (isset($CurItem["Absence_Reason_Name"]) ? $CurItem["Absence_Reason_Name"] : 'Accrued'); ?></td>
                                    <td class='v-align-middle text-center ' ><?php echo $CurItem["start"]; ?></td>
                                    <td class='v-align-middle text-center ' ><?php echo $CurItem["end"]; ?></td>
                                    <td class='v-align-middle text-center ' >
                                        <a  href="<?php echo $CurItem['Document_File_Name'] == '' ? 'javascript:void(0)' : SITE_LINK . 'uploads/Documents/' . $CurItem['Document_File_Name'] ?>"   target="_blank"><button class="btn Viewfile"  <?php echo $CurItem['Document_File_Name'] == '' ? 'disabled="disabled" ' : '' ?>style = "<?php echo $CurItem['Document_File_Name'] == '' ? 'cursor: not-allowed;' : '' ?>">
                                                <i class="fa fa-eye"></i>  </button></a>

                                    </td>
                                </tr>
                            <?php } ?>
                        </tbody>
                    </table>
                </div>
            </div>
            <div class="col-sm-12 col-md-12 col-lg-12 divClass"  >
                <div class="col-sm-4 col-md-4 col-lg-4">
                    <h3 class="text-left" style="border:6px solid #4c0870;background-color: #4c0870;color: #fff;"><?php echo CommonLanguage::getMessage('view_medical_employee') ?></h3>
                </div>
                <div class="col-sm-12 col-md-12 col-lg-12 ">

                    <table class="table table-bordered table-hover demo-table-search" id="tableMedical">
                        <thead>
                        <th  class="text-center"><?php print CommonLanguage::getMessage('Date'); ?></th>
                        <th  class="text-center"><?php print CommonLanguage::getMessage('note'); ?></th>
                        <th  class="text-center"><?php print CommonLanguage::getMessage('mdcl_total_iswa'); ?></th>
                        <th  class="text-center"><?php print CommonLanguage::getMessage('mdcl_total_emp'); ?></th>
                        <th  class="text-center"><?php print CommonLanguage::getMessage('amount'); ?></th>
                        <?php if ($permissions->hasPermission('DeleteMedicalEmployee') || $permissions->hasPermission('EditMedicalEmployee')) { ?>
                            <th class="text-center"><?php print CommonLanguage::getMessage('Action'); ?></th>
                        <?php } ?>



                        </thead>
                        <tbody>

                        </tbody>
                    </table>

                </div>
            </div>
            <div class="col-sm-12 col-md-12 col-lg-12 divClass"  >
                <div class="col-sm-4 col-md-4 col-lg-4">
                    <h3 class="text-left" style="border:6px solid #4c0870;background-color: #4c0870;color: #fff;"><?php echo CommonLanguage::getMessage('emergency_contact') ?></h3>
                </div>
                <div class="col-sm-12 col-md-12 col-lg-12 table ">

                    <table class="table table-bordered table-hover demo-table-search" id="tableWithSearch">
                        <thead>
                            <tr>
                                <!--<th class="text-center" ><?php print CommonLanguage::getMessage('Name'); ?></th>-->
                                <th class="text-center" ><?php print CommonLanguage::getMessage('relationship'); ?></th>
                                <th class="text-center" ><?php print CommonLanguage::getMessage('home_phone'); ?></th>
                                <th class="text-center" ><?php print CommonLanguage::getMessage('mobile_phone'); ?></th>
                                <th class="text-center" ><?php print CommonLanguage::getMessage('work_phone'); ?></th>
                                <th class="text-center" ><?php print CommonLanguage::getMessage('Action'); ?></th>
                            </tr>
                        </thead>
                        <tbody>

                        </tbody>
                    </table>

                </div>
            </div>
            <div class="col-sm-12 col-md-12 col-lg-12 divClass"  >
                <div class="col-sm-4 col-md-4 col-lg-4">
                    <h3 class="text-left" style="border:6px solid #4c0870;background-color: #4c0870;color: #fff;"><?php echo CommonLanguage::getMessage('viewEmployeeAlert') ?></h3>
                </div>

                <table class="table table-bordered table-hover demo-table-search" id="viewEmployeeAlert">
                    <thead>
                        <tr>

                            <th class="text-center" style="width:5%"><?php print CommonLanguage::getMessage('Date'); ?></th>
                            <th class="text-center" style="width:5%"><?php print CommonLanguage::getMessage('Type'); ?></th>
                            <th class="text-center" style="width:5%"><?php print CommonLanguage::getMessage('note'); ?></th>
                            <th class="text-center" style="width:5%"><?php print CommonLanguage::getMessage('Action'); ?></th>

                        </tr>
                    </thead>
                    <tbody>

                    </tbody>
                </table>



            </div>

            <div class="col-sm-12 col-md-12 col-lg-12 divClass"  >
                <div class="col-sm-4 col-md-4 col-lg-4">
                    <h3 class="text-left" style="border:6px solid #4c0870;background-color: #4c0870;color: #fff;"><?php echo CommonLanguage::getMessage('emp_doc_list') ?></h3>
                </div>

                <table class="table table-bordered table-hover demo-table-search" id="empDoc">
                    <thead>
                    <th  class="text-center"><?php print CommonLanguage::getMessage('doc_name'); ?></th>
                    <th  class="text-center"><?php print CommonLanguage::getMessage('comments'); ?></th>
                    <th  class="text-center"><?php print CommonLanguage::getMessage('Date'); ?></th>
                    <th  class="text-center"><?php print CommonLanguage::getMessage('Type'); ?></th>
                    <th  class="text-center" style="width:20%"><?php print CommonLanguage::getMessage('Action'); ?></th>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>



            <div class="col-sm-12 col-md-12 col-lg-12 divClass"  >
                <div class="col-sm-4 col-md-4 col-lg-4">
                    <h3 class="text-left" style="border:6px solid #4c0870;background-color: #4c0870;color: #fff;"><?php echo CommonLanguage::getMessage('viewEmpTransferDay') ?></h3>
                </div>

                <table class="table table-bordered table-hover demo-table-search" id="emp_trs_dys">
                    <thead>
                    <th class="text-center" style="width:5%"><?php print CommonLanguage::getMessage('Date'); ?></th>
                    <th class="text-center" style="width:5%"><?php print CommonLanguage::getMessage('days_nb'); ?></th>
                    <th class="text-center" style="width:5%"><?php print CommonLanguage::getMessage('note'); ?></th>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>



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

<div class="modal fade bs-example-modal-md" id="DeleteMedicalFromList" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width:50%">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                <h4 class="modal-title"><?php print CommonLanguage::getMessage('Confirm_Delete'); ?></h4>
                <div id="Delete_modalAlert" class="alert alert-success"></div>
            </div>
            <div class="modal-body">
                <form>
                    <div class="row">
                        <div class="col-sm-12 col-md-12 col-lg-12 ">
                            <div class="col-sm-12 col-md-12 col-lg-12" style="margin-top: 20px;">
                                <p><?php print CommonLanguage::getMessage('About_Delete'); ?> <strong class="Name"></strong> <strong class="Days">  </strong> </p>
                                <p><?php print CommonLanguage::getMessage('Proceed_Delete'); ?></p>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><?php print CommonLanguage::getMessage('Close'); ?></button>
                <button type="button" class="btn btn-danger" id="Medical_Delete" style="width:auto"><?php print CommonLanguage::getMessage('Save'); ?></button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade bs-example-modal-md" id="DeleteEmergencyFromList" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="width:50%">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
                <h4 class="modal-title"><?php print CommonLanguage::getMessage('Confirm_Delete'); ?></h4>
                <div id="DeleteEmergency_modalAlert" class="alert alert-success"></div>
            </div>
            <div class="modal-body">
                <form>
                    <div class="row">
                        <div class="col-sm-12 col-md-12 col-lg-12 ">
                            <div class="col-sm-12 col-md-12 col-lg-12" style="margin-top: 20px;">
                                <p><?php print CommonLanguage::getMessage('About_Delete'); ?> <strong class="Name"></strong> </p>
                                <p><?php print CommonLanguage::getMessage('Proceed_Delete'); ?></p>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><?php print CommonLanguage::getMessage('Close'); ?></button>
                <button type="button" class="btn btn-danger" id="Emergency_Delete" style="width:auto"><?php print CommonLanguage::getMessage('delete'); ?></button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="ConfirmDeleteRow" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title"><?php print CommonLanguage::getMessage('Confirm_Delete') ?></h4>
                <div id="delete_alert"></div>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-md-12 m-t-10">
                        <p><?php print CommonLanguage::getMessage('About_To_Delete') ?></p>
                        <p><?php print CommonLanguage::getMessage('Proceed_Delete') ?></p>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal"><?php print CommonLanguage::getMessage('Close') ?></button>
                <button type="button" class="btn btn-danger width-auto" id="Row_Delete"><?php print CommonLanguage::getMessage('delete') ?></button>
            </div>
        </div>
    </div>
</div>
<script>
    var emp_id = <?php echo json_encode($employee_ID); ?>;
    var title_med = <?php echo json_encode(CommonLanguage::getMessage('view_medical_employee')) ?>;
    var title_abs = <?php echo json_encode(CommonLanguage::getMessage('hr_pers_abs')); ?>;
    var title_child = <?php echo json_encode(CommonLanguage::getMessage('hr_pers_child')); ?>;
    var title = <?php echo json_encode(CommonLanguage::getMessage('emp_doc_list')); ?>;
    var title_alert = <?php echo json_encode(CommonLanguage::getMessage('viewEmployeeAlert')); ?>;
    var title_trs_dys = <?php echo json_encode(CommonLanguage::getMessage('viewEmpTransferDay')); ?>;
    var emp_name = <?php echo json_encode($Content[0]["Employee_Name"]); ?>;
    var myurl = "HRM/printEmpDetails/" + emp_id;
    var Submitted_Successfully = <?php echo json_encode(CommonLanguage::getMessage('Submitted_Successfully')); ?>,
            no_document = <?php echo json_encode(CommonLanguage::getMessage('no_document')); ?>,
            Failed_Submit = <?php echo json_encode(CommonLanguage::getMessage('Failed_Submit')); ?>;

    $(function () {

        RebuildDataTable((title_child + ' ' + emp_name), [1, 2, 3, 4, 5, 6], 'HRMAjax/viewEmployeeDependantRequest', {employee_ID: emp_id}, '#tableWithSearch1', [0])
        RebuildDataTable((title_abs + ' ' + emp_name), [0, 1, 2], false, false, '#tableAbsence');
        RebuildDataTable((title_med + ' ' + emp_name), [0, 1, 2, 3, 4], 'HRMAjax/EmployeeMedicalList', {emp_id: emp_id}, '#tableMedical');
        RebuildDataTable((title + ' ' + emp_name), [0, 1, 2, 3], 'HRMAjax/EmployeeDocumentList', {emp_id: emp_id, Is_Vlnt: 0}, '#empDoc');
        RebuildDataTable((title_alert + ' ' + emp_name), [0, 1, 2], 'HRMAjax/viewEmployeeAlertDetails', {emp_id: emp_id}, '#viewEmployeeAlert')
        RebuildDataTable((title_trs_dys + ' ' + emp_name), [0, 1, 2], 'HRMAjax/viewEmpTransferDayPerEmp', {emp_id: emp_id}, '#emp_trs_dys');
          $('.delete_employee_image').on('click',function(){
            var parent =  $(this),
                data={directory_name:'employees',image_name:parent.attr('data-content')+'.jpg'};
            deleteSpecificImage(data,parent.attr('data-view') == 1 ? '#MainEmployeeLoader' : '#EmployeeIsBusy',function(response){
                if(response[1] == "success"){
                    $('#EmployeeImagePreview,#EditProfilePhoto').attr('src','<?php echo SITE_LINK; ?>img/profiles/avatar.jpg').attr('data-src','<?php echo SITE_LINK; ?>img/profiles/avatar.jpg');
                    $('.delete_employee_image').remove();
                }
            });
        });

    })


    var CurrentMedical_ToDelete;

    $("#tableMedical").on("click", ".Action .Delete", function () {
        var Medical_Type_name = $(this).parents("tr").find("td:eq(0)").text()//parent tr keep searching till it reach tr 

        $("#DeleteMedicalFromList").find(".Name").text("معاينة في" + Medical_Type_name).end().modal("show") // to set the name of employee in modal to delete 

        CurrentMedical_ToDelete = $(this).parents("tr").find('.Action').attr('data-id') // current id to delete
    })
    $("#Delete_modalAlert").hide(); // hide the alert when submit if true or false
    //on click the delete button in modal get the id of the selected employee to delete it 
    $("#Medical_Delete").on("click", function () {
        $.ajax({
            type: 'POST',
            url: 'HRMAjax/medicalEmployeeListRequest',
            data: {GetID: CurrentMedical_ToDelete},
            complete: function (data, vv) {
                if (vv == "success" && data.responseText == "OK") {
                    RebuildDataTable((title + ' ' + emp_name), [0, 1, 2, 3, 4], 'HRMAjax/EmployeeMedicalList', {emp_id: emp_id}, '#tableMedical');
                    $("#Delete_modalAlert").attr("class", "alert alert-success").html(Submitted_Successfully).show();
                    setTimeout(function () {
                        $("#DeleteMedicalFromList").modal("hide")
                        $("#Delete_modalAlert").remove()
                    }, 1000)
                } else {
                    $("#Delete_modalAlert").show().empty().removeClass('alert-success').addClass('alert-danger').html(Failed_Submit);
                }
            }});
    })


    var Submitted_Successfully = <?php echo json_encode(CommonLanguage::getMessage('Submitted_Successfully')); ?>,
            Failed_Submit = <?php echo json_encode(CommonLanguage::getMessage('Failed_Submit')); ?>,
            title_emr = <?php echo json_encode(CommonLanguage::getMessage('emergency_contact')); ?>,
            relationship = <?php print json_encode(CommonLanguage::getMessage('relationship')); ?>,
            employee_ID = <?php echo json_encode($employee_ID) ?>;

    $(function () {

        RebuildDataTable(title_emr, [0, 1, 2, 3], 'HRMAjax/viewEmployeeEmergencyContactRequest', {employee_ID: employee_ID})
        
        if ($('#is_modal_shown').val() == 1)
                $('#Edit_Employee').modal('show');

    })
    var CurrentEmergency_ToDelete;
    $("#tableWithSearch").on("click", ".Action .Delete", function () {
        var EmergencyName = relationship + " " + $(this).parents("tr").find("td:eq(1)").text() //parent tr keep searching till it reach tr 


        $("#DeleteEmergencyFromList").find(".Name").text(EmergencyName).end().modal("show") // to set the name of employee in modal to delete 


        CurrentEmergency_ToDelete = $(this).parents('div.Action').attr('data-id') // current id to delete

    })
    $("#DeleteEmergency_modalAlert").hide(); // hide the alert when submit if true or false
    //on click the delete button in modal get the id of the selected employee to delete it 
    $("#Emergency_Delete").on("click", function () {
        //    console.log(CurrentEmergency_ToDelete)
        var oTable = $('#tableWithSearch').dataTable();
        var me = this;
        $.ajax({
            type: 'POST',
            url: 'HRMAjax/viewEmployeeEmergencyContactRequest',
            data: {GetID: CurrentEmergency_ToDelete},
            complete: function (data, vv) {
                if (vv == "success" && data.responseText == "ok") {
                    $("#DeleteEmergency_modalAlert").attr("class", "alert alert-success").html(Submitted_Successfully).show();
                    setTimeout(function () {
                        $("#DeleteEmergencyFromList").modal("hide")
                        $("#DeleteEmergency_modalAlert").remove()
                    }, 1000)
                    RebuildDataTable(title_emr, [0, 1, 2, 3], 'HRMAjax/viewEmployeeEmergencyContactRequest', {employee_ID: employee_ID})


                } else {
                    $("#DeleteEmergency_modalAlert").attr("class", "alert alert-danger").html(Failed_Submit).show();
                }
            }

        });
    });
    $("#print_data").on('click', function () {

        printPOSExternal(myurl);

    });
    function printPOSExternal(url) {

        $("#print_iframe").remove();
        $("<iframe id='print_iframe' style='position:absolute;top:0px;left:0;width:0px;height:0px;opacity:0;' src='" + url + "' '  ></iframe>").appendTo("body");


    }

    $('#delete_doc').on("click", function () {
        var entry_id = $(this).attr('data-id');
        $.ajax({
            url: 'HRMAjax/deleteJobFile?entry_id=' + entry_id,
            complete: function (v, v1) {
                if (v1 == 'success' && v.responseText == 'ok') {

                    $("#DeleteAlert").attr("class", "alert alert-success").html(Submitted_Successfully);

                    $('#delete_doc').addClass('hidden')
                    $('#job_file').attr('href', 'javascript:void(0)')
                    $('#job_file').empty().html(no_document)

                } else {
                    $("#DeleteAlert").attr("class", "alert alert-danger").html(Failed_Submit);
                }
                $(document.body).animate({scrollTop: 0}, 800);
            }


        });
       
    });

    $('#empDoc').on('click', '.deletefile', function () {
        var entry_id = $(this).attr('data-id');
        $("#ConfirmDeleteRow").attr("data-id", entry_id).modal("show")
    })
    $("#Row_Delete").on("click", function () {
        $.ajax({
            url: 'HRMAjax/deleteEmpFile?id=' + $("#ConfirmDeleteRow").attr("data-id"),
            complete: function (v, v1) {
                if (v.responseText == 'OK' && v1 == "success") {
                    $("#delete_alert").attr("class", "alert alert-success").html(Submitted_Successfully)
                    RebuildDataTable((title + ' ' + emp_name), [0, 1, 2, 3], 'HRMAjax/EmployeeDocumentList', {emp_id: emp_id, Is_Vlnt: 0}, '#empDoc');
                    $("#ConfirmDeleteRow").modal("hide")
                } else {
                    $("#delete_alert").attr("class", "alert alert-danger").html(Failed_Submit)

                }
            }
        })
    })
    $("#ConfirmDeleteRow").on("hidden.bs.modal", function () {
        $("#ConfirmDeleteRow").attr("data-id", 0)
        $("#delete_alert").addClass("hidden")
    })

</script>