diff --git a/app/assets/javascripts/custom.js b/app/assets/javascripts/custom.js index 64835a3b..005d6c6a 100644 --- a/app/assets/javascripts/custom.js +++ b/app/assets/javascripts/custom.js @@ -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'); diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index ada129dc..6d784645 100755 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -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; + } \ No newline at end of file diff --git a/app/models/ability.rb b/app/models/ability.rb index 7a341ed2..982d669a 100755 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -246,6 +246,7 @@ class Ability can :move_dining, :moveroom + can :manage, Sale can :manage, Customer can :manage, DiningQueue diff --git a/app/models/sale.rb b/app/models/sale.rb index c90a5857..5120605f 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -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() diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index d6dad83f..a0915c98 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -51,38 +51,28 @@ <% else %>
<% end %> -
- <%= table.name %> - - billed -
+
+ <%= table.name %> + billed +
+
-
<% else %> <% if table.get_checkout_booking.nil? %>
<% else %>
<% end %> -
- <%= table.name %> - - new +
+ <%= table.name %> + new +
-
<% end %> <% else %>
-
- <%= table.name %> +
+ <%= table.name %> new
@@ -98,33 +88,23 @@ <% if room.status == 'occupied' %> <% if room.get_booking.nil? %> <% if room.get_checkout_booking.nil? %> -
+
<% else %> -
+
<% end %> -
- <%= room.name %> - - billed +
+ <%= room.name %> + billed +
-
<% else %> <% if room.get_checkout_booking.nil? %> -
+
<% else %> -
+
<% end %> -
+
<%= room.name %> - new
@@ -147,22 +127,22 @@ <% @orders.each do |order| %>
text-white" data-id="<%= order.order_id %>">
- <% - 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 %>
<% end %> @@ -211,7 +191,13 @@
-
+ <% 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%> +
> <% if @status_order == 'order' && @status_sale != 'sale' %> <% if !@obj_order.nil? %>
@@ -259,7 +245,6 @@   Order No: <% if @status_order == 'order' %> <%= @obj_order.order_id rescue '' %> - <% end %>
@@ -271,109 +256,84 @@ <% end %>
-
- - <% if @status_sale == 'sale' %> - -   Customer : <%= @sale_array[0].customer.name rescue '' %> - <% elsif @status_order == 'order' - %> - -   Customer : <%= @customer.name rescue "" %> - <% end %> - -
+
+ <% if @status_sale == 'sale' %> + +   Customer : <%= @sale_array[0].customer.name rescue '' %> + <% elsif @status_order == 'order' + %> + +   Customer : <%= @customer.name rescue "" %> + <% end %> +
">
- - - - - - - + + + + + + - <% - 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%> - <% - # Can't check for discount - # unless sale_item.price == 0 - count += 1 - %> + <%count += 1 %> + <%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 %> + + + - - - - - - <% - - # end - end - end - end - %> + <% end %> + + <% end + sub_total += set_item_prices + end %> + + + + + <% end %> + <% end %> + <% end %>
#ItemsQTY - Price -
#ItemsQTYPrice
<%= count %> <%= sale_item.product_name %> <%= sale_item.qty %> <%= sale_item.price %>
<%= count %><%= 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| %> +
<%= option %> + <% 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 %> -
<%= count %> - <%= 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| %> -
- <%= option %> - + <% 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 %> +
+ + <%= item_instance["item_instance_name"] %> + <% if !item_instance["options"].nil? && !item_instance["options"].empty? %> + <% (item_instance["options"]).each do |set_item_option| %> +
<%= set_item_option %> <% 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 %> -
- <%= item_instance["item_instance_name"] %> - <% if !item_instance["options"].nil? && !item_instance["options"].empty? %> - <% (item_instance["options"]).each do |set_item_option| %> -
- <%= set_item_option %> - - <% end %> - <% end %> -
- <% end - sub_total += set_item_prices - end %> -
<%= order_item.qty %><%= (order_item.qty*order_item.price).to_f + set_item_prices %>
<%= order_item.qty %><%= (order_item.qty*order_item.price).to_f + set_item_prices %>
@@ -385,64 +345,60 @@ <%= sub_total %> - <%if @obj_sale != nil && @obj_sale.discount_type == 'member_discount'%> - Member Discount: - <%else%> - Discount: - <%end%> + <%if @obj_sale != nil && @obj_sale.discount_type == 'member_discount'%> + Member Discount: + <%else%> + Discount: + <%end%> - (<%= @obj_sale.total_discount rescue 0%>) - + (<%= @obj_sale.total_discount rescue 0%>) + <% if @status_sale == "sale" %> - - - <% 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 %>
- <%if !@webview %> - - <% end %> - - <%= @obj_sale.total_tax rescue 0%> - - Rounding Adj: - <%= @obj_sale.rounding_adjustment rescue 0%> - - - Grand Total: - <%= @obj_sale.grand_total rescue 0%> - - <% end %> + + <% 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 %>
+ <%if !@webview %> + + <% end %> + + <%= @obj_sale.total_tax rescue 0%> + + + Rounding Adj: + <%= @obj_sale.rounding_adjustment rescue 0%> + + + Grand Total: + <%= @obj_sale.grand_total rescue 0%> + + <% end %> - -
+ +
- <% - if @status_sale == 'sale' - unless @order_items.nil? || @order_items.empty? - %> - Pending New Order - - <% - count = 0 - @order_items.each do |order_item| - set_item_prices = 0 - count += 1 - %> - -
<%= count %> - - <%= order_item.item_name %> + <% if @status_sale == 'sale' + unless @order_items.nil? || @order_items.empty?%> + - + <% end %> <% if @sale_array.size > 1 %>

@@ -486,24 +442,21 @@ <% @sale_array.each do |sale| if @sale_array.size > 1 unless sale.receipt_no == @sale_array[0].receipt_no - %> - - - - - + +
Receipt No - <%= sale.receipt_no %> - +
+ <%end%> + <% end%> + <% end%> + <%end %> @@ -568,12 +521,12 @@ <%if @membership.discount && @obj_sale.customer.membership_id %> - + <%else%> - + <%end%> - +