add survey form

This commit is contained in:
Yan
2017-11-07 15:06:27 +06:30
6 changed files with 82 additions and 22 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -1,14 +1,42 @@
<div class="row">
<div class="container-fluid">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8">
<%= simple_form_for([:settings,@settings_account]) do |f| %>
<%= simple_form_for(@survey, :url => origami_create_surveys_path) do |f| %>
<%= f.error_notification %>
<div class="form-inputs p-l-10">
<%= 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 %>
<div class="row clearfix">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<div class="form-group">
<label>Foreigner</label>
<select class="form-control col-md-12 selectpicker show-tick" name="survey[foreigner]" style="height: " >
<% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>
<option value="<%= ct.value %>">
<%= ct.name %></option>
<%end %>
</select>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<div class="form-group">
<label>Number</label>
<input type="number" name="survey[foreigner]" class="form-control">
</div>
</div>
</div>
<%= f.input :total_customer %>
<input type="hidden" name="table_id" value="<%=@dining_facility.id%>">
<%= 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 } %>
</div>
<div class="form-actions">
<%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %>
@@ -40,3 +68,5 @@
</div>
</div>
</div>
</div>

View File

@@ -1,9 +1,10 @@
<div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= origami_path %>"><%= t("views.right_panel.button.home") %></a></li>
<li class="breadcrumb-item active"><%= t("views.right_panel.detail.survey") %></li>
<span class="float-right">
<%= link_to t('.back', :default => t("views.btn.back")), settings_accounts_path %>
<%= link_to t('.back', :default => t("views.btn.back")), root_path %>
</span>
</ol>
</div>

View File

@@ -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:

View File

@@ -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 ------------#