X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;ds=inline;f=purchasing%2Fsupplier_invoice.php;h=9341a11cc1f403771899605fd9dd0d2bc726fc16;hb=1bb2f13025c8472861d331315f6d33b2241de046;hp=b4a83c48a3948506d95c3b63363a07535c372d41;hpb=431531eebf3ba494002cfbf7ea36f9e82d4975c0;p=fa-stable.git diff --git a/purchasing/supplier_invoice.php b/purchasing/supplier_invoice.php index b4a83c48..9341a11c 100644 --- a/purchasing/supplier_invoice.php +++ b/purchasing/supplier_invoice.php @@ -23,6 +23,18 @@ page(_("Enter Supplier Invoice"), false, false, "", $js); check_db_has_suppliers(_("There are no suppliers defined in the system.")); +//--------------------------------------------------------------------------------------------------------------- +if ($ret = context_restore()) { + // return from supplier editor + copy_from_trans($_SESSION['supp_trans']); + if(isset($ret['supplier_id'])) + $_POST['supplier_id'] = $ret['supplier_id']; +} +if (isset($_POST['_supplier_id_editor'])) { + copy_to_trans($_SESSION['supp_trans']); + context_call($path_to_root.'/purchasing/manage/suppliers.php?supplier_id='.$_POST['supplier_id'], 'supp_trans'); +} + //--------------------------------------------------------------------------------------------------------------- if (isset($_GET['AddedID'])) @@ -60,6 +72,63 @@ if (isset($_GET['New'])) } //-------------------------------------------------------------------------------------------------- +function clear_fields() +{ + global $Ajax; + + unset($_POST['gl_code']); + unset($_POST['dimension_id']); + unset($_POST['dimension2_id']); + unset($_POST['amount']); + unset($_POST['memo_']); + unset($_POST['AddGLCodeToTrans']); + $Ajax->activate('gl_ctrls'); + set_focus('gl_code'); +} +//------------------------------------------------------------------------------------------------ +// GL postings are often entered in the same form to two accounts +// so fileds are cleared only on user demand. +// +if (isset($_POST['ClearFields'])) +{ + clear_fields(); +} + +if (isset($_POST['AddGLCodeToTrans'])){ + + $Ajax->activate('gl_items'); + $input_error = false; + + $sql = "SELECT account_code, account_name FROM ".TB_PREF."chart_master WHERE account_code='" . $_POST['gl_code'] . "'"; + $result = db_query($sql,"get account information"); + if (db_num_rows($result) == 0) + { + display_error(_("The account code entered is not a valid code, this line cannot be added to the transaction.")); + set_focus('gl_code'); + $input_error = true; + } + else + { + $myrow = db_fetch_row($result); + $gl_act_name = $myrow[1]; + if (!check_num('amount')) + { + display_error(_("The amount entered is not numeric. This line cannot be added to the transaction.")); + set_focus('amount'); + $input_error = true; + } + } + + if ($input_error == false) + { + $_SESSION['supp_trans']->add_gl_codes_to_trans($_POST['gl_code'], $gl_act_name, + $_POST['dimension_id'], $_POST['dimension2_id'], + input_num('amount'), $_POST['memo_']); + set_focus('gl_code'); + } +} + +//------------------------------------------------------------------------------------------------ function check_data() { @@ -72,34 +141,40 @@ function check_data() if (!references::is_valid($_SESSION['supp_trans']->reference)) { display_error(_("You must enter an invoice reference.")); + set_focus('reference'); return false; } if (!is_new_reference($_SESSION['supp_trans']->reference, 20)) { display_error(_("The entered reference is already in use.")); + set_focus('reference'); return false; } if (!references::is_valid($_SESSION['supp_trans']->supp_reference)) { display_error(_("You must enter a supplier's invoice reference.")); + set_focus('supp_reference'); return false; } if (!is_date( $_SESSION['supp_trans']->tran_date)) { display_error(_("The invoice as entered cannot be processed because the invoice date is in an incorrect format.")); + set_focus('trans_date'); return false; } elseif (!is_date_in_fiscalyear($_SESSION['supp_trans']->tran_date)) { display_error(_("The entered date is not in fiscal year.")); + set_focus('trans_date'); return false; } if (!is_date( $_SESSION['supp_trans']->due_date)) { display_error(_("The invoice as entered cannot be processed because the due date is in an incorrect format.")); + set_focus('due_date'); return false; } @@ -140,35 +215,168 @@ if (isset($_POST['PostInvoice'])) handle_commit_invoice(); } -//-------------------------------------------------------------------------------------------------- +function check_item_data($n) +{ + global $check_price_charged_vs_order_price, + $check_qty_charged_vs_del_qty; + if (!check_num('this_quantity_inv'.$n, 0) || input_num('this_quantity_inv'.$n)==0) + { + display_error( _("The quantity to invoice must be numeric and greater than zero.")); + set_focus('this_quantity_inv'.$n); + return false; + } -start_form(false, true); + if (!check_num('ChgPrice'.$n)) + { + display_error( _("The price is not numeric.")); + set_focus('ChgPrice'.$n); + return false; + } -start_table("$table_style2 width=80%", 8); -echo "