diff --git a/app/assets/javascripts/order_reservation.js b/app/assets/javascripts/order_reservation.js
new file mode 100644
index 00000000..fdea26b8
--- /dev/null
+++ b/app/assets/javascripts/order_reservation.js
@@ -0,0 +1,189 @@
+
+$(function() {
+
+ $(".nav-item").on("click", function(){
+ type = $(this).attr("data-type");
+ refreshDetailData();
+ if (type == "pending") {
+ $(".first-1").click();
+ $('#accepted').text("Accepted");
+ $('#accepted').attr("data-value","accepted");
+ }else if(type == "processing"){
+ $(".second-1").click();
+ $('#accepted').text("SEND TO KITCHEN");
+ $('#accepted').attr("data-value","processed");
+ }else if(type == "delivery"){
+ $(".third-1").click();
+ $('#accepted').text("READY TO DELIVERY");
+ $('#accepted').attr("data-value","delivery");
+ }else if(type == "completed"){
+ $(".fourth-1").click();
+ $('#accepted').text("PICK-UP");
+ $('#accepted').attr("data-value","completed");
+ }
+ // console.log(type);
+ });
+
+ jQuery(function(){
+ jQuery('.first-1').click();
+ });
+
+ $(".custom-tr").on("click", function(){
+ $(".custom-tr").removeClass("tr-active");
+ $(this).addClass("tr-active");
+ var order_id = $(this).attr("data-id");
+ var sr_no = $(this).attr("data-sr-no");
+ var url = "order_reservation/get_order/"+order_id;
+ show_order_detail(url,sr_no);
+ });
+
+ function refreshDetailData(){
+ $("#sr_number").text("");
+ $("#delivery_info").text("");
+ $("#contact_info").text("");
+ $('.summary-items').html("");
+ $('#sub_total').text("0.00");
+ $('#delivery_fee').text("0.00");
+ $('#total_charges').text("0.00");
+ $('#total_tax').text("0.00");
+ $('#grand_total').text("0.00");
+ }
+
+ //show order list
+ function show_order_detail(url,sr_no){
+ $('.summary-items').html("");
+ //Start Ajax
+ $.ajax({
+ type: "GET",
+ url: url,
+ data: {},
+ dataType: "json",
+ success: function(data) {
+ // console.log(data);
+ var delivery = data["delivery"];
+ var items = data["order_items"];
+
+ var item_list = $('.summary-items');
+ item_list.empty();
+
+ if(items!=undefined && items!=""){
+ if(items.length > 0){
+ for(var i in items) {
+ 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 = '
'
+ +''+items[i].item_name
+ +' '+items[i].qty+ ' X '+items[i].unit_price+' '
+ +' '
+ +''+ total +' '
+ +' ';
+ $('.summary-items').append(row);
+ }
+
+ $('#sub_total').text(data.total_amount);
+ $('#delivery_fee').text(delivery.delivery_fee);
+ $('#total_charges').text(0);
+ $('#total_tax').text(data.total_tax);
+ $('#grand_total').text(data.grand_total);
+
+ var address = delivery.address +', ' +delivery.township+", (" +delivery.direction_address+")"
+ $('#customer_name').text(data.customer_name);
+ $('#phone').text(data.phone);
+ $('#address').text(address);
+ $('#delivery_to').text(delivery.provider);
+
+ $('#ref_no').text(data.transaction_ref);
+ $('#callback_url').text(data.callback_url);
+ $('#order_id').text(data.order_reservation_id);
+
+ if(delivery.provider == "direct_delivery"){
+ $("#delivery_info").text("(DELIVERY)");
+ }else if(delivery.provider == "self_pick_up"){
+ $("#delivery_info").text("(PICK-UP)");
+ }
+
+ if(data.order_remark!=null && data.order_remark!=""){
+ $("#order_remark").text(data.order_remark);
+ }else if(data.reservation_remark!=null && data.reservation_remark!=""){
+ $("#order_remark").text(data.reservation_remark);
+ }
+ $("#sr_number").text("No."+sr_no);
+ $("#contact_info").text();
+ }
+ }
+ }
+ });
+ //end Ajax
+ }
+
+ $("#accepted").on("click", function(){
+ var status = $(this).attr("data-value");
+ var order_id = $('#order_id').text();
+ var ref_no = $('#ref_no').text();
+ var callback = $('#callback_url').text();
+ callback_url(callback,ref_no,order_id,status);
+ });
+
+ $("#cancel").on("click", function(){
+ var status = $(this).attr("data-value");
+ var order_id = $('#order_id').text();
+ var callback = $('#callback_url').text();
+ var ref_no = $('#ref_no').text();
+ callback_url(callback,ref_no,order_id,status);
+ });
+
+ 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: 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.message,
+ type: 'success',
+ html: true,
+ closeOnConfirm: false,
+ closeOnCancel: false,
+ allowOutsideClick: false
+ }, function () {
+ window.location.href = '/origami/order_reservation';
+ });
+ }
+ }
+ });
+ }else{
+ swal({
+ title: 'Oops',
+ text: data.message,
+ type: 'error',
+ html: true,
+ closeOnConfirm: false,
+ closeOnCancel: false,
+ allowOutsideClick: false
+ }, function () {
+ window.location.href = '/origami/order_reservation';
+ });
+ }
+ }
+ });
+ }
+});
+
diff --git a/app/assets/stylesheets/order_reservation.scss b/app/assets/stylesheets/order_reservation.scss
new file mode 100644
index 00000000..c33e1f32
--- /dev/null
+++ b/app/assets/stylesheets/order_reservation.scss
@@ -0,0 +1,88 @@
+ .nav-tabs > li.active > a,
+ .nav-tabs > li.active > a:hover,
+ .nav-tabs > li.active > a:focus {
+ border-bottom: 2px solid #2196F3 ;
+ bottom: 2px ;
+}
+
+.nav-tabs .nav-link {
+ padding: 0.5286em .33em;
+}
+.nav-tabs li a.active {
+ color: #111 !important;
+ border-bottom: 0px solid #fff !important;
+}
+.nav-tabs .nav-link.active {
+ color: #111;
+ border-color: #fff;
+}
+.nav-tabs > li > a {
+ margin-right: 0px;
+ color:#fff !important;
+}
+
+.nav-tabs > li > a {
+ border-bottom: 2px solid #2196F3;
+ bottom: 2px;
+}
+.nav-tabs.tab-col-teal > li > a:before {
+ border-bottom: 0px solid #009688;
+}
+.nav-tabs .nav-item{
+ margin-bottom: 2px ;
+}
+.num{
+ color:#fff;
+ text-align: center;
+ margin-bottom: -1px !important;
+}
+.nav-tabs .nav-link.active > p{
+ color: #111;
+ border-color: #fff;
+}
+
+/*Custosm Class*/
+.table .header-td{
+ border-top:0px solid !important;
+ border-bottom: 0px solid !important;
+ padding:3px 7px !important;
+ border-top:0px solid !important;
+ border-bottom: 0px solid !important;
+}
+.custom-card-block .table td:first-child,
+.custom-card-block .table td:nth-child(2),
+.custom-card-footer .table td:first-child,
+.custom-card-footer .table td:nth-child(2){
+ border-top:0px solid !important;
+}
+
+.custom-card-footer .footer-td ,
+.grand-card-footer .footer-td {
+ border-top:0px solid !important;
+ border-bottom:0px solid !important;
+ font-weight: bold;
+ padding:6px 10px;
+}
+.custom-card-header{
+ border-bottom: 1px solid #F8BBD0 !important;
+ padding:13px 5px !important;
+}
+.custom-card-footer{
+ border-top: 1px solid #F8BBD0 !important;
+}
+.custom-card-block,
+.grand-card-footer,
+.custom-card-footer{
+ padding :5px !important;
+}
+.custom-table{
+ background-color:#F3E5F5;
+}
+.custom-table tbody tr td,
+.custom-table tbody tr th{
+ border-top: 1px solid #FFEBEE;
+ border-bottom: 1px solid #FFEBEE;
+}
+.tr-active{
+ background-color : #FFCDD2;
+}
\ No newline at end of file
diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb
index 4abab9c8..8e23d2c9 100755
--- a/app/controllers/origami/addorders_controller.rb
+++ b/app/controllers/origami/addorders_controller.rb
@@ -111,7 +111,8 @@ class Origami::AddordersController < BaseOrigamiController
end
items_arr.push(items)
}
-
+puts items_arr.to_json
+ puts "sssssssssssssssssssssss"
# begin
# if params[:order_source] == "quick_service"
# customer_id = "CUS-000000000002" # for no customer id from mobile
diff --git a/app/controllers/origami/movetable_controller.rb b/app/controllers/origami/movetable_controller.rb
index 9cacd8f4..bbc02bdc 100755
--- a/app/controllers/origami/movetable_controller.rb
+++ b/app/controllers/origami/movetable_controller.rb
@@ -71,35 +71,37 @@ class Origami::MovetableController < BaseOrigamiController
booking.booking_orders.each do |booking_order|
order = Order.find(booking_order.order_id)
- if order.status == 'new'
+ if order.status == 'new'
order.order_items.each do |order_item|
order_items.push(order_item)
end
- end
+ end
end
end
end
@get_type = Booking.update_dining_facility(booking_array,change_to,change_from)
- # get printer info
- @from = (DiningFacility.find(change_from)).name
- @to = (DiningFacility.find(change_to)).name
- @type = (DiningFacility.find(change_to)).type
- @moved_by = @current_user.name
- @date = DateTime.now
- @shop = Shop.first
- unique_code = "MoveTablePdf"
- pdf_no = PrintSetting.where(:unique_code => unique_code).count
- #print_settings = PrintSetting.find_by_unique_code(unique_code)
- printer_array = []
- printer_array = PrintSetting.where(:unique_code => unique_code)
+ if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
+ # get printer info
+ @from = (DiningFacility.find(change_from)).name
+ @to = (DiningFacility.find(change_to)).name
+ @type = (DiningFacility.find(change_to)).type
+ @moved_by = @current_user.name
+ @date = DateTime.now
+ @shop = Shop.first
+ unique_code = "MoveTablePdf"
+ pdf_no = PrintSetting.where(:unique_code => unique_code).count
+ #print_settings = PrintSetting.find_by_unique_code(unique_code)
+ printer_array = []
+ printer_array = PrintSetting.where(:unique_code => unique_code)
- for i in 0..pdf_no
- if i != pdf_no
- print_settings = printer_array[i]
- printer = Printer::ReceiptPrinter.new(print_settings)
- printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by,order_items)
+ for i in 0..pdf_no
+ if i != pdf_no
+ print_settings = printer_array[i]
+ printer = Printer::ReceiptPrinter.new(print_settings)
+ printer.print_move_table(print_settings,@to,@from ,@shop,@date,@type,@moved_by,order_items)
+ end
end
end
end
diff --git a/app/controllers/origami/order_reservation_controller.rb b/app/controllers/origami/order_reservation_controller.rb
index db56d882..562eaaed 100644
--- a/app/controllers/origami/order_reservation_controller.rb
+++ b/app/controllers/origami/order_reservation_controller.rb
@@ -1,12 +1,58 @@
class Origami::OrderReservationController < BaseOrigamiController
def index
- @webview = check_mobile
- @shop = Shop::ShopDetail
-
+ @order = OrderReservation.all
end
+ def update
+ @id = params[:order_id]
+ @status = params[:status]
+ @order_reservation = OrderReservation.find(@id)
+ status = true
+ if status
+ if @status == "processed"
+ result = OrderReservation.create_doemal_order(@order_reservation,current_user)
+ elsif @status == "delivery"
+ OrderReservation.update_order_reservation(@id, nil, "ready_to_delivery")
+ response = OrderReservation.send_status_to_ordering(@order_reservation.callback_url,@order_reservation.transaction_ref,"ready_to_delivery")
+ result = {:status=> true, :message => "ready for delivery" }
+ elsif @status == "completed"
+ result = OrderReservation.update_doemal_payment(@order_reservation,current_user)
+ else
+ if @status == "cancel"
+ OrderReservation.update_order_reservation(@id, nil, "cancelled")
+ result = {:status=> true, :message => "rejected" }
+ else
+ OrderReservation.update_order_reservation(@id, nil, "accepted")
+ result = {:status=> true, :message => "accepted" }
+ end
+ end
+ render :json => result.to_json
+ else
+ result = {:status=> false, :message => "Order not accepted !" }
+ render :json => result.to_json
+ end
+ end
+
+ def get_order
+ if (params[:id])
+ @order = OrderReservation.find(params[:id])
+ return @order
+ end
+ end
+
+ def send_status
+ if params[:status] == "cancel"
+ status = "rejected"
+ else
+ status = params[:status]
+ end
+
+ response = OrderReservation.send_status_to_ordering(params[:url],params[:ref_no],status)
+
+ render :json => response
+ end
end
diff --git a/app/models/customer.rb b/app/models/customer.rb
index 3eb51a24..c380f24b 100755
--- a/app/models/customer.rb
+++ b/app/models/customer.rb
@@ -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]
diff --git a/app/models/order_reservation.rb b/app/models/order_reservation.rb
index 62342b0c..2fa99cf4 100644
--- a/app/models/order_reservation.rb
+++ b/app/models/order_reservation.rb
@@ -7,13 +7,18 @@ class OrderReservation < ApplicationRecord
has_many :order_reservation_items
belongs_to :delivery
+ SEND_TO_KITCHEN = "send_to_kitchen"
+ READY_TO_DELIVERY = "ready_to_deliver"
+ DELIVERED = "delivered"
+ COMPLETED = "completed"
+
def self.addOrderReservationInfo(params)
check_order_reservation = OrderReservation.where("transaction_ref = ?",params[:reference])
if check_order_reservation.empty?
order_reservation = OrderReservation.new
order_reservation.order_reservation_type = params[:order_type]
order_reservation.customer_id = params[:cus_info]
- order_reservation.requested_time = Time.parse(params[:requested_time]).utc.strftime("%Y-%m-%d %H:%M:%S")
+ order_reservation.requested_time = DateTime.parse(params[:requested_time]).utc.strftime("%Y-%m-%d %H:%M:%S")
order_reservation.callback_url = params[:callback_url]
order_reservation.transaction_ref = params[:reference]
if params[:order_info]
@@ -48,6 +53,206 @@ class OrderReservation < ApplicationRecord
end
end
+ def self.create_doemal_order(order,current_user)
+ 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)
+ }
+
+ 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_user.name
+ @order.employee_name = current_user.name
+
+ @order.is_extra_time = is_extra_time
+ @order.extra_time = extra_time
+
+ @status, @booking = @order.generate
+
+ # Order.send_customer_view(@booking)
+ if @status && @booking
+
+ @status, @sale = Sale.request_bill(@order,current_user,current_user)
+
+ #order status send to doemal
+ callback_response = send_status_to_ordering(order.callback_url,order.transaction_ref,SEND_TO_KITCHEN)
+ #order reservation status updated
+ update_order_reservation(order.id, @sale.sale_id, SEND_TO_KITCHEN)
+
+ result = {:status=> @status, :data => @sale, :message => "created" }
+ return result
+ end
+ end
+
+ def self.update_doemal_payment(order,current_user)
+ if(Sale.exists?(order.sale_id))
+ saleObj = Sale.find(order.sale_id)
+ shop_details = Shop.first
+ # rounding adjustment
+ if shop_details.is_rounding_adj
+ a = saleObj.grand_total % 25 # Modulus
+ b = saleObj.grand_total / 25 # Division
+ #not calculate rounding if modulus is 0 and division is even
+ #calculate rounding if modulus is zero or not zero and division are not even
+ if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0)
+ new_total = Sale.get_rounding_adjustment(saleObj.grand_total)
+ rounding_adj = new_total-saleObj.grand_total
+ saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj)
+ end
+ end
+ #end rounding adjustment
+
+ sale_payment = SalePayment.new
+ sale_payment.process_payment(saleObj, current_user.name, saleObj.grand_total, "cash")
+
+ #order status send to doemal
+ callback_response = send_status_to_ordering(order.callback_url,order.transaction_ref,DELIVERED)
+ #order reservation status updated
+ update_order_reservation(order.id, saleObj.sale_id, DELIVERED)
+
+ result = {:status=> true, :message => DELIVERED }
+ return result
+ # rebate_amount = nil
+
+ # For Cashier by Zone
+ # bookings = Booking.where("sale_id='#{sale_id}'")
+
+ # if bookings[0].dining_facility_id.to_i > 0
+ # table = DiningFacility.find(bookings[0].dining_facility_id)
+ # cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
+ # cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id)
+ # else
+ # shift = ShiftSale.find(saleObj.shift_sale_id)
+ # cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
+ # end
+
+ # For Print
+ # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
+ # receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
+ # unique_code = "ReceiptBillPdf"
+ # if !receipt_bill_a5_pdf.empty?
+ # receipt_bill_a5_pdf.each do |receipt_bilA5|
+ # if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
+ # if receipt_bilA5[1] == '1'
+ # unique_code = "ReceiptBillA5Pdf"
+ # else
+ # unique_code = "ReceiptBillPdf"
+ # end
+ # end
+ # end
+ # end
+
+ # customer= Customer.find(saleObj.customer_id)
+
+ # get member information
+ # rebate = MembershipSetting.find_by_rebate(1)
+ # credit_data = SalePayment.find_by_sale_id_and_payment_method(sale_id,'creditnote')
+
+ # if customer.membership_id != nil && rebate && credit_data.nil?
+ # member_info = Customer.get_member_account(customer)
+ # if member_info["status"] == true
+ # rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
+ # current_balance = SaleAudit.paymal_search(sale_id)
+ # end
+ # end
+
+ #orders print out
+ # if params[:type] == "quick_service"
+ # booking = Booking.find_by_sale_id(sale_id)
+ # if booking.dining_facility_id.to_i>0
+ # table_id = booking.dining_facility_id
+ # else
+ # table_id = 0
+ # end
+
+ # booking.booking_orders.each do |order|
+ # # Order.pay_process_order_queue(order.order_id, table_id)
+ # oqs = OrderQueueStation.new
+ # oqs.pay_process_order_queue(order.order_id, table_id)
+ # end
+
+ # end
+
+ #for card sale data
+ # card_data = Array.new
+ # card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id)
+ # if !card_sale_trans_ref_no.nil?
+ # card_sale_trans_ref_no.each do |cash_sale_trans|
+ # card_res_date = cash_sale_trans.res_date.strftime("%Y-%m-%d").to_s
+ # card_res_time = cash_sale_trans.res_time.strftime("%H:%M").to_s
+ # card_no = cash_sale_trans.pan.last(4)
+ # card_no = card_no.rjust(19,"**** **** **** ")
+ # card_data.push({'res_date' => card_res_date, 'res_time' => card_res_time, 'batch_no' => cash_sale_trans.batch_no, 'trace' => cash_sale_trans.trace, 'pan' => card_no, 'app' => cash_sale_trans.app, 'tid' => cash_sale_trans.terminal_id, 'app_code' => cash_sale_trans.app_code, 'ref_no' => cash_sale_trans.ref_no, 'mid' => cash_sale_trans.merchant_id})
+ # end
+ # end
+
+ # get printer info
+ # print_settings=PrintSetting.find_by_unique_code(unique_code)
+ # Calculate Food and Beverage Total
+ # item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
+ # discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
+
+ # printer = Printer::ReceiptPrinter.new(print_settings)
+ # filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data)
+
+ # render json: JSON.generate({:status => saleObj.rebate_status, :message => "Can't Rebate coz of Sever Error ", :filename => filename, :receipt_no => sale_receipt_no, :printer_name => printer_name})
+
+ #end
+ end
+ end
+
+ def self.send_status_to_ordering(url,ref_no,status)
+ base_url = "http://192.168.1.186:3002"
+ post_url = base_url + url
+
+ begin
+ response = HTTParty.post(post_url,
+ :body => { id: 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
+ return response
+ end
+
+ def self.update_order_reservation(id, sale_id, status)
+ order_reservation = OrderReservation.find(id)
+ if sale_id.present?
+ order_reservation.sale_id = sale_id
+ end
+ order_reservation.status = status
+ order_reservation.save
+ end
+
private
def generate_custom_id
self.order_reservation_id = SeedGenerator.generate_id(self.class.name, "ODRS")
diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb
index 2af02ca8..7c736299 100755
--- a/app/views/origami/home/show.html.erb
+++ b/app/views/origami/home/show.html.erb
@@ -488,7 +488,9 @@
active="true">Edit
> Void
<% end %>
+ <% if current_login_employee.role != "waiter" %>
active="true">Discount
+ <% end %>
Charges
<% if !@split_bill.nil? %>
diff --git a/app/views/origami/order_reservation/_order_item.json.jbuilder b/app/views/origami/order_reservation/_order_item.json.jbuilder
new file mode 100644
index 00000000..794da464
--- /dev/null
+++ b/app/views/origami/order_reservation/_order_item.json.jbuilder
@@ -0,0 +1,15 @@
+json.id item.order_reservation_items_id
+json.order_id item.order_reservation_id
+json.item_status item.item_status
+json.item_code item.item_code
+json.item_instance_code item.item_instance_code
+json.item_name item.item_name
+json.alt_name item.alt_name
+json.set_menu_items item.set_menu_items
+json.account_id item.account_id
+json.qty item.qty
+json.unit_price item.unit_price
+json.price item.price
+json.remark item.remark
+json.options item.options
+json.taxable item.taxable
\ No newline at end of file
diff --git a/app/views/origami/order_reservation/get_order.json.jbuilder b/app/views/origami/order_reservation/get_order.json.jbuilder
new file mode 100644
index 00000000..5fdd5293
--- /dev/null
+++ b/app/views/origami/order_reservation/get_order.json.jbuilder
@@ -0,0 +1,25 @@
+if @order
+
+ json.(@order, :order_reservation_id,:order_reservation_type,:customer_id,
+ :requested_time,:callback_url,:transaction_ref,:item_count,:total_customer,:payment_type,
+ :payment_status,:payment_ref,:total_amount,:total_tax,
+ :discount_amount,:grand_total,:status,:order_remark,
+ :reservation_remark)
+ @delivery = Delivery.find_by_order_reservation_id(@order.order_reservation_id)
+ if @delivery
+ json.delivery do |json|
+ # json.(@article.author, :id, :name)
+ json.(@delivery, :provider,:delivery_type,:township,
+ :address,:direction_address,:delivery_fee,:remark)
+ end
+ end
+ if @order.order_reservation_items
+ json.order_items @order.order_reservation_items do |item|
+ json.partial! 'origami/order_reservation/order_item', item: item
+ end
+ end
+ @customer = Customer.find(@order.customer_id)
+
+ json.customer_name @customer.name
+ json.phone @customer.contact_no
+end
diff --git a/app/views/origami/order_reservation/index.html.erb b/app/views/origami/order_reservation/index.html.erb
index 42628dd9..c157b1bb 100644
--- a/app/views/origami/order_reservation/index.html.erb
+++ b/app/views/origami/order_reservation/index.html.erb
@@ -1,17 +1,19 @@
+<%= stylesheet_link_tag 'order_reservation', media: 'all', 'data-turbolinks-track': 'reload' %>
+<%= javascript_include_tag 'order_reservation', 'data-turbolinks-track': 'reload' %>
@@ -22,62 +24,26 @@
@@ -90,35 +56,26 @@
@@ -130,49 +87,26 @@
@@ -184,35 +118,26 @@
@@ -227,59 +152,25 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb
index 18b7b69d..9125a315 100755
--- a/app/views/origami/payments/show.html.erb
+++ b/app/views/origami/payments/show.html.erb
@@ -437,10 +437,12 @@
- Print
+ <% if ENV["SERVER_MODE"] != "cloud" %>
+ Print
+ <% end %>
-
diff --git a/app/views/origami/surveys/_form.html.erb b/app/views/origami/surveys/_form.html.erb
index 5640b549..1b6d07e2 100755
--- a/app/views/origami/surveys/_form.html.erb
+++ b/app/views/origami/surveys/_form.html.erb
@@ -9,12 +9,12 @@
- <%= f.input :child, input_html: { value: @survey_data.child, class: 'col-md-10' }%>
+ <%= f.input :child, input_html: { value: @survey_data.child, class: 'col-md-10', :onChange => "total_customer();" }%>
- <%= f.input :adult, input_html: { value: @survey_data.adult, class: 'col-md-10' }%>
+ <%= f.input :adult, input_html: { value: @survey_data.adult, class: 'col-md-10', :onChange => "total_customer();" }%>
@@ -30,7 +30,7 @@
- <%= f.input :total_customer, input_html: { value: @survey_data.total_customer, class: 'col-md-11'} %>
+ <%= f.input :total_customer, input_html: { value:@survey_data.total_customer , :readonly => true, class: 'col-md-11'} %>
<%= f.input :local , input_html: { value: @survey_data.local, class: 'col-md-11' }%>
@@ -67,12 +67,12 @@
- <%= f.input :child , input_html: { class: 'col-md-10' }%>
+ <%= f.input :child , input_html: { class: 'col-md-10' , :onChange => "total_customer();"}%>
- <%= f.input :adult , input_html: { class: 'col-md-10' }%>
+ <%= f.input :adult , input_html: { class: 'col-md-10' , :onChange => "total_customer();"}%>
@@ -88,7 +88,7 @@
- <%= f.input :total_customer, input_html: { class: 'col-md-11'} %>
+ <%= f.input :total_customer, input_html: { :readonly => true, class: 'col-md-11'} %>
<%= f.input :local , input_html: { class: 'col-md-11' }%>
@@ -457,4 +457,11 @@ var cashier_type = "<%= @cashier_type %>";
});
}
}
+
+ function total_customer(){
+ var child = $("#survey_child").val() || 0;
+ var adult = $("#survey_adult").val() || 0;
+ var result = parseInt(child) + parseInt(adult);
+ $("#survey_total_customer").val(result);
+ }
\ No newline at end of file
diff --git a/app/views/print_settings/_form.html.erb b/app/views/print_settings/_form.html.erb
index 9c62b36f..e07da111 100755
--- a/app/views/print_settings/_form.html.erb
+++ b/app/views/print_settings/_form.html.erb
@@ -13,14 +13,10 @@
<%= f.input :header_font_size %>
<%= f.input :item_font_size %>
- <%
- if(@server_mode != 'cloud')
- %>
+ <% if(@server_mode != 'cloud') %>
<%= f.input :printer_name, :as => :select, :collection => Printer::PrinterWorker.printers, include_blank: false %>
- <%
- else
- %>
- <%= f.input :printer_name, :as => :select, :collection => [], include_blank: false %>
+ <% else %>
+ <%= f.input :printer_name %>
<% end %>
<%= f.input :brand_name %>
<%= f.input :printer_type %>
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb
index 7aa7b6ba..bd889f51 100755
--- a/config/initializers/assets.rb
+++ b/config/initializers/assets.rb
@@ -37,7 +37,7 @@ Rails.application.config.assets.precompile += %w( CRM.js )
# --- Image Uploader ----
Rails.application.config.assets.precompile += %w( fileinput.min.js )
-# --- Customer/ Customer - Crm ----
+# --- Add order/ Add order - Crm ----
Rails.application.config.assets.precompile += %w( addorder.css )
Rails.application.config.assets.precompile += %w( addorder.js )
@@ -53,4 +53,9 @@ Rails.application.config.assets.precompile += %w( sx-sidebar.css )
Rails.application.config.assets.precompile += %w( inventory_definitions.css )
Rails.application.config.assets.precompile += %w( inventory.js )
+# --- Customer/ Customer - Crm ----
+Rails.application.config.assets.precompile += %w( order_reservation.css )
+Rails.application.config.assets.precompile += %w( order_reservation.js )
+
+
diff --git a/config/locales/en.yml b/config/locales/en.yml
index b2862dd2..cdce1df7 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -75,6 +75,10 @@ en:
dine_in_cashier: "Dine-in Cashier"
quick_service: "Quick Service"
order_reservation: "Order & Reservation"
+ pending: "Pending"
+ processing: "Processing"
+ delivering: "Delivering"
+ completed: "Completed"
views:
btn:
diff --git a/config/locales/mm.yml b/config/locales/mm.yml
index 3a025eaf..aba51ed5 100644
--- a/config/locales/mm.yml
+++ b/config/locales/mm.yml
@@ -70,6 +70,10 @@ mm:
dine_in_cashier: "Dine-in Cashier"
quick_service: "Quick Service"
order_reservation: "Order & Reservation"
+ pending: "Pending"
+ processing: "Processing"
+ delivering: "Delivering"
+ completed: "Completed"
views:
btn:
diff --git a/config/routes.rb b/config/routes.rb
index 0e868e3b..bd1d8921 100755
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -268,6 +268,9 @@ scope "(:locale)", locale: /en|mm/ do
#order and reservation
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", :defaults => { :format => 'json' }
end
#--------- Waiter/Ordering Station ------------#
diff --git a/db/migrate/20180406080240_create_order_reservations.rb b/db/migrate/20180406080240_create_order_reservations.rb
index cde96ac0..740ce6f1 100644
--- a/db/migrate/20180406080240_create_order_reservations.rb
+++ b/db/migrate/20180406080240_create_order_reservations.rb
@@ -7,6 +7,7 @@ class CreateOrderReservations < ActiveRecord::Migration[5.1]
t.datetime :requested_time, :null => false
t.string :callback_url, :null => false
t.string :transaction_ref, :null => false
+ t.string :sale_id
t.integer :item_count, :null => false, :default => 0
t.integer :total_customer
t.string :payment_type