From e445b3e88e94f89a0c32546a8d5f3c0a5d2dce7f Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 8 Feb 2018 17:56:41 +0630 Subject: [PATCH 1/2] add order count and change orders UI for table and room --- app/controllers/origami/home_controller.rb | 29 +- app/controllers/origami/orders_controller.rb | 26 ++ app/controllers/origami/rooms_controller.rb | 26 ++ app/views/home/dashboard.html.erb | 2 +- app/views/origami/home/show.html.erb | 24 +- app/views/origami/orders/show.html.erb | 425 ++++++++++--------- app/views/origami/rooms/show.html.erb | 20 + 7 files changed, 355 insertions(+), 197 deletions(-) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 0dda31f5..5bb8a02a 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -26,7 +26,33 @@ class Origami::HomeController < BaseOrigamiController @shop = Shop::ShopDetail @membership = MembershipSetting::MembershipSetting @payment_methods = PaymentMethodSetting.all - + + @order_items_count = Hash.new + bookings = Booking.all + if !bookings.nil? + 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) + end + end + end + end + else + 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) + end + end + end + end + end + @dining.bookings.active.each do |booking| if booking.sale_id.nil? && booking.booking_status != 'moved' @order_items = Array.new @@ -65,7 +91,6 @@ class Origami::HomeController < BaseOrigamiController else sale = Sale.find(booking.sale_id) if sale.sale_status != "completed" && sale.sale_status != 'void' - @sale_array.push(sale) if @status_order == 'order' @status_order = 'sale' diff --git a/app/controllers/origami/orders_controller.rb b/app/controllers/origami/orders_controller.rb index 22a1e802..f4b11fc5 100755 --- a/app/controllers/origami/orders_controller.rb +++ b/app/controllers/origami/orders_controller.rb @@ -12,5 +12,31 @@ class Origami::OrdersController < BaseOrigamiController @sale_status = sale.sale_status end end + + @order_items_count = Hash.new + bookings = Booking.all + if !bookings.nil? + 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) + end + end + end + end + else + 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) + end + end + end + end + end end end diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index cda8c299..68f8ffe0 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -22,6 +22,32 @@ class Origami::RoomsController < BaseOrigamiController @shop = Shop::ShopDetail @membership = MembershipSetting::MembershipSetting @payment_methods = PaymentMethodSetting.all + + @order_items_count = Hash.new + bookings = Booking.all + if !bookings.nil? + 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) + end + end + end + end + else + 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) + end + end + end + end + end @room.bookings.active.each do |booking| if booking.sale_id.nil? && booking.booking_status != 'moved' diff --git a/app/views/home/dashboard.html.erb b/app/views/home/dashboard.html.erb index eb1bdecd..104c4c67 100755 --- a/app/views/home/dashboard.html.erb +++ b/app/views/home/dashboard.html.erb @@ -155,7 +155,7 @@ <% if !(@total_payment_methods.nil?) %> <% @total_payment_methods.each do |payment| %> <% if !@sale_data[0].empty? %> - <% if payment.payment_method != 'mpu' && payment.payment_method != 'visa' && payment.payment_method != 'master' && payment.payment_method != 'jcb' %> + <% if payment.payment_method != 'mpu' && payment.payment_method != 'visa' && payment.payment_method != 'master' && payment.payment_method != 'jcb' && payment.payment_method != 'unionpay' %> <%= payment.payment_method.to_s.capitalize %> Sale : diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index a5b7b23c..6e1f7128 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -40,7 +40,7 @@
- <% @tables.each do |table| %> + <% @tables.each do |table| %> <% if table.status == 'occupied' %> <% if table.get_booking.nil? %> <% if table.get_checkout_booking.nil? %> @@ -50,6 +50,11 @@ <% end %>
<%= table.name %> + <% if !@order_items_count.nil? %> + <% if @order_items_count.key?(table.id) %> + (Orders : <%= @order_items_count[table.id] %>) + <% end %> + <% end %> billed
@@ -61,7 +66,12 @@
<% end %>
- <%= table.name %> + <%= table.name %> + <% if !@order_items_count.nil? %> + <% if @order_items_count.key?(table.id) %> + (Orders : <%= @order_items_count[table.id] %>) + <% end %> + <% end %> new
@@ -87,6 +97,11 @@
<%= room.name %> + <% if !@order_items_count.nil? %> + <% if @order_items_count.key?(room.id) %> + (Orders : <%= @order_items_count[room.id] %>) + <% end %> + <% end %> billed
@@ -94,6 +109,11 @@
<%= room.name %> + <% if !@order_items_count.nil? %> + <% if @order_items_count.key?(room.id) %> + (Orders : <%= @order_items_count[room.id] %>) + <% end %> + <% end %> new
diff --git a/app/views/origami/orders/show.html.erb b/app/views/origami/orders/show.html.erb index c1a581dc..852e731a 100755 --- a/app/views/origami/orders/show.html.erb +++ b/app/views/origami/orders/show.html.erb @@ -5,7 +5,7 @@
-
+
<% @complete.each do |sale| %>
- <%= sale.receipt_no %><%= sale.sale_status %> -
-
- <% end %> -
-
+ <%= sale.receipt_no %><%= sale.sale_status %> +
+
+ <% end %> +
+
- -
-
- <% @tables.each do |table| %> - <% if table.status == 'occupied' %> -
-
- <%= table.name %> - <% if table.get_booking.nil? %> - billed - <% else %> - new - <% end %> -
-
- <% else %> -
-
- <%= table.name %> -
-
- <% end %> - <% 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' %> -
-
- <%= room.name %> - <% if room.get_booking.nil? %> - billed + <% 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 %> - new +
+
+ <%= 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| %> -
-
- <% - 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 %> -
-
- -
-
- -
- - - -
-
-
-
ORDERS DETAILS
-
-
-
-
- Order No: <%= @order.order_id %> - -
-
- Date: <%= @order.created_at.utc.getlocal.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%> -
-
-
-
- Customer : -
- -
-
"> -
- - - - - - - - - - <% - sub_total = 0 - @order.order_items.each do |sale_item| - sub_total = sub_total + sale_item.price - %> - <% unless sale_item.price <= 0 %> - - - - - - <% - end - end - %> - -
ItemsQTYPrice
<%= sale_item.item_name %><%= sale_item.qty %><%= sale_item.price %>
-
-
- -
-
+ <% else %> +
+
+ <%= room.name %> + +
+
+ <% end %> + <% end %> +
- -
- - <% if @sale_status != 'completed' %> - - <% end %> - + +
+
+ <% @orders.each do |order| %> +
+
+ <% + 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 %> +
+
+ +
+ + + + + + +
+
+
+
ORDERS DETAILS
+
+
+
+
+ Order No: <%= @order.order_id %> + +
+
+ Date: <%= @order.created_at.utc.getlocal.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%> +
+
+
+
+ Customer :
+ +
+
"> +
+ + + + + + + + + + <% + sub_total = 0 + @order.order_items.each do |sale_item| + sub_total = sub_total + sale_item.price + %> + <% unless sale_item.price <= 0 %> + + + + + + <% + end + end + %> + +
ItemsQTYPrice
<%= sale_item.item_name %><%= sale_item.qty %><%= sale_item.price %>
+
+
+ +
+
+
+ + +
+ + <% if @sale_status != 'completed' %> + + <% end %> + +
diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 385129bf..17674fff 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -50,6 +50,11 @@ <% end %>
<%= table.name %> + <% if !@order_items_count.nil? %> + <% if @order_items_count.key?(table.id) %> + (Orders : <%= @order_items_count[table.id] %>) + <% end %> + <% end %> billed
@@ -61,6 +66,11 @@ <% end %>
<%= table.name %> + <% if !@order_items_count.nil? %> + <% if @order_items_count.key?(table.id) %> + (Orders : <%= @order_items_count[table.id] %>) + <% end %> + <% end %> new
@@ -87,6 +97,11 @@
<%= room.name %> + <% if !@order_items_count.nil? %> + <% if @order_items_count.key?(room.id) %> + (Orders : <%= @order_items_count[room.id] %>) + <% end %> + <% end %> billed
@@ -95,6 +110,11 @@
<%= room.name %> + <% if !@order_items_count.nil? %> + <% if @order_items_count.key?(room.id) %> + (Orders : <%= @order_items_count[room.id] %>) + <% end %> + <% end %> new
From d42fc485aebfb422ba62f5d0df5f34b162195f85 Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 8 Feb 2018 18:10:11 +0630 Subject: [PATCH 2/2] change ui for left sidebar --- app/views/layouts/_left_sidebar.html.erb | 1 + config/locales/en.yml | 1 + config/locales/mm.yml | 1 + 3 files changed, 3 insertions(+) diff --git a/app/views/layouts/_left_sidebar.html.erb b/app/views/layouts/_left_sidebar.html.erb index c6b1356a..57f05179 100755 --- a/app/views/layouts/_left_sidebar.html.erb +++ b/app/views/layouts/_left_sidebar.html.erb @@ -75,6 +75,7 @@ --> <%end%> +
  • <%= t :backend %>
  • widgets diff --git a/config/locales/en.yml b/config/locales/en.yml index 6bc0271e..d4dc8005 100755 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -70,6 +70,7 @@ en: sale_audits: "Sale Audits" bottom: "Bottom" payment: "Payment" + backend: "Backend" views: btn: diff --git a/config/locales/mm.yml b/config/locales/mm.yml index 6bdb1768..2d35b1bf 100755 --- a/config/locales/mm.yml +++ b/config/locales/mm.yml @@ -65,6 +65,7 @@ mm: sale_audits: "အရောင်းပြင်ဆင်ခြင်းများ" bottom: "အရောင်းအနဲဆုံး" payment: "ငွေပေးချေမှု" + backend: "Backend" views: btn: