From 2d05886be4a6836a1e3e94a70982247283faeab8 Mon Sep 17 00:00:00 2001 From: phyusin Date: Wed, 4 Jul 2018 18:46:13 +0630 Subject: [PATCH] UI for credit payment --- app/assets/javascripts/origami.js | 97 +- .../origami/credit_sales_controller.rb | 25 + .../origami/dashboard_controller.rb | 11 + app/controllers/origami/home_controller.rb | 3 +- app/controllers/origami/orders_controller.rb | 72 +- app/controllers/origami/rooms_controller.rb | 2 +- app/controllers/origami/sales_controller.rb | 12 +- app/models/sale.rb | 24 +- app/views/origami/credit_sales/show.html.erb | 360 +++ app/views/origami/home/index.html.erb | 409 ++-- app/views/origami/home/show.html.erb | 2094 +++++++++-------- app/views/origami/orders/show.html.erb | 71 +- app/views/origami/rooms/show.html.erb | 50 + app/views/origami/sales/show.html.erb | 53 + config/routes.rb | 5 +- 15 files changed, 2017 insertions(+), 1271 deletions(-) create mode 100644 app/controllers/origami/credit_sales_controller.rb create mode 100755 app/views/origami/credit_sales/show.html.erb diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index de92d994..3e11666d 100755 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -63,10 +63,8 @@ $(document).on('turbolinks:load', function() { ' {caption}\n' + '\n', } - }); -}); + }); -$(document).on('turbolinks:load', function() { $('.datetimepicker').bootstrapMaterialDatePicker({ format: 'DD-MM-YYYY - HH:mm', clearButton: true, @@ -228,6 +226,11 @@ $(document).on('turbolinks:load', function() { return false; } }); + + $(document).on("click", ".credit_detail",function(){ + var sale_payment_id = $(this).attr("data-id"); + window.location.href = "/origami/cashier/credit_sales/"+sale_payment_id; + }); }); /* start check first bill or not funs: */ @@ -480,4 +483,90 @@ function getAllMenu(){ } } }); -} \ No newline at end of file +} + +/* String format */ +if (!String.prototype.formatUnicorn) { + String.prototype.formatUnicorn=function(){ + var e=this.toString(); + if(!arguments.length){ + return e; + } + var t=typeof arguments[0],n="string"==t||"number"==t?Array.prototype.slice.call(arguments):arguments[0]; + for(var i in n){ + e=e.replace(new RegExp("\\{"+i+"\\}","gi"),n[i]==null?'':n[i]); + } + return e; + }; +} +/* String format */ + +//credit sales lists +function timeFormat(date){ + var isPM = date.getHours() >= 12; + var isMidday = date.getHours() == 12; + var time = [(date.getHours()>10? date.getHours() : '0'+date.getHours()) - (isPM && !isMidday ? 12 : 0), + (date.getMinutes()>10? date.getMinutes() : '0'+date.getMinutes()) || '00'].join(':') + + (isPM ? ' PM' : ' AM'); + return time; +} + +function getCreditData(){ + var filter = $("#filter").val(); + var customer = $("#sel_customer").val(); + + var receipt_no = ""; + var customer_id = ""; + if((filter!=undefined) && (filter!=null) && (filter!="")){ + receipt_no = filter; + } + if((customer!=undefined) && (customer!=null) && (customer!="")){ + customer_id = customer; + } + getCreditSales(receipt_no, customer_id); +} + +function getCreditSales(filter, customer){ + $(".tbd_credit_lists").empty(); + var html_credit_items = $("#html_credit_items").html(); + var receipt_no = ""; + var customer_id = ""; + if((filter!=undefined) && (filter!=null) && (filter!="")){ + receipt_no = filter; + } + if((customer!=undefined) && (customer!=null) && (customer!="")){ + customer_id = customer; + } + $.ajax({ + type: "POST", + data: {receipt_no: receipt_no, customer_id: customer_id}, + dataType: 'json', + url: "/origami/cashier/credit_sales", + success: function(data){ + // console.log(data); + if(data.status){ + var credit_sales = data.data; + // console.log(credit_sales); + if(credit_sales.length > 0){ + for (var i = 0; i < credit_sales.length ; i++) { + var sale_date = new Date(credit_sales[i].sale_date); + var receipt_date = sale_date.getFullYear() +'-'+ (sale_date.getMonth() > 10 ? sale_date.getMonth() : '0' + sale_date.getMonth()) +'-'+ (sale_date.getDate() > 10 ? sale_date.getDate() : '0' + sale_date.getDate()); + $('.tbd_credit_lists').append(html_credit_items.formatUnicorn({ + 'key':i, + 'sale_payment_id':credit_sales[i].sale_payment_id, + 'receipt_date':receipt_date +" "+timeFormat(sale_date), + 'receipt_no':credit_sales[i].receipt_no, + 'cashier_name':credit_sales[i].cashier_name, + 'customer_name':credit_sales[i].customer_name, + 'credit_amount':credit_sales[i].payment_amount + })); + } + } + }else{ + $(".credit_items").empty(); + $(".tbd_credit_lists").html(data.message); + } + } + }); +} +//End of credit sales function \ No newline at end of file diff --git a/app/controllers/origami/credit_sales_controller.rb b/app/controllers/origami/credit_sales_controller.rb new file mode 100644 index 00000000..97f1d38c --- /dev/null +++ b/app/controllers/origami/credit_sales_controller.rb @@ -0,0 +1,25 @@ +class Origami::CreditSalesController < BaseOrigamiController + def show + @webview = false + if check_mobile + @webview = true + end + + @tables = Table.unscoped.all.active.order('status desc') + @rooms = Room.unscoped.all.active.order('status desc') + @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) + @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @customers = Customer.pluck("customer_id, name") + + sale_payment = SalePayment.find_by_sale_payment_id(params[:sale_payment_id]) + @sale = Sale.find_by_sale_id(sale_payment.sale_id) + @sale_taxes = [] + sale_taxes = SaleTax.where("sale_id = ?", @sale.sale_id) + if !sale_taxes.empty? + sale_taxes.each do |sale_tax| + @sale_taxes.push(sale_tax) + end + end + end + +end diff --git a/app/controllers/origami/dashboard_controller.rb b/app/controllers/origami/dashboard_controller.rb index af182356..c2c77384 100644 --- a/app/controllers/origami/dashboard_controller.rb +++ b/app/controllers/origami/dashboard_controller.rb @@ -91,4 +91,15 @@ def get_all_menu @menus = Menu.all end +def get_credit_sales + credit_sales = Sale.get_credit_sales(params) + if !credit_sales.nil? + result = {:status=> true, :data=> credit_sales } + else + result = {:status=> false, :message=>"There is no record." } + end + + render :json => result.to_json +end + end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 2d03d298..799d6c28 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -9,7 +9,7 @@ class Origami::HomeController < BaseOrigamiController @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @shop = Shop.first - + @customers = Customer.pluck("customer_id, name") # @shift = ShiftSale.current_open_shift(current_user.id) end @@ -21,6 +21,7 @@ class Origami::HomeController < BaseOrigamiController @rooms = Room.unscoped.all.active.order('status desc') @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @customers = Customer.pluck("customer_id, name") @status_order = "" @status_sale = "" diff --git a/app/controllers/origami/orders_controller.rb b/app/controllers/origami/orders_controller.rb index c6048404..5f34d9a3 100755 --- a/app/controllers/origami/orders_controller.rb +++ b/app/controllers/origami/orders_controller.rb @@ -5,10 +5,10 @@ class Origami::OrdersController < BaseOrigamiController @webview = true end - @tables = Table.all.active.order('status desc') - @rooms = Room.all.active.order('status desc') + @tables = Table.unscoped.all.active.order('status desc') + @rooms = Room.unscoped.all.active.order('status desc') @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) - @orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @order = Order.find(params[:order_id]) booking = Booking.select('bookings.booking_id, bookings.dining_facility_id') .joins(" JOIN booking_orders as bo on bo.booking_id = bookings.booking_id") @@ -24,7 +24,7 @@ class Origami::OrdersController < BaseOrigamiController end end - + @customers = Customer.pluck("customer_id, name") #for split bill lookup_spit_bill = Lookup.collection_of('split_bill') @split_bill = 0 @@ -52,38 +52,38 @@ class Origami::OrdersController < BaseOrigamiController @order.order_items[order_item_index].set_menu_items = arr_instance_item_sets end end - - bookings = Booking.all - if !bookings.today.nil? - @order_items_count = Hash.new - bookings.each do |booking| - if booking.sale_id.nil? && booking.booking_status != 'moved' - if !booking.booking_orders.empty? - booking.booking_orders.each do |booking_order| - order = Order.find(booking_order.order_id) - if !order.order_items.empty? - if !@order_items_count.key?(booking.dining_facility_id) - @order_items_count.store(booking.dining_facility_id, order.order_items.count) - else - @order_items_count[booking.dining_facility_id] += order.order_items.count - end - end - end - end - else - if !booking.sale_id.nil? - sale = Sale.find(booking.sale_id) - if sale.sale_status !='completed' - if !@order_items_count.key?(booking.dining_facility_id) - @order_items_count.store(booking.dining_facility_id, sale.sale_items.count) - else - @order_items_count[booking.dining_facility_id] = sale.sale_items.count - end - end - end - end - end - end + + # bookings = Booking.all + # if !bookings.today.nil? + # @order_items_count = Hash.new + # bookings.each do |booking| + # if booking.sale_id.nil? && booking.booking_status != 'moved' + # if !booking.booking_orders.empty? + # booking.booking_orders.each do |booking_order| + # order = Order.find(booking_order.order_id) + # if !order.order_items.empty? + # if !@order_items_count.key?(booking.dining_facility_id) + # @order_items_count.store(booking.dining_facility_id, order.order_items.count) + # else + # @order_items_count[booking.dining_facility_id] += order.order_items.count + # end + # end + # end + # end + # else + # if !booking.sale_id.nil? + # sale = Sale.find(booking.sale_id) + # if sale.sale_status !='completed' + # if !@order_items_count.key?(booking.dining_facility_id) + # @order_items_count.store(booking.dining_facility_id, sale.sale_items.count) + # else + # @order_items_count[booking.dining_facility_id] = sale.sale_items.count + # end + # end + # end + # end + # end + # end end end diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 49b7ce14..54c67776 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -21,7 +21,7 @@ class Origami::RoomsController < BaseOrigamiController @rooms = Room.unscoped.all.active.order('status desc') @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') - + @customers = Customer.pluck("customer_id, name") @room = DiningFacility.find(params[:room_id]) @status_order = "" diff --git a/app/controllers/origami/sales_controller.rb b/app/controllers/origami/sales_controller.rb index 63a7a34b..9cb28815 100755 --- a/app/controllers/origami/sales_controller.rb +++ b/app/controllers/origami/sales_controller.rb @@ -1,9 +1,15 @@ class Origami::SalesController < BaseOrigamiController def show - @tables = Table.all.active.order('status desc') - @rooms = Room.all.active.order('status desc') + @webview = false + if check_mobile + @webview = true + end + + @tables = Table.unscoped.all.active.order('status desc') + @rooms = Room.unscoped.all.active.order('status desc') @complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d')) - @orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @customers = Customer.pluck("customer_id, name") @sale = Sale.find(params[:sale_id]) @order = SaleOrder.find_by_sale_id(@sale.sale_id).order_id @booking = BookingOrder.find_by_order_id(@order).booking_id diff --git a/app/models/sale.rb b/app/models/sale.rb index 33c7f1b6..f8c28351 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -2566,7 +2566,29 @@ def self.all_receipt_details return query end - private +def self.get_credit_sales(params) + receipt_no = "" + customer = "" + if !params["receipt_no"].blank? + receipt_no = " and s.receipt_no LIKE '%#{params["receipt_no"]}%'" + end + + if !params["customer_id"].blank? + customer = " and s.customer_id = '#{params["customer_id"]}'" + end + + query = SalePayment.select("s.receipt_no, sale_payments.sale_payment_id, sale_payments.payment_method, sale_payments.payment_amount,s.receipt_date as sale_date, + s.cashier_name as cashier_name, c.name as customer_name") + .joins("INNER JOIN sales s ON s.sale_id = sale_payments.sale_id") + .joins("INNER JOIN customers c ON c.customer_id = s.customer_id") + + query = query.where("payment_method='creditnote' and s.sale_status = 'completed' #{receipt_no} #{customer}") + .order("s.receipt_date ASC, s.receipt_no ASC") + + return query +end + +private def generate_custom_id self.sale_id = SeedGenerator.generate_id(self.class.name, "SAL") diff --git a/app/views/origami/credit_sales/show.html.erb b/app/views/origami/credit_sales/show.html.erb new file mode 100755 index 00000000..c374e75d --- /dev/null +++ b/app/views/origami/credit_sales/show.html.erb @@ -0,0 +1,360 @@ + +
+ +
+ + + + +
+
+ +
+
+ <% @complete.each do |sale| %> +
+
+ <%= sale.receipt_no %><%= sale.sale_status %> +
+
+ <% end %> +
+
+ + +
+
+ <% @tables.each do |table| %> + <% if table.status == 'occupied' %> + <% if table.get_booking.nil? %> + <% if table.get_checkout_booking.nil? %> +
+ <% else %> +
+ <% end %> +
+ <%= table.name %> + <% if !@order_items_count.nil? %> + <% if @order_items_count.key?(table.id) %> + (Orders : <%= @order_items_count[table.id] %>) + <% end %> + <% end %> + billed +
+
+
+ <% else %> + <% if table.get_checkout_booking.nil? %> +
+ <% else %> +
+ <% end %> +
+ <%= table.name %> + <% if !@order_items_count.nil? %> + <% if @order_items_count.key?(table.id) %> + (Orders : <%= @order_items_count[table.id] %>) + <% end %> + <% end %> + new +
+
+ <% end %> + <% else %> +
+
+ <%= table.name %> + new +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @rooms.each do |room| %> + <% if room.status == 'occupied' %> + <% if room.get_booking.nil? %> +
+
+ <%= room.name %> + <% if !@order_items_count.nil? %> + <% if @order_items_count.key?(room.id) %> + (Orders : <%= @order_items_count[room.id] %>) + <% end %> + <% end %> + billed +
+
+ <% else %> +
+
+ <%= room.name %> + <% if !@order_items_count.nil? %> + <% if @order_items_count.key?(room.id) %> + (Orders : <%= @order_items_count[room.id] %>) + <% end %> + <% end %> + new +
+
+ <% end %> + <% else %> +
+
+ <%= room.name %> + +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @orders.each do |order| %> +
text-white" data-id = "<%= order.order_id %>"> +
+ <% + order_status = "" + sale_order = SaleOrder.find_by_order_id(order) + 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 %> +
+
+ + +
+
+
+
+ +
+
+ +
+
+
+ + + + + + + + + +
<%= t :credit %> <%= t :sale %> <%= t("views.right_panel.detail.date") %><%= t("views.right_panel.detail.receipt_no") %> <%= t :cashier %> <%= t("views.right_panel.detail.name") %> <%= t :customer %> <%= t("views.right_panel.detail.name") %> <%= t("views.right_panel.detail.credit_amount") %>
+
+
+
+ +
+
+ +
+ + +
+
+
+
SALE DETAILS
+
+
+
+
+ Receipt No: <%= @sale.receipt_no %> + +
+
+ Date: <%= @sale.receipt_date.utc.getlocal.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%> +
+
+
+
+ Customer : +
+ +
+
+
+ + + + + + + + + + <% + sub_total = 0 + @sale.sale_items.each do |sale_item| + sub_total = sub_total + sale_item.price + %> + <% unless sale_item.price <= 0 %> + + + + + + <% + end + end + %> + +
ItemsQTYPrice
<%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
+
+
+ +
+
+
+ + +
+ + +
+
+
+ + + + + + diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 3e565ffa..7ad5cf0f 100755 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -1,196 +1,245 @@
- -
- -
+ +
+ +
- - - + + + -
- -
-
- <% @complete.each do |sale| %> -
-
+
+ +
+
+ <% @complete.each do |sale| %> +
+
<%= sale.receipt_no %> - <%= sale.sale_status %> -
-
- <% end %> -
-
- - -
-
- <% @tables.each do |table| %> - <% if table.status == 'occupied' %> - <% if table.get_booking.nil? %> - <% if table.get_checkout_booking.nil? %> -
- <% else %> -
- <% end %> -
- Table <%= table.name %> ( <%= table.seater %> Seat )
- Zone <%= table.zone_id %> -
-
- <% else %> - <% if table.get_checkout_booking.nil? %> -
- <% else %> -
- <% end %> -
- Table <%= table.name %> ( <%= table.seater %> Seat )
- Zone <%= table.zone_id %> -
-
- <% end %> - <% else %> -
-
- Table <%= table.name %> ( <%= table.seater %> Seat )
- Zone <%= table.zone_id %> -
-
- <% end %> - <% end %> -
-
- - -
-
- <% @rooms.each do |room| %> - <% if room.status == 'occupied' %> - <% if room.get_booking.nil? %> -
- <% else %> -
- <% end %> -
- <%= room.name %> -
-
- <% else %> -
-
- <%= room.name %> -
-
- <% end %> - <% end %> -
-
- - -
-
- <% @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 %> + <%= sale.sale_status %>
- <% end %> + <% end %> +
+
+ + +
+
+ <% @tables.each do |table| %> + <% if table.status == 'occupied' %> + <% if table.get_booking.nil? %> + <% if table.get_checkout_booking.nil? %> +
+ <% else %> +
+ <% end %> +
+ Table <%= table.name %> ( <%= table.seater %> Seat )
+ Zone <%= table.zone_id %> +
+
+ <% else %> + <% if table.get_checkout_booking.nil? %> +
+ <% else %> +
+ <% end %> +
+ Table <%= table.name %> ( <%= table.seater %> Seat )
+ Zone <%= table.zone_id %> +
+
+ <% end %> + <% else %> +
+
+ Table <%= table.name %> ( <%= table.seater %> Seat )
+ Zone <%= table.zone_id %> +
+
+ <% end %> + <% end %> +
-
-
- -
-
- - - <%if current_login_employee.role == "administrator" || current_login_employee.role == "manager" %> + +
+
+ <% @rooms.each do |room| %> + <% if room.status == 'occupied' %> + <% if room.get_booking.nil? %> +
+ <% else %> +
+ <% end %> +
+ <%= room.name %> +
+
+ <% else %> +
+
+ <%= room.name %> +
+
+ <% end %> + <% end %> +
+
+ + +
+
+ <% @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 %> +
+
+ <% end %> +
+
+ + +
+
+
+
+ +
+
+ +
+
+
+ + + + + + + + + +
<%= t :credit %> <%= t :sale %> <%= t("views.right_panel.detail.date") %><%= t("views.right_panel.detail.receipt_no") %> <%= t :cashier %> <%= t("views.right_panel.detail.name") %> <%= t :customer %> <%= t("views.right_panel.detail.name") %> <%= t("views.right_panel.detail.credit_amount") %>
+
+
+
+
+ +
+
+ + +<%if current_login_employee.role == "administrator" || current_login_employee.role == "manager" %> - <%end%> - <%if current_login_employee.role != "waiter" %> - - - + --> + <%end%> + <%if current_login_employee.role != "waiter" %> + + + + + + <%end%> +
+
+
+ + + + - - <%end%> -
-
-
- diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 11057247..79aa367e 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -16,845 +16,895 @@ - - - -
-
- -
-
- <% @complete.each do |sale| %> -
-
- <%= sale.receipt_no %> - <%= sale.sale_status %> -
-
- <% end %> + + + + +
+
+ +
+
+ <% @complete.each do |sale| %> +
+
+ <%= sale.receipt_no %> + <%= sale.sale_status %> +
+ <% end %>
+
- -
-
- <% @tables.each do |table| %> - <% if table.status == 'occupied' %> - <% if table.get_booking.nil? %> - <% if table.get_checkout_booking.nil? %> -
- <% else %> -
- <% end %> -
- <%= table.name %> + +
+
+ <% @tables.each do |table| %> + <% if table.status == 'occupied' %> + <% if table.get_booking.nil? %> + <% if table.get_checkout_booking.nil? %> +
+ <% else %> +
+ <% end %> +
+ <%= table.name %> - billed -
+ <% end %> --> + billed +
+
-
- <% else %> - <% if table.get_checkout_booking.nil? %> + <% else %> + <% if table.get_checkout_booking.nil? %>
- <% else %> -
- <% end %> -
- <%= table.name %> + <% else %> +
+ <% end %> +
+ <%= table.name %> - new + <% end %> --> + new +
-
- <% end %> - <% else %> -
-
- <%= table.name %> - new + <% end %> + <% else %> +
+
+ <%= table.name %> + new +
+
+ <% end %> + <% end %>
- <% end %> - <% end %> -
-
- -
-
- <% @rooms.each do |room| %> - <% if room.status == 'occupied' %> - <% if room.get_booking.nil? %> - <% if room.get_checkout_booking.nil? %> -
- <% else %> -
- <% end %> -
- <%= room.name %> + +
+
+ <% @rooms.each do |room| %> + <% if room.status == 'occupied' %> + <% if room.get_booking.nil? %> + <% if room.get_checkout_booking.nil? %> +
+ <% else %> +
+ <% end %> +
+ <%= room.name %> - billed + <% end %> --> + billed +
-
- <% else %> - <% if room.get_checkout_booking.nil? %> -
- <% else %> -
- <% end %> -
- <%= room.name %> + <% else %> + <% if room.get_checkout_booking.nil? %> +
+ <% else %> +
+ <% end %> +
+ <%= room.name %> - new + <% end %> --> + new +
+
+ <% end %> + <% else %> +
+
+ <%= room.name %> + +
+
+ <% end %> + <% end %>
- <% end %> - <% else %> -
-
- <%= room.name %> - + + +
+
+ <% @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 %> +
+
+ <% end %> +
+
+ + +
+
+
+
+ +
+
+ +
+
+
+ + + + + + + + + +
<%= t :credit %> <%= t :sale %> <%= t("views.right_panel.detail.date") %><%= t("views.right_panel.detail.receipt_no") %> <%= t :cashier %> <%= t("views.right_panel.detail.name") %> <%= t :customer %> <%= t("views.right_panel.detail.name") %> <%= t("views.right_panel.detail.credit_amount") %>
+
+
- <% end %> - <% end %> -
-
+
+ +
+ - -
-
- <% @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 %> + +
+
+
+ <% if @status_order == 'order' && @status_sale != 'sale' %> + <% if !@obj_order.nil? %> +
+ <% else %> +
+ <% end %> + ORDER DETAILS | Table <%= @dining.name rescue "" %> + <% if @booking.checkout_by.nil? && !@booking.reserved_by.nil? %> + <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> - <%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") %> + <% else %> + Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> + <% end %> +
+ <% elsif @status_sale == 'sale' %> +
+ INVOICE DETAILS | Table <%= @dining.name rescue "" %> + <% if !@booking.reserved_by.nil? && %> + <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> - <%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") %> + <% else %> + Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> + <% end %> +
+ <% else %> + ORDER DETAILS | Table <%= @dining.name rescue "" %> + <% end %> +
+
+
+
+ <% if (!@sale_array.empty?) && (!@date.nil?) %> +
+   Receipt No: + <% if @status_sale == 'sale' %> + <%= @sale_array[0].receipt_no rescue '' %> + <% end %> + +
+
+
+ Date: <%= @date.utc.getlocal.strftime("%d/%m/%Y-%I:%M %p") rescue '-' %> +
+
+ <% elsif !@date.nil? %> +
+   Order No: + <% if @status_order == 'order' %> + <%= @obj_order.order_id rescue '' %> + + <% end %> + +
+
+
+ Date: <%= @date.utc.getlocal.strftime("%d/%m/%Y") rescue '-' %> +
+
+ <% end %> +
+
+
+ + <% if @status_sale == 'sale' %> + +   Customer : <%= @sale_array[0].customer.name rescue '' %> + <% elsif @status_order == 'order' + %> + +   Customer : <%= @customer.name rescue "" %> + <% end %> + +
+
-
- <% end %> -
-
-
-
- -
- +
"> +
+ + + - -
-
-
- <% if @status_order == 'order' && @status_sale != 'sale' %> - <% if !@obj_order.nil? %> -
- <% else %> -
- <% end %> - ORDER DETAILS | Table <%= @dining.name rescue "" %> - <% if @booking.checkout_by.nil? && !@booking.reserved_by.nil? %> - <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> - <%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") %> - <% else %> - Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> - <% end %> -
- <% elsif @status_sale == 'sale' %> -
- INVOICE DETAILS | Table <%= @dining.name rescue "" %> - <% if !@booking.reserved_by.nil? && %> - <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> - <%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") %> - <% else %> - Checkin Time : <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> - <% end %> -
- <% else %> - ORDER DETAILS | Table <%= @dining.name rescue "" %> - <% end %> -
-
-
-
- <% if (!@sale_array.empty?) && (!@date.nil?) %> -
-   Receipt No: - <% if @status_sale == 'sale' %> - <%= @sale_array[0].receipt_no rescue '' %> - <% end %> - -
-
-
- Date: <%= @date.utc.getlocal.strftime("%d/%m/%Y-%I:%M %p") rescue '-' %> -
-
- <% elsif !@date.nil? %> -
-   Order No: - <% if @status_order == 'order' %> - <%= @obj_order.order_id rescue '' %> +
+ + + + + + + <% + count = 0 + sub_total = 0 + if @status_sale == "sale" + @sale_array[0].sale_items.each do |sale_item| - <% end %> - -
- -
- Date: <%= @date.utc.getlocal.strftime("%d/%m/%Y") rescue '-' %> -
-
- <% end %> - -
-
- - <% if @status_sale == 'sale' %> - -   Customer : <%= @sale_array[0].customer.name rescue '' %> - <% elsif @status_order == 'order' - %> - -   Customer : <%= @customer.name rescue "" %> - <% end %> - -
-
- -
"> -
-
#ItemsQTY + Price +
- - - - - - - - - - - <% - 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 + %> + + + + + + + + <% + 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 %> + - - - - + - - - - - - <% + <% 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 %> + + + + + <% # end - end - end - end - %> - -
#ItemsQTY - Price -
<%= count %><%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
<%= count %><%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
+ <%= 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 %> - - <% 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 %>
-
-
- - - <% - 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 - %> - - - - - - <% + end + end end - %> + %> +
<%= 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 %> - - <% 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 - %> -
- <%= item_instance["item_instance_name"] %> - <% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %> - <% (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 %>
- - +
+
+ + + <% + 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 + %> + + + + + + <% + end + %> +
<%= 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 %> + + <% 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 + %> +
+ <%= item_instance["item_instance_name"] %> + <% if !item_instance["options"].nil? && item_instance["options"] != "undefined" %> + <% (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 %>
+ + <% end %> <% if @sale_array.size > 1 %> -

- Pending Payment +

+ Pending Payment <% end %> <% @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 - %> + + + + + +
Receipt No - <%= sale.receipt_no %> + +
+ <% + end + end + end + end + %> +
-
- -
- + +
+ - - - - - <% if @dining.status != "available" %> - <% if @status_order == 'order' && @status_sale != 'sale' %> - - - - - - - - <% if !@split_bill.nil? %> - <% if @split_bill == '1' %> - - <% end %> - <% end %> - - - - <% end %> - <% if @status_sale == 'sale' %> - <% if current_login_employee.role != "waiter" %> - - - <% end %> - - <% if current_login_employee.role != "waiter" %> + + + + + <% if @dining.status != "available" %> + <% if @status_order == 'order' && @status_sale != 'sale' %> + + + + + + + + <% if !@split_bill.nil? %> + <% if @split_bill == '1' %> + + <% end %> + <% end %> + + + + <% end %> + <% if @status_sale == 'sale' %> + <% if current_login_employee.role != "waiter" %> + + + <% end %> + + <% if current_login_employee.role != "waiter" %> <% if current_login_employee.role == "cashier" %> - Edit - Void + Edit + Void <% else %> - - <% end %> + <% if @split_bill == '1' %> + <% end %> - <% if current_login_employee.role != "waiter" %> - - - <%if @membership.discount && @obj_sale.customer.membership_id %> - - <%else%> - - <%end%> - + <% end %> + <% if current_login_employee.role != "waiter" %> + + + <%if @membership.discount && @obj_sale.customer.membership_id %> + + <%else%> + + <%end%> + - <% end %> - <% end %> - + <% end %>--> + <% end %> + <% end %> + - - <% else %> - <% if !@checkout_time.empty? && !@checkout_alert_time.empty? %> - - <% end %> - <% end %> - "> - - - - - - +