From 574f320dfdf96c74f87370cccb86f7d350029dec Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Tue, 22 May 2018 11:37:08 +0630 Subject: [PATCH] Export excel in Survey Report --- .../transactions/surveys_controller.rb | 1 + .../surveys/_survey_report_filter.html.erb | 41 +++++++++ app/views/transactions/surveys/index.html.erb | 34 +++----- app/views/transactions/surveys/index.xls.erb | 86 +++++++++++++++++++ 4 files changed, 141 insertions(+), 21 deletions(-) create mode 100644 app/views/transactions/surveys/_survey_report_filter.html.erb create mode 100644 app/views/transactions/surveys/index.xls.erb diff --git a/app/controllers/transactions/surveys_controller.rb b/app/controllers/transactions/surveys_controller.rb index b6c48215..4bf4ec2d 100644 --- a/app/controllers/transactions/surveys_controller.rb +++ b/app/controllers/transactions/surveys_controller.rb @@ -22,6 +22,7 @@ class Transactions::SurveysController < ApplicationController respond_to do |format| format.html # index.html.erb + format.xls format.json { render json: @surveys } end end diff --git a/app/views/transactions/surveys/_survey_report_filter.html.erb b/app/views/transactions/surveys/_survey_report_filter.html.erb new file mode 100644 index 00000000..78a988b9 --- /dev/null +++ b/app/views/transactions/surveys/_survey_report_filter.html.erb @@ -0,0 +1,41 @@ +<%= form_tag transactions_surveys_path, :method => :get, :id=>"frm_report", :class => "form" do %> +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+
+<% end %> + \ No newline at end of file diff --git a/app/views/transactions/surveys/index.html.erb b/app/views/transactions/surveys/index.html.erb index 7e750faa..cb95ad16 100644 --- a/app/views/transactions/surveys/index.html.erb +++ b/app/views/transactions/surveys/index.html.erb @@ -10,29 +10,15 @@
- <%= form_tag transactions_surveys_path, :method => :get do %> -
-
- - -
+ <%= render :partial=>'survey_report_filter', + :locals=>{ :period_type => true, :shift_name => true, :report_path =>transactions_surveys_path} %> -
- - -
+
+ + -
- - -
- -
- -
-
-
- <% end %>
@@ -116,3 +102,9 @@ + \ No newline at end of file diff --git a/app/views/transactions/surveys/index.xls.erb b/app/views/transactions/surveys/index.xls.erb new file mode 100644 index 00000000..3e31ad12 --- /dev/null +++ b/app/views/transactions/surveys/index.xls.erb @@ -0,0 +1,86 @@ +
+
+
+
+
+
+ + + + + + + + + + + + + + <% total_child = 0 %> + <% total_adult = 0 %> + <% total_male = 0 %> + <% total_female = 0 %> + <% total_local = 0 %> + <% total_customer = 0 %> + <% total_foreigner = 0 %> + <% if !@surveys.nil? %> + <% @surveys.each do |survey| %> + <% total_child = total_child.to_i + survey.child.to_i %> + <% total_adult = total_adult.to_i + survey.adult.to_i %> + <% total_male = total_male.to_i + survey.male.to_i %> + <% total_female = total_female.to_i + survey.female.to_i %> + <% total_local = total_local.to_i + survey.local.to_i %> + <% total_customer = total_customer.to_i + survey.total_customer.to_i %> + + + + + + + + + + + + + <% end %> + <% end %> + + + + + + + + + + + +
<%= t("views.right_panel.detail.dining") %><%= t("views.right_panel.detail.receipt_no") %><%= t("views.right_panel.detail.created_by") %><%= t("views.right_panel.detail.child") %><%= t("views.right_panel.detail.adult") %><%= t("views.right_panel.detail.male") %><%= t("views.right_panel.detail.female") %><%= t("views.right_panel.detail.total") %> <%= t :customer %> + <%= t("views.right_panel.detail.local") %><%= t("views.right_panel.detail.foreigner") %>
<%= survey.dining_name rescue ' '%><%= survey.receipt_no rescue '-'%><%= survey.created_by rescue ' '%><%= survey.child rescue ' '%><%= survey.adult rescue ' '%><%= survey.male rescue ' '%><%= survey.female rescue ' '%><%= survey.total_customer rescue ' '%><%= survey.local rescue ' '%> + <% if !survey.foreigner.nil? %> + <% JSON.parse(survey.foreigner).each do |foreign| %> + <% foreigner_lists = foreign.split(",") %> + <% if !foreigner_lists.empty? %> + <% foreigner_lists.each do |fgn| %> + <% unless fgn.match(/[^[:digit:]]+/) + total_foreigner = total_foreigner.to_i + fgn.to_i + end %> + <% if !fgn.scan(/\D/).empty? %> + <%= fgn %> :<% end %> <%= fgn.to_i unless fgn.match(/[^[:digit:]]+/) %>
+ <% end %> + <% end %> + <% end %> + <% end %> +
<%= t("views.right_panel.detail.total") %><%= total_child %><%= total_adult %><%= total_male %><%= total_female %><%= total_customer %><%= total_local %><%= total_foreigner %>
+
+ <%if !@orders.nil?%> + <%= paginate @surveys %> + <%end%> +
+
+
+ +
+