*/
set_time_limit(0);
// Disable magic quotes and fake register globals.
$sanitize_all_escapes = true;
$fake_register_globals = false;
require_once '../../globals.php';
require_once $GLOBALS['srcdir'] . '/acl.inc';
require_once "Holidays_Controller.php";
if (!acl_check('admin', 'super')) {
    die(xlt('Not authorized'));
}
$holidays_controller = new Holidays_Controller();
$csv_file_data = $holidays_controller->get_file_csv_data();
//this part download the CSV file after the click on the href link
if ($_GET['download_file'] == 1) {
    $target_file = $holidays_controller->get_target_file();
    if (!file_exists($target_file)) {
        echo xlt('file missing');
    } else {
        header('HTTP/1.1 200 OK');
        header('Cache-Control: no-cache, must-revalidate');
        header("Pragma: no-cache");
        header("Expires: 0");
        header("Content-type: text/csv");
        header("Content-Disposition: attachment; filename=holiday.csv");
        readfile($target_file);
        exit;
    }
    die;
}
// end download section