Merge branch 'august_spring' of bitbucket.org:code2lab/sxrestaurant into august_spring
* 'august_spring' of bitbucket.org:code2lab/sxrestaurant: (71 commits) Update Coupon / Voucher data change update menu_sync update addorder update addorder view add fields for Menu Sync update add oreder add menu api update add order and calculate subtotal update seed menu ui update update ability for setmenu fixed update show for foc add bootstrap file input and menu item img implemented update foc and pdf update menu item update receipt bill pdf for foc and credit add CarrierWave gems for menu image upload add CarrierWave gems for menu image upload ...
This commit is contained in:
9
app/controllers/api/restaurant/item_sets_controller.rb
Normal file
9
app/controllers/api/restaurant/item_sets_controller.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class Api::Restaurant::ItemSetsController < Api::ApiController
|
||||
|
||||
#Description
|
||||
# Pull the default menu details and also other available (active) menus
|
||||
# Input Params - order_id
|
||||
def index
|
||||
@item_sets = ItemSet.all
|
||||
end
|
||||
end
|
||||
@@ -1,11 +1,11 @@
|
||||
class Api::Restaurant::MenuController < Api::ApiController
|
||||
|
||||
class Api::Restaurant::MenuCategoriesController < Api::ApiController
|
||||
skip_before_action :authenticate
|
||||
#Description
|
||||
# Pull the default menu details and also other available (active) menus
|
||||
# Input Params - order_id
|
||||
def index
|
||||
@menus = Menu.all
|
||||
@current_menu = Menu.current_menu
|
||||
@menus = MenuCategory.all
|
||||
@current_menu = MenuCategory.current_menu
|
||||
|
||||
end
|
||||
|
||||
@@ -21,10 +21,10 @@ class Api::Restaurant::MenuController < Api::ApiController
|
||||
def menu_detail (menu_id)
|
||||
if (menu_id)
|
||||
#Pull this menu
|
||||
menu = Menu.find_by_id(menu_id)
|
||||
menu = MenuCategory.find_by_id(menu_id)
|
||||
return menu
|
||||
else
|
||||
Menu.current_menu
|
||||
MenuCategory.current_menu
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,12 +1,11 @@
|
||||
class Api::Restaurant::MenuController < Api::ApiController
|
||||
|
||||
skip_before_action :authenticate
|
||||
#Description
|
||||
# Pull the default menu details and also other available (active) menus
|
||||
# Input Params - order_id
|
||||
def index
|
||||
@menus = Menu.all
|
||||
@current_menu = Menu.current_menu
|
||||
|
||||
# @current_menu = Menu.current_menu
|
||||
end
|
||||
|
||||
#Description
|
||||
|
||||
@@ -6,8 +6,4 @@ class Api::Restaurant::MenuItemAttributesController < Api::ApiController
|
||||
def index
|
||||
@menu_attributes = MenuItemAttribute.all
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
class Api::Restaurant::MenuItemOptionsController < Api::ApiController
|
||||
|
||||
#Description
|
||||
# Pull the default menu details and also other available (active) menus
|
||||
# Input Params - order_id
|
||||
def index
|
||||
@menu_options = MenuItemOption.all
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -14,10 +14,9 @@ module TokenVerification
|
||||
end
|
||||
|
||||
def authenticate_token
|
||||
authenticate_with_http_token do |token, options|
|
||||
authenticate_with_http_token do |token, options|
|
||||
#@current_user = User.find_by(api_key: token)
|
||||
Rails.logger.debug "token - " + token.to_s
|
||||
|
||||
@user = Employee.authenticate_by_token(token)
|
||||
if @user
|
||||
return true
|
||||
|
||||
@@ -17,6 +17,8 @@ class Crm::CustomersController < BaseCrmController
|
||||
@crm_customer = Customer.new
|
||||
@count_customer = Customer.count_customer
|
||||
|
||||
@taxes = TaxProfile.all.order("order_by asc")
|
||||
|
||||
# if flash["errors"]
|
||||
# @crm_customer.valid?
|
||||
# end
|
||||
@@ -63,15 +65,21 @@ class Crm::CustomersController < BaseCrmController
|
||||
|
||||
# GET /crm/customers/1/edit
|
||||
def edit
|
||||
@customer = Customer.find(params[:id])
|
||||
end
|
||||
|
||||
# POST /crm/customers
|
||||
# POST /crm/customers.json
|
||||
def create
|
||||
def create
|
||||
# Remove "" default first
|
||||
params[:customer][:tax_profiles].delete_at(0)
|
||||
@crm_customers = Customer.new(customer_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @crm_customers.save
|
||||
# update tax profile
|
||||
customer = Customer.find(@crm_customers.customer_id)
|
||||
customer.update_attributes(tax_profiles: params[:customer][:tax_profiles])
|
||||
name = customer_params[:name]
|
||||
phone = customer_params[:contact_no]
|
||||
email = customer_params[:email]
|
||||
@@ -188,10 +196,12 @@ end
|
||||
# PATCH/PUT /crm/customers/1
|
||||
# PATCH/PUT /crm/customers/1.json
|
||||
def update
|
||||
|
||||
# Remove "" default first
|
||||
params[:customer][:tax_profiles].delete_at(0)
|
||||
respond_to do |format|
|
||||
if @crm_customer.update(customer_params)
|
||||
|
||||
# update tax profile
|
||||
@crm_customer.update_attributes(tax_profiles: params[:customer][:tax_profiles])
|
||||
name = customer_params[:name]
|
||||
phone = customer_params[:contact_no]
|
||||
email = customer_params[:email]
|
||||
@@ -346,7 +356,7 @@ end
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def customer_params
|
||||
|
||||
params.require(:customer).permit(:name, :company, :contact_no, :email,
|
||||
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no)
|
||||
params.require(:customer).permit(:id, :name, :company, :contact_no, :email,
|
||||
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type)
|
||||
end
|
||||
end
|
||||
|
||||
126
app/controllers/oqs/backhome_controller.rb
Normal file
126
app/controllers/oqs/backhome_controller.rb
Normal file
@@ -0,0 +1,126 @@
|
||||
class Oqs::HomeController < BaseOqsController
|
||||
def index
|
||||
queue_stations=OrderQueueStation.all
|
||||
|
||||
# Query for OQS with delivery status false
|
||||
@queue_items_details = queue_items_query(false)
|
||||
|
||||
# Query for OQS with delivery status true
|
||||
@queue_completed_item = completed_order
|
||||
|
||||
@queue_stations_items=Array.new
|
||||
|
||||
# Calculate Count for each station tab
|
||||
queue_stations.each do |que|
|
||||
i = 0
|
||||
zone_id = 0
|
||||
@queue_items_details.each do |qid|
|
||||
dining = DiningFacility.find_by_name(qid.zone)
|
||||
que.order_queue_process_by_zones.each do |qz|
|
||||
if qid.station_id == qz.order_queue_station_id && qid.zone_id == qz.zone_id
|
||||
zone_id = qid.zone_id
|
||||
i=i+1
|
||||
end
|
||||
end
|
||||
end
|
||||
@queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i })
|
||||
end
|
||||
|
||||
# @queue_items_details = @queue_items_details.paginate(:per_page => 10, :page => params[:page])
|
||||
@queue_stations_items
|
||||
end
|
||||
|
||||
# Get Order items
|
||||
def get_order_items
|
||||
items = []
|
||||
table_name = params[:table_id]
|
||||
status = params[:status]
|
||||
dining = DiningFacility.find_by_name(table_name);
|
||||
# oqpz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id)
|
||||
# if status == ""
|
||||
# AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=0").find_each do |aoi|
|
||||
# oi = OrderItem.find_by_item_code(aoi.item_code)
|
||||
# items.push(oi)
|
||||
# end
|
||||
# else
|
||||
# AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=1").find_each do |aoi|
|
||||
# oi = OrderItem.find_by_item_code(aoi.item_code)
|
||||
# items.push(oi)
|
||||
# end
|
||||
# end
|
||||
|
||||
booking = Booking.find_by_dining_facility_id(dining.id)
|
||||
BookingOrder.where("booking_id='#{ booking.booking_id }'").find_each do |bo|
|
||||
order=Order.find(bo.order_id)
|
||||
order.order_items.each do |oi|
|
||||
items.push(oi)
|
||||
end
|
||||
end
|
||||
|
||||
# booking_id = dining.get_new_booking
|
||||
# BookingOrder.where("booking_id='#{ booking_id }'").find_each do |bo|
|
||||
# order=Order.find(bo.order_id);
|
||||
# order.order_items.each do |oi|
|
||||
# items.push(oi)
|
||||
# end
|
||||
# end
|
||||
|
||||
render :json => items.to_json
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
# update delivery status when complete click
|
||||
def update_delivery_status
|
||||
removed_item = []
|
||||
assigned_item_id = params[:id]
|
||||
assigned_item=AssignedOrderItem.find(assigned_item_id)
|
||||
assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
|
||||
|
||||
# update delivery status for completed same order items
|
||||
assigned_items.each do |ai|
|
||||
ai.delivery_status=true
|
||||
ai.save
|
||||
removed_item.push(ai.assigned_order_item_id)
|
||||
end
|
||||
render :json => removed_item.to_json
|
||||
end
|
||||
|
||||
# Query for OQS with delivery status
|
||||
def queue_items_query(status)
|
||||
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type as type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
|
||||
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
|
||||
left join orders as od ON od.order_id = assigned_order_items.order_id
|
||||
left join order_items as odt ON odt.item_code = assigned_order_items.item_code AND odt.order_id = assigned_order_items.order_id
|
||||
left join customers as cus ON cus.customer_id = od.customer_id
|
||||
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
|
||||
left join bookings as bk on bk.booking_id = bo.booking_id
|
||||
left join dining_facilities as df on df.id = bk.dining_facility_id")
|
||||
.where("assigned_order_items.delivery_status = 0 AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}'")
|
||||
.group("assigned_order_items.assigned_order_item_id")
|
||||
.order("assigned_order_items.created_at")
|
||||
end
|
||||
|
||||
# Completed Order
|
||||
def completed_order
|
||||
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
|
||||
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
|
||||
left join orders as od ON od.order_id = assigned_order_items.order_id
|
||||
left join order_items as odt ON odt.item_code = assigned_order_items.item_code AND odt.order_id = assigned_order_items.order_id
|
||||
left join customers as cus ON cus.customer_id = od.customer_id
|
||||
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
|
||||
left join bookings as bk on bk.booking_id = bo.booking_id
|
||||
left join dining_facilities as df on df.id = bk.dining_facility_id")
|
||||
.where("assigned_order_items.delivery_status = true AND odt.price <> 0 AND assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'")
|
||||
.group("assigned_order_items.order_id")
|
||||
.limit(20)
|
||||
.order("assigned_order_items.created_at")
|
||||
|
||||
|
||||
# completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true');
|
||||
end
|
||||
|
||||
end
|
||||
@@ -1,33 +1,44 @@
|
||||
class Oqs::HomeController < BaseOqsController
|
||||
def index
|
||||
queue_stations=OrderQueueStation.all
|
||||
|
||||
@queue_stations = OrderQueueStation.all
|
||||
|
||||
# Query for OQS with delivery status false
|
||||
@queue_items_details = queue_items_query(false)
|
||||
# @queue_items_details = queue_items_query(false)
|
||||
|
||||
# Query for OQS with delivery status true
|
||||
@queue_completed_item = completed_order
|
||||
|
||||
|
||||
@queue_stations_items=Array.new
|
||||
@filter = params[:filter]
|
||||
|
||||
@queue_completed_item = completed_order(@filter)
|
||||
if !@filter.nil?
|
||||
@count = queue_items_count_query(false,@filter)
|
||||
@count.each do |count|
|
||||
|
||||
# Calculate Count for each station tab
|
||||
queue_stations.each do |que|
|
||||
i = 0
|
||||
zone_id = 0
|
||||
@queue_items_details.each do |qid|
|
||||
dining = DiningFacility.find_by_name(qid.zone)
|
||||
que.order_queue_process_by_zones.each do |qz|
|
||||
if qid.station_id == qz.order_queue_station_id && qid.zone_id == qz.zone_id
|
||||
zone_id = qid.zone_id
|
||||
i=i+1
|
||||
end
|
||||
end
|
||||
end
|
||||
@queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i })
|
||||
end
|
||||
|
||||
# @queue_items_details = @queue_items_details.paginate(:per_page => 10, :page => params[:page])
|
||||
@queue_stations_items
|
||||
# @queue_stations_items=Array.new
|
||||
|
||||
# Calculate Count for each station tab
|
||||
# @queue_stations.each do |que|
|
||||
# i = 0
|
||||
# zone_id = 0
|
||||
# @queue_items_details.each do |qid|
|
||||
# dining = DiningFacility.find_by_name(qid.zone)
|
||||
# que.order_queue_process_by_zones.each do |qz|
|
||||
# if qid.station_id == qz.order_queue_station_id && qid.zone_id == qz.zone_id
|
||||
# zone_id = qid.zone_id
|
||||
# i=i+1
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
# @queue_stations_items.push({:zone_id => zone_id , :station_name => que.station_name, :is_active => que.is_active , :is_ap => que.auto_print, :item_count => i })
|
||||
# end
|
||||
|
||||
# # @queue_items_details = @queue_items_details.paginate(:per_page => 10, :page => params[:page])
|
||||
# @queue_stations_items
|
||||
end
|
||||
|
||||
# Get Order items
|
||||
@@ -68,6 +79,13 @@ class Oqs::HomeController < BaseOqsController
|
||||
render :json => items.to_json
|
||||
end
|
||||
|
||||
def get_items_by_oqs
|
||||
oqs_id = params[:id]
|
||||
filter = params[:filter]
|
||||
items = queue_items_query(false,oqs_id,filter)
|
||||
render :json => items.to_json
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
@@ -87,9 +105,22 @@ class Oqs::HomeController < BaseOqsController
|
||||
render :json => removed_item.to_json
|
||||
end
|
||||
|
||||
|
||||
# Query for OQS with delivery status
|
||||
def queue_items_query(status)
|
||||
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
|
||||
def queue_items_query(status,oqs_id=nil,filter)
|
||||
if oqs_id == nil
|
||||
oqs = ''
|
||||
else
|
||||
oqs = "and assigned_order_items.order_queue_station_id = '#{oqs_id}' "
|
||||
end
|
||||
|
||||
query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id,
|
||||
oqs.id as station_id, oqs.station_name,
|
||||
oqs.is_active, oqpz.zone_id,
|
||||
df.name as zone, df.type as table_type,
|
||||
odt.order_id, odt.item_code, odt.item_name,
|
||||
odt.price, odt.qty, odt.item_order_by, odt.options,
|
||||
cus.name as customer_name, odt.created_at")
|
||||
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
|
||||
left join orders as od ON od.order_id = assigned_order_items.order_id
|
||||
@@ -98,14 +129,15 @@ class Oqs::HomeController < BaseOqsController
|
||||
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
|
||||
left join bookings as bk on bk.booking_id = bo.booking_id
|
||||
left join dining_facilities as df on df.id = bk.dining_facility_id")
|
||||
.where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}'")
|
||||
.where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} ")
|
||||
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
|
||||
.group("assigned_order_items.assigned_order_item_id")
|
||||
.order("assigned_order_items.created_at")
|
||||
|
||||
end
|
||||
|
||||
# Completed Order
|
||||
def completed_order
|
||||
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
|
||||
def completed_order(filter)
|
||||
query = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.id as station_id, oqs.station_name, oqs.is_active, oqpz.zone_id, df.name as zone, df.type, odt.order_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
|
||||
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
|
||||
left join orders as od ON od.order_id = assigned_order_items.order_id
|
||||
@@ -115,12 +147,28 @@ class Oqs::HomeController < BaseOqsController
|
||||
left join bookings as bk on bk.booking_id = bo.booking_id
|
||||
left join dining_facilities as df on df.id = bk.dining_facility_id")
|
||||
.where("assigned_order_items.delivery_status = true AND odt.price <> 0 AND assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'")
|
||||
.group("assigned_order_items.order_id")
|
||||
.limit(20)
|
||||
.order("assigned_order_items.created_at")
|
||||
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
|
||||
.group("assigned_order_items.order_id")
|
||||
.limit(20)
|
||||
.order("assigned_order_items.created_at")
|
||||
|
||||
|
||||
# completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true');
|
||||
end
|
||||
|
||||
def queue_items_count_query(status,filter)
|
||||
query = AssignedOrderItem.select("count(odt.item_code) as total,oqs.id as station_id")
|
||||
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
|
||||
left join orders as od ON od.order_id = assigned_order_items.order_id
|
||||
left join order_items as odt ON odt.item_code = assigned_order_items.item_code AND odt.order_id = assigned_order_items.order_id
|
||||
left join customers as cus ON cus.customer_id = od.customer_id
|
||||
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
|
||||
left join bookings as bk on bk.booking_id = bo.booking_id
|
||||
left join dining_facilities as df on df.id = bk.dining_facility_id")
|
||||
.where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' ")
|
||||
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
|
||||
.group("oqs.id")
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
22
app/controllers/origami/addorders_controller.rb
Normal file
22
app/controllers/origami/addorders_controller.rb
Normal file
@@ -0,0 +1,22 @@
|
||||
class Origami::AddordersController < BaseOrigamiController
|
||||
before_action :set_dining, only: [:show]
|
||||
|
||||
def index
|
||||
@tables = Table.all.active.order('zone_id asc').group("zone_id")
|
||||
@rooms = Room.all.active.order('zone_id asc').group("zone_id")
|
||||
@all_table = Table.all.active.order('status desc')
|
||||
@all_room = Room.all.active.order('status desc')
|
||||
end
|
||||
|
||||
def show
|
||||
@menu = MenuCategory.all
|
||||
@table_id = params[:id]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_dining
|
||||
@dining = DiningFacility.find(params[:id])
|
||||
end
|
||||
|
||||
end
|
||||
@@ -37,14 +37,14 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
@crm_customers = Customer.order("customer_id").page(params[:page])
|
||||
#@products = Product.order("name").page(params[:page]).per(5)
|
||||
else
|
||||
@crm_customers = Customer.search(filter)
|
||||
|
||||
@crm_customers = Customer.search(filter)
|
||||
end
|
||||
#@crm_customers = Customer.all
|
||||
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
|
||||
@crm_customer = Customer.new
|
||||
@count_customer = Customer.count_customer
|
||||
|
||||
@taxes = TaxProfile.all.order("order_by asc")
|
||||
# if flash["errors"]
|
||||
# @crm_customer.valid?
|
||||
# end
|
||||
@@ -60,6 +60,7 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
|
||||
id = params[:sale_id][0,3]
|
||||
customer_id = params[:customer_id]
|
||||
customer = Customer.find(customer_id)
|
||||
|
||||
# Check and find with card no
|
||||
# if(!customer_id.include? "CUS")
|
||||
@@ -74,7 +75,7 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
status = sale.update_attributes(customer_id: customer_id)
|
||||
sale.sale_orders.each do |sale_order|
|
||||
order = Order.find(sale_order.order_id)
|
||||
status = order.update_attributes(customer_id: customer_id)
|
||||
status = order.update_attributes(customer_id: customer_id,order_type:customer.customer_type)
|
||||
end
|
||||
else
|
||||
@booking = BookingOrder.find_by_order_id(params[:sale_id])
|
||||
@@ -82,13 +83,15 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
|
||||
@orders.each do |bo|
|
||||
order = Order.find(bo.order_id)
|
||||
status = order.update_attributes(customer_id: customer_id)
|
||||
status = order.update_attributes(customer_id: customer_id,order_type:customer.customer_type)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if status == true
|
||||
render json: JSON.generate({:status => true})
|
||||
# Re-calc All Amount in Sale
|
||||
sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount)
|
||||
else
|
||||
render json: JSON.generate({:status => false, :error_message => "Record not found"})
|
||||
end
|
||||
|
||||
@@ -2,10 +2,12 @@ class Origami::HomeController < BaseOrigamiController
|
||||
before_action :set_dining, only: [:show]
|
||||
|
||||
def index
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@tables = Table.all.active.order('status desc')
|
||||
@rooms = Room.all.active.order('status desc')
|
||||
@complete = Sale.where("sale_status != 'new'")
|
||||
@orders = Order.all.order('date desc')
|
||||
@orders = Order.all.order('date desc')
|
||||
@shop = Shop.find_by_id(1)
|
||||
|
||||
# @shift = ShiftSale.current_open_shift(current_user.id)
|
||||
end
|
||||
|
||||
@@ -38,7 +40,6 @@ class Origami::HomeController < BaseOrigamiController
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
if sale.sale_status != "completed" && sale.sale_status != 'void'
|
||||
puts "enter"
|
||||
@sale_array.push(sale)
|
||||
if @status_order == 'order'
|
||||
@status_order = 'sale'
|
||||
|
||||
@@ -163,6 +163,35 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print")
|
||||
end
|
||||
|
||||
def foc
|
||||
cash = params[:cash]
|
||||
sale_id = params[:sale_id]
|
||||
sub_total = params[:sub_total]
|
||||
member_info = nil
|
||||
rebate_amount = nil
|
||||
|
||||
if(Sale.exists?(sale_id))
|
||||
saleObj = Sale.find(sale_id)
|
||||
sale_payment = SalePayment.new
|
||||
sale_payment.process_payment(saleObj, @user, cash, "foc")
|
||||
|
||||
unique_code = "ReceiptBillPdf"
|
||||
customer= Customer.find(saleObj.customer_id)
|
||||
|
||||
#shop detail
|
||||
shop_details = Shop.find(1)
|
||||
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
# Calculate Food and Beverage Total
|
||||
item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
|
||||
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC")
|
||||
end
|
||||
end
|
||||
|
||||
def rounding_adj
|
||||
|
||||
saleObj = Sale.find(params[:sale_id])
|
||||
|
||||
@@ -31,15 +31,21 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
unique_code = "CloseCashierPdf"
|
||||
shop_details = Shop.find(1)
|
||||
#get tax
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||
#other payment details for mpu or visa like card
|
||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
||||
|
||||
# Calculate price_by_accounts
|
||||
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
||||
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
|
||||
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
|
||||
# get printer info
|
||||
print_settings=PrintSetting.find_by_unique_code(unique_code)
|
||||
print_settings = PrintSetting.find_by_unique_code(unique_code)
|
||||
|
||||
printer = Printer::CashierStationPrinter.new(print_settings)
|
||||
|
||||
printer.print_close_cashier(print_settings,@shift,shop_details,@sale_taxes)
|
||||
printer.print_close_cashier(print_settings,@shift,shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount)
|
||||
|
||||
|
||||
end
|
||||
@@ -52,6 +58,21 @@ class Origami::ShiftsController < BaseOrigamiController
|
||||
|
||||
def sale_summary
|
||||
@shift = ShiftSale.current_open_shift(current_user.id)
|
||||
|
||||
# @shift = ShiftSale.find_by_id(shift_id)
|
||||
if @shift
|
||||
#get tax
|
||||
shift_obj = ShiftSale.where('id =?',@shift.id)
|
||||
@sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='')
|
||||
#other payment details for mpu or visa like card
|
||||
@other_payment = ShiftSale.get_by_shift_other_payment(@shift)
|
||||
|
||||
# Calculate price_by_accounts
|
||||
@total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount')
|
||||
@total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount')
|
||||
@total_member_discount = ShiftSale.get_total_member_discount(@shift)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -6,18 +6,19 @@ class Origami::VoidController < BaseOrigamiController
|
||||
|
||||
if Sale.exists?(sale_id)
|
||||
sale = Sale.find_by_sale_id(sale_id)
|
||||
sale.payment_status = 'void'
|
||||
sale.sale_status = 'void'
|
||||
sale.save
|
||||
|
||||
|
||||
# update count for shift sale
|
||||
if(sale.sale_status == "void")
|
||||
if(sale.sale_status == "completed")
|
||||
if sale.shift_sale_id != nil
|
||||
shift = ShiftSale.find(sale.shift_sale_id)
|
||||
shift.calculate(sale_id, "void")
|
||||
end
|
||||
end
|
||||
|
||||
sale.payment_status = 'void'
|
||||
sale.sale_status = 'void'
|
||||
sale.save
|
||||
|
||||
bookings = sale.bookings
|
||||
bookings.each do |booking|
|
||||
orders = booking.orders
|
||||
|
||||
@@ -22,7 +22,7 @@ class Origami::VoucherController < BaseOrigamiController
|
||||
def create
|
||||
cash = params[:amount]
|
||||
sale_id = params[:sale_id]
|
||||
sale_id = params[:refnumber]
|
||||
voucher_no = params[:refnumber]
|
||||
if(Sale.exists?(sale_id))
|
||||
customer_data= Customer.find_by_customer_id(sale_data.customer_id)
|
||||
if customer_data
|
||||
@@ -37,11 +37,12 @@ class Origami::VoucherController < BaseOrigamiController
|
||||
auth_token = member_actions.auth_token.to_s
|
||||
# membership_data = SalePayment.get_paypar_account(url,membership_setting.auth_token,@membership_id,@campaign_type_id,merchant_uid,auth_token)
|
||||
# if membership_data["status"]==true
|
||||
# app_token: token,membership_id:membership_id,
|
||||
# campaign_type_id:campaign_type_id,merchant_uid:merchant_uid,
|
||||
# auth_token:auth_token
|
||||
begin
|
||||
response = HTTParty.get(url,
|
||||
:body => { app_token: token,membership_id:membership_id,
|
||||
campaign_type_id:campaign_type_id,merchant_uid:merchant_uid,
|
||||
auth_token:auth_token
|
||||
:body => { voucher_no: voucher_no,membership_id:membership_id
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
|
||||
74
app/controllers/settings/item_sets_controller.rb
Normal file
74
app/controllers/settings/item_sets_controller.rb
Normal file
@@ -0,0 +1,74 @@
|
||||
class Settings::ItemSetsController < ApplicationController
|
||||
before_action :set_settings_item_set, only: [:show, :edit, :update, :destroy]
|
||||
load_and_authorize_resource except: [:create]
|
||||
# GET /settings/item_sets
|
||||
# GET /settings/item_sets.json
|
||||
def index
|
||||
@settings_item_sets = ItemSet.all
|
||||
end
|
||||
|
||||
# GET /settings/item_sets/1
|
||||
# GET /settings/item_sets/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /settings/item_sets/new
|
||||
def new
|
||||
@settings_item_set = ItemSet.new
|
||||
end
|
||||
|
||||
# GET /settings/item_sets/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /settings/item_sets
|
||||
# POST /settings/item_sets.json
|
||||
def create
|
||||
@settings_item_set = ItemSet.new(settings_item_set_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @settings_item_set.save
|
||||
format.html { redirect_to settings_item_sets_path, notice: 'Item set was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @settings_item_set }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @settings_item_set.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /settings/item_sets/1
|
||||
# PATCH/PUT /settings/item_sets/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @settings_item_set.update(settings_item_set_params)
|
||||
format.html { redirect_to settings_item_sets_path, notice: 'Item set was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @settings_item_set }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @settings_item_set.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /settings/item_sets/1
|
||||
# DELETE /settings/item_sets/1.json
|
||||
def destroy
|
||||
@settings_item_set.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_item_sets_url, notice: 'Item set was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_settings_item_set
|
||||
@settings_item_set = ItemSet.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def settings_item_set_params
|
||||
params.require(:item_set).permit(:name, :alt_name, :min_selectable_qty, :max_selectable_qty)
|
||||
end
|
||||
end
|
||||
@@ -89,6 +89,6 @@ class Settings::MenuCategoriesController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def settings_menu_category_params
|
||||
params.require(:menu_category).permit(:code, :menu_id, :name, :alt_name, :order_by, :menu_category_id)
|
||||
params.require(:menu_category).permit(:code, :menu_id, :name, :alt_name, :order_by, :menu_category_id, :is_available)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -21,12 +21,14 @@ class Settings::MenuItemInstancesController < ApplicationController
|
||||
id = MenuItemInstance.findParentCategory(@item)
|
||||
@category = MenuCategory.find(id)
|
||||
@settings_menu_item_instances = MenuItemInstance.new
|
||||
@item_sets = ItemSet.all
|
||||
end
|
||||
|
||||
# GET /settings/menu_item_instances/1/edit
|
||||
def edit
|
||||
id = MenuItemInstance.findParentCategory(@item)
|
||||
@category = MenuCategory.find(id)
|
||||
@item_sets = ItemSet.all
|
||||
end
|
||||
|
||||
# POST /settings/menu_item_instances
|
||||
@@ -45,6 +47,18 @@ class Settings::MenuItemInstancesController < ApplicationController
|
||||
|
||||
id = MenuItemInstance.findParentCategory(catID)
|
||||
category = MenuCategory.find(id)
|
||||
|
||||
# Bind for Item Sets
|
||||
if params[:menu_item_instance][:item_sets].count > 1
|
||||
params[:menu_item_instance][:item_sets].delete_at(0)
|
||||
|
||||
sets = ItemSet.find(params[:menu_item_instance][:item_sets])
|
||||
|
||||
if sets.count > 0
|
||||
@settings_menu_item.item_sets = sets
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
if @settings_menu_item_instances.save
|
||||
@settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].reject(&:blank?)
|
||||
@@ -70,6 +84,18 @@ class Settings::MenuItemInstancesController < ApplicationController
|
||||
|
||||
id = MenuItemInstance.findParentCategory(catID)
|
||||
category = MenuCategory.find(id)
|
||||
|
||||
# Bind for Item Sets
|
||||
if params[:menu_item_instance][:item_sets].count > 1
|
||||
params[:menu_item_instance][:item_sets].delete_at(0)
|
||||
|
||||
sets = ItemSet.find(params[:menu_item_instance][:item_sets])
|
||||
|
||||
if sets.count > 0
|
||||
@settings_menu_item.item_sets = sets
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
if @settings_menu_item_instances.update(settings_menu_item_instance_params)
|
||||
@@ -122,8 +148,6 @@ class Settings::MenuItemInstancesController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def settings_menu_item_instance_params
|
||||
|
||||
params.require(:menu_item_instance).permit(:item_instance_code, :item_instance_name, :price, :item_attributes, :is_on_promotion, :promotion_price, :is_available,:menu_category_id,:menu_item_id)
|
||||
|
||||
params.require(:menu_item_instance).permit(:item_instance_code, :item_instance_name, :price, :item_attributes, :is_on_promotion, :promotion_price, :is_available,:menu_category_id,:menu_item_id, :is_default, :item_sets)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -70,6 +70,6 @@ class Settings::MenuItemOptionsController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def settings_menu_item_option_params
|
||||
params.require(:menu_item_option).permit(:name, :value)
|
||||
params.require(:menu_item_option).permit(:option_type, :name, :value)
|
||||
end
|
||||
end
|
||||
|
||||
74
app/controllers/settings/menu_item_sets_controller.rb
Normal file
74
app/controllers/settings/menu_item_sets_controller.rb
Normal file
@@ -0,0 +1,74 @@
|
||||
class Settings::MenuItemSetsController < ApplicationController
|
||||
before_action :set_settings_menu_item_set, only: [:show, :edit, :update, :destroy]
|
||||
load_and_authorize_resource except: [:create]
|
||||
# GET /settings/menu_item_sets
|
||||
# GET /settings/menu_item_sets.json
|
||||
def index
|
||||
@settings_menu_item_sets = MenuItemSet.all
|
||||
end
|
||||
|
||||
# GET /settings/menu_item_sets/1
|
||||
# GET /settings/menu_item_sets/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /settings/menu_item_sets/new
|
||||
def new
|
||||
@settings_menu_item_set = MenuItemSet.new
|
||||
end
|
||||
|
||||
# GET /settings/menu_item_sets/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /settings/menu_item_sets
|
||||
# POST /settings/menu_item_sets.json
|
||||
def create
|
||||
@settings_menu_item_set = MenuItemSet.new(settings_menu_item_set_params)
|
||||
|
||||
respond_to do |format|
|
||||
if @settings_menu_item_set.save
|
||||
format.html { redirect_to settings_menu_item_sets_path, notice: 'Menu item set was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @settings_menu_item_set }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @settings_menu_item_set.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /settings/menu_item_sets/1
|
||||
# PATCH/PUT /settings/menu_item_sets/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @settings_menu_item_set.update(settings_menu_item_set_params)
|
||||
format.html { redirect_to settings_menu_item_sets_path, notice: 'Menu item set was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @settings_menu_item_set }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @settings_menu_item_set.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /settings/menu_item_sets/1
|
||||
# DELETE /settings/menu_item_sets/1.json
|
||||
def destroy
|
||||
@settings_menu_item_set.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_menu_item_sets_url, notice: 'Menu item set was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_settings_menu_item_set
|
||||
@settings_menu_item_set = MenuItemSet.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def settings_menu_item_set_params
|
||||
params.require(:menu_item_set).permit(:item_set_id, :menu_item_id)
|
||||
end
|
||||
end
|
||||
@@ -1,6 +1,8 @@
|
||||
class Settings::SetMenuItemsController < ApplicationController
|
||||
before_action :set_settings_menu_item, only: [:show, :edit, :update, :destroy]
|
||||
before_action :set_settings_menu_category, only: [:index, :show, :edit, :new, :update]
|
||||
before_action :set_settings_item_attribute, only: [:index, :show, :edit, :new, :update ,:create]
|
||||
before_action :set_settings_item_option, only: [:index, :show, :edit, :new, :update ,:create]
|
||||
# GET /settings/menu_items
|
||||
# GET /settings/menu_items.json
|
||||
def index
|
||||
@@ -10,32 +12,52 @@ class Settings::SetMenuItemsController < ApplicationController
|
||||
# GET /settings/menu_items/1
|
||||
# GET /settings/menu_items/1.json
|
||||
def show
|
||||
@sub_menu = MenuItem.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
|
||||
|
||||
# @sub_menu = MenuItem.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
|
||||
@menu_item_instance = MenuItemInstance.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
|
||||
|
||||
end
|
||||
|
||||
# GET /settings/menu_items/new
|
||||
def new
|
||||
@settings_menu_item = MenuItem.new
|
||||
@settings_menu_item.type = "SetMenuItem"
|
||||
@item_sets = ItemSet.all
|
||||
end
|
||||
|
||||
# GET /settings/menu_items/1/edit
|
||||
def edit
|
||||
@item_sets = ItemSet.all
|
||||
end
|
||||
|
||||
# POST /settings/menu_items
|
||||
# POST /settings/menu_items.json
|
||||
def create
|
||||
@settings_menu_item = MenuItem.new(settings_menu_item_params)
|
||||
if params[:simple_menu_item][:menu_item_id] == ''
|
||||
@settings_menu_item.menu_category_id = params[:menu_category_id]
|
||||
end
|
||||
|
||||
# if params[:set_menu_item][:menu_item_id] == ''
|
||||
@settings_menu_item.menu_category_id = params[:menu_category_id]
|
||||
# end
|
||||
@settings_menu_item.created_by = current_login_employee.name
|
||||
|
||||
# Remove "" default first
|
||||
params[:set_menu_item][:item_attributes].delete_at(0)
|
||||
params[:set_menu_item][:item_options].delete_at(0)
|
||||
|
||||
# Bind for Item Sets
|
||||
if params[:set_menu_item][:item_sets].count > 1
|
||||
params[:set_menu_item][:item_sets].delete_at(0)
|
||||
|
||||
sets = ItemSet.find(params[:set_menu_item][:item_sets])
|
||||
|
||||
if sets.count > 0
|
||||
@settings_menu_item.item_sets = sets
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
if @settings_menu_item.save
|
||||
menu_item = MenuItem.find(@settings_menu_item.id)
|
||||
menu_item.update_attributes(item_attributes: params[:set_menu_item][:item_attributes], item_options: params[:set_menu_item][:item_options])
|
||||
|
||||
format.html { redirect_to settings_menu_category_set_menu_items_path, notice: 'Menu item was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @settings_menu_item }
|
||||
else
|
||||
@@ -48,8 +70,27 @@ class Settings::SetMenuItemsController < ApplicationController
|
||||
# PATCH/PUT /settings/menu_items/1
|
||||
# PATCH/PUT /settings/menu_items/1.json
|
||||
def update
|
||||
# Remove "" default first
|
||||
params[:set_menu_item][:item_attributes].delete_at(0)
|
||||
params[:set_menu_item][:item_options].delete_at(0)
|
||||
|
||||
# Bind for Item Sets
|
||||
if params[:set_menu_item][:item_sets].count > 1
|
||||
params[:set_menu_item][:item_sets].delete_at(0)
|
||||
|
||||
sets = ItemSet.find(params[:set_menu_item][:item_sets])
|
||||
|
||||
if sets.count > 0
|
||||
@settings_menu_item.item_sets = sets
|
||||
end
|
||||
end
|
||||
|
||||
@settings_menu_item.menu_category_id = params[:menu_category_id]
|
||||
|
||||
respond_to do |format|
|
||||
if @settings_menu_item.update(settings_menu_item_params)
|
||||
@settings_menu_item.update_attributes(item_attributes: params[:set_menu_item][:item_attributes], item_options: params[:set_menu_item][:item_options])
|
||||
|
||||
format.html { redirect_to settings_menu_category_set_menu_items_path, notice: 'Menu item was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @settings_menu_item }
|
||||
else
|
||||
@@ -62,6 +103,8 @@ class Settings::SetMenuItemsController < ApplicationController
|
||||
# DELETE /settings/menu_items/1
|
||||
# DELETE /settings/menu_items/1.json
|
||||
def destroy
|
||||
path_to_file = @settings_menu_item.image_path.to_s
|
||||
File.delete(path_to_file) if File.exist?(path_to_file)
|
||||
abc = MenuItem.deleteRecursive(@settings_menu_item)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_menu_category_set_menu_items_path, notice: 'Menu item was successfully destroyed.' }
|
||||
@@ -79,8 +122,16 @@ class Settings::SetMenuItemsController < ApplicationController
|
||||
@category = MenuCategory.find(params[:menu_category_id])
|
||||
end
|
||||
|
||||
def set_settings_item_attribute
|
||||
@item_attributes = MenuItemAttribute.all.order("id asc").map{|a| [a.name, a.value]}
|
||||
end
|
||||
|
||||
def set_settings_item_option
|
||||
@item_options = MenuItemOption.all
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def settings_menu_item_params
|
||||
params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:account_id , :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
|
||||
params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id,:account_id , :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
class Settings::SimpleMenuItemsController < ApplicationController
|
||||
before_action :set_settings_menu_item, only: [:show, :edit, :update, :destroy ]
|
||||
before_action :set_settings_menu_category, only: [:index, :show, :edit, :new, :update ,:create]
|
||||
before_action :set_settings_item_attribute, only: [:index, :show, :edit, :new, :update ,:create]
|
||||
before_action :set_settings_item_option, only: [:index, :show, :edit, :new, :update ,:create]
|
||||
# GET /settings/menu_items
|
||||
# GET /settings/menu_items.json
|
||||
def index
|
||||
@@ -10,29 +12,75 @@ class Settings::SimpleMenuItemsController < ApplicationController
|
||||
# GET /settings/menu_items/1
|
||||
# GET /settings/menu_items/1.json
|
||||
def show
|
||||
@sub_menu = MenuItem.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
|
||||
# @sub_menu = MenuItem.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
|
||||
@menu_item_instance = MenuItemInstance.where("menu_item_id=?",params[:id]).page(params[:page]).per(10)
|
||||
end
|
||||
|
||||
# GET /settings/menu_items/new
|
||||
def new
|
||||
@settings_menu_item = MenuItem.new
|
||||
@settings_menu_item = MenuItem.new
|
||||
@item_sets = ItemSet.all
|
||||
end
|
||||
|
||||
# GET /settings/menu_items/1/edit
|
||||
def edit
|
||||
def edit
|
||||
@item_sets = ItemSet.all
|
||||
end
|
||||
|
||||
# POST /settings/menu_items
|
||||
# POST /settings/menu_items.json
|
||||
def create
|
||||
@settings_menu_item = MenuItem.new(settings_menu_item_params)
|
||||
if params[:simple_menu_item][:menu_item_id] == ''
|
||||
@settings_menu_item.menu_category_id = params[:menu_category_id]
|
||||
end
|
||||
|
||||
# if params[:simple_menu_item][:menu_item_id] == ''
|
||||
@settings_menu_item.menu_category_id = params[:menu_category_id]
|
||||
# end
|
||||
@settings_menu_item.created_by = current_login_employee.name
|
||||
|
||||
# Remove "" default first
|
||||
params[:simple_menu_item][:item_attributes].delete_at(0)
|
||||
params[:simple_menu_item][:item_options].delete_at(0)
|
||||
|
||||
# attr_format = []
|
||||
# param_count = params[:simple_menu_item][:item_attributes].count
|
||||
# # Format for attributes json
|
||||
# params[:simple_menu_item][:item_attributes].each do|attr_id|
|
||||
# menu_attr = MenuItemAttribute.find(attr_id)
|
||||
# if attr_format.count == 0
|
||||
# attr_format.push({ type: menu_attr.attribute_type, value: [] })
|
||||
# end
|
||||
|
||||
# attr_format.each do |af|
|
||||
# if menu_attr.attribute_type == af[:type]
|
||||
# af[:value].push(menu_attr.value)
|
||||
# else
|
||||
# new_attr = {type: menu_attr.attribute_type, value: [ menu_attr.value ] }
|
||||
# attr_format.push(new_attr)
|
||||
# end
|
||||
|
||||
# break if attr_format.count > param_count
|
||||
# end
|
||||
|
||||
# param_count -= 1
|
||||
# end
|
||||
# @settings_menu_item.item_attributes = attr_format
|
||||
|
||||
# Bind for Item Sets
|
||||
if params[:simple_menu_item][:item_sets].count > 1
|
||||
params[:simple_menu_item][:item_sets].delete_at(0)
|
||||
|
||||
sets = ItemSet.find(params[:simple_menu_item][:item_sets])
|
||||
|
||||
if sets.count > 0
|
||||
@settings_menu_item.item_sets = sets
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
if @settings_menu_item.save
|
||||
menu_item = MenuItem.find(@settings_menu_item.id)
|
||||
menu_item.update_attributes(item_options: params[:simple_menu_item][:item_options])
|
||||
|
||||
format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @settings_menu_item }
|
||||
else
|
||||
@@ -45,8 +93,26 @@ class Settings::SimpleMenuItemsController < ApplicationController
|
||||
# PATCH/PUT /settings/menu_items/1
|
||||
# PATCH/PUT /settings/menu_items/1.json
|
||||
def update
|
||||
# Remove "" default first
|
||||
params[:simple_menu_item][:item_attributes].delete_at(0)
|
||||
params[:simple_menu_item][:item_options].delete_at(0)
|
||||
|
||||
# Bind for Item Sets
|
||||
if params[:simple_menu_item][:item_sets].count > 1
|
||||
params[:simple_menu_item][:item_sets].delete_at(0)
|
||||
|
||||
sets = ItemSet.find(params[:simple_menu_item][:item_sets])
|
||||
|
||||
if sets.count > 0
|
||||
@settings_menu_item.item_sets = sets
|
||||
end
|
||||
end
|
||||
|
||||
@settings_menu_item.menu_category_id = params[:menu_category_id]
|
||||
|
||||
respond_to do |format|
|
||||
if @settings_menu_item.update(settings_menu_item_params)
|
||||
@settings_menu_item.update_attributes(item_attributes: params[:simple_menu_item][:item_attributes], item_options: params[:simple_menu_item][:item_options])
|
||||
format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @settings_menu_item }
|
||||
else
|
||||
@@ -59,6 +125,8 @@ class Settings::SimpleMenuItemsController < ApplicationController
|
||||
# DELETE /settings/menu_items/1
|
||||
# DELETE /settings/menu_items/1.json
|
||||
def destroy
|
||||
path_to_file = @settings_menu_item.image_path.to_s
|
||||
File.delete(path_to_file) if File.exist?(path_to_file)
|
||||
abc = MenuItem.deleteRecursive(@settings_menu_item)
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully destroyed.' }
|
||||
@@ -76,8 +144,16 @@ class Settings::SimpleMenuItemsController < ApplicationController
|
||||
@category = MenuCategory.find(params[:menu_category_id])
|
||||
end
|
||||
|
||||
def set_settings_item_attribute
|
||||
@item_attributes = MenuItemAttribute.all.order("id asc") #.map{|a| [a.name, a.value]}
|
||||
end
|
||||
|
||||
def set_settings_item_option
|
||||
@item_options = MenuItemOption.all
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def settings_menu_item_params
|
||||
params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:account_id,:item_attributes, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by)
|
||||
params.require(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :image_path, :menu_category_id, :account_id, :item_attributes, :item_options, :min_qty, :is_sub_item, :is_available, :created_by, :item_sets)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3,18 +3,17 @@ class Transactions::OrdersController < ApplicationController
|
||||
def index
|
||||
|
||||
filter = params[:filter]
|
||||
count = params[:count]
|
||||
from = params[:from]
|
||||
to = params[:to]
|
||||
|
||||
if filter.nil? || from.nil? || to.nil?
|
||||
if filter.nil? && from.nil? && to.nil? && count.nil?
|
||||
orders = Order.order("order_id desc")
|
||||
puts "ssssss"
|
||||
else
|
||||
orders = Order.search(filter,from,to)
|
||||
# if order.count > 0
|
||||
# orders = order
|
||||
# else
|
||||
# orders = Order.order("order_id desc")
|
||||
# end
|
||||
orders = Order.search(filter,from,to,count)
|
||||
puts "aaaaa"
|
||||
|
||||
end
|
||||
|
||||
if !orders.nil?
|
||||
@@ -22,6 +21,7 @@ class Transactions::OrdersController < ApplicationController
|
||||
else
|
||||
@orders = []
|
||||
end
|
||||
puts @orders.to_json
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @orders }
|
||||
|
||||
Reference in New Issue
Block a user