dashboard update
This commit is contained in:
@@ -80,14 +80,21 @@ class HomeController < ApplicationController
|
||||
end
|
||||
|
||||
def dashboard
|
||||
@from, @to = get_date_range_from_params
|
||||
@from, @to, @from_time, @to_time = get_date_range_from_params
|
||||
|
||||
@shop = Shop.first
|
||||
|
||||
today = DateTime.now.strftime('%Y-%m-%d')
|
||||
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
|
||||
if !@from.nil? && !@to.nil?
|
||||
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}'").count()
|
||||
else
|
||||
@orders = Sale::where("payment_status='new' and sale_status='bill' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
end
|
||||
if !@from.nil? && !@to.nil?
|
||||
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') between '#{@from}' and '#{@to}'").count()
|
||||
else
|
||||
@sales = Sale::where("payment_status='paid' and sale_status='completed' and DATE_FORMAT(receipt_date,'%Y-%m-%d') = '#{today}'").count()
|
||||
end
|
||||
@top_products = Sale.top_products(today,@from,@to).sum('i.qty')
|
||||
@bottom_products = Sale.bottom_products(today,@from,@to).sum('i.qty')
|
||||
@hourly_sales = Sale.hourly_sales(today,@from,@to).sum(:grand_total)
|
||||
@@ -190,7 +197,9 @@ class HomeController < ApplicationController
|
||||
|
||||
def get_date_range_from_params
|
||||
from = params[:from]
|
||||
to = params[:to]
|
||||
to = params[:to]
|
||||
from_time = params[:from_time]
|
||||
to_time = params[:to_time]
|
||||
|
||||
if from.present? && to.present?
|
||||
f_date = DateTime.parse(from)
|
||||
@@ -201,7 +210,7 @@ class HomeController < ApplicationController
|
||||
to = t_time.end_of_day.utc.getlocal
|
||||
end
|
||||
|
||||
return from, to
|
||||
return from, to, from_time, to_time
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
|
||||
@@ -68,16 +68,26 @@
|
||||
|
||||
<!-- Date range for dashboard -->
|
||||
<div class="row clearfix">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4">
|
||||
<div class="col-lg-3 col-md-3 col-sm-3">
|
||||
<label class="font-14"><%= t("views.right_panel.detail.from") %></label>
|
||||
<input data-behaviour='datepicker' class="form-control datepicker" name="from" id="from" type="text" value="<%= Time.now.utc.strftime('%d-%m-%Y') %>" placeholder="From date" style="height: 35px;">
|
||||
<input data-behaviour='datepicker' class="form-control datepicker" name="from" id="from" type="text" value="<%= Time.now.utc.getlocal.strftime('%d-%m-%Y') %>" placeholder="From date" style="height: 35px;">
|
||||
<span id="fromErr" style="color:red;"></span>
|
||||
</div>
|
||||
<div class="col-lg-4 col-md-4 col-sm-4">
|
||||
<div class="col-lg-3 col-md-3 col-sm-3">
|
||||
<label class="font-14"><%= t("views.right_panel.detail.to") %></label>
|
||||
<input data-behaviour='datepicker' class="form-control datepicker" name="to" id="to" type="text" value="<%= Time.now.utc.strftime('%d-%m-%Y') %>" placeholder="To date" style="height: 35px;">
|
||||
<input data-behaviour='datepicker' class="form-control datepicker" name="to" id="to" type="text" value="<%= Time.now.utc.getlocal.strftime('%d-%m-%Y') %>" placeholder="To date" style="height: 35px;">
|
||||
<span id="toErr" style="color:red;"></span>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<label class="font-14"><%= t("views.right_panel.detail.from_time") %></label>
|
||||
<input data-behaviour='timepicker' class="form-control timepicker" name="from_time" id="from_time" type="text" value="" placeholder="From Time" style="height: 35px;">
|
||||
<span id="from_timeErr" style="color:red;"></span>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<label class="font-14"><%= t("views.right_panel.detail.to_time") %></label>
|
||||
<input data-behaviour='timepicker' class="form-control timepicker" name="to_time" id="to_time" type="text" value="" placeholder="To time" style="height: 35px;">
|
||||
<span id="to_timeErr" style="color:red;"></span>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<label></label><br>
|
||||
<input type="button" value="Generate" class='btn btn-primary btn_generate'>
|
||||
@@ -340,21 +350,53 @@
|
||||
$('.btn_generate').on('click',function(){
|
||||
var from = $("#from").val();
|
||||
var to = $("#to").val();
|
||||
var from_time = $("#from_time").val();
|
||||
var to_time = $("#to_time").val();
|
||||
|
||||
if(check(from,to,from_time,to_time)){
|
||||
var params = '?';
|
||||
if((from!='' && to!='') && (from_time!='' && to_time!='')){
|
||||
params += 'from='+from+'&to='+to+'&from_time='+from_time+'&to_time='+to_time;
|
||||
}else{
|
||||
params += 'from='+from+'&to='+to;
|
||||
}
|
||||
window.location.href = '/dashboard'+params;
|
||||
}
|
||||
});
|
||||
|
||||
function check(from,to,from_time,to_time){
|
||||
var status = true;
|
||||
if((from=='') && (to=='')){
|
||||
status = false;
|
||||
$('#fromErr').html("can't be blank");
|
||||
$('#toErr').html("can't be blank");
|
||||
}else if((from!='') && (to=='')){
|
||||
status = false;
|
||||
$('#fromErr').html("");
|
||||
$('#toErr').html("can't be blank");
|
||||
}else if((from=='') && (to!='')){
|
||||
status = false;
|
||||
$('#fromErr').html("can't be blank");
|
||||
$('#toErr').html("");
|
||||
}else{
|
||||
status = true;
|
||||
$('#fromErr').html("");
|
||||
$('#toErr').html("");
|
||||
}
|
||||
if((from!='') && (to!='')){
|
||||
window.location.href = '/dashboard?from='+from+'&to='+to;
|
||||
|
||||
if(((from_time=='') && (to_time=='')) || ((from_time!='') && (to_time!=''))){
|
||||
status = true;
|
||||
$('#from_timeErr').html("");
|
||||
$('#to_timeErr').html("");
|
||||
}else if((from_time!='') && (to_time=='')){
|
||||
status = false;
|
||||
$('#from_timeErr').html("");
|
||||
$('#to_timeErr').html("can't be blank");
|
||||
}else if((from_time=='') && (to_time!='')){
|
||||
status = false;
|
||||
$('#from_timeErr').html("can't be blank");
|
||||
$('#to_timeErr').html("");
|
||||
}
|
||||
});
|
||||
return status;
|
||||
}
|
||||
</script>
|
||||
@@ -22,7 +22,7 @@
|
||||
<div class="icon" >
|
||||
<i class="material-icons">arrow_forward</i>
|
||||
</div>
|
||||
<div class="text font-20 m-l-5" style="line-height: 80px;">Quick Service</div>
|
||||
<div class="text font-20 m-l-5" style="line-height: 80px;"><%= t :quick_service %></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-3 col-sm-4 col-xs-12 cashier_view">
|
||||
@@ -30,7 +30,7 @@
|
||||
<div class="icon" >
|
||||
<i class="material-icons">arrow_forward</i>
|
||||
</div>
|
||||
<div class="text font-20 m-l-5" style="line-height: 80px;">Cashier</div>
|
||||
<div class="text font-20 m-l-5" style="line-height: 80px;"><%= t :dine_in_order %></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -72,6 +72,8 @@ en:
|
||||
payment: "Payment"
|
||||
backend: "Backend"
|
||||
date_time: "DateTime"
|
||||
dine_in_order: "Dine In Order"
|
||||
quick_service: "Quick Service"
|
||||
|
||||
views:
|
||||
btn:
|
||||
|
||||
@@ -67,6 +67,8 @@ mm:
|
||||
payment: "ငွေပေးချေမှု"
|
||||
backend: "နောက်ကွယ်"
|
||||
date_time: "ရက်စွဲအချိန်"
|
||||
dine_in_order: "Dine In Order"
|
||||
quick_service: "Quick Service"
|
||||
|
||||
views:
|
||||
btn:
|
||||
|
||||
Reference in New Issue
Block a user