remove con္ူငခအဓ

This commit is contained in:
phyusin
2018-07-13 14:45:32 +06:30
5 changed files with 312 additions and 250 deletions

View File

@@ -82,7 +82,15 @@ $(document).ready(function() {
touchScrollStep : 45
});
$('#pending-order-slimscroll').slimScroll({
height: height-$('#pending-order-slimscroll').attr('data-height'),
size: '5px',
color: 'rgba(0,0,0,0.5)',
alwaysVisible: false,
borderRadius: '0',
railBorderRadius: '0',
touchScrollStep : 50
});
// $('.delete').click(function(){
// var method = $(this).attr('data-method');
// var url = $(this).attr('data-ref');

View File

@@ -519,4 +519,9 @@ nav.pagination .page a:hover,
z-index: 101;
filter: alpha(opacity=100); /* ie */
-moz-opacity: 1; /* mozilla */
}
.existing_invoice{
background-color:#ffab51;
color:#fff;
}

View File

@@ -246,6 +246,7 @@ class Ability
can :move_dining, :moveroom
can :manage, Sale
can :manage, Customer
can :manage, DiningQueue

View File

@@ -1361,7 +1361,7 @@ end
.order("SUM(i.qty) ASC").limit(20)
end
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
" i.price as unit_price,mi.name as product_name")
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
@@ -1416,7 +1416,7 @@ end
query = query.order("SUM(i.qty) ASC").limit(20)
end
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.select("(SUM(i.qty) * i.price) as grand_total,SUM(i.qty) as total_item," +
" i.price as unit_price,mi.name as product_name")
.joins("JOIN sale_items i ON i.sale_id = sales.sale_id JOIN menu_items mi ON i.product_code = mi.item_code")
@@ -1460,7 +1460,7 @@ end
query = query.group("date_format(CONVERT_TZ(receipt_date,'+00:00', 'SYSTEM'), '%I %p')")
.order('receipt_date')
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.select("grand_total")
if !from_time.nil? && !to_time.nil?
query = query.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%M") between ? and ?',from,to,from_time,to_time)
@@ -1490,7 +1490,7 @@ end
.group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')")
.order('receipt_date')
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.select("grand_total")
.where('sale_status = "completed" and DATE_FORMAT(receipt_date,"%Y-%m-%d") = ?',today)
.group("date_format(CONVERT_TZ(receipt_date,'+00:00', '+06:30'), '%I %p')")
@@ -1521,7 +1521,7 @@ end
query = query.group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay' or sp.payment_method='alipay' or sp.payment_method='paymal' or sp.payment_method='dinga' or sp.payment_method='JunctionPay' or sp.payment_method='giftvoucher') THEN 'card' ELSE sp.payment_method END)","e.name")
.order("e.name")
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.joins("JOIN employees as e on e.id=sales.cashier_id")
.joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id")
if !from_time.nil? && !to_time.nil?
@@ -1554,7 +1554,7 @@ end
.group("(CASE WHEN (sp.payment_method='mpu' or sp.payment_method='visa' or sp.payment_method='master' or sp.payment_method='jcb' or sp.payment_method='unionpay' or sp.payment_method='alipay' or sp.payment_method='paymal' or sp.payment_method='dinga' or sp.payment_method='JunctionPay' or sp.payment_method='giftvoucher') THEN 'card' ELSE sp.payment_method END)","e.name")
.order("e.name")
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.joins("JOIN employees as e on e.id=sales.cashier_id")
.joins("JOIN sale_payments as sp on sp.sale_id=sales.sale_id")
.where("sales.payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = '#{today}'")
@@ -1583,7 +1583,7 @@ end
total = Sale.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count").where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to)
end
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
if !from_time.nil? && !to_time.nil?
total = Sale.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count").where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time)
else
@@ -1604,7 +1604,7 @@ end
if current_user.nil?
total = Sale.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count").where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today)
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
total = Sale.select("SUM(grand_total) as total_sale, COUNT(sales.sale_id) as total_count").where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today)
else
shift = ShiftSale.current_open_shift(current_user.id)
@@ -1629,7 +1629,7 @@ end
.sum("sp.payment_amount")
end
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
if !from_time.nil? && !to_time.nil?
query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',from,to,from_time,to_time)
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
@@ -1660,7 +1660,7 @@ end
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
.sum("sp.payment_amount")
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and (sp.payment_method = "mpu" or sp.payment_method = "visa" or sp.payment_method = "master" or sp.payment_method = "jcb" or sp.payment_method = "unionpay" or sp.payment_method = "alipay" or sp.payment_method = "paymal" or sp.payment_method = "dinga" or sp.payment_method = "JunctionPay")',today,today)
.joins("JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
.sum("sp.payment_amount")
@@ -1689,7 +1689,7 @@ end
.sum("payment_amount")
end
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
if !from_time.nil? && !to_time.nil?
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time)
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
@@ -1720,7 +1720,7 @@ end
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
.sum("payment_amount")
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = SalePayment.where('s.sale_status = "completed" and payment_method="creditnote" and DATE_FORMAT(CONVERT_TZ(s.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',today,today)
.joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id")
.sum("payment_amount")
@@ -1749,7 +1749,7 @@ end
.first()
end
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
if !from_time.nil? && !to_time.nil?
query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax')
.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time)
@@ -1780,7 +1780,7 @@ end
.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today)
.first()
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.select('count(sale_id) as total_receipt, (case when sum(total_amount) > 0 then sum(total_amount) else 0.0 end) as total_amount, (case when sum(grand_total) > 0 then sum(grand_total) else 0.0 end) as grand_total, (case when sum(total_discount) > 0 then sum(total_discount) else 0.0 end) as total_discount, (case when sum(total_tax) > 0 then sum(total_tax) else 0.0 end) as total_tax')
.where('sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today)
.first()
@@ -1809,7 +1809,7 @@ end
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
end
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
if !from_time.nil? && !to_time.nil?
query = Sale.select("distinct sp.payment_method")
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date, "+00:00", "+06:30"),"%H:%i") between ? and ?',from,to,from_time,to_time)
@@ -1840,7 +1840,7 @@ end
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today)
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.select("distinct sp.payment_method")
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today)
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
@@ -1881,7 +1881,7 @@ end
query.select("(CASE WHEN sp.payment_method='cash' THEN (SUM(sp.payment_amount) - SUM(sales.amount_changed)) ELSE SUM(sp.payment_amount) END) as payment_amount").first()
end
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
if !from_time.nil? && !to_time.nil?
query = Sale.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
if payment_method == 'card'
@@ -1994,7 +1994,7 @@ end
.first()
end
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
if !from_time.nil? && !to_time.nil?
query = Sale.select("(CASE WHEN c.customer_type='Dinein' THEN count(sales.customer_id) ELSE 0 END) as total_dinein_cus, (CASE WHEN c.customer_type='Takeaway' THEN count(sales.customer_id) ELSE 0 END) as total_take_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
@@ -2063,7 +2063,7 @@ end
.first()
end
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
if !from_time.nil? && !to_time.nil?
query = Sale.select("count(distinct sales.customer_id) as total_memb_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
@@ -2095,7 +2095,7 @@ end
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today)
.first()
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.select("count(distinct sales.customer_id) as total_memb_cus")
.joins("JOIN customers as c ON c.customer_id = sales.customer_id")
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and ((c.customer_type = "Dinein" and c.membership_id is not null) or (c.customer_type = "Takeaway" and c.membership_id is not null))',today)
@@ -2126,7 +2126,7 @@ end
# .first()
# end
# else
# if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
# if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
# query = Sale.select("count(sales.customer_id) as total_cus")
# .joins("JOIN customers as c ON c.customer_id = sales.customer_id")
# if !from_time.nil? && !to_time.nil?
@@ -2158,7 +2158,7 @@ end
# .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today)
# .first()
# else
# if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
# if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
# query = Sale.select("count(sales.customer_id) as total_cus")
# .joins("JOIN customers as c ON c.customer_id = sales.customer_id")
# .where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and c.customer_type is null and c.membership_id is null',today)
@@ -2190,7 +2190,7 @@ end
.first()
end
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.select("count(distinct a.order_id) as total_order")
.joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id")
.joins("JOIN orders as b ON b.order_id = a.order_id")
@@ -2225,7 +2225,7 @@ end
.where('b.status = "billed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today)
.first()
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.select("count(distinct a.order_id) as total_order")
.joins("JOIN sale_orders as a ON a.sale_id = sales.sale_id")
.joins("JOIN orders as b ON b.order_id = a.order_id")
@@ -2257,7 +2257,7 @@ end
query = query.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to)
end
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.select("distinct b.id as account_id, b.title as title")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.joins("JOIN accounts as b ON b.id = a.account_id")
@@ -2287,7 +2287,7 @@ end
.joins("JOIN accounts as b ON b.id = a.account_id")
.where('sales.sale_status = "completed" and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today)
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.select("distinct b.id as account_id, b.title as title")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.joins("JOIN accounts as b ON b.id = a.account_id")
@@ -2318,7 +2318,7 @@ end
.first()
end
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
if !from_time.nil? && !to_time.nil?
@@ -2350,7 +2350,7 @@ end
.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
.first()
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.select("count(*) as cnt_acc, SUM(a.price) as total_acc")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.where("sales.sale_status = 'completed' and a.account_id ='#{account_id}' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
@@ -2382,7 +2382,7 @@ end
.order("SUM(a.qty) DESC")
.first()
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
if !from_time.nil? && !to_time.nil?
@@ -2418,7 +2418,7 @@ end
.order("SUM(a.qty) DESC")
.first()
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.select("a.product_name as item_name, SUM(a.price) as item_total_price")
.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.where("(a.qty > 0 and a.price > 0) and payment_status='paid' and sales.sale_status = 'completed' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
@@ -2452,7 +2452,7 @@ end
.count()
end
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
if !from_time.nil? && !to_time.nil?
query = query.where("sales.sale_status = 'completed' and a.status='foc' and a.product_name like '%FOC%' and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%Y-%m-%d') between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,'+00:00','+06:30'),'%H:%i') between ? and ?",from,to,from_time,to_time)
@@ -2481,7 +2481,7 @@ end
.where("sales.sale_status = 'completed' and a.status='foc' and a.product_name like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
.count()
else
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account'
if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
query = Sale.joins("JOIN sale_items as a ON a.sale_id = sales.sale_id")
.where("sales.sale_status = 'completed' and a.status='foc' and a.product_name like '%FOC%' and DATE_FORMAT(sales.receipt_date,'%Y-%m-%d') = ?",today)
.count()

View File

@@ -51,38 +51,28 @@
<% else %>
<div class="card tables orange text-white table_<%= table.id %>" data-id="<%= table.id %>">
<% end %>
<div class="card-block">
<%= table.name %>
<!-- <% if !@order_items_count.nil? %>
<% if @order_items_count.key?(table.id) %>
(Orders : <%= @order_items_count[table.id] %>)
<% end %>
<% end %> -->
<span class="float-right font-12 new_text_<%= table.id %>"> billed</span>
<div style="font-size:12px;"></div>
<div class="card-block">
<%= table.name %>
<span class="float-right font-12 new_text_<%= table.id %>"> billed</span>
<div style="font-size:12px;"></div>
</div>
</div>
</div>
<% else %>
<% if table.get_checkout_booking.nil? %>
<div class="card tables blue text-white table_<%= table.id %>" data-id="<%= table.id %>">
<% else %>
<div class="card tables orange text-white table_<%= table.id %>" data-id="<%= table.id %>">
<% end %>
<div class="card-block">
<%= table.name %>
<!-- <% if !@order_items_count.nil? %>
<% if @order_items_count.key?(table.id) %>
(Orders : <%= @order_items_count[table.id] %>)
<% end %>
<% end %> -->
<span class="float-right font-12 new_text_<%= table.id %>"> new</span>
<div class="card-block">
<%= table.name %>
<span class="float-right font-12 new_text_<%= table.id %>"> new</span>
</div>
</div>
</div>
<% end %>
<% else %>
<div class="card tables green text-white table_<%= table.id %>" data-id="<%= table.id %>">
<div class="card-block">
<%= table.name %>
<div class="card-block">
<%= table.name %>
<span class="float-right font-12 new_text_<%= table.id %> hide"> new</span>
</div>
</div>
@@ -98,33 +88,23 @@
<% if room.status == 'occupied' %>
<% if room.get_booking.nil? %>
<% if room.get_checkout_booking.nil? %>
<div class="card rooms red text-white table_<%= room.id %>" data-id="<%= room.id %>">
<div class="card rooms red text-white table_<%= room.id %>" data-id="<%= room.id %>">
<% else %>
<div class="card rooms orange text-white table_<%= room.id %>" data-id="<%= room.id %>">
<div class="card rooms orange text-white table_<%= room.id %>" data-id="<%= room.id %>">
<% end %>
<div class="card-block">
<%= room.name %>
<!-- <% if !@order_items_count.nil? %>
<% if @order_items_count.key?(room.id) %>
(Orders : <%= @order_items_count[room.id] %>)
<% end %>
<% end %> -->
<span class="float-right font-12 new_text_<%= room.id %>"> billed</span>
<div class="card-block">
<%= room.name %>
<span class="float-right font-12 new_text_<%= room.id %>"> billed</span>
</div>
</div>
</div>
<% else %>
<% if room.get_checkout_booking.nil? %>
<div class="card rooms blue text-white table_<%= room.id %>" data-id="<%= room.id %>">
<div class="card rooms blue text-white table_<%= room.id %>" data-id="<%= room.id %>">
<% else %>
<div class="card rooms orange text-white table_<%= room.id %>" data-id="<%= room.id %>">
<div class="card rooms orange text-white table_<%= room.id %>" data-id="<%= room.id %>">
<% end %>
<div class="card-block">
<div class="card-block">
<%= room.name %>
<!-- <% if !@order_items_count.nil? %>
<% if @order_items_count.key?(room.id) %>
(Orders : <%= @order_items_count[room.id] %>)
<% end %>
<% end %> -->
<span class="float-right font-12 new_text_<%= room.id %>"> new</span>
</div>
</div>
@@ -147,22 +127,22 @@
<% @orders.each do |order| %>
<div class="card orders <%=(order.status=="new") ? 'blue' : 'red'%> text-white" data-id="<%= order.order_id %>">
<div class="card-block">
<%
order_status = ""
sale_order = order.sale_orders.first
if sale_order
unless sale_order.sale_id.nil?
sale = Sale.find(sale_order.sale_id)
order_status = sale.sale_status
if order_status == 'new'
order_status = order.status
end
end
else
order_status = order.status
end
%>
<%= order.order_id %> <% if !order_status.empty? %>| <%= order_status %> <% end %>
<% order_status = "" %>
<% sale_order = order.sale_orders.first %>
<% if sale_order %>
<% unless sale_order.sale_id.nil? %>
<% sale = Sale.find(sale_order.sale_id) %>
<% order_status = sale.sale_status %>
<% if order_status == 'new' %>
<% order_status = order.status %>
<% end %>
<% end %>
<% else %>
<% order_status = order.status %>
<% end %>
<%= order.order_id %>
<% if !order_status.empty? %>| <%= order_status %>
<% end %>
</div>
</div>
<% end %>
@@ -211,7 +191,13 @@
<!-- Column Two -->
<div class="col-lg-5 col-md-5 col-sm-5">
<div class="card">
<div class="card-header">
<% existing_class = "" %><% existing_order = false %>
<% if @status_sale == 'sale' && (!@order_items.nil?) %>
<% existing_class = "existing_invoice"%>
<% existing_order = true %>
<% tooltip = ' data-toggle=modal title=Add_To_Existing data-target=#invoiceModal'%>
<%end%>
<div class="card-header <%= existing_class %>" <%= tooltip %>>
<% if @status_order == 'order' && @status_sale != 'sale' %>
<% if !@obj_order.nil? %>
<div id="save_order_id" data-order="<%= @obj_order.order_id %>">
@@ -259,7 +245,6 @@
&nbsp; Order No: <span id="order_no">
<% if @status_order == 'order' %>
<%= @obj_order.order_id rescue '' %>
<% end %>
</span>
<br>
@@ -271,109 +256,84 @@
<% end %>
</div>
<div class="row p-l-5 p-r-5">
<div class="col-lg-6 col-md-6 col-sm-6">
<% if @status_sale == 'sale' %>
<p class="hidden customer-id"><%= @sale_array[0].customer_id rescue '' %></p>
&nbsp; Customer : <%= @sale_array[0].customer.name rescue '' %>
<% elsif @status_order == 'order'
%>
<p class="hidden customer-id"><%= @customer.customer_id rescue "" %></p>
&nbsp; Customer : <%= @customer.name rescue "" %>
<% end %>
</div>
<div class="col-lg-6 col-md-6 col-sm-6">
<% if @status_sale == 'sale' %>
<p class="hidden customer-id"><%= @sale_array[0].customer_id rescue '' %></p>
&nbsp; Customer : <%= @sale_array[0].customer.name rescue '' %>
<% elsif @status_order == 'order'
%>
<p class="hidden customer-id"><%= @customer.customer_id rescue "" %></p>
&nbsp; Customer : <%= @customer.name rescue "" %>
<% end %>
</div>
</div>
</div>
<div id="order-detail-slimscroll" data-height="<%= @status_sale=="sale" ? 200 : 160%>">
<div class="card-text" >
<table class="table table-striped" id="order-items-table">
<thead>
<tr>
<th>#</th>
<th class="item-name">Items</th>
<th class="item-attr">QTY
</th>
<th class="item-attr">Price
</th>
</tr>
<tr>
<th>#</th>
<th class="item-name">Items</th>
<th class="item-attr">QTY</th>
<th class="item-attr">Price</th>
</tr>
</thead>
<tbody>
<%
count = 0
<% count = 0
sub_total = 0
if @status_sale == "sale"
@sale_array[0].sale_items.each do |sale_item|
sub_total = sub_total + sale_item.price
%>
sub_total = sub_total + sale_item.price%>
<input type="hidden" id="sale_id" value="<%= @sale_array[0].sale_id %>">
<%
# Can't check for discount
# unless sale_item.price == 0
count += 1
%>
<%count += 1 %>
<tr>
<td><%= count %></td>
<td class='item-name'><%= sale_item.product_name %></td>
<td class='item-attr'><%= sale_item.qty %></td>
<td class='item-attr'><%= sale_item.price %></td>
</tr>
<%end %>
<% end %>
<% if @status_order == 'order' && @status_sale != 'sale'
unless @order_items.nil? || @order_items.empty?
count = 0
@order_items.each do |order_item|
set_item_prices = 0
count += 1
sub_total = sub_total + (order_item.price * order_item.qty)
# unless order_item.price == 0 %>
<tr class="<%= @edit_order_origami==true ? 'edit_order' : '' %>" data-id='<%= order_item.order_items_id %>'>
<td><%= count %></td>
<td class='item-name'><%= order_item.item_name %>
<% if !order_item.options.nil? && !order_item.options.empty? && order_item.options != "undefined" %>
<% JSON.parse(order_item.options).each do |option| %>
<br><span class="font-13"><%= option %></span>
<% end %>
<% end %>
<%
end
end
if @status_order == 'order' && @status_sale != 'sale'
puts
unless @order_items.nil? || @order_items.empty?
count = 0
@order_items.each do |order_item|
set_item_prices = 0
count += 1
sub_total = sub_total + (order_item.price * order_item.qty)
# unless order_item.price == 0 %>
<tr class="<%= @edit_order_origami==true ? 'edit_order' : '' %>" data-id='<%= order_item.order_items_id %>'>
<td><%= count %></td>
<td class='item-name'>
<%= order_item.item_name %>
<% if !order_item.options.nil? && !order_item.options.empty? && order_item.options != "undefined" %>
<% JSON.parse(order_item.options).each do |option| %>
<br><span class="font-13">
<%= option %>
</span>
<% if !order_item.set_menu_items.nil? && order_item.set_menu_items != '[]'
JSON.parse(order_item.set_menu_items).each do |item_instance|
set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f %>
<br>
<span class="font-13">
<%= item_instance["item_instance_name"] %>
<% if !item_instance["options"].nil? && !item_instance["options"].empty? %>
<% (item_instance["options"]).each do |set_item_option| %>
<br><span class="font-13"> <%= set_item_option %></span>
<% end %>
<% end %>
<% if !order_item.set_menu_items.nil? && order_item.set_menu_items != '[]'
JSON.parse(order_item.set_menu_items).each do |item_instance|
set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f %>
<br><span class="font-13">
<%= item_instance["item_instance_name"] %>
<% if !item_instance["options"].nil? && !item_instance["options"].empty? %>
<% (item_instance["options"]).each do |set_item_option| %>
<br><span class="font-13">
<%= set_item_option %>
</span>
<% end %>
<% end %>
</span>
<% end
sub_total += set_item_prices
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= (order_item.qty*order_item.price).to_f + set_item_prices %></td>
</tr>
<%
# end
end
end
end
%>
<% end %>
</span>
<% end
sub_total += set_item_prices
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= (order_item.qty*order_item.price).to_f + set_item_prices %></td>
</tr>
<% end %>
<% end %>
<% end %>
</tbody>
</table>
</div>
@@ -385,64 +345,60 @@
<td class="item-attr"><strong id="sub-total"><%= sub_total %></strong></td>
</tr>
<tr>
<%if @obj_sale != nil && @obj_sale.discount_type == 'member_discount'%>
<td class="charges-name"><strong>Member Discount:</strong></td>
<%else%>
<td class="charges-name"><strong>Discount:</strong></td>
<%end%>
<%if @obj_sale != nil && @obj_sale.discount_type == 'member_discount'%>
<td class="charges-name"><strong>Member Discount:</strong></td>
<%else%>
<td class="charges-name"><strong>Discount:</strong></td>
<%end%>
<td class="item-attr"><strong id="order-discount">(<%= @obj_sale.total_discount rescue 0%>)</strong></td>
</tr>
<td class="item-attr"><strong id="order-discount">(<%= @obj_sale.total_discount rescue 0%>)</strong></td>
</tr>
<% if @status_sale == "sale" %>
<tr>
<td class="charges-name"><strong>
<% if !@sale_taxes.empty? %>
Tax:
(<% @i = 0
@sale_taxes.each do |ct| %>
<%=ct.tax_name%>
<% if @sale_taxes.count != @i+1%>
+ <% @i =+1 %>
<%end%>
<%end %>)
<% else %>
No Tax
<% end %></strong><br>
<%if !@webview %>
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
<% end %>
</td>
<td class="item-attr"><strong id="order-Tax"><%= @obj_sale.total_tax rescue 0%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Rounding Adj:</strong></td>
<td class="item-attr"><strong id="order-round-adj"><%= @obj_sale.rounding_adjustment rescue 0%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Grand Total:</strong></td>
<td class="item-attr"><strong id="order-grand-total"><%= @obj_sale.grand_total rescue 0%></strong></td>
</tr>
<% end %>
<td class="charges-name"><strong>
<% if !@sale_taxes.empty? %>
Tax:
(<% @i = 0
@sale_taxes.each do |ct| %>
<%=ct.tax_name%>
<% if @sale_taxes.count != @i+1%>
+ <% @i =+1 %>
<%end%>
<%end %>)
<% else %>
No Tax
<% end %></strong><br>
<%if !@webview %>
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
<% end %>
</td>
<td class="item-attr"><strong id="order-Tax"><%= @obj_sale.total_tax rescue 0%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Rounding Adj:</strong></td>
<td class="item-attr"><strong id="order-round-adj"><%= @obj_sale.rounding_adjustment rescue 0%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Grand Total:</strong></td>
<td class="item-attr"><strong id="order-grand-total"><%= @obj_sale.grand_total rescue 0%></strong></td>
</tr>
<% end %>
<tr class="rebate_amount"></tr>
</table>
</div>
</table>
</div>
<%
if @status_sale == 'sale'
unless @order_items.nil? || @order_items.empty?
%>
Pending New Order
<table class="table table-striped">
<%
count = 0
@order_items.each do |order_item|
set_item_prices = 0
count += 1
%>
<tr class="<%= @edit_order_origami==true ? 'edit_order' : '' %>" data-id='<%= order_item.order_items_id %>'>
<td><%= count %>
<td class='item-name'>
<%= order_item.item_name %>
<% if @status_sale == 'sale'
unless @order_items.nil? || @order_items.empty?%>
<!-- Pending New Order
<table class="table table-striped">
<% count = 0
@order_items.each do |order_item|
set_item_prices = 0
count += 1 %>
<tr class="<%= @edit_order_origami==true ? 'edit_order' : '' %>" data-id='<%= order_item.order_items_id %>'>
<td><%= count %>
<td class='item-name'>
<%= order_item.item_name %>
<% if !order_item.options.nil? && !order_item.options.empty? && order_item.options != "undefined" %>
<% JSON.parse(order_item.options).each do |option| %>
<br><span class="font-13">
@@ -475,9 +431,9 @@
<%
end
%>
</table>
</table> -->
<button class='btn btn-primary btn-block waves-effect' id='add_invoice'> Add to existing invoice</button>
<!-- <button class='btn btn-primary btn-block waves-effect' id='add_invoice'> Add to existing invoice</button> -->
<% end %>
<% if @sale_array.size > 1 %>
<br><br>
@@ -486,24 +442,21 @@
<% @sale_array.each do |sale|
if @sale_array.size > 1
unless sale.receipt_no == @sale_array[0].receipt_no
%>
<table class="table table-striped">
<tr>
<td>Receipt No - <%= sale.receipt_no %></td>
<td>
<button class='btn btn-sm btn-primary invoicedetails' id="<%= sale.sale_id %>">Show
%>
<table class="table table-striped">
<tr>
<td>Receipt No - <%= sale.receipt_no %></td>
<td>
<button class='btn btn-sm btn-primary invoicedetails' id="<%= sale.sale_id %>">Show
Detail
</button>
</td>
</tr>
</table>
<%
end
end
end
end
%>
</button>
</td>
</tr>
</table>
<%end%>
<% end%>
<% end%>
<%end %>
</div>
</div>
</div>
@@ -568,12 +521,12 @@
<!-- first bill not used in cloud -->
<%if @membership.discount && @obj_sale.customer.membership_id %>
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#paymentModal">First Bill</button>
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#paymentModal" data-order="<%= existing_order %>">First Bill</button>
<%else%>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<button type="button" id="first_bill" data-order="<%= existing_order %>" class="btn btn-block bg-blue waves-effect">First Bill</button>
<%end%>
<button type="button" id="pay" class="btn btn-block bg-blue waves-effect">Pay</button>
<button type="button" id="pay" data-order="<%= existing_order %>" class="btn btn-block bg-blue waves-effect">Pay</button>
<!--<% if current_login_employee.role != "waiter" %>
<button type="button" class="btn action-btn bg-blue waves-effect" data-toggle="modal" data-target="#waste_spoileModal" > Waste & Spoile</button>
@@ -679,6 +632,84 @@
</div>
</div>
<% if @status_sale == 'sale' && (!@order_items.nil?) %>
<div class="modal fade" id="invoiceModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="invoiceModalLabel">Pending New Order</h4>
</div>
<div class="modal-body">
<div class="card">
<div id="pending-order-slimscroll" data-height="160">
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th class="item-name">Items</th>
<th class="item-attr">QTY</th>
<th class="item-attr">Price</th>
</tr>
</thead>
<tbody>
<% count = 0
@order_items.each do |order_item|
set_item_prices = 0
count += 1 %>
<tr class="<%= @edit_order_origami==true ? 'edit_order' : '' %>" data-id='<%= order_item.order_items_id %>'>
<td><%= count %></td>
<td class='item-name'>
<%= order_item.item_name %>
<% if !order_item.options.nil? && !order_item.options.empty? && order_item.options != "undefined" %>
<% JSON.parse(order_item.options).each do |option| %>
<br><span class="font-13">
<%= option %>
</span>
<% end %>
<% end %>
<% if !order_item.set_menu_items.nil?
JSON.parse(order_item.set_menu_items).each do |item_instance|
set_item_prices += (item_instance["quantity"].to_f * item_instance["price"].to_f).to_f
%>
<br><span class="font-13">
<%= item_instance["item_instance_name"] %>
<% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %>
<% (item_instance["options"]).each do |set_item_option| %>
<br><span class="font-13">
<%= set_item_option %>
</span>
<% end %>
<% end %>
</span>
<% end
sub_total += set_item_prices
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= (order_item.qty*order_item.price).to_f + set_item_prices %></td>
</tr>
<%end %>
</tbody>
</table>
</div>
</div>
</div>
<div class="modal-footer ">
<div class="row p-r-20">
<div class="col-md-9">
<button class='btn btn-link bg-blue waves-effect' data-dismiss="modal" id='add_invoice'> Add to existing invoice</button>
</div>
<div class="col-md-3">
<button type="button" class="btn btn-link bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
</div>
</div>
</div>
</div>
</div>
</div>
<%end%>
<!-- change tax modal -->
<div class="modal fade" id="change_taxModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-md" role="document">
@@ -993,7 +1024,24 @@
$('#pay').on('click', function () {
var sale_id = $('#sale_id').val();
window.location.href = '/origami/sale/' + sale_id + "/cashier/payment";
var data_order = $(this).data("order");
if (data_order) {
swal({
title: "Alert! This Receipt has another item",
text: "Are you sure want to pay this receipt !",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, Pay it !",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
window.location.href = '/origami/sale/' + sale_id + "/cashier/payment";
}
});
}else{
window.location.href = '/origami/sale/' + sale_id + "/cashier/payment";
}
});
// Bill Request