order reservation
This commit is contained in:
@@ -47,7 +47,13 @@ $(function() {
|
||||
item_list.empty();
|
||||
|
||||
for(var i in items) {
|
||||
var total = items[i].qty*items[i].unit_price;
|
||||
var item_price = 0;
|
||||
if(items[i].price > 0){
|
||||
item_price = items[i].price;
|
||||
}else{
|
||||
item_price = items[i].unit_price;
|
||||
}
|
||||
var total = items[i].qty * item_price;
|
||||
row = '<tr>'
|
||||
+'<td width ="70%" class="body-td align-left">'+items[i].item_name
|
||||
+' <br><span class="font-13">'+items[i].qty+ '<span class="col-blue"> <b>X</b>'+items[i].unit_price+'</span></span>'
|
||||
@@ -78,56 +84,66 @@ $(function() {
|
||||
}
|
||||
|
||||
$("#accepted").on("click", function(){
|
||||
var status = $(this).attr("data-value");
|
||||
var status = $(this).attr("data-value");
|
||||
var order_id = $('#order_id').text();
|
||||
var url = 'order_reservation/update';
|
||||
var ref_no = $('#ref_no').text();
|
||||
var callback = $('#callback_url').text();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
data: {'order_id': order_id, 'status': status},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
console.log(data)
|
||||
if (data.status) {
|
||||
// callback_url(callback,data.message)
|
||||
swal("Information","Order has been +'data.status'+","success");
|
||||
window.location.href = '/origami/order_reservation';
|
||||
}
|
||||
}
|
||||
});
|
||||
callback_url(callback,ref_no,order_id,status);
|
||||
});
|
||||
|
||||
$("#cancel").on("click", function(){
|
||||
var status = $(this).attr("data-value");
|
||||
var status = $(this).attr("data-value");
|
||||
var order_id = $('#order_id').text();
|
||||
var url = 'order_reservation/update';
|
||||
var callback = $('#callback_url').text();
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
data: {'order_id': order_id, 'status': status},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
console.log(data)
|
||||
if (data.status) {
|
||||
console.log(data)
|
||||
// callback_url(callback,data.message)
|
||||
swal("Information","Order has been +'data.status'+","warning");
|
||||
window.location.href = '/origami/order_reservation';
|
||||
}
|
||||
}
|
||||
});
|
||||
var ref_no = $('#ref_no').text();
|
||||
callback_url(callback,ref_no,order_id,status);
|
||||
});
|
||||
|
||||
function callback_url(url,message){
|
||||
function callback_url(callback,ref_no,order_id,status){
|
||||
var url = 'order_reservation/update';
|
||||
var post_url = "order_reservation/send_status";
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
data: {},
|
||||
url: post_url,
|
||||
data: {url: callback, ref_no: ref_no, status: status},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
|
||||
if(data.status){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
data: {'order_id': order_id, 'status': status},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
if (data.status) {
|
||||
swal({
|
||||
title: 'Information',
|
||||
text: "Order has been "+data.status,
|
||||
type: 'success',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.href = '/origami/order_reservation';
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}else{
|
||||
swal({
|
||||
title: 'Oops',
|
||||
text: data.message.toString(),
|
||||
type: 'error',
|
||||
html: true,
|
||||
closeOnConfirm: false,
|
||||
closeOnCancel: false,
|
||||
allowOutsideClick: false
|
||||
}, function () {
|
||||
window.location.href = '/origami/order_reservation';
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -36,5 +36,37 @@ class Origami::OrderReservationController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
def send_status
|
||||
base_url = "http://192.168.1.186:3002"
|
||||
post_url = base_url + params[:url]
|
||||
# status = params[:status]
|
||||
if params[:status] == "cancel"
|
||||
status = "rejected"
|
||||
else
|
||||
status = params[:status]
|
||||
end
|
||||
|
||||
begin
|
||||
response = HTTParty.post(post_url,
|
||||
:body => { id: params[:ref_no], status: status}.to_json,
|
||||
:headers => {
|
||||
'Authorization' => 'Token token=3T-tnlYtFJ-5Z1vY6XQqxQ',
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json; version=3'
|
||||
}, :timeout => 10
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
response = { status: false }
|
||||
|
||||
rescue OpenURI::HTTPError
|
||||
response = { status: false}
|
||||
rescue SocketError
|
||||
response = { status: false}
|
||||
end
|
||||
Rails.logger.debug "Get Doemal Status "
|
||||
Rails.logger.debug response.to_json
|
||||
render :json => response
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -354,6 +354,11 @@ class Customer < ApplicationRecord
|
||||
|
||||
#new customer for doemal
|
||||
def self.addCustomer(params)
|
||||
if params[:gender] == "female"
|
||||
gender = "Female"
|
||||
else
|
||||
gender = "Male"
|
||||
end
|
||||
customer = Customer.new
|
||||
customer.name = params[:name]
|
||||
customer.email = params[:email]
|
||||
|
||||
@@ -49,43 +49,39 @@ class OrderReservation < ApplicationRecord
|
||||
end
|
||||
|
||||
def self.create_doemal_order(order)
|
||||
|
||||
is_extra_time = false
|
||||
extra_time = ''
|
||||
is_extra_time = false
|
||||
extra_time = ''
|
||||
|
||||
items_arr = []
|
||||
count = 1
|
||||
order.order_reservation_items.each { |i|
|
||||
i.item_instance_code = i.item_instance_code.downcase.to_s
|
||||
|
||||
items = {"order_item_id": count,"item_instance_code": i.item_instance_code,"quantity": i.qty,"options": []}
|
||||
count += 1
|
||||
items_arr.push(items)
|
||||
}
|
||||
items_arr = []
|
||||
count = 1
|
||||
order.order_reservation_items.each { |i|
|
||||
i.item_instance_code = i.item_instance_code.downcase.to_s
|
||||
items = {"order_item_id": count,"item_instance_code": i.item_instance_code,"quantity": i.qty,"options": []}
|
||||
count += 1
|
||||
items_arr.push(items)
|
||||
}
|
||||
|
||||
puts items_arr.to_json
|
||||
puts "sssssssssssssssssssssss"
|
||||
customer_id = order.customer_id
|
||||
puts items_arr.to_json
|
||||
puts "sssssssssssssssssssssss"
|
||||
customer_id = order.customer_id
|
||||
|
||||
@order = Order.new
|
||||
@order.source = "doemal_order"
|
||||
@order.order_type = "delivery"
|
||||
@order.customer_id = customer_id
|
||||
@order.items = items_arr
|
||||
@order.guest = ''
|
||||
@order.table_id = nil # this is dining facilities's id
|
||||
@order.new_booking = true
|
||||
@order.waiters = current_login_employee.name
|
||||
@order.employee_name = current_login_employee.name
|
||||
@order = Order.new
|
||||
@order.source = "doemal_order"
|
||||
@order.order_type = "delivery"
|
||||
@order.customer_id = customer_id
|
||||
@order.items = items_arr
|
||||
@order.guest = ''
|
||||
@order.table_id = nil # this is dining facilities's id
|
||||
@order.new_booking = true
|
||||
@order.waiters = current_login_employee.name
|
||||
@order.employee_name = current_login_employee.name
|
||||
|
||||
@order.is_extra_time = is_extra_time
|
||||
@order.extra_time = extra_time
|
||||
@order.is_extra_time = is_extra_time
|
||||
@order.extra_time = extra_time
|
||||
|
||||
@status, @booking = @order.generate
|
||||
@status, @booking = @order.generate
|
||||
|
||||
# Order.send_customer_view(@booking)
|
||||
|
||||
|
||||
if @status && @booking
|
||||
|
||||
@status, @sale = Sale.request_bill(@order,current_user,current_login_employee)
|
||||
|
||||
@@ -285,10 +285,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p id="ref_no"></p>
|
||||
<p id="callback_url"></p>
|
||||
<p id="order_id"></p>
|
||||
<p id="status"></p>
|
||||
<p id="ref_no" class="hidden"></p>
|
||||
<p id="callback_url" class="hidden"></p>
|
||||
<p id="order_id" class="hidden"></p>
|
||||
<p id="status" class="hidden"></p>
|
||||
<script type="text/javascript">
|
||||
jQuery(function(){
|
||||
jQuery('.first-1').click();
|
||||
|
||||
@@ -268,7 +268,7 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
resources :order_reservation
|
||||
get 'order_reservation/get_order/:id' => "order_reservation#get_order",:as => "get_order", :defaults => { :format => 'json' }
|
||||
post 'order_reservation/update', to: "order_reservation#update" , :defaults => { :format => 'json' }
|
||||
|
||||
post 'order_reservation/send_status', to: "order_reservation#send_status"
|
||||
end
|
||||
|
||||
#--------- Waiter/Ordering Station ------------#
|
||||
|
||||
Reference in New Issue
Block a user