latest Aston req from OPT team
This commit is contained in:
@@ -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 }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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}%")
|
||||
|
||||
@@ -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
|
||||
|
||||
21
app/views/transactions/sales/index.html.erb
Executable file → Normal file
21
app/views/transactions/sales/index.html.erb
Executable file → Normal file
@@ -59,6 +59,7 @@
|
||||
<th><%= t("views.right_panel.detail.grand_total") %></th>
|
||||
<th><%= t :cashier %></th>
|
||||
<th><%= t("views.right_panel.detail.sales_status") %></th>
|
||||
<th><%= t("views.right_panel.detail.remark") %></th>
|
||||
<th><%= t("views.right_panel.detail.receipt_date") %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -67,7 +68,16 @@
|
||||
<% if @sales != 0 %>
|
||||
<% @sales.each do |sale| %>
|
||||
<tr>
|
||||
<td><%= link_to sale.sale_id, transactions_sale_path(sale) %></td>
|
||||
<td>
|
||||
<% if !@sale_item_audits.nil? %>
|
||||
<% @sale_item_audits.each do |audit| %>
|
||||
<%if audit.include?(sale.sale_id) %>
|
||||
<span style="color:#2196f3;">*</span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= link_to sale.sale_id, transactions_sale_path(sale) %>
|
||||
</td>
|
||||
<td><%= sale.receipt_no %></td>
|
||||
<td><%= sale.total_discount %></td>
|
||||
<td><%= sale.total_tax %></td>
|
||||
@@ -75,6 +85,15 @@
|
||||
<td><%= sale.grand_total rescue '-' %></td>
|
||||
<td><%= sale.cashier_name rescue '-' %></td>
|
||||
<td> <%= sale.sale_status %> </td>
|
||||
<td>
|
||||
<% if !@sale_audits.nil? %>
|
||||
<% @sale_audits.each do |audit| %>
|
||||
<%if audit.include?(sale.sale_id) %>
|
||||
<%= audit[sale.sale_id] %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td> <%= sale.receipt_date.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %> </td>
|
||||
</tr>
|
||||
<% end %>
|
||||
|
||||
@@ -10,9 +10,32 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||
<div class="main-box-body clearfix p-l-15 p-r-15">
|
||||
<%= form_tag transactions_surveys_path, :method => :get do %>
|
||||
<div class="row clearfix">
|
||||
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
|
||||
<label class="form-control-label"><%= t("views.right_panel.button.search_keyboard") %></label>
|
||||
<input type="text" id="dining_name" name="filter" placeholder="Dining Name" class="form-control input-md" >
|
||||
</div>
|
||||
|
||||
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
|
||||
<label class="form-control-label"><%= t("views.right_panel.detail.from") %></label>
|
||||
<input class="form-control datepicker" name="from" id="from" type="text" placeholder="From date">
|
||||
</div>
|
||||
|
||||
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-2">
|
||||
<label class="form-control-label"><%= t("views.right_panel.detail.to") %></label>
|
||||
<input class="form-control datepicker" name="to" id="to" type="text" placeholder="To date">
|
||||
</div>
|
||||
|
||||
<div class="form-group col-lg-1 col-md-1 col-sm-1 col-xs-1">
|
||||
<label > </label>
|
||||
<br> <input type="submit" value="Search" class='btn btn-primary btn-md'>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="card">
|
||||
<div class="table-responsive">
|
||||
<table class="table ">
|
||||
<table class="table table-bordered table-striped table-hover">
|
||||
<thead>
|
||||
<th><%= t("views.right_panel.detail.dining") %></th>
|
||||
<th><%= t("views.right_panel.detail.receipt_no") %></th>
|
||||
@@ -21,11 +44,26 @@
|
||||
<th><%= t("views.right_panel.detail.adult") %></th>
|
||||
<th><%= t("views.right_panel.detail.male") %></th>
|
||||
<th><%= t("views.right_panel.detail.female") %></th>
|
||||
<th><%= t("views.right_panel.detail.total") %> <%= t :customer %>
|
||||
<th><%= t("views.right_panel.detail.local") %></th>
|
||||
</th>
|
||||
<th><%= t("views.right_panel.detail.foreigner") %></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% 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 %>
|
||||
<tr>
|
||||
<td><%= survey.dining_name rescue ' '%></td>
|
||||
<td><%= survey.receipt_no rescue '-'%></td>
|
||||
@@ -34,17 +72,39 @@
|
||||
<td><%= survey.adult rescue ' '%></td>
|
||||
<td><%= survey.male rescue ' '%></td>
|
||||
<td><%= survey.female rescue ' '%></td>
|
||||
<td><%= survey.total_customer rescue ' '%></td>
|
||||
<td><%= survey.local rescue ' '%></td>
|
||||
<td>
|
||||
<% 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:]]+/) %><br>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<tr>
|
||||
<td colspan="3"><strong><%= t("views.right_panel.detail.total") %></strong></td>
|
||||
<td><strong><%= total_child %></strong></td>
|
||||
<td><strong><%= total_adult %></strong></td>
|
||||
<td><strong><%= total_male %></strong></td>
|
||||
<td><strong><%= total_female %></strong></td>
|
||||
<td><strong><%= total_customer %></strong></td>
|
||||
<td colspan="2"><strong><%= total_local %></strong></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
<%if !@orders.nil?%>
|
||||
<%= paginate @surveys %>
|
||||
<%end%>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -454,6 +454,7 @@ en:
|
||||
child: "Child"
|
||||
adult: "Adult"
|
||||
foreigner: "Foreigner"
|
||||
local: "Local"
|
||||
|
||||
code_txt: "code "
|
||||
charge_txt: "charge"
|
||||
|
||||
@@ -449,6 +449,7 @@ mm:
|
||||
child: "ကလေး"
|
||||
adult: "လူကြီး"
|
||||
foreigner: "နိုင်ငံခြားသား"
|
||||
local: "နိုင်ငံသား"
|
||||
|
||||
code_txt: "ကုတ်ဒ် "
|
||||
charge_txt: "ကောက်ခံသည်"
|
||||
|
||||
Reference in New Issue
Block a user