From 8259c324f645a39cb847d5a4346b70e225e1b02c Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Sun, 6 Jul 2008 08:50:15 +0000 Subject: [PATCH] Ajax additions --- admin/change_current_user_password.php | 39 +++------- admin/company_preferences.php | 4 +- admin/forms_setup.php | 2 +- admin/gl_setup.php | 2 +- admin/payment_terms.php | 69 ++++++++--------- admin/shipping_companies.php | 65 ++++++++-------- admin/users.php | 100 ++++++++++--------------- inventory/manage/item_categories.php | 57 +++++++------- inventory/manage/item_units.php | 59 ++++++++------- inventory/manage/locations.php | 69 +++++++++-------- inventory/manage/movement_types.php | 54 +++++++------ manufacturing/manage/work_centres.php | 59 +++++++-------- sales/manage/credit_status.php | 55 +++++++------- sales/manage/sales_areas.php | 54 ++++++------- sales/manage/sales_people.php | 82 ++++++++++---------- sales/manage/sales_types.php | 71 ++++++++++-------- taxes/item_tax_types.php | 75 +++++++++---------- taxes/tax_groups.php | 48 ++++++------ taxes/tax_types.php | 58 +++++++------- 19 files changed, 493 insertions(+), 529 deletions(-) diff --git a/admin/change_current_user_password.php b/admin/change_current_user_password.php index 817c94f6..1f739243 100644 --- a/admin/change_current_user_password.php +++ b/admin/change_current_user_password.php @@ -14,11 +14,6 @@ include_once($path_to_root . "/admin/db/users_db.inc"); $selected_id = $_SESSION["wa_current_user"]->username; -if (isset($_GET['UpdatedID'])) -{ - display_notification_centered(_("Your password has been updated.")); -} - function can_process() { @@ -51,14 +46,9 @@ if (isset($_POST['UPDATE_ITEM'])) if (can_process()) { - if (isset($selected_id)) - { - if ($_POST['password'] != "") - update_user_password($_POST['user_id'], md5($_POST['password'])); - - unset($selected_id); - meta_forward($_SERVER['PHP_SELF'], "UpdatedID=1"); - } + update_user_password($_POST['user_id'], md5($_POST['password'])); + display_notification(_("Your password has been updated.")); + $Ajax->activate('_page_body'); } } @@ -66,19 +56,14 @@ start_form(); start_table($table_style); -if (isset($selected_id)) -{ - //editing an existing User - - $myrow = get_user($selected_id); +$myrow = get_user($selected_id); - $_POST['user_id'] = $myrow["user_id"]; - hidden('selected_id', $selected_id); - hidden('user_id', $_POST['user_id']); +$_POST['user_id'] = $myrow["user_id"]; +hidden('selected_id', $selected_id); +hidden('user_id', $_POST['user_id']); - label_row(_("User login:"), $_POST['user_id']); +label_row(_("User login:"), $_POST['user_id']); -} $_POST['password'] = ""; $_POST['passwordConfirm'] = ""; @@ -92,15 +77,11 @@ label_cell(_("Repeat password:")); label_cell(""); end_row(); -if (isset($selected_id)) -{ - table_section_title(_("Enter your new password in the fields.")); -} +table_section_title(_("Enter your new password in the fields.")); end_table(1); -submit_add_or_update_center(!isset($selected_id)); - +submit_center( 'UPDATE_ITEM', _('Change password'), true, '', true); end_form(); end_page(); ?> diff --git a/admin/company_preferences.php b/admin/company_preferences.php index 693dd5a4..ff9dd5a9 100644 --- a/admin/company_preferences.php +++ b/admin/company_preferences.php @@ -82,7 +82,7 @@ if (isset($_POST['submit']) && $_POST['submit'] != "") display_notification_centered(_("Company setup has been updated.")); } - + $Ajax->activate('_page_body'); } /* end of if submit */ //--------------------------------------------------------------------------------------------- @@ -168,7 +168,7 @@ end_row(); end_table(1); hidden('coy_logo', $_POST['coy_logo']); -submit_center('submit', _("Update")); +submit_center('submit', _("Update"), true, '', true); end_form(2); //------------------------------------------------------------------------------------------------- diff --git a/admin/forms_setup.php b/admin/forms_setup.php index bdd1b219..b4a8aa28 100644 --- a/admin/forms_setup.php +++ b/admin/forms_setup.php @@ -42,7 +42,7 @@ while ($type = db_fetch($systypes)) end_table(1); -submit_center('setprefs', _("Update")); +submit_center('setprefs', _("Update"), true, '', true); end_form(2); diff --git a/admin/gl_setup.php b/admin/gl_setup.php index 97206794..044a111a 100644 --- a/admin/gl_setup.php +++ b/admin/gl_setup.php @@ -184,7 +184,7 @@ text_row(_("Dimension Required By After:"), 'default_dim_required', $_POST['defa end_table(1); -submit_center('submit', _("Update")); +submit_center('submit', _("Update"), true, '', true); end_form(2); diff --git a/admin/payment_terms.php b/admin/payment_terms.php index 33ddf118..0bb78419 100644 --- a/admin/payment_terms.php +++ b/admin/payment_terms.php @@ -8,21 +8,10 @@ page(_("Payment Terms")); include($path_to_root . "/includes/ui.inc"); - -//------------------------------------------------------------------------------------------- - -if (isset($_GET['selected_id'])) -{ - $selected_id = $_GET['selected_id']; -} -elseif (isset($_POST['selected_id'])) -{ - $selected_id = $_POST['selected_id']; -} - +simple_page_mode(true); //------------------------------------------------------------------------------------------- -if (isset($_POST['ADD_ITEM']) OR isset($_POST['UPDATE_ITEM'])) +if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') { $inpug_error = 0; @@ -57,7 +46,7 @@ if (isset($_POST['ADD_ITEM']) OR isset($_POST['UPDATE_ITEM'])) if ($inpug_error != 1) { - if (isset($selected_id)) + if ($selected_id != -1) { if (check_value('DaysOrFoll')) { @@ -73,7 +62,7 @@ if (isset($_POST['ADD_ITEM']) OR isset($_POST['UPDATE_ITEM'])) days_before_due=0 WHERE terms_indicator = " .db_escape( $selected_id ); } - + $note = _('Selected payment terms have been updated'); } else { @@ -92,16 +81,16 @@ if (isset($_POST['ADD_ITEM']) OR isset($_POST['UPDATE_ITEM'])) VALUES (" . db_escape($_POST['terms']) . ", 0, " . db_escape($_POST['DayNumber']) . ")"; } - + $note = _('New payment terms have been added'); } //run the sql from either of the above possibilites db_query($sql,"The payment term could not be added or updated"); - - meta_forward($_SERVER['PHP_SELF']); + display_notification($note); + $Mode = 'RESET'; } } -if (isset($_GET['delete'])) +if ($Mode == 'Delete') { // PREVENT DELETES IF DEPENDENT RECORDS IN debtors_master @@ -127,18 +116,23 @@ if (isset($_GET['delete'])) $sql="DELETE FROM ".TB_PREF."payment_terms WHERE terms_indicator='$selected_id'"; db_query($sql,"could not delete a payment terms"); - - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('Selected payment terms have been deleted')); + $Mode = 'RESET'; } } //end if payment terms used in customer or supplier accounts } +if ($Mode == 'RESET') +{ + $selected_id = -1; + unset($_POST); +} //------------------------------------------------------------------------------------------------- $sql = "SELECT * FROM ".TB_PREF."payment_terms"; $result = db_query($sql,"could not get payment terms"); - +start_form(); start_table($table_style); $th = array(_("Description"), _("Following Month On"), _("Due After (Days)"), "", ""); table_header($th); @@ -169,16 +163,16 @@ while ($myrow = db_fetch($result)) label_cell($myrow["terms"]); label_cell($full_text); label_cell($after_text); - edit_link_cell("selected_id=".$myrow["terms_indicator"]); - delete_link_cell("selected_id=".$myrow["terms_indicator"]."&delete=1"); + edit_button_cell("Edit".$myrow["terms_indicator"], _("Edit")); + edit_button_cell("Delete".$myrow["terms_indicator"], _("Delete")); end_row(); } //END WHILE LIST LOOP end_table(); - -hyperlink_no_params($_SERVER['PHP_SELF'], _("New Payment Term")); +end_form(); +echo '
'; //------------------------------------------------------------------------------------------------- @@ -187,19 +181,20 @@ start_form(); start_table($table_style2); $day_in_following_month = $days_before_due = 0; -if (isset($selected_id)) +if ($selected_id != -1) { - //editing an existing payment terms - $sql = "SELECT * FROM ".TB_PREF."payment_terms - WHERE terms_indicator='$selected_id'"; + if ($Mode == 'Edit') { + //editing an existing payment terms + $sql = "SELECT * FROM ".TB_PREF."payment_terms + WHERE terms_indicator='$selected_id'"; - $result = db_query($sql,"could not get payment term"); - $myrow = db_fetch($result); - - $_POST['terms'] = $myrow["terms"]; - $days_before_due = $myrow["days_before_due"]; - $day_in_following_month = $myrow["day_in_following_month"]; + $result = db_query($sql,"could not get payment term"); + $myrow = db_fetch($result); + $_POST['terms'] = $myrow["terms"]; + $days_before_due = $myrow["days_before_due"]; + $day_in_following_month = $myrow["day_in_following_month"]; + } hidden('selected_id', $selected_id); } text_row(_("Terms Description:"), 'terms', null, 40, 40); @@ -218,7 +213,7 @@ text_row_ex(_("Days (Or Day In Following Month):"), 'DayNumber', 3); end_table(1); -submit_add_or_update_center(!isset($selected_id)); +submit_add_or_update_center($selected_id == -1, '', true); end_form(); diff --git a/admin/shipping_companies.php b/admin/shipping_companies.php index ec9f8953..e01ad9ef 100644 --- a/admin/shipping_companies.php +++ b/admin/shipping_companies.php @@ -7,16 +7,7 @@ include($path_to_root . "/includes/session.inc"); page(_("Shipping Company")); include($path_to_root . "/includes/ui.inc"); - -if (isset($_GET['selected_id'])) -{ - $selected_id = $_GET['selected_id']; -} -else if (isset($_POST['selected_id'])) -{ - $selected_id = $_POST['selected_id']; -} - +simple_page_mode(true); //---------------------------------------------------------------------------------------------- function can_process() @@ -31,8 +22,7 @@ function can_process() } //---------------------------------------------------------------------------------------------- - -if (isset($_POST['ADD_ITEM']) && can_process()) +if ($Mode=='ADD_ITEM' && can_process()) { $sql = "INSERT INTO ".TB_PREF."shippers (shipper_name, contact, phone, address) @@ -42,12 +32,13 @@ if (isset($_POST['ADD_ITEM']) && can_process()) db_escape($_POST['address']) . ")"; db_query($sql,"The Shipping Company could not be added"); - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('New shipping company has been added')); + $Mode = 'RESET'; } //---------------------------------------------------------------------------------------------- -if (isset($_POST['UPDATE_ITEM']) && can_process()) +if ($Mode=='UPDATE_ITEM' && can_process()) { $sql = "UPDATE ".TB_PREF."shippers SET shipper_name=" . db_escape($_POST['shipper_name']). " , @@ -57,12 +48,13 @@ if (isset($_POST['UPDATE_ITEM']) && can_process()) WHERE shipper_id = $selected_id"; db_query($sql,"The shipping company could not be updated"); - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('Selected shipping company has been updated')); + $Mode = 'RESET'; } //---------------------------------------------------------------------------------------------- -if (isset($_GET['delete'])) +if ($Mode == 'Delete') { // PREVENT DELETES IF DEPENDENT RECORDS IN 'sales_orders' @@ -90,17 +82,23 @@ if (isset($_GET['delete'])) { $sql="DELETE FROM ".TB_PREF."shippers WHERE shipper_id=$selected_id"; db_query($sql,"could not delete shipper"); - - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('Selected shipping company has been deleted')); + $Mode = 'RESET'; } } } +if ($Mode == 'RESET') +{ + $selected_id = -1; + unset($_POST); +} //---------------------------------------------------------------------------------------------- $sql = "SELECT * FROM ".TB_PREF."shippers ORDER BY shipper_id"; $result = db_query($sql,"could not get shippers"); +start_form(); start_table($table_style); $th = array(_("Name"), _("Contact Person"), _("Phone Number"), _("Address"), "", ""); table_header($th); @@ -114,35 +112,36 @@ while ($myrow = db_fetch($result)) label_cell($myrow["contact"]); label_cell($myrow["phone"]); label_cell($myrow["address"]); - edit_link_cell("selected_id=".$myrow[0]); - delete_link_cell("selected_id=".$myrow[0]."&delete=1"); + edit_button_cell("Edit".$myrow[0], _("Edit")); + edit_button_cell("Delete".$myrow[0], _("Delete")); end_row(); } end_table(); +end_form(); +echo '
'; //---------------------------------------------------------------------------------------------- -hyperlink_no_params($_SERVER['PHP_SELF'], _("New Shipping Company")); - start_form(); start_table($table_style2); -if (isset($selected_id)) +if ($selected_id != -1) { - //editing an existing Shipper - - $sql = "SELECT * FROM ".TB_PREF."shippers WHERE shipper_id=$selected_id"; + if ($Mode == 'Edit') { + //editing an existing Shipper - $result = db_query($sql, "could not get shipper"); - $myrow = db_fetch($result); + $sql = "SELECT * FROM ".TB_PREF."shippers WHERE shipper_id=$selected_id"; - $_POST['shipper_name'] = $myrow["shipper_name"]; - $_POST['contact'] = $myrow["contact"]; - $_POST['phone'] = $myrow["phone"]; - $_POST['address'] = $myrow["address"]; + $result = db_query($sql, "could not get shipper"); + $myrow = db_fetch($result); + $_POST['shipper_name'] = $myrow["shipper_name"]; + $_POST['contact'] = $myrow["contact"]; + $_POST['phone'] = $myrow["phone"]; + $_POST['address'] = $myrow["address"]; + } hidden('selected_id', $selected_id); } @@ -156,7 +155,7 @@ text_row_ex(_("Address:"), 'address', 50); end_table(1); -submit_add_or_update_center(!isset($selected_id)); +submit_add_or_update_center($selected_id == -1, '', true); end_form(); end_page(); diff --git a/admin/users.php b/admin/users.php index 765997cb..bd3b0eb3 100644 --- a/admin/users.php +++ b/admin/users.php @@ -11,32 +11,7 @@ include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/admin/db/users_db.inc"); -if (isset($_GET['selected_id'])) -{ - $selected_id = $_GET['selected_id']; -} -elseif (isset($_POST['selected_id'])) -{ - $selected_id = $_POST['selected_id']; -} - -//------------------------------------------------------------------------------------------------- - -if (isset($_GET['AddedID'])) -{ - display_notification_centered(_("A new user has been added.")); -} - -if (isset($_GET['UpdatedID'])) -{ - display_notification_centered(_("The selected user has been updated.")); -} - -if (isset($_GET['DeletedID'])) -{ - display_notification_centered(_("User has been deleted.")); -} - +simple_page_mode(false); //------------------------------------------------------------------------------------------------- function can_process() @@ -54,14 +29,14 @@ function can_process() if (strlen($_POST['password']) < 4) { display_error( _("The password entered must be at least 4 characters long.")); - set_focus('password'); + 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'); + set_focus('password'); return false; } } @@ -71,12 +46,12 @@ function can_process() //------------------------------------------------------------------------------------------------- -if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) +if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') { if (can_process()) { - if (isset($selected_id)) + if ($selected_id != '') { update_user($_POST['user_id'], $_POST['real_name'], $_POST['phone'], $_POST['email'], $_POST['Access'], $_POST['language']); @@ -84,34 +59,37 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) if ($_POST['password'] != "") update_user_password($_POST['user_id'], md5($_POST['password'])); - unset($selected_id); - meta_forward($_SERVER['PHP_SELF'], "UpdatedID=1"); + display_notification_centered(_("The selected user has been updated.")); } else { add_user($_POST['user_id'], $_POST['real_name'], md5($_POST['password']), $_POST['phone'], $_POST['email'], $_POST['Access'], $_POST['language']); - unset($selected_id); - meta_forward($_SERVER['PHP_SELF'], "AddedID=1"); + display_notification_centered(_("A new user has been added.")); } + $Mode = 'RESET'; } } //------------------------------------------------------------------------------------------------- -if (isset($_GET['delete'])) +if ($Mode == 'Delete') { delete_user($selected_id); - unset($selected_id); - - meta_forward($_SERVER['PHP_SELF'], "DeletedID=1"); + display_notification_centered(_("User has been deleted.")); + $Mode = 'RESET'; } //------------------------------------------------------------------------------------------------- +if ($Mode == 'RESET') +{ + $selected_id = ''; + unset($_POST); // clean all input fields +} $result = get_users(); - +start_form(); start_table($table_style); if ($_SESSION["wa_current_user"]->access == 2) @@ -139,42 +117,42 @@ while ($myrow = db_fetch($result)) label_cell($myrow["email"]); label_cell($last_visit_date, "nowrap"); label_cell($security_headings[$myrow["full_access"]]); - edit_link_cell("selected_id=".$myrow["user_id"]); + edit_button_cell("Edit".$myrow["user_id"], _("Edit")); if (strcasecmp($myrow["user_id"], $_SESSION["wa_current_user"]->username) && $_SESSION["wa_current_user"]->access == 2) - delete_link_cell("selected_id=".$myrow["user_id"]."&delete=1"); + edit_button_cell("Delete".$myrow["user_id"], _("Delete")); + else + label_cell(''); end_row(); } //END WHILE LIST LOOP end_table(); +end_form(); +echo '
'; //------------------------------------------------------------------------------------------------- - -hyperlink_no_params($_SERVER['PHP_SELF'], _("New User")); - start_form(); start_table($table_style2); -if (isset($selected_id)) +if ($selected_id != '') { - //editing an existing User - - $myrow = get_user($selected_id); - - $_POST['user_id'] = $myrow["user_id"]; - $_POST['real_name'] = $myrow["real_name"]; - $_POST['phone'] = $myrow["phone"]; - $_POST['email'] = $myrow["email"]; - $_POST['Access'] = $myrow["full_access"]; - $_POST['language'] = $myrow["language"]; - + if ($Mode == 'Edit') { + //editing an existing User + $myrow = get_user($selected_id); + + $_POST['user_id'] = $myrow["user_id"]; + $_POST['real_name'] = $myrow["real_name"]; + $_POST['phone'] = $myrow["phone"]; + $_POST['email'] = $myrow["email"]; + $_POST['Access'] = $myrow["full_access"]; + $_POST['language'] = $myrow["language"]; + } hidden('selected_id', $selected_id); - hidden('user_id', $_POST['user_id']); + hidden('user_id'); start_row(); label_row(_("User login:"), $_POST['user_id']); - } else { //end of if $selected_id only do the else when a new record is being entered @@ -186,7 +164,7 @@ label_cell(_("Password:")); label_cell(""); end_row(); -if (isset($selected_id)) +if ($selected_id != '') { table_section_title(_("Enter a new password to change, leave empty to keep current.")); } @@ -197,13 +175,13 @@ text_row_ex(_("Telephone No.:"), 'phone', 30); text_row_ex(_("Email Address:"), 'email', 50); -security_headings_list_row(_("Access Level:"), "Access", null); +security_headings_list_row(_("Access Level:"), 'Access', null); languages_list_row(_("Language:"), 'language', null); end_table(1); -submit_add_or_update_center(!isset($selected_id)); +submit_add_or_update_center($selected_id == '', '', true); end_form(); end_page(); diff --git a/inventory/manage/item_categories.php b/inventory/manage/item_categories.php index 4474dc97..4b3db64b 100644 --- a/inventory/manage/item_categories.php +++ b/inventory/manage/item_categories.php @@ -10,18 +10,10 @@ include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/inventory/includes/inventory_db.inc"); -if (isset($_GET['selected_id'])) -{ - $selected_id = strtoupper($_GET['selected_id']); -} -else if (isset($_POST['selected_id'])) -{ - $selected_id = strtoupper($_POST['selected_id']); -} - +simple_page_mode(true); //---------------------------------------------------------------------------------- -if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) +if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') { //initialise no input errors assumed initially before we test @@ -36,21 +28,23 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) if ($input_error !=1) { - if (isset($selected_id)) + if ($selected_id != -1) { update_item_category($selected_id, $_POST['description']); + display_notification(_('Selected item category has been updated')); } else { add_item_category($_POST['description']); + display_notification(_('New item category has been added')); } - meta_forward($_SERVER['PHP_SELF']); + $Mode = 'RESET'; } } //---------------------------------------------------------------------------------- -if (isset($_GET['delete'])) +if ($Mode == 'Delete') { // PREVENT DELETES IF DEPENDENT RECORDS IN 'stock_master' @@ -60,20 +54,26 @@ if (isset($_GET['delete'])) if ($myrow[0] > 0) { display_error(_("Cannot delete this item category because items have been created using this item category.")); - } else { delete_item_category($selected_id); - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('Selected item category has been deleted')); + $Mode = 'RESET'; } } +if ($Mode == 'RESET') +{ + $selected_id = -1; + unset($_POST); +} //---------------------------------------------------------------------------------- $sql = "SELECT * FROM ".TB_PREF."stock_category"; $result = db_query($sql, "could not get stock categories"); +start_form(); start_table("$table_style width=30%"); $th = array(_("Name"), "", ""); table_header($th); @@ -85,39 +85,38 @@ while ($myrow = db_fetch($result)) alt_table_row_color($k); label_cell($myrow["description"]); - edit_link_cell(SID."selected_id=$myrow[0]"); - delete_link_cell(SID."selected_id=$myrow[0]&delete=yes"); + edit_button_cell("Edit".$myrow[0], _("Edit")); + edit_button_cell("Delete".$myrow[0], _("Delete")); end_row(); } end_table(); - +end_form(); +echo '
'; //---------------------------------------------------------------------------------- -hyperlink_no_params($_SERVER['PHP_SELF'], _("New Item Category")); - start_form(); start_table("class='tablestyle_noborder'"); -if (isset($selected_id)) +if ($selected_id != -1) { - //editing an existing item category - - $myrow = get_item_category($selected_id); - - $_POST['category_id'] = $myrow["category_id"]; - $_POST['description'] = $myrow["description"]; + if ($Mode == 'Edit') { + //editing an existing item category + $myrow = get_item_category($selected_id); + $_POST['category_id'] = $myrow["category_id"]; + $_POST['description'] = $myrow["description"]; + } hidden('selected_id', $selected_id); - hidden('category_id', $_POST['category_id']); + hidden('category_id'); } text_row(_("Category Name:"), 'description', null, 30, 30); end_table(1); -submit_add_or_update_center(!isset($selected_id)); +submit_add_or_update_center($selected_id == -1, '', true); end_form(); diff --git a/inventory/manage/item_units.php b/inventory/manage/item_units.php index e5a72f95..61e4e685 100644 --- a/inventory/manage/item_units.php +++ b/inventory/manage/item_units.php @@ -10,18 +10,10 @@ include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/inventory/includes/db/items_units_db.inc"); -if (isset($_GET['selected_id'])) -{ - $selected_id = $_GET['selected_id']; -} -else if (isset($_POST['selected_id'])) -{ - $selected_id = $_POST['selected_id']; -} - +simple_page_mode(false); //---------------------------------------------------------------------------------- -if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) +if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') { //initialise no input errors assumed initially before we test @@ -41,14 +33,18 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) } if ($input_error !=1) { - write_item_unit(isset($selected_id) ? $selected_id : '', $_POST['abbr'], $_POST['description'], $_POST['decimals'] ); - meta_forward($_SERVER['PHP_SELF']); + write_item_unit($selected_id, $_POST['abbr'], $_POST['description'], $_POST['decimals'] ); + if($selected_id != '') + display_notification(_('Selected unit has been updated')); + else + display_notification(_('New unit has been added')); + $Mode = 'RESET'; } } //---------------------------------------------------------------------------------- -if (isset($_GET['delete'])) +if ($Mode == 'Delete') { // PREVENT DELETES IF DEPENDENT RECORDS IN 'stock_master' @@ -61,13 +57,21 @@ if (isset($_GET['delete'])) else { delete_item_unit($selected_id); - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('Selected unit has been deleted')); + $Mode = 'RESET'; } } +if ($Mode == 'RESET') +{ + $selected_id = ''; + unset($_POST); +} + //---------------------------------------------------------------------------------- $result = get_all_item_units(); +start_form(); start_table("$table_style width=50%"); $th = array(_('Unit'), _('Description'), _('Decimals'), "", ""); @@ -83,35 +87,36 @@ while ($myrow = db_fetch($result)) label_cell($myrow["name"]); label_cell(($myrow["decimals"]==-1?_("User Quantity Decimals"):$myrow["decimals"])); - edit_link_cell(SID."selected_id=$myrow[0]"); - delete_link_cell(SID."selected_id=$myrow[0]&delete=yes"); + edit_button_cell("Edit".$myrow[0], _("Edit")); + edit_button_cell("Delete".$myrow[0], _("Delete")); end_row(); } end_table(); +end_form(); +echo '
'; //---------------------------------------------------------------------------------- -hyperlink_no_params($_SERVER['PHP_SELF'], _("New Unit of Measure")); - start_form(); start_table("class='tablestyle_noborder'"); -if (isset($selected_id)) +if ($selected_id != '') { - //editing an existing item category - - $myrow = get_item_unit($selected_id); + if ($Mode == 'Edit') { + //editing an existing item category - $_POST['abbr'] = $myrow["abbr"]; - $_POST['description'] = $myrow["name"]; - $_POST['decimals'] = $myrow["decimals"]; + $myrow = get_item_unit($selected_id); + $_POST['abbr'] = $myrow["abbr"]; + $_POST['description'] = $myrow["name"]; + $_POST['decimals'] = $myrow["decimals"]; + } hidden('selected_id', $selected_id); } -if (isset($selected_id) && item_unit_used($selected_id)) { +if ($selected_id != '' && item_unit_used($selected_id)) { label_row(_("Unit Abbreviation:"), $_POST['abbr']); hidden('abbr', $_POST['abbr']); } else @@ -122,7 +127,7 @@ number_list_row(_("Decimal Places:"), 'decimals', null, 0, 6, _("User Quantity D end_table(1); -submit_add_or_update_center(!isset($selected_id)); +submit_add_or_update_center($selected_id == '', '', true); end_form(); diff --git a/inventory/manage/locations.php b/inventory/manage/locations.php index 6bb732fc..3fcddeae 100644 --- a/inventory/manage/locations.php +++ b/inventory/manage/locations.php @@ -10,16 +10,9 @@ include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/inventory/includes/inventory_db.inc"); -if (isset($_GET['selected_id'])) -{ - $selected_id = $_GET['selected_id']; -} -elseif (isset($_POST['selected_id'])) -{ - $selected_id = $_POST['selected_id']; -} +simple_page_mode(true); -if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) +if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') { //initialise no input errors assumed initially before we test @@ -46,11 +39,12 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) if ($input_error != 1) { - if (isset($selected_id)) + if ($selected_id != -1) { update_item_location($selected_id, $_POST['location_name'], $_POST['delivery_address'], $_POST['phone'], $_POST['fax'], $_POST['email'], $_POST['contact']); + display_notification(_('Selected location has been updated')); } else { @@ -59,9 +53,10 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) add_item_location($_POST['loc_code'], $_POST['location_name'], $_POST['delivery_address'], $_POST['phone'], $_POST['fax'], $_POST['email'], $_POST['contact']); + display_notification(_('New location has been added')); } - meta_forward($_SERVER['PHP_SELF']); + $Mode = 'RESET'; } } @@ -99,24 +94,27 @@ function can_delete($selected_id) //---------------------------------------------------------------------------------- -if (isset($_GET['delete'])) +if ($Mode == 'Delete') { if (can_delete($selected_id)) { delete_item_location($selected_id); - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('Selected location has been deleted')); + $Mode = 'RESET'; } //end if Delete Location } -/* It could still be the second time the page has been run and a record has been selected for modification - selected_id will exist because it was sent with the new call. If its the first time the page has been displayed with no parameters -then none of the above are true and the list of locations will be displayed with -links to delete or edit each. These will call the same page again and allow update/input -or deletion of the records*/ +if ($Mode == 'RESET') +{ + $selected_id = -1; + unset($_POST); +} $sql = "SELECT * FROM ".TB_PREF."locations"; $result = db_query($sql, "could not query locations");; +start_form(); start_table("$table_style width=30%"); $th = array(_("Location Code"), _("Location Name"), "", ""); table_header($th); @@ -128,8 +126,8 @@ while ($myrow = db_fetch_row($result)) label_cell($myrow[0]); label_cell($myrow[1]); - edit_link_cell("selected_id=$myrow[0]"); - delete_link_cell("selected_id=$myrow[0]&delete=1"); + edit_button_cell("Edit".$myrow[0], _("Edit")); + edit_button_cell("Delete".$myrow[0], _("Delete")); end_row(); } //END WHILE LIST LOOP @@ -138,27 +136,30 @@ while ($myrow = db_fetch_row($result)) end_table(); -hyperlink_no_params($_SERVER['PHP_SELF'], _("New Location")); +end_form(); +echo '
'; start_form(); start_table($table_style2); -if (isset($selected_id)) + +if ($selected_id != -1) { //editing an existing Location - $myrow = get_item_location($selected_id); - - $_POST['loc_code'] = $myrow["loc_code"]; - $_POST['location_name'] = $myrow["location_name"]; - $_POST['delivery_address'] = $myrow["delivery_address"]; - $_POST['contact'] = $myrow["contact"]; - $_POST['phone'] = $myrow["phone"]; - $_POST['fax'] = $myrow["fax"]; - $_POST['email'] = $myrow["email"]; + if ($Mode == 'Edit') { + $myrow = get_item_location($selected_id); + $_POST['loc_code'] = $myrow["loc_code"]; + $_POST['location_name'] = $myrow["location_name"]; + $_POST['delivery_address'] = $myrow["delivery_address"]; + $_POST['contact'] = $myrow["contact"]; + $_POST['phone'] = $myrow["phone"]; + $_POST['fax'] = $myrow["fax"]; + $_POST['email'] = $myrow["email"]; + } hidden("selected_id", $selected_id); - hidden("loc_code", $_POST['loc_code']); + hidden("loc_code"); label_row(_("Location Code:"), $_POST['loc_code']); } else @@ -176,12 +177,10 @@ text_row_ex(_("Facsimile No:"), 'fax', 30, 30); text_row_ex(_("Email:"), 'email', 30, 30); end_table(1); -submit_add_or_update_center(!isset($selected_id)); +submit_add_or_update_center($selected_id == -1, '', true); end_form(); -//end if record deleted no point displaying form to add record - - end_page(); +end_page(); ?> diff --git a/inventory/manage/movement_types.php b/inventory/manage/movement_types.php index 5ac29b22..9660af23 100644 --- a/inventory/manage/movement_types.php +++ b/inventory/manage/movement_types.php @@ -10,18 +10,10 @@ include_once($path_to_root . "/inventory/includes/inventory_db.inc"); include_once($path_to_root . "/includes/ui.inc"); -if (isset($_GET['selected_id'])) -{ - $selected_id = $_GET['selected_id']; -} -elseif(isset($_POST['selected_id'])) -{ - $selected_id = $_POST['selected_id']; -} - +simple_page_mode(true); //----------------------------------------------------------------------------------- -if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) +if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') { //initialise no input errors assumed initially before we test @@ -36,20 +28,18 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) if ($input_error != 1) { - - if (isset($selected_id)) + if ($selected_id != -1) { - update_movement_type($selected_id, $_POST['name']); - + display_notification(_('Selected movement type has been updated')); } else { - add_movement_type($_POST['name']); + display_notification(_('New movement type has been added')); } - meta_forward($_SERVER['PHP_SELF']); + $Mode = 'RESET'; } } @@ -73,20 +63,27 @@ function can_delete($selected_id) //----------------------------------------------------------------------------------- -if (isset($_GET['delete'])) +if ($Mode == 'Delete') { if (can_delete($selected_id)) { delete_movement_type($selected_id); - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('Selected movement type has been deleted')); + $Mode = 'RESET'; } } +if ($Mode == 'RESET') +{ + $selected_id = -1; + unset($_POST); +} //----------------------------------------------------------------------------------- $result = get_all_movement_type(); +start_form(); start_table("$table_style width=30%"); $th = array(_("Description"), "", ""); @@ -98,29 +95,30 @@ while ($myrow = db_fetch($result)) alt_table_row_color($k); label_cell($myrow["name"]); - edit_link_cell("selected_id=" . $myrow["id"]); - delete_link_cell("selected_id=" . $myrow["id"]. "&delete=1"); + edit_button_cell("Edit".$myrow['id'], _("Edit")); + edit_button_cell("Delete".$myrow['id'], _("Delete")); end_row(); } end_table(); +end_form(); +echo '
'; //----------------------------------------------------------------------------------- -hyperlink_no_params($_SERVER['PHP_SELF'], _("New Inventory Movement Type")); - start_form(); start_table(); -if (isset($selected_id)) +if ($selected_id != -1) { - //editing an existing status code - - $myrow = get_movement_type($selected_id); + if ($Mode == 'Edit') { + //editing an existing status code - $_POST['name'] = $myrow["name"]; + $myrow = get_movement_type($selected_id); + $_POST['name'] = $myrow["name"]; + } hidden('selected_id', $selected_id); } @@ -128,7 +126,7 @@ text_row(_("Description:"), 'name', null, 50, 50); end_table(1); -submit_add_or_update_center(!isset($selected_id)); +submit_add_or_update_center($selected_id == -1, '', true); end_form(); diff --git a/manufacturing/manage/work_centres.php b/manufacturing/manage/work_centres.php index bd08430e..04d10fee 100644 --- a/manufacturing/manage/work_centres.php +++ b/manufacturing/manage/work_centres.php @@ -10,18 +10,10 @@ include($path_to_root . "/manufacturing/includes/manufacturing_db.inc"); include($path_to_root . "/includes/ui.inc"); -if (isset($_GET['selected_id'])) -{ - $selected_id = $_GET['selected_id']; -} -elseif(isset($_POST['selected_id'])) -{ - $selected_id = $_POST['selected_id']; -} - +simple_page_mode(true); //----------------------------------------------------------------------------------- -if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) +if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') { //initialise no input errors assumed initially before we test @@ -37,18 +29,17 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) if ($input_error != 1) { - if (isset($selected_id)) + if ($selected_id != -1) { - update_work_centre($selected_id, $_POST['name'], $_POST['description']); - + display_notification(_('Selected work center has been updated')); } else { - add_work_centre($_POST['name'], $_POST['description']); + display_notification(_('New work center has been added')); } - meta_forward($_SERVER['PHP_SELF']); + $Mode = 'RESET'; } } @@ -80,20 +71,27 @@ function can_delete($selected_id) //----------------------------------------------------------------------------------- -if (isset($_GET['delete'])) +if ($Mode == 'Delete') { if (can_delete($selected_id)) { delete_work_centre($selected_id); - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('Selected work center has been deleted')); + $Mode = 'RESET'; } } +if ($Mode == 'RESET') +{ + $selected_id = -1; + unset($_POST); +} //----------------------------------------------------------------------------------- $result = get_all_work_centres(); +start_form(); start_table("$table_style width=50%"); $th = array(_("Name"), _("description"), "", ""); table_header($th); @@ -106,30 +104,29 @@ while ($myrow = db_fetch($result)) label_cell($myrow["name"]); label_cell($myrow["description"]); - edit_link_cell("selected_id=" . $myrow["id"]); - delete_link_cell("selected_id=" . $myrow["id"]. "&delete=1"); + edit_button_cell("Edit".$myrow['id'], _("Edit")); + edit_button_cell("Delete".$myrow['id'], _("Delete")); end_row(); } end_table(); - +end_form(); +echo '
'; //----------------------------------------------------------------------------------- -hyperlink_no_params($_SERVER['PHP_SELF'], _("New Work Centre")); - start_form(); start_table($table_style2); -if (isset($selected_id)) +if ($selected_id != -1) { - //editing an existing status code - - $myrow = get_work_centre($selected_id); - - $_POST['name'] = $myrow["name"]; - $_POST['description'] = $myrow["description"]; - + if ($Mode == 'Edit') { + //editing an existing status code + $myrow = get_work_centre($selected_id); + + $_POST['name'] = $myrow["name"]; + $_POST['description'] = $myrow["description"]; + } hidden('selected_id', $selected_id); } @@ -138,7 +135,7 @@ text_row_ex(_("Description:"), 'description', 50); end_table(1); -submit_add_or_update_center(!isset($selected_id)); +submit_add_or_update_center($selected_id == -1, '', true); end_form(); diff --git a/sales/manage/credit_status.php b/sales/manage/credit_status.php index f90ca551..f4608d08 100644 --- a/sales/manage/credit_status.php +++ b/sales/manage/credit_status.php @@ -10,15 +10,7 @@ include($path_to_root . "/sales/includes/db/credit_status_db.inc"); include($path_to_root . "/includes/ui.inc"); -if (isset($_GET['selected_id'])) -{ - $selected_id = $_GET['selected_id']; -} -elseif (isset($_POST['selected_id'])) -{ - $selected_id = $_POST['selected_id']; -} - +simple_page_mode(true); //----------------------------------------------------------------------------------- function can_process() @@ -35,20 +27,21 @@ function can_process() //----------------------------------------------------------------------------------- -if (isset($_POST['ADD_ITEM']) && can_process()) +if ($Mode=='ADD_ITEM' && can_process()) { add_credit_status($_POST['reason_description'], $_POST['DisallowInvoices']); - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('New credit status has been added')); + $Mode = 'RESET'; } //----------------------------------------------------------------------------------- -if (isset($_POST['UPDATE_ITEM']) && can_process()) +if ($Mode=='UPDATE_ITEM' && can_process()) { - + display_notification(_('Selected credit status has been updated')); update_credit_status($selected_id, $_POST['reason_description'], $_POST['DisallowInvoices']); - meta_forward($_SERVER['PHP_SELF']); + $Mode = 'RESET'; } //----------------------------------------------------------------------------------- @@ -71,20 +64,27 @@ function can_delete($selected_id) //----------------------------------------------------------------------------------- -if (isset($_GET['delete'])) +if ($Mode == 'Delete') { if (can_delete($selected_id)) { delete_credit_status($selected_id); - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('Selected credit status has been deleted')); + $Mode = 'RESET'; } } +if ($Mode == 'RESET') +{ + $selected_id = -1; + unset($_POST); +} //----------------------------------------------------------------------------------- $result = get_all_credit_status(); +start_form(); start_table("$table_style width=40%"); $th = array(_("Description"), _("Dissallow Invoices"),'',''); table_header($th); @@ -106,30 +106,31 @@ while ($myrow = db_fetch($result)) label_cell($myrow["reason_description"]); label_cell($disallow_text); - edit_link_cell("selected_id=" . $myrow["id"]); - delete_link_cell("selected_id=" . $myrow["id"]. "&delete=1"); + edit_button_cell("Edit".$myrow['id'], _("Edit")); + edit_button_cell("Delete".$myrow['id'], _("Delete")); end_row(); } end_table(); +end_form(); +echo '
'; //----------------------------------------------------------------------------------- -hyperlink_no_params($_SERVER['PHP_SELF'], _("New Credit Status")); - start_form(); start_table("$table_style2 width=40%"); -if (isset($selected_id)) +if ($selected_id != -1) { - //editing an existing status code - - $myrow = get_credit_status($selected_id); + if ($Mode == 'Edit') { + //editing an existing status code - $_POST['reason_description'] = $myrow["reason_description"]; - $_POST['DisallowInvoices'] = $myrow["dissallow_invoices"]; + $myrow = get_credit_status($selected_id); + $_POST['reason_description'] = $myrow["reason_description"]; + $_POST['DisallowInvoices'] = $myrow["dissallow_invoices"]; + } hidden('selected_id', $selected_id); } @@ -139,7 +140,7 @@ yesno_list_row(_("Dissallow invoicing ?"), 'DisallowInvoices', null); end_table(1); -submit_add_or_update_center(!isset($selected_id)); +submit_add_or_update_center($selected_id == -1, '', true); end_form(); diff --git a/sales/manage/sales_areas.php b/sales/manage/sales_areas.php index 7b993667..c6e69676 100644 --- a/sales/manage/sales_areas.php +++ b/sales/manage/sales_areas.php @@ -9,16 +9,9 @@ page(_("Sales Areas")); include($path_to_root . "/includes/ui.inc"); -if (isset($_GET['selected_id'])) -{ - $selected_id = strtoupper($_GET['selected_id']); -} -elseif (isset($_POST['selected_id'])) -{ - $selected_id = strtoupper($_POST['selected_id']); -} +simple_page_mode(true); -if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) +if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') { $input_error = 0; @@ -31,23 +24,24 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) if ($input_error != 1) { - if (isset($selected_id)) + if ($selected_id != -1) { $sql = "UPDATE ".TB_PREF."areas SET description=".db_escape($_POST['description'])." WHERE area_code = '$selected_id'"; + $note = _('Selected sales area has been updated'); } else { - $sql = "INSERT INTO ".TB_PREF."areas (description) VALUES (".db_escape($_POST['description']) . ")"; + $note = _('New sales area has been added'); } db_query($sql,"The sales area could not be updated or added"); - - meta_forward($_SERVER['PHP_SELF']); + display_notification($note); + $Mode = 'RESET'; } } -if (isset($_GET['delete'])) +if ($Mode == 'Delete') { $cancel_delete = 0; @@ -67,15 +61,22 @@ if (isset($_GET['delete'])) $sql="DELETE FROM ".TB_PREF."areas WHERE area_code='" . $selected_id . "'"; db_query($sql,"could not delete sales area"); - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('Selected sales area has been deleted')); + $Mode = 'RESET'; } //end if Delete area } +if ($Mode == 'RESET') +{ + $selected_id = -1; + unset($_POST); +} //------------------------------------------------------------------------------------------------- $sql = "SELECT * FROM ".TB_PREF."areas"; $result = db_query($sql,"could not get areas"); +start_form(); start_table("$table_style width=40%"); $th = array(_("Area Name"), "", ""); table_header($th); @@ -87,14 +88,15 @@ while ($myrow = db_fetch($result)) alt_table_row_color($k); label_cell($myrow["description"]); - edit_link_cell("selected_id=" . $myrow["area_code"]); - delete_link_cell("selected_id=" . $myrow["area_code"]. "&delete=1"); + edit_button_cell("Edit".$myrow["area_code"], _("Edit")); + edit_button_cell("Delete".$myrow["area_code"], _("Delete")); end_row(); } end_table(); -hyperlink_no_params($_SERVER['PHP_SELF'], _("New Sales Area")); +end_form(); +echo '
'; //------------------------------------------------------------------------------------------------- @@ -102,15 +104,17 @@ start_form(); start_table("$table_style2 width=40%"); -if (isset($selected_id)) +if ($selected_id != -1) { - //editing an existing area - $sql = "SELECT * FROM ".TB_PREF."areas WHERE area_code='$selected_id'"; + if ($Mode == 'Edit') { + //editing an existing area + $sql = "SELECT * FROM ".TB_PREF."areas WHERE area_code='$selected_id'"; - $result = db_query($sql,"could not get area"); - $myrow = db_fetch($result); + $result = db_query($sql,"could not get area"); + $myrow = db_fetch($result); - $_POST['description'] = $myrow["description"]; + $_POST['description'] = $myrow["description"]; + } hidden("selected_id", $selected_id); } @@ -118,7 +122,7 @@ text_row_ex(_("Area Name:"), 'description', 30); end_table(1); -submit_add_or_update_center(!isset($selected_id)); +submit_add_or_update_center($selected_id == -1, '', true); end_form(); diff --git a/sales/manage/sales_people.php b/sales/manage/sales_people.php index ff45e3e0..723fabd3 100644 --- a/sales/manage/sales_people.php +++ b/sales/manage/sales_people.php @@ -8,18 +8,10 @@ page(_("Sales Persons")); include($path_to_root . "/includes/ui.inc"); -if (isset($_GET['selected_id'])) -{ - $selected_id = strtoupper($_GET['selected_id']); -} -elseif (isset($_POST['selected_id'])) -{ - $selected_id = strtoupper($_POST['selected_id']); -} - +simple_page_mode(true); //------------------------------------------------------------------------------------------------ -if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) +if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') { //initialise no input errors assumed initially before we test @@ -43,7 +35,7 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) } if ($input_error != 1) { - if (isset($selected_id)) + if ($selected_id != -1) { /*selected_id could also exist if submit had not been clicked this code would not run in this case cos submit is false of course see the delete code below*/ @@ -70,12 +62,15 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) } //run the sql from either of the above possibilites - db_query($sql,"The insert or update of the salesperson failed"); - - meta_forward($_SERVER['PHP_SELF']); + db_query($sql,"The insert or update of the sales person failed"); + if ($selected_id != -1) + display_notification(_('Selected sales person data have been updated')); + else + display_notification(_('New sales person data have been added')); + $Mode = 'RESET'; } } -if (isset($_GET['delete'])) +if ($Mode == 'Delete') { //the link to delete a selected record was clicked instead of the submit button @@ -92,16 +87,22 @@ if (isset($_GET['delete'])) { $sql="DELETE FROM ".TB_PREF."salesman WHERE salesman_code='$selected_id'"; db_query($sql,"The sales-person could not be deleted"); - - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('Selected sales person data have been deleted')); + $Mode = 'RESET'; } } +if ($Mode == 'RESET') +{ + $selected_id = -1; + unset($_POST); +} //------------------------------------------------------------------------------------------------ $sql = "SELECT * FROM ".TB_PREF."salesman"; $result = db_query($sql,"could not get sales persons"); +start_form(); start_table("$table_style width=60%"); $th = array(_("Name"), _("Phone"), _("Fax"), _("Email"), _("Provision"), _("Break Pt."), _("Provision")." 2", "", ""); table_header($th); @@ -120,39 +121,42 @@ while ($myrow = db_fetch($result)) label_cell(percent_format($myrow["provision"])." %", "nowrap align=right"); amount_cell($myrow["break_pt"]); label_cell(percent_format($myrow["provision2"])." %", "nowrap align=right"); - edit_link_cell(SID . "selected_id=" . $myrow["salesman_code"]); - delete_link_cell(SID . "selected_id=" . $myrow["salesman_code"]. "&delete=1"); + edit_button_cell("Edit".$myrow["salesman_code"], _("Edit")); + edit_button_cell("Delete".$myrow["salesman_code"], _("Delete")); end_row(); } //END WHILE LIST LOOP end_table(); - -//------------------------------------------------------------------------------------------------ - -hyperlink_no_params($_SERVER['PHP_SELF'], _("New Sales Person")); +end_form(); +echo '
'; //------------------------------------------------------------------------------------------------ start_form(); -if (isset($selected_id)) +if ($selected_id != -1) { - //editing an existing Sales-person - $sql = "SELECT * FROM ".TB_PREF."salesman WHERE salesman_code='$selected_id'"; - - $result = db_query($sql,"could not get sales person"); - $myrow = db_fetch($result); - - $_POST['salesman_name'] = $myrow["salesman_name"]; - $_POST['salesman_phone'] = $myrow["salesman_phone"]; - $_POST['salesman_fax'] = $myrow["salesman_fax"]; - $_POST['salesman_email'] = $myrow["salesman_email"]; - $_POST['provision'] = percent_format($myrow["provision"]); - $_POST['break_pt'] = price_format($myrow["break_pt"]); - $_POST['provision2'] = percent_format($myrow["provision2"]); - + if ($Mode == 'Edit') { + //editing an existing Sales-person + $sql = "SELECT * FROM ".TB_PREF."salesman WHERE salesman_code='$selected_id'"; + + $result = db_query($sql,"could not get sales person"); + $myrow = db_fetch($result); + + $_POST['salesman_name'] = $myrow["salesman_name"]; + $_POST['salesman_phone'] = $myrow["salesman_phone"]; + $_POST['salesman_fax'] = $myrow["salesman_fax"]; + $_POST['salesman_email'] = $myrow["salesman_email"]; + $_POST['provision'] = percent_format($myrow["provision"]); + $_POST['break_pt'] = price_format($myrow["break_pt"]); + $_POST['provision2'] = percent_format($myrow["provision2"]); + } hidden('selected_id', $selected_id); +} elseif ($Mode != 'ADD_ITEM') { + $_POST['provision'] = percent_format(0); + $_POST['break_pt'] = price_format(0); + $_POST['provision2'] = percent_format(0); } start_table("$table_style2 width=60%"); @@ -166,7 +170,7 @@ amount_row(_("Break Pt.:"), 'break_pt'); percent_row(_("Provision")." 2:", 'provision2'); end_table(1); -submit_add_or_update_center(!isset($selected_id)); +submit_add_or_update_center($selected_id == -1, '', true); end_form(); diff --git a/sales/manage/sales_types.php b/sales/manage/sales_types.php index 195a1a5b..4acbe7d0 100644 --- a/sales/manage/sales_types.php +++ b/sales/manage/sales_types.php @@ -9,17 +9,7 @@ page(_("Sales Types")); include($path_to_root . "/includes/ui.inc"); include($path_to_root . "/sales/includes/db/sales_types_db.inc"); -if (isset($_POST['selected_id'])) -{ - $selected_id = $_POST['selected_id']; -} -elseif (isset($_GET['selected_id'])) -{ - $selected_id = $_GET['selected_id']; -} -else - $selected_id = -1; - +simple_page_mode(true); //---------------------------------------------------------------------------------------------------- function can_process() @@ -27,6 +17,14 @@ function can_process() if (strlen($_POST['sales_type']) == 0) { display_error(_("The sales type description cannot be empty.")); + set_focus('sales_type'); + return false; + } + + if (!check_num('factor', 0)) + { + display_error(_("Calculation factor must be valid positive number.")); + set_focus('factor'); return false; } return true; @@ -34,26 +32,28 @@ function can_process() //---------------------------------------------------------------------------------------------------- -if (isset($_POST['ADD_ITEM']) && can_process()) +if ($Mode=='ADD_ITEM' && can_process()) { add_sales_type($_POST['sales_type'], isset($_POST['tax_included']) ? 1:0, - $_POST['factor']); - meta_forward($_SERVER['PHP_SELF']); + input_num('factor')); + display_notification(_('New sales type has been added')); + $Mode = 'RESET'; } //---------------------------------------------------------------------------------------------------- -if (isset($_POST['UPDATE_ITEM']) && can_process()) +if ($Mode=='UPDATE_ITEM' && can_process()) { update_sales_type($selected_id, $_POST['sales_type'], isset($_POST['tax_included']) ? 1:0, - $_POST['factor']); - meta_forward($_SERVER['PHP_SELF']); + input_num('factor')); + display_notification(_('Selected sales type has been updated')); + $Mode = 'RESET'; } //---------------------------------------------------------------------------------------------------- -if (isset($_GET['delete'])) +if ($Mode == 'Delete') { // PREVENT DELETES IF DEPENDENT RECORDS IN 'debtor_trans' @@ -82,15 +82,22 @@ if (isset($_GET['delete'])) else { delete_sales_type($selected_id); - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('Selected sales type has been deleted')); + $Mode = 'RESET'; } } //end if sales type used in debtor transactions or in customers set up } +if ($Mode == 'RESET') +{ + $selected_id = -1; + unset($_POST); +} //---------------------------------------------------------------------------------------------------- $result = get_all_sales_types(); +start_form(); start_table("$table_style width=30%"); $th = array (_('Type Name'), _('Factor'), _('Tax Incl'), '',''); @@ -109,18 +116,17 @@ while ($myrow = db_fetch($result)) if($myrow["id"] == $base_sales) $f = ""._('Base').""; label_cell($f); label_cell($myrow["tax_included"] ? _('Yes'):_('No'), 'align=center'); - edit_link_cell("selected_id=".$myrow["id"]); - delete_link_cell("selected_id=".$myrow["id"]."&delete=1"); + edit_button_cell("Edit".$myrow['id'], _("Edit")); + edit_button_cell("Delete".$myrow['id'], _("Delete")); end_row(); } end_table(); +end_form(); display_note(_("Marked sales type is the company base pricelist for prices calculations."), 0, 0, "class='overduefg'"); //---------------------------------------------------------------------------------------------------- -hyperlink_no_params($_SERVER['PHP_SELF'], _("New Sales type")); - start_form(); if (!isset($_POST['tax_included'])) $_POST['tax_included'] = 0; @@ -132,22 +138,25 @@ start_table("$table_style2 width=30%"); if ($selected_id != -1) { - $myrow = get_sales_type($selected_id); - - $_POST['sales_type'] = $myrow["sales_type"]; - $_POST['tax_included'] = $myrow["tax_included"]; - $_POST['factor'] = number_format2($myrow["factor"],4); + if ($Mode == 'Edit') { + $myrow = get_sales_type($selected_id); + $_POST['sales_type'] = $myrow["sales_type"]; + $_POST['tax_included'] = $myrow["tax_included"]; + $_POST['factor'] = number_format2($myrow["factor"],4); + } hidden('selected_id', $selected_id); -} +} else { + $_POST['factor'] = number_format2(1,4); +} text_row_ex(_("Sales Type Name").':', 'sales_type', 20); -amount_row(_("Calculation factor").':', 'factor'); +amount_row(_("Calculation factor").':', 'factor', null, null, null, 4); check_row(_("Tax included").':', 'tax_included', $_POST['tax_included']); end_table(1); -submit_add_or_update_center($selected_id == -1); +submit_add_or_update_center($selected_id == -1, '', true); end_form(); diff --git a/taxes/item_tax_types.php b/taxes/item_tax_types.php index 661c86ca..f8eb7cdc 100644 --- a/taxes/item_tax_types.php +++ b/taxes/item_tax_types.php @@ -12,18 +12,10 @@ include_once($path_to_root . "/taxes/db/tax_types_db.inc"); include($path_to_root . "/includes/ui.inc"); -if (isset($_GET['selected_id'])) -{ - $selected_id = $_GET['selected_id']; -} -elseif(isset($_POST['selected_id'])) -{ - $selected_id = $_POST['selected_id']; -} - +simple_page_mode(true); //----------------------------------------------------------------------------------- -if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) +if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') { $input_error = 0; @@ -53,17 +45,17 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) } } - if (isset($selected_id)) - { - + if ($selected_id != -1) + { update_item_tax_type($selected_id, $_POST['name'], $_POST['exempt'], $exempt_from); + display_notification(_('Selected item tax type has been updated')); } else { - add_item_tax_type($_POST['name'], $_POST['exempt'], $exempt_from); + display_notification(_('New item tax type has been added')); } - meta_forward($_SERVER['PHP_SELF']); + $Mode = 'RESET'; } } @@ -86,20 +78,27 @@ function can_delete($selected_id) //----------------------------------------------------------------------------------- -if (isset($_GET['delete'])) +if ($Mode == 'Delete') { if (can_delete($selected_id)) { delete_item_tax_type($selected_id); - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('Selected item tax type has been deleted')); + $Mode = 'RESET'; } } +if ($Mode == 'RESET') +{ + $selected_id = -1; + unset($_POST); +} //----------------------------------------------------------------------------------- $result2 = $result = get_all_item_tax_types(); +start_form(); start_table("$table_style width=30%"); $th = array(_("Name"), _("Tax exempt"),'',''); @@ -122,41 +121,39 @@ while ($myrow = db_fetch($result2)) label_cell($myrow["name"]); label_cell($disallow_text); - edit_link_cell("selected_id=" . $myrow["id"]); - delete_link_cell("selected_id=" . $myrow["id"]. "&delete=1"); + edit_button_cell("Edit".$myrow["id"], _("Edit")); + edit_button_cell("Delete".$myrow["id"], _("Delete")); end_row(); } end_table(); +end_form(); +echo '
'; //----------------------------------------------------------------------------------- -hyperlink_no_params($_SERVER['PHP_SELF'], _("New Item Tax type")); - start_form(); start_table($table_style2); -if (isset($selected_id)) +if ($selected_id != -1) { - - if (!isset($_POST['name'])) - { - $myrow = get_item_tax_type($selected_id); + if ($Mode == 'Edit') { + $myrow = get_item_tax_type($selected_id); - $_POST['name'] = $myrow["name"]; - $_POST['exempt'] = $myrow["exempt"]; + $_POST['name'] = $myrow["name"]; + $_POST['exempt'] = $myrow["exempt"]; - // read the exemptions and check the ones that are on - $exemptions = get_item_tax_type_exemptions($selected_id); + // read the exemptions and check the ones that are on + $exemptions = get_item_tax_type_exemptions($selected_id); - if (db_num_rows($exemptions) > 0) - { - while ($exmp = db_fetch($exemptions)) - { - $_POST['ExemptTax' . $exmp["tax_type_id"]] = 1; - } - } + if (db_num_rows($exemptions) > 0) + { + while ($exmp = db_fetch($exemptions)) + { + $_POST['ExemptTax' . $exmp["tax_type_id"]] = 1; + } + } } hidden('selected_id', $selected_id); @@ -185,7 +182,7 @@ if (!isset($_POST['exempt']) || $_POST['exempt'] == 0) alt_table_row_color($k); label_cell($myrow["name"]); - label_cell(percent_format($myrow["rate"])." %", "nowrap align=right"); + label_cell(percent_format($myrow["rate"])." %", "nowrap align=right"); check_cells("", 'ExemptTax' . $myrow["id"], null); end_row(); } @@ -193,7 +190,7 @@ if (!isset($_POST['exempt']) || $_POST['exempt'] == 0) end_table(1); } -submit_add_or_update_center(!isset($selected_id)); +submit_add_or_update_center($selected_id == -1, '', true); end_form(); diff --git a/taxes/tax_groups.php b/taxes/tax_groups.php index e7f99f21..78993f2a 100644 --- a/taxes/tax_groups.php +++ b/taxes/tax_groups.php @@ -13,22 +13,13 @@ include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/taxes/db/tax_groups_db.inc"); include_once($path_to_root . "/taxes/db/tax_types_db.inc"); -if (isset($_GET['selected_id'])) -{ - $selected_id = $_GET['selected_id']; -} -elseif(isset($_POST['selected_id'])) -{ - $selected_id = $_POST['selected_id']; -} -else - $selected_id = -1; +simple_page_mode(true); check_db_has_tax_types(_("There are no tax types defined. Define tax types before defining tax groups.")); //----------------------------------------------------------------------------------- -if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) +if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM') { //initialise no input errors assumed initially before we test @@ -76,18 +67,17 @@ if (isset($_POST['ADD_ITEM']) || isset($_POST['UPDATE_ITEM'])) if ($selected_id != -1) { - - update_tax_group($selected_id, $_POST['name'], $_POST['tax_shipping'], $taxes, + update_tax_group($selected_id, $_POST['name'], $_POST['tax_shipping'], $taxes, $rates); - + display_notification(_('Selected tax group has been updated')); } else { - - add_tax_group($_POST['name'], $_POST['tax_shipping'], $taxes, $rates); + add_tax_group($_POST['name'], $_POST['tax_shipping'], $taxes, $rates); + display_notification(_('New tax group has been added')); } - meta_forward($_SERVER['PHP_SELF']); + $Mode = 'RESET'; } } @@ -122,20 +112,27 @@ function can_delete($selected_id) //----------------------------------------------------------------------------------- -if (isset($_GET['delete'])) +if ($Mode == 'Delete') { if (can_delete($selected_id)) { delete_tax_group($selected_id); - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('Selected tax group has been deleted')); + $Mode = 'RESET'; } } +if ($Mode == 'RESET') +{ + $selected_id = -1; + unset($_POST); +} //----------------------------------------------------------------------------------- $result = get_all_tax_groups(); +start_form(); start_table($table_style); $th = array(_("Description"), _("Tax Shipping"), "", ""); table_header($th); @@ -156,17 +153,17 @@ while ($myrow = db_fetch($result)) if ($myrow["type" . $i] != reserved_words::get_all_numeric()) echo "" . $myrow["type" . $i] . "";*/ - edit_link_cell("selected_id=" . $myrow["id"]); - delete_link_cell("selected_id=" . $myrow["id"]. "&delete=1"); + edit_button_cell("Edit".$myrow["id"], _("Edit")); + edit_button_cell("Delete".$myrow["id"], _("Delete")); end_row();; } end_table(); +end_form(); +echo '
'; //----------------------------------------------------------------------------------- -hyperlink_no_params($_SERVER['PHP_SELF'], _("New Tax Group")); - start_form(); start_table($table_style2); @@ -175,8 +172,7 @@ if ($selected_id != -1) { //editing an existing status code - if (!isset($_POST['name'])) - { + if ($Mode == 'Edit') { $group = get_tax_group($selected_id); $_POST['name'] = $group["name"]; @@ -228,7 +224,7 @@ for ($i = 0; $i < 5; $i++) end_table(1); -submit_add_or_update_center(!isset($selected_id)); +submit_add_or_update_center($selected_id == -1, '', true); end_form(); diff --git a/taxes/tax_types.php b/taxes/tax_types.php index 55e40950..d93a29a3 100644 --- a/taxes/tax_types.php +++ b/taxes/tax_types.php @@ -8,14 +8,7 @@ page(_("Tax Types")); include_once($path_to_root . "/includes/ui.inc"); include_once($path_to_root . "/taxes/db/tax_types_db.inc"); -if (isset($_GET['selected_id'])) -{ - $selected_id = $_GET['selected_id']; -} -elseif(isset($_POST['selected_id'])) -{ - $selected_id = $_POST['selected_id']; -} +simple_page_mode(true); //----------------------------------------------------------------------------------- function can_process() @@ -38,22 +31,24 @@ function can_process() //----------------------------------------------------------------------------------- -if (isset($_POST['ADD_ITEM']) && can_process()) +if ($Mode=='ADD_ITEM' && can_process()) { add_tax_type($_POST['name'], $_POST['sales_gl_code'], $_POST['purchasing_gl_code'], input_num('rate')); - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('New tax type has been added')); + $Mode = 'RESET'; } //----------------------------------------------------------------------------------- -if (isset($_POST['UPDATE_ITEM']) && can_process()) +if ($Mode=='UPDATE_ITEM' && can_process()) { update_tax_type($selected_id, $_POST['name'], $_POST['sales_gl_code'], $_POST['purchasing_gl_code'], input_num('rate')); - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('Selected tax type has been updated')); + $Mode = 'RESET'; } //----------------------------------------------------------------------------------- @@ -76,20 +71,27 @@ function can_delete($selected_id) //----------------------------------------------------------------------------------- -if (isset($_GET['delete'])) +if ($Mode == 'Delete') { if (can_delete($selected_id)) { delete_tax_type($selected_id); - meta_forward($_SERVER['PHP_SELF']); + display_notification(_('Selected tax type has been deleted')); + $Mode = 'RESET'; } } +if ($Mode == 'RESET') +{ + $selected_id = -1; + unset($_POST); +} //----------------------------------------------------------------------------------- $result = get_all_tax_types(); +start_form(); start_table($table_style); $th = array(_("Description"), _("Default Rate (%)"), @@ -107,17 +109,16 @@ while ($myrow = db_fetch($result)) label_cell($myrow["sales_gl_code"] . " " . $myrow["SalesAccountName"]); label_cell($myrow["purchasing_gl_code"] . " " . $myrow["PurchasingAccountName"]); - edit_link_cell("selected_id=".$myrow["id"]); - delete_link_cell("selected_id=".$myrow["id"]."&delete=1"); + edit_button_cell("Edit".$myrow["id"], _("Edit")); + edit_button_cell("Delete".$myrow["id"], _("Delete")); end_row(); } end_table(); -//----------------------------------------------------------------------------------- - -hyperlink_no_params($_SERVER['PHP_SELF'], _("New Tax Type")); +end_form(); +echo '
'; //----------------------------------------------------------------------------------- @@ -125,17 +126,18 @@ start_form(); start_table($table_style2); -if (isset($selected_id)) +if ($selected_id != -1) { - //editing an existing status code - - $myrow = get_tax_type($selected_id); + if ($Mode == 'Edit') { + //editing an existing status code - $_POST['name'] = $myrow["name"]; - $_POST['rate'] = percent_format($myrow["rate"]); - $_POST['sales_gl_code'] = $myrow["sales_gl_code"]; - $_POST['purchasing_gl_code'] = $myrow["purchasing_gl_code"]; + $myrow = get_tax_type($selected_id); + $_POST['name'] = $myrow["name"]; + $_POST['rate'] = percent_format($myrow["rate"]); + $_POST['sales_gl_code'] = $myrow["sales_gl_code"]; + $_POST['purchasing_gl_code'] = $myrow["purchasing_gl_code"]; + } hidden('selected_id', $selected_id); } text_row_ex(_("Description:"), 'name', 50); @@ -146,7 +148,7 @@ gl_all_accounts_list_row(_("Purchasing GL Account:"), 'purchasing_gl_code', null end_table(1); -submit_add_or_update_center(!isset($selected_id)); +submit_add_or_update_center($selected_id == -1, '', true); end_form(); -- 2.30.2