Exemplo n.º 1
0
function handle_submit()
{
    global $selected_id, $Mode;
    $ok = true;
    if ($selected_id != -1) {
        // make from_date start of month and to_date a year minus one day later
        $_POST['from_date'] = start_month($_POST['from_date']);
        $_POST['to_date'] = end_month(add_months($_POST['from_date'], 11));
        if ($_POST['closed'] == 1) {
            if (check_years_before($_POST['from_date'], false)) {
                display_error(_("Cannot CLOSE this year because there are open fiscal years before"));
                set_focus('closed');
                return false;
            }
            $ok = close_year($selected_id);
        } else {
            open_year($selected_id);
        }
        if ($ok) {
            update_fiscalyear($selected_id, $_POST['from_date'], $_POST['to_date'], $_POST['closed']);
            display_notification(_('Selected fiscal year has been updated'));
        }
    } else {
        if (!check_data()) {
            return false;
        }
        add_fiscalyear($_POST['from_date'], $_POST['to_date'], $_POST['closed']);
        display_notification(_('New fiscal year has been added'));
    }
    $Mode = 'RESET';
}
Exemplo n.º 2
0
function handle_submit()
{
    global $selected_id;
    if (!check_data()) {
        return false;
    }
    if (isset($selected_id)) {
        update_fiscalyear($_POST['from_date'], $_POST['closed']);
    } else {
        add_fiscalyear($_POST['from_date'], $_POST['to_date'], $_POST['closed']);
    }
    return true;
}