From 6183e9450dcd7e4c747889c10903f6ff1b0add33 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Wed, 2 Apr 2008 10:48:47 +0000 Subject: [PATCH] Focus set to invalid field after submit check fail --- admin/backups.php | 2 +- admin/company_preferences.php | 1 + admin/fiscalyears.php | 3 +++ admin/gl_setup.php | 3 +++ admin/payment_terms.php | 4 ++++ admin/shipping_companies.php | 1 + admin/users.php | 3 +++ admin/void_transaction.php | 9 ++++++++- dimensions/dimension_entry.php | 6 ++++++ gl/bank_transfer.php | 6 ++++++ gl/gl_deposit.php | 7 +++++++ gl/gl_journal.php | 14 ++++++++++++-- gl/gl_payment.php | 7 +++++++ gl/manage/bank_accounts.php | 1 + gl/manage/bank_trans_types.php | 1 + gl/manage/currencies.php | 4 ++++ gl/manage/exchange_rates.php | 3 +++ gl/manage/gl_account_classes.php | 1 + gl/manage/gl_account_types.php | 1 + gl/manage/gl_accounts.php | 3 +++ inventory/adjustments.php | 6 ++++++ inventory/cost_update.php | 1 + inventory/manage/item_categories.php | 1 + inventory/manage/item_units.php | 3 +++ inventory/manage/items.php | 3 +++ inventory/manage/locations.php | 2 ++ inventory/manage/movement_types.php | 1 + inventory/prices.php | 1 + inventory/purchasing_data.php | 4 ++++ inventory/transfers.php | 7 +++++++ manufacturing/manage/bom_edit.php | 1 + manufacturing/manage/work_centres.php | 1 + manufacturing/work_order_add_finished.php | 17 +++++++++-------- manufacturing/work_order_entry.php | 10 ++++++++++ manufacturing/work_order_issue.php | 7 +++++++ manufacturing/work_order_release.php | 2 ++ purchasing/allocations/supplier_allocate.php | 1 + purchasing/manage/suppliers.php | 1 + purchasing/po_entry_items.php | 13 +++++++++++-- purchasing/po_receive_items.php | 3 +++ purchasing/supplier_credit.php | 7 +++++++ purchasing/supplier_credit_grns.php | 2 ++ purchasing/supplier_invoice.php | 6 ++++++ purchasing/supplier_invoice_grns.php | 4 ++++ purchasing/supplier_payment.php | 7 +++++++ purchasing/supplier_trans_gl.php | 2 ++ sales/allocations/customer_allocate.php | 2 ++ sales/credit_note_entry.php | 7 +++++++ sales/customer_credit_invoice.php | 5 +++++ sales/customer_delivery.php | 7 +++++++ sales/customer_invoice.php | 6 ++++++ sales/customer_payments.php | 7 +++++++ sales/sales_order_entry.php | 12 ++++++++++++ taxes/item_tax_types.php | 1 + taxes/tax_groups.php | 6 ++++-- taxes/tax_types.php | 3 +++ 56 files changed, 233 insertions(+), 16 deletions(-) diff --git a/admin/backups.php b/admin/backups.php index 3286f48c..4fcc453f 100644 --- a/admin/backups.php +++ b/admin/backups.php @@ -216,7 +216,7 @@ function get_backup_file_combo() { global $path_to_root; $ar_files = array(); - + default_focus('cmb_backups'); $dh = opendir(BACKUP_PATH); while (($file = readdir($dh)) !== false) $ar_files[] = $file; diff --git a/admin/company_preferences.php b/admin/company_preferences.php index d4f3839d..69dc25b6 100644 --- a/admin/company_preferences.php +++ b/admin/company_preferences.php @@ -22,6 +22,7 @@ if (isset($_POST['submit']) && $_POST['submit'] != "") { $input_error = 1; display_error(_("The company name must be entered.")); + set_focus('coy_name'); } if ($input_error != 1) { diff --git a/admin/fiscalyears.php b/admin/fiscalyears.php index a1f1b751..414f655c 100644 --- a/admin/fiscalyears.php +++ b/admin/fiscalyears.php @@ -36,16 +36,19 @@ function check_data() if (!is_date($from)) { display_error( _("Invalid BEGIN date in fiscal year.")); + set_focus('from_date'); return false; } if (!is_date($_POST['to_date'])) { display_error( _("Invalid END date in fiscal year.")); + set_focus('to_date'); return false; } if (date1_greater_date2($from, $_POST['to_date'])) { display_error( _("BEGIN date bigger than END date.")); + set_focus('from_date'); return false; } return true; diff --git a/admin/gl_setup.php b/admin/gl_setup.php index a0c99433..cf107a41 100644 --- a/admin/gl_setup.php +++ b/admin/gl_setup.php @@ -19,18 +19,21 @@ function can_process() if (!check_num('po_over_receive', 0, 100)) { display_error(_("The delivery over-receive allowance must be between 0 and 100.")); + set_focus('po_over_receive'); return false; } if (!check_num('po_over_charge', 0, 100)) { display_error(_("The invoice over-charge allowance must be between 0 and 100.")); + set_focus('po_over_charge'); return false; } if (!check_num('past_due_days', 0, 100)) { display_error(_("The past due days interval allowance must be between 0 and 100.")); + set_focus('past_due_days'); return false; } return true; diff --git a/admin/payment_terms.php b/admin/payment_terms.php index cf46b906..1edaa025 100644 --- a/admin/payment_terms.php +++ b/admin/payment_terms.php @@ -31,21 +31,25 @@ if (isset($_POST['ADD_ITEM']) OR isset($_POST['UPDATE_ITEM'])) { $inpug_error = 1; display_error( _("The number of days or the day in the following month must be numeric.")); + set_focus('DayNumber'); } elseif (strlen($_POST['terms']) == 0) { $inpug_error = 1; display_error( _("The Terms description must be entered.")); + set_focus('terms'); } elseif ($_POST['DayNumber'] > 30 && !check_value('DaysOrFoll')) { $inpug_error = 1; display_error( _("When the check box to indicate a day in the following month is the due date, the due date cannot be a day after the 30th. A number between 1 and 30 is expected.")); + set_focus('DayNumber'); } elseif ($_POST['DayNumber'] > 500 && check_value('DaysOrFoll')) { $inpug_error = 1; display_error( _("When the check box is not checked to indicate that the term expects a number of days after which accounts are due, the number entered should be less than 500 days.")); + set_focus('DayNumber'); } if ($_POST['DayNumber'] == '') diff --git a/admin/shipping_companies.php b/admin/shipping_companies.php index 7d4e530c..9fd8af59 100644 --- a/admin/shipping_companies.php +++ b/admin/shipping_companies.php @@ -24,6 +24,7 @@ function can_process() if (strlen($_POST['shipper_name']) == 0) { display_error(_("The shipping company name cannot be empty.")); + set_focus('shipper_name'); return false; } return true; diff --git a/admin/users.php b/admin/users.php index 8eeb575c..765997cb 100644 --- a/admin/users.php +++ b/admin/users.php @@ -45,6 +45,7 @@ function can_process() if (strlen($_POST['user_id']) < 4) { display_error( _("The user login entered must be at least 4 characters long.")); + set_focus('user_id'); return false; } @@ -53,12 +54,14 @@ function can_process() if (strlen($_POST['password']) < 4) { display_error( _("The password entered must be at least 4 characters long.")); + set_focus('password'); return false; } if (strstr($_POST['password'], $_POST['user_id']) != false) { display_error( _("The password cannot contain the user login.")); + set_focus('password'); return false; } } diff --git a/admin/void_transaction.php b/admin/void_transaction.php index 8b6ab746..371e3e5a 100644 --- a/admin/void_transaction.php +++ b/admin/void_transaction.php @@ -54,17 +54,20 @@ function check_valid_entries() if (!is_date($_POST['date_'])) { display_error(_("The entered date is invalid.")); + set_focus('date_'); return false; } if (!is_date_in_fiscalyear($_POST['date_'])) { display_error(_("The entered date is not in fiscal year.")); + set_focus('date_'); return false; } if (!is_numeric($_POST['trans_no']) OR $_POST['trans_no'] <= 0) { display_error(_("The transaction number is expected to be numeric and greater than zero.")); + set_focus('trans_no'); return false; } @@ -85,6 +88,7 @@ function handle_void_transaction() unset($_POST['trans_no']); unset($_POST['memo_']); unset($_POST['date_']); + set_focus('trans_no'); return; } @@ -98,8 +102,11 @@ function handle_void_transaction() unset($_POST['memo_']); unset($_POST['date_']); } - else + else { display_error(_("The entered transaction does not exist or cannot be voided.")); + set_focus('trans_no'); + + } } } diff --git a/dimensions/dimension_entry.php b/dimensions/dimension_entry.php index c1c0a0be..e0b89b3f 100644 --- a/dimensions/dimension_entry.php +++ b/dimensions/dimension_entry.php @@ -98,12 +98,14 @@ function can_process() if (!references::is_valid($_POST['ref'])) { display_error( _("The dimension reference must be entered.")); + set_focus('ref'); return false; } if (!is_new_reference($_POST['ref'], systypes::dimension())) { display_error(_("The entered reference is already in use.")); + set_focus('ref'); return false; } } @@ -111,18 +113,21 @@ function can_process() if (strlen($_POST['name']) == 0) { display_error( _("The dimension name must be entered.")); + set_focus('name'); return false; } if (!is_date($_POST['date_'])) { display_error( _("The date entered is in an invalid format.")); + set_focus('date_'); return false; } if (!is_date($_POST['due_date'])) { display_error( _("The required by date entered is in an invalid format.")); + set_focus('due_date'); return false; } @@ -165,6 +170,7 @@ if (isset($_POST['delete'])) if (dimension_has_payments($selected_id) || dimension_has_deposits($selected_id)) { display_error(_("This dimension cannot be deleted because it has already been processed.")); + set_focus('ref'); $cancel_delete = true; } diff --git a/gl/bank_transfer.php b/gl/bank_transfer.php index 5f5a783b..6c7133de 100644 --- a/gl/bank_transfer.php +++ b/gl/bank_transfer.php @@ -96,35 +96,41 @@ function check_valid_entries() if (!is_date($_POST['DatePaid'])) { display_error(_("The entered date is invalid.")); + set_focus('DatePaid'); return false; } if (!is_date_in_fiscalyear($_POST['DatePaid'])) { display_error(_("The entered date is not in fiscal year.")); + set_focus('DatePaid'); return false; } if (!check_num('amount', 0)) { display_error(_("The entered amount is invalid or less than zero.")); + set_focus('amount'); return false; } if (!references::is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); + set_focus('ref'); return false; } if (!is_new_reference($_POST['ref'], systypes::bank_transfer())) { display_error(_("The entered reference is already in use.")); + set_focus('ref'); return false; } if ($_POST['FromBankAccount'] == $_POST['ToBankAccount']) { display_error(_("The source and destination bank accouts cannot be the same.")); + set_focus('ToBankAccount'); return false; } diff --git a/gl/gl_deposit.php b/gl/gl_deposit.php index a64a5b45..3b9a3c62 100644 --- a/gl/gl_deposit.php +++ b/gl/gl_deposit.php @@ -101,23 +101,27 @@ if (isset($_POST['Process'])) if (!references::is_valid($_POST['ref'])) { display_error( _("You must enter a reference.")); + set_focus('ref'); $input_error = 1; } elseif (!is_new_reference($_POST['ref'], systypes::bank_deposit())) { display_error( _("The entered reference is already in use.")); + set_focus('ref'); $input_error = 1; } if (!is_date($_POST['date_'])) { display_error(_("The entered date for the deposit is invalid.")); + set_focus('date_'); $input_error = 1; } if (!is_date_in_fiscalyear($_POST['date_'])) { display_error(_("The entered date is not in fiscal year.")); + set_focus('date_'); $input_error = 1; } @@ -152,18 +156,21 @@ function check_item_data() if (!check_num('amount', 0)) { display_error( _("The amount entered is not a valid number or is less than zero.")); + set_focus('amount'); return false; } if ($_POST['code_id'] == $_POST['bank_account']) { display_error( _("The source and destination accouts cannot be the same.")); + set_focus('code_id'); return false; } if (is_bank_account($_POST['code_id'])) { display_error( _("You cannot make a deposit from a bank account. Please use the transfer funds facility for this.")); + set_focus('code_id'); return false; } diff --git a/gl/gl_journal.php b/gl/gl_journal.php index e6f1bcc6..5c974d29 100644 --- a/gl/gl_journal.php +++ b/gl/gl_journal.php @@ -87,21 +87,25 @@ if (isset($_POST['Process'])) if (!is_date($_POST['date_'])) { display_error(_("The entered date is invalid.")); + set_focus('date_'); $input_error = 1; } elseif (!is_date_in_fiscalyear($_POST['date_'])) { display_error(_("The entered date is not in fiscal year.")); + set_focus('date_'); $input_error = 1; } elseif (!references::is_valid($_POST['ref'])) { display_error( _("You must enter a reference.")); + set_focus('ref'); $input_error = 1; } elseif (references::exists(systypes::journal_entry(), $_POST['ref'])) { display_error( _("The entered reference is already in use.")); + set_focus('ref'); $input_error = 1; } @@ -128,28 +132,33 @@ function check_item_data() if (isset($_POST['dimension_id']) && $_POST['dimension_id'] != 0 && dimension_is_closed($_POST['dimension_id'])) { display_error(_("Dimension is closed.")); - return false; + set_focus('dimension_id'); + return false; } if (isset($_POST['dimension2_id']) && $_POST['dimension2_id'] != 0 && dimension_is_closed($_POST['dimension2_id'])) { display_error(_("Dimension is closed.")); - return false; + set_focus('dimension2_id'); + return false; } if (!(input_num('AmountDebit')!=0 ^ input_num('AmountCredit')!=0) ) { display_error(_("You must enter either a debit amount or a credit amount.")); + set_focus('Amount_Debit'); return false; } if (strlen($_POST['AmountDebit']) && !check_num('AmountDebit', 0)) { display_error(_("The debit amount entered is not a valid number or is less than zero.")); + set_focus('AmountDebit'); return false; } elseif (strlen($_POST['AmountCredit']) && !check_num('AmountCredit', 0)) { display_error(_("The credit amount entered is not a valid number or is less than zero.")); + set_focus('AmountCredit'); return false; } @@ -157,6 +166,7 @@ function check_item_data() if ($_SESSION["wa_current_user"]->access != 2 && is_bank_account($_POST['code_id'])) { display_error(_("You cannot make a journal entry for a bank account. Please use one of the banking functions for bank transactions.")); + set_focus('code_id'); return false; } diff --git a/gl/gl_payment.php b/gl/gl_payment.php index 24be2b43..12d05480 100644 --- a/gl/gl_payment.php +++ b/gl/gl_payment.php @@ -102,21 +102,25 @@ if (isset($_POST['Process'])) if (!references::is_valid($_POST['ref'])) { display_error( _("You must enter a reference.")); + set_focus('ref'); $input_error = 1; } elseif (!is_new_reference($_POST['ref'], systypes::bank_payment())) { display_error( _("The entered reference is already in use.")); + set_focus('ref'); $input_error = 1; } elseif (!is_date($_POST['date_'])) { display_error(_("The entered date for the payment is invalid.")); + set_focus('date_'); $input_error = 1; } elseif (!is_date_in_fiscalyear($_POST['date_'])) { display_error(_("The entered date is not in fiscal year.")); + set_focus('date_'); $input_error = 1; } @@ -149,18 +153,21 @@ function check_item_data() if (!check_num('amount', 0)) { display_error( _("The amount entered is not a valid number or is less than zero.")); + set_focus('amount'); return false; } if ($_POST['code_id'] == $_POST['bank_account']) { display_error( _("The source and destination accouts cannot be the same.")); + set_focus('code_id'); return false; } if (is_bank_account($_POST['code_id'])) { display_error( _("You cannot make a payment to a bank account. Please use the transfer funds facility for this.")); + set_focus('code_id'); return false; } diff --git a/gl/manage/bank_accounts.php b/gl/manage/bank_accounts.php index 14b4e794..c7d665c3 100644 --- a/gl/manage/bank_accounts.php +++ b/gl/manage/bank_accounts.php @@ -28,6 +28,7 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) { $input_error = 1; display_error(_("The bank account name cannot be empty.")); + set_focus('bank_account_name'); } if ($input_error != 1) diff --git a/gl/manage/bank_trans_types.php b/gl/manage/bank_trans_types.php index bc9efacd..5f5267f3 100644 --- a/gl/manage/bank_trans_types.php +++ b/gl/manage/bank_trans_types.php @@ -33,6 +33,7 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) { $input_error = 1; display_error( _("The bank transaction type name cannot be empty.")); + set_focus('name'); } if ($input_error != 1) diff --git a/gl/manage/currencies.php b/gl/manage/currencies.php index 1cdd5421..0204cfd7 100644 --- a/gl/manage/currencies.php +++ b/gl/manage/currencies.php @@ -28,21 +28,25 @@ function check_data() if (strlen($_POST['Abbreviation']) == 0) { display_error( _("The currency abbreviation must be entered.")); + set_focus('Abbreviation'); return false; } elseif (strlen($_POST['CurrencyName']) == 0) { display_error( _("The currency name must be entered.")); + set_focus('CurrencyName'); return false; } elseif (strlen($_POST['Symbol']) == 0) { display_error( _("The currency symbol must be entered.")); + set_focus('Symbol'); return false; } elseif (strlen($_POST['hundreds_name']) == 0) { display_error( _("The hundredths name must be entered.")); + set_focus('hundreds_name'); return false; } diff --git a/gl/manage/exchange_rates.php b/gl/manage/exchange_rates.php index 77decb39..5ece97ad 100644 --- a/gl/manage/exchange_rates.php +++ b/gl/manage/exchange_rates.php @@ -31,16 +31,19 @@ function check_data() if (!is_date($_POST['date_'])) { display_error( _("The entered date is invalid.")); + set_focus('date_'); return false; } if (!check_num('BuyRate', 0)) { display_error( _("The exchange rate must be numeric and greater than zero.")); + set_focus('BuyRate'); return false; } if ($_POST['BuyRate'] <= 0) { display_error( _("The exchange rate cannot be zero or a negative number.")); + set_focus('BuyRate'); return false; } diff --git a/gl/manage/gl_account_classes.php b/gl/manage/gl_account_classes.php index cfdff8a8..f0fd7edb 100644 --- a/gl/manage/gl_account_classes.php +++ b/gl/manage/gl_account_classes.php @@ -28,6 +28,7 @@ function can_process() if (strlen($_POST['name']) == 0) { display_error( _("The account class name cannot be empty.")); + set_focus('name'); return false; } diff --git a/gl/manage/gl_account_types.php b/gl/manage/gl_account_types.php index 915835d8..8485eb76 100644 --- a/gl/manage/gl_account_types.php +++ b/gl/manage/gl_account_types.php @@ -29,6 +29,7 @@ function can_process() if (strlen($_POST['name']) == 0) { display_error( _("The account group name cannot be empty.")); + set_focus('name'); return false; } diff --git a/gl/manage/gl_accounts.php b/gl/manage/gl_accounts.php index 1a10f414..6c46842f 100644 --- a/gl/manage/gl_accounts.php +++ b/gl/manage/gl_accounts.php @@ -41,16 +41,19 @@ if (isset($_POST['add']) || isset($_POST['update'])) { $input_error = 1; display_error( _("The account code must be entered.")); + set_focus('account_code'); } elseif (strlen($_POST['account_name']) == 0) { $input_error = 1; display_error( _("The account name cannot be empty.")); + set_focus('account_name'); } elseif (!$accounts_alpha && !is_numeric($_POST['account_code'])) { $input_error = 1; display_error( _("The account code must be numeric.")); + set_focus('account_code'); } if ($input_error != 1) diff --git a/inventory/adjustments.php b/inventory/adjustments.php index a70d2d54..1f9d04a5 100644 --- a/inventory/adjustments.php +++ b/inventory/adjustments.php @@ -89,23 +89,27 @@ function can_process() if (!references::is_valid($_POST['ref'])) { display_error( _("You must enter a reference.")); + set_focus('ref'); return false; } if (!is_new_reference($_POST['ref'], systypes::inventory_adjustment())) { display_error( _("The entered reference is already in use.")); + set_focus('ref'); return false; } if (!is_date($_POST['AdjDate'])) { display_error(_("The entered date for the adjustment is invalid.")); + set_focus('AdjDate'); return false; } elseif (!is_date_in_fiscalyear($_POST['AdjDate'])) { display_error(_("The entered date is not in fiscal year.")); + set_focus('AdjDate'); return false; } $failed_item = $_SESSION['adj_items']->check_qoh($_POST['StockLocation'], $_POST['AdjDate'], !$_POST['Increase']); @@ -139,12 +143,14 @@ function check_item_data() if (!check_num('qty',0)) { display_error(_("The quantity entered is negative or invalid.")); + set_focus('qty'); return false; } if (!check_num('std_cost', 0)) { display_error(_("The entered standard cost is negative or invalid.")); + set_focus('std_cost'); return false; } diff --git a/inventory/cost_update.php b/inventory/cost_update.php index 39216039..16544599 100644 --- a/inventory/cost_update.php +++ b/inventory/cost_update.php @@ -41,6 +41,7 @@ if (isset($_POST['UpdateData'])) !check_num('overhead_cost')) { display_error( _("The entered cost is not numeric.")); + set_focus('material_cost'); $should_update = false; } elseif ($old_cost == $new_cost) diff --git a/inventory/manage/item_categories.php b/inventory/manage/item_categories.php index d32ba2ea..4474dc97 100644 --- a/inventory/manage/item_categories.php +++ b/inventory/manage/item_categories.php @@ -31,6 +31,7 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) { $input_error = 1; display_error(_("The item category description cannot be empty.")); + set_focus('description'); } if ($input_error !=1) diff --git a/inventory/manage/item_units.php b/inventory/manage/item_units.php index 76af07d9..ce5f50d0 100644 --- a/inventory/manage/item_units.php +++ b/inventory/manage/item_units.php @@ -31,16 +31,19 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) { $input_error = 1; display_error(_("The unit of measure code cannot be empty.")); + set_focus('abbr'); } if (strlen($_POST['description']) == 0) { $input_error = 1; display_error(_("The unit of measure description cannot be empty.")); + set_focus('description'); } if (!is_numeric($_POST['decimals'])) { $input_error = 1; display_error(_("The number of decimal places must be integer.")); + set_focus('decimals'); } diff --git a/inventory/manage/items.php b/inventory/manage/items.php index 4a954d34..199addb2 100644 --- a/inventory/manage/items.php +++ b/inventory/manage/items.php @@ -112,11 +112,13 @@ if (isset($_POST['addupdate'])) { $input_error = 1; display_error( _('The item name must be entered.')); + set_focus('description'); } elseif (strlen($_POST['NewStockID']) == 0) { $input_error = 1; display_error( _('The item code cannot be empty')); + set_focus('NewStockID'); } elseif (strstr($_POST['NewStockID'], " ") || strstr($_POST['NewStockID'],"'") || strstr($_POST['NewStockID'], "+") || strstr($_POST['NewStockID'], "\"") || @@ -124,6 +126,7 @@ if (isset($_POST['addupdate'])) { $input_error = 1; display_error( _('The item code cannot contain any of the following characters - & + OR a space OR quotes')); + set_focus('NewStockID'); } diff --git a/inventory/manage/locations.php b/inventory/manage/locations.php index fe90a68c..6bb732fc 100644 --- a/inventory/manage/locations.php +++ b/inventory/manage/locations.php @@ -35,11 +35,13 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) { $input_error = 1; display_error( _("The location code must be five characters or less long.")); + set_focus('loc_code'); } elseif (strlen($_POST['location_name']) == 0) { $input_error = 1; display_error( _("The location name must be entered.")); + set_focus('location_name'); } if ($input_error != 1) diff --git a/inventory/manage/movement_types.php b/inventory/manage/movement_types.php index 4a2369e7..5ac29b22 100644 --- a/inventory/manage/movement_types.php +++ b/inventory/manage/movement_types.php @@ -31,6 +31,7 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) { $input_error = 1; display_error(_("The inventory movement type name cannot be empty.")); + set_focus('name'); } if ($input_error != 1) diff --git a/inventory/prices.php b/inventory/prices.php index 06fab6d1..64371bbe 100644 --- a/inventory/prices.php +++ b/inventory/prices.php @@ -71,6 +71,7 @@ if (isset($_POST['updatePrice'])) { $input_error = 1; display_error( _("The price entered must be numeric.")); + set_focus('price'); } if ($input_error != 1) diff --git a/inventory/purchasing_data.php b/inventory/purchasing_data.php index 4d03d6fe..80a71d14 100644 --- a/inventory/purchasing_data.php +++ b/inventory/purchasing_data.php @@ -39,16 +39,19 @@ if ((isset($_POST['AddRecord']) || isset($_POST['UpdateRecord'])) && isset($supp { $input_error = 1; display_error( _("There is no item selected.")); + set_focus('stock_id'); } elseif (!check_num('price', 0)) { $input_error = 1; display_error( _("The price entered was not numeric.")); + set_focus('price'); } elseif (!check_num('conversion_factor')) { $input_error = 1; display_error( _("The conversion factor entered was not numeric. The conversion factor is the number by which the price must be divided by to get the unit price in our unit of measure.")); + set_focus('conversion_factor'); } if ($input_error == 0) @@ -123,6 +126,7 @@ $mb_flag = get_mb_flag($_POST['stock_id']); if ($mb_flag == -1) { display_error(_("Entered item is not defined. Please re-enter.")); + set_focus('stock_id'); } else { diff --git a/inventory/transfers.php b/inventory/transfers.php index 78f86a7d..c28604c0 100644 --- a/inventory/transfers.php +++ b/inventory/transfers.php @@ -91,26 +91,31 @@ if (isset($_POST['Process'])) if (!references::is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); + set_focus('ref'); $input_error = 1; } elseif (!is_new_reference($_POST['ref'], systypes::location_transfer())) { display_error(_("The entered reference is already in use.")); + set_focus('ref'); $input_error = 1; } elseif (!is_date($_POST['AdjDate'])) { display_error(_("The entered date for the adjustment is invalid.")); + set_focus('AdjDate'); $input_error = 1; } elseif (!is_date_in_fiscalyear($_POST['AdjDate'])) { display_error(_("The entered date is not in fiscal year.")); + set_focus('AdjDate'); $input_error = 1; } elseif ($_POST['FromStockLocation'] == $_POST['ToStockLocation']) { display_error(_("The locations to transfer from and to must be different.")); + set_focus('FromStockLocation'); $input_error = 1; } else @@ -151,12 +156,14 @@ function check_item_data() if (!check_num('qty')) { display_error( _("The quantity entered is not a valid number.")); + set_focus('qty'); return false; } if (!check_num('qty', 0)) { display_error(_("The quantity entered must be a positive number.")); + set_focus('qty'); return false; } diff --git a/manufacturing/manage/bom_edit.php b/manufacturing/manage/bom_edit.php index 94cc504c..9399d99b 100644 --- a/manufacturing/manage/bom_edit.php +++ b/manufacturing/manage/bom_edit.php @@ -119,6 +119,7 @@ function on_submit($selected_parent, $selected_component=null) if (!check_num('quantity', 0)) { display_error(_("The quantity entered must be numeric and greater than zero.")); + set_focus('quantity'); return; } diff --git a/manufacturing/manage/work_centres.php b/manufacturing/manage/work_centres.php index 865fecd8..bd08430e 100644 --- a/manufacturing/manage/work_centres.php +++ b/manufacturing/manage/work_centres.php @@ -31,6 +31,7 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) { $input_error = 1; display_error(_("The work centre name cannot be empty.")); + set_focus('name'); } if ($input_error != 1) diff --git a/manufacturing/work_order_add_finished.php b/manufacturing/work_order_add_finished.php index ecc1d0a6..9cb56074 100644 --- a/manufacturing/work_order_add_finished.php +++ b/manufacturing/work_order_add_finished.php @@ -53,40 +53,40 @@ function can_process() if (!references::is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); + set_focus('ref'); return false; } if (!is_new_reference($_POST['ref'], 29)) { display_error(_("The entered reference is already in use.")); + set_focus('ref'); return false; } - if (!is_numeric($_POST['quantity'])) + if (!check_num('quantity', 0)) { - display_error(_("The quantity entered is not a valid number.")); - return false; - } - - if ($_POST['quantity'] <= 0) - { - display_error(_("The quantity entered must be greater than zero.")); + display_error(_("The quantity entered is not a valid number or less then zero.")); + set_focus('quantity'); return false; } if (!is_date($_POST['date_'])) { display_error(_("The entered date is invalid.")); + set_focus('date_'); return false; } elseif (!is_date_in_fiscalyear($_POST['date_'])) { display_error(_("The entered date is not in fiscal year.")); + set_focus('date_'); return false; } if (date_diff(sql2date($wo_details["released_date"]), $_POST['date_'], "d") > 0) { display_error(_("The production date cannot be before the release date of the work order.")); + set_focus('date_'); return false; } @@ -99,6 +99,7 @@ function can_process() if (-$_POST['quantity'] + $qoh < 0) { display_error(_("The unassembling cannot be processed because there is insufficient stock.")); + set_focus('quantity'); return false; } } diff --git a/manufacturing/work_order_entry.php b/manufacturing/work_order_entry.php index 9abac4df..1a192ef0 100644 --- a/manufacturing/work_order_entry.php +++ b/manufacturing/work_order_entry.php @@ -105,12 +105,14 @@ function can_process() if (!references::is_valid($_POST['wo_ref'])) { display_error(_("You must enter a reference.")); + set_focus('wo_ref'); return false; } if (!is_new_reference($_POST['wo_ref'], systypes::work_order())) { display_error(_("The entered reference is already in use.")); + set_focus('wo_ref'); return false; } } @@ -118,17 +120,20 @@ function can_process() if (!check_num('quantity', 0)) { display_error( _("The quantity entered is invalid or less than zero.")); + set_focus('quantity'); return false; } if (!is_date($_POST['date_'])) { display_error( _("The date entered is in an invalid format.")); + set_focus('date_'); return false; } elseif (!is_date_in_fiscalyear($_POST['date_'])) { display_error(_("The entered date is not in fiscal year.")); + set_focus('date_'); return false; } // only check bom and quantites if quick assembly @@ -137,6 +142,7 @@ function can_process() if (!has_bom($_POST['stock_id'])) { display_error(_("The selected item to manufacture does not have a bom.")); + set_focus('stock_id'); return false; } @@ -145,6 +151,7 @@ function can_process() if (!check_num('Costs', 0)) { display_error( _("The cost entered is invalid or less than zero.")); + set_focus('Costs'); return false; } @@ -168,6 +175,7 @@ function can_process() { display_error(_("The work order cannot be processed because there is an insufficient quantity for component:") . " " . $bom_item["component"] . " - " . $bom_item["description"] . ". " . _("Location:") . " " . $bom_item["location_name"]); + set_focus('quantity'); return false; } } @@ -189,6 +197,7 @@ function can_process() { if (!is_date($_POST['RequDate'])) { + set_focus('RequDate'); display_error( _("The date entered is in an invalid format.")); return false; } @@ -203,6 +212,7 @@ function can_process() if ($_POST['units_issued'] > input_num('quantity')) { + set_focus('quantity'); display_error(_("The quantity cannot be changed to be less than the quantity already manufactured for this order.")); return false; } diff --git a/manufacturing/work_order_issue.php b/manufacturing/work_order_issue.php index ec394566..943dbc66 100644 --- a/manufacturing/work_order_issue.php +++ b/manufacturing/work_order_issue.php @@ -52,22 +52,26 @@ function can_process() if (!is_date($_POST['date_'])) { display_error(_("The entered date for the issue is invalid.")); + set_focus('date_'); return false; } elseif (!is_date_in_fiscalyear($_POST['date_'])) { display_error(_("The entered date is not in fiscal year.")); + set_focus('date_'); return false; } if (!references::is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); + set_focus('ref'); return false; } if (!is_new_reference($_POST['ref'], 28)) { display_error(_("The entered reference is already in use.")); + set_focus('ref'); return false; } @@ -110,18 +114,21 @@ function check_item_data() if (!is_numeric($_POST['qty'])) { display_error(_("The quantity entered is not a valid number.")); + set_focus('qty'); return false; } if ($_POST['qty'] <= 0) { display_error(_("The quantity entered must be greater than zero.")); + set_focus('qty'); return false; } if (!is_numeric($_POST['std_cost']) || $_POST['std_cost'] < 0) { display_error(_("The entered standard cost is negative or invalid.")); + set_focus('std_cost'); return false; } diff --git a/manufacturing/work_order_release.php b/manufacturing/work_order_release.php index 6b4effc2..18bae33d 100644 --- a/manufacturing/work_order_release.php +++ b/manufacturing/work_order_release.php @@ -36,6 +36,7 @@ function can_process($myrow) if ($myrow['released']) { display_error(_("This work order has already been released.")); + set_focus('released'); return false; } @@ -43,6 +44,7 @@ function can_process($myrow) if (!has_bom($myrow['stock_id'])) { display_error(_("This Work Order cannot be released. The selected item to manufacture does not have a bom.")); + set_focus('stock_id'); return false; } diff --git a/purchasing/allocations/supplier_allocate.php b/purchasing/allocations/supplier_allocate.php index 0a85f478..2f93c1a9 100644 --- a/purchasing/allocations/supplier_allocate.php +++ b/purchasing/allocations/supplier_allocate.php @@ -46,6 +46,7 @@ function check_data() if (!check_num('amount' . $counter, 0)) { display_error(_("The entry for one or more amounts is invalid or negative.")); + set_focus('amount'); return false; } diff --git a/purchasing/manage/suppliers.php b/purchasing/manage/suppliers.php index 6745d7b9..b1866cd1 100644 --- a/purchasing/manage/suppliers.php +++ b/purchasing/manage/suppliers.php @@ -37,6 +37,7 @@ if (isset($_POST['submit'])) { $input_error = 1; display_error(_("The supplier name must be entered.")); + set_focus('supp_name'); } if ($input_error !=1 ) diff --git a/purchasing/po_entry_items.php b/purchasing/po_entry_items.php index 57693a30..13897245 100644 --- a/purchasing/po_entry_items.php +++ b/purchasing/po_entry_items.php @@ -153,17 +153,20 @@ function check_data() if (!check_num('qty',0)) { display_error(_("The quantity of the order item must be numeric and not less than zero.")); + set_focus('qty'); return false; } if (!check_num('price', 0)) { display_error(_("The price entered must be numeric and not less than zero.")); + set_focus('price'); return false; } if (!is_date($_POST['req_del_date'])){ - display_error(_("The date entered is in an invalid format.")); - return false; + display_error(_("The date entered is in an invalid format.")); + set_focus('req_del_date'); + return false; } return true; @@ -181,6 +184,7 @@ function handle_update_item() { display_error(_("You are attempting to make the quantity ordered a quantity less than has already been invoiced or received. This is prohibited.") . "
" . _("The quantity received can only be modified by entering a negative receipt and the quantity invoiced can only be reduced by entering a credit note against this item.")); + set_focus('qty'); return; } @@ -251,6 +255,7 @@ function can_commit() if (!is_date($_POST['OrderDate'])) { display_error(_("The entered order date is invalid.")); + set_focus('OrderDate'); return false; } @@ -259,12 +264,14 @@ function can_commit() if (!references::is_valid($_SESSION['PO']->reference)) { display_error(_("There is no reference entered for this purchase order.")); + set_focus('ref'); return false; } if (!is_new_reference($_SESSION['PO']->reference, systypes::po())) { display_error(_("The entered reference is already in use.")); + set_focus('ref'); return false; } } @@ -272,12 +279,14 @@ function can_commit() if ($_SESSION['PO']->delivery_address == "") { display_error(_("There is no delivery address specified.")); + set_focus('delivery_address'); return false; } if (!isset($_SESSION['PO']->Location) || $_SESSION['PO']->Location == "") { display_error(_("There is no location specified to move any items into.")); + set_focus('StkLocation'); return false; } diff --git a/purchasing/po_receive_items.php b/purchasing/po_receive_items.php index 836a0548..e0a58428 100644 --- a/purchasing/po_receive_items.php +++ b/purchasing/po_receive_items.php @@ -154,18 +154,21 @@ function can_process() if (!is_date($_POST['DefaultReceivedDate'])) { display_error(_("The entered date is invalid.")); + set_focus('DefaultReceivedDate'); return false; } if (!references::is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); + set_focus('ref'); return false; } if (!is_new_reference($_POST['ref'], 25)) { display_error(_("The entered reference is already in use.")); + set_focus('ref'); return false; } diff --git a/purchasing/supplier_credit.php b/purchasing/supplier_credit.php index 680c988b..c16211be 100644 --- a/purchasing/supplier_credit.php +++ b/purchasing/supplier_credit.php @@ -66,40 +66,47 @@ function check_data() if (!$_SESSION['supp_trans']->is_valid_trans_to_post()) { display_error(_("The credit note cannot be processed because the there are no items or values on the invoice. Credit notes are expected to have a charge.")); + set_focus(''); return false; } if (!references::is_valid($_SESSION['supp_trans']->reference)) { display_error(_("You must enter an credit note reference.")); + set_focus('reference'); return false; } if (!is_new_reference($_SESSION['supp_trans']->reference, 21)) { 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 credit note reference.")); + set_focus('supp_reference'); return false; } if (!is_date($_SESSION['supp_trans']->tran_date)) { display_error(_("The credit note as entered cannot be processed because the date entered is not valid.")); + set_focus('tran_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('tran_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; } diff --git a/purchasing/supplier_credit_grns.php b/purchasing/supplier_credit_grns.php index 3d18c98a..373e7676 100644 --- a/purchasing/supplier_credit_grns.php +++ b/purchasing/supplier_credit_grns.php @@ -32,12 +32,14 @@ function check_data() if (!check_num('This_QuantityCredited', 0)) { display_error(_("The quantity to credit must be numeric and greater than zero.")); + set_focus('This_QuantityCredited'); return false; } if (!check_num('ChgPrice', 0)) { display_error(_("The price is either not numeric or negative.")); + set_focus('ChgPrice'); return false; } diff --git a/purchasing/supplier_invoice.php b/purchasing/supplier_invoice.php index b4a83c48..915ec27c 100644 --- a/purchasing/supplier_invoice.php +++ b/purchasing/supplier_invoice.php @@ -72,34 +72,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; } diff --git a/purchasing/supplier_invoice_grns.php b/purchasing/supplier_invoice_grns.php index 3ba94c09..13f4d304 100644 --- a/purchasing/supplier_invoice_grns.php +++ b/purchasing/supplier_invoice_grns.php @@ -36,12 +36,14 @@ function check_data() if (!check_num('this_quantity_inv', 0) || input_num('this_quantity_inv')==0) { display_error( _("The quantity to invoice must be numeric and greater than zero.")); + set_focus('this_quantity_inv'); return false; } if (!check_num('ChgPrice')) { display_error( _("The price is not numeric.")); + set_focus('ChgPrice'); return false; } @@ -54,6 +56,7 @@ function check_data() { display_error(_("The price being invoiced is more than the purchase order price by more than the allowed over-charge percentage. The system is set up to prohibit this. See the system administrator to modify the set up parameters if necessary.") . _("The over-charge percentage allowance is :") . sys_prefs::over_charge_allowance() . "%"); + set_focus('ChgPrice'); return false; } } @@ -66,6 +69,7 @@ function check_data() { display_error( _("The quantity being invoiced is more than the outstanding quantity by more than the allowed over-charge percentage. The system is set up to prohibit this. See the system administrator to modify the set up parameters if necessary.") . _("The over-charge percentage allowance is :") . sys_prefs::over_charge_allowance() . "%"); + set_focus('this_quantity_inv'); return false; } } diff --git a/purchasing/supplier_payment.php b/purchasing/supplier_payment.php index 6cf62669..4c99f95d 100644 --- a/purchasing/supplier_payment.php +++ b/purchasing/supplier_payment.php @@ -123,6 +123,7 @@ function check_inputs() if (!check_num('amount', 0)) { display_error(_("The entered amount is invalid or less than zero.")); + set_focus('amount'); return false; } @@ -134,34 +135,40 @@ function check_inputs() 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) { display_error(_("The total of the amount and the discount negative. Please enter positive values.")); + set_focus('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 not in fiscal year.")); + set_focus('DatePaid'); return false; } if (!references::is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); + set_focus('ref'); return false; } if (!is_new_reference($_POST['ref'], 22)) { display_error(_("The entered reference is already in use.")); + set_focus('ref'); return false; } diff --git a/purchasing/supplier_trans_gl.php b/purchasing/supplier_trans_gl.php index fdec05f8..b2b827fe 100644 --- a/purchasing/supplier_trans_gl.php +++ b/purchasing/supplier_trans_gl.php @@ -48,6 +48,7 @@ if (isset($_POST['AddGLCodeToTrans'])){ 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 @@ -57,6 +58,7 @@ if (isset($_POST['AddGLCodeToTrans'])){ 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; } } diff --git a/sales/allocations/customer_allocate.php b/sales/allocations/customer_allocate.php index e1fd9ea2..d1401e3e 100644 --- a/sales/allocations/customer_allocate.php +++ b/sales/allocations/customer_allocate.php @@ -41,12 +41,14 @@ function check_data() if (!check_num('amount' . $counter)) { display_error(_("The entry for one or more amounts is invalid.")); + set_focus('amount'.$counter); return false; } if (!check_num('amount' . $counter,0)) { display_error(_("The entry for an amount to allocate was negative. A positive allocation amount is expected.")); + set_focus('amount'.$counter); return false; } diff --git a/sales/credit_note_entry.php b/sales/credit_note_entry.php index 86ce2466..fe9bd274 100644 --- a/sales/credit_note_entry.php +++ b/sales/credit_note_entry.php @@ -107,17 +107,21 @@ function can_process() if($_SESSION['Items']->trans_no == 0) { if (!references::is_valid($_POST['ref'])) { display_error( _("You must enter a reference.")); + set_focus('ref'); $input_error = 1; } elseif (!is_new_reference($_POST['ref'], 11)) { display_error( _("The entered reference is already in use.")); + set_focus('ref'); $input_error = 1; } } if (!is_date($_POST['OrderDate'])) { display_error(_("The entered date for the credit note is invalid.")); + set_focus('OrderDate'); $input_error = 1; } elseif (!is_date_in_fiscalyear($_POST['OrderDate'])) { display_error(_("The entered date is not in fiscal year.")); + set_focus('OrderDate'); $input_error = 1; } return ($input_error == 0); @@ -147,14 +151,17 @@ function check_item_data() { if (!check_num('qty',0)) { display_error(_("The quantity must be greater than zero.")); + set_focus('qty'); return false; } if (!check_num('price',0)) { display_error(_("The entered price is negative or invalid.")); + set_focus('price'); return false; } if (!check_num('Disc', 0, 100)) { display_error(_("The entered discount percent is negative, greater than 100 or invalid.")); + set_focus('Disc'); return false; } return true; diff --git a/sales/customer_credit_invoice.php b/sales/customer_credit_invoice.php index b084a7d1..ed9d2390 100644 --- a/sales/customer_credit_invoice.php +++ b/sales/customer_credit_invoice.php @@ -73,25 +73,30 @@ function can_process() { if (!is_date($_POST['CreditDate'])) { display_error(_("The entered date is invalid."));; + set_focus('CreditDate'); return false; } elseif (!is_date_in_fiscalyear($_POST['CreditDate'])) { display_error(_("The entered date is not in fiscal year.")); + set_focus('CreditDate'); return false; } if ($_SESSION['Items']->trans_no==0) { if (!references::is_valid($_POST['ref'])) { display_error(_("You must enter a reference."));; + set_focus('ref'); return false; } if (!is_new_reference($_POST['ref'], 11)) { display_error(_("The entered reference is already in use."));; + set_focus('ref'); return false; } } if (!check_num('ChargeFreightCost', 0)) { display_error(_("The entered shipping cost is invalid or less than zero."));; + set_focus('ChargeFreightCost'); return false; } diff --git a/sales/customer_delivery.php b/sales/customer_delivery.php index 2c0991ab..db8a51b8 100644 --- a/sales/customer_delivery.php +++ b/sales/customer_delivery.php @@ -121,6 +121,7 @@ if (isset($_GET['OrderNumber']) && $_GET['OrderNumber'] > 0) { } elseif(!check_num('ChargeFreightCost', 0)) display_error(_("Freight cost cannot be less than zero")); + set_focus('ChargeFreightCost'); //----------------------------------------------------------------------------- @@ -129,27 +130,32 @@ function check_data() { if (!isset($_POST['DispatchDate']) || !is_date($_POST['DispatchDate'])) { display_error(_("The entered date of delivery is invalid.")); + set_focus('DispatchDate'); return false; } if (!is_date_in_fiscalyear($_POST['DispatchDate'])) { display_error(_("The entered date of delivery is not in fiscal year.")); + set_focus('DispatchDate'); return false; } if (!isset($_POST['due_date']) || !is_date($_POST['due_date'])) { display_error(_("The entered dead-line for invoice is invalid.")); + set_focus('due_date'); return false; } if ($_SESSION['Items']->trans_no==0) { if (!references::is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); + set_focus('ref'); return false; } if ($_SESSION['Items']->trans_no==0 && !is_new_reference($_POST['ref'], 13)) { display_error(_("The entered reference is already in use.")); + set_focus('ref'); return false; } } @@ -159,6 +165,7 @@ function check_data() if (!check_num('ChargeFreightCost',0)) { display_error(_("The entered shipping value is not numeric.")); + set_focus('ChargeFreightCost'); return false; } diff --git a/sales/customer_invoice.php b/sales/customer_invoice.php index e8dadd9a..ded481fa 100644 --- a/sales/customer_invoice.php +++ b/sales/customer_invoice.php @@ -176,27 +176,32 @@ function check_data() { if (!isset($_POST['InvoiceDate']) || !is_date($_POST['InvoiceDate'])) { display_error(_("The entered invoice date is invalid.")); + set_focus('InvoiceDate'); return false; } if (!is_date_in_fiscalyear($_POST['InvoiceDate'])) { display_error(_("The entered invoice date is not in fiscal year.")); + set_focus('InvoiceDate'); return false; } if (!isset($_POST['due_date']) || !is_date($_POST['due_date'])) { display_error(_("The entered invoice due date is invalid.")); + set_focus('due_date'); return false; } if ($_SESSION['Items']->trans_no == 0) { if (!references::is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); + set_focus('ref'); return false; } if (!is_new_reference($_POST['ref'], 10)) { display_error(_("The entered reference is already in use.")); + set_focus('ref'); return false; } } @@ -207,6 +212,7 @@ function check_data() if (!check_num('ChargeFreightCost', 0)) { display_error(_("The entered shipping value is not numeric.")); + set_focus('ChargeFreightCost'); return false; } diff --git a/sales/customer_payments.php b/sales/customer_payments.php index 212b96e0..de86600d 100644 --- a/sales/customer_payments.php +++ b/sales/customer_payments.php @@ -49,34 +49,41 @@ function can_process() { 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 (!references::is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); + set_focus('ref'); return false; } if (!is_new_reference($_POST['ref'], 12)) { 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 (!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)) { display_error(_("The balance of the amount and discout is zero or negative. Please enter valid amounts.")); + set_focus('discount'); return false; } diff --git a/sales/sales_order_entry.php b/sales/sales_order_entry.php index f311cdca..16098b0f 100644 --- a/sales/sales_order_entry.php +++ b/sales/sales_order_entry.php @@ -191,22 +191,27 @@ function line_start_focus() { function can_process() { if (!is_date($_POST['OrderDate'])) { display_error(_("The entered date is invalid.")); + set_focus('OrderDate'); return false; } if ($_SESSION['Items']->trans_type!=30 && !is_date_in_fiscalyear($_POST['OrderDate'])) { display_error(_("The entered date is not in fiscal year")); + set_focus('OrderDate'); return false; } if (count($_SESSION['Items']->line_items) == 0) { display_error(_("You must enter at least one non empty item line.")); + set_focus('AddItem'); return false; } if (strlen($_POST['deliver_to']) <= 1) { display_error(_("You must enter the person or company to whom delivery should be made to.")); + set_focus('deliver_to'); return false; } if (strlen($_POST['delivery_address']) <= 1) { display_error( _("You should enter the street address in the box provided. Orders cannot be accepted without a valid street address.")); + set_focus('delivery_address'); return false; } @@ -215,18 +220,22 @@ function can_process() { if (!check_num('freight_cost',0)) { display_error(_("The shipping cost entered is expected to be numeric.")); + set_focus('freight_cost'); return false; } if (!is_date($_POST['delivery_date'])) { display_error(_("The delivery date is invalid.")); + set_focus('delivery_date'); return false; } if (date1_greater_date2($_SESSION['Items']->document_date, $_POST['delivery_date'])) { display_error(_("The requested delivery date is before the date of the order.")); + set_focus('delivery_date'); return false; } if ($_SESSION['Items']->trans_type != 30 && !references::is_valid($_POST['ref'])) { display_error(_("You must enter a reference.")); + set_focus('ref'); return false; } @@ -265,13 +274,16 @@ function check_item_data() if (!check_num('qty', 0) || !check_num('Disc', 0, 100)) { display_error( _("The item could not be updated because you are attempting to set the quantity ordered to less than 0, or the discount percent to more than 100.")); + set_focus('qty'); return false; } elseif (!check_num('price', 0)) { display_error( _("Price for item must be entered and can not be less than 0")); + set_focus('price'); return false; } elseif (isset($_POST['LineNo']) && isset($_SESSION['Items']->line_items[$_POST['LineNo']]) && !check_num('qty', $_SESSION['Items']->line_items[$_POST['LineNo']]->qty_done)) { + set_focus('qty'); display_error(_("You attempting to make the quantity ordered a quantity less than has already been delivered. The quantity delivered cannot be modified retrospectively.")); return false; } diff --git a/taxes/item_tax_types.php b/taxes/item_tax_types.php index d398e6c9..661c86ca 100644 --- a/taxes/item_tax_types.php +++ b/taxes/item_tax_types.php @@ -32,6 +32,7 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) { $input_error = 1; display_error(_("The item tax type description cannot be empty.")); + set_focus('name'); } if ($input_error != 1) diff --git a/taxes/tax_groups.php b/taxes/tax_groups.php index f04e0bfa..398d6255 100644 --- a/taxes/tax_groups.php +++ b/taxes/tax_groups.php @@ -38,6 +38,7 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) { $input_error = 1; display_error(_("The tax group name cannot be empty.")); + set_focus('name'); } else { @@ -48,9 +49,10 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) $_POST['tax_type_id' . $i] != reserved_words::get_all_numeric() && !check_num('rate' . $i, 0)) { - display_error( _("An entered tax rate is invalid or less than zero.")); + display_error( _("An entered tax rate is invalid or less than zero.")); $input_error = 1; - break; + set_focus('rate'); + break; } } } diff --git a/taxes/tax_types.php b/taxes/tax_types.php index f0cf4c81..51fd5760 100644 --- a/taxes/tax_types.php +++ b/taxes/tax_types.php @@ -23,11 +23,13 @@ function can_process() if (strlen($_POST['name']) == 0) { display_error(_("The tax type name cannot be empty.")); + set_focus('name'); return false; } elseif (!check_num('rate', 0)) { display_error( _("The default tax rate must be numeric and not less than zero.")); + set_focus('rate'); return false; } @@ -64,6 +66,7 @@ function can_delete($selected_id) if ($myrow[0] > 0) { display_error(_("Cannot delete this tax type because tax groups been created referring to it.")); + return false; } -- 2.30.2