add survey update function
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
class Origami::SurveysController < BaseOrigamiController
|
||||
def new
|
||||
@id = params[:id]
|
||||
@survey = Survey.new()
|
||||
@id = params[:id]
|
||||
|
||||
if(@id[0,3] == "SAL")
|
||||
@sale = Sale.find(@id)
|
||||
@@ -9,14 +10,17 @@ class Origami::SurveysController < BaseOrigamiController
|
||||
@booking = Booking.find_by_sale_id(@id)
|
||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||
@table_type = @dining_facility.type
|
||||
@survey = Survey.new()
|
||||
# @survey = Survey.find_by_dining_name_and_receipt_no(@dining_facility.name, @receipt_no)
|
||||
@survey_data = Survey.find_by_dining_name(@dining_facility.name)
|
||||
survey_process = Survey.find_by_receipt_no(@receipt_no)
|
||||
if !survey_process.nil?
|
||||
@survey_data = survey_process
|
||||
end
|
||||
else
|
||||
@dining_facility = DiningFacility.find(@id)
|
||||
@table_type = @dining_facility.type
|
||||
@receipt_no = nil
|
||||
@grand_total = nil
|
||||
@survey = Survey.find_by_dining_name(@dining_facility.name)
|
||||
@survey_data = Survey.find_by_dining_name(@dining_facility.name)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -25,8 +29,8 @@ class Origami::SurveysController < BaseOrigamiController
|
||||
@url = "/origami/"+@dining_facility.type.downcase+"/"+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)
|
||||
|
||||
if request.post?
|
||||
|
||||
if params[:survey_id].nil? || params[:survey_id] == ""
|
||||
@survey = Survey.new(survey_params)
|
||||
@survey.shift_id = shift_by_terminal.id
|
||||
@survey.foreigner = params["survey"]["foreigner"].to_json
|
||||
@@ -61,7 +65,7 @@ class Origami::SurveysController < BaseOrigamiController
|
||||
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)
|
||||
|
||||
survey = Survey.find_by_receipt_no(params[:receipt_no])
|
||||
survey = Survey.find_by_dining_name(dining_facility.name)
|
||||
|
||||
if survey.nil?
|
||||
survey = Survey.new
|
||||
@@ -73,6 +77,7 @@ class Origami::SurveysController < BaseOrigamiController
|
||||
survey.total_amount = params[:total_amount]
|
||||
survey.save!
|
||||
else
|
||||
survey.receipt_no = params[:receipt_no]
|
||||
survey.total_customer = params[:total_customer]
|
||||
survey.save!
|
||||
end
|
||||
|
||||
@@ -5,43 +5,79 @@
|
||||
<%= simple_form_for(@survey, :url => origami_create_surveys_path) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
<div class="form-inputs p-l-10">
|
||||
<% if !@survey_data.nil? %>
|
||||
<%= f.input :child, input_html: { value: @survey_data.child, class: 'col-md-10' }%>
|
||||
<%= f.input :adult, input_html: { value: @survey_data.adult, class: 'col-md-10' }%>
|
||||
<%= f.input :male , input_html: { value: @survey_data.male, class: 'col-md-10' }%>
|
||||
<%= f.input :female , input_html: { value: @survey_data.female, class: 'col-md-10' }%>
|
||||
<%= f.input :total_customer, input_html: { value: @survey_data.total_customer, class: 'col-md-10'} %>
|
||||
<%= f.input :local , input_html: { value: @survey_data.local, class: 'col-md-10' }%>
|
||||
|
||||
<%= f.input :child , input_html: { class: 'col-md-10' }%>
|
||||
<%= f.input :adult , input_html: { class: 'col-md-10' }%>
|
||||
<%= f.input :male , input_html: { class: 'col-md-10' }%>
|
||||
<%= f.input :female , input_html: { class: 'col-md-10' }%>
|
||||
<%= f.input :total_customer, input_html: { class: 'col-md-10'} %>
|
||||
<%= f.input :local , input_html: { class: 'col-md-10' }%>
|
||||
|
||||
<div class="row clearfix">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 ">
|
||||
<div class="form-group p-l-10 p-r-10">
|
||||
<label class="p-l-10">Foreigner</label>
|
||||
<!-- <input type="text" class="form-control" name="survey[foreigner][]"> -->
|
||||
<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 class="row clearfix">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 ">
|
||||
<div class="form-group p-l-10 p-r-10">
|
||||
<label class="p-l-10">Foreigner</label>
|
||||
<!-- <input type="text" class="form-control" name="survey[foreigner][]"> -->
|
||||
<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>
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 ">
|
||||
<div class="form-group p-l-10 p-r-10">
|
||||
<label class="p-l-10">Number</label>
|
||||
<input type="number" name="survey[foreigner][]" class="form-control">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 ">
|
||||
<div class="form-group p-l-10 p-r-10">
|
||||
<label class="p-l-10">Number</label>
|
||||
<input type="number" name="survey[foreigner][]" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">
|
||||
<br>
|
||||
<button type="button" class="btn btn-success" id="addForeigner">Add</button>
|
||||
<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">
|
||||
<br>
|
||||
<button type="button" class="btn btn-success" id="addForeigner">Add</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<%= f.input :child , input_html: { class: 'col-md-10' }%>
|
||||
<%= f.input :adult , input_html: { class: 'col-md-10' }%>
|
||||
<%= f.input :male , input_html: { class: 'col-md-10' }%>
|
||||
<%= f.input :female , input_html: { class: 'col-md-10' }%>
|
||||
<%= f.input :total_customer, input_html: { class: 'col-md-10'} %>
|
||||
<%= f.input :local , input_html: { class: 'col-md-10' }%>
|
||||
|
||||
<div class="row clearfix">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4 ">
|
||||
<div class="form-group p-l-10 p-r-10">
|
||||
<label class="p-l-10">Foreigner</label>
|
||||
<!-- <input type="text" class="form-control" name="survey[foreigner][]"> -->
|
||||
<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-4 col-md-4 col-sm-4 col-xs-4 ">
|
||||
<div class="form-group p-l-10 p-r-10">
|
||||
<label class="p-l-10">Number</label>
|
||||
<input type="number" name="survey[foreigner][]" class="form-control">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-1 col-sm-1 col-xs-1 ">
|
||||
<br>
|
||||
<button type="button" class="btn btn-success" id="addForeigner">Add</button>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="hidden" id="newTemplate" >
|
||||
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="survey_id" value="<%=@survey.id%>">
|
||||
<% if !@survey_data.nil? %>
|
||||
<input type="hidden" name="survey_id" value=<%= @survey_data.id %> />
|
||||
<% 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 } %>
|
||||
|
||||
Reference in New Issue
Block a user