changed in server master

This commit is contained in:
superuser
2017-06-22 11:38:42 +06:30
82 changed files with 2217 additions and 513 deletions

View File

@@ -15,14 +15,29 @@ class Api::BillController < Api::ApiController
@status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee)
else
@status = true
@sale_id = booking.sale_id
end
end
elsif (params[:order_id])
@sale = Sale.new
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee)
end
@sale_data = Sale.find_by_sale_id(@sale_id)
@sale_items = SaleItem.where("sale_id=?",@sale_id)
unique_code = "ReceiptBillPdf"
customer= Customer.where('customer_id=' + @sale_data.customer_id)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
food_total, beverage_total = SaleItem.calculate_food_beverage(@sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total)
end

View File

@@ -23,55 +23,117 @@ class BaseReportController < ActionController::Base
period = params[:period]
from = params[:from]
to = params[:to]
day_ref = Time.now
if period_type.to_i == 1
if params[:from] && params[:to]
if params[:from] != "" && params[:to] !=""
from = DateTime.strptime(params[:from], "%m/%d/%Y")
to = DateTime.strptime(params[:to], "%m/%d/%Y")
else
day_ref = Time.now.utc.getlocal
if params[:report_type] == "daily_sale"
if from != "" && to != ""
f_date = DateTime.parse(params[:from])
t_date = DateTime.parse(params[:to])
f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
from = f_time.beginning_of_day.utc.getlocal
to = t_time.end_of_day.utc.getlocal
else
case period.to_i
when PERIOD["today"]
from = day_ref.beginning_of_day.utc
to = day_ref.end_of_day.utc
end
end
else
case period.to_i
when PERIOD["today"]
from = day_ref.beginning_of_day.utc
to = day_ref.end_of_day.utc
when PERIOD["yesterday"]
from = (day_ref - 1.day).beginning_of_day.utc
to = (day_ref - 1.day).end_of_day.utc
when PERIOD["yesterday"]
from = (day_ref - 1.day).beginning_of_day.utc
to = (day_ref - 1.day).end_of_day.utc
when PERIOD["this_week"]
from = Time.now.beginning_of_week.utc
to = Time.now.utc
when PERIOD["last_week"]
from = (day_ref - 7.day).beginning_of_week.utc
to = (day_ref - 7.day).end_of_week.utc
when PERIOD["last_7"]
from = (day_ref - 7.day).utc
to = Time.now.utc
when PERIOD["this_month"]
from = Time.now.beginning_of_month.utc
to = Time.now.utc
when PERIOD["last_month"]
from = (day_ref - 1.month).beginning_of_month.utc
to = (day_ref - 1.month).end_of_month.utc
when PERIOD["last_30"]
from = (day_ref - 30.day).utc
to = Time.now.utc
when PERIOD["this_year"]
from = Time.now.beginning_of_year.utc
to = Time.now.utc
when PERIOD["last_year"]
from = (day_ref - 1.year).beginning_of_year.utc
to = (day_ref - 1.year).end_of_year.utc
end
end
else # end daily sale report
if period_type.to_i == 1
if params[:from] && params[:to]
when PERIOD["this_week"]
from = Time.now.beginning_of_week.utc
to = Time.now.utc
when PERIOD["last_week"]
from = (day_ref - 7.day).beginning_of_week.utc
to = (day_ref - 7.day).end_of_week.utc
when PERIOD["last_7"]
from = (day_ref - 7.day).utc
to = Time.now.utc
when PERIOD["this_month"]
from = Time.now.beginning_of_month.utc
to = Time.now.utc
when PERIOD["last_month"]
from = (day_ref - 1.month).beginning_of_month.utc
to = (day_ref - 1.month).end_of_month.utc
when PERIOD["last_30"]
from = (day_ref - 30.day).utc
to = Time.now.utc
when PERIOD["this_year"]
from = Time.now.beginning_of_year.utc
to = Time.now.utc
when PERIOD["last_year"]
from = (day_ref - 1.year).beginning_of_year.utc
to = (day_ref - 1.year).end_of_year.utc
end
if params[:from] != "" && params[:to] !=""
f_date = DateTime.parse(params[:from])
t_date = DateTime.parse(params[:to])
f_time = Time.mktime(f_date.year,f_date.month,f_date.day,f_date.hour,f_date.min,f_date.sec)
t_time = Time.mktime(t_date.year,t_date.month,t_date.day,t_date.hour,t_date.min,t_date.sec)
from = f_time.beginning_of_day.utc.getlocal
to = t_time.end_of_day.utc.getlocal
else
from = day_ref.beginning_of_day.utc
to = day_ref.end_of_day.utc
end
end
else
case period.to_i
when PERIOD["today"]
from = day_ref.beginning_of_day.utc
to = day_ref.end_of_day.utc
when PERIOD["yesterday"]
from = (day_ref - 1.day).beginning_of_day.utc
to = (day_ref - 1.day).end_of_day.utc
when PERIOD["this_week"]
from = Time.now.beginning_of_week.utc
to = Time.now.utc
when PERIOD["last_week"]
from = (day_ref - 7.day).beginning_of_week.utc
to = (day_ref - 7.day).end_of_week.utc
when PERIOD["last_7"]
from = (day_ref - 7.day).utc
to = Time.now.utc
when PERIOD["this_month"]
from = Time.now.beginning_of_month.utc
to = Time.now.utc
when PERIOD["last_month"]
from = (day_ref - 1.month).beginning_of_month.utc
to = (day_ref - 1.month).end_of_month.utc
when PERIOD["last_30"]
from = (day_ref - 30.day).utc
to = Time.now.utc
when PERIOD["this_year"]
from = Time.now.beginning_of_year.utc
to = Time.now.utc
when PERIOD["last_year"]
from = (day_ref - 1.year).beginning_of_year.utc
to = (day_ref - 1.year).end_of_year.utc
end
end
end
return from, to
end
end

