"; hyperlink_params($path_to_root . "/purchasing/allocations/supplier_allocate.php", _("Allocate this Payment"), "trans_no=$payment_id&trans_type=22"); echo "

"; hyperlink_params($_SERVER['PHP_SELF'], _("Enter another supplier payment"), "supplier_id=" . $_POST['supplier_id']); echo "

"; end_page(); exit; } //---------------------------------------------------------------------------------------- function display_controls() { global $table_style2; start_form(false, true); if (!isset($_POST['supplier_id'])) $_POST['supplier_id'] = get_global_supplier(false); if (!isset($_POST['DatePaid'])) { $_POST['DatePaid'] = Today(); if (!is_date_in_fiscalyear($_POST['DatePaid'])) $_POST['DatePaid'] = end_fiscalyear(); } start_table($table_style2, 5, 7); echo ""; // outer table echo ""; bank_accounts_list_row(_("From Bank Account:"), 'bank_account', null, true); amount_row(_("Amount of Payment:"), 'amount'); amount_row(_("Amount of Discount:"), 'discount'); date_row(_("Date Paid") . ":", 'DatePaid'); echo "
"; echo ""; // outer table echo ""; supplier_list_row(_("Payment To:"), 'supplier_id', null, false, true); set_global_supplier($_POST['supplier_id']); $supplier_currency = get_supplier_currency($_POST['supplier_id']); $bank_currency = get_bank_account_currency($_POST['bank_account']); if ($bank_currency != $supplier_currency) { exchange_rate_display($bank_currency, $supplier_currency, $_POST['DatePaid']); } bank_trans_types_list_row(_("Payment Type:"), 'PaymentType', null); ref_row(_("Reference:"), 'ref', references::get_next(22)); text_row(_("Memo:"), 'memo_', null, 52,50); echo "
"; echo ""; end_table(1); // outer table submit_center('ProcessSuppPayment',_("Enter Payment")); if ($bank_currency != $supplier_currency) { display_note(_("The amount and discount are in the bank account's currency."), 2, 0); } end_form(); } //---------------------------------------------------------------------------------------- function check_inputs() { if ($_POST['amount'] == "") { $_POST['amount'] = 0; } if (!is_numeric($_POST['amount']) || $_POST['amount'] < 0) { display_error(_("The entered amount is invalid or less than zero.")); return false; } if ($_POST['discount'] == "") { $_POST['discount'] = 0; } if (!is_numeric($_POST['discount']) OR $_POST['discount'] < 0) { display_error(_("The entered discount is invalid or less than zero.")); return false; } if ($_POST['amount'] - $_POST['discount'] <= 0) { display_error(_("The total of the amount and the discount negative. Please enter positive values.")); return false; } if (!is_date($_POST['DatePaid'])) { display_error(_("The entered date is invalid.")); return false; } elseif (!is_date_in_fiscalyear($_POST['DatePaid'])) { display_error(_("The entered date is not in fiscal year.")); return false; } if (!references::is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); return false; } if (!is_new_reference($_POST['ref'], 22)) { display_error(_("The entered reference is already in use.")); return false; } return true; } //---------------------------------------------------------------------------------------- function handle_add_payment() { $payment_id = add_supp_payment($_POST['supplier_id'], $_POST['DatePaid'], $_POST['PaymentType'], $_POST['bank_account'], $_POST['amount'], $_POST['discount'], $_POST['ref'], $_POST['memo_']); //unset($_POST['supplier_id']); unset($_POST['bank_account']); unset($_POST['DatePaid']); unset($_POST['PaymentType']); unset($_POST['currency']); unset($_POST['memo_']); unset($_POST['amount']); unset($_POST['discount']); unset($_POST['ProcessSuppPayment']); meta_forward($_SERVER['PHP_SELF'], "AddedID=$payment_id&supplier_id=".$_POST['supplier_id']); } //---------------------------------------------------------------------------------------- if (isset($_POST['ProcessSuppPayment'])) { /*First off check for valid inputs */ if (check_inputs() == true) { handle_add_payment(); end_page(); exit; } } display_controls(); end_page(); ?>