shop code

This commit is contained in:
Myat Zin Wai Maw
2019-11-22 18:24:02 +06:30
parent 5a3f328789
commit d1ab2c194d
106 changed files with 834 additions and 895 deletions

View File

@@ -2,9 +2,9 @@ class Origami::SurveysController < BaseOrigamiController
def new
@webview = false
if check_mobile
@webview = true
@webview = true
end
@survey = Survey.new
@id = params[:id]
@cashier_type = params[:type]
@@ -18,8 +18,8 @@ class Origami::SurveysController < BaseOrigamiController
if @booking.dining_facility_id.to_i>0
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
@table_type = @dining_facility.type
@survey_data = Survey.find_by_dining_name(@dining_facility.name)
survey_process = Survey.find_by_receipt_no(@receipt_no)
@survey_data = Survey.find_by_dining_name_and_shop_code(@dining_facility.name,@shop.shop_code)
survey_process = Survey.find_by_receipt_no_and_shop_code(@receipt_no,@shop.shop_code)
if !survey_process.nil?
@survey_data = survey_process
end
@@ -27,14 +27,14 @@ class Origami::SurveysController < BaseOrigamiController
@dining_facility = nil
@table_type = nil
end
else
@dining_facility = DiningFacility.find(@id)
@table_type = @dining_facility.type
@receipt_no = nil
@grand_total = nil
@survey_data = Survey.find_by_dining_name_and_receipt_no(@dining_facility.name,nil)
end
@survey_data = Survey.find_by_dining_name_and_receipt_no_and_shop_code(@dining_facility.name,nil,@shop.shop_code)
end
end
def create
@@ -43,38 +43,40 @@ class Origami::SurveysController < BaseOrigamiController
if params[:table_id].to_i>0
@dining_facility = DiningFacility.find(params[:table_id])
if params[:sale_id].to_i > 0
# cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_id)
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
# set cashier
open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
current_shift = ShiftSale.current_shift
if open_cashier.count>0
shift_by_terminal = ShiftSale.current_open_shift(open_cashier[0].id)
else
shift_by_terminal = ShiftSale.current_open_shift(current_shift.employee_id)
end
else
sale = Sale.find(@sale_id)
shift = ShiftSale.find(sale.shift_sale_id)
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(shift.cashier_terminal_id,nil)
end
# cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_id)
# shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
# set cashier
open_cashier = Employee.where("role = 'cashier' AND token_session <> '' and shop_code='#{@shop.shop_code}'")
current_shift = ShiftSale.current_shift(@shop.shop_code)
current_shift_user =Employee.find_by_id(current_user.employee_id)
if open_cashier.count>0
shift_by_terminal = ShiftSale.current_open_shift(open_cashier[0])
else
shift_by_terminal = ShiftSale.current_open_shift(current_shift_user)
end
else
sale = Sale.find(@sale_id)
shift = ShiftSale.find(sale.shift_sale_id)
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(shift.cashier_terminal_id,nil)
end
else
sale = Sale.find(@sale_id)
shift = ShiftSale.find(sale.shift_sale_id)
shift = ShiftSale.find(sale.shift_sale_id)
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(shift.cashier_terminal_id,nil)
end
if @type == "quick_service" || @type == "food_court"
@url = "/origami/sale/"+@sale_id+"/"+@type+"/payment"
else
@url = "/origami/"+@dining_facility.type.downcase+"/"+params[:table_id]
end
if params[:survey_id].nil? || params[:survey_id] == ""
@survey = Survey.new(survey_params)
@survey.shift_id = shift_by_terminal.id
@survey.foreigner = params["survey"]["foreigner"].to_json
@survey.shop_code = @shop.shop_code
# respond_to do |format|
if @survey.save
redirect_to @url
@@ -106,5 +108,5 @@ class Origami::SurveysController < BaseOrigamiController
def survey_params
params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner, :dining_name,:receipt_no,:shift_id,:created_by,:total_customer,:total_amount,:survey_id)
end
end