add survey update function
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
class Origami::SurveysController < BaseOrigamiController
|
class Origami::SurveysController < BaseOrigamiController
|
||||||
def new
|
def new
|
||||||
|
@survey = Survey.new()
|
||||||
@id = params[:id]
|
@id = params[:id]
|
||||||
|
|
||||||
if(@id[0,3] == "SAL")
|
if(@id[0,3] == "SAL")
|
||||||
@@ -9,14 +10,17 @@ class Origami::SurveysController < BaseOrigamiController
|
|||||||
@booking = Booking.find_by_sale_id(@id)
|
@booking = Booking.find_by_sale_id(@id)
|
||||||
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
|
||||||
@table_type = @dining_facility.type
|
@table_type = @dining_facility.type
|
||||||
@survey = Survey.new()
|
@survey_data = Survey.find_by_dining_name(@dining_facility.name)
|
||||||
# @survey = Survey.find_by_dining_name_and_receipt_no(@dining_facility.name, @receipt_no)
|
survey_process = Survey.find_by_receipt_no(@receipt_no)
|
||||||
|
if !survey_process.nil?
|
||||||
|
@survey_data = survey_process
|
||||||
|
end
|
||||||
else
|
else
|
||||||
@dining_facility = DiningFacility.find(@id)
|
@dining_facility = DiningFacility.find(@id)
|
||||||
@table_type = @dining_facility.type
|
@table_type = @dining_facility.type
|
||||||
@receipt_no = nil
|
@receipt_no = nil
|
||||||
@grand_total = 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
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -26,7 +30,7 @@ class Origami::SurveysController < BaseOrigamiController
|
|||||||
cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_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)
|
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 = Survey.new(survey_params)
|
||||||
@survey.shift_id = shift_by_terminal.id
|
@survey.shift_id = shift_by_terminal.id
|
||||||
@survey.foreigner = params["survey"]["foreigner"].to_json
|
@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)
|
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)
|
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?
|
if survey.nil?
|
||||||
survey = Survey.new
|
survey = Survey.new
|
||||||
@@ -73,6 +77,7 @@ class Origami::SurveysController < BaseOrigamiController
|
|||||||
survey.total_amount = params[:total_amount]
|
survey.total_amount = params[:total_amount]
|
||||||
survey.save!
|
survey.save!
|
||||||
else
|
else
|
||||||
|
survey.receipt_no = params[:receipt_no]
|
||||||
survey.total_customer = params[:total_customer]
|
survey.total_customer = params[:total_customer]
|
||||||
survey.save!
|
survey.save!
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,7 +5,39 @@
|
|||||||
<%= simple_form_for(@survey, :url => origami_create_surveys_path) do |f| %>
|
<%= simple_form_for(@survey, :url => origami_create_surveys_path) do |f| %>
|
||||||
<%= f.error_notification %>
|
<%= f.error_notification %>
|
||||||
<div class="form-inputs p-l-10">
|
<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' }%>
|
||||||
|
|
||||||
|
<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>
|
||||||
|
<% else %>
|
||||||
<%= f.input :child , input_html: { class: 'col-md-10' }%>
|
<%= f.input :child , input_html: { class: 'col-md-10' }%>
|
||||||
<%= f.input :adult , 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 :male , input_html: { class: 'col-md-10' }%>
|
||||||
@@ -37,11 +69,15 @@
|
|||||||
<button type="button" class="btn btn-success" id="addForeigner">Add</button>
|
<button type="button" class="btn btn-success" id="addForeigner">Add</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<% end %>
|
||||||
<div class="hidden" id="newTemplate" >
|
<div class="hidden" id="newTemplate" >
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
<% if !@survey_data.nil? %>
|
||||||
<input type="hidden" name="survey_id" value="<%=@survey.id%>">
|
<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%>">
|
<input type="hidden" name="table_id" value="<%=@dining_facility.id%>">
|
||||||
<%= f.input :dining_name, :as => :hidden, :input_html => { :value => @dining_facility.name } %>
|
<%= 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 :created_by, :as => :hidden, :input_html => { :value => current_login_employee.name } %>
|
||||||
|
|||||||
Reference in New Issue
Block a user