From ce6785c70be5b011cd65fcb9db5c751a05fa8bdd Mon Sep 17 00:00:00 2001 From: Zin Moe Date: Mon, 16 Mar 2020 17:54:10 +0630 Subject: [PATCH] fix addorder UI --- app/assets/javascripts/addorder.js | 17 +- app/assets/javascripts/custom.js | 10 + app/controllers/base_foodcourt_controller.rb | 2 +- .../foodcourt/orders_controller.rb | 8 + app/views/foodcourt/addorders/detail.html.erb | 7 +- .../foodcourt/orders/app_orders.html.erb | 179 +++++++++--------- app/views/foodcourt/payments/show.html.erb | 15 +- app/views/layouts/_header.html.erb | 33 +++- app/views/layouts/application.html.erb | 11 +- app/views/layouts/foodcourt.html.erb | 2 +- config/routes.rb | 1 + 11 files changed, 166 insertions(+), 119 deletions(-) diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 2a042828..e3f9877e 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -1539,6 +1539,13 @@ $(function() { // price = $("#unit_price").text(); // $("#total_price").text(qty*price); // }); + function truncateString(str, num) { + if (str.length <= num) { + return str + } else { + return str.slice(0, num) + '...' + } + } function show_menu_list(menu_items) { var menu_list = $('.menu_items_list'); menu_list.empty(); @@ -1617,10 +1624,12 @@ $(function() { oos_header = '' opacity = '' } + name = menu_items[field].name + short_name = truncateString(name, 30) row = '
' + oos_item + oos_header - +'
' - +'
'+ menu_items[field].name +'
' + +'
' + +'
'+ short_name +'
' +'
' +"
" - +'
'+ menu_items[field].name +'
' + +'
'+ short_name +'
' +'
' +"
-
+
@@ -156,8 +157,8 @@
-
-
+
+
<% end %> <% if @pending %> -
+
<% if @status == 'sale' %> <% elsif @status == 'order' %> @@ -312,90 +308,97 @@
-
-
-
- - - - - - - - - - <% if @status == 'sale' %> - <% sub_total = 0 - @pending.sale_items.each do |sale_item| - sub_total = sub_total + sale_item.price %> - - - - - - <% end%> - <% else %> - <% sub_total = 0 - total = 0 - @pending.order_items.each do |order_item| - total = order_item.qty * order_item.price - sub_total = sub_total + total %> - - - - - - <% end %> +
+
+
ItemsQTYPrice
<%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
<%= order_item.item_name %><%= order_item.qty %><%= total %>
+ + + + + + + + + <% if @status == 'sale' %> + <% sub_total = 0 + @pending.sale_items.each do |sale_item| + sub_total = sub_total + sale_item.price %> + + + + + <% end%> - -
ItemsQTYPrice
<%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.price %>
-
-
-
- +
+
-
-
+
<% end %> -
+ <% if @pending || @booking %> +
+ <% else %> +
+ <% end %> - <% if !@booking.nil?%> - Void + <% if @booking && @booking.booking_status == 'assign' %> + + <% end %> + <% if @booking && @booking.booking_status != 'void' %> + Void <% end %> diff --git a/app/views/foodcourt/payments/show.html.erb b/app/views/foodcourt/payments/show.html.erb index 89886e13..5f6bea26 100755 --- a/app/views/foodcourt/payments/show.html.erb +++ b/app/views/foodcourt/payments/show.html.erb @@ -19,7 +19,7 @@
-
+
@@ -159,12 +159,12 @@
-
-
+
+
Amount Due: <% if !@sale_payment.nil? %>( Credit )<% end %>
-
+
- <%= link_to 'Back', '/foodcourt/app_orders', class: 'btn btn-block btn-default waves-effect' %> + <%= link_to '/foodcourt/app_orders', class: 'btn btn-block btn-default waves-effect', style: "padding-top: 0;" do%> + reply + BACK + <% end %> @@ -445,7 +448,7 @@

Card Tap

-
+
diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index fd2e7a9c..7330b392 100755 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -254,14 +254,29 @@ $('.close_cashier').on('click',function(e){ e.preventDefault(); // Prevent the href from redirecting directly var linkURL = '/foodcourt/shift/cashier/close'; - swal({ - title: "Alert!", - text: "Are you sure you want to close cashier?", - type: "warning", - showCancelButton: true, - html: true - }, function() { - window.location.href = linkURL; - }); + var count = '' + var text = '' + $.ajax({ + url: '/foodcourt/current_shift_order_count', + method: 'get', + success: function(data) { + count = JSON.stringify(data) + console.log(count) + if (count > 0) { + text = "
We have "+count+" pending orders and sales
.
Are you sure you want to close cashier? "; + }else{ + text = "Are you sure you want to close cashier?"; + } + swal({ + title: "Alert!", + text: text, + type: "warning", + showCancelButton: true, + html: true + }, function() { + window.location.href = linkURL; + }); + } + }) }) diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 4a0a3e7c..f7df0c86 100755 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -38,14 +38,9 @@ <%= render 'layouts/header' %>
- <%food_court = Lookup.find_by_lookup_type_and_value("food_court", "1")%> - <% if food_court && current_user.role=='cashier'%> - <%= render 'layouts/foodcourt_left_sidebar' %> - <% else %> - <%= render 'layouts/left_sidebar' %> - <%end%> - - <%= render 'layouts/right_sidebar' %> + <%= render 'layouts/left_sidebar' %> + + <%= render 'layouts/right_sidebar' %>
diff --git a/app/views/layouts/foodcourt.html.erb b/app/views/layouts/foodcourt.html.erb index 05b1542b..bb1f40b8 100644 --- a/app/views/layouts/foodcourt.html.erb +++ b/app/views/layouts/foodcourt.html.erb @@ -38,7 +38,7 @@ <%= render 'layouts/header' %>
- <%= render 'layouts/foodcourt_left_sidebar' %> + <%= render 'layouts/left_sidebar' %> <%= render 'layouts/right_sidebar' %>
diff --git a/config/routes.rb b/config/routes.rb index dbd947f4..8914aced 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -701,6 +701,7 @@ scope "(:locale)", locale: /en|mm/ do get "food_court/modify_order/:id/:sale_id" => "orders#modify_order" post '/food_court/update_modify_order' => "orders#update_modify_order", :defaults => { :format => 'json' } get '/food_court/:order_id/request_bill' => 'orders#request_bill', :as => 'food_court_request_bill' + get 'current_shift_order_count' => 'orders#current_shift_order_count', :as => 'food_court_order_count' end end end