change order reservation data

This commit is contained in:
phyusin
2018-05-09 19:10:11 +06:30
parent fe306dc26b
commit 0127b23e93
9 changed files with 113 additions and 78 deletions

View File

@@ -17,7 +17,7 @@ App.order_reservation = App.cable.subscriptions.create('OrderReservationChannel'
var rowCount = key+1; var rowCount = key+1;
var date = new Date(value.created_at); var date = new Date(value.created_at);
var time = timeFormat(date); var time = timeFormat(date);
var created_at = date.getFullYear() +'-'+ (date.getMonth() > 10? date.getMonth() : '0' + (date.getMonth() + 1)) +'-'+ (date.getDate()>10?date.getDate() : '0'+date.getDate()); var created_at = date.getFullYear() +'-'+ (date.getMonth() >= 10? date.getMonth() : '0' + (date.getMonth() + 1)) +'-'+ (date.getDate() >=10?date.getDate() : '0'+date.getDate());
var delivery_type = ""; var delivery_type = "";
if(value.delivery_type == "service"){ if(value.delivery_type == "service"){

View File

@@ -2,6 +2,9 @@
$(function() { $(function() {
$("#discount").hide(); $("#discount").hide();
$(".expected_time").hide(); $(".expected_time").hide();
$('#accepted').hide();
$('#cancel').hide();
$(".tbl_customer").hide();
$(function() { $(function() {
$('.first-1').click(); $('.first-1').click();
}); });
@@ -11,8 +14,9 @@ $(function() {
$(".nav-item").on("click", function(){ $(".nav-item").on("click", function(){
type = $(this).attr("data-type"); type = $(this).attr("data-type");
refreshDetailData(); refreshDetailData();
$('#accepted').show(); $('#accepted').hide();
$('#cancel').show(); $('#cancel').hide();
$(".tbl_customer").hide();
if (type == "pending") { if (type == "pending") {
$(".first-1").click(); $(".first-1").click();
$('#accepted').text("ACCEPT"); $('#accepted').text("ACCEPT");
@@ -26,13 +30,14 @@ $(function() {
$('#accepted').text("READY TO DELIVERY"); $('#accepted').text("READY TO DELIVERY");
$('#accepted').attr("data-value","delivery"); $('#accepted').attr("data-value","delivery");
}else if(type == "completed"){ }else if(type == "completed"){
// $('#cancel').hide();
$(".fourth-1").click(); $(".fourth-1").click();
$('#accepted').text("PICK-UP"); $('#accepted').text("COMPLETE");
$('#accepted').attr("data-value","completed"); $('#accepted').attr("data-value","completed");
}else if(type == "processed"){ }else if(type == "processed"){
$(".fifth-1").click(); $(".fifth-1").click();
$('#accepted').hide(); // $('#accepted').hide();
$('#cancel').hide(); // $('#cancel').hide();
} }
// console.log(type); // console.log(type);
}); });
@@ -94,7 +99,7 @@ $(function() {
$(".time_interval").on("click",function(){ $(".time_interval").on("click",function(){
var type = ''; var type = '';
if($(".timer_type").hasClass("selected-item")){ if($(".timer_type").hasClass("selected-item")){
type = '+'; type = 'after';
} }
var minutes = $(this).attr("data-value"); var minutes = $(this).attr("data-value");
// console.log(type); // console.log(type);
@@ -104,14 +109,14 @@ $(function() {
var order_id = $('#order_id').text(); var order_id = $('#order_id').text();
var ref_no = $('#ref_no').text(); var ref_no = $('#ref_no').text();
var callback = $('#callback_url').text(); var callback = $('#callback_url').text();
var requested_time = new Date($("#requested_date_time").text()); // var requested_time = new Date($("#requested_date_time").text());
if(type == 'plus'){ // if(type == 'after'){
requested_time.setMinutes(requested_time.getMinutes() + minutes); // requested_time.setMinutes(requested_time.getMinutes() + minutes);
}else{ // }else{
requested_time.setMinutes(requested_time.getMinutes() - minutes); // requested_time.setMinutes(requested_time.getMinutes() - minutes);
} // }
// console.log(requested_time); // console.log(requested_time);
callback_url(callback,ref_no,order_id,status,type,minutes,requested_time); callback_url(callback,ref_no,order_id,status,type,minutes);
}); });
$(document).on('click','.access_number', function(event){ $(document).on('click','.access_number', function(event){
@@ -201,20 +206,30 @@ function show_order_detail(url,sr_no){
dataType: "json", dataType: "json",
success: function(data) { success: function(data) {
// console.log(data); // console.log(data);
$(".tbl_customer").show();
if(data.status != "delivered"){
$('#accepted').show();
if(data.status != "ready_to_delivery" && data.status != "send_to_kitchen"){
$('#cancel').show();
}
}else{
$('#accepted').hide();
$('#cancel').hide();
}
var delivery = data["delivery"]; var delivery = data["delivery"];
var items = data["order_items"]; var items = data["order_items"];
var item_list = $('.summary-items'); var item_list = $('.summary-items');
var newDate = new Date(data.requested_time); var newDate = new Date(data.requested_time);
var time = timeFormat(newDate); var time = timeFormat(newDate);
var requested_date = newDate.getFullYear() + '-' + (newDate.getMonth() > 10? newDate.getMonth() : '0' + (newDate.getMonth() + 1)) +'-'+ (newDate.getDate() > 10? newDate.getDate() : '0' + newDate.getDate()) +' '+time; var requested_date = newDate.getFullYear() + '-' + (newDate.getMonth() >= 10? newDate.getMonth() : '0' + (newDate.getMonth() + 1)) +'-'+ (newDate.getDate() >= 10? newDate.getDate() : '0' + newDate.getDate()) +' '+time;
if((data.expected_waiting_time!=undefined) && (data.expected_waiting_time!=null)){ if((data.expected_waiting_time!=undefined) && (data.expected_waiting_time!=null)){
var expDate = new Date(data.expected_waiting_time); // var expDate = new Date(data.expected_waiting_time);
var exptime = timeFormat(expDate); // var exptime = timeFormat(expDate);
var expected_time = expDate.getFullYear() + '-' + (expDate.getMonth() > 10? expDate.getMonth() : '0' + (expDate.getMonth() + 1)) +'-'+ (expDate.getDate() > 10? expDate.getDate() : '0' + expDate.getDate()) +' '+exptime; // var expected_time = expDate.getFullYear() + '-' + (expDate.getMonth() >= 10? expDate.getMonth() : '0' + (expDate.getMonth() + 1)) +'-'+ (expDate.getDate() >= 10? expDate.getDate() : '0' + expDate.getDate()) +' '+exptime;
$('.expected_time').show(); $('.expected_time').show();
$('#expected_time').text(expected_time? expected_time : ''); $('#expected_time').text(data.expected_waiting_time? data.expected_waiting_time : '');
}else{ }else{
$('.expected_time').hide(); $('.expected_time').hide();
$('#expected_time').text(''); $('#expected_time').text('');
@@ -334,7 +349,7 @@ function callback_url(callback,ref_no,order_id,status,min_type,time,exptime,reas
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: url, url: url,
data: {order_id: order_id, status: status, expected_time: expected_time, remark: reason, access_code: access_code}, data: {order_id: order_id, status: status, min_type: min_type, expected_time: waiting_time, remark: reason, access_code: access_code},
dataType: "json", dataType: "json",
success: function(data) { success: function(data) {
if (data.status) { if (data.status) {
@@ -383,7 +398,7 @@ function showNewOrder(order_reservation){
if((order_reservation!=undefined) && (order_reservation!=null) && (order_reservation!="")){ if((order_reservation!=undefined) && (order_reservation!=null) && (order_reservation!="")){
var date = new Date(order_reservation.requested_time); var date = new Date(order_reservation.requested_time);
var time = timeFormat(date); var time = timeFormat(date);
var requested_date = date.getFullYear() + '-' + (date.getMonth() > 10? date.getMonth() : '0' + (date.getMonth() + 1)) +'-'+ (date.getDate() > 10? date.getDate() : '0' + date.getDate()) +' '+time; var requested_date = date.getFullYear() + '-' + (date.getMonth() >= 10? date.getMonth() : '0' + (date.getMonth() + 1)) +'-'+ (date.getDate() >= 10? date.getDate() : '0' + date.getDate()) +' '+time;
//audio play //audio play
var audio = new Audio('/beep-07.wav'); // define your audio var audio = new Audio('/beep-07.wav'); // define your audio
// setTimeout(function(){ // setTimeout(function(){

View File

@@ -220,8 +220,12 @@ class Api::OrdersController < Api::ApiController
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# print # print
assigned_item = AssignedOrderItem.find_by_instance_code(order_item.item_instance_code) assigned_item = AssignedOrderItem.find_by_instance_code(order_item.item_instance_code)
assigned_items = AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'")
if !assigned_items.nil?
assigned_items.each do |assign_item|
# order queue stations # order queue stations
oqs = assigned_item.order_queue_station oqs = assign_item.order_queue_station
order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf
@@ -248,6 +252,8 @@ class Api::OrdersController < Api::ApiController
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Cancelled)", before_updated_qty ) order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Cancelled)", before_updated_qty )
end end
end
end
return return_json_status_with_code(200, "updated successfully!") return return_json_status_with_code(200, "updated successfully!")
else else

View File

@@ -9,7 +9,12 @@ class Origami::OrderReservationController < BaseOrigamiController
def update def update
@id = params[:order_id] @id = params[:order_id]
@status = params[:status] @status = params[:status]
min_type = params[:min_type]
if min_type != ""
expected_waiting_time = params[:expected_time] expected_waiting_time = params[:expected_time]
else
expected_waiting_time = min_type + " " +params[:expected_time]
end
remark = params[:remark] remark = params[:remark]
access_code = params[:access_code] access_code = params[:access_code]
@order_reservation = OrderReservation.find(@id) @order_reservation = OrderReservation.find(@id)

View File

@@ -1,7 +1,7 @@
class Reports::OrderReservationController < BaseReportController class Reports::OrderReservationController < BaseReportController
# authorize_resource :class => false # authorize_resource :class => false
def index def index
@providers = [["All",''], ["food2u","food2u"], ["Pick-Up","pick_up"], ["ygndoor2door","ygndoor2door"], ["Direct Delivery","direct_delivery"]] @providers = [["All",''], ["Direct Delivery","direct_delivery"],["Pick-Up","pick_up"],["food2u","food2u"], ["ygndoor2door","ygndoor2door"]]
from, to = get_date_range_from_params from, to = get_date_range_from_params

View File

@@ -30,7 +30,7 @@ class OrderReservation < ApplicationRecord
order_reservation.payment_type = order_reserve[:payment_info][:payment_type] order_reservation.payment_type = order_reserve[:payment_info][:payment_type]
order_reservation.payment_status = order_reserve[:payment_info][:payment_status] order_reservation.payment_status = order_reserve[:payment_info][:payment_status]
order_reservation.payment_ref = order_reserve[:payment_info][:payment_ref] order_reservation.payment_ref = order_reserve[:payment_info][:payment_ref]
order_reservation.taxes = order_reserve[:payment_info][:taxes] order_reservation.taxes = order_reserve[:payment_info][:taxes].to_json
order_reservation.total_amount = order_reserve[:payment_info][:sub_total] order_reservation.total_amount = order_reserve[:payment_info][:sub_total]
order_reservation.total_tax = order_reserve[:payment_info][:total_tax] order_reservation.total_tax = order_reserve[:payment_info][:total_tax]
order_reservation.discount_amount = order_reserve[:payment_info][:discount_amount] order_reservation.discount_amount = order_reserve[:payment_info][:discount_amount]
@@ -193,7 +193,7 @@ class OrderReservation < ApplicationRecord
order_reservation.sale_id = sale_id order_reservation.sale_id = sale_id
end end
if !expected_waiting_time.nil? if !expected_waiting_time.nil?
order_reservation.expected_waiting_time = DateTime.parse(expected_waiting_time).utc order_reservation.expected_waiting_time = expected_waiting_time
end end
order_reservation.status = status order_reservation.status = status
if !remark.nil? if !remark.nil?

View File

@@ -360,7 +360,7 @@
<tr> <tr>
<td width ="50%" class="footer-td align-left col-blue"> <td width ="50%" class="footer-td align-left col-blue">
<button type="button" class="btn btn-lg bg-red waves-effect" id="cancel" data-value="rejected"> <button type="button" class="btn btn-lg bg-red waves-effect" id="cancel" data-value="rejected">
<strong>DECLINE</strong> <strong>REJECT</strong>
</button> </button>
</td> </td>
<td width ="50%" class="footer-td align-right col-blue"> <td width ="50%" class="footer-td align-right col-blue">
@@ -394,8 +394,8 @@
</tr> </tr>
</table> </table>
</div> </div>
<div class="card-block"> <div class="card-block" style="height: 520px">
<table class="table"> <table class="table tbl_customer">
<tbody> <tbody>
<tr> <tr>
<td class="body-td align-left"> <td class="body-td align-left">
@@ -413,8 +413,8 @@
<b id="customer_name"></b> <b id="customer_name"></b>
</td> </td>
<td class="body-td align-right expected_time"> <td class="body-td align-right expected_time">
<span class="font-13">EXPECTED TIME</span><br> <span class="font-13">COOKING TIME</span><br>
<b id="expected_time"></b> <b><span id="expected_time"></span> MINS</b>
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -467,7 +467,7 @@
<div class="row text-center m-t-20"> <div class="row text-center m-t-20">
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"></div> <div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"></div>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6"> <div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg btn-link bg-info timer_type" data-value="plus">After</button> <button type="button" class="btn btn-lg btn-link bg-info timer_type" data-value="after">After</button>
</div> </div>
</div> </div>

View File

@@ -71,7 +71,6 @@
delimiter = "" delimiter = ""
end %> end %>
<% <%
discount_amount = 0.0 discount_amount = 0.0
delivery_fee = 0.0 delivery_fee = 0.0
convenience_charge = 0.0 convenience_charge = 0.0
@@ -96,20 +95,24 @@
discount_amount = order_reservation.discount_amount discount_amount = order_reservation.discount_amount
delivery_fee = order_reservation.delivery_fee ? order_reservation.delivery_fee : 0.0 delivery_fee = order_reservation.delivery_fee ? order_reservation.delivery_fee : 0.0
convenience_charge = order_reservation.convenience_charge convenience_charge = order_reservation.convenience_charge
JSON.parse(order_reservation.taxes).each do |tax_data|
(order_reservation.taxes).each do |tax| %> if tax_data[0] == "delivery_tax"
delivery_tax = tax_data[1]
<% end elsif tax_data[0] == "convenience_tax"
convenience_tax = tax_data[1]
elsif tax_data[0] == "commercial_tax"
commercial_tax = tax_data[1]
end
end
total_discount_amount += discount_amount.to_f total_discount_amount += discount_amount.to_f
total_delivery_fee += delivery_fee.to_f total_delivery_fee += delivery_fee.to_f
total_convenience_charge += convenience_charge total_convenience_charge += convenience_charge.to_f
total_delivery_tax += delivery_tax total_delivery_tax += delivery_tax.to_f
total_convenience_tax += convenience_tax total_convenience_tax += convenience_tax.to_f
total_commercial_tax += commercial_tax total_commercial_tax += commercial_tax.to_f
total_tax += order_reservation.total_tax total_tax += order_reservation.total_tax.to_f
total_amount += order_reservation.total_amount total_amount += order_reservation.total_amount.to_f
grand_total += order_reservation.grand_total grand_total += order_reservation.grand_total.to_f
%> %>
<% <%
if order_reservation.provider == 'pick_up' if order_reservation.provider == 'pick_up'
@@ -123,7 +126,7 @@
<tr> <tr>
<td><%= order_reservation.email %></td> <td><%= order_reservation.email %></td>
<td><%= order_reservation.order_reservation_type %></td> <td><%= order_reservation.order_reservation_type %></td>
<td><%= order_reservation.requested_time.utc.getlocal.strftime("%d %m %Y %I:%M %p") %></td> <td><%= order_reservation.requested_time.utc.getlocal.strftime("%Y-%m-%d %I:%M %p") %></td>
<td><%= provider%></td> <td><%= provider%></td>
<td><%= order_reservation.payment_type%></td> <td><%= order_reservation.payment_type%></td>
<td><%= order_reservation.payment_status%></td> <td><%= order_reservation.payment_status%></td>

View File

@@ -63,19 +63,25 @@
delivery_fee = order_reservation.delivery_fee ? order_reservation.delivery_fee : 0.0 delivery_fee = order_reservation.delivery_fee ? order_reservation.delivery_fee : 0.0
convenience_charge = order_reservation.convenience_charge convenience_charge = order_reservation.convenience_charge
(order_reservation.taxes).each do |tax| %> JSON.parse(order_reservation.taxes).each do |tax_data|
if tax_data[0] == "delivery_tax"
<% end delivery_tax = tax_data[1]
elsif tax_data[0] == "convenience_tax"
convenience_tax = tax_data[1]
elsif tax_data[0] == "commercial_tax"
commercial_tax = tax_data[1]
end
end
total_discount_amount += discount_amount.to_f total_discount_amount += discount_amount.to_f
total_delivery_fee += delivery_fee.to_f total_delivery_fee += delivery_fee.to_f
total_convenience_charge += convenience_charge total_convenience_charge += convenience_charge.to_f
total_delivery_tax += delivery_tax total_delivery_tax += delivery_tax.to_f
total_convenience_tax += convenience_tax total_convenience_tax += convenience_tax.to_f
total_commercial_tax += commercial_tax total_commercial_tax += commercial_tax.to_f
total_tax += order_reservation.total_tax total_tax += order_reservation.total_tax.to_f
total_amount += order_reservation.total_amount total_amount += order_reservation.total_amount.to_f
grand_total += order_reservation.grand_total grand_total += order_reservation.grand_total.to_f
%> %>
<% <%
if order_reservation.provider == 'pick_up' if order_reservation.provider == 'pick_up'
@@ -89,7 +95,7 @@
<tr> <tr>
<td><%= order_reservation.email %></td> <td><%= order_reservation.email %></td>
<td><%= order_reservation.order_reservation_type %></td> <td><%= order_reservation.order_reservation_type %></td>
<td><%= order_reservation.requested_time.utc.getlocal.strftime("%d %m %Y %I:%M %p") %></td> <td><%= order_reservation.requested_time.utc.getlocal.strftime("%Y-%m-%d %I:%M %p") %></td>
<td><%= provider%></td> <td><%= provider%></td>
<td><%= order_reservation.payment_type%></td> <td><%= order_reservation.payment_type%></td>
<td><%= order_reservation.payment_status%></td> <td><%= order_reservation.payment_status%></td>