update survey
This commit is contained in:
@@ -1,18 +1,42 @@
|
||||
class Origami::SurveysController < ApplicationController
|
||||
class Origami::SurveysController < BaseOrigamiController
|
||||
def new
|
||||
@survey = Account.new
|
||||
@survey = Survey.new
|
||||
@id = params[:id]
|
||||
|
||||
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)
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
@table_type = @dining_facility.type
|
||||
else
|
||||
@dining_facility = DiningFacility.find(@id)
|
||||
@table_type = @dining_facility.type
|
||||
@receipt_no = nil
|
||||
@grand_total = nil
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
@survey = Account.new(survey_params)
|
||||
respond_to do |format|
|
||||
puts params[:table_id]
|
||||
puts params
|
||||
puts "tttttttttt"
|
||||
@dining_facility = DiningFacility.find(params[:table_id])
|
||||
@url = "/origami/"+@dining_facility.type.downcase+"/"+params[:table_id]
|
||||
puts @url
|
||||
@survey = Survey.new(survey_params)
|
||||
|
||||
# respond_to do |format|
|
||||
if @survey.save
|
||||
format.html { redirect_to settings_accounts_url, notice: 'survey was successfully created.' }
|
||||
format.json { render :index, status: :created, location: @survey }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: settings_accounts_url.errors, status: :unprocessable_entity }
|
||||
redirect_to @url
|
||||
end
|
||||
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
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user