From 84f87ec5f95e20ad091448bf40d3375bb72292cb Mon Sep 17 00:00:00 2001 From: phyusin Date: Tue, 17 Jul 2018 14:35:53 +0630 Subject: [PATCH 1/2] check btn show/hide --- app/views/origami/home/show.html.erb | 45 +++++++++++++------------ app/views/origami/rooms/show.html.erb | 47 +++++++++++++++------------ 2 files changed, 52 insertions(+), 40 deletions(-) diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 812f85e9..f15475a1 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -474,7 +474,9 @@ <% if @dining.status != "available" %> <% if @status_order == 'order' && @status_sale != 'sale' %> - + <%if !@order_items.empty? %> + + <% end %> @@ -482,7 +484,7 @@ <% if !@split_bill.nil? %> - <% if @split_bill == '1' %> + <% if @split_bill == '1' && (!@order_items.empty?) %> <% end %> <% end %> @@ -513,7 +515,7 @@ <% if !@split_bill.nil? %> - <% if @split_bill == '1' %> + <% if @split_bill == '1' && (!@order_items.empty?) %> <% end %> <% end %> @@ -1049,25 +1051,28 @@ // Bill Request $('#request_bills').click(function () { - if($('#request_bills').is(":visible")) { - $('#request_bills').prop("disabled",true); - } - var order_id = $('#save_order_id').attr('data-order'); var ajax_url = "/origami/" + order_id + "/request_bills"; - $.ajax({ - type: "GET", - url: ajax_url, - // data: 'order_id='+ order_id, - success: function (result) { - if (!result.status) { - swal("Information!", result.error_message); - } - else { - location.reload(); - } - } - }); + if(order_id!=undefined && order_id!=null && order_id!=""){ + if($('#request_bills').is(":visible")) { + $('#request_bills').prop("disabled",true); + } + $.ajax({ + type: "GET", + url: ajax_url, + // data: 'order_id='+ order_id, + success: function (result) { + if (!result.status) { + swal("Information!", result.error_message); + } + else { + location.reload(); + } + } + }); + }else{ + swal("Opps","There is no orders!","warning"); + } }); //split bill process diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index f27ba647..83e75023 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -506,12 +506,14 @@ - + <% if !@order_items.empty? %> + + <% end %> <% if !@split_bill.nil? %> - <% if @split_bill == '1' %> + <% if @split_bill == '1' && (!@order_items.empty?) %> <% end %> <% end %> @@ -538,7 +540,7 @@ <% if !@split_bill.nil? %> - <% if @split_bill == '1' %> + <% if @split_bill == '1' && (!@order_items.empty?) %> <% end %> <% end %> @@ -1027,24 +1029,29 @@ $('#pay').on('click',function() { }); // Bill Request $('#request_bills').click(function() { - if($('#request_bills').is(":visible")) { - $('#request_bills').prop("disabled",true); - } var order_id = $('#save_order_id').attr('data-order'); var ajax_url = "/origami/" + order_id + "/request_bills"; - $.ajax({ - type: "GET", - url: ajax_url, - // data: 'order_id='+ order_id, - success: function (result) { - if (!result.status) { - swal("Information!", result.error_message); - } - else { - location.reload(); - } - } - }); + if(order_id!=undefined && order_id!=null && order_id!=""){ + if($('#request_bills').is(":visible")) { + $('#request_bills').prop("disabled",true); + } + $.ajax({ + type: "GET", + url: ajax_url, + // data: 'order_id='+ order_id, + success: function (result) { + if (!result.status) { + swal("Information!", result.error_message); + } + else { + location.reload(); + } + } + }); + }else{ + swal("Opps","There is no orders!","warning"); + } + }); //split bill process @@ -1215,7 +1222,7 @@ $('#add_invoice').on('click',function(){ } }); }else{ - swal("Opps","You are not authorized for void","warning") + swal("Opps","You are not authorized for void","warning"); } }); From 91fc8696af531d843a46ce600bbb04f52f8c2ef7 Mon Sep 17 00:00:00 2001 From: phyusin Date: Tue, 17 Jul 2018 14:45:14 +0630 Subject: [PATCH 2/2] check order items arr --- app/controllers/origami/home_controller.rb | 1 + app/controllers/origami/rooms_controller.rb | 2 +- app/views/origami/home/show.html.erb | 4 ++-- app/views/origami/rooms/show.html.erb | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 69b20576..3f5c310c 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -33,6 +33,7 @@ class Origami::HomeController < BaseOrigamiController @payment_methods = PaymentMethodSetting.all @dining_booking = @dining.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ") #@dining_booking = @dining.bookings.active.where("created_at between '#{DateTime.now.utc - 12.hours}' and '#{DateTime.now.utc}'") + @order_items = Array.new @dining_booking.each do |booking| if booking.sale_id.nil? && booking.booking_status != 'moved' @order_items = Array.new diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index b2319691..0a44ede7 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -33,6 +33,7 @@ class Origami::RoomsController < BaseOrigamiController @payment_methods = PaymentMethodSetting.all @dining_room = @room.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ") + @order_items = Array.new @dining_room.each do |booking| if booking.sale_id.nil? && booking.booking_status != 'moved' @order_items = Array.new @@ -100,7 +101,6 @@ class Origami::RoomsController < BaseOrigamiController end end end - # @room.bookings.each do |booking| # if booking.sale_id.nil? # @order_items = Array.new diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index f15475a1..10bd36cd 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -484,7 +484,7 @@ <% if !@split_bill.nil? %> - <% if @split_bill == '1' && (!@order_items.empty?) %> + <% if @split_bill == '1' && (!(@order_items.nil?) || !(@order_items.empty?)) %> <% end %> <% end %> @@ -515,7 +515,7 @@ <% if !@split_bill.nil? %> - <% if @split_bill == '1' && (!@order_items.empty?) %> + <% if @split_bill == '1' && (!(@order_items.nil?) || !(@order_items.empty?)) %> <% end %> <% end %> diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 83e75023..54cbd97f 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -513,7 +513,7 @@ <% if !@split_bill.nil? %> - <% if @split_bill == '1' && (!@order_items.empty?) %> + <% if @split_bill == '1' && (!(@order_items.nil?) || !(@order_items.empty?)) %> <% end %> <% end %> @@ -540,7 +540,7 @@ <% if !@split_bill.nil? %> - <% if @split_bill == '1' && (!@order_items.empty?) %> + <% if @split_bill == '1' && (!(@order_items.nil?) || !(@order_items.empty?)) %> <% end %> <% end %>