shop code
This commit is contained in:
@@ -4,7 +4,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
# GET /inventory_definitions
|
||||
# GET /inventory_definitions.json
|
||||
def index
|
||||
@inventory_definitions = InventoryDefinition.all
|
||||
@inventory_definitions = InventoryDefinition.where("shop_code='#{@shop.shop_code}'")
|
||||
end
|
||||
|
||||
# GET /inventory_definitions/1
|
||||
@@ -14,7 +14,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
|
||||
# GET /inventory_definitions/new
|
||||
def new
|
||||
@menus = Menu.all
|
||||
@menus = Menu.where("shop_code='#{@shop.shop_code}'").order('created_at asc')
|
||||
@menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc')
|
||||
@inventory_definition = InventoryDefinition.new
|
||||
end
|
||||
@@ -26,7 +26,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
# POST /inventory_definitions
|
||||
# POST /inventory_definitions.json
|
||||
def create
|
||||
inventory = InventoryDefinition.find_by_item_code(params[:item_code])
|
||||
inventory = InventoryDefinition.find_by_item_code_and_shop_code(params[:item_code],@shop.shop_code)
|
||||
if inventory.nil?
|
||||
|
||||
@inventory_definition = InventoryDefinition.new
|
||||
@@ -39,6 +39,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
@inventory_definition.min_order_level = params[:min_order_level]
|
||||
@inventory_definition.max_stock_level = inventory.max_stock_level.to_i + params[:max_stock_level].to_i
|
||||
end
|
||||
@inventory_definition.shop_code = @shop.shop_code
|
||||
@inventory_definition.created_by = current_user.id
|
||||
if @inventory_definition.save
|
||||
result = {:status=> true, :message => "Inventory definition was created successfully",:data=> @inventory_definition}
|
||||
@@ -83,16 +84,16 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
# DELETE /inventory_definitions/1
|
||||
# DELETE /inventory_definitions/1.json
|
||||
def destroy
|
||||
inventory = InventoryDefinition.find_by_item_code(params[:item_code])
|
||||
inventory = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
||||
@inventory_definition.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to inventory_definitions_url, notice: 'Inventory definition was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
# respond_to do |format|
|
||||
# format.html { redirect_to inventory_inventory_definitions_url, notice: 'Inventory definition was successfully destroyed.' }
|
||||
# format.json { head :no_content }
|
||||
# end
|
||||
|
||||
inventory = InventoryDefinition.find(params[:id])
|
||||
StockJournal.delete_stock_journal(inventory.item_code)
|
||||
StockCheckItem.delete_stock_check_item(inventory.item_code)
|
||||
# inventory = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
||||
StockJournal.delete_stock_journal(inventory.item_code,@shop)
|
||||
StockCheckItem.delete_stock_check_item(inventory.item_code,@shop)
|
||||
if !inventory.nil?
|
||||
inventory.destroy
|
||||
flash[:message] = 'Inventory was successfully destroyed.'
|
||||
@@ -103,16 +104,10 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
end
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
@shop = Shop.first
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_inventory_definition
|
||||
@inventory_definition = InventoryDefinition.find(params[:id])
|
||||
@inventory_definition = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code)
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
|
||||
Reference in New Issue
Block a user