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 @@ -
+
+
- <%= simple_form_for([:settings,@settings_account]) do |f| %> + <%= simple_form_for(@survey, :url => origami_create_surveys_path) do |f| %> <%= f.error_notification %>
- <%= f.input :title ,:input_html=>{:class=>"col-md-10"},:required=>true%> - <%= f.input :account_type, :collection => Lookup.collection_of("account_type"),:input_html=>{:class=>"col-md-10"},:required=>true %> - <%= f.input :discount %> - <%= f.input :point %> - <%= f.input :bonus %> - <%= f.input :rebate %> + + <%= f.input :child%> + <%= f.input :adult %> + <%= f.input :male %> + <%= f.input :female %> + <%= f.input :local %> + +
+
+
+ + +
+
+
+ +
+ + +
+
+
+ <%= f.input :total_customer %> + + <%= f.input :dining_name, :as => :hidden, :input_html => { :value => @dining_facility.name } %> + <%= f.input :created_by, :as => :hidden, :input_html => { :value => current_login_employee.name } %> + <%= f.input :receipt_no, :as => :hidden, :input_html => { :value => @receipt_no} %> + <%= f.input :total_amount, :as => :hidden, :input_html => { :value => @grand_total } %>
<%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %> @@ -40,3 +68,5 @@
+ +
\ No newline at end of file diff --git a/app/views/origami/surveys/new.html.erb b/app/views/origami/surveys/new.html.erb index 05dfdf68..4a287beb 100755 --- a/app/views/origami/surveys/new.html.erb +++ b/app/views/origami/surveys/new.html.erb @@ -1,9 +1,10 @@ diff --git a/config/locales/en.yml b/config/locales/en.yml index 7dc50bbb..a63c5d78 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -590,6 +590,7 @@ en: edit_btn_txt: "to edit " delete_btn_txt: "to delete " update_btn_txt: "to update " + survey: "Survey" helpers: page_entries_info: diff --git a/config/routes.rb b/config/routes.rb index e02a0436..a60b8bc4 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -73,6 +73,7 @@ scope "(:locale)", locale: /en|mm/ do #--------- Cashier ------------# namespace :origami do + resources :cash_ins, only: [:new, :create] resources :cash_outs, only: [:new, :create] root "home#index" @@ -178,6 +179,9 @@ scope "(:locale)", locale: /en|mm/ do post '/:sale_id/get_customer' => "customers#get_customer" + get '/:id/surveys', to: "surveys#new" + post '/:id/create' => "surveys#create", :as => "create_surveys" + get '/addorders/get_menu_category/:id' => "addorders#get_menu_category",:as => "get_menu_category", :defaults => { :format => 'json' } get '/addorders/products/list' => "addorders#get_all_product",:as => "get_all_product", :defaults => { :format => 'json' } @@ -195,6 +199,8 @@ scope "(:locale)", locale: /en|mm/ do post 'select_sale_item' => 'product_commissions#select_sale_item', as: 'select_sale_item' post 'select_commissioner' => 'product_commissions#set_commissioner_to_sale_item', as: 'select_commissioner' + + end #--------- Waiter/Ordering Station ------------#