app order with order

This commit is contained in:
Myat Zin Wai Maw
2019-12-04 16:18:06 +06:30
parent f404328089
commit 7a4db5e0f4
5 changed files with 46 additions and 44 deletions

View File

@@ -35,12 +35,13 @@ class Foodcourt::FoodCourtController < ApplicationController
end
end
end
@app_order_new_count =Booking.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
@app_order_new_count = Booking.select("bookings.*,customers.*")
.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
.joins("JOIN orders ON orders.order_id=booking_orders.order_id")
.joins("JOIN order_items ON orders.order_id=order_items.order_id")
.joins("JOIN customers ON orders.customer_id=customers.customer_id")
.where("orders.source='app' and bookings.shop_code='#{Shop.current_shop.shop_code}' and bookings.booking_status='assign'").uniq.length
puts @app_order_new_count
.where("orders.source='app' and bookings.shop_code='#{Shop.current_shop.shop_code}' and DATE(bookings.created_at) = '#{Date.today}' and bookings.booking_status='assign'").uniq.length
render "foodcourt/addorders/detail"
end

View File

@@ -62,18 +62,19 @@ class Foodcourt::OrdersController < BaseFoodcourtController
.where("orders.source='app' and bookings.booking_id='#{params[:booking_id]}'").first
@customer_id =@booking.customer_id
@booking_id =@booking.booking_id
@order_id =@booking.order_id
end
@bookings = Booking.select("bookings.*,customers.*")
.joins(" JOIN booking_orders ON booking_orders.booking_id=bookings.booking_id")
.joins("JOIN orders ON orders.order_id=booking_orders.order_id")
.joins("JOIN order_items ON orders.order_id=order_items.order_id")
.joins("JOIN customers ON orders.customer_id=customers.customer_id")
.where("orders.source='app' and DATE(bookings.created_at) = '#{Date.today}'").order("bookings.created_at desc").uniq
.where("orders.source='app' and DATE(bookings.created_at) = '#{Date.today}' and bookings.shop_code='#{Shop.current_shop.shop_code}'").order("bookings.created_at desc").uniq
end
def completed
customer =Customer.find_by_customer_id(params[:customer_id])
phone_number =customer.contact_no
if Order.send_message(phone_number,params[:booking_id])
if Order.send_message(phone_number,params[:order_id])
booking =Booking.find(params[:booking_id])
booking.booking_status ='completed'
booking.save!

View File

@@ -591,8 +591,8 @@ class Order < ApplicationRecord
Rails.logger.debug '...... order sync completed .....'
end
end
def self.send_message(phone, booking_id)
url = "http://smspoh.com/api/http/send?key=5QfyN0OtGsFXnOqwtpVAGZCyPGP28nbX_Nm_oPsUw2ybq714T_951ycz3Ypl5URA&message=Your order "+booking_id.to_s+" is ready to pick up&recipients="+ phone.to_s
def self.send_message(phone, order_id)
url = "http://smspoh.com/api/http/send?key=5QfyN0OtGsFXnOqwtpVAGZCyPGP28nbX_Nm_oPsUw2ybq714T_951ycz3Ypl5URA&message=Your order "+order_id.to_s+" is ready to pick up&recipients="+ phone.to_s
begin
@result = HTTParty.get(url.to_str)

View File

@@ -50,8 +50,7 @@
<div class="card <%= bk_color %> text-white" data-id ="<%= bk.booking_id %>">
<div class="card-block">
Cus Ph :<%= bk.contact_no %><span style="font-size:12px;float:right;line-height:inherit;">Order Time :<%= bk.checkin_at.utc.getlocal.strftime("%I:%M %p") %></span><br>
BK :<%= bk.booking_id %><span style="font-size:12px;float:right;line-height:inherit;"><%= bk_status %></span>
</div>
Order No :<%= bk.orders[0].order_id %><span style="font-size:12px;float:right;line-height:inherit;"><%= bk_status %></span> </div>
</div>
<% end %>
<% end %>
@@ -65,6 +64,7 @@
<div class="col-md-9 col-lg-9 col-sm-9">
<strong id="order-title" class="font-14 p-l-10">ORDER DETAILS </strong>| <span class="font-14">Table-<%=@booking.dining_facility.name%></span><br>
<strong class="font-14 p-l-10">Booking - <%=@booking.booking_id%></strong>
<strong class="font-14 p-l-10">Order No- <%=@booking.order_id%></strong>
</div>
<div class="col-md-3 col-lg-3 col-sm-3">
<button type="button" class="btn btn-block btn-default waves-effect" id='back'>
@@ -122,38 +122,38 @@
</div>
</div>
<script type="text/javascript">
$('#back').on('click', function () {
window.location.href ="<%=foodcourt_food_court_path %>";
});
$('#done_order').on('click', function () {
swal({
title: "Alert !",
text: 'Order Complete?',
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes",
cancelButtonClass: 'btn btn-danger',
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
$('.confirm').prop("disabled",true);
$.ajax({
type: "POST",
url: "/foodcourt/<%=@booking_id %>/completed",
data: {customer_id:"<%=@customer_id %>"},
dataType: "json",
success: function(data) {
swal({
title: "Information!",
text: 'Send sms to customer ',
type: "success",
}, function () {
window.location.href ="<%=foodcourt_app_order_by_booking_path %>";
});
}
});
}
});
});
  $('#back').on('click', function () {
     window.location.href ="<%=foodcourt_food_court_path %>";
  });
  $('#done_order').on('click', function () {
    swal({
      title: "Alert !",
      text: 'Order Complete?',
      type: "warning",
      showCancelButton: true,
      confirmButtonColor: "#DD6B55",
      confirmButtonText: "Yes",
      cancelButtonClass: 'btn btn-danger',
      closeOnConfirm: false
    }, function (isConfirm) {
      if (isConfirm) {
        $('.confirm').prop("disabled",true);
        $.ajax({
          type: "POST",
          url: "/foodcourt/<%=@booking_id %>/<%=@order_id %>/completed",
          data: {customer_id:"<%=@customer_id %>"},
          dataType: "json",
          success: function(data) {
            swal({
             title: "Information!",
             text: 'Send sms to customer ',
             type: "success",
           }, function () {
             window.location.href ="<%=foodcourt_app_order_by_booking_path %>";
           });
          }
        });
      }
    });
  });
</script>

View File

@@ -688,7 +688,7 @@ scope "(:locale)", locale: /en|mm/ do
post '/customer_view' => "second_display#customer_view",:as => "customer_view", :defaults => { :format => 'json' }
get "food_court" => "food_court#index"
get "app_orders" => "orders#app_orders",:as => "app_order_by_booking"
post ':booking_id/completed' => "orders#completed", :defaults => { :format => 'json' }
post ':booking_id/:order_id/completed' => "orders#completed", :defaults => { :format => 'json' }
end
end
end