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; } }
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; } }
div_start('alloc_tbl'); if (count($cart->allocs) > 0) { show_allocatable(true); submit_center_first('UpdateDisplay', _("Refresh"), _('Start again allocation of selected amount'), true); submit('Process', _("Process"), true, _('Process allocations'), 'default'); submit_center_last('Cancel', _("Back to Allocations"), _('Abandon allocations and return to selection of allocatable amounts'), 'cancel'); } else { display_note(_("There are no unsettled transactions to allocate."), 0, 1); submit_center('Cancel', _("Back to Allocations"), true, _('Abandon allocations and return to selection of allocatable amounts'), 'cancel'); } div_end(); end_form(); } //-------------------------------------------------------------------------------- if (isset($_POST['Process'])) { if (check_allocations()) { $_SESSION['alloc']->write(); clear_allocations(); $_POST['Cancel'] = 1; } } //-------------------------------------------------------------------------------- if (isset($_POST['Cancel'])) { clear_allocations(); meta_forward($path_to_root . "/sales/allocations/customer_allocation_main.php"); } //-------------------------------------------------------------------------------- if (isset($_GET['trans_no']) && isset($_GET['trans_type'])) { clear_allocations(); $_SESSION['alloc'] = new allocation($_GET['trans_type'], $_GET['trans_no'], @$_GET['debtor_no'], PT_CUSTOMER); }