diff --git a/app/controllers/origami/surveys_controller.rb b/app/controllers/origami/surveys_controller.rb index 49d5632c..32aea6dd 100644 --- a/app/controllers/origami/surveys_controller.rb +++ b/app/controllers/origami/surveys_controller.rb @@ -1,18 +1,40 @@ -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| + + @dining_facility = DiningFacility.find(params[:table_id]) + @url = "/origami/"+@dining_facility.type.downcase+"/"+params[:table_id] + + @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 diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 22ff45dd..52c011ce 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -402,11 +402,11 @@ if (sale) { var sale_id = sale } else { - var sale_id = $('#save_order_id').attr('data-order'); + var sale_id = $('.tables').attr("data-id");; } - var table_id = $('.tables').attr("data-id"); + //var table_id = $('.tables').attr("data-id"); - window.location.href = '/origami/' + sale_id + "/survey" + window.location.href = '/origami/' + sale_id + "/surveys" }); // bind customer to order or sale diff --git a/app/views/origami/surveys/_form.html.erb b/app/views/origami/surveys/_form.html.erb index 5badaff4..bcd3ea74 100755 --- a/app/views/origami/surveys/_form.html.erb +++ b/app/views/origami/surveys/_form.html.erb @@ -1,14 +1,42 @@ -