diff --git a/Gemfile b/Gemfile index 94ed4ef3..4ca47865 100755 --- a/Gemfile +++ b/Gemfile @@ -48,7 +48,6 @@ gem 'prawn' gem 'prawn-table' gem 'spreadsheet' gem 'to_xls-rails' - #Reporting gem #gem 'compendium' #gem "cancan" @@ -81,7 +80,6 @@ gem 'kaminari', '~> 1.0.1' gem 'filterrific' gem 'cancancan', '~> 1.10' - #pageless no need for current # gem 'will_paginate' # gem 'pageless-rails', github: 'rorlab/pageless-rails' @@ -129,4 +127,4 @@ gem 'momentjs-rails' # for date-range selector # gem 'bootstrap-datepicker-rails' # date picker # gem 'jquery-datetimepicker-rails' # gem 'select2-rails' # for multi-select and auto-complete select box -gem "chartkick" #chart lib +gem "chartkick" #chart lib \ No newline at end of file diff --git a/README.md b/README.md index b5d2c62b..506ab0b6 100755 --- a/README.md +++ b/README.md @@ -132,12 +132,34 @@ ADD COLUMN image_path VARCHAR(255); ALTER TABLE sales ADD COLUMN equal_persons INT(11) after rebate_status; + +ALTER TABLE sale_items +ADD COLUMN remark VARCHAR(255) after status; + +ALTER TABLE shops +ADD COLUMN shop_code VARCHAR(255) after name, +ADD COLUMN client_name VARCHAR(255) after shop_code, +ADD COLUMN client_code VARCHAR(255) after client_name; + +ALTER TABLE print_settings +ADD COLUMN brand_name VARCHAR(255) after api_settings, +ADD COLUMN type VARCHAR(255) after brand_name; + +ALTER TABLE tax_profiles +ADD COLUMN group_type VARCHAR(255) after name; + <---- Extra Fields Script -----> For CloseCashierCustomisePdf in lookups *** change CloseCashierPdf to CloseCashierCustomisePdf 1) settings/print_settings 2) settings/lookups => { type:print_settings, name: CloseCashierCustomisePdf, value:1 } +/* Tax Profile Group Types in lookups */ +1) settings/lookups => { type:tax_profiles, name: Cashier, value:cashier } +2) settings/lookups => { type:tax_profiles, name: Quick Service, value: quick_service } +3) settings/lookups => { type:tax_profiles, name: Doemal, value: doemal } +/* Tax Profile Group Types in lookups */ + * ToDo list 1. Migration diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index 1df7a16e..f6365db0 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -180,7 +180,6 @@ $(function() { image_path = "image/logo.png"; } } - row = '
' +'
' @@ -190,6 +189,7 @@ $(function() { +JSON.stringify(menu_items[field].instances)+"' data-id = '" +JSON.stringify(menu_items[field].attributes)+"' data-item = '" +JSON.stringify(item_attributes)+"' data-option = '" + +JSON.stringify(menu_items[field].options)+"'data-opt = '" +JSON.stringify(menu_items[field].options)+"' data-item-sets = '" +JSON.stringify(menu_items[field].item_sets)+"' data-toggle='modal' data-target='."+data_target+"' >" +"" @@ -202,7 +202,8 @@ $(function() { + price +"' data-instance-code = '"+ code +"' data-instance = '" + name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '" + JSON.stringify(item_attributes) +"' data-options = '" - + options +"' data-image='"+image_path+"' data-toggle='" + + JSON.stringify(menu_items[field].options) +"' data-opt = '" + + JSON.stringify(menu_items[field].options) +"' data-image='"+image_path+"' data-toggle='" +data_modal+"' data-target='."+data_target+"' data-item-sets = '" +JSON.stringify(menu_items[field].item_sets)+"'data-instances = '" +JSON.stringify(menu_items[field].instances)+"'>" @@ -237,10 +238,10 @@ $(function() { //instances = $(this).data('instance'); item_sets = $(this).data('item-sets'); instances = $(this).data('instances'); - // item_sets = $(data).attr('data-item-sets'); + item_options = $(this).data('options'); for(var field in item_sets) { - + $('.set_order').attr('data-min-qty',item_sets[field]["min_selectable_qty"]); value = item_sets[field]["instances"]; @@ -283,10 +284,20 @@ $(function() { }); } + for(var j in item_options) { + value = item_options[j]["values"]; + type = item_options[j]["type"]; + row = "

"+type+"

" + $(value).each(function(i){ + row +=""; + }); + $(".options-list").append(row); + } $('.set-item').attr('data-code',instances[0]['code']); $('.set-item').attr('data-name',instances[0]['name']); $('.set-item').attr('data-price',instances[0]['price']); - $('.set-item').attr('data-options','[]'); + $('.set-item').attr('data-options',''); $('.set-item').attr('data-parent',true); $('#set_change_qty').val(1); @@ -341,6 +352,7 @@ $(function() { sub_total = $('#set_total_price').text(); name = $(this).data('name'); price = $(this).data('price'); + options = $(this).attr('data-options',''); // qty = $('#set_change_qty').val(); qty = document.getElementById("set_count").value; total = qty*price; @@ -369,52 +381,48 @@ $(function() { item = get_set_item(items); customer_display_view(item,"set_add"); - + var option = '' attribute_arr = [] - option_arr = [] var rowCount = $('.summary-items tbody tr').length+1; - option_arr = [] code = $('.set-item').attr('data-code'); name = $('.set-item').attr('data-name'); price = $('.set-item').attr('data-price'); - option = $('.set-item').attr('data-options'); + option = ($('.set-item').attr('data-options') === 'undefined') ? '' :$('.set-item').attr('data-options'); parent = $('.set-item').attr('data-parent'); total = qty * price ; - option_arr.push(option); row ="" + +option+"' data-row ='"+rowCount+ "' data-parent ='"+parent+ "'>" +''+rowCount+'' - +'' + item_name+ ' ' + name +'' + +'' + item_name+ ' ' + name +' ' + option +'' +'' + qty + '' +'' + parseFloat(total).toFixed(2) +'' +''; $(".summary-items tbody").append(row); - var rowCount = $('.summary-items tbody tr').length+1; + var set_option = '' $(items).each(function(i){ code = $(items[i]).attr('data-code'); name = $(items[i]).attr('data-name'); price = $(items[i]).attr('data-price'); - option = $(items[i]).attr('data-options'); + set_option = ($(items[i]).attr('data-options') === 'undefined') ? ' ' :$(items[i]).attr('data-options'); + sub_item = $(items[i]).attr('data-sub-item'); - option = $(items[i]).attr('data-options'); total = qty * price ; - option_arr.push(option); row ="" + +set_option+"' data-row ='"+rowCount+ "' data-sub-item ='"+sub_item+ "'>" +''+rowCount+'' - +'' + item_name+ ' ' + name +'' + +'' + item_name+ ' ' + name +' ' + set_option +'' +'' + qty + '' +'' + parseFloat(total).toFixed(2) @@ -626,8 +634,6 @@ $(function() { if(group == "set_menu"){ - code = $(this).data('code'); - value = $(this).data('value'); instance = $(".selected-instance"); $(instance).each(function(i){ @@ -638,6 +644,12 @@ $(function() { } }); } + + if(group == "set_menu_default"){ + option_arr = get_selected_attributes('selected-option'); + $('.set-item').attr('data-options',JSON.stringify(option_arr)); + $('.set_default_option').text(option_arr); + } }); //End selecct attribute buttom @@ -650,7 +662,6 @@ $(function() { attribute_arr = get_selected_attributes('selected-attribute'); option_arr = get_selected_attributes('selected-option'); - if (item_row.length>0) { var instances = jQuery.parseJSON(item_row.attr('data-instances')); @@ -691,7 +702,7 @@ $(function() { var item_data = $(this); item = get_item(item_data); customer_display_view(item,"add"); - show_item_detail(item_data); + show_item_detail(item_data,"add_to_order"); calculate_sub_total(); }); //End add order Click @@ -701,11 +712,11 @@ $(function() { var item_data = $(this); item = get_item(item_data); customer_display_view(item,"add"); - show_item_detail(item_data); + show_item_detail(item_data,"add_icon"); calculate_sub_total(); }); //End Add Icon Click - function show_item_detail(data){ + function show_item_detail(data,click_type){ qty = parseInt(data.attr('data-qty')); append = 0; @@ -717,23 +728,26 @@ $(function() { }else{ instance = "("+data.attr('data-instance')+")"; } - - d_option = data.attr('data-options'); - if (d_option){ - option_name = "-"+data.attr('data-options'); + d_option = data.attr('data-opt'); + if (click_type != "add_icon"){ + option_name = "-"+data.attr('data-options'); + data_option = data.attr('data-options') ; }else{ - option_name = ''; + option_name = ' '; + data_option = '[]'; } + var rowCount = $('.summary-items tbody tr').length+1; var item_row = $('.summary-items tbody tr'); $(item_row).each(function(i){ item_code = $(item_row[i]).attr('data-code'); instance_code = $(item_row[i]).attr('data-instance-code'); - r_option = $(item_row[i]).attr('data-options'); - - if (item_code == data.attr('data-item-code') && instance_code == data.attr('data-instance-code')&&r_option==d_option) { + r_option = $(item_row[i]).attr('data-opt'); +console.log(r_option) +console.log(d_option) + if (item_code == data.attr('data-item-code') && instance_code == data.attr('data-instance-code')&&r_option == d_option) { if (qty > 1) { qty = parseInt($(item_row[i]).children('#item_qty').text()) + qty; }else{ @@ -757,9 +771,10 @@ $(function() { +instance+ "' data-code='"+data.attr('data-item-code')+"' data-instance-code='" +data.attr('data-instance-code')+"' data-attributes='" +data.attr('data-attributes')+"' data-options ='" + +data_option+"' data-opt ='" +data.attr('data-options')+"' data-row ='"+rowCount+ "'>" +''+rowCount+'' - +'' + data.attr('data-name')+ ' ' + instance +' ' + option_name +'' + +'' + data.attr('data-name')+ ' ' + instance +''+option_name+'' +'' + qty + '' +'' + parseFloat(price).toFixed(2) @@ -813,8 +828,6 @@ $(function() { data: params, dataType: "json", success:function(result){ - console.log(type) - console.log(table_type) if (type == "quick_service") { window.location.href = "/origami/quick_service" }else{ @@ -880,7 +893,7 @@ $(function() { dataType: "json", success:function(result){ if (result.status) { - console.log(result) + if (result.data == null){ swal({ title: "Please Open Shift !", diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index 2e9602c8..43e1bd11 100755 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -67,7 +67,8 @@ class Api::OrdersController < Api::ApiController end } #end extra time - + puts params[:order_items] + puts "ITEM aaaaaaaaaaaaaaaaaaa" # begin @order = Order.new @order.source = params[:order_source] diff --git a/app/controllers/oqs/edit_controller.rb b/app/controllers/oqs/edit_controller.rb old mode 100755 new mode 100644 index b123ac73..94ba5842 --- a/app/controllers/oqs/edit_controller.rb +++ b/app/controllers/oqs/edit_controller.rb @@ -6,6 +6,11 @@ class Oqs::EditController < BaseOqsController if params[:type] == 'oqs' assigned_item = AssignedOrderItem.find(assigned_item_id) @order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.instance_code }'") + elsif + assigned_item = OrderItem.find(assigned_item_id) + @booking = Booking.joins(" JOIN booking_orders as bko on bko.booking_id = bookings.booking_id") + .where("bko.order_id = '#{assigned_item.order_id}'").first() + @order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.item_instance_code }'") else assigned_item = OrderItem.find(assigned_item_id) dining = DiningFacility.find_by_id(params[:type]) @@ -25,13 +30,6 @@ class Oqs::EditController < BaseOqsController order_item.item_order_by = current_user.name order_item.qty = qty_weight order_item.remark = remarks - if !order_item.set_menu_items.nil? - instance_item_sets = JSON.parse(order_item.set_menu_items) - instance_item_sets.each_with_index do |instance_item, instance_index| - instance_item_sets[instance_index]["quantity"] = qty_weight - end - order_item.set_menu_items = instance_item_sets.to_json - end order_item.save if ENV["SERVER_MODE"] != "cloud" #no print in cloud server @@ -67,4 +65,9 @@ class Oqs::EditController < BaseOqsController end end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index 7dd2b3f0..3a8dea9b 100755 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -94,10 +94,10 @@ class Origami::AddordersController < BaseOrigamiController extra_time = Time.at(time) end end - if i["parent_order_item_id"] - items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": i["options"]} + if i["parent_order_item_id"]; + items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"parent_order_item_id": i["parent_order_item_id"],"options": JSON.parse(i["options"])} else - items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": i["options"]} + items = {"order_item_id": i["order_item_id"],"item_instance_code": i["item_instance_code"],"quantity": i["quantity"],"options": JSON.parse(i["options"])} end items_arr.push(items) } diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 6a6c0c90..a8e2818c 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -74,16 +74,6 @@ class Origami::HomeController < BaseOrigamiController @date = order.created_at @booking= booking order.order_items.each do |item| - if !item.set_menu_items.nil? - instance_item_sets = JSON.parse(item.set_menu_items) - arr_instance_item_sets = Array.new - instance_item_sets.each do |instance_item| - item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name - arr_instance_item_sets.push(item_instance_name) - item.price = item.price.to_f + instance_item["price"].to_f - end - item.set_menu_items = arr_instance_item_sets - end @order_items.push(item) # assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id) # if !assigned_order_items.nil? diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 4e0c7100..a2a85b92 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -113,7 +113,9 @@ class Origami::PaymentsController < BaseOrigamiController end end #end rounding adjustment - + puts "sale" + puts saleObj.to_json + sale_payment = SalePayment.new sale_payment.process_payment(saleObj, current_user.name, cash, "cash") @@ -161,12 +163,24 @@ class Origami::PaymentsController < BaseOrigamiController 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 + rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no) + current_balance = SaleAudit.paymal_search(sale_id) 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) + end + end + #for card sale data card_data = Array.new card_sale_trans_ref_no = Sale.getCardSaleTrans(sale_id) diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 3aa98282..11a7f93d 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -68,16 +68,6 @@ class Origami::RoomsController < BaseOrigamiController @date = order.created_at @booking = booking order.order_items.each do |item| - if !item.set_menu_items.nil? - instance_item_sets = JSON.parse(item.set_menu_items) - arr_instance_item_sets = Array.new - instance_item_sets.each do |instance_item| - item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name - arr_instance_item_sets.push(item_instance_name) - item.price = item.price.to_f + instance_item["price"].to_f - end - item.set_menu_items = arr_instance_item_sets - end @order_items.push(item) # assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id) # if !assigned_order_items.nil? diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 19def9b6..d0b73f99 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -3,6 +3,7 @@ class Origami::ShiftsController < BaseOrigamiController end def show + @type = params[:type] @shift = ShiftSale.current_open_shift(current_user.id) #for bank integration bank_integration = Lookup.collection_of('bank_integration') diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb index 240343b1..0a6d87c7 100755 --- a/app/controllers/settings/menus_controller.rb +++ b/app/controllers/settings/menus_controller.rb @@ -6,6 +6,13 @@ class Settings::MenusController < ApplicationController # GET /settings/menus.json def index @settings_menus = Menu.all.page(params[:page]).per(10) + respond_to do |format| + format.html + # format.csv { send_data MenuCsvExport.generate } + +format.csv { send_data Menu.to_csv } +# format.csv { send_data MenuCategory.to_csv } + end end # GET /settings/menus/1 @@ -67,6 +74,11 @@ class Settings::MenusController < ApplicationController # end end + def import + Menu.import(params[:file]) + redirect_to settings_menu_path, notice: "imported" + end + private # Use callbacks to share common setup or constraints between actions. def set_settings_menu diff --git a/app/controllers/settings/tax_profiles_controller.rb b/app/controllers/settings/tax_profiles_controller.rb index 77414c57..75e4343e 100755 --- a/app/controllers/settings/tax_profiles_controller.rb +++ b/app/controllers/settings/tax_profiles_controller.rb @@ -6,6 +6,18 @@ class Settings::TaxProfilesController < ApplicationController # GET /settings/tax_profiles.json def index @settings_tax_profiles = TaxProfile.all + tax_profiles = Lookup.collection_of("tax_profiles") + if !@settings_tax_profiles.nil? + @settings_tax_profiles.each_with_index do |setting_tax_profile, tax_index| + if !tax_profiles.nil? + tax_profiles.each do |group| + if setting_tax_profile.group_type == group[1] + @settings_tax_profiles[tax_index].group_type = group[0] + end + end + end + end + end end # GET /settings/tax_profiles/1 @@ -15,11 +27,19 @@ class Settings::TaxProfilesController < ApplicationController # GET /settings/tax_profiles/new def new + @name = nil @settings_tax_profile = TaxProfile.new + @tax_profiles = TaxProfile.all end # GET /settings/tax_profiles/1/edit def edit + @settings_tax_profile = TaxProfile.find(params[:id]) + @name = nil + if !@settings_tax_profile.nil? + @name = @settings_tax_profile.name + end + @tax_profiles = TaxProfile.all end # POST /settings/tax_profiles @@ -69,10 +89,20 @@ class Settings::TaxProfilesController < ApplicationController # Use callbacks to share common setup or constraints between actions. def set_settings_tax_profile @settings_tax_profile = TaxProfile.find(params[:id]) + tax_profiles = Lookup.collection_of("tax_profiles") + if !@settings_tax_profile.nil? + if !tax_profiles.nil? + tax_profiles.each do |group| + if @settings_tax_profile.group_type == group[1] + @settings_tax_profile.group_type = group[0] + end + end + end + end end # Never trust parameters from the scary internet, only allow the white list through. def settings_tax_profile_params - params.require(:tax_profile).permit(:name, :rate, :inclusive, :order_by, :created_by) + params.require(:tax_profile).permit(:name, :group_type, :rate, :inclusive, :order_by, :created_by) end end diff --git a/app/controllers/transactions/orders_controller.rb b/app/controllers/transactions/orders_controller.rb index 17a117bb..52abf7fd 100755 --- a/app/controllers/transactions/orders_controller.rb +++ b/app/controllers/transactions/orders_controller.rb @@ -21,11 +21,12 @@ class Transactions::OrdersController < ApplicationController @receipt_no = filter @from = from @to = to - + respond_to do |format| - format.html # index.html.erb - format.json { render json: @orders } - end + format.html + format.json { render json: @orders } + # format.csv { send_data OrdersCsvExport.generate } + end end def show diff --git a/app/models/menu.rb b/app/models/menu.rb index b96fe03a..12784eea 100755 --- a/app/models/menu.rb +++ b/app/models/menu.rb @@ -31,4 +31,22 @@ class Menu < ApplicationRecord menu.destroy return false end -end + + def self.to_csv + m_attributes = %w{name is_active valid_days valid_time_from valid_time_to created_by created_at updated_at} + CSV.generate(headers: true) do |csv| + csv << m_attributes + menu = Menu.all + menu.each do |user| + csv << m_attributes.map{ |attr| user.send(attr)} + end + end + end + + def self.import(file) + CSV.foreach(file.path, headers:true) do |row| + Menu.create! row.to_hash + end + end + +end \ No newline at end of file diff --git a/app/models/menu_category.rb b/app/models/menu_category.rb index acb06c4f..65477a37 100755 --- a/app/models/menu_category.rb +++ b/app/models/menu_category.rb @@ -1,7 +1,7 @@ class MenuCategory < ApplicationRecord # before_create :generate_menu_category_code - belongs_to :menu + belongs_to :menu , counter_cache: true has_many :children, :class_name => "MenuCategory", foreign_key: "menu_category_id" belongs_to :parent, :class_name => "MenuCategory", foreign_key: "menu_category_id", optional: true has_many :menu_items @@ -83,4 +83,19 @@ class MenuCategory < ApplicationRecord # def generate_menu_category_code # self.code = SeedGenerator.generate_code(self.class.name, "C") # end + + def self.to_csv + + mc_attributes = %w{id menu_id code name alt_name order_by created_by menu_category_id is_available created_at updated_at} + CSV.generate(headers: true) do |csv| + csv << mc_attributes + + csv << mc_attributes + MenuCategory.all.each do |user| + puts user + csv << mc_attributes.map{ |attr| user.send(attr)} + end + end + + end end diff --git a/app/models/order.rb b/app/models/order.rb index 1508c960..25c5db4a 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -135,7 +135,7 @@ class Order < ApplicationRecord #loop to add all items to order ordered_list.each do |item| - + menu_item = MenuItem.search_by_item_code(item[:item_instance_code]) # For Product while item code not in menu item @@ -152,7 +152,7 @@ class Order < ApplicationRecord item[:sub_items].each do |si| # Retrive instance's Price set_item = MenuItem.search_by_item_code(si[:item_instance_code]) - set_order_items.push({"item_instance_code"=>si[:item_instance_code], "quantity"=>si[:quantity], "price"=>set_item[:price]}) + set_order_items.push({"item_instance_code"=>si[:item_instance_code], "item_instance_name"=>set_item[:name], "quantity"=>si[:quantity], "price"=>set_item[:price], "options"=>si[:options]}) end end set_order_items = set_order_items.to_json @@ -339,17 +339,17 @@ class Order < ApplicationRecord #Process order items and send to order queue def self.pay_process_order_queue(id,table_id) sidekiq = Lookup.find_by_lookup_type("sidekiq") - if !sidekiq.nil? - OrderQueueProcessorJob.perform_later(id, table_id) - else - order = Order.find(id) - if order - oqs = OrderQueueStation.new - oqs.process_order(order, table_id) - end - assign_order = AssignedOrderItem.assigned_order_item_by_job(id) - ActionCable.server.broadcast "order_queue_station_channel",order: assign_order - end + if !sidekiq.nil? + OrderQueueProcessorJob.perform_later(id, table_id) + else + order = Order.find(id) + if order + oqs = OrderQueueStation.new + oqs.process_order(order, table_id) + end + assign_order = AssignedOrderItem.assigned_order_item_by_job(id) + ActionCable.server.broadcast "order_queue_station_channel",order: assign_order + end end def check_cup_status(status) diff --git a/app/models/order_item.rb b/app/models/order_item.rb index 776bb94c..87d60e63 100755 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -5,7 +5,8 @@ class OrderItem < ApplicationRecord before_create :generate_custom_id #Associations - belongs_to :order, autosave: true + belongs_to :order, autosave: true + # belongs_to :order, counter_cache: true #Validation validates_presence_of :item_code, :item_name, :qty diff --git a/app/models/tax_profile.rb b/app/models/tax_profile.rb index e478ecd5..a9e56fac 100755 --- a/app/models/tax_profile.rb +++ b/app/models/tax_profile.rb @@ -1,5 +1,5 @@ class TaxProfile < ApplicationRecord default_scope { order('order_by asc') } # validations - validates_presence_of :name, :rate + validates_presence_of :name, :rate, :group_type end diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index 379e919c..fabc8d11 100755 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -37,7 +37,7 @@ class OrderItemPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" #font "public/fonts/Chinese.ttf" - if order_item.dining.to_i > 0 + if !order_item.dining.nil? text "#{ order_item.type + '-' + order_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 diff --git a/app/pdf/order_item_slim_pdf.rb b/app/pdf/order_item_slim_pdf.rb old mode 100644 new mode 100755 index 09cce4d1..146b585f --- a/app/pdf/order_item_slim_pdf.rb +++ b/app/pdf/order_item_slim_pdf.rb @@ -37,7 +37,7 @@ class OrderItemSlimPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" #font "public/fonts/Chinese.ttf" - if order_item_slim.dining.to_i > 0 + if !order_item_slim.dining.nil? text "#{ order_item_slim.type + '-' + order_item_slim.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 diff --git a/app/pdf/order_set_item_pdf.rb b/app/pdf/order_set_item_pdf.rb old mode 100644 new mode 100755 index 6aa6efc4..9aac0d0e --- a/app/pdf/order_set_item_pdf.rb +++ b/app/pdf/order_set_item_pdf.rb @@ -37,7 +37,7 @@ class OrderSetItemPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" #font "public/fonts/Chinese.ttf" - if order_set_item.dining.to_i > 0 + if !order_set_item.dining.nil? text "#{ order_set_item.type + '-' + order_set_item.dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index 6c8dacac..17cf905c 100755 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -36,7 +36,8 @@ class OrderSummaryPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - if order[0].dining.to_i > 0 + + if !order[0].dining.nil? text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 diff --git a/app/pdf/order_summary_set_pdf.rb b/app/pdf/order_summary_set_pdf.rb old mode 100644 new mode 100755 index 8828ea43..14b2f796 --- a/app/pdf/order_summary_set_pdf.rb +++ b/app/pdf/order_summary_set_pdf.rb @@ -36,7 +36,7 @@ class OrderSummarySetPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - if order[0].dining.to_i > 0 + if !order[0].dining.nil? text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 diff --git a/app/pdf/order_summary_slim_pdf.rb b/app/pdf/order_summary_slim_pdf.rb old mode 100644 new mode 100755 index 73023278..c88061ea --- a/app/pdf/order_summary_slim_pdf.rb +++ b/app/pdf/order_summary_slim_pdf.rb @@ -36,7 +36,7 @@ class OrderSummarySlimPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - if order[0].dining.to_i > 0 + if !order[0].dining.nil? text "#{ order[0].type + '-' + order[0].dining + print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 else text "#{ print_status }", :size => self.header_font_size,:align => :center, :left_margin => -20 diff --git a/app/views/api/orders/view_orders.json.jbuilder b/app/views/api/orders/view_orders.json.jbuilder index ae3fea84..dd72a3a3 100755 --- a/app/views/api/orders/view_orders.json.jbuilder +++ b/app/views/api/orders/view_orders.json.jbuilder @@ -46,9 +46,12 @@ if (@booking) child_spent += (item.price * item.qty) end # End YGN BBQ + json.order_items_id item.order_items_id + json.order_id item.order_id json.item_code item.item_code json.item_instance_code item.item_instance_code json.item_name item.item_name + json.set_menu_items item.set_menu_items json.price item.price json.qty item.qty json.options item.options diff --git a/app/views/oqs/edit/index.html.erb b/app/views/oqs/edit/index.html.erb old mode 100755 new mode 100644 index 775b214d..7a1eebab --- a/app/views/oqs/edit/index.html.erb +++ b/app/views/oqs/edit/index.html.erb @@ -112,6 +112,8 @@ $(document).ready(function(){ var remarks = $("textarea[name='remarks']").val(); var order_items_id = $(this).attr('data-id'); var params = { 'order_items_id': order_items_id, 'qty_weight': qty_weight, 'remarks': remarks } + var booking_id = '<%= @booking.booking_id %>'; + $.ajax({ type: 'POST', url: '/oqs/' + order_items_id, @@ -121,6 +123,8 @@ $(document).ready(function(){ <% if !@link_type.nil? %> <% if @link_type == 'oqs' %> window.location.href = '/oqs'; + <% elsif @link_type == 'pending' %> + window.location.href = '/origami/quick_service/pending_order/'+booking_id; <% else %> <% if !@dining_type.nil? %> <% if @dining_type == 'Table' %> diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb index 6c580f40..4e93e5a7 100755 --- a/app/views/origami/addorders/detail.html.erb +++ b/app/views/origami/addorders/detail.html.erb @@ -375,7 +375,7 @@