<?php
/**********************************************************************
***********************************************************************/
$page_security = 'SA_APPROVE_OT';
if (!@$_GET['popup'])
    $path_to_root = "..";
else	
    $path_to_root = "../..";

include_once($path_to_root . "/includes/session.inc");
include_once($path_to_root . "/includes/date_functions.inc");
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/includes/data_checks.inc");
include_once($path_to_root . "/payroll/includes/ui/approve_ot_ui.inc");
include_once($path_to_root . "/payroll/includes/db/approve_ot_db.inc");
include_once($path_to_root . "/payroll/includes/db/attendance_db.inc"); 
include_once($path_to_root . "/payroll/includes/db/employees_db.inc");

$week_start_date = "";
$week_end_date = "";

$js = "";
$js .= get_js_open_window(900, 500);
$js .= get_js_date_picker();

page(_($help_context = "Approve OT"), @$_GET['popup'], false, "", $js);

simple_page_mode(true);

if (isset($_GET['employee_code'])) {
    $_POST['employee_code'] = $_GET['employee_code'];
}

if (isset($_POST['UpdateData'])) {
    $msg = approve_ot_records($_POST['cutoff_date']);
        if ($msg['success'] === false) {
            display_error($msg['message']);
        } else {
            display_notification($msg['message']);
        }
}

if ($Mode == 'RESET') {
    $selected_id = -1;
}


start_form();

    display_approve_ot_filtering_controls();

    $Ajax->activate('attendance');
    div_start('attendance');
        display_unapproved_ot_records($_POST['cutoff_date']);
        br();
        
    div_end();

    hidden('selected_id', $selected_id);

    submit_center_first('UpdateData', _("Save"), '', 'default');
    submit('CalculateValues', _("Calculate"), true, '', true);
    br(2);

if (!@$_GET['popup']) {
    end_form();
    end_page(@$_GET['popup'], false, false);
}

?>