<?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 . "/payroll/includes/ui/open_approved_ot_ui.inc");
include_once($path_to_root . "/payroll/includes/db/open_approved_ot_db.inc");
include_once($path_to_root . "/payroll/includes/db/employees_db.inc");
include_once($path_to_root . "/payroll/includes/db/payroll_calculation_db.inc"); 
include_once($path_to_root . "/payroll/includes/db/payroll_run_db.inc"); 
include_once($path_to_root . "/payroll/includes/ui/payroll_ui.inc"); 

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

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

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

simple_page_mode(true);

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

start_form();

    display_open_approved_ot_filtering_controls();

        $Ajax->activate('open_approved_ot');
        div_start('open_approved_ot');
            display_approved_and_calculated_ot_records($_POST['cutoff_date'], $show_button);
            br();
        div_end();

        if ($show_button === true) {
            submit_center_first('UpdateData', _("Open"), '', 'default');
            submit('Refresh', _("Refresh"), true, '', true);
        } else {
            display_note("No any approved OT records found for selected cutoff date.", 2, 2, 'style=color:red');
        }

end_form(3);
end_page(@$_GET['popup'], false, false);

?>