diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index 321fa44a..f996142d 100755 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -11,7 +11,7 @@ class Transactions::SalesController < ApplicationController to = params[:to] if receipt_no.nil? && from.nil? && to.nil? - @sales = Sale.order("sale_id desc") + @sales = Sale.where("NOT sale_status='new'").order("sale_id desc") @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20) else sale = Sale.search(receipt_no,from,to) @@ -45,6 +45,24 @@ class Transactions::SalesController < ApplicationController # end # end + @sale_audits = [] + @sale_item_audits = [] + if !@sales.nil? + @sales.each do |sale| + sale_audit = SaleAudit.where("(action = 'SALEPAYMENT' or action = 'SALEVOID') and sale_id = ? and remark IS NOT NULL",sale.sale_id) + if !sale_audit.nil? + sale_audit.each do |audit| + @sale_audits.push({sale.sale_id => audit.remark}) + end + end + + sale_item_audit = SaleAudit.where("(action LIKE '%ITEM%') and sale_id = ?",sale.sale_id) + if !sale_item_audit.nil? && sale_item_audit.count > 0 + @sale_item_audits.push({sale.sale_id => sale_item_audit.count}) + end + end + end + respond_to do |format| format.html # index.html.erb format.json { render json: @sales } diff --git a/app/controllers/transactions/surveys_controller.rb b/app/controllers/transactions/surveys_controller.rb index 8d11fa41..b6c48215 100644 --- a/app/controllers/transactions/surveys_controller.rb +++ b/app/controllers/transactions/surveys_controller.rb @@ -1,5 +1,28 @@ class Transactions::SurveysController < ApplicationController def index - @surveys = Survey.all + filter = params[:filter] + from = params[:from] + to = params[:to] + + if filter.nil? && from.nil? && to.nil? + surveys = Survey.all + else + surveys = Survey.search(filter,from,to) + end + + if !surveys.nil? + @surveys = Kaminari.paginate_array(surveys).page(params[:page]).per(20) + else + @surveys = [] + end + + @filter = filter + @from = from + @to = to + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @surveys } + end end end diff --git a/app/models/sale.rb b/app/models/sale.rb index c95617b2..2b93cfb2 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -605,7 +605,7 @@ class Sale < ApplicationRecord end if from.present? && to.present? - sale = Sale.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and NOT sale_status = 'void' ", from,to) + sale = Sale.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and NOT sale_status = 'new' ", from,to) query = sale.where(keyword) else where("receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%") diff --git a/app/models/survey.rb b/app/models/survey.rb index 27b6229e..840b4c1e 100644 --- a/app/models/survey.rb +++ b/app/models/survey.rb @@ -1,2 +1,17 @@ class Survey < ApplicationRecord + + def self.search(filter,from,to) + if filter.blank? + keyword = '' + else + keyword = "dining_name LIKE ?","%#{filter}%" + end + + if from.present? && to.present? + survey = Survey.where("DATE_FORMAT(created_at,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(created_at,'%d-%m-%Y') <= ?", from,to) + query = survey.where(keyword) + else + where("dining_name LIKE ?", "%#{filter}%") + end + end end diff --git a/app/views/transactions/sales/index.html.erb b/app/views/transactions/sales/index.html.erb old mode 100755 new mode 100644 index 172320df..5bfc4e61 --- a/app/views/transactions/sales/index.html.erb +++ b/app/views/transactions/sales/index.html.erb @@ -59,6 +59,7 @@ <%= t("views.right_panel.detail.grand_total") %> <%= t :cashier %> <%= t("views.right_panel.detail.sales_status") %> + <%= t("views.right_panel.detail.remark") %> <%= t("views.right_panel.detail.receipt_date") %> @@ -67,7 +68,16 @@ <% if @sales != 0 %> <% @sales.each do |sale| %> - <%= link_to sale.sale_id, transactions_sale_path(sale) %> + + <% if !@sale_item_audits.nil? %> + <% @sale_item_audits.each do |audit| %> + <%if audit.include?(sale.sale_id) %> + * + <% end %> + <% end %> + <% end %> + <%= link_to sale.sale_id, transactions_sale_path(sale) %> + <%= sale.receipt_no %> <%= sale.total_discount %> <%= sale.total_tax %> @@ -75,6 +85,15 @@ <%= sale.grand_total rescue '-' %> <%= sale.cashier_name rescue '-' %> <%= sale.sale_status %> + + <% if !@sale_audits.nil? %> + <% @sale_audits.each do |audit| %> + <%if audit.include?(sale.sale_id) %> + <%= audit[sale.sale_id] %> + <% end %> + <% end %> + <% end %> + <%= sale.receipt_date.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %> <% end %> diff --git a/app/views/transactions/surveys/index.html.erb b/app/views/transactions/surveys/index.html.erb index 4e1c02d3..66defdc0 100644 --- a/app/views/transactions/surveys/index.html.erb +++ b/app/views/transactions/surveys/index.html.erb @@ -10,9 +10,32 @@
+ <%= form_tag transactions_surveys_path, :method => :get do %> +
+
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ +
+
+
+ <% end %>
- +
@@ -21,11 +44,26 @@ + + + <% total_child = 0 %> + <% total_adult = 0 %> + <% total_male = 0 %> + <% total_female = 0 %> + <% total_local = 0 %> + <% total_customer = 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 %> @@ -34,17 +72,39 @@ + + <% end %> <% end %> + + + + + + + + +
<%= t("views.right_panel.detail.dining") %> <%= t("views.right_panel.detail.receipt_no") %><%= 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.adult rescue ' '%> <%= survey.male rescue ' '%> <%= survey.female rescue ' '%><%= survey.total_customer rescue ' '%><%= survey.local rescue ' '%> <% if !survey.foreigner.nil? %> - <%= JSON.parse(survey.foreigner) %> + <% JSON.parse(survey.foreigner).each do |foreign| %> + <% foreigner_lists = foreign.split(",") %> + <% if !foreigner_lists.empty? %> + <% foreigner_lists.each do |fgn| %> + <% 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 %>

+ <%if !@orders.nil?%> + <%= paginate @surveys %> + <%end%>
diff --git a/config/locales/en.yml b/config/locales/en.yml index 4852f454..da68414c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -454,6 +454,7 @@ en: child: "Child" adult: "Adult" foreigner: "Foreigner" + local: "Local" code_txt: "code " charge_txt: "charge" diff --git a/config/locales/mm.yml b/config/locales/mm.yml index b8a567bc..d3ca2d0f 100644 --- a/config/locales/mm.yml +++ b/config/locales/mm.yml @@ -449,6 +449,7 @@ mm: child: "ကလေး" adult: "လူကြီး" foreigner: "နိုင်ငံခြားသား" + local: "နိုင်ငံသား" code_txt: "ကုတ်ဒ် " charge_txt: "ကောက်ခံသည်"