- $sql= "SELECT COUNT(*) FROM ".TB_PREF."bom WHERE component='$stock_id'";
- $result = db_query($sql, "could not query boms");
- $myrow = db_fetch_row($result);
- if ($myrow[0] > 0)
- {
- display_error(_('Cannot delete this item record because there are bills of material that require this part as a component.'));
- return false;
- }
-
- $sql= "SELECT COUNT(*) FROM ".TB_PREF."sales_order_details WHERE stk_code='$stock_id'";
- $result = db_query($sql, "could not query sales orders");
- $myrow = db_fetch_row($result);
- if ($myrow[0] > 0)
- {
- display_error(_('Cannot delete this item record because there are existing sales orders for this part.'));
- return false;
- }
-
- $sql= "SELECT COUNT(*) FROM ".TB_PREF."purch_order_details WHERE item_code='$stock_id'";
- $result = db_query($sql, "could not query purchase orders");
- $myrow = db_fetch_row($result);
- if ($myrow[0] > 0)
- {
- display_error(_('Cannot delete this item because there are existing purchase order items for it.'));
- return false;
- }
- $kits = get_where_used($stock_id);
- $num_kits = db_num_rows($kits);
- if ($num_kits) {
- $msg = _("This item cannot be deleted because some code aliases
- or foreign codes was entered for it, or there are kits defined
- using this item as component")
- .':<br>';
-
- while($num_kits--) {
- $kit = db_fetch($kits);
- $msg .= "'".$kit[0]."'";
- if ($num_kits) $msg .= ',';
- }
- display_error($msg);