From 5d60d620b4848f5289a73e25cf9931260d88326c Mon Sep 17 00:00:00 2001 From: Yan Date: Thu, 22 Jun 2017 18:03:16 +0630 Subject: [PATCH] add for room tab and complete --- app/models/sale.rb | 2 +- app/views/origami/home/show.html.erb | 1 + app/views/origami/rooms/show.html.erb | 56 +++++++++++++++++++++++++-- 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/app/models/sale.rb b/app/models/sale.rb index 6b02e4c8..f79d8642 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -15,7 +15,7 @@ class Sale < ApplicationRecord has_many :bookings scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") } - scope :complete_sale, -> { where("sale_status = 'completed' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") } + scope :complete_sale, -> { where("sale_status = 'completed' and receipt_date BETWEEN '#{DateTime.now.utc.beginning_of_day}' AND '#{DateTime.now.utc.end_of_day}'") } REPORT_TYPE = { "daily" => 0, diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 364b0f91..7bc62af7 100644 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -338,6 +338,7 @@ $('#pay').on('click',function() { window.location.href = '/origami/sale/'+ sale_id + "/payment"; }); +// Bill Request $('#request_bills').click(function() { var order_id = $('#save_order_id').attr('data-order'); var ajax_url = "/origami/" + order_id + "/request_bills"; diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index c1797158..d3b78719 100644 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -98,7 +98,7 @@
<% if @status == "order" %> -
ORDER DETAILS
+
ORDER DETAILS
<% else %>
INVOICE DETAILS
<% end %> @@ -139,7 +139,7 @@ sub_total = sub_total + sale_item.price %> - <% unless sale_item.price <= 0 %> + <% unless sale_item.price == 0 %> <%= sale_item.product_name %> <%= sale_item.qty %> @@ -155,7 +155,7 @@ @order_items.each do |order_item | sub_total = sub_total + order_item.price - unless order_item.price <= 0 %> + unless order_item.price == 0 %> <%= order_item.item_name %> <%= order_item.qty %> @@ -259,15 +259,65 @@ $(document).ready(function(){ var order_id = $(this).attr("data-id"); window.location.href = '/origami/order/' + order_id; }) + + // bind customer to order or sale + $("#customer").on('click', function(){ + var sale = $('#sale_id').val(); + if (sale) { + var sale_id = sale + }else{ + var sale_id = $('#save_order_id').attr('data-order'); + } + + window.location.href = '/origami/'+ sale_id + "/customers" + }); + + // Discount for Payment + $('#discount').click(function() { + var sale = $('#sale_id').val(); + if (sale!="") { + var sale_id = sale + }else{ + var sale_id = $('#save_order_id').attr('data-order'); + } + + if(sale_id!=""){ + window.location.href = '/origami/' + sale_id + '/discount' + } + else { + alert("Please select an table!"); + } + + return false; + }); }); + + $('#pay').on('click',function() { var sale_id = $('#sale_id').val(); window.location.href = '/origami/sale/'+ sale_id + "/payment"; }); + +// Bill Request +$('#request_bills').click(function() { + var order_id = $('#save_order_id').attr('data-order'); + var ajax_url = "/origami/" + order_id + "/request_bills"; + $.ajax({ + type: "POST", + url: ajax_url, + data: 'order_id='+ order_id, + success:function(result){ + + location.reload(); + } + }); +}); + $('#move').on('click',function(){ var dining_id = "<%= @room.id %>" window.location.href = '/origami/table/'+ dining_id + "/moveroom"; }) + $('#back').on('click',function(){ window.location.href = '/origami/'; })