fixed for survey for cashier and quick_ser

This commit is contained in:
Aung Myo
2018-02-19 14:50:38 +06:30
parent c064f9d6f5
commit 48c33f68c2
2 changed files with 43 additions and 18 deletions

View File

@@ -35,18 +35,25 @@ class Origami::SurveysController < BaseOrigamiController
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 params[:table_id].to_i>0
@dining_facility = DiningFacility.find(params[:table_id])
cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_id)
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
else
sale = Sale.find(@sale_id)
shift = ShiftSale.find(sale.shift_sale_id)
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(shift.cashier_terminal_id,nil)
end
if @type == "quick_service"
@url = "/origami/sale/"+@sale_id+"/"+@type+"/payment"
else
@url = "/origami/"+@dining_facility.type.downcase+"/"+params[:table_id]
end
cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_id)
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
if params[:survey_id].nil? || params[:survey_id] == ""
@survey = Survey.new(survey_params)
@@ -79,15 +86,34 @@ class Origami::SurveysController < BaseOrigamiController
def create_survey
if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id)
dining_facility = DiningFacility.find(params[:dining_id])
cashier_zone = CashierTerminalByZone.find_by_zone_id(dining_facility.zone_id)
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
@type = params[:cashier_type]
@sale_id = params[:sale_id]
sale = Sale.find(@sale_id)
if @type != "quick_service"
dining_facility = DiningFacility.find(params[:dining_id])
cashier_zone = CashierTerminalByZone.find_by_zone_id(dining_facility.zone_id)
cashier_zone = cashier_zone.cashier_terminal_id
else
shift = ShiftSale.find(sale.shift_sale_id)
cashier_zone = shift.cashier_terminal_id
end
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_terminal_id,nil)
if @type != "quick_service"
survey = Survey.find_by_dining_name(dining_facility.name)
else
survey = nil
end
survey = Survey.find_by_dining_name(dining_facility.name)
if survey.nil?
survey = Survey.new
survey.dining_name = dining_facility.name
if @type != "quick_service"
survey.dining_name = dining_facility.name
end
survey.receipt_no = params[:receipt_no]
survey.shift_id = shift_by_terminal.id
survey.created_by = current_user.name

View File

@@ -74,13 +74,13 @@
</div>
<%if !@dining_facility.nil?%>
<input type="hidden" name="table_id" value="<%= @dining_facility.id %>">
<input type="hidden" name="table_type" value="<%= @table_type %>">
<%= f.input :dining_name, :as => :hidden, :input_html => { :value => @dining_facility.name } %>
<input type="hidden" name="table_id" value="<%= @dining_facility.id %>">
<input type="hidden" name="table_type" value="<%= @table_type %>">
<%= f.input :dining_name, :as => :hidden, :input_html => { :value => @dining_facility.name } %>
<%else%>
<input type="hidden" name="table_id" value="0">
<input type="hidden" name="table_type" value="0">
<%= f.input :dining_name, :as => :hidden, :input_html => { :value => 0 } %>
<input type="hidden" name="table_id" value="0">
<input type="hidden" name="table_type" value="0">
<%= f.input :dining_name, :as => :hidden, :input_html => { :value => 0 } %>
<%end%>
<input type="hidden" name="sale_id" value="<%=@id%>">
<input type="hidden" name="cashier_type" value="<%=@cashier_type%>">
@@ -90,8 +90,7 @@
<% else %>
<input type="hidden" name="survey_id" />
<% end %>
<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} %>