X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=inventory%2Fmanage%2Flocations.php;h=b43c878195425dec7f6454648f6d6ffbc800f85a;hb=c31829537f02787dd94654820dd74168c054b8c4;hp=4fdef13119df1bddd13d34c46a42d6da300603ca;hpb=0b253e5e0d23400838d3bfb4f27fb3fb2637b3ab;p=fa-stable.git diff --git a/inventory/manage/locations.php b/inventory/manage/locations.php index 4fdef131..b43c8781 100644 --- a/inventory/manage/locations.php +++ b/inventory/manage/locations.php @@ -9,8 +9,8 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License here . ***********************************************************************/ -$page_security = 11; -$path_to_root="../.."; +$page_security = 'SA_INVENTORYLOCATION'; +$path_to_root = "../.."; include($path_to_root . "/includes/session.inc"); page(_("Inventory Locations")); @@ -98,6 +98,46 @@ function can_delete($selected_id) return false; } + $sql= "SELECT COUNT(*) FROM ".TB_PREF."bom WHERE loc_code='$selected_id'"; + $result = db_query($sql, "could not query bom"); + $myrow = db_fetch_row($result); + if ($myrow[0] > 0) + { + display_error(_("Cannot delete this location because it is used by some related records in other tables.")); + return false; + } + $sql= "SELECT COUNT(*) FROM ".TB_PREF."grn_batch WHERE loc_code='$selected_id'"; + $result = db_query($sql, "could not query grn batch"); + $myrow = db_fetch_row($result); + if ($myrow[0] > 0) + { + display_error(_("Cannot delete this location because it is used by some related records in other tables.")); + return false; + } + $sql= "SELECT COUNT(*) FROM ".TB_PREF."purch_orders WHERE into_stock_location='$selected_id'"; + $result = db_query($sql, "could not query purch orders"); + $myrow = db_fetch_row($result); + if ($myrow[0] > 0) + { + display_error(_("Cannot delete this location because it is used by some related records in other tables.")); + return false; + } + $sql= "SELECT COUNT(*) FROM ".TB_PREF."sales_orders WHERE from_stk_loc='$selected_id'"; + $result = db_query($sql, "could not query sales orders"); + $myrow = db_fetch_row($result); + if ($myrow[0] > 0) + { + display_error(_("Cannot delete this location because it is used by some related records in other tables.")); + return false; + } + $sql= "SELECT COUNT(*) FROM ".TB_PREF."sales_pos WHERE pos_location='$selected_id'"; + $result = db_query($sql, "could not query sales pos"); + $myrow = db_fetch_row($result); + if ($myrow[0] > 0) + { + display_error(_("Cannot delete this location because it is used by some related records in other tables.")); + return false; + } return true; } @@ -127,7 +167,7 @@ if (!check_value('show_inactive')) $sql .= " WHERE !inactive"; $result = db_query($sql, "could not query locations");; start_form(); -start_table("$table_style width=30%"); +start_table($table_style); $th = array(_("Location Code"), _("Location Name"), _("Address"), _("Phone"), "", ""); inactive_control_column($th); table_header($th);