View File

@@ -117,7 +117,7 @@ class Crm::CustomersController < BaseCrmController
# format.json { render :index, status: :created, location: @crm_customers }
else
@crm_customers.destroy
# @crm_customers.destroy
if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'}
else

View File

@@ -4,7 +4,8 @@ class Crm::DiningQueuesController < BaseCrmController
# GET /crm/dining_queues
# GET /crm/dining_queues.json
def index
@dining_queues = DiningQueue.all
today = DateTime.now.strftime('%Y-%m-%d')
@dining_queues = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? ", today).order("queue_no asc")
end
# GET /crm/dining_queues/1
@@ -38,7 +39,7 @@ class Crm::DiningQueuesController < BaseCrmController
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_queue_no(print_settings,@dining_queue)
format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully created.' }
format.html { redirect_to crm_dining_queues_path, notice: 'Queue was successfully created.' }
format.json { render :show, status: :created, location: @dining_queue }
else
format.html { render :new }
@@ -52,7 +53,7 @@ class Crm::DiningQueuesController < BaseCrmController
def update
respond_to do |format|
if @dining_queue.update(dining_queue_params)
format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully updated.' }
format.html { redirect_to crm_dining_queues_path, notice: 'Queue was successfully updated.' }
format.json { render :show, status: :ok, location: @dining_queue }
else
format.html { render :edit }
@@ -71,6 +72,27 @@ class Crm::DiningQueuesController < BaseCrmController
end
end
def assign
@queue = DiningQueue.find(params[:id])
@tables = DiningFacility.where("status = 'available' ")
respond_to do |format|
format.html # index.html.erb
end
end
def assign_table
queue = DiningQueue.find(params[:id])
table_id = params[:table_id]
queue.update_attributes(dining_facility_id: table_id,status:"Assign")
DiningFacility.find(table_id).update_attributes(status: "occupied")
respond_to do |format|
format.html { redirect_to crm_dining_queues_path, notice: 'Table was successfully assigned.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_dining_queue
@@ -79,6 +101,6 @@ class Crm::DiningQueuesController < BaseCrmController
# Never trust parameters from the scary internet, only allow the white list through.
def dining_queue_params
params.require(:dining_queue).permit(:name, :contact_no, :queue_no)
params.require(:dining_queue).permit(:name, :contact_no, :queue_no,:status)
end
end

View File

@@ -1,27 +1,65 @@
class Oqs::HomeController < BaseOqsController
def index
queue_stations=OrderQueueStation.all
@queue_items_details = queue_items_query(0)
@queue_completed_item = queue_items_query(1)
@queue_items_details = queue_items_query(false)
@queue_completed_item = queue_items_query(true)
@queue_stations_items=Array.new
# Calculate Count for each station tab
queue_stations.each do |que|
queue_stations.each do |que|
i=0
@queue_items_details.each do |qid|
if qid.station_name == que.station_name
i=i+1
end
end
@queue_stations_items.push({:station_name => que.station_name, :is_active => que.is_active ,:item_count => i })
@queue_items_details.each do |qid|
if qid.station_name == que.station_name
i=i+1
end
end
@queue_stations_items.push({:station_name => que.station_name, :is_active => que.is_active ,:item_count => i })
end
@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
@@ -35,24 +73,33 @@ class Oqs::HomeController < BaseOqsController
# update delivery status for completed same order items
assigned_items.each do |ai|
ai.delivery_status=true
ai.save
ai.save
removed_item.push(ai.assigned_order_item_id)
end
render :json => removed_item.to_json
end
render :json => removed_item.to_json
end
# Query for OQS with status
def queue_items_query(status)
# AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at")
# .joins(" left join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id
# left join dining_facilities as df on df.zone_id = oqpz.zone_id
# 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
# left join customers as cus ON cus.customer_id = od.customer_id")
# .where("assigned_order_items.delivery_status = #{status}")
# .group("assigned_order_items.assigned_order_item_id")
# .order("odt.item_name DESC")
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at")
.joins(" left join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id
left join dining_facilities as df on df.zone_id = oqpz.zone_id
left join order_queue_stations as oqs ON oqs.id = assigned_order_items.order_queue_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
left join customers as cus ON cus.customer_id = od.customer_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}")
.group("assigned_order_items.assigned_order_item_id")
.order("odt.item_name DESC")
end
end

View File

@@ -9,10 +9,13 @@ class Oqs::PrintController < ApplicationController
# order queue stations
oqs = assigned_item.order_queue_station
# Check Printed
print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
# print when complete click
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(oqs,assigned_item.order_id, assigned_item.item_code )
order_queue_printer.print_order_item(oqs, assigned_item.order_id, assigned_item.item_code, print_status )
# update print status for completed same order items
assigned_items.each do |ai|
@@ -21,20 +24,28 @@ class Oqs::PrintController < ApplicationController
end
end
# Print Order Details
# Print Order Details with booking id
def print_order_summary
unique_code="OrderSummaryPdf"
assigned_item_id=params[:id]
table_name=params[:table_name]
assigned_item=AssignedOrderItem.find(assigned_item_id)
assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
# order queue stations
oqs = assigned_item.order_queue_station
# Check Printed
print_status = assigned_item.print_status == true ? " (Re-Print)" : ""
# get dining
dining = DiningFacility.find_by_name(table_name);
booking = Booking.find_by_dining_facility_id(dining.id)
# print when complete click
print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_summary(oqs,assigned_item.order_id)
order_queue_printer.print_booking_summary(oqs, booking.booking_id, print_status)
# update print status for completed same order items
assigned_items.each do |ai|

View File

@@ -1,8 +1,8 @@
class Origami::HomeController < BaseOrigamiController
def index
if params[:booking_id] != nil
type=params[:booking_id].split('-')[0];
# Sale
type=params[:booking_id].split('-')[0];
# Sale
if type == "SAL"
@selected_item = Sale.find(params[:booking_id])
@selected_item_type="Sale"
@@ -10,23 +10,23 @@ class Origami::HomeController < BaseOrigamiController
else
@selected_item = Order.find(params[:booking_id])
@selected_item_type="Order"
end
end
end
end
@completed_orders = Order.get_completed_order()
@booking_orders = Order.get_booking_order_table()
@booking_rooms = Order.get_booking_order_rooms()
@booking_rooms = Order.get_booking_order_rooms()
@orders = Order.get_orders()
end
end
def item_show
selection(params[:booking_id],1)
end
end
def selection(selected_id, is_ajax)
str = []
type=selected_id.split('-')[0];
# Sale
type=selected_id.split('-')[0];
# Sale
if type == "SAL"
@order_details = SaleItem.get_order_items_details(params[:booking_id])
@order_details.each do |ord_detail|
@@ -39,6 +39,7 @@ class Origami::HomeController < BaseOrigamiController
str.push(ord_detail)
end
end
if is_ajax == 1
render :json => str.to_json
else
@@ -54,21 +55,21 @@ class Origami::HomeController < BaseOrigamiController
else
sale = Order.find(params[:sale_id])
end
status = sale.update_attributes(customer_id: params[:customer_id])
if status == true
render json: JSON.generate({:status => true})
else
render json: JSON.generate({:status => false, :error_message => "Record not found"})
end
end
end
def get_customer
@customer = Customer.find(params[:customer_id])
response = Customer.get_member_account(@customer)
respond_to do |format|

View File

@@ -12,7 +12,7 @@ class Origami::PaymentsController < BaseOrigamiController
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, @user, cash, "cash")
unique_code = "ReceiptBillPdf"
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
# get member information
@@ -20,11 +20,10 @@ class Origami::PaymentsController < BaseOrigamiController
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info)
end
end
@@ -41,14 +40,14 @@ class Origami::PaymentsController < BaseOrigamiController
@sale_data = Sale.find_by_sale_id(sale_id)
#get customer amount
@customer = Customer.find(@sale_data.customer_id)
@customer = Customer.find(@sale_data.customer_id)
# get member information
response = Customer.get_member_account(@customer)
@balance = 0.00
@accountable_type = ''
if response["data"]==true
if response["status"]==true
response["data"].each do |res|
if res["accountable_type"] == "RebateAccount"
@balance = res["balance"]
@@ -84,19 +83,19 @@ class Origami::PaymentsController < BaseOrigamiController
saleObj = Sale.find(sale_id)
unique_code = "ReceiptBillPdf"
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
# get member information
member_info = Customer.get_member_account(customer)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info)
end

View File

@@ -6,7 +6,8 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
sale_data = Sale.find_by_sale_id(@sale_id)
# limit redeem_amount
food_prices, beverage_prices = SaleItem.calculate_food_beverage(sale_data.sale_items)
rebate_prices = SaleItem.calculate_food_beverage(sale_data.sale_items)
nonrebate_prices = sale_data.total_amount - rebate_prices
@payparcount = 0
others = 0
sale_data.sale_payments.each do |sale_payment|
@@ -16,11 +17,11 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
others = others + sale_payment.payment_amount
end
end
is_bervage_exceed = others - (beverage_prices + sale_data.total_tax)
if is_bervage_exceed < 0
@food_prices = food_prices - @payparcount
non_rebate_exceed = others - (nonrebate_prices + sale_data.total_tax)
if non_rebate_exceed < 0
@redeem_prices = rebate_prices - @payparcount
else
@food_prices = food_prices - @payparcount -is_bervage_exceed
@redeem_prices = rebate_prices - @payparcount -non_rebate_exceed
end
if sale_data

View File

@@ -1,9 +1,25 @@
class Reports::DailySaleController < BaseReportController
def index
from, to = get_date_range_from_params
@sale_data = Sale.get_receipt_no_list(from,to)
@sale_data = Kaminari.paginate_array(@sale_data).page(params[:page]).per(50)
from, to = get_date_range_from_params
@sale_data = Sale.daily_sales_list(from,to)
@tax = SaleTax.get_tax(from,to)
end
# @locations = Location.all
# branch,from, to, report_type = get_date_range_from_params
# @location = Location.find_by_id(current_location)
# @sale_data = Sale.daily_sales_report(current_location,from,to)
# @tax = SaleT.get_tax(current_location,from,to)
# if @sale_data.blank? && @tax.blank? && request.post?
# flash.now[:notice] = "No data available for selected filters"
# end
def show
end
end

View File

@@ -68,6 +68,6 @@ class Settings::AccountsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def account_params
params.require(:account).permit(:title, :account_type)
params.require(:account).permit(:title, :account_type,:discount,:point,:bonus,:rebate)
end
end

View File

@@ -41,7 +41,7 @@ class Settings::OrderQueueStationsController < ApplicationController
# PATCH/PUT /settings/order_queue_stations/1
# PATCH/PUT /settings/order_queue_stations/1.json
def update
params[:order_queue_station][:processing_items] = params[:order_queue_station][:processing_items].split(/,/).inspect
# params[:order_queue_station][:processing_items] = params[:order_queue_station][:processing_items].split(/,/).inspect
respond_to do |format|
if @settings_order_queue_station.update(settings_order_queue_station_params)
format.html { redirect_to settings_order_queue_station_path(@settings_order_queue_station), notice: 'Order queue station was successfully updated.' }
@@ -71,6 +71,11 @@ class Settings::OrderQueueStationsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_order_queue_station_params
# <<<<<<< HEAD
params.require(:order_queue_station).permit(:station_name, :is_active, :auto_print, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by)
# =======
# Don't Know { zone_ids: [] }
# params.require(:order_queue_station).permit(:station_name, :is_active, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by,{ zone_ids: [] })
# >>>>>>> b093a993ba002c92659bbb34338c55c031c11d87
end
end

View File

@@ -0,0 +1,83 @@
class Settings::RoomsController < ApplicationController
before_action :set_settings_room, only: [:show, :edit, :update, :destroy]
before_action :set_settings_zone, only: [:index, :show, :edit, :new, :update,:create,:destroy]
# GET /settings/rooms
# GET /settings/rooms.json
def index
@settings_rooms = @zone.rooms
end
# GET /settings/rooms/1
# GET /settings/rooms/1.json
def show
@room = Room.find(params[:id])
end
# GET /settings/rooms/new
def new
@settings_room = Room.new
end
# GET /settings/rooms/1/edit
def edit
end
# POST /settings/rooms
# POST /settings/rooms.json
def create
@settings_room = Room.new(settings_room_params)
@settings_room.type = DiningFacility::ROOM_TYPE
@settings_room.zone_id = params[:zone_id]
@settings_room.created_by = current_login_employee.name
respond_to do |format|
if @settings_room.save
format.html { redirect_to settings_zone_path(@zone), notice: 'Room was successfully created.' }
format.json { render :show, status: :created, location: @settings_room }
else
puts "abc"
format.html { render :new }
format.json { render json: @settings_room.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /settings/rooms/1
# PATCH/PUT /settings/rooms/1.json
def update
@settings_room.created_by = current_login_employee.name
respond_to do |format|
if @settings_room.update(settings_room_params)
format.html { redirect_to settings_zone_path(@zone), notice: 'Room was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_room }
else
format.html { render :edit }
format.json { render json: @settings_room.errors, status: :unprocessable_entity }
end
end
end
# DELETE /settings/rooms/1
# DELETE /settings/rooms/1.json
def destroy
@settings_room.destroy
respond_to do |format|
format.html { redirect_to settings_zone_path(@zone), notice: 'Room was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_settings_room
@settings_room = Room.find(params[:id])
end
def set_settings_zone
@zone = Zone.find(params[:zone_id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def settings_room_params
params.require(:room).permit(:name, :status, :seater, :order_by,:is_active ,:id, :zone_id, :created_by)
end
end

View File

@@ -0,0 +1,82 @@
class Settings::TablesController < ApplicationController
before_action :set_settings_table, only: [:show, :edit, :update, :destroy]
before_action :set_settings_zone, only: [:index, :show, :edit, :new, :update,:create]
# GET /settings/tables
# GET /settings/tables.json
def index
@settings_tables = @zone.tables
end
# GET /settings/tables/1
# GET /settings/tables/1.json
def show
@table = Table.find(params[:id])
end
# GET /settings/tables/new
def new
@settings_table = Table.new
end
# GET /settings/tables/1/edit
def edit
end
# POST /settings/tables
# POST /settings/tables.json
def create
@settings_table = Table.new(settings_table_params)
@settings_table.type = DiningFacility::TABLE_TYPE
@settings_table.zone_id = params[:zone_id]
@settings_table.created_by = current_login_employee.name
respond_to do |format|
if @settings_table.save
format.html { redirect_to settings_zone_path(@zone), notice: 'Table was successfully created.' }
format.json { render :show, status: :created, location: @settings_table }
else
format.html { render :new }
format.json { render json: @settings_table.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /settings/tables/1
# PATCH/PUT /settings/tables/1.json
def update
@settings_table.created_by = current_login_employee.name
respond_to do |format|
if @settings_table.update(settings_table_params)
format.html { redirect_to settings_zone_path(@zone), notice: 'Table was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_table }
else
format.html { render :edit }
format.json { render json: @settings_table.errors, status: :unprocessable_entity }
end
end
end
# DELETE /settings/tables/1
# DELETE /settings/tables/1.json
def destroy
@settings_table.destroy
respond_to do |format|
format.html { redirect_to settings_zone_path(@zone), notice: 'Table was successfully destroyed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_settings_table
@settings_table = Table.find(params[:id])
end
def set_settings_zone
@zone = Zone.find(params[:zone_id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def settings_table_params
params.require(:table).permit(:name, :status, :seater, :order_by,:is_active ,:id, :zone_id, :created_by)
end
end

View File

@@ -10,6 +10,8 @@ class Settings::ZonesController < ApplicationController
# GET /settings/zones/1
# GET /settings/zones/1.json
def show
@settings_tables = @settings_zone.tables
@settings_rooms = @settings_zone.rooms
end
# GET /settings/zones/new
@@ -25,10 +27,10 @@ class Settings::ZonesController < ApplicationController
# POST /settings/zones.json
def create
@settings_zone = Zone.new(settings_zone_params)
@settings_zone.created_by = current_login_employee.name
respond_to do |format|
if @settings_zone.save
format.html { redirect_to @settings_zone, notice: 'Zone was successfully created.' }
format.html { redirect_to settings_zone_path(@settings_zone), notice: 'Zone was successfully created.' }
format.json { render :show, status: :created, location: @settings_zone }
else
format.html { render :new }
@@ -41,8 +43,9 @@ class Settings::ZonesController < ApplicationController
# PATCH/PUT /settings/zones/1.json
def update
respond_to do |format|
@settings_zone.created_by = current_login_employee.name
if @settings_zone.update(settings_zone_params)
format.html { redirect_to @settings_zone, notice: 'Zone was successfully updated.' }
format.html { redirect_to settings_zone_path(@settings_zone), notice: 'Zone was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_zone }
else
format.html { render :edit }
@@ -54,9 +57,11 @@ class Settings::ZonesController < ApplicationController
# DELETE /settings/zones/1
# DELETE /settings/zones/1.json
def destroy
@settings_zone.rooms.destroy
@settings_zone.tables.destroy
@settings_zone.destroy
respond_to do |format|
format.html { redirect_to settings_zones_url, notice: 'Zone was successfully destroyed.' }
format.html { redirect_to settings_zones_path, notice: 'Zone was successfully destroyed.' }
format.json { head :no_content }
end
end
@@ -69,6 +74,6 @@ class Settings::ZonesController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def settings_zone_params
params.require(:settings_zone).permit(:name, :is_active, :created_by)
params.require(:zone).permit(:name, :is_active, :created_by)
end
end