X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=inventory%2Fmanage%2Flocations.php;h=26152b28694316d8726d3109194260f8dfad0e36;hb=2383d33373d6ddec06906658a0ed6398077c1147;hp=4fdef13119df1bddd13d34c46a42d6da300603ca;hpb=eb5b2d3ee7cc0fca5ec63dfada65ecf23b693e85;p=fa-stable.git diff --git a/inventory/manage/locations.php b/inventory/manage/locations.php index 4fdef131..26152b28 100644 --- a/inventory/manage/locations.php +++ b/inventory/manage/locations.php @@ -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; }