From 7de795ee272b34393bbec4f347eabe22839b9029 Mon Sep 17 00:00:00 2001 From: NyanLinHtut Date: Thu, 20 Jun 2019 15:07:18 +0630 Subject: [PATCH] second display --- app/assets/javascripts/addorder.js | 349 +++++++++--------- .../channels/second_display_view.js | 60 +-- app/controllers/api/payments_controller.rb | 4 +- .../origami/addorders_controller.rb | 44 +-- .../origami/payments_controller.rb | 160 ++++---- .../origami/quick_service_controller.rb | 32 +- .../origami/second_display_controller.rb | 4 +- app/views/layouts/_header.html.erb | 9 + app/views/origami/addorders/detail.html.erb | 123 +++--- app/views/origami/dashboard/index.html.erb | 18 +- app/views/origami/payments/show.html.erb | 196 +++++----- ...ge_image_to_add_limit_in_display_images.rb | 11 + 12 files changed, 534 insertions(+), 476 deletions(-) create mode 100644 db/migrate/20190617045150_change_image_to_add_limit_in_display_images.rb diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 6ab73e7a..548c7d41 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -1,17 +1,16 @@ -$(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(); @@ -25,20 +24,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 = []; @@ -92,13 +90,13 @@ $(function() { +''+ product[field].unit_price +'' +'' +'' - +''; + +''; $('.menu_items_list').append(row); } } } }); - //end Ajax + //end Ajax } //end show list function //click menu sidebar menu category @@ -114,7 +112,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 @@ -125,19 +123,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); @@ -148,7 +146,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){ @@ -159,9 +157,9 @@ $(function() { } //Start Ajax - $.ajax({ - type: "GET", - url: url_item, + $.ajax({ + type: "GET", + url: url_item, data: {}, dataType: "json", success: function(data) { @@ -171,12 +169,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(); @@ -189,8 +187,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"]; @@ -198,9 +196,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"]; @@ -232,7 +230,7 @@ $(function() { +'' +'' +' ' - $(".instance-list").append(row); + $(".instance-list").append(row); } } } @@ -281,22 +279,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']); @@ -313,8 +311,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(); @@ -326,18 +324,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){ @@ -364,7 +362,7 @@ $(function() { var total_price = +sub_total + +total; $(this).addClass('selected-instance'); - set = "
'+$(this).data('name')+'' +'
' +'
' - + +' ' +'
' // +'' +'' - +''; ; + +''; ; $('.menu_items_list').append(row); } //end instances in menu-items alest 1 instance @@ -1492,4 +1493,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 59aaec3a..794908fa 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -8,14 +8,14 @@ class Origami::PaymentsController < BaseOrigamiController sale_data = Sale.find_by_sale_id(sale_id) sale_items = SaleItem.get_all_sale_items(sale_id) member_info = nil - + # For Cashier by Zone bookings = Booking.where("sale_id='#{sale_id}'") - # if bookings.count > 1 + # if bookings.count > 1 # # for Multiple Booking # table = DiningFacility.find(bookings[0].dining_facility_id) # else - # table = DiningFacility.find(bookings[0].dining_facility_id) + # table = DiningFacility.find(bookings[0].dining_facility_id) # end shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? @@ -48,7 +48,7 @@ class Origami::PaymentsController < BaseOrigamiController if !receipt_bill_a5_pdf.empty? receipt_bill_a5_pdf.each do |receipt_bilA5| - if receipt_bilA5[0] == 'ReceiptBillA5Pdf' + if receipt_bilA5[0] == 'ReceiptBillA5Pdf' if receipt_bilA5[1] == '1' unique_code = "ReceiptBillA5Pdf" else @@ -59,7 +59,7 @@ class Origami::PaymentsController < BaseOrigamiController end #shop detail - ## shop_detail = Shop.first + ## shop_detail = Shop.first # customer= Customer.where('customer_id=' +.customer_id) customer = Customer.find(sale_data.customer_id) # rounding adjustment @@ -71,14 +71,14 @@ class Origami::PaymentsController < BaseOrigamiController if (a != 0.0 && b%2 != 0.0) || (a==0.0 && b%2 !=0) new_total = Sale.get_rounding_adjustment(sale_data.grand_total) rounding_adj = new_total-sale_data.grand_total - sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj) + sale_data.update_attributes(grand_total: new_total,old_grand_total: sale_data.grand_total,rounding_adjustment:rounding_adj) end end #end rounding adjustment #record for sale audit action_by = current_user.name type = "FIRST_BILL" - + remark = "#{action_by} print out first bill for Receipt No #{sale_data.receipt_no}" sale_audit = SaleAudit.record_audit_sale(sale_id,remark,action_by,type ) # get member information @@ -102,12 +102,12 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) - filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount,nil,nil,nil) + filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount,nil,nil,nil) - result = { - :filepath => filename, - :printer_model => print_settings.brand_name, - :printer_url => print_settings.api_settings + result = { + :filepath => filename, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings } # Mobile Print @@ -127,7 +127,7 @@ class Origami::PaymentsController < BaseOrigamiController if(Sale.exists?(sale_id)) saleObj = Sale.find(sale_id) sale_items = SaleItem.get_all_sale_items(sale_id) - #shop_detail = Shop.first + #shop_detail = Shop.first # rounding adjustment if !path.include? ("credit_payment") if shop_detail.is_rounding_adj @@ -138,12 +138,12 @@ class Origami::PaymentsController < BaseOrigamiController 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) + saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:rounding_adj) end end end #end rounding adjustment - + sale_payment = SalePayment.new if path.include? ("credit_payment") sale_payment.process_payment(saleObj, current_user, cash, "cash", nil, true) @@ -166,7 +166,7 @@ class Origami::PaymentsController < BaseOrigamiController table = DiningFacility.find(bookings.dining_facility_id) cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) cashier_terminal = CashierTerminal.find(cashier_zone.cashier_terminal_id) - + type = 'payment' from = getCloudDomain #get sub domain in cloud mode ActionCable.server.broadcast "order_channel",table: table,type:type,from:from @@ -193,11 +193,11 @@ class Origami::PaymentsController < BaseOrigamiController if !receipt_bill_a5_pdf.empty? receipt_bill_a5_pdf.each do |receipt_bilA5| - if receipt_bilA5[0] == 'ReceiptBillA5Pdf' + if receipt_bilA5[0] == 'ReceiptBillA5Pdf' if receipt_bilA5[1] == '1' unique_code = "ReceiptBillA5Pdf" # else - + end end end @@ -208,16 +208,16 @@ class Origami::PaymentsController < BaseOrigamiController # 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) @@ -226,7 +226,7 @@ class Origami::PaymentsController < BaseOrigamiController else table_id = 0 end - + latest_order = booking.booking_orders.order("order_id DESC").limit(1).first() if !latest_order.nil? latest_order_no = latest_order.order_id @@ -241,13 +241,13 @@ class Origami::PaymentsController < BaseOrigamiController from = getCloudDomain #get sub domain in cloud mode ActionCable.server.broadcast "order_queue_station_channel",order: assign_order,from:from 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? + 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 @@ -259,7 +259,7 @@ class Origami::PaymentsController < BaseOrigamiController #card_balance amount for Paymal payment card_balance_amount = SaleAudit.getCardBalanceAmount(sale_id) - + # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) # Calculate Food and Beverage Total @@ -274,10 +274,16 @@ class Origami::PaymentsController < BaseOrigamiController #end end - end + end end def show + 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 @@ -287,11 +293,11 @@ class Origami::PaymentsController < BaseOrigamiController else @cashier_type = params[:type] end - + if path.include? ("credit_payment") @sale_payment = SalePayment.get_credit_amount_due_left(sale_id) end - + @member_discount = MembershipSetting.find_by_discount(1) @membership_rebate_balance=0 @@ -326,15 +332,15 @@ class Origami::PaymentsController < BaseOrigamiController lookup_changable_tax = Lookup.collection_of('changable_tax') if !lookup_changable_tax.empty? lookup_changable_tax.each do |changable_tax| - if changable_tax[0].downcase == "change" - if changable_tax[1] == '0' + if changable_tax[0].downcase == "change" + if changable_tax[1] == '0' @changable_tax = false end end end end - - @shop = shop_detail #show shop info + + @shop = shop_detail #show shop info @customer_lists = Customer.where("customer_id = 'CUS-000000000001' or customer_id = 'CUS-000000000002'") @@ -373,7 +379,7 @@ class Origami::PaymentsController < BaseOrigamiController 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) + saleObj.update_attributes(grand_total: new_total,old_grand_total: saleObj.grand_total,rounding_adjustment:@rounding_adj) @sale_data.grand_total = new_total @sale_data.old_grand_total = saleObj.grand_total @sale_data.rounding_adjustment = @rounding_adj @@ -418,11 +424,11 @@ class Origami::PaymentsController < BaseOrigamiController end end end - end + end #end customer amount - #paymal payment + #paymal payment @sale_data.bookings.each do |sbk| if sbk.dining_facility_id.to_i >0 @@ -444,13 +450,13 @@ class Origami::PaymentsController < BaseOrigamiController @sale_payment_data = SalePayment.get_sale_payments(@sale_data) end @sale_payment_data.each do |spay| - if spay.payment_method == "cash" + if spay.payment_method == "cash" @cash += spay.payment_amount end - if spay.payment_method !="creditnote" + if spay.payment_method !="creditnote" @other_payment += spay.payment_amount end - + if spay.payment_method == "mpu" @other += spay.payment_amount elsif spay.payment_method == "paypar" @@ -485,7 +491,7 @@ class Origami::PaymentsController < BaseOrigamiController member_info = nil latest_order_no = nil saleObj = Sale.find(sale_id) - + # For Cashier by Zone bookings = Booking.where("sale_id='#{sale_id}'") @@ -494,11 +500,11 @@ class Origami::PaymentsController < BaseOrigamiController if !latest_order.nil? latest_order_no = latest_order.order_id end - # if bookings.count > 1 + # if bookings.count > 1 # # for Multiple Booking # table = DiningFacility.find(bookings[0].dining_facility_id) # else - # table = DiningFacility.find(bookings[0].dining_facility_id) + # table = DiningFacility.find(bookings[0].dining_facility_id) # end shift = ShiftSale.current_open_shift(current_user.id) if !shift.nil? @@ -512,14 +518,14 @@ class Origami::PaymentsController < BaseOrigamiController shift = ShiftSale.find(saleObj.shift_sale_id) cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) end - end + end # 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[0] == 'ReceiptBillA5Pdf' if receipt_bilA5[1] == '1' unique_code = "ReceiptBillA5Pdf" else @@ -531,7 +537,7 @@ class Origami::PaymentsController < BaseOrigamiController customer= Customer.find(saleObj.customer_id) #shop detail - #shop_detail = Shop.first + #shop_detail = Shop.first # get member information rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate @@ -543,7 +549,7 @@ class Origami::PaymentsController < BaseOrigamiController #for card sale data card_data = Array.new card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id) - if !card_sale_trans_ref_no.nil? + 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 @@ -566,20 +572,20 @@ class Origami::PaymentsController < BaseOrigamiController printer = Printer::ReceiptPrinter.new(print_settings) filename, receipt_no, cashier_printer = 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_detail, "Re-print",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil) - - result = { + + result = { :status => true, - :filepath => filename, - :printer_model => print_settings.brand_name, - :printer_url => print_settings.api_settings + :filepath => filename, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings } - + # Mobile Print render :json => result.to_json # end end - def foc + def foc cash = params[:cash] sale_id = params[:sale_id] sub_total = params[:sub_total] @@ -598,7 +604,7 @@ class Origami::PaymentsController < BaseOrigamiController saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0) saleObj.compute_by_sale_items(sale_id, saleObj.sale_items,0,order_source) end - + saleObj.update_attributes(grand_total: 0, rounding_adjustment: 0, amount_received: 0, amount_changed: 0) sale_payment = SalePayment.new @@ -612,7 +618,7 @@ class Origami::PaymentsController < BaseOrigamiController ActionCable.server.broadcast "order_channel",table: table,type:type,from:from end - + # For Cashier by Zone bookings = Booking.where("sale_id='#{sale_id}'") @@ -629,17 +635,17 @@ class Origami::PaymentsController < BaseOrigamiController shift = ShiftSale.find(saleObj.shift_sale_id) cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id) end - end - + end + # Re-call Sale Data saleObj = Sale.find(sale_id) # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server unique_code = "ReceiptBillPdf" customer= Customer.find(saleObj.customer_id) - + #shop detail - #shop_detail = Shop.first + #shop_detail = Shop.first # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) @@ -652,11 +658,11 @@ class Origami::PaymentsController < BaseOrigamiController 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_detail, "FOC",nil,nil,other_amount,nil,nil,nil) - result = { + result = { :status => true, - :filepath => filename, - :printer_model => print_settings.brand_name, - :printer_url => print_settings.api_settings + :filepath => filename, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings } # Mobile Print @@ -669,26 +675,26 @@ class Origami::PaymentsController < BaseOrigamiController else table_id = 0 end - + booking.booking_orders.each do |order| Order.pay_process_order_queue(order.order_id,table_id) end end # end - end + end end def rounding_adj saleObj = Sale.find(params[:sale_id]) @shop = shop_detail - + if @shop.is_rounding_adj a = saleObj.grand_total % 25 # Modulus - b = saleObj.grand_total / 25 # Division + 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) + 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) @@ -697,12 +703,12 @@ class Origami::PaymentsController < BaseOrigamiController end #print function for receipt - def print + def print filename = params[:filename] receipt_no = params[:receipt_no] printer_name = params[:printer_name] cashier_type = params[:type] - + if cashier_type.strip.downcase == "doemal_order" unique_code = "ReceiptBillOrderPdf" else @@ -720,7 +726,7 @@ class Origami::PaymentsController < BaseOrigamiController end if !receipt_bill_a5_pdf.empty? receipt_bill_a5_pdf.each do |receipt_bilA5| - if receipt_bilA5[0] == 'ReceiptBillA5Pdf' + if receipt_bilA5[0] == 'ReceiptBillA5Pdf' if receipt_bilA5[1] == '1' unique_code = "ReceiptBillA5Pdf" # else @@ -734,12 +740,12 @@ class Origami::PaymentsController < BaseOrigamiController print_settings=PrintSetting.find_by_unique_code(unique_code) printer = Printer::ReceiptPrinter.new(print_settings) printer.print_receipt_pdf(filename,receipt_no,print_settings.print_copies,printer_name) - - result = { + + result = { :status => true, - :filepath => filename, - :printer_model => print_settings.brand_name, - :printer_url => print_settings.api_settings + :filepath => filename, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings } Rails.logger.debug "$$$$$$$$$ result ::" Rails.logger.debug result @@ -755,7 +761,7 @@ class Origami::PaymentsController < BaseOrigamiController tax_type = params[:tax_type] sale = Sale.find(sale_id) sale.compute_by_sale_items(sale.sale_id, sale.sale_items, sale.total_discount,nil,order_source,tax_type) - + render json: JSON.generate({:status => true}) end @@ -768,4 +774,4 @@ class Origami::PaymentsController < BaseOrigamiController return from end -end \ No newline at end of file +end diff --git a/app/controllers/origami/quick_service_controller.rb b/app/controllers/origami/quick_service_controller.rb index 98e61545..f13d0dab 100644 --- a/app/controllers/origami/quick_service_controller.rb +++ b/app/controllers/origami/quick_service_controller.rb @@ -6,7 +6,7 @@ class Origami::QuickServiceController < ApplicationController redirect_to root_path end end - + def index today = DateTime.now day = Date.today.wday @@ -14,7 +14,7 @@ class Origami::QuickServiceController < ApplicationController @menus = [] @menu = [] # else - # @menus = Menu.all + # @menus = Menu.all # @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc') # end @zone = Zone.all @@ -28,20 +28,20 @@ class Origami::QuickServiceController < ApplicationController else @display_type = nil end - + #checked quick_service only @quick_service_only = true lookup_dine_in = Lookup.collection_of('dinein_cashier') if !lookup_dine_in.empty? lookup_dine_in.each do |dine_in| - if dine_in[0].downcase == "dineincashier" - if dine_in[1] == '1' + if dine_in[0].downcase == "dineincashier" + if dine_in[1] == '1' @quick_service_only = false end end end end - + render "origami/addorders/detail" end @@ -53,7 +53,7 @@ class Origami::QuickServiceController < ApplicationController @menus = [] @menu = [] # else - # @menus = Menu.all + # @menus = Menu.all # @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc') # end if(params[:id][0,3] == "BKI") @@ -65,7 +65,7 @@ class Origami::QuickServiceController < ApplicationController @table = DiningFacility.find(@table_id) @booking = @table.get_booking end - + @sale_id = params[:sale_id] if @booking @@ -96,7 +96,7 @@ class Origami::QuickServiceController < ApplicationController @cashier_type = "quick_service" 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 @@ -169,7 +169,7 @@ class Origami::QuickServiceController < ApplicationController end @status, @booking = @order.generate - if(params[:sale_id][0,3] == "SAL") + if(params[:sale_id][0,3] == "SAL") if @status && @booking && @order.source == 'quick_service' if params[:sale_id] @sale = Sale.find(params[:sale_id]) @@ -180,17 +180,17 @@ class Origami::QuickServiceController < ApplicationController end update = Sale.add_to_existing_pending_invoice(@table_id,params[:sale_id],@booking) end - + result = {:status=> true, :data => @sale } render :json => result.to_json - end + end elsif (params[:sale_id][0,3] == "BKI") result = {:status=> true, :data => 'OK' } - render :json => result.to_json + render :json => result.to_json else result = {:status=> true, :data => nil } render :json => result.to_json - end + end end @@ -216,9 +216,9 @@ class Origami::QuickServiceController < ApplicationController return @sub_menu end end - + def get_all_product() - @product = Product.all + @product = Product.all end # render json for http status code 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/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 %>