projects
/
fa-stable.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Added 'View Attachments' if any in all popup view windows
[fa-stable.git]
/
inventory
/
manage
/
locations.php
diff --git
a/inventory/manage/locations.php
b/inventory/manage/locations.php
index d32d10a1ea7486fbd12768829fc365b1229ee107..1deb1f2064df5f9db3d34fe516273bfd5fc9a8a8 100644
(file)
--- a/
inventory/manage/locations.php
+++ b/
inventory/manage/locations.php
@@
-13,7
+13,7
@@
$page_security = 'SA_INVENTORYLOCATION';
$path_to_root = "../..";
include($path_to_root . "/includes/session.inc");
$path_to_root = "../..";
include($path_to_root . "/includes/session.inc");
-page(_("Inventory Locations"));
+page(_(
$help_context =
"Inventory Locations"));
include_once($path_to_root . "/includes/ui.inc");
include_once($path_to_root . "/includes/ui.inc");
@@
-71,69
+71,46
@@
if ($Mode=='ADD_ITEM' || $Mode=='UPDATE_ITEM')
function can_delete($selected_id)
{
function can_delete($selected_id)
{
- $sql= "SELECT COUNT(*) FROM ".TB_PREF."stock_moves WHERE loc_code=".db_escape($selected_id);
- $result = db_query($sql, "could not query stock moves");
- $myrow = db_fetch_row($result);
- if ($myrow[0] > 0)
+ if (key_in_foreign_table($selected_id, 'stock_moves', 'loc_code'))
{
display_error(_("Cannot delete this location because item movements have been created using this location."));
return false;
}
{
display_error(_("Cannot delete this location because item movements have been created using this location."));
return false;
}
- $sql= "SELECT COUNT(*) FROM ".TB_PREF."workorders WHERE loc_code=".db_escape($selected_id);
- $result = db_query($sql, "could not query work orders");
- $myrow = db_fetch_row($result);
- if ($myrow[0] > 0)
+ if (key_in_foreign_table($selected_id, 'workorders', 'loc_code'))
{
display_error(_("Cannot delete this location because it is used by some work orders records."));
return false;
}
{
display_error(_("Cannot delete this location because it is used by some work orders records."));
return false;
}
- $sql= "SELECT COUNT(*) FROM ".TB_PREF."cust_branch WHERE default_location='$selected_id'";
- $result = db_query($sql, "could not query customer branches");
- $myrow = db_fetch_row($result);
- if ($myrow[0] > 0)
+ if (key_in_foreign_table($selected_id, 'cust_branch', 'default_location'))
{
display_error(_("Cannot delete this location because it is used by some branch records as the default location to deliver from."));
return false;
}
{
display_error(_("Cannot delete this location because it is used by some branch records as the default location to deliver from."));
return false;
}
- $sql= "SELECT COUNT(*) FROM ".TB_PREF."bom WHERE loc_code=".db_escape($selected_id);
- $result = db_query($sql, "could not query bom");
- $myrow = db_fetch_row($result);
- if ($myrow[0] > 0)
+ if (key_in_foreign_table($selected_id, 'bom', 'loc_code'))
{
display_error(_("Cannot delete this location because it is used by some related records in other tables."));
return false;
}
{
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=".db_escape($selected_id);
- $result = db_query($sql, "could not query grn batch");
- $myrow = db_fetch_row($result);
- if ($myrow[0] > 0)
+
+ if (key_in_foreign_table($selected_id, 'grn_batch', 'loc_code'))
{
display_error(_("Cannot delete this location because it is used by some related records in other tables."));
return false;
}
{
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=".db_escape($selected_id);
- $result = db_query($sql, "could not query purch orders");
- $myrow = db_fetch_row($result);
- if ($myrow[0] > 0)
+ if (key_in_foreign_table($selected_id, 'purch_orders', 'into_stock_location'))
{
display_error(_("Cannot delete this location because it is used by some related records in other tables."));
return false;
}
{
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=".db_escape($selected_id);
- $result = db_query($sql, "could not query sales orders");
- $myrow = db_fetch_row($result);
- if ($myrow[0] > 0)
+ if (key_in_foreign_table($selected_id, 'sales_orders', 'from_stk_loc'))
{
display_error(_("Cannot delete this location because it is used by some related records in other tables."));
return false;
}
{
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=".db_escape($selected_id);
- $result = db_query($sql, "could not query sales pos");
- $myrow = db_fetch_row($result);
- if ($myrow[0] > 0)
+ if (key_in_foreign_table($selected_id, 'sales_pos', 'pos_location'))
{
display_error(_("Cannot delete this location because it is used by some related records in other tables."));
return false;
{
display_error(_("Cannot delete this location because it is used by some related records in other tables."));
return false;
@@
-162,9
+139,7
@@
if ($Mode == 'RESET')
$_POST['show_inactive'] = $sav;
}
$_POST['show_inactive'] = $sav;
}
-$sql = "SELECT * FROM ".TB_PREF."locations";
-if (!check_value('show_inactive')) $sql .= " WHERE !inactive";
-$result = db_query($sql, "could not query locations");;
+$result = get_item_locations(check_value('show_inactive'));
start_form();
start_table($table_style);
start_form();
start_table($table_style);