function display_fiscalyear_edit($selected_id)
{
    global $Mode;
    start_form();
    start_table(TABLESTYLE2);
    $company_year = get_company_pref('f_year');
    $result = get_all_fiscalyears();
    $row_cnt = db_num_rows($result);
    if ($selected_id != -1) {
        if ($Mode == 'Edit') {
            $myrow = get_fiscalyear($selected_id);
            $_POST['from_date'] = sql2date($myrow["begin"]);
            $_POST['to_date'] = sql2date($myrow["end"]);
            $_POST['closed'] = $myrow["closed"];
        }
        if ($row_cnt == 1) {
            date_row(_("Fiscal Year Begin:"), 'from_date', '', null, 0, 0, 1001);
        } else {
            hidden('from_date');
            label_row(_("Fiscal Year Begin:"), $_POST['from_date']);
        }
        hidden('to_date');
        label_row(_("Fiscal Year End:"), $_POST['to_date']);
        if ($myrow["id"] != $company_year) {
            yesno_list_row(_("Is Closed:"), 'closed', null, "", "", false);
        } else {
            hidden('closed');
            label_row(_("Is Closed:"), yesno_value($_POST['closed']));
        }
    } else {
        $begin = next_begin_date();
        if ($begin && $Mode != 'ADD_ITEM') {
            $_POST['from_date'] = $begin;
            $_POST['to_date'] = end_month(add_months($begin, 11));
            $_POST['closed'] = 0;
        }
        hidden('from_date');
        hidden('to_date');
        hidden('closed');
    }
    hidden('selected_id', $selected_id);
    end_table(1);
    submit_add_or_update_center($selected_id == -1, '', 'both');
    end_form();
}
Example #2
0
function display_fiscalyear_edit($selected_id)
{
    global $Mode;
    start_form();
    start_table(TABLESTYLE2);
    if ($selected_id != -1) {
        if ($Mode == 'Edit') {
            $myrow = get_fiscalyear($selected_id);
            $_POST['from_date'] = sql2date($myrow["begin"]);
            $_POST['to_date'] = sql2date($myrow["end"]);
            $_POST['closed'] = $myrow["closed"];
        }
        hidden('from_date');
        hidden('to_date');
        label_row(_("Fiscal Year Begin:"), $_POST['from_date']);
        label_row(_("Fiscal Year End:"), $_POST['to_date']);
    } else {
        $begin = next_begin_date();
        if ($begin && $Mode != 'ADD_ITEM') {
            $_POST['from_date'] = $begin;
            $_POST['to_date'] = end_month(add_months($begin, 11));
        }
        date_row(_("Fiscal Year Begin:"), 'from_date', '', null, 0, 0, 1001);
        date_row(_("Fiscal Year End:"), 'to_date', '', null, 0, 0, 1001);
    }
    hidden('selected_id', $selected_id);
    yesno_list_row(_("Is Closed:"), 'closed', null, "", "", false);
    end_table(1);
    submit_add_or_update_center($selected_id == -1, '', 'both');
    end_form();
}