diff --git a/app/controllers/origami/orders_controller.rb b/app/controllers/origami/orders_controller.rb index 85047ef0..22a1e802 100755 --- a/app/controllers/origami/orders_controller.rb +++ b/app/controllers/origami/orders_controller.rb @@ -3,7 +3,7 @@ class Origami::OrdersController < BaseOrigamiController @tables = Table.all.active.order('status desc') @rooms = Room.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.all.order('status desc') + @orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @order = Order.find(params[:order_id]) sale_order = SaleOrder.find_by_order_id(@order.order_id) if sale_order diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index bd375d63..d2c89e37 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -11,7 +11,7 @@ class Origami::RoomsController < BaseOrigamiController @tables = Table.all.active.order('status desc') @rooms = Room.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.all.order('date desc') + @orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @room = DiningFacility.find(params[:room_id]) @@ -90,6 +90,12 @@ class Origami::RoomsController < BaseOrigamiController # end # end # end + + lookup_spit_bill = Lookup.collection_of('split_bill') + @spit_bill = 0 + if !lookup_spit_bill[0].nil? + @spit_bill = lookup_spit_bill[0][1] + end end diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 64aa00ff..7f16833e 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -116,7 +116,22 @@ <% @orders.each do |order| %>
- <%= 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 %> @@ -678,7 +693,7 @@ if(lookup_split_bill == '1'){ swal({ title: "Alert", - text: "Do you want to Split bill?", + text: "Are you sure, you want to Split bill?", type: "warning", showCancelButton: true, confirmButtonColor: "#DD6B55", diff --git a/app/views/origami/orders/show.html.erb b/app/views/origami/orders/show.html.erb index 6e8163ed..779755ae 100755 --- a/app/views/origami/orders/show.html.erb +++ b/app/views/origami/orders/show.html.erb @@ -128,7 +128,7 @@ order_status = order.status end %> - <%= order.order_id %> | <%= order_status %> + <%= order.order_id %> <% if !order_status.empty? %>| <%= order_status %> <% end %> <% end %> @@ -150,7 +150,7 @@
- Receipt No: + Order No: <%= @order.order_id %>
diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 385129bf..26986ac6 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -117,7 +117,22 @@ <% @orders.each do |order| %>
- <%= 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 %> @@ -676,34 +691,46 @@ $('#pay').on('click',function() { }); // Bill Request $('#request_bills').click(function() { - var order_id = $('#save_order_id').attr('data-order'); - var ajax_url = "/origami/" + order_id + "/request_bills"; - $.ajax({ + var lookup_split_bill = '<%= @spit_bill %>'; + if(lookup_split_bill == '1'){ + swal({ + title: "Alert", + text: "Are you sure, you want to Split bill?", + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + confirmButtonText: "Yes, split it!", + closeOnConfirm: false + }, function (isConfirm) { + if (isConfirm) { + var dining_id = "<%= @room.id %>"; + window.location.href = '/origami/room/' + dining_id + "/split_bills"; + }else{ + requestBillProcess(); + } + }); + }else{ + requestBillProcess(); + } +}); + +function requestBillProcess(){ + 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){ - $.confirm({ - title: 'Information!', - content: result.error_message, - buttons: { - confirm: { - text: 'Ok', - btnClass: 'btn-green', - action: function(){ - window.location.href = '/origami'; - } - } - } - }); + url: ajax_url, + // data: 'order_id='+ order_id, + success: function (result) { + if (!result.status) { + swal("Information!", result.error_message); } - else { + else { location.reload(); } - } - }); -}); + } + }); +} $('#move').on('click',function(){ var dining_id = "<%= @room.id %>" diff --git a/config/routes.rb b/config/routes.rb index 5afcb32e..f37c6895 100755 --- a/config/routes.rb +++ b/config/routes.rb @@ -221,7 +221,8 @@ scope "(:locale)", locale: /en|mm/ do post "bank_integration/sale_trans", to: "bank_integration#sale_trans", as:"sale_trans" #split bill - get '/table/:dining_id/split_bills' => 'split_bill#index', as:'split_bill_index' + get '/table/:dining_id/split_bills' => 'split_bill#index' + get '/room/:dining_id/split_bills' => 'split_bill#index' post '/split_bills', to: 'split_bill#create', as:"order_item_split_bills" end