diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index f5a44e26..500fcacb 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -1,18 +1,17 @@ //middle edit -$(function() { +$(function() { var role = $('#role').val(); var second_display_lookup = $("#display_type").val(); - console.log(second_display_lookup); type = window.location.href.indexOf("quick_service") || window.location.href.indexOf("food_court"); modify_order = window.location.href.indexOf("modify_order"); - + //click menu sidebar menu category $(".product").on("click", function(){ var url = $(this).attr('data-ref'); - show_product_list(url); - }); + show_product_list(url); + }); //show menu item list when click menu category - function show_product_list(url_item){ + function show_product_list(url_item){ var menu_list = $('.menu_items_list'); menu_list.empty(); @@ -26,20 +25,19 @@ $(function() { if (type ==-1 && modify_order == -1){ url_item = url_item } - console.log(url_item) //Start Ajax - $.ajax({ - type: "GET", - url: url_item, + $.ajax({ + type: "GET", + url: url_item, data: {}, dataType: "json", success: function(data) { - + var menu_items_list = $('.menu_items_list'); menu_items_list.empty(); product = data; - for(var field in product) { + for(var field in product) { if (product[field].unit_price > 0) { qty = 1; options = []; @@ -55,13 +53,13 @@ $(function() { if (type ==-1 && modify_order == -1){ image_path = product[field].image_path.url; } - + row = '
' +'
' +'
' +'
'+ product[field].name +'
' - + +'
' +"
' +'
' +'
' - - +'
'; + + +''; } else { @@ -105,8 +103,8 @@ $(function() { + JSON.stringify(options) +"' data-image=''>" +'
'+ product[field].name +'
' +'' - - + + +'' +"
' +'
' +'' - - +''; + + +''; } $('.menu_items_list').append(row); } } } }); - //end Ajax + //end Ajax } //end show list function //click menu sidebar menu category @@ -158,7 +156,7 @@ $(function() { sub_category = $(this).siblings('.sub_category_list'); show_sub_category_list(sub_url,sub_category,menu_id); } - }); + }); //End menu category Click //click menu sidebar menu category @@ -169,19 +167,19 @@ $(function() { var menu_id = $(this).attr("data-id"); var url = "get_menu_category/"+menu_id; show_menu_item_list(url,menu_id); - }); + }); //End menu category Click //show menu item list when click menu category - function show_menu_item_list(url_item,menu_id){ + function show_menu_item_list(url_item,menu_id){ var menu_list = $('.menu_items_list'); menu_list.empty(); menus = JSON.parse(localStorage.getItem("menus")); if (menus != null) { - for(var i in menus) { + for(var i in menus) { var categories = menus[i]["categories"]; - for(var ii in categories) { + for(var ii in categories) { if (categories[ii]["id"] == menu_id) { var menu_items = categories[ii]["items"]; show_menu_list(menu_items); @@ -192,7 +190,7 @@ $(function() { type = window.location.href.indexOf("quick_service") || window.location.href.indexOf("food_court"); modify_order = window.location.href.indexOf("modify_order"); - + if (type != -1 && modify_order != -1) { url_item = '../../../addorders/'+url_item; }if(modify_order == -1 && type != -1){ @@ -203,9 +201,9 @@ $(function() { } //Start Ajax - $.ajax({ - type: "GET", - url: url_item, + $.ajax({ + type: "GET", + url: url_item, data: {}, dataType: "json", success: function(data) { @@ -215,12 +213,12 @@ $(function() { show_menu_list(menu_items); } }); - //end Ajax + //end Ajax } } //end show list function //click item row for item set - $(document).on('click', '.set_item_box', function(event){ + $(document).on('click', '.set_item_box', function(event){ $(".instance-list").empty(); $(".options-list").empty(); $(".selected-set-list").empty(); @@ -233,8 +231,8 @@ $(function() { instances = $(this).data('instances'); item_options = $(this).data('options'); - for(var field in item_sets) { - + for(var field in item_sets) { + $('.set_order').attr('data-min-qty',item_sets[field]["min_selectable_qty"]); value = item_sets[field]["instances"]; @@ -242,9 +240,9 @@ $(function() { $(value).each(function(i){ menus = JSON.parse(localStorage.getItem("menus")); if (menus != null) { - for(var j in menus) { + for(var j in menus) { var categories = menus[j]["categories"]; - for(var ii in categories) { + for(var ii in categories) { var items = categories[ii]["items"]; for(var iii in items) { var result = items[iii]["instances"]; @@ -276,7 +274,7 @@ $(function() { +'' +'' +' ' - $(".instance-list").append(row); + $(".instance-list").append(row); } } } @@ -325,22 +323,22 @@ $(function() { +'' +' ' - $(".instance-list").append(row); + $(".instance-list").append(row); } }); } }); } - for(var j in item_options) { + for(var j in item_options) { value = item_options[j]["values"]; type = item_options[j]["type"]; row = "

"+type+"

" $(value).each(function(i){ row +=""; + +type+"' data-value='"+value[i]+"' data-group='set_menu_default'>"+value[i]+""; }); - $(".options-list").append(row); + $(".options-list").append(row); } $('.set-item').attr('data-code',instances[0]['code']); $('.set-item').attr('data-name',instances[0]['name']); @@ -357,8 +355,8 @@ $(function() { $('#set_unit_price').text($(this).attr('data-price')); // $('#set_unit_price').text(0); }); - // click instance for add item set - $(document).on('click', '.instance_box', function(event){ + // click instance for add item set + $(document).on('click', '.instance_box', function(event){ $(".options-list").empty(); @@ -370,18 +368,18 @@ $(function() { max_qty = $(this).data('max-qty'); code = $(this).data('code'); - + if (rowCount.length+1 <= max_qty) { - for(var field in item_options) { + for(var field in item_options) { value = item_options[field]["values"]; type = item_options[field]["type"]; row = "

"+type+"

" $(value).each(function(i){ row +=""; + +value[i]+""; }); - $(".options-list").append(row); + $(".options-list").append(row); } } // if($(this).hasClass('selected-instance') == true){ @@ -408,7 +406,7 @@ $(function() { var total_price = +sub_total + +total; $(this).addClass('selected-instance'); - set = "
'+$(this).data('name')+'' +'
' +'
' - + +' ' +'
' // +'' +'' - - + + +'' - +''; + +''; } $('.menu_items_list').append(row); @@ -1596,4 +1597,4 @@ $(function() { //end is_sub_item false } } -}); \ No newline at end of file +}); diff --git a/app/assets/javascripts/channels/second_display_view.js b/app/assets/javascripts/channels/second_display_view.js index 9e5ab3fa..721b098f 100644 --- a/app/assets/javascripts/channels/second_display_view.js +++ b/app/assets/javascripts/channels/second_display_view.js @@ -1,13 +1,13 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', { -// App.messages = App.cable.subscriptions.create('MessagesChannel', { +// App.messages = App.cable.subscriptions.create('MessagesChannel', { connected: function() {}, disconnected: function() {}, - received: function(data) { + received: function(data) { var hostname = location.hostname.trim(); - if(data.from == "" || hostname == data.from){ + if(data.from == "" || hostname == data.from){ var items = data.data; var tax = data.tax_profiles; var status= data.status @@ -16,8 +16,8 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', { } $('#second_display_slider').addClass("hidden") $('#second_display_items').removeClass("hidden") - - + + // append items if (status == "add") { for(var i in items) { @@ -34,15 +34,15 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', { // d_option = items[i].options; // if (d_option){ - // option_name = "-"+items[i].options; + // option_name = "-"+items[i].options; // }else{ // option_name = ''; // } d_option = items[i].opt; if (items[i].click_type != "add_icon"){ - option_name = "-"+items[i].options; - data_option = items[i].options ; + option_name = "-"+items[i].options; + data_option = items[i].options ; }else{ option_name = ' '; data_option = '[]'; @@ -56,25 +56,25 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', { var instance_code = $(item_row[j]).attr('data-instance-code'); var r_option = $(item_row[j]).attr('data-options'); if (item_code == items[i].item_code && instance_code == items[i].instance_code && r_option==d_option) { - if (qty > 1) { + if (qty > 1) { qty = parseInt($(item_row[j]).children('#item_qty').text()) + qty; - }else{ + }else{ qty = parseInt($(item_row[j]).children('#item_qty').text()) + 1; } - + $(item_row[j]).children('#item_qty').text(qty); parseFloat($(item_row[j]).children('#item_price').text(parseFloat(price*qty).toFixed(2))); append =1; }else{ - if (qty > 1) { + if (qty > 1) { qty = qty; - }else{ + }else{ qty = 1; } - } - }); + } + }); if (append===0) { - row ="'+rowCount+'' +'' + items[i].name+ ' ' + instance + ' ' + option_name +'' +'' + qty + '' - +'' + +'' + parseFloat(price).toFixed(2) - +'' + +'' +''; $(".second_display_items tbody").append(row); - + } } } @@ -117,28 +117,29 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', { +''+rowCount+'' +'' + item_name+ ' ' + name + ''+option+'' +'' + qty + '' - +'' + +'' + parseFloat(total).toFixed(2) - +'' + +'' +''; $(".second_display_items tbody").append(row); rowCount = rowCount + 1; - + } } //remove item if(status == "remove"){ for(var i in items) { - var item_code = items[i].item_code; + var item_code = items[i].instance_code; $("#order-items-table tbody > tr.item_box_"+item_code+"").remove(); } } //remove item //update item qty if(status == "update_qty"){ + for(var i in items) { - var item_code = items[i].item_code; + var item_code = items[i].instance_code; var item_qty = parseInt(items[i].qty); var item_price = parseFloat(items[i].price); var item_total = parseFloat(item_qty * item_price).toFixed(2); @@ -157,8 +158,8 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', { $(item_row).each(function(i){ var unit_price = parseFloat($(item_row[i]).attr('data-price')); var qty = parseFloat($(item_row[i]).children('#item_qty').text()); - total_price += qty*unit_price; - }); + total_price += qty*unit_price; + }); //calculate Tax Amount for(var i in tax) { // substract , to give after discount @@ -177,13 +178,12 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', { var fixed_taxable_amount = parseFloat(total_tax_amount).toFixed(2); var fixed_grand_total = parseFloat(total_price + total_tax_amount).toFixed(2); - $('#s_sub_total').empty(); + $('#s_sub_total').empty(); $('#s_sub_total').append(fixed_total_price); - $('#s_tatal_tax').empty(); + $('#s_tatal_tax').empty(); $('#s_tatal_tax').append(fixed_taxable_amount); - $('#s_grand_total').empty(); + $('#s_grand_total').empty(); $('#s_grand_total').append(fixed_grand_total); } } }); - diff --git a/app/controllers/api/payments_controller.rb b/app/controllers/api/payments_controller.rb index 2f67a484..521f58a3 100755 --- a/app/controllers/api/payments_controller.rb +++ b/app/controllers/api/payments_controller.rb @@ -31,7 +31,7 @@ class Api::PaymentsController < Api::ApiController if @status sale_payment = SalePayment.new status, @sale, @membership_data = sale_payment.process_payment(sale, current_login_employee, sale.grand_total, "paymal",params[:card_no]) - + if status == true && @membership_data["status"] == true sale_payment = SalePayment.new status = sale_payment.process_payment(sale, current_login_employee, 0, "cash") @@ -95,7 +95,7 @@ class Api::PaymentsController < Api::ApiController @message = membership_data["message"] end else - @status = false + @status = false @message = "No gateway url!" end diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index d4486da5..22442fb0 100755 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -1,10 +1,10 @@ class Origami::AddordersController < BaseOrigamiController # before_action :set_dining, only: [:detail] - + def index @webview = false if check_mobile - @webview = true + @webview = true end @tables = Table.all.active.order('zone_id asc').group("zone_id") @@ -17,7 +17,7 @@ class Origami::AddordersController < BaseOrigamiController @cashier_type = params[:type] @webview = false if check_mobile - @webview = true + @webview = true end display_type = Lookup.find_by_lookup_type("display_type") if !display_type.nil? && display_type.value.to_i ==2 @@ -29,7 +29,7 @@ class Origami::AddordersController < BaseOrigamiController @menus = [] @menu = [] # else - # @menus = Menu.all + # @menus = Menu.all # @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc') # end @@ -57,10 +57,10 @@ class Origami::AddordersController < BaseOrigamiController def get_menu_category () if (params[:id]) - + #Pull this menu @menu = MenuCategory.find_by_id(params[:id]) - + # puts @menu.menu_items[1].item_attributes.to_json return @menu else @@ -96,9 +96,9 @@ class Origami::AddordersController < BaseOrigamiController return @sub_menu end end - + def get_all_product() - @product = Product.all + @product = Product.all end def create @@ -108,7 +108,7 @@ class Origami::AddordersController < BaseOrigamiController extra_time = '' items_arr = [] - JSON.parse(params[:order_items]).each { |i| + JSON.parse(params[:order_items]).each { |i| i["item_instance_code"] = i["item_instance_code"].downcase.to_s if i["item_instance_code"].include? "ext" is_extra_time = true @@ -192,25 +192,25 @@ class Origami::AddordersController < BaseOrigamiController type = 'order' from = getCloudDomain #get sub domain in cloud mode ActionCable.server.broadcast "order_channel",table: table,type:type,from:from - + end if params[:order_source] != "quick_service" && params[:order_source] != "food_court" process_order_queue(@order.order_id,@order.table_id,@order.source) - end - end + end + end # Order.send_customer_view(@booking) - + if current_user.role != "waiter" && params[:create_type] == "create_pay" if @status && @booking && (@order.source == 'quick_service') || (@order.source == 'food_court') - + @status, @sale = Sale.request_bill(@order,current_user,current_login_employee) - - # for second display + + # for second display if @order.source == 'quick_service' from = getCloudDomain #get sub domain in cloud mode - ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale",from:from + ActionCable.server.broadcast "second_display_channel",data: @sale,status:"sale",from:from end #end result = {:status=> @status, :data => @sale } @@ -220,7 +220,7 @@ class Origami::AddordersController < BaseOrigamiController result = {:status=> @status, :data => 0 } render :json => result.to_json end - + end # render json for http status code @@ -266,9 +266,9 @@ class Origami::AddordersController < BaseOrigamiController def process_order_queue(order_id,table_id,order_source) print_status = nil cup_status = nil - + #Send to background job for processing - order = Order.find(order_id) + order = Order.find(order_id) sidekiq = Lookup.find_by_lookup_type("sidekiq") if ENV["SERVER_MODE"] != 'cloud' cup_status = `#{"sudo service cups status"}` @@ -307,7 +307,7 @@ class Origami::AddordersController < BaseOrigamiController else if ENV["SERVER_MODE"] != 'cloud' from = "" - msg = ' Print Error ! Please contact to service' + msg = ' Print Error ! Please contact to service' ActionCable.server.broadcast "call_waiter_channel",table: msg,time:'print_error',from:from end if !sidekiq.nil? @@ -342,7 +342,7 @@ class Origami::AddordersController < BaseOrigamiController return from end - + private # def set_dining diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 71a364e2..37d3daa1 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -278,8 +278,12 @@ class Origami::PaymentsController < BaseOrigamiController end def show - puts current_user - puts "Hello current_user" + display_type = Lookup.find_by_lookup_type("display_type") + if !display_type.nil? && display_type.value.to_i ==2 + @display_type = display_type.value + else + @display_type = nil + end path = request.fullpath sale_id = params[:sale_id] @trans_flag = true diff --git a/app/controllers/origami/second_display_controller.rb b/app/controllers/origami/second_display_controller.rb index d28d7b06..21c0674d 100644 --- a/app/controllers/origami/second_display_controller.rb +++ b/app/controllers/origami/second_display_controller.rb @@ -9,7 +9,7 @@ class Origami::SecondDisplayController < BaseOrigamiController def customer_view display_type = Lookup.find_by_lookup_type("display_type") - if !display_type.nil? && display_type.value.to_i == 2 + if !display_type.nil? && display_type.value.to_i == 2 if params[:status]!= "billed" tax_profiles = TaxProfile.all.order("order_by asc") else @@ -17,7 +17,7 @@ class Origami::SecondDisplayController < BaseOrigamiController end if ENV["SERVER_MODE"] == 'cloud' from = request.subdomain + "." + request.domain - else + else from = "" end ActionCable.server.broadcast "second_display_view_channel",data: params[:data],tax_profiles: tax_profiles,status:params[:status],from:from diff --git a/app/models/sale.rb b/app/models/sale.rb index ad8cdba2..8b245b54 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -140,7 +140,13 @@ class Sale < ApplicationRecord # shift with terminal zone # set cashier - if order_source.downcase == "emenu" + if !order_source.nil? + orderSoure = order_source.downcase + else + orderSoure = nil + end + + if orderSoure == "emenu" if !booking.dining_facility_id.nil? table = DiningFacility.find(booking.dining_facility_id) cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 415e8f2c..90530096 100755 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -139,7 +139,16 @@ Team Viewer

+ <%if current_login_employee.role =="cashier" %>
  • +

    + + info + Second Display + +

    +
  • + <% end %>
    @@ -114,9 +114,9 @@ <% if payment.payment_method == 'paypar' %> Redeem Sale : - <% else %> + <% else %> <%= payment.payment_method.to_s.capitalize %> Sale : - <% end %> + <% end %> <% @sale_data.each do |data| %> <% pay_mth = payment.payment_method %> @@ -143,7 +143,7 @@
    - <% end %> + <% end %>
    @@ -211,7 +211,7 @@ <% if !@top_items.nil? %> <%= t :top %> <%= t("views.right_panel.detail.item") %> : - <%= @top_items.item_name %> + <%= @top_items.item_name %>
    (<%= @top_items.item_total_price %>) <% end %> @@ -249,7 +249,7 @@ $(function() { if ($('#server_mode').val() != "cloud" && display_type == 2) { document.getElementById('second_view').click(); } - window.location.href = '/origami/quick_service'; + window.location.href = '/origami/quick_service'; }); $(".fc_view").on('click', function() { @@ -262,13 +262,13 @@ $(function() { if ($('#server_mode').val() != "cloud" && display_type == 2) { document.getElementById('second_view').click(); } - window.location.href = '/origami/food_court'; + window.location.href = '/origami/food_court'; }); $(".order_reservation").on('click', function() { window.location.href = '/origami/order_reservation'; }); - + $("#second_view").on('click', function () { var url = $(this).attr("data-href"); window.open(url,'_blank'); @@ -278,4 +278,4 @@ $(function() { window.location.href = '/origami/reservation'; }); }); - \ 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 29d93ca7..6c86805b 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -31,7 +31,7 @@
    Sale ID : <% if @sale_data %><%=@sale_data.sale_id %><% end %>
    - +
    Customer : @@ -186,7 +186,7 @@
    - +
    Cash
    @@ -387,6 +387,8 @@
    10000
    + " id="server_mode"> +
    Pay
    @@ -442,7 +444,7 @@ <% else %>