61 lines
1.7 KiB
Ruby
61 lines
1.7 KiB
Ruby
class Origami::SurveysController < BaseOrigamiController
|
|
def new
|
|
@survey = Survey.new
|
|
@id = params[:id]
|
|
@cashier_type = params[:type]
|
|
|
|
if(@id[0,3] == "SAL")
|
|
@sale = Sale.find(@id)
|
|
@receipt_no = @sale.receipt_no
|
|
@grand_total = @sale.grand_total
|
|
@booking = Booking.find_by_sale_id(@id)
|
|
if @booking.dining_facility_id.to_i>0
|
|
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
|
@table_type = @dining_facility.type
|
|
else
|
|
@dining_facility = nil
|
|
@table_type = nil
|
|
end
|
|
|
|
else
|
|
@dining_facility = DiningFacility.find(@id)
|
|
@table_type = @dining_facility.type
|
|
@receipt_no = nil
|
|
@grand_total = nil
|
|
end
|
|
end
|
|
|
|
def create
|
|
if params[:table_id].to_i>0
|
|
@dining_facility = DiningFacility.find(params[:table_id])
|
|
end
|
|
@type = params[:cashier_type]
|
|
@sale_id = params[:sale_id]
|
|
if @type == "quick_service"
|
|
@url = "/origami/sale/"+@sale_id+"/"+@type+"/payment"
|
|
else
|
|
@url = "/origami/"+@dining_facility.type.downcase+"/"+params[:table_id]
|
|
end
|
|
@survey = Survey.new(survey_params)
|
|
@survey.foreigner = params["survey"]["foreigner"].to_json
|
|
# respond_to do |format|
|
|
if @survey.save
|
|
redirect_to @url
|
|
end
|
|
# end
|
|
end
|
|
|
|
private
|
|
|
|
# Never trust parameters from the scary internet, only allow the white list through.
|
|
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)
|
|
end
|
|
|
|
#Shop Name in Navbor
|
|
helper_method :shop_detail
|
|
def shop_detail
|
|
@shop = Shop.first
|
|
end
|
|
end
|