public function getById($rest, $id) { $acct = get_gl_account($id); if (!$acct) { $acct = array(); } api_success_response(json_encode($acct)); }
function can_process() { global $Refs; if (!get_post('customer_id')) { display_error(_("There is no customer selected.")); set_focus('customer_id'); return false; } if (!get_post('BranchID')) { display_error(_("This customer has no branch defined.")); set_focus('BranchID'); return false; } if (!isset($_POST['DateBanked']) || !is_date($_POST['DateBanked'])) { display_error(_("The entered date is invalid. Please enter a valid date for the payment.")); set_focus('DateBanked'); return false; } elseif (!is_date_in_fiscalyear($_POST['DateBanked'])) { display_error(_("The entered date is not in fiscal year.")); set_focus('DateBanked'); return false; } if (!$Refs->is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); set_focus('ref'); return false; } //Chaitanya : 13-OCT-2011 - To support Edit feature if (isset($_POST['trans_no']) && $_POST['trans_no'] == 0 && !is_new_reference($_POST['ref'], ST_CUSTPAYMENT)) { display_error(_("The entered reference is already in use.")); set_focus('ref'); return false; } elseif ($_POST['ref'] != $_POST['old_ref'] && !is_new_reference($_POST['ref'], ST_CUSTPAYMENT)) { display_error(_("The entered reference is already in use.")); set_focus('ref'); return false; } if (!check_num('amount', 0)) { display_error(_("The entered amount is invalid or negative and cannot be processed.")); set_focus('amount'); return false; } if (isset($_POST['charge']) && !check_num('charge', 0)) { display_error(_("The entered amount is invalid or negative and cannot be processed.")); set_focus('charge'); return false; } if (isset($_POST['charge']) && input_num('charge') > 0) { $charge_acct = get_company_pref('bank_charge_act'); if (get_gl_account($charge_acct) == false) { display_error(_("The Bank Charge Account has not been set in System and General GL Setup.")); set_focus('charge'); return false; } } if (isset($_POST['_ex_rate']) && !check_num('_ex_rate', 1.0E-6)) { display_error(_("The exchange rate must be numeric and greater than zero.")); set_focus('_ex_rate'); return false; } if ($_POST['discount'] == "") { $_POST['discount'] = 0; } if (!check_num('discount')) { display_error(_("The entered discount is not a valid number.")); set_focus('discount'); return false; } //if ((input_num('amount') - input_num('discount') <= 0)) { if (input_num('amount') <= 0) { display_error(_("The balance of the amount and discout is zero or negative. Please enter valid amounts.")); set_focus('discount'); return false; } if (!db_has_currency_rates(get_customer_currency($_POST['customer_id']), $_POST['DateBanked'], true)) { return false; } $_SESSION['alloc']->amount = input_num('amount'); if (isset($_POST["TotalNumberOfAllocs"])) { return check_allocations(); } else { return true; } }
function check_inputs() { global $Refs; if (!get_post('supplier_id')) { display_error(_("There is no supplier selected.")); set_focus('supplier_id'); return false; } if (@$_POST['amount'] == "") { $_POST['amount'] = price_format(0); } if (!check_num('amount', 0)) { display_error(_("The entered amount is invalid or less than zero.")); set_focus('amount'); return false; } if (isset($_POST['charge']) && !check_num('charge', 0)) { display_error(_("The entered amount is invalid or less than zero.")); set_focus('charge'); return false; } if (isset($_POST['charge']) && input_num('charge') > 0) { $charge_acct = get_company_pref('bank_charge_act'); if (get_gl_account($charge_acct) == false) { display_error(_("The Bank Charge Account has not been set in System and General GL Setup.")); set_focus('charge'); return false; } } if (@$_POST['discount'] == "") { $_POST['discount'] = 0; } if (!check_num('discount', 0)) { display_error(_("The entered discount is invalid or less than zero.")); set_focus('amount'); return false; } //if (input_num('amount') - input_num('discount') <= 0) if (input_num('amount') <= 0) { display_error(_("The total of the amount and the discount is zero or negative. Please enter positive values.")); set_focus('amount'); return false; } if (isset($_POST['bank_amount']) && input_num('bank_amount') <= 0) { display_error(_("The entered bank amount is zero or negative.")); set_focus('bank_amount'); return false; } if (!is_date($_POST['DatePaid'])) { display_error(_("The entered date is invalid.")); set_focus('DatePaid'); return false; } elseif (!is_date_in_fiscalyear($_POST['DatePaid'])) { display_error(_("The entered date is out of fiscal year or is closed for further data entry.")); set_focus('DatePaid'); return false; } $limit = get_bank_account_limit($_POST['bank_account'], $_POST['DatePaid']); if ($limit !== null && floatcmp($limit, input_num('amount')) < 0) { display_error(sprintf(_("The total bank amount exceeds allowed limit (%s)."), price_format($limit))); set_focus('amount'); return false; } if (!$Refs->is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); set_focus('ref'); return false; } if (!is_new_reference($_POST['ref'], ST_SUPPAYMENT)) { display_error(_("The entered reference is already in use.")); set_focus('ref'); return false; } if (!db_has_currency_rates(get_supplier_currency($_POST['supplier_id']), $_POST['DatePaid'], true)) { return false; } $_SESSION['alloc']->amount = -input_num('amount'); if (isset($_POST["TotalNumberOfAllocs"])) { return check_allocations(); } else { return true; } }
start_table(TABLESTYLE_NOBORDER); start_row(); gl_all_accounts_list_cells(null, 'AccountList', null, false, false, _('New account'), true, check_value('show_inactive')); check_cells(_("Show inactive:"), 'show_inactive', null, true); end_row(); end_table(); if (get_post('_show_inactive_update')) { $Ajax->activate('AccountList'); set_focus('AccountList'); } } br(1); start_table(TABLESTYLE2); if ($selected_account != "") { //editing an existing account $myrow = get_gl_account($selected_account); $_POST['account_code'] = $myrow["account_code"]; $_POST['account_code2'] = $myrow["account_code2"]; $_POST['account_name'] = $myrow["account_name"]; $_POST['account_type'] = $myrow["account_type"]; $_POST['inactive'] = $myrow["inactive"]; $tags_result = get_tags_associated_with_record(TAG_ACCOUNT, $selected_account); $tagids = array(); while ($tag = db_fetch($tags_result)) { $tagids[] = $tag['id']; } $_POST['account_tags'] = $tagids; hidden('account_code', $_POST['account_code']); hidden('selected_account', $selected_account); label_row(_("Account Code:"), $_POST['account_code']); } else {
} } if ($error) { $errCnt++; } $error = false; init_entry($entry, $type, $date, $reference); $curEntryId = $entryid; $curDate = $date; } if ($entryid == '') { display_error("Error: entryid not specified (line {$line} in import file '{$_FILES['imp']['name']}')"); $error = true; } // Check that the account code exists if (get_gl_account($code) == null) { display_error("Error: Could not find account code '{$code}' (line {$line} in import file '{$_FILES['imp']['name']}')"); $error = true; } // Check that dimension 1 exists $dim1 = get_dimension_id_from_reference($dim1_ref); if ($dim1_ref != '' && $dim1 == null) { display_error("Error: Could not find dimension with reference '{$dim1_ref}' (line {$line} in import file '{$_FILES['imp']['name']}')"); $error = true; } // Check that dimension 2 exists $dim2 = get_dimension_id_from_reference($dim2_ref); if ($dim2_ref != '' && $dim2 == null) { display_error("Error: Could not find dimension with reference '{$dim2_ref}' (line {$line} in import file '{$_FILES['imp']['name']}')"); $error = true; }