Пример #1
0
    //initialise no input errors assumed initially before we test
    $input_error = 0;
    //first off validate inputs sensible
    if (strlen($_POST['bank_account_name']) == 0) {
        $input_error = 1;
        display_error(_("The bank account name cannot be empty."));
        set_focus('bank_account_name');
    }
    if ($Mode == 'ADD_ITEM' && (gl_account_in_bank_accounts(get_post('account_code')) || key_in_foreign_table(get_post('account_code'), 'gl_trans', 'account'))) {
        $input_error = 1;
        display_error(_("The GL account selected is already in use. Select another GL account."));
        set_focus('account_code');
    }
    if ($input_error != 1) {
        if ($selected_id != -1) {
            update_bank_account($selected_id, $_POST['account_code'], $_POST['account_type'], $_POST['bank_account_name'], $_POST['bank_name'], $_POST['bank_account_number'], $_POST['bank_address'], $_POST['BankAccountCurrency'], $_POST['dflt_curr_act']);
            display_notification(_('Bank account has been updated'));
        } else {
            add_bank_account($_POST['account_code'], $_POST['account_type'], $_POST['bank_account_name'], $_POST['bank_name'], $_POST['bank_account_number'], $_POST['bank_address'], $_POST['BankAccountCurrency'], $_POST['dflt_curr_act']);
            display_notification(_('New bank account has been added'));
        }
        $Mode = 'RESET';
    }
} elseif ($Mode == 'Delete') {
    //the link to delete a selected record was clicked instead of the submit button
    $cancel_delete = 0;
    // PREVENT DELETES IF DEPENDENT RECORDS IN 'bank_trans'
    if (key_in_foreign_table($selected_id, 'bank_trans', 'bank_act') || key_in_foreign_table(get_post('account_code'), 'gl_trans', 'account')) {
        $cancel_delete = 1;
        display_error(_("Cannot delete this bank account because transactions have been created using this account."));
    }
Пример #2
0
}
#
if (isset($_POST['update_bank_account'])) {
    $id = COM_applyFilter($_GET['id']);
    $bank_name = COM_applyFilter($_POST['bank_name']);
    $account_number = COM_applyFilter($_POST['account_number']);
    $check_account_type = COM_applyFilter($_POST['check_account_type']);
    $routing_number = COM_applyFilter($_POST['routing_number']);
    $first_name = COM_applyFilter($_POST['first_name']);
    $last_name = COM_applyFilter($_POST['last_name']);
    $address_line1 = COM_applyFilter($_POST['address_line1']);
    $city = COM_applyFilter($_POST['city']);
    $state = COM_applyFilter($_POST['state']);
    $zip = COM_applyFilter($_POST['zip']);
    $country = COM_applyFilter($_POST['country']);
    $error = update_bank_account($id, $bank_name, $account_number, $check_account_type, $routing_number, $first_name, $last_name, $address_line1, $city, $state, $zip, $country, isset($_POST['default']) ? true : false);
} else {
    if (isset($_POST['add_bank_account'])) {
        $bank_name = COM_applyFilter($_POST['bank_name']);
        $account_number = COM_applyFilter($_POST['account_number']);
        $check_account_type = COM_applyFilter($_POST['check_account_type']);
        $routing_number = COM_applyFilter($_POST['routing_number']);
        $first_name = COM_applyFilter($_POST['first_name']);
        $last_name = COM_applyFilter($_POST['last_name']);
        $address_line1 = COM_applyFilter($_POST['address_line1']);
        $city = COM_applyFilter($_POST['city']);
        $state = COM_applyFilter($_POST['state']);
        $zip = COM_applyFilter($_POST['zip']);
        $country = COM_applyFilter($_POST['country']);
        $error = add_bank_account($_USER['uid'], $bank_name, $account_number, $check_account_type, $routing_number, $first_name, $last_name, $address_line1, $city, $state, $zip, $country, isset($_POST['default']) ? true : false);
    } else {