diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index 609fdfc2..831f2f5f 100755 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -66,30 +66,30 @@ $(document).on('turbolinks:load', function() { } var date = new Date(data[field]["created_at"]); - var show_date = date.getDate() + "-" + date.getMonth() + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes(); + var show_date = date.getDate() + "-" + date.getMonth() + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes(); row ='
' +'
' - +'
' - +''+data[field]["table_type"]+'- ' - +''+ data[field]["zone"] +'' - +''+ data[field]["order_id"] +'' - +'
' + +'
' + +''+data[field]["table_type"]+'-'+ data[field]["zone"] +'' + +'' + +''+data[field]["order_id"]+'' + +'
' - +'
' - +''+ data[field]["item_name"] +'- ' - +''+ data[field]["qty"] +' ' - +'
' + +'

' + +''+ data[field]["item_name"] +'- ' + +' [x'+ data[field]["qty"] +'] ' + +'

' +'

'+ options +'

' - +'

' - +'Order at' - +''+ show_date +' - ' + +'' + +'Order at - ' + +''+ show_date +'
' - +''+ data[field]["item_order_by"] +' ' - +'
' - +'

' + +'Order By - '+ data[field]["item_order_by"] +' ' + +' ' + +'' +' ' +' ' @@ -114,6 +114,7 @@ $(document).on('turbolinks:load', function() { $(document).on('click', '.queue_station', function(event){ var orderZone=$(this).children().children().children('.order-zone').text().trim(); + var orderZoneType=$(this).children().children().children('.order-zone-type').text().trim(); // var orderItem=$(this).children().children().children('.order-item').text(); var assigned_item_id = $(this).children().find(".assigned-order-item").text(); var orderQty = $(this).children().children().children('.order-qty').text(); @@ -121,8 +122,8 @@ $(document).on('turbolinks:load', function() { var orderAt = $(this).children().children().children().children('.order-at').text(); var orderCustomer = $(this).children().children('.order-customer').text(); var order_status = $(this).children().children('.order-status').text(); - - $('#order-title').text("ORDER DETAILS - " + orderZone); + $('.cus_name').removeClass('hidden'); + $('#order-title').text("ORDER DETAILS - " + orderZoneType); $('#order-by').text(orderBy); $('#order-at').text(orderAt); $('#order-customer').text(orderCustomer); @@ -134,7 +135,8 @@ $(document).on('turbolinks:load', function() { type: 'GET', url: '/oqs/' + orderZone, data: { 'status' : order_status }, - success: function(res){ + success: function(res){ + for (i = 0; i < res.length; i++) { var data = JSON.stringify(res[i]); var parse_data = JSON.parse(data); diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 66714f33..629b2542 100755 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -16,7 +16,6 @@ //= require bootstrap/js/popper.min //= require bootstrap/js/bootstrap-material-design.min //= require jquery_nested_form -//= require cable //= require momentjs/moment //= require bootstrap-material-datetimepicker/js/bootstrap-material-datetimepicker //= require multi-select/js/jquery.multi-select.js @@ -343,6 +342,7 @@ $(document).ready(function(){ } }); }); + }); diff --git a/app/assets/javascripts/channels/order_queue_station.js b/app/assets/javascripts/channels/order_queue_station.js index 4fb7d214..11f21727 100755 --- a/app/assets/javascripts/channels/order_queue_station.js +++ b/app/assets/javascripts/channels/order_queue_station.js @@ -37,26 +37,27 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann row ='
' +'' +'
' - +'

' - +''+items[field]["table_type"]+'- ' - +''+ items[field]["zone"] +'' - +''+ items[field]["order_id"] +'- ' - +'

' + - +'

' - +''+ items[field]["item_name"] +'- ' - +''+ items[field]["qty"] +'- ' - +'

' + +'
' + +''+items[field]["table_type"]+'-'+ items[field]["zone"] +'' + +'' + +''+items[field]["order_id"]+'' + +'
' + +'

' + +''+ items[field]["item_name"] +'- ' + +' [x'+ items[field]["qty"] +'] ' + +'

' +'

'+ options +'

' - +'

' - +'Order at' - +''+ show_date +' - ' + +'' + +'Order at - ' + +''+ show_date +'
' - +''+ items[field]["item_order_by"] +' ' - +'
' - +'

' + +'Order By - '+ items[field]["item_order_by"] +' ' + +' ' + +'' +' ' +' ' @@ -73,8 +74,12 @@ App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChann var $divs = $("div.queue_station"); var SortListDivs = $divs.sort(function (a, b) { + first = $(a).attr('data-date'); next = $(b).attr('data-date'); + console.log(first); + console.log("hi") + console.log(next); return parseInt(next.substring(4, 16)) - parseInt(first.substring(4, 16)); }); $("#oqs_container").html(SortListDivs); diff --git a/app/assets/stylesheets/OQS.scss b/app/assets/stylesheets/OQS.scss index f6211dec..8258a2df 100755 --- a/app/assets/stylesheets/OQS.scss +++ b/app/assets/stylesheets/OQS.scss @@ -21,11 +21,51 @@ color: #fff !important; background-color: blue; } - -.order-item { - width: 49%; - font-size: 18px; - margin: 0px 0px 5px 0px; +.cashier_number{ + width: 33%; + height:58px; + line-height:58px; + text-align:center; + background:#54A5AF; + // float:left; + // margin:2px; + font-size:20px; + color:white; + // cursor:pointer; +} +.del_cashier_number{ + opacity:0.6, +} +.pay{ + width: 86%; + height:174px; + line-height:174px; + text-align:center; + font-size:20px; + color:white; +} +.long{ + width:43%; +} +.orange{ + background-color:#FF7F50; } +.red { + background-color:#F44336; +} + +.green{ + background-color: #009900; +} +.left{ + margin-left:1px; +} + +.bottom{ + margin-bottom:1px; +} +.border-left{ + border-left:1px solid #fff; +} diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 48edff46..ea71f60e 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -39,7 +39,16 @@ class ApplicationController < ActionController::Base end def cache_license() + @license = License.new(url, subdomain) + ##creating md5 hash + md5_hostname = Digest::MD5.new + md5key = md5_hostname.update(request.host) + if (@license.detail_with_local_cache(subdomain, md5key.to_s) == true) + return @license + else + return nil + end end def current_license(url, key) @@ -50,8 +59,6 @@ class ApplicationController < ActionController::Base key, iv = AESEncDec.export_key(passphrase) if (@license.detail_with_local_file(key, key, iv) == true) - #if (@license.detail == true) - return @license else return nil @@ -100,7 +107,9 @@ class ApplicationController < ActionController::Base private def check_license if License.check_license_file - + # if !License.check_license_valid + # redirect_to install_path + # end else redirect_to install_path end diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index ff917887..7bde1e98 100755 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -67,7 +67,7 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController @order.guest = params[:guest_info] @order.table_id = params[:table_id] # this is dining facilities's id @order.new_booking = true - @order.employee_name = current_login_employee.name + @order.waiters = current_login_employee.name #Create Table Booking or Room Booking if !params["booking_id"].nil? # check booking id is already completed. diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index 44ddd60e..d5ea194f 100755 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -6,7 +6,9 @@ class Origami::DiscountsController < BaseOrigamiController sale_id = params[:id] if Sale.exists?(sale_id) @sale_data = Sale.find(sale_id) + @table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id) end + @member_discount = MembershipSetting.find_by_discount(1) @accounts = Account.all end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 27b9cc52..febf7e45 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -24,6 +24,7 @@ class Origami::HomeController < BaseOrigamiController @dining.bookings.active.each do |booking| if booking.sale_id.nil? && booking.booking_status != 'moved' + @order_items = Array.new booking.booking_orders.each do |booking_order| order = Order.find(booking_order.order_id) @@ -31,26 +32,42 @@ class Origami::HomeController < BaseOrigamiController @obj_order = order @customer = order.customer @date = order.created_at + @booking= booking order.order_items.each do |item| @order_items.push(item) end + accounts = @customer.tax_profiles + @account_arr =[] + accounts.each do |acc| + account = TaxProfile.find(acc) + @account_arr.push(account) + end end end @status_order = 'order' else sale = Sale.find(booking.sale_id) if sale.sale_status != "completed" && sale.sale_status != 'void' + @sale_array.push(sale) if @status_order == 'order' @status_order = 'sale' end + @booking= booking @date = sale.created_at @status_sale = 'sale' @obj_sale = sale @customer = sale.customer + accounts = @customer.tax_profiles + @account_arr =[] + accounts.each do |acc| + account = TaxProfile.find(acc) + @account_arr.push(account) + end end end end + end private diff --git a/app/controllers/origami/other_charges_controller.rb b/app/controllers/origami/other_charges_controller.rb index c402782d..c7e20ba6 100755 --- a/app/controllers/origami/other_charges_controller.rb +++ b/app/controllers/origami/other_charges_controller.rb @@ -5,6 +5,7 @@ class Origami::OtherChargesController < BaseOrigamiController sale_id = params[:sale_id] if Sale.exists?(sale_id) @sale_data = Sale.find(sale_id) + @table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id) end end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index d6671700..0ef1c1a5 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -116,6 +116,13 @@ class Origami::PaymentsController < BaseOrigamiController #get customer amount @customer = Customer.find(@sale_data.customer_id) + accounts = @customer.tax_profiles + @account_arr =[] + accounts.each do |acc| + account = TaxProfile.find(acc) + @account_arr.push(account) + end + rebate = MembershipSetting.find_by_rebate(1) # get member information if @customer.membership_id != nil && rebate @@ -136,6 +143,7 @@ class Origami::PaymentsController < BaseOrigamiController @sale_data.bookings.each do |sbk| df = DiningFacility.find(sbk.dining_facility_id) @table_no = df.type + ' ' + df.name + @checkin_time = sbk.checkin_at break end diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index f235aee3..6c0b98c8 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -24,10 +24,12 @@ class Origami::RoomsController < BaseOrigamiController @order_items = Array.new booking.booking_orders.each do |booking_order| order = Order.find(booking_order.order_id) + @customer = order.customer if (order.status == "new") @obj_order = order - @customer = order.customer + @date = order.created_at + @booking = booking order.order_items.each do |item| @order_items.push(item) end @@ -42,6 +44,7 @@ class Origami::RoomsController < BaseOrigamiController if @status_order == 'order' @status_order = 'sale' end + @booking = booking @date = sale.created_at @status_sale = 'sale' @obj_sale = sale diff --git a/app/controllers/transactions/bookings_controller.rb b/app/controllers/transactions/bookings_controller.rb new file mode 100644 index 00000000..b826cd52 --- /dev/null +++ b/app/controllers/transactions/bookings_controller.rb @@ -0,0 +1,59 @@ +class Transactions::BookingsController < ApplicationController + load_and_authorize_resource except: [:create] + before_action :set_transactions_booking, only: [:show, :edit, :update, :destroy] + + def index + + filter = params[:filter] + from = params[:from] + to = params[:to] + + if filter.nil? && from.nil? && to.nil? + @bookings = Booking.all.order("sale_id desc") + @bookings = Kaminari.paginate_array(@bookings).page(params[:page]).per(2) + else + sale = Sale.search(filter,from,to) + if sale.count > 0 + @bookings = sale + @bookings = Kaminari.paginate_array(@bookings).page(params[:page]).per(2) + else + @bookings = 0 + end + end + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @bookings } + end + + end + + # GET /transactions/bookings/1 + # GET /transactions/bookings/1.json + def show + + @booking = Booking.find(params[:id]) + + @order_items = [] + @booking.booking_orders.each do |booking_order| + @order = Order.find(booking_order.order_id) + #if (order.status == "new") + @order_items = @order_items + @order.order_items + #end + end + if @booking.sale_id.present? + @sale = Sale.find(@booking.sale_id) + end + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @booking } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_transactions_booking + @transactions_booking = Booking.find(params[:id]) + end +end diff --git a/app/controllers/transactions/credit_notes_controller.rb b/app/controllers/transactions/credit_notes_controller.rb index 339998f5..e28b5331 100755 --- a/app/controllers/transactions/credit_notes_controller.rb +++ b/app/controllers/transactions/credit_notes_controller.rb @@ -15,12 +15,11 @@ class Transactions::CreditNotesController < ApplicationController if filter.nil? && from.nil? && to.nil? && customer.nil? @sales = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING) - puts "cccccccccccc" else sale = Sale.search_credit_sales(customer,filter,from,to) if sale.count > 0 @sales = sale - @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50) + @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20) else @sales = 0 end diff --git a/app/controllers/transactions/orders_controller.rb b/app/controllers/transactions/orders_controller.rb index bd079d83..496d43cd 100755 --- a/app/controllers/transactions/orders_controller.rb +++ b/app/controllers/transactions/orders_controller.rb @@ -9,19 +9,18 @@ class Transactions::OrdersController < ApplicationController if filter.nil? && from.nil? && to.nil? && count.nil? orders = Order.order("order_id desc") - puts "ssssss" + else orders = Order.search(filter,from,to,count) - puts "aaaaa" end if !orders.nil? - @orders = Kaminari.paginate_array(orders).page(params[:page]).per(50) + @orders = Kaminari.paginate_array(orders).page(params[:page]).per(20) else @orders = [] end - puts @orders.to_json + respond_to do |format| format.html # index.html.erb format.json { render json: @orders } diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index 9aca7d87..8486d9ca 100755 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -11,13 +11,13 @@ class Transactions::SalesController < ApplicationController to = params[:to] if receipt_no.nil? && from.nil? && to.nil? - @sales = Sale.where("NOT sale_status = 'void' " ).order("sale_id desc").limit(500) - @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50) + @sales = Sale.where("NOT sale_status = 'void' " ).order("sale_id desc") + @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20) else sale = Sale.search(receipt_no,from,to) if sale.count > 0 @sales = sale - @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50) + @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20) else @sales = 0 end diff --git a/app/models/AESEncDec.rb b/app/models/AESEncDec.rb index b6231df7..b70328ed 100644 --- a/app/models/AESEncDec.rb +++ b/app/models/AESEncDec.rb @@ -5,6 +5,7 @@ require 'uri' class AESEncDec { cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc") +<<<<<<< HEAD def self.export_key(passphrase) # We want a 256 bit key symetric key based on passphrase digest = Digest::SHA256.new diff --git a/app/models/booking.rb b/app/models/booking.rb index e3d94a37..b65063a4 100755 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -41,6 +41,22 @@ class Booking < ApplicationRecord return new_dining.type end + def self.search(filter,from,to) + if filter.blank? + keyword = '' + else + keyword = "booking_id LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%" + end + + if from.present? && to.present? + sale = Sale.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and NOT sale_status = 'void' ", from,to) + query = sale.where(keyword) + else + where("receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%",) + end + + end + private def generate_custom_id self.booking_id = SeedGenerator.generate_id(self.class.name, "BKI") diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index ba01afb6..24a3e47b 100755 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -33,7 +33,6 @@ class DiningFacility < ApplicationRecord def get_current_booking booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1) - if booking.count > 0 then return booking[0] else diff --git a/app/models/license.rb b/app/models/license.rb index b32eb48f..9473f6a4 100755 --- a/app/models/license.rb +++ b/app/models/license.rb @@ -34,20 +34,13 @@ class License end end - def detail_with_local_file(lookup, key, iv) + def detail_with_local_cache(lookup) ##Check from local redis - if available load local otherwise get from remote - #cache_key = "store:license:#{key}:hostname" + cache_key = "store:license:#{@secret}:hostname" + end - # No Needs for current - # @secret = key - - #cache_license = nil - - ##Get redis connection from connection pool - # - - #Rails.logger.info "Cache key - " + cache_key.to_s + def detail_with_local_file(lookup, key, iv) has_license = check_license_file if has_license @@ -56,7 +49,6 @@ class License if cache_license.nil? ##change the d/e key - # @options = { query: {device: "SXlite", lookup: lookup, skey: @secret, token: SECRETS_CONFIG['provision_key']} } @params = { query: { lookup_type: self.server_mode, lookup: lookup, encrypted_key: key, iv_key: iv} } response = self.class.get("/request_license", @params) diff --git a/app/views/layouts/_left_sidebar.html.erb b/app/views/layouts/_left_sidebar.html.erb index cf9f77c0..fb326c24 100755 --- a/app/views/layouts/_left_sidebar.html.erb +++ b/app/views/layouts/_left_sidebar.html.erb @@ -89,7 +89,7 @@ <% end %> <% if can? :menage, Sale %>
  • - <%= (t :credit) + " " + (t :reports) %> + <%= (t :credit) %>
  • <% end %> diff --git a/app/views/oqs/edit/index.html.erb b/app/views/oqs/edit/index.html.erb index cf255912..99541e8a 100755 --- a/app/views/oqs/edit/index.html.erb +++ b/app/views/oqs/edit/index.html.erb @@ -1,5 +1,5 @@ -