function can_process()
{
    global $Refs, $SysPrefs;
    copy_to_cart();
    if (!get_post('customer_id')) {
        display_error(_("There is no customer selected."));
        set_focus('customer_id');
        return false;
    }
    if (!get_post('branch_id')) {
        display_error(_("This customer has no branch defined."));
        set_focus('branch_id');
        return false;
    }
    if (!is_date($_POST['OrderDate'])) {
        display_error(_("The entered date is invalid."));
        set_focus('OrderDate');
        return false;
    }
    if ($_SESSION['Items']->trans_type != ST_SALESORDER && $_SESSION['Items']->trans_type != ST_SALESQUOTE && !is_date_in_fiscalyear($_POST['OrderDate'])) {
        display_error(_("The entered date is not in fiscal year"));
        set_focus('OrderDate');
        return false;
    }
    if (count($_SESSION['Items']->line_items) == 0) {
        display_error(_("You must enter at least one non empty item line."));
        set_focus('AddItem');
        return false;
    }
    if (!$SysPrefs->allow_negative_stock() && ($low_stock = $_SESSION['Items']->check_qoh())) {
        display_error(_("This document cannot be processed because there is insufficient quantity for items marked."));
        return false;
    }
    if ($_SESSION['Items']->payment_terms['cash_sale'] == 0) {
        if (strlen($_POST['deliver_to']) <= 1) {
            display_error(_("You must enter the person or company to whom delivery should be made to."));
            set_focus('deliver_to');
            return false;
        }
        if ($_SESSION['Items']->trans_type != ST_SALESQUOTE && strlen($_POST['delivery_address']) <= 1) {
            display_error(_("You should enter the street address in the box provided. Orders cannot be accepted without a valid street address."));
            set_focus('delivery_address');
            return false;
        }
        if ($_POST['freight_cost'] == "") {
            $_POST['freight_cost'] = price_format(0);
        }
        if (!check_num('freight_cost', 0)) {
            display_error(_("The shipping cost entered is expected to be numeric."));
            set_focus('freight_cost');
            return false;
        }
        if (!is_date($_POST['delivery_date'])) {
            if ($_SESSION['Items']->trans_type == ST_SALESQUOTE) {
                display_error(_("The Valid date is invalid."));
            } else {
                display_error(_("The delivery date is invalid."));
            }
            set_focus('delivery_date');
            return false;
        }
        if (date1_greater_date2($_POST['OrderDate'], $_POST['delivery_date'])) {
            if ($_SESSION['Items']->trans_type == ST_SALESQUOTE) {
                display_error(_("The requested valid date is before the date of the quotation."));
            } else {
                display_error(_("The requested delivery date is before the date of the order."));
            }
            set_focus('delivery_date');
            return false;
        }
    } else {
        if (!db_has_cash_accounts()) {
            display_error(_("You need to define a cash account for your Sales Point."));
            return false;
        }
    }
    if (!$Refs->is_valid($_POST['ref'])) {
        display_error(_("You must enter a reference."));
        set_focus('ref');
        return false;
    }
    if (!db_has_currency_rates($_SESSION['Items']->customer_currency, $_POST['OrderDate'])) {
        return false;
    }
    if ($_SESSION['Items']->get_items_total() < 0) {
        display_error("Invoice total amount cannot be less than zero.");
        return false;
    }
    return true;
}
while ($myrow = db_fetch($result)) {
    alt_table_row_color($k);
    label_cell($myrow["pos_name"], "nowrap");
    label_cell($myrow['credit_sale'] ? _('Yes') : _('No'));
    label_cell($myrow['cash_sale'] ? _('Yes') : _('No'));
    label_cell($myrow["location_name"], "");
    label_cell($myrow["bank_account_name"], "");
    inactive_control_cell($myrow["id"], $myrow["inactive"], "sales_pos", 'id');
    edit_button_cell("Edit" . $myrow['id'], _("Edit"));
    delete_button_cell("Delete" . $myrow['id'], _("Delete"));
    end_row();
}
inactive_control_row($th);
end_table(1);
//----------------------------------------------------------------------------------------------------
$cash = db_has_cash_accounts();
if (!$cash) {
    display_note(_("To have cash POS first define at least one cash bank account."));
}
start_table(TABLESTYLE2);
if ($selected_id != -1) {
    if ($Mode == 'Edit') {
        $myrow = get_sales_point($selected_id);
        $_POST['name'] = $myrow["pos_name"];
        $_POST['location'] = $myrow["pos_location"];
        $_POST['account'] = $myrow["pos_account"];
        if ($myrow["credit_sale"]) {
            $_POST['credit_sale'] = 1;
        }
        if ($myrow["cash_sale"]) {
            $_POST['cash_sale'] = 1;