From 6ae0959602d9e7faf95d04dee5e7004810d4be03 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 13 Jul 2018 11:34:24 +0630 Subject: [PATCH] update existin order --- app/assets/stylesheets/origami.scss | 2 +- app/models/ability.rb | 1 + app/models/sale.rb | 64 ++++++++++++++-------------- app/views/origami/home/show.html.erb | 28 +++++++++--- 4 files changed, 57 insertions(+), 38 deletions(-) diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 91708815..6d784645 100755 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -521,7 +521,7 @@ nav.pagination .page a:hover, -moz-opacity: 1; /* mozilla */ } .existing_invoice{ - background-color:#009688; + 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 0dcd5d34..d2d546cb 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1323,7 +1323,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") @@ -1378,7 +1378,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") @@ -1422,7 +1422,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) @@ -1452,7 +1452,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')") @@ -1483,7 +1483,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? @@ -1516,7 +1516,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}'") @@ -1545,7 +1545,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 @@ -1566,7 +1566,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) @@ -1591,7 +1591,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") @@ -1622,7 +1622,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") @@ -1651,7 +1651,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") @@ -1682,7 +1682,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") @@ -1711,7 +1711,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) @@ -1742,7 +1742,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() @@ -1771,7 +1771,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) @@ -1802,7 +1802,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") @@ -1843,7 +1843,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' @@ -1956,7 +1956,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") @@ -2025,7 +2025,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") @@ -2057,7 +2057,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) @@ -2088,7 +2088,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? @@ -2120,7 +2120,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) @@ -2152,7 +2152,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") @@ -2187,7 +2187,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") @@ -2219,7 +2219,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") @@ -2249,7 +2249,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") @@ -2280,7 +2280,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? @@ -2312,7 +2312,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) @@ -2344,7 +2344,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? @@ -2380,7 +2380,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) @@ -2414,7 +2414,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) @@ -2443,7 +2443,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 345d089d..4b8a7205 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -154,9 +154,10 @@
- <% existing_class = "" %> + <% 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%>
> @@ -483,12 +484,12 @@ <%if @membership.discount && @obj_sale.customer.membership_id %> - + <%else%> - + <%end%> - +