diff --git a/app/controllers/api/authenticate_controller.rb b/app/controllers/api/authenticate_controller.rb index ba2cf5a8..ec1f4410 100755 --- a/app/controllers/api/authenticate_controller.rb +++ b/app/controllers/api/authenticate_controller.rb @@ -1,6 +1,5 @@ class Api::AuthenticateController < Api::ApiController skip_before_action :authenticate - # before_action :find_shop def create emp_id = params[:emp_id] @@ -67,8 +66,5 @@ class Api::AuthenticateController < Api::ApiController params.permit(:emp_id, :password, :session_token) end - private - def find_shop - @shop = Shop.find_by_shop_code(params[:shop_code]) - end + end diff --git a/app/controllers/concerns/login_verification.rb b/app/controllers/concerns/login_verification.rb index 1e3a61bf..ff5e2da2 100755 --- a/app/controllers/concerns/login_verification.rb +++ b/app/controllers/concerns/login_verification.rb @@ -18,7 +18,7 @@ module LoginVerification def current_shop begin - return @shop + return Shop.current_shop rescue return nil end @@ -40,7 +40,7 @@ module LoginVerification #Shop Name in Navbor def shop_detail - @shop = current_shop + @shop ||= current_shop end #check order reservation used diff --git a/app/controllers/concerns/multi_tenancy.rb b/app/controllers/concerns/multi_tenancy.rb index cbea7e62..d495709d 100644 --- a/app/controllers/concerns/multi_tenancy.rb +++ b/app/controllers/concerns/multi_tenancy.rb @@ -12,8 +12,7 @@ module MultiTenancy shop_code = request.subdomain.partition('-').last @shop = Shop.find_by(shop_code: shop_code) else - # @shop = Shop.first - @shop = Shop.find_by(shop_code: '262') + @shop = Shop.first end set_current_tenant(@shop) end diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index df17d7b1..f636072e 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -9,15 +9,25 @@ class Crm::CustomersController < BaseCrmController filter = params[:filter] filter_card_no = params[:filter_card_no] type = params[:type] + puts "type :" + puts type + puts "filter :" + puts filter + puts "filter card no" + puts filter_card_no @customer_update_phone_email_membertype =false if filter_card_no=="" @crm_customers = Customer.all + puts "Filter card no" elsif !filter_card_no.nil? @crm_customers=Customer.where("card_no=?",filter_card_no) + puts "Null filter card no" elsif filter.nil? || filter_card_no=="" @crm_customers = Customer.all + puts "filter null filter card no nulll" else @crm_customers = Customer.search(filter) + puts "else" # paymal_customer = Customer.search_paypar_account_no(filter) # search account no from paypar if type == "card" diff --git a/app/controllers/foodcourt/discounts_controller.rb b/app/controllers/foodcourt/discounts_controller.rb index 2d4c13d8..7c925a1d 100755 --- a/app/controllers/foodcourt/discounts_controller.rb +++ b/app/controllers/foodcourt/discounts_controller.rb @@ -22,7 +22,7 @@ class Foodcourt::DiscountsController < BaseFoodcourtController end @member_discount = MembershipSetting.find_by_discount(1) - @accounts = Account.where("shop_code='#{@shop.shop_code}'") + @accounts = Account.all end #discount page show from origami index with selected order diff --git a/app/controllers/foodcourt/food_court_controller.rb b/app/controllers/foodcourt/food_court_controller.rb index d818c7fd..20c467eb 100644 --- a/app/controllers/foodcourt/food_court_controller.rb +++ b/app/controllers/foodcourt/food_court_controller.rb @@ -74,7 +74,7 @@ class Foodcourt::FoodCourtController < ApplicationController end def get_all_product() - @product = Product.where("shop_code='#{@shop.shop_code}'") + @product = Product.all end # render json for http status code diff --git a/app/controllers/foodcourt/home_controller.rb b/app/controllers/foodcourt/home_controller.rb index 3bfc6867..354e8163 100755 --- a/app/controllers/foodcourt/home_controller.rb +++ b/app/controllers/foodcourt/home_controller.rb @@ -4,13 +4,13 @@ class Foodcourt::HomeController < BaseFoodcourtController def index @webview = check_mobile - @tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') - @rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') + @tables = Table.unscoped.all.active.order('status desc') + @rooms = Room.unscoped.all.active.order('status desc') @complete = Sale.completed_sale("cashier") - @orders = Order.includes("sale_orders").where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @customers = Customer.pluck("customer_id, name") - @occupied_table = DiningFacility.where("shop_code='#{@shop.shop_code}' and status='occupied'").count + @occupied_table = DiningFacility.where("status='occupied'").count @shift = ShiftSale.current_open_shift(current_user) end @@ -19,10 +19,10 @@ class Foodcourt::HomeController < BaseFoodcourtController # get printer info @print_settings = PrintSetting.get_precision_delimiter() @webview = check_mobile - @tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') - @rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') + @tables = Table.unscoped.all.active.order('status desc') + @rooms = Room.unscoped.all.active.order('status desc') @complete = Sale.completed_sale("cashier") - @orders = Order.includes("sale_orders").where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') + @orders = Order.includes("sale_orders").where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed' and source != 'quick_service'",DateTime.now.strftime('%Y-%m-%d')).order('date desc') @customers = Customer.pluck("customer_id, name") @shift = ShiftSale.current_open_shift(current_user) @@ -30,8 +30,8 @@ class Foodcourt::HomeController < BaseFoodcourtController @status_sale = "" @sale_array = Array.new - @membership = MembershipSetting.find_by_shop_code(@shop.shop_code) - @payment_methods = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'") + @membership = MembershipSetting.all + @payment_methods = PaymentMethodSetting.all @dining_booking = @dining.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ") #@dining_booking = @dining.bookings.active.where("created_at between '#{DateTime.now.utc - 12.hours}' and '#{DateTime.now.utc}'") @order_items = Array.new @@ -103,16 +103,16 @@ class Foodcourt::HomeController < BaseFoodcourtController end #for bank integration - @checkout_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_time') - @checkout_alert_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_alert_time') + @checkout_time = Lookup.collection_of('checkout_time') + @checkout_alert_time = Lookup.collection_of('checkout_alert_time') - accounts = TaxProfile.where("shop_code='#{@shop.shop_code}' and group_type = ?","cashier").order("order_by ASC") + accounts = TaxProfile.where("group_type = ?","cashier").order("order_by ASC") @tax_arr =[] accounts.each do |acc| @tax_arr.push(acc.name) end - lookup_spit_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('split_bill') + lookup_spit_bill = Lookup.collection_of('split_bill') @split_bill = 0 if !lookup_spit_bill[0].nil? @split_bill = lookup_spit_bill[0][1] @@ -120,7 +120,7 @@ class Foodcourt::HomeController < BaseFoodcourtController #for edit order on/off @edit_order_origami = true - lookup_edit_order = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('edit_order') + lookup_edit_order = Lookup.collection_of('edit_order') if !lookup_edit_order.empty? lookup_edit_order.each do |edit_order| if edit_order[0].downcase == "editorderorigami" @@ -133,7 +133,7 @@ class Foodcourt::HomeController < BaseFoodcourtController #for changable on/off @changable_tax = true - lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax') + 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" diff --git a/app/controllers/foodcourt/orders_controller.rb b/app/controllers/foodcourt/orders_controller.rb index 6439bd5f..f7f30fdf 100755 --- a/app/controllers/foodcourt/orders_controller.rb +++ b/app/controllers/foodcourt/orders_controller.rb @@ -71,7 +71,7 @@ class Foodcourt::OrdersController < BaseFoodcourtController .joins("JOIN orders ON orders.order_id=booking_orders.order_id") .joins("JOIN order_items ON orders.order_id=order_items.order_id") .joins("JOIN customers ON orders.customer_id=customers.customer_id") - .where("sales.sale_status !=? and orders.source='app' and DATE(bookings.created_at)=?",'void',@shop.shop_code,Date.today).order("bookings.created_at desc").uniq + .where("sales.sale_status !=? and orders.source='app' and DATE(bookings.created_at)=?",'void',Date.today).order("bookings.created_at desc").uniq end def completed customer =Customer.find_by_customer_id(params[:customer_id]) diff --git a/app/controllers/foodcourt/payments_controller.rb b/app/controllers/foodcourt/payments_controller.rb index 661f1d41..14a6dd02 100755 --- a/app/controllers/foodcourt/payments_controller.rb +++ b/app/controllers/foodcourt/payments_controller.rb @@ -547,7 +547,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController #shop detail #shop_detail = Shop.first - printer = PrintSetting.where("shop_code='#{@shop.shop_code}'") + printer = PrintSetting.all unique_code="ReceiptBillPdf" if !printer.empty? @@ -562,7 +562,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController end end # get printer info - print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + print_settings=PrintSetting.find_by_unique_code(unique_code) # Calculate Food and Beverage Total item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) @@ -631,7 +631,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController else receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf unique_code = "ReceiptBillPdf" - print_settings = PrintSetting.where("shop_code='#{@shop.shop_code}'") + print_settings = PrintSetting.all if !print_settings.nil? print_settings.each do |setting| if setting.unique_code == 'ReceiptBillPdf' @@ -654,7 +654,7 @@ class Foodcourt::PaymentsController < BaseFoodcourtController end end # get printer info - print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + 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) diff --git a/app/controllers/foodcourt/shifts_controller.rb b/app/controllers/foodcourt/shifts_controller.rb index 50ede017..d097282b 100755 --- a/app/controllers/foodcourt/shifts_controller.rb +++ b/app/controllers/foodcourt/shifts_controller.rb @@ -6,7 +6,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController @cashier_type = params[:type] @shift = ShiftSale.current_open_shift(current_user) #for bank integration - bank_integration = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('bank_integration') + bank_integration = Lookup.collection_of('bank_integration') @bank_integration = 0 if !bank_integration[0].nil? @bank_integration = bank_integration[0][1] @@ -15,8 +15,8 @@ class Foodcourt::ShiftsController < BaseFoodcourtController end def new - @float = Lookup.where('lookup_type=? and shop_code=?','float_value',@shop.shop_code) - @terminal = CashierTerminal.available.where("shop_code='#{@shop.shop_code}'") + @float = Lookup.where('lookup_type=?','float_value') + @terminal = CashierTerminal.available end def create @@ -56,7 +56,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController cashier_terminal.save #add shift_sale_id to card_settle_trans - bank_integration = Lookup.find_by_lookup_type_and_shop_code('bank_integration',@shop.shop_code) + bank_integration = Lookup.find_by_lookup_type('bank_integration') if !bank_integration.nil? card_settle_trans = CardSettleTran.select('id').where(['shift_sale_id IS NULL and status IS NOT NULL']) @@ -74,7 +74,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController # if !close_cashier_print[0].nil? # @close_cashier_print = close_cashier_print[0][1] # end - close_cashier_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") + close_cashier_pdf = Lookup.collection_of("print_settings") unique_code = "CloseCashierPdf" if !close_cashier_pdf.empty? @@ -98,7 +98,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController other_charges = Sale.get_other_charges() @total_other_charges_info = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",@shift) end - @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'") + @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='') @total_waste = Sale.get_total_waste(shift_id).sum(:grand_total) @total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total) #other payment details for mpu or visa like card @@ -143,7 +143,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController if @shift #get tax shift_obj = ShiftSale.where('id =?',@shift.id) - @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'") + @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='') #other payment details for mpu or visa like card @other_payment = ShiftSale.get_by_shift_other_payment(@shift) diff --git a/app/controllers/foodcourt/surveys_controller.rb b/app/controllers/foodcourt/surveys_controller.rb index e7f4a664..e664aca2 100644 --- a/app/controllers/foodcourt/surveys_controller.rb +++ b/app/controllers/foodcourt/surveys_controller.rb @@ -18,8 +18,8 @@ class Foodcourt::SurveysController < BaseFoodcourtController if @booking.dining_facility_id.to_i>0 @dining_facility = DiningFacility.find(@booking.dining_facility_id) @table_type = @dining_facility.type - @survey_data = Survey.find_by_dining_name_and_shop_code(@dining_facility.name,@shop.shop_code) - survey_process = Survey.find_by_receipt_no_and_shop_code(@receipt_no,@shop.shop_code) + @survey_data = Survey.find_by_dining_name(@dining_facility.name) + survey_process = Survey.find_by_receipt_no(@receipt_no) if !survey_process.nil? @survey_data = survey_process end @@ -33,7 +33,7 @@ class Foodcourt::SurveysController < BaseFoodcourtController @table_type = @dining_facility.type @receipt_no = nil @grand_total = nil - @survey_data = Survey.find_by_dining_name_and_receipt_no_and_shop_code(@dining_facility.name,nil,@shop.shop_code) + @survey_data = Survey.find_by_dining_name_and_receipt_no(@dining_facility.name,nil) end end @@ -46,7 +46,7 @@ class Foodcourt::SurveysController < BaseFoodcourtController # cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_id) # shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil) # set cashier - open_cashier = Employee.where("role = 'cashier' AND token_session <> '' and shop_code='#{@shop.shop_code}'") + open_cashier = Employee.where("role = 'cashier' AND token_session <> ''") current_shift = ShiftSale.current_shift current_shift_user =Employee.find_by_id(current_user.employee_id) if open_cashier.count>0 diff --git a/app/controllers/foodcourt/void_controller.rb b/app/controllers/foodcourt/void_controller.rb index 10171423..d86eb652 100755 --- a/app/controllers/foodcourt/void_controller.rb +++ b/app/controllers/foodcourt/void_controller.rb @@ -64,7 +64,7 @@ class Foodcourt::VoidController < BaseFoodcourtController # FOr Sale Audit action_by = current_user.name if access_code != "null" && current_user.role == "cashier" - action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name + action_by = Employee.find_by_emp_id(access_code).name end # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" @@ -111,7 +111,7 @@ class Foodcourt::VoidController < BaseFoodcourtController current_balance = 0 end - printer = PrintSetting.where("shop_code='#{@shop.shop_code}'") + printer = PrintSetting.all unique_code="ReceiptBillPdf" if !printer.empty? @@ -126,7 +126,7 @@ class Foodcourt::VoidController < BaseFoodcourtController end end # get printer info - print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + print_settings=PrintSetting.find_by_unique_code(unique_code) # Calculate Food and Beverage Total item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) diff --git a/app/controllers/foodcourt/waste_spoile_controller.rb b/app/controllers/foodcourt/waste_spoile_controller.rb index c7619636..aea75d18 100755 --- a/app/controllers/foodcourt/waste_spoile_controller.rb +++ b/app/controllers/foodcourt/waste_spoile_controller.rb @@ -54,7 +54,7 @@ class Foodcourt::WasteSpoileController < BaseFoodcourtController # FOr Sale Audit action_by = current_user.name if access_code != "null" && current_user.role == "cashier" - action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name + action_by = Employee.find_by_emp_id(access_code).name end # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,remark ) @@ -88,7 +88,7 @@ class Foodcourt::WasteSpoileController < BaseFoodcourtController customer= Customer.find(sale.customer_id) # get member information - rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code) + rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate member_info = Customer.get_member_account(customer) rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no) @@ -96,7 +96,7 @@ class Foodcourt::WasteSpoileController < BaseFoodcourtController current_balance = 0 end - printer = PrintSetting.where("shop_code='#{@shop.shop_code}'") + printer = PrintSetting.all unique_code="ReceiptBillPdf" if !printer.empty? @@ -112,7 +112,7 @@ class Foodcourt::WasteSpoileController < BaseFoodcourtController end # get printer info - print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + print_settings=PrintSetting.find_by_unique_code(unique_code) # Calculate Food and Beverage Total item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 1f445e6c..9e9b4866 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -18,8 +18,8 @@ class HomeController < ApplicationController def index # @employees = Employee.all_emp_except_waiter.order("name asc") - @employees = Employee.all.where("shop_code='#{@shop.shop_code}' and is_active = true").order("name asc") - @roles = Employee.where("shop_code='#{@shop.shop_code}'").distinct.pluck(:role) + @employees = Employee.all.where("is_active = true").order("name asc") + @roles = Employee.distinct.pluck(:role) # byebug # @roles = Lookup.collection_of("employee_roles") diff --git a/app/controllers/inventory/inventory_controller.rb b/app/controllers/inventory/inventory_controller.rb index e9629f4e..1e73f250 100755 --- a/app/controllers/inventory/inventory_controller.rb +++ b/app/controllers/inventory/inventory_controller.rb @@ -3,14 +3,14 @@ class Inventory::InventoryController < BaseInventoryController def index filter = params[:filter] - @inventory_definitions = InventoryDefinition.get_by_category(@shop,filter) + @inventory_definitions = InventoryDefinition.get_by_category(filter) end def show inventory_definition_id = params[:inventory_definition_id] - inventory = InventoryDefinition.find_by_id_and_shop_code(inventory_definition_id,@shop.shop_code) - @stock_journals = StockJournal.where("item_code=? and shop_code='#{@shop.shop_code}'",inventory.item_code).order("id DESC") + inventory = InventoryDefinition.find_by_id(inventory_definition_id) + @stock_journals = StockJournal.where("item_code=?",inventory.item_code).order("id DESC") @stock_journals = Kaminari.paginate_array(@stock_journals).page(params[:page]).per(20) respond_to do |format| diff --git a/app/controllers/inventory/inventory_definitions_controller.rb b/app/controllers/inventory/inventory_definitions_controller.rb index 22e151db..b3496c49 100755 --- a/app/controllers/inventory/inventory_definitions_controller.rb +++ b/app/controllers/inventory/inventory_definitions_controller.rb @@ -4,7 +4,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController # GET /inventory_definitions # GET /inventory_definitions.json def index - @inventory_definitions = InventoryDefinition.where("shop_code='#{@shop.shop_code}'") + @inventory_definitions = InventoryDefinition.all end # GET /inventory_definitions/1 @@ -14,7 +14,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController # GET /inventory_definitions/new def new - @menus = Menu.where("shop_code='#{@shop.shop_code}'").order('created_at asc') + @menus = Menu.order('created_at asc') @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc') @inventory_definition = InventoryDefinition.new end @@ -26,7 +26,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController # POST /inventory_definitions # POST /inventory_definitions.json def create - inventory = InventoryDefinition.find_by_item_code_and_shop_code(params[:item_code],@shop.shop_code) + inventory = InventoryDefinition.find_by_item_code(params[:item_code]) if inventory.nil? @inventory_definition = InventoryDefinition.new @@ -84,7 +84,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController # DELETE /inventory_definitions/1 # DELETE /inventory_definitions/1.json def destroy - inventory = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code) + inventory = InventoryDefinition.find_by_id(params[:id]) @inventory_definition.destroy respond_to do |format| format.html { redirect_to inventory_inventory_definitions_url, notice: 'Inventory definition was successfully destroyed.' } @@ -107,7 +107,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController private # Use callbacks to share common setup or constraints between actions. def set_inventory_definition - @inventory_definition = InventoryDefinition.find_by_id_and_shop_code(params[:id],@shop.shop_code) + @inventory_definition = InventoryDefinition.find_by_id(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. diff --git a/app/controllers/inventory/stock_checks_controller.rb b/app/controllers/inventory/stock_checks_controller.rb index 2eb0bdae..b71b7bec 100755 --- a/app/controllers/inventory/stock_checks_controller.rb +++ b/app/controllers/inventory/stock_checks_controller.rb @@ -8,7 +8,6 @@ class Inventory::StockChecksController < BaseInventoryController .joins("JOIN menu_item_instances mii ON mii.item_instance_code = inventory_definitions.item_code" + " JOIN menu_items mi ON mi.id = mii.menu_item_id" + " JOIN menu_categories mc ON mc.id = mi.menu_category_id ") - .where("inventory_definitions.shop_code='#{@shop.shop_code}'") .group("mi.menu_category_id") .order("mi.menu_category_id desc") unless !@category.nil? @@ -24,7 +23,7 @@ class Inventory::StockChecksController < BaseInventoryController end def show - @check = StockCheck.find_by_id_and_shop_code(params[:id],@shop.shop_code) + @check = StockCheck.find_by_id(params[:id]) @stock_check_items = StockCheckItem.get_items_with_category(params[:id]) diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index c89f6e0a..8c766a96 100755 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -6,8 +6,8 @@ class Oqs::HomeController < BaseOqsController # Query for OQS with delivery status true # @tables = DiningFacility.all.active.order('status desc') - @tables = DiningFacility.all.active.where("type = 'Table' and shop_code='#{@shop.shop_code}' ").order('status desc') - @rooms = DiningFacility.all.active.where("type = 'Room' and shop_code='#{@shop.shop_code}' ").order('status desc') + @tables = DiningFacility.all.active.where("type = 'Table'").order('status desc') + @rooms = DiningFacility.all.active.where("type = 'Room'").order('status desc') @filter = params[:filter] @@ -232,7 +232,7 @@ class Oqs::HomeController < BaseOqsController left join bookings as bk on bk.booking_id = bo.booking_id left join dining_facilities as df on df.id = bk.dining_facility_id") .where("assigned_order_items.created_at between '#{Time.now.beginning_of_day.utc}' and '#{Time.now.end_of_day.utc}'") - query = query.where("df.shop_code='#{@shop.shop_code}' and df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",) + query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",) .group("odt.order_items_id") .order("assigned_order_items.created_at desc") diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index 72ef22bc..fc95e227 100755 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -19,7 +19,7 @@ class Origami::AddordersController < BaseOrigamiController if check_mobile @webview = true end - display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code) + 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 diff --git a/app/controllers/origami/cash_ins_controller.rb b/app/controllers/origami/cash_ins_controller.rb index 2dbd3796..8aebb03f 100755 --- a/app/controllers/origami/cash_ins_controller.rb +++ b/app/controllers/origami/cash_ins_controller.rb @@ -21,7 +21,7 @@ class Origami::CashInsController < BaseOrigamiController shift = shift else - open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''") + open_cashier = Employee.where("role = 'cashier' AND token_session <> ''") if open_cashier.count>0 shift = ShiftSale.current_open_shift(open_cashier[0]) diff --git a/app/controllers/origami/cash_outs_controller.rb b/app/controllers/origami/cash_outs_controller.rb index 98f82ade..d2c29784 100755 --- a/app/controllers/origami/cash_outs_controller.rb +++ b/app/controllers/origami/cash_outs_controller.rb @@ -16,7 +16,7 @@ class Origami::CashOutsController < BaseOrigamiController if shift != nil shift = shift else - open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''") + open_cashier = Employee.where("role = 'cashier' AND token_session <> ''") if open_cashier.count>0 shift = ShiftSale.current_open_shift(open_cashier[0]) diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 29b7e8bb..4f25cb7d 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -92,12 +92,12 @@ class Origami::CustomersController < BaseOrigamiController # if flash["errors"] # @crm_customer.valid? # end - @membership_types = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("member_group_type") + @membership_types = Lookup.collection_of("member_group_type") #get paypar accountno @paypar_accountno = Customer.where("paypar_account_no IS NOT NULL AND paypar_account_no != ''").pluck("paypar_account_no") #for create customer on/off @create_flag = true - lookup_customer = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('customer_settings') + lookup_customer = Lookup.collection_of('customer_settings') if !lookup_customer.empty? lookup_customer.each do |create_setting| if create_setting[0].downcase == "create" @@ -168,9 +168,9 @@ class Origami::CustomersController < BaseOrigamiController sale = Sale.find_by_receipt_no(receipt_no) @out = [] action_by = current_user.name - membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",@shop.shop_code) + membership_setting = MembershipSetting.find_by_membership_type("paypar_url") if membership_setting.gateway_url - member_actions =MembershipAction.find_by_membership_type_and_shop_code("get_account_balance",@shop.shop_code) + member_actions =MembershipAction.find_by_membership_type("get_account_balance") if member_actions.gateway_url @campaign_type_id = nil url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s diff --git a/app/controllers/origami/dashboard_controller.rb b/app/controllers/origami/dashboard_controller.rb index 5fd47f7f..ef855bbf 100644 --- a/app/controllers/origami/dashboard_controller.rb +++ b/app/controllers/origami/dashboard_controller.rb @@ -47,21 +47,21 @@ class Origami::DashboardController < BaseOrigamiController @print_settings = PrintSetting.get_precision_delimiter() @current_user = current_user #dine-in cashier - dinein_cashier = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('dinein_cashier') + dinein_cashier = Lookup.collection_of('dinein_cashier') @dinein_cashier = 0 if !dinein_cashier[0].nil? @dinein_cashier = dinein_cashier[0][1] end #quick service - quick_service = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('quick_service') + quick_service = Lookup.collection_of('quick_service') @quick_service = 0 if !quick_service[0].nil? @quick_service = quick_service[0][1] end #fourt court - food_court = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('food_court') + food_court = Lookup.collection_of('food_court') @food_court = 0 @food_court_name = nil if !food_court[0].nil? @@ -70,7 +70,7 @@ class Origami::DashboardController < BaseOrigamiController end #order reservation - order_reservation = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('order_reservation') + order_reservation = Lookup.collection_of('order_reservation') @order_reservation = 0 if !order_reservation.empty? order_reservation.each do |order_reserve| @@ -81,7 +81,7 @@ class Origami::DashboardController < BaseOrigamiController end #dashboard settings on/off for supervisor and cashier - dashboard_settings = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('dashboard_settings') + dashboard_settings = Lookup.collection_of('dashboard_settings') @setting_flag = true if !dashboard_settings.empty? dashboard_settings.each do |setting| @@ -92,7 +92,7 @@ class Origami::DashboardController < BaseOrigamiController end #reservation - reservation = Lookup.where("shop_code='#{current_shop.shop_code}'").collection_of('reservation') + reservation = Lookup.collection_of('reservation') @reservation = 0 if !reservation.empty? reservation.each do |reserve| diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index 4d9f26f8..19a9f087 100755 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -21,8 +21,8 @@ class Origami::DiscountsController < BaseOrigamiController end end - @member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code) - @accounts = Account.where("shop_code='#{@shop.shop_code}'") + @member_discount = MembershipSetting.find_by_discount(1) + @accounts = Account.all end #discount page show from origami index with selected order diff --git a/app/controllers/origami/food_court_controller.rb b/app/controllers/origami/food_court_controller.rb index f4806217..fde4d754 100644 --- a/app/controllers/origami/food_court_controller.rb +++ b/app/controllers/origami/food_court_controller.rb @@ -17,10 +17,10 @@ class Origami::FoodCourtController < ApplicationController # @menus = Menu.all # @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc') # end - @zone = Zone.all.where("shop_code='#{@shop.shop_code}' and is_active= true") + @zone = Zone.all.where("is_active= true") @customer = Customer.all - @tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') - @rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') + @tables = Table.all.active.order('status desc') + @rooms = Room.all.active.order('status desc') @cashier_type = "food_court" display_type = Lookup.find_by_lookup_type("display_type") if !display_type.nil? && display_type.value.to_i ==2 @@ -31,7 +31,7 @@ class Origami::FoodCourtController < ApplicationController #checked quick_service only @quick_service_only = true - lookup_dine_in = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('dinein_cashier') + 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" @@ -160,7 +160,7 @@ class Origami::FoodCourtController < ApplicationController end def get_all_product() - @product = Product..where("shop_code='#{@shop.shop_code}'") + @product = Product.all end # render json for http status code diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 1e7baf7d..6ea59d86 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -73,16 +73,16 @@ class Origami::HomeController < BaseOrigamiController end #for bank integration - @checkout_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_time') - @checkout_alert_time = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('checkout_alert_time') + @checkout_time = Lookup.collection_of('checkout_time') + @checkout_alert_time = Lookup.collection_of('checkout_alert_time') - accounts = TaxProfile.where("shop_code='#{@shop.shop_code}' and group_type = ?","cashier").order("order_by ASC") + accounts = TaxProfile.where("group_type = ?","cashier").order("order_by ASC") @tax_arr =[] accounts.each do |acc| @tax_arr.push(acc.name) end - lookup_spit_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('split_bill') + lookup_spit_bill = Lookup.collection_of('split_bill') @split_bill = 0 if !lookup_spit_bill[0].nil? @split_bill = lookup_spit_bill[0][1] @@ -90,7 +90,7 @@ class Origami::HomeController < BaseOrigamiController #for edit order on/off @edit_order_origami = true - lookup_edit_order = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('edit_order') + lookup_edit_order = Lookup.collection_of('edit_order') if !lookup_edit_order.empty? lookup_edit_order.each do |edit_order| if edit_order[0].downcase == "editorderorigami" @@ -103,7 +103,7 @@ class Origami::HomeController < BaseOrigamiController #for changable on/off @changable_tax = true - lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax') + 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" diff --git a/app/controllers/origami/order_reservation_controller.rb b/app/controllers/origami/order_reservation_controller.rb index 54760e78..88dfd1b4 100644 --- a/app/controllers/origami/order_reservation_controller.rb +++ b/app/controllers/origami/order_reservation_controller.rb @@ -98,12 +98,12 @@ class Origami::OrderReservationController < BaseOrigamiController end def get_order_info - order_reservation = OrderReservation.where("status = 'new' and shop_code='#{current_shop.shop_code}'").count() + order_reservation = OrderReservation.where("status = 'new'").count() render :json => order_reservation end def check_receipt_bill - receipt_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("order_reservation") + receipt_bill = Lookup.collection_of("order_reservation") status = 0 if !receipt_bill.nil? diff --git a/app/controllers/origami/paymal_controller.rb b/app/controllers/origami/paymal_controller.rb index a65319d2..419e914f 100644 --- a/app/controllers/origami/paymal_controller.rb +++ b/app/controllers/origami/paymal_controller.rb @@ -32,9 +32,9 @@ class Origami::PaymalController < BaseOrigamiController if customer_data @membership_id = customer_data.membership_id if !@membership_id.nil? - membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",@shop.shop_code) + membership_setting = MembershipSetting.find_by_membership_type("paypar_url") if membership_setting.gateway_url - member_actions =MembershipAction.find_by_membership_type_and_shop_code("get_account_balance",@shop.shop_code) + member_actions =MembershipAction.find_by_membership_type("get_account_balance") if member_actions.gateway_url @campaign_type_id = nil url = membership_setting.gateway_url.to_s + member_actions.gateway_url.to_s diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 371dd070..07c716e2 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -65,7 +65,7 @@ class Origami::PaymentsController < BaseOrigamiController end end - filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings, status, qr, 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, status, qr, cashier_terminal, sale_items, sale_data, customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, @shop, "Frt", current_balance, nil, other_amount, nil, nil, nil) result = { :filepath => filename, @@ -202,7 +202,7 @@ class Origami::PaymentsController < BaseOrigamiController other_amount = SaleItem.calculate_other_charges(sale_items) printer = Printer::ReceiptPrinter.new(print_settings) - filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_detail, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil) + filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil, cashier_terminal,sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,@shop, "Paid",current_balance,card_data,other_amount,latest_order_no,card_balance_amount,nil) #end end @@ -225,7 +225,7 @@ class Origami::PaymentsController < BaseOrigamiController # end def show - display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code) + 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 @@ -245,7 +245,7 @@ class Origami::PaymentsController < BaseOrigamiController @sale_payment = SalePayment.where(sale_id: sale_id, payment_method: 'creditnote').select("SUM(payment_amount) as payment_amount") end - @member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code) + @member_discount = MembershipSetting.find_by_discount(1) @membership_rebate_balance=0 if Sale.exists?(sale_id) @@ -270,7 +270,7 @@ class Origami::PaymentsController < BaseOrigamiController @dining = '' @other_payment = 0.0 @pdf_view = nil - @lookup_pdf = Lookup.find_by_lookup_type_and_shop_code("ReceiptPdfView",@shop.shop_code) + @lookup_pdf = Lookup.find_by_lookup_type("ReceiptPdfView") if !@lookup_pdf.nil? @pdf_view = @lookup_pdf.value end @@ -280,7 +280,7 @@ class Origami::PaymentsController < BaseOrigamiController #for changable on/off @changable_tax = true - lookup_changable_tax = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('changable_tax') + 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" @@ -348,7 +348,7 @@ class Origami::PaymentsController < BaseOrigamiController #get customer amount @customer = Customer.find(@sale_data.customer_id) # accounts = @customer.tax_profiles - accounts = TaxProfile.where("group_type = ? and shop_code='#{@shop.shop_code}'",@cashier_type).order("order_by ASC") + accounts = TaxProfile.where("group_type = ?",@cashier_type).order("order_by ASC") @account_arr =[] @tax_arr =[] accounts.each do |acc| @@ -362,7 +362,7 @@ class Origami::PaymentsController < BaseOrigamiController @account_arr.push(sale_tax) end end - rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code) + rebate = MembershipSetting.find_by_rebate(1) # get member information if @customer.membership_id != nil && rebate response = Customer.get_member_account(@customer) @@ -613,7 +613,7 @@ class Origami::PaymentsController < BaseOrigamiController end end # get printer info - print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + print_settings=PrintSetting.find_by_unique_code(unique_code) # Calculate Food and Beverage Total item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items) @@ -680,9 +680,9 @@ class Origami::PaymentsController < BaseOrigamiController if cashier_type.strip.downcase == "doemal_order" unique_code = "ReceiptBillOrderPdf" else - receipt_bill_a5_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf + receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf unique_code = "ReceiptBillPdf" - print_settings = PrintSetting.where("shop_code='#{@shop.shop_code}'") + print_settings = PrintSetting.all if !print_settings.nil? print_settings.each do |setting| if setting.unique_code == 'ReceiptBillPdf' diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index a567851f..21530e65 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -30,8 +30,8 @@ class Origami::RoomsController < BaseOrigamiController @status_order = "" @status_sale = "" @sale_array = Array.new - @membership = MembershipSetting.find_by_shop_code(@shop.shop_code) - @payment_methods = PaymentMethodSetting.find_by_shop_code(@shop.shop_code) + @membership = MembershipSetting.all + @payment_methods = PaymentMethodSetting.all @membership = MembershipSetting::MembershipSetting @payment_methods = PaymentMethodSetting.all @dining_room = @room.bookings.active.where("DATE_FORMAT(created_at,'%Y-%m-%d') = '#{DateTime.now.strftime('%Y-%m-%d')}' OR DATE_FORMAT(created_at,'%Y-%m-%d') = '#{Date.today.prev_day}' ") diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index 7c70ea89..91033f94 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -15,7 +15,7 @@ class Origami::ShiftsController < BaseOrigamiController end def new - @float = Lookup.where('lookup_type=? and shop_code=?','float_value',@shop.shop_code) + @float = Lookup.where('lookup_type=?','float_value') @terminal = CashierTerminal.available end @@ -56,7 +56,7 @@ class Origami::ShiftsController < BaseOrigamiController cashier_terminal.save #add shift_sale_id to card_settle_trans - bank_integration = Lookup.find_by_lookup_type_and_shop_code('bank_integration',@shop.shop_code) + bank_integration = Lookup.find_by_lookup_type('bank_integration') if !bank_integration.nil? card_settle_trans = CardSettleTran.select('id').where(['shift_sale_id IS NULL and status IS NOT NULL']) @@ -74,7 +74,7 @@ class Origami::ShiftsController < BaseOrigamiController # if !close_cashier_print[0].nil? # @close_cashier_print = close_cashier_print[0][1] # end - close_cashier_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") + close_cashier_pdf = Lookup.collection_of("print_settings") unique_code = "CloseCashierPdf" if !close_cashier_pdf.empty? @@ -97,7 +97,7 @@ class Origami::ShiftsController < BaseOrigamiController other_charges = Sale.get_other_charges() @total_other_charges_info = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",@shift) end - @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'") + @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='') @total_waste = Sale.get_total_waste(shift_id).sum(:grand_total) @total_spoile = Sale.get_total_spoile(shift_id).sum(:grand_total) #other payment details for mpu or visa like card @@ -144,7 +144,7 @@ class Origami::ShiftsController < BaseOrigamiController if @shift #get tax shift_obj = ShiftSale.where('id =?',@shift.id) - @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='').where("sales.shop_code='#{@shop.shop_code}'") + @sale_taxes = Sale.get_separate_tax(shift_obj,from=nil,to=nil,type='') #other payment details for mpu or visa like card @other_payment = ShiftSale.get_by_shift_other_payment(@shift) diff --git a/app/controllers/origami/surveys_controller.rb b/app/controllers/origami/surveys_controller.rb index efe8271b..126f7d11 100644 --- a/app/controllers/origami/surveys_controller.rb +++ b/app/controllers/origami/surveys_controller.rb @@ -18,8 +18,8 @@ class Origami::SurveysController < BaseOrigamiController if @booking.dining_facility_id.to_i>0 @dining_facility = DiningFacility.find(@booking.dining_facility_id) @table_type = @dining_facility.type - @survey_data = Survey.find_by_dining_name_and_shop_code(@dining_facility.name,@shop.shop_code) - survey_process = Survey.find_by_receipt_no_and_shop_code(@receipt_no,@shop.shop_code) + @survey_data = Survey.find_by_dining_name(@dining_facility.name) + survey_process = Survey.find_by_receipt_no(@receipt_no) if !survey_process.nil? @survey_data = survey_process end @@ -46,7 +46,7 @@ class Origami::SurveysController < BaseOrigamiController # cashier_zone = CashierTerminalByZone.find_by_zone_id(@dining_facility.zone_id) # shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil) # set cashier - open_cashier = Employee.where("role = 'cashier' AND token_session <> '' and shop_code='#{@shop.shop_code}'") + open_cashier = Employee.where("role = 'cashier' AND token_session <> ''") current_shift = ShiftSale.current_shift current_shift_user =Employee.find_by_id(current_user.employee_id) if open_cashier.count>0 diff --git a/app/controllers/origami/table_invoices_controller.rb b/app/controllers/origami/table_invoices_controller.rb index d72afd9a..0431ff87 100755 --- a/app/controllers/origami/table_invoices_controller.rb +++ b/app/controllers/origami/table_invoices_controller.rb @@ -39,7 +39,7 @@ class Origami::TableInvoicesController < BaseOrigamiController @status_sale = 'sale' @customer = @sale.customer #for split bill - lookup_spit_bill = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of('split_bill') + lookup_spit_bill = Lookup.collection_of('split_bill') @split_bill = 0 if !lookup_spit_bill[0].nil? @split_bill = lookup_spit_bill[0][1] diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index d0d001c2..b4a3c1dc 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -72,7 +72,7 @@ class Origami::VoidController < BaseOrigamiController # FOr Sale Audit action_by = current_user.name if access_code != "null" && current_user.role == "cashier" - action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name + action_by = Employee.find_by_emp_id(access_code).name end # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" @@ -114,7 +114,7 @@ class Origami::VoidController < BaseOrigamiController customer= Customer.find(sale.customer_id) # get member information - rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code) + rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate member_info = Customer.get_member_account(customer) rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no) @@ -122,7 +122,7 @@ class Origami::VoidController < BaseOrigamiController current_balance = 0 end - printer = PrintSetting.where("shop_code='#{@shop.shop_code}'") + printer = PrintSetting.all unique_code="ReceiptBillPdf" if !printer.empty? @@ -137,7 +137,7 @@ class Origami::VoidController < BaseOrigamiController end end # get printer info - print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + print_settings=PrintSetting.find_by_unique_code(unique_code) # Calculate Food and Beverage Total item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) diff --git a/app/controllers/origami/waste_spoile_controller.rb b/app/controllers/origami/waste_spoile_controller.rb index 13a70728..4ab7b671 100755 --- a/app/controllers/origami/waste_spoile_controller.rb +++ b/app/controllers/origami/waste_spoile_controller.rb @@ -54,7 +54,7 @@ class Origami::WasteSpoileController < BaseOrigamiController # FOr Sale Audit action_by = current_user.name if access_code != "null" && current_user.role == "cashier" - action_by = Employee.find_by_emp_id_and_shop_code(access_code,@shop.shop_code).name + action_by = Employee.find_by_emp_id(access_code).name end # remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}" sale_audit = SaleAudit.record_audit_for_edit(sale_id,current_user.name, action_by,remark,remark ) @@ -87,7 +87,7 @@ class Origami::WasteSpoileController < BaseOrigamiController # unique_code = "ReceiptBillPdf" customer= Customer.find(sale.customer_id) # get member information - rebate = MembershipSetting.find_by_rebate_and_shop_code(1,@shop.shop_code) + rebate = MembershipSetting.find_by_rebate(1) if customer.membership_id != nil && rebate member_info = Customer.get_member_account(customer) rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no) @@ -95,7 +95,7 @@ class Origami::WasteSpoileController < BaseOrigamiController current_balance = 0 end - printer = PrintSetting.where("shop_code='#{@shop.shop_code}'") + printer = PrintSetting.all unique_code="ReceiptBillPdf" if !printer.empty? @@ -111,7 +111,7 @@ class Origami::WasteSpoileController < BaseOrigamiController end # get printer info - print_settings=PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + print_settings=PrintSetting.find_by_unique_code(unique_code) # Calculate Food and Beverage Total item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items) discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items) diff --git a/app/controllers/reports/commission_controller.rb b/app/controllers/reports/commission_controller.rb index b30299d2..25f8bb03 100755 --- a/app/controllers/reports/commission_controller.rb +++ b/app/controllers/reports/commission_controller.rb @@ -6,7 +6,7 @@ class Reports::CommissionController < BaseReportController commissioner = params[:commissioner].to_i @com_id = commissioner - @commissioner = Commissioner.active.where("shop_code='#{@shop.shop_code}'") + @commissioner = Commissioner.active @transaction = ProductCommission.get_transaction(from_date, to_date, commissioner) @@ -23,7 +23,7 @@ class Reports::CommissionController < BaseReportController def show from, to = get_date_range_from_params - @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") + @sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED) date_arr = Array.new @sale_data.each do |sale| diff --git a/app/controllers/reports/credit_payment_controller.rb b/app/controllers/reports/credit_payment_controller.rb index c1c16623..76465bd8 100755 --- a/app/controllers/reports/credit_payment_controller.rb +++ b/app/controllers/reports/credit_payment_controller.rb @@ -5,16 +5,16 @@ authorize_resource :class => false @sources = [["All",''], ["Cashier","cashier"],["Quick Service","quick_service"],["Online Order","doemal_order"]] from, to = get_date_range_from_params - @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") + @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) @shift = '' if params[:shift_name].to_i != 0 shift_sale = ShiftSale.find(params[:shift_name]) if to.blank? - @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at) + @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at) else - @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at) + @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at) end end diff --git a/app/controllers/reports/dailysale_controller.rb b/app/controllers/reports/dailysale_controller.rb index 74c73477..159232db 100755 --- a/app/controllers/reports/dailysale_controller.rb +++ b/app/controllers/reports/dailysale_controller.rb @@ -7,7 +7,7 @@ class Reports::DailysaleController < BaseReportController @tax = SaleTax.get_tax(from,to) @from = from @to = to - @payment_methods = PaymentMethodSetting.where("is_active='1' and shop_code=?",@shop.shop_code).pluck("payment_method") + @payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method") # get printer info @print_settings = PrintSetting.get_precision_delimiter() respond_to do |format| diff --git a/app/controllers/reports/hourly_saleitem_controller.rb b/app/controllers/reports/hourly_saleitem_controller.rb index 38d4cb27..4092ee40 100644 --- a/app/controllers/reports/hourly_saleitem_controller.rb +++ b/app/controllers/reports/hourly_saleitem_controller.rb @@ -1,7 +1,7 @@ class Reports::HourlySaleitemController < BaseReportController authorize_resource :class => false def index - @account = Account.where("shop_code='#{@shop.shop_code}'") + @account = Account.all from, to = get_date_range_from_params @start_time = params[:start_time] @@ -12,16 +12,16 @@ class Reports::HourlySaleitemController < BaseReportController shift = '' if params[:shift_name].to_i != 0 - shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") + shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) shift_sale = ShiftSale.find(params[:shift_name]) if to.blank? - shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at) + shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at) else if shift_sale.shift_closed_at.blank? - shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at) + shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at) else - shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at) + shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at) end end end @@ -31,7 +31,7 @@ class Reports::HourlySaleitemController < BaseReportController @type = params[:sale_type] @sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_hourly_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type,filter,@start_time,@end_time) - @sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil).where("sales.shop_code='#{@shop.shop_code}'") + @sale_taxes = Sale.get_separate_tax(shift_sale_range,shift,from,to,nil) @account_cate_count = Hash.new {|hash, key| hash[key] = 0} @sale_data.each {|acc_cate| @account_cate_count[acc_cate.account_id] += 1} diff --git a/app/controllers/reports/induty_controller.rb b/app/controllers/reports/induty_controller.rb index efc821a7..2c435f25 100644 --- a/app/controllers/reports/induty_controller.rb +++ b/app/controllers/reports/induty_controller.rb @@ -1,20 +1,20 @@ class Reports::IndutyController < BaseReportController authorize_resource :class => false def index - @commissioners = Commissioner.where("shop_code='#{@shop.shop_code}'") #.where("is_active='1'") + @commissioners = Commissioner.all from, to = get_date_range_from_params - @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") + @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) @shift = '' if params[:shift_name].to_i != 0 shift_sale = ShiftSale.find(params[:shift_name]) if to.blank? - @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at) + @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at) else - @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at, shift_sale.shift_closed_at) + @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at) end end @@ -43,7 +43,7 @@ class Reports::IndutyController < BaseReportController def show from, to = get_date_range_from_params - @induty_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") + @induty_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) @commissioner = params[:commissioner] date_arr = Array.new diff --git a/app/controllers/reports/order_reservation_controller.rb b/app/controllers/reports/order_reservation_controller.rb index 4625c1f1..257623dc 100644 --- a/app/controllers/reports/order_reservation_controller.rb +++ b/app/controllers/reports/order_reservation_controller.rb @@ -11,16 +11,16 @@ class Reports::OrderReservationController < BaseReportController @shift = '' if params[:shift_name].to_i != 0 - @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") + @shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) shift_sale = ShiftSale.find(params[:shift_name]) if to.blank? - @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at) + @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at) else if shift_sale.shift_closed_at.blank? - @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at) + @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at) else - @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at) + @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at) end end end diff --git a/app/controllers/reports/payment_method_controller.rb b/app/controllers/reports/payment_method_controller.rb index 244e2974..3a82f01d 100644 --- a/app/controllers/reports/payment_method_controller.rb +++ b/app/controllers/reports/payment_method_controller.rb @@ -15,9 +15,9 @@ class Reports::PaymentMethodController < BaseReportController if params[:shift_name].to_i != 0 shift_sale = ShiftSale.find(params[:shift_name]) if to.blank? - @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at) + @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at) else - @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at) + @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at) end end @payment_type = params[:payment_type] diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index 5da8f9de..e06c1007 100755 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -2,7 +2,7 @@ class Reports::ReceiptNoController < BaseReportController authorize_resource :class => false def index @payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]] - @payment_method = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'") + @payment_method = PaymentMethodSetting.all from, to = get_date_range_from_params @shift_sale_range = '' @@ -14,17 +14,17 @@ authorize_resource :class => false @shift_sale = ShiftSale.find(params[:shift_name]) if to.blank? - @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",@shift_sale.shift_started_at) + @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",@shift_sale.shift_started_at) else if @shift_sale.shift_closed_at.blank? - @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",@shift_sale.shift_started_at) + @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",@shift_sale.shift_started_at) else - @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}' ",@shift_sale.shift_started_at, @shift_sale.shift_closed_at) + @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",@shift_sale.shift_started_at, @shift_sale.shift_closed_at) end end end - @lookup = Lookup.find_by_lookup_type_and_shop_code('reprint_receipt',@shop.shop_code) + @lookup = Lookup.find_by_lookup_type('reprint_receipt') if @lookup.nil? @lookup = Lookup.create_reprint_receipt_lookup(@shop.shop_code) end @@ -32,7 +32,7 @@ authorize_resource :class => false payment_type = params[:payment_type] @sale_data = Sale.get_shift_sales_by_receipt_no(@shift_sale_range,@shift,from,to,payment_type).where("sales.shop_code='#{@shop.shop_code}'") @sale_taxes = Sale.get_separate_tax(@shift_sale_range,@shift,from,to,payment_type).where("sales.shop_code='#{@shop.shop_code}'") - @tax_profiles = TaxProfile.where("shop_code='#{@shop.shop_code}'").group('name').order('order_by asc') #.limit(2) + @tax_profiles = TaxProfile.group('name').order('order_by asc') #.limit(2) @from = from @to = to diff --git a/app/controllers/reports/receipt_no_detail_controller.rb b/app/controllers/reports/receipt_no_detail_controller.rb index 59bf70c5..0fe2458d 100755 --- a/app/controllers/reports/receipt_no_detail_controller.rb +++ b/app/controllers/reports/receipt_no_detail_controller.rb @@ -2,7 +2,7 @@ class Reports::ReceiptNoDetailController < BaseReportController authorize_resource :class => false def index @payments = [["All Payment",''], ["Cash Payment","cash"], ["Credit Payment","creditnote"], ["FOC Payment","foc"]] - @payment_method = PaymentMethodSetting.where("shop_code='#{@shop.shop_code}'") + @payment_method = PaymentMethodSetting.all from, to = get_date_range_from_params @shift_sale_range = '' @@ -17,9 +17,9 @@ authorize_resource :class => false @shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at) else if @shift_sale.shift_closed_at.blank? - @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",@shift_sale.shift_started_at) + @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",@shift_sale.shift_started_at) else - @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",@shift_sale.shift_started_at, @shift_sale.shift_closed_at) + @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",@shift_sale.shift_started_at, @shift_sale.shift_closed_at) end end end diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index a9cf0139..b5a55f72 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -1,7 +1,7 @@ class Reports::SaleitemController < BaseReportController authorize_resource :class => false def index - @account = Account.where("shop_code='#{@shop.shop_code}'") + @account = Account.all from, to = get_date_range_from_params shift_sale_range = '' @@ -13,12 +13,12 @@ class Reports::SaleitemController < BaseReportController shift_sale = ShiftSale.find(params[:shift_name]) if to.blank? - shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at) + shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at) else if shift_sale.shift_closed_at.blank? - shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at) + shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at) else - shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at) + shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at) end end end @@ -92,16 +92,16 @@ class Reports::SaleitemController < BaseReportController shift_name = 'All Shift' if params[:shift_name].to_i != 0 - shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") + shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) shift_sale = ShiftSale.find(params[:shift_name]) if to.blank? - shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at) + shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at) else if shift_sale.shift_closed_at.blank? - shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'" ,shift_sale.shift_started_at) + shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL" ,shift_sale.shift_started_at) else - shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at) + shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at) end end @@ -117,14 +117,14 @@ class Reports::SaleitemController < BaseReportController @sale_data, @other_charges,@product, @discount_data , @cash_data , @card_data , @credit_data , @foc_data , @grand_total , @change_amount = Sale.get_by_shift_items(shift_sale_range,shift, from, to, Sale::SALE_STATUS_COMPLETED,@type,account_type,@shop.shop_code) other_charges = Sale.get_other_charges() if shift.present? - @total_other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed' and sales.shop_code='#{@shop.shop_code}'",shift.to_a) + @total_other_charges = other_charges.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift.to_a) else - @total_other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed' and sales.shop_code='#{@shop.shop_code}'",from,to) + @total_other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to) end # get printer info - print_settings = PrintSetting.find_by_unique_code_and_shop_code('SaleItemsPdf',@shop.shop_code) # SaleItemsPdf - print_settings_star = PrintSetting.find_by_unique_code_and_shop_code('SaleItemsStarPdf',@shop.shop_code) + print_settings = PrintSetting.find_by_unique_code('SaleItemsPdf') # SaleItemsPdf + print_settings_star = PrintSetting.find_by_unique_code('SaleItemsStarPdf') if print_settings.nil? if !print_settings_star.nil? diff --git a/app/controllers/reports/shiftsale_controller.rb b/app/controllers/reports/shiftsale_controller.rb index 0c71f061..5d02e9a1 100755 --- a/app/controllers/reports/shiftsale_controller.rb +++ b/app/controllers/reports/shiftsale_controller.rb @@ -58,7 +58,7 @@ class Reports::ShiftsaleController < BaseReportController if ENV["SERVER_MODE"] != "cloud" #no print in cloud server - close_cashier_pdf = Lookup.where("shop_code='#{@shop.shop_code}'").collection_of("print_settings") + close_cashier_pdf = Lookup.collection_of("print_settings") unique_code = "CloseCashierPdf" @@ -93,7 +93,7 @@ class Reports::ShiftsaleController < BaseReportController @total_credit_payments = ShiftSale.get_shift_sales_with_credit_payment(shift_id).total_credit_payments # get printer info - print_settings = PrintSetting.find_by_unique_code_and_shop_code(unique_code,@shop.shop_code) + print_settings = PrintSetting.find_by_unique_code(unique_code) printer = Printer::CashierStationPrinter.new(print_settings) # printer.print_close_cashier(print_settings,cashier_terminal,@shift, nil, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments) diff --git a/app/controllers/reports/staff_meal_controller.rb b/app/controllers/reports/staff_meal_controller.rb index 7a478847..9b3c0236 100644 --- a/app/controllers/reports/staff_meal_controller.rb +++ b/app/controllers/reports/staff_meal_controller.rb @@ -2,7 +2,7 @@ class Reports::StaffMealController < BaseReportController authorize_resource :class => false def index - @account = Account.where("shop_code='#{@shop.shop_code}'") + @account = Account.all from, to = get_date_range_from_params shift_sale_range = '' @@ -10,16 +10,16 @@ class Reports::StaffMealController < BaseReportController shift = '' if params[:shift_name].to_i != 0 - shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED).where("shift_sales.shop_code='#{@shop.shop_code}'") + shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED) shift_sale = ShiftSale.find(params[:shift_name]) if to.blank? - shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at) + shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at) else if shift_sale.shift_closed_at.blank? - shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at) + shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at) else - shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}'",shift_sale.shift_started_at, shift_sale.shift_closed_at) + shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at) end end end diff --git a/app/controllers/reports/stock_check_controller.rb b/app/controllers/reports/stock_check_controller.rb index 48d28f42..b9e54e8b 100755 --- a/app/controllers/reports/stock_check_controller.rb +++ b/app/controllers/reports/stock_check_controller.rb @@ -12,9 +12,9 @@ class Reports::StockCheckController < BaseReportController # end from_date, to_date = get_date_range_from_params @item_code = params[:item_code] - @inventory_definitions = InventoryDefinition.active.where("shop_code='#{@shop.shop_code}'") + @inventory_definitions = InventoryDefinition.active - @transaction = StockCheckItem.where("shop_code='#{@shop.shop_code}'").get_transaction(from_date, to_date, @item_code) + @transaction = StockCheckItem.get_transaction(from_date, to_date, @item_code) @from = from_date @to = to_date # get printer info diff --git a/app/controllers/reports/void_sale_controller.rb b/app/controllers/reports/void_sale_controller.rb index 425844b8..55560bd2 100755 --- a/app/controllers/reports/void_sale_controller.rb +++ b/app/controllers/reports/void_sale_controller.rb @@ -9,10 +9,10 @@ authorize_resource :class => false if params[:shift_name].to_i != 0 shift_sale = ShiftSale.find(params[:shift_name]) if to.blank? - @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at) + @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at is NULL",shift_sale.shift_started_at) else - @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ? and shop_code='#{@shop.shop_code}' ",shift_sale.shift_started_at, shift_sale.shift_closed_at) + @shift = ShiftSale.where("shift_started_at = ? and shift_closed_at = ?",shift_sale.shift_started_at, shift_sale.shift_closed_at) end end diff --git a/app/controllers/settings/accounts_controller.rb b/app/controllers/settings/accounts_controller.rb index ca6aa027..0f5b0ba7 100755 --- a/app/controllers/settings/accounts_controller.rb +++ b/app/controllers/settings/accounts_controller.rb @@ -6,7 +6,7 @@ class Settings::AccountsController < ApplicationController # GET /settings/accounts.json def index - @settings_accounts = Account.all.where("shop_code='#{@shop.shop_code}'") + @settings_accounts = Account.all end # GET /settings/accounts/1 diff --git a/app/controllers/settings/cashier_terminals_controller.rb b/app/controllers/settings/cashier_terminals_controller.rb index cb875a6b..2e1d63c1 100755 --- a/app/controllers/settings/cashier_terminals_controller.rb +++ b/app/controllers/settings/cashier_terminals_controller.rb @@ -5,7 +5,7 @@ class Settings::CashierTerminalsController < ApplicationController # GET /settings/cashier_terminals # GET /settings/cashier_terminals.json def index - @settings_cashier_terminals = CashierTerminal.where("shop_code=?",@shop.shop_code) + @settings_cashier_terminals = CashierTerminal.all end # GET /settings/cashier_terminals/1 diff --git a/app/controllers/settings/employees_controller.rb b/app/controllers/settings/employees_controller.rb index 140ff2c0..74c8b410 100755 --- a/app/controllers/settings/employees_controller.rb +++ b/app/controllers/settings/employees_controller.rb @@ -31,7 +31,7 @@ class Settings::EmployeesController < ApplicationController # POST /employees.json def create @employee = Employee.new(employee_params) - @employee.shop_code =current_shop.shop_code + @employee.shop_code =@shop.shop_code respond_to do |format| if @employee.save format.html { redirect_to settings_employees_path, notice: 'Employee was successfully created.' } diff --git a/app/controllers/settings/lookups_controller.rb b/app/controllers/settings/lookups_controller.rb index 4390dadd..87c81842 100755 --- a/app/controllers/settings/lookups_controller.rb +++ b/app/controllers/settings/lookups_controller.rb @@ -25,7 +25,7 @@ class Settings::LookupsController < ApplicationController # POST /settings/lookups.json def create @settings_lookup = Lookup.new(settings_lookup_params) - @settings_lookup.shop_code = current_shop.shop_code + @settings_lookup.shop_code = @shop.shop_code respond_to do |format| if @settings_lookup.save format.html { redirect_to settings_lookups_path, notice: 'Lookup was successfully created.' } diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb index e449dd38..f448b959 100755 --- a/app/controllers/settings/menus_controller.rb +++ b/app/controllers/settings/menus_controller.rb @@ -6,7 +6,7 @@ class Settings::MenusController < ApplicationController # GET /settings/menus.json def index - @settings_menus = Menu.all.where("shop_code='#{@shop.shop_code}'").page(params[:page]).per(10) + @settings_menus = Menu.all.page(params[:page]).per(10) respond_to do |format| format.html format.xlsx @@ -77,7 +77,7 @@ class Settings::MenusController < ApplicationController def export - @settings_menus = Menu.all.where("shop_code='#{@shop.shop_code}'").page(params[:page]).per(10) + @settings_menus = Menu.all.page(params[:page]).per(10) menu = Menu.find(params[:id]) p = Axlsx::Package.new diff --git a/app/controllers/settings/order_queue_stations_controller.rb b/app/controllers/settings/order_queue_stations_controller.rb index ae9ad34a..e3a30d1f 100755 --- a/app/controllers/settings/order_queue_stations_controller.rb +++ b/app/controllers/settings/order_queue_stations_controller.rb @@ -6,7 +6,7 @@ class Settings::OrderQueueStationsController < ApplicationController # GET /settings/order_queue_stations # GET /settings/order_queue_stations.json def index - @settings_order_queue_stations = OrderQueueStation.where("shop_code=?",@shop.shop_code) + @settings_order_queue_stations = OrderQueueStation.all @settings_order_queue_stations = Kaminari.paginate_array(@settings_order_queue_stations).page(params[:page]).per(50) end diff --git a/app/controllers/settings/out_of_stock_controller.rb b/app/controllers/settings/out_of_stock_controller.rb index beb51bd2..36754fb8 100644 --- a/app/controllers/settings/out_of_stock_controller.rb +++ b/app/controllers/settings/out_of_stock_controller.rb @@ -7,7 +7,7 @@ class Settings::OutOfStockController < ApplicationController end def new - @menus = Menu.where("shop_code='#{@shop.shop_code}'").order('created_at asc') + @menus = Menu.order('created_at asc') @menu = MenuCategory.active.where("menu_id =#{@menus[0].id}").order('order_by asc') end diff --git a/app/controllers/settings/zones_controller.rb b/app/controllers/settings/zones_controller.rb index 57ecd577..1c1524ae 100755 --- a/app/controllers/settings/zones_controller.rb +++ b/app/controllers/settings/zones_controller.rb @@ -6,7 +6,7 @@ class Settings::ZonesController < ApplicationController # GET /settings/zones.json def index - @settings_zones = Zone.all.where("shop_code='#{@shop.shop_code}' and is_active= true") + @settings_zones = Zone.all.where("is_active= true") end # GET /settings/zones/1 diff --git a/app/controllers/transactions/bookings_controller.rb b/app/controllers/transactions/bookings_controller.rb index 75eac975..0a6f7cbb 100644 --- a/app/controllers/transactions/bookings_controller.rb +++ b/app/controllers/transactions/bookings_controller.rb @@ -9,7 +9,7 @@ class Transactions::BookingsController < ApplicationController to = params[:to] if filter.nil? && from.nil? && to.nil? - @bookings = Booking.where("shop_code=?",@shop.shop_code).order("sale_id desc") + @bookings = Booking.order("sale_id desc") @bookings = Kaminari.paginate_array(@bookings).page(params[:page]).per(20) else booking = Booking.search(filter,from,to) diff --git a/app/controllers/transactions/order_reservations_controller.rb b/app/controllers/transactions/order_reservations_controller.rb index 3f035486..9a5e259f 100644 --- a/app/controllers/transactions/order_reservations_controller.rb +++ b/app/controllers/transactions/order_reservations_controller.rb @@ -13,11 +13,11 @@ class Transactions::OrderReservationsController < ApplicationController if from.nil? && to.nil? @order_reservations = OrderReservation.select("order_reservations.*, deliveries.provider, deliveries.delivery_fee") .joins(" JOIN deliveries on deliveries.order_reservation_id = order_reservations.order_reservation_id") - .where("NOT order_reservation_status='new' and order_reservations.shop_code='#{@shop.shop_code}'") + .where("NOT order_reservation_status='new'") .order("order_reservation_id desc") @order_reservations = Kaminari.paginate_array(@order_reservations).page(params[:page]).per(20) else - order_reservation = OrderReservation.search(filter,from,to).where("order_reservations.shop_code='#{@shop.shop_code}'") + order_reservation = OrderReservation.search(filter,from,to) if order_reservation.length > 0 @order_reservations = order_reservation @order_reservations = Kaminari.paginate_array(@order_reservations).page(params[:page]).per(20) diff --git a/app/controllers/transactions/orders_controller.rb b/app/controllers/transactions/orders_controller.rb index 59b5a106..5d41439c 100755 --- a/app/controllers/transactions/orders_controller.rb +++ b/app/controllers/transactions/orders_controller.rb @@ -9,9 +9,9 @@ class Transactions::OrdersController < ApplicationController to = params[:to] if filter.nil? && from.nil? && to.nil? - orders = Order.where("shop_code='#{@shop.shop_code}'").order("order_id desc") + orders = Order.order("order_id desc") else - orders = Order.search(filter,from,to).where("orders.shop_code='#{@shop.shop_code}'") + orders = Order.search(filter,from,to) end if !orders.nil? diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index 761ec761..b4072855 100755 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -89,7 +89,7 @@ class Transactions::SalesController < ApplicationController # GET /transactions/sales/1 # GET /transactions/sales/1.json def show - @membership = MembershipSetting.find_by_shop_code(@shop.shop_code) + @membership = MembershipSetting.all @payment_methods = PaymentMethodSetting.where("is_active='1'") @sale = Sale.find(params[:id]) diff --git a/app/controllers/transactions/shift_sales_controller.rb b/app/controllers/transactions/shift_sales_controller.rb index e6565324..db41b03a 100644 --- a/app/controllers/transactions/shift_sales_controller.rb +++ b/app/controllers/transactions/shift_sales_controller.rb @@ -11,10 +11,10 @@ class Transactions::ShiftSalesController < ApplicationController to = params[:to] if filter.nil? && from.nil? && to.nil? - @shift_sales = ShiftSale.where("shop_code='#{@shop.shop_code}'").order("id desc") + @shift_sales = ShiftSale.order("id desc") @shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20) else - shift_sale = ShiftSale.search(filter,from,to).where("shift_sales.shop_code='#{@shop.shop_code}'") + shift_sale = ShiftSale.search(filter,from,to) if shift_sale.count > 0 @shift_sales = shift_sale @shift_sales = Kaminari.paginate_array(@shift_sales).page(params[:page]).per(20) diff --git a/app/controllers/transactions/surveys_controller.rb b/app/controllers/transactions/surveys_controller.rb index 6f90c040..90fe841f 100644 --- a/app/controllers/transactions/surveys_controller.rb +++ b/app/controllers/transactions/surveys_controller.rb @@ -6,9 +6,9 @@ class Transactions::SurveysController < ApplicationController to = params[:to] if filter.nil? && from.nil? && to.nil? - @surveys = Survey.where("shop_code='#{@shop.shop_code}'") + @surveys = Survey.all else - @surveys = Survey.search(filter,from,to).where("shop_code='#{@shop.shop_code}'") + @surveys = Survey.search(filter,from,to) end @filter = filter diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index 80a0ff69..8717222e 100755 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -54,7 +54,7 @@ class DiningFacility < ApplicationRecord def get_checkout_booking booking = self.current_reserved_booking if booking - lookup_checkout_time = Lookup.where("shop_code='#{self.shop_code}'").collection_of("checkout_alert_time") + lookup_checkout_time = Lookup.collection_of("checkout_alert_time") free_time_min = 0 if !lookup_checkout_time.empty? now = Time.now.utc @@ -95,7 +95,7 @@ class DiningFacility < ApplicationRecord bookings = self.current_checkin_booking arr_booking = Array.new if bookings - lookup_checkout_time = Lookup.where("shop_code='#{self.shop_code}'").collection_of("checkout_alert_time") + lookup_checkout_time = Lookup.collection_of("checkout_alert_time") free_time_min = 0 if !lookup_checkout_time.empty? now = Time.now.utc diff --git a/app/models/inventory_definition.rb b/app/models/inventory_definition.rb index 90f21c9b..6be91da4 100755 --- a/app/models/inventory_definition.rb +++ b/app/models/inventory_definition.rb @@ -25,8 +25,8 @@ class InventoryDefinition < ApplicationRecord def self.find_product_in_inventory(item) - if product = InventoryDefinition.find_by_item_code_and_shop_code(item.item_instance_code,Shop.current_shop.shop_code) - if stock_check_item = StockCheckItem.find_by_item_code_and_shop_code(item.item_instance_code,Shop.current_shop.shop_code) + if product = InventoryDefinition.find_by_item_code(item.item_instance_code) + if stock_check_item = StockCheckItem.find_by_item_code(item.item_instance_code) return true, product end end @@ -34,7 +34,7 @@ class InventoryDefinition < ApplicationRecord def self.check_balance(item, inventory_definition) # item => saleItemOBj - stock = StockJournal.where("shop_code='#{inventory_definition.shop_code}' and item_code=?", item.item_instance_code).order("id DESC").first + stock = StockJournal.where("item_code=?", item.item_instance_code).order("id DESC").first unless stock.nil? modify_balance(item, stock, inventory_definition) else @@ -99,7 +99,7 @@ class InventoryDefinition < ApplicationRecord " JOIN menu_items mi ON mi.id = mii.menu_item_id" + " JOIN menu_categories mc ON mc.id = mi.menu_category_id ") .joins(" JOIN accounts acc ON acc.id = mi.account_id") - .where("inventory_definitions.shop_code='#{shop.shop_code}' and (inventory_definitions.item_code LIKE ? OR inventory_definitions.min_order_level LIKE ? + .where("(inventory_definitions.item_code LIKE ? OR inventory_definitions.min_order_level LIKE ? OR inventory_definitions.max_stock_level LIKE ? OR sj.balance LIKE ? OR mi.name LIKE ? OR mii.item_instance_name LIKE ? OR mc.name LIKE ?)","%#{filter}%","%#{filter}%","%#{filter}%", "%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%") diff --git a/app/models/lookup.rb b/app/models/lookup.rb index 97c8e9d5..323bf664 100755 --- a/app/models/lookup.rb +++ b/app/models/lookup.rb @@ -86,7 +86,7 @@ class Lookup < ApplicationRecord end def self.save_shift_sale_items_settings(val,shop_code) - @lookup = Lookup.where("shop_code='#{shop_code}' and lookup_type=?", 'shift_sale_items').last + @lookup = Lookup.where("lookup_type=?", 'shift_sale_items').last if @lookup.nil? @lookup = Lookup.create_shift_sale_lookup(shop_code) end @@ -95,7 +95,7 @@ class Lookup < ApplicationRecord end def self.shift_sale_items_lookup_value(shop_code) - @lookup = Lookup.where("shop_code='#{shop_code}' and lookup_type=?", 'shift_sale_items').last + @lookup = Lookup.where("lookup_type=?", 'shift_sale_items').last if @lookup.nil? @lookup = Lookup.create_shift_sale_lookup(shop_code) end diff --git a/app/models/order.rb b/app/models/order.rb index 30f311ab..00a7aae7 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -212,7 +212,7 @@ class Order < ApplicationRecord def self.pay_process_order_queue(id,table_id) # if ENV["SERVER_MODE"] != 'cloud' order = Order.find(id) - sidekiq = Lookup.find_by_lookup_type_and_shop_code("sidekiq",order.shop_code) + sidekiq = Lookup.find_by_lookup_type("sidekiq") if !sidekiq.nil? OrderQueueProcessorJob.perform_later(id, table_id) else diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index 670dfa31..682737b1 100755 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -153,23 +153,36 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # Query for OQS with status def print_query(type, id) - query = OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name") - .joins("left join orders ON orders.order_id = order_items.order_id") - .joins("left join booking_orders AS bo ON bo.order_id=order_items.order_id") - .joins("left join bookings AS b ON b.booking_id = bo.booking_id") - .joins("left join dining_facilities AS df ON df.id = b.dining_facility_id") - .joins("left join customers as cus ON cus.customer_id = orders.customer_id") - .joins("left join menu_items as item ON item.item_code = order_items.item_code") - if type == "order_item" - query.where("order_items.order_items_id = ?", id) - .group("order_items.item_code") + OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name") + .joins("left join orders ON orders.order_id = order_items.order_id + left join booking_orders AS bo ON bo.order_id=order_items.order_id + left join bookings AS b ON b.booking_id = bo.booking_id + left join dining_facilities AS df ON df.id = b.dining_facility_id + left join customers as cus ON cus.customer_id = orders.customer_id + left join menu_items as item ON item.item_code = order_items.item_code") + .where("order_items.order_items_id = '#{ id }'") + .group("order_items.item_code") elsif type == "order_summary" - query.where("orders.order_id = ?", id) - .group("order_items.order_items_id") + OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name") + .joins("left join orders ON orders.order_id = order_items.order_id + left join booking_orders AS bo ON bo.order_id=order_items.order_id + left join bookings AS b ON b.booking_id = bo.booking_id + left join dining_facilities AS df ON df.id = b.dining_facility_id + left join customers as cus ON cus.customer_id = orders.customer_id + left join menu_items as item ON item.item_code = order_items.item_code") + .where("orders.order_id = '#{ id }'") + .group("order_items.order_items_id") else - # order summary for booking - query.where("b.booking_id = ?", id) + # order summary for booking + OrderItem.select("orders.source,cus.contact_no,order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, order_items.set_menu_items, cus.name as customer, df.type, df.name as dining, item.alt_name as alt_name") + .joins("left join orders ON orders.order_id = order_items.order_id + left join booking_orders AS bo ON bo.order_id=order_items.order_id + left join bookings AS b ON b.booking_id = bo.booking_id + left join dining_facilities AS df ON df.id = b.dining_facility_id + left join customers as cus ON cus.customer_id = orders.customer_id + left join menu_items as item ON item.item_code = order_items.item_code") + .where("b.booking_id = '#{ id }'") end end diff --git a/app/models/printer/printer_worker.rb b/app/models/printer/printer_worker.rb index d30af42d..5d7cce22 100755 --- a/app/models/printer/printer_worker.rb +++ b/app/models/printer/printer_worker.rb @@ -42,17 +42,17 @@ class Printer::PrinterWorker end def print(file_path, printer_destination = nil ) - if printer_destination.nil? - printer_destination = self.printer_destination - end + # if printer_destination.nil? + # printer_destination = self.printer_destination + # end - copy = self.print_copies - #Print only when printer information is not null - if !self.printer_destination.nil? - (1..copy).each do - page = Cups::PrintJob.new(file_path, printer_destination) - page.print - end - end + # copy = self.print_copies + # #Print only when printer information is not null + # if !self.printer_destination.nil? + # (1..copy).each do + # page = Cups::PrintJob.new(file_path, printer_destination) + # page.print + # end + # end end end diff --git a/app/models/product_commission.rb b/app/models/product_commission.rb index 7ab094af..b017df1e 100755 --- a/app/models/product_commission.rb +++ b/app/models/product_commission.rb @@ -35,7 +35,7 @@ class ProductCommission < ApplicationRecord def self.edit_product_commission(saleItemObj,shop_code) menu_item = MenuItem.find_by_item_code(saleItemObj.product_code) - commission = Commission.where("shop_code='#{shop_code}' and product_code = ? AND is_active = ?", menu_item.id, true).take + commission = Commission.where("product_code = ? AND is_active = ?", menu_item.id, true).take product_commission = ProductCommission.where('sale_item_id = ?', saleItemObj.id).take if !product_commission.nil? diff --git a/app/models/sale.rb b/app/models/sale.rb index f8155b5d..2788f449 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -849,9 +849,9 @@ end def self.get_by_shiftsales(from,to,shift,shop_code) if !shift.blank? - query = ShiftSale.where("shift_sales.id =? and shop_code='#{shop_code}'",shift.id) + query = ShiftSale.where("shift_sales.id =?",shift.id) else - query = ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? ) and shop_code='#{shop_code}'", from, to, from, to) + query = ShiftSale.where("(shift_started_at between ? and ? OR shift_closed_at between ? and ? )", from, to, from, to) end shift_sale_data = Hash.new @@ -1127,13 +1127,13 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account # end product = product.where("sales.shift_sale_id IN (?) and sale_status='completed'",shift_sale_range.to_a) discount_query = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:total_discount) - change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed) + change_amount = Sale.where("sales.shift_sale_id IN (?) and sale_status ='completed'", shift_sale_range.to_a).sum(:amount_changed) sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") - .where("sales.shop_code='#{shop_code}' and sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a) + .where("sales.shift_sale_id in (?) and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift_sale_range.to_a) sale_cash.each do |s_c| total_cash_amount += s_c.cash_amount.to_f total_card_amount += s_c.card_amount.to_f @@ -1144,20 +1144,20 @@ def self.get_staff_meal_items(shift_sale_range, shift, from, to, status, account total_grand_total = total_cash_amount.to_f + total_card_amount.to_f + total_credit_amount.to_f else - query = query.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",from,to) + query = query.where("sales.receipt_date between ? and ? #{account_type} and sale_status='completed' and sales.customer_id IN(#{customer_id})",from,to) # if type.nil? || type == 'all' || type == "other" # other_charges = other_charges.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to) # end - product = product.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status='completed'",from,to) + product = product.where("sales.receipt_date between ? and ? and sale_status='completed'",from,to) - discount_query = Sale.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount) - change_amount = Sale.where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed) + discount_query = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:total_discount) + change_amount = Sale.where("sales.receipt_date between ? and ? and sale_status ='completed'", from,to).sum(:amount_changed) sale_cash = Sale.select("SUM(case when (sale_payments.payment_method = 'mpu' or sale_payments.payment_method = 'visa' or sale_payments.payment_method = 'master' or sale_payments.payment_method = 'jcb' or sale_payments.payment_method = 'paypar' or sale_payments.payment_method = 'unionpay' or sale_payments.payment_method = 'alipay' or sale_payments.payment_method = 'paymal' or sale_payments.payment_method = 'dinga' or sale_payments.payment_method = 'JunctionPay' or sale_payments.payment_method = 'giftvoucher') then (sale_payments.payment_amount) else 0 end) as card_amount, SUM(case when (sale_payments.payment_method='cash') then (sale_payments.payment_amount) else 0 end) as cash_amount, SUM(case when (sale_payments.payment_method='creditnote') then (sale_payments.payment_amount) else 0 end) as credit_amount, SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount") .joins("join sale_payments on sale_payments.sale_id = sales.sale_id") - .where("sales.shop_code='#{shop_code}' and sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to) + .where("sales.receipt_date between ? and ? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", from,to) sale_cash.each do |s_c| total_cash_amount += s_c.cash_amount.to_f total_card_amount += s_c.card_amount.to_f @@ -1263,8 +1263,7 @@ def self.get_by_shift_sale_credit_payment(shift_sale_range,shift,from,to,filter, CONCAT(DATE_FORMAT(CONVERT_TZ(shift_sales.shift_started_at,'+00:00','+06:30'),'%d %b %y %h:%i%p'),' - ',DATE_FORMAT(CONVERT_TZ(shift_sales.shift_closed_at,'+00:00','+06:30'),'%d %b %y %h:%i%p')) as credit_payment_shift_name") .joins(:sale_audit) .joins(:sale => :shift_sale) - .joins(:sale => :cashier) - .where("sales.shop_code='#{shop_code}'").to_sql + .joins(:sale => :cashier).to_sql credits = SalePayment.select(" sale_payments.sale_payment_id, @@ -1315,7 +1314,6 @@ end sale_arr = Array.new query = Sale.select("sales.receipt_no,sales.receipt_date, sales.payment_status, sales.sale_status,sales.total_amount,sales.grand_total, sales.rounding_adjustment") - .where("sales.shop_code='#{shop_code}'") # .joins("INNER JOIN shift_sales sh ON sh.id = sales.shift_sale_id") # .where("sales.sale_status = 'void' and (sh.shift_started_at between ? and ? # OR sh.shift_closed_at between ? and ? )", from ,to, from, to) @@ -1488,7 +1486,7 @@ end def self.top_bottom_products(current_user,from,to,type,current_shop) query = Sale.joins("JOIN sale_items ON sale_items.sale_id = sales.sale_id") .completed - .where("qty > 0 AND price > 0 AND shop_code='#{current_shop.shop_code}'") + .where("qty > 0 AND price > 0") .group("SUBSTRING_INDEX(product_name, ' - ', 1)") if !from.nil? && !to.nil? @@ -1600,7 +1598,7 @@ end query = SalePayment.credits .joins(:sale) .joins("LEFT JOIN (#{payments_for_credits}) payments_for_credits ON payments_for_credits.sale_id = sale_payments.sale_id") - .where("sale_payments.payment_method= ? AND sales.sale_status = ? AND sales.shop_code=?", 'creditnote', 'completed',current_shop.shop_code) + .where("sale_payments.payment_method= ? AND sales.sale_status = ?", 'creditnote', 'completed') if (!from.nil? && !to.nil?) query = query.merge(Sale.receipt_date_between(from, to)) @@ -1818,7 +1816,6 @@ end query = Sale.select("count(distinct sale_orders.order_id) as total_order") .joins(:sale_orders) - .where("shop_code='#{current_shop.shop_code}'") .completed if (!from.nil? && !to.nil?) @@ -2357,8 +2354,8 @@ def self.get_check_sale_data(transaction_date) .group("sales.receipt_no,sales.sale_status") end def paymal_payment_void - membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",self.shop_code) - membership_actions_data = MembershipAction.find_by_membership_type_and_shop_code("void",self.shop_code) + membership_setting = MembershipSetting.find_by_membership_type("paypar_url") + membership_actions_data = MembershipAction.find_by_membership_type("void") if !membership_actions_data.nil? sale_payments =self.sale_payments.where("payment_reference is not null") if !sale_payments.empty? diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 9e23c84d..2ee26003 100755 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -36,7 +36,7 @@ class SalePayment < ApplicationRecord def self.get_kbz_pay_amount(sale_id, current_user,shop) amount = 0 - kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY,:shop_code => shop.shop_code).last + kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last sale_payment = SalePayment.where('sale_id=? and payment_method=? and payment_status!=?', sale_id, KbzPay::KBZ_PAY, 'dead').last if !sale_payment.nil? and !kbz_pay_method.nil? if sale_payment.payment_status == 'pending' @@ -295,7 +295,7 @@ class SalePayment < ApplicationRecord def self.create_payment(paypar_url,payment_type,membership_id,received_amount,sale_id) # membership_actions_data = MembershipAction.find_by_membership_type("create_payment"); sale_data = Sale.find_by_sale_id(sale_id) - membership_actions_data = PaymentMethodSetting.find_by_payment_method_and_shop_code(payment_type,sale_data.shop_code) + membership_actions_data = PaymentMethodSetting.find_by_payment_method(payment_type) customer_data = Customer.find_by_customer_id(sale_data.customer_id) if !membership_actions_data.nil? @@ -530,7 +530,7 @@ class SalePayment < ApplicationRecord #Next time - validate if the vochure number is valid - within account_no = self.payment_reference # self.sale.customer.update_attributes(paypar_account_no: ) - membership_setting = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",self.sale.shop_code) + membership_setting = MembershipSetting.find_by_membership_type("paypar_url") membership_data = SalePayment.create_payment(membership_setting.gateway_url,"PAYMAL",account_no,self.received_amount,self.sale.sale_id) #record an payment in sale-audit @@ -783,8 +783,8 @@ class SalePayment < ApplicationRecord overall_dis = sObj.total_discount if credit != 1 - membership = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",sObj.shop_code) - memberaction = MembershipAction.find_by_membership_type_and_shop_code("get_member_campaign",sObj.shop_code) + membership = MembershipSetting.find_by_membership_type("paypar_url") + memberaction = MembershipAction.find_by_membership_type("get_member_campaign") merchant_uid = memberaction.merchant_account_id.to_s campaign_type_id = memberaction.additional_parameter["campaign_type_id"] auth_token = memberaction.auth_token.to_s @@ -868,8 +868,8 @@ class SalePayment < ApplicationRecord if total_amount >= 0 receipt_no = sObj.receipt_no - membership = MembershipSetting.find_by_membership_type_and_shop_code("paypar_url",sObj.shop_code) - memberaction = MembershipAction.find_by_membership_type_and_shop_code("rebate",sObj.shop_code) + membership = MembershipSetting.find_by_membership_type("paypar_url") + memberaction = MembershipAction.find_by_membership_type("rebate") merchant_uid = memberaction.merchant_account_id.to_s campaign_type_id = memberaction.additional_parameter["campaign_type_id"] auth_token = memberaction.auth_token.to_s diff --git a/app/models/sale_tax.rb b/app/models/sale_tax.rb index ac981d1e..801c3bf7 100755 --- a/app/models/sale_tax.rb +++ b/app/models/sale_tax.rb @@ -31,7 +31,7 @@ class SaleTax < ApplicationRecord def self.get_tax(from,to) query = SaleTax.select("sale_taxes.tax_name,SUM(sale_taxes.tax_payable_amount) as tax_amount") .joins("join sales on sales.sale_id = sale_taxes.sale_id") - .where("sales.shop_code=? and sale_status = ? AND sales.receipt_date between ? and ? AND total_amount != 0 AND inclusive = 0",Shop.current_shop.shop_code, 'completed', from, to) + .where("sale_status = ? AND sales.receipt_date between ? and ? AND total_amount != 0 AND inclusive = 0", 'completed', from, to) .group("sale_taxes.tax_name") end diff --git a/app/models/shift_sale.rb b/app/models/shift_sale.rb index 4f929d62..9717f9e5 100755 --- a/app/models/shift_sale.rb +++ b/app/models/shift_sale.rb @@ -28,7 +28,7 @@ class ShiftSale < ApplicationRecord #find open shift where is open today and is not closed and login by current cashier #DATE(shift_started_at)=? and today_date = DateTime.now.strftime("%Y-%m-%d") - shift = ShiftSale.where("shop_code='#{current_user.shop_code}' and shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user.id}").take + shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user.id}").take return shift #end end diff --git a/app/models/stock_check_item.rb b/app/models/stock_check_item.rb index 18d90156..9cab250e 100755 --- a/app/models/stock_check_item.rb +++ b/app/models/stock_check_item.rb @@ -68,6 +68,6 @@ class StockCheckItem < ApplicationRecord end def self.delete_stock_check_item(item_code,shop) - self.where("item_code=? and shop_code='#{shop.shop_code}'", item_code).delete_all + self.where("item_code=?", item_code).delete_all end end diff --git a/app/models/stock_journal.rb b/app/models/stock_journal.rb index 2250b23a..f84c6204 100755 --- a/app/models/stock_journal.rb +++ b/app/models/stock_journal.rb @@ -36,7 +36,7 @@ class StockJournal < ApplicationRecord end def self.from_stock_check(item,shop) - stock_journal = StockJournal.where("shop_code='#{shop.shop_code}' and item_code=?", item.item_code).order("id DESC").first + stock_journal = StockJournal.where("item_code=?", item.item_code).order("id DESC").first if stock_journal.nil? old_blance = 0 inventory_definition_id = InventoryDefinition.find_by_item_code_and_shop_code(item.item_code,shop.shop_code).id @@ -79,7 +79,7 @@ class StockJournal < ApplicationRecord end def self.delete_stock_journal(item_code,shop) - self.where("item_code=? and shop_code='#{shop.shop_code}'", item_code).delete_all + self.where("item_code=?", item_code).delete_all end end diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index bcb96241..b07699a1 100755 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -31,7 +31,7 @@ class OrderSummaryPdf < Prawn::Document end # font "public/fonts/Zawgyi-One.ttf" - # font "public/fonts/padauk.ttf" + # font "public/fonts/padauk.ttf"z if order[0].source =='app' text "Mobile Order", :size => self.header_font_size,:align => :left move_down 1 diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 423e7bf8..aba19030 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -5,7 +5,7 @@ class ReceiptBillPdf < Prawn::Document attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width, :description_width, :price_num_width, :line_move - def initialize(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_account, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,other_charges_amount,latest_order_no,card_balance_amount,transaction_ref) + def initialize(printer_settings, kbz_pay_status, qr_code, sale_items, sale_data, customer_account, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil, shop_details, printed_status, current_balance, card_data, other_charges_amount, latest_order_no, card_balance_amount, transaction_ref) self.page_width = printer_settings.page_width self.page_height = printer_settings.page_height self.header_font_size = printer_settings.header_font_size.to_i @@ -72,6 +72,8 @@ class ReceiptBillPdf < Prawn::Document else customer(customer_account,nil) end + puts "Card data = >" +card_data + puts "Printed =>" + printed_status #start card sale trans data if card_data != nil card_sale_data(card_data) diff --git a/app/views/crm/customers/_new_form.html.erb b/app/views/crm/customers/_new_form.html.erb index e401aef6..e2916605 100644 --- a/app/views/crm/customers/_new_form.html.erb +++ b/app/views/crm/customers/_new_form.html.erb @@ -308,6 +308,8 @@ $("#type").val("card"); } } + $("#sxModal").hide(); + //$("#filter_form").submit(); } } diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 815335f2..52ef29c4 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -175,8 +175,6 @@ $("#sxModal").show(); setTimeout(function(){ getCardNo(); - $("#sxModal").hide(); - $("#filter_form").submit(); },100); }); diff --git a/app/views/foodcourt/customers/index.html.erb b/app/views/foodcourt/customers/index.html.erb index 82d72d07..b57c8786 100644 --- a/app/views/foodcourt/customers/index.html.erb +++ b/app/views/foodcourt/customers/index.html.erb @@ -375,7 +375,6 @@ $("#sxModal").show(); setTimeout(function(){ getCardNo(); - $("#sxModal").hide(); },100); } }); @@ -395,7 +394,6 @@ $("#sxModal").show(); setTimeout(function(){ getCardNo(); - $("#sxModal").hide(); customer_mamber_card_no = $("#search").val(); if(sale_id != 0 && customer_mamber_card_no != 0){ @@ -497,6 +495,7 @@ $("#type").val("card"); } } + $("#sxModal").hide(); } } diff --git a/app/views/foodcourt/paymal/index.html.erb b/app/views/foodcourt/paymal/index.html.erb index 17d99db0..f2a7191c 100644 --- a/app/views/foodcourt/paymal/index.html.erb +++ b/app/views/foodcourt/paymal/index.html.erb @@ -248,19 +248,29 @@ // Read Card Reader $(".btn_member").on('click', function(){ - var cardNo = ""; - var sale_id = $("#sale_id").text() || 0; - var receipt_no = $("#receipt_no").val() || ""; - - var customer_mamber_card_no = 0; - var payment_amount = parseFloat($("#used_amount").text()); - $("#is_paymemberModal").hide(); $("#sxModal").show(); setTimeout(function(){ getCardNo(); - $("#sxModal").hide(); - customer_mamber_card_no = $("#paypar_account_no").val(); + },100); + }); + + // Read NFC card no from java + function getCardNo(){ + code2lab.readNFC(); + } + + // get CardNo from Java + function setCardNo(cardNo){ + var sale_id = $("#sale_id").text() || 0; + var receipt_no = $("#receipt_no").val() || ""; + + var customer_mamber_card_no = 0; + var payment_amount = parseFloat($("#used_amount").text()); + + if(cardNo.length == 16){ + $("#paypar_account_no").val(cardNo); + customer_mamber_card_no = $("#paypar_account_no").val(); if (customer_mamber_card_no == 0) { customer_mamber_card_no = $("#membership_id").text() || 0; } @@ -316,18 +326,7 @@ }else{ swal("Opp","Please Check Member","warning") } - },100); - }); - - // Read NFC card no from java - function getCardNo(){ - code2lab.readNFC(); - } - - // get CardNo from Java - function setCardNo(cardNo){ - if(cardNo.length == 16){ - $("#paypar_account_no").val(cardNo); + $("#sxModal").hide(); } } diff --git a/app/views/foodcourt/payments/show.html.erb b/app/views/foodcourt/payments/show.html.erb index 6ed489a9..691e7ec8 100755 --- a/app/views/foodcourt/payments/show.html.erb +++ b/app/views/foodcourt/payments/show.html.erb @@ -1150,43 +1150,172 @@ $(document).ready(function(){ // Read Card Reader $(".btn_member").on('click', function(){ - var cardNo = ""; + $("#is_memberModal").hide(); + $("#sxModal").attr('data-for', 'member'); + $("#sxModal").show(); + setTimeout(function(){ + getCardNo(); + },100); + }); + + function pay_with_card(cardNo) { + var sale_id = $("#sale_id").text() || 0; + var receipt_no = ""; + if(($("#receipt_no").html() != undefined) && ($("#receipt_no").html()!="")){ + receipt_no = ($("#receipt_no").html()).trim(); + } + + var customer_mamber_card_no = 0; + var payment_amount = parseFloat($("#grand_total").text()); + + + $("#sxModal").hide(); + customer_mamber_card_no = $("#paypar_account_no").val(); + if (customer_mamber_card_no == 0) { + customer_mamber_card_no = $("#membership_id").text() || 0; + } + if(sale_id != 0 && customer_mamber_card_no !=0){ + $("#loading_wrapper").show(); + $.ajax({ + type: "POST", + url: "/foodcourt/"+sale_id+"/send_account" , + data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no}, + dataType: "json", + success: function(data) { + $("#loading_wrapper").hide(); + if (data.status == true) { + var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount); + // $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0); + $.ajax({ + type: "POST", + url: "<%=foodcourt_payment_paymal_path%>", + data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:customer_mamber_card_no}, + success: function(result){ + if(result.status == true){ + swal({ + title: "Information!", + text: result.message, + type: 'success', + html: true, + closeOnConfirm: true, + closeOnCancel: false, + allowOutsideClick: false + }, function (isConfirm) { + $('.confirm').attr("disabled","disabled"); + sub_total = $('#sub-total').text(); + member = $('#membership_id').text(); + + $( "#loading_wrapper").show(); + var sale_id = $('#sale_id').text(); + // var item_row = $('.is_card'); + + // payment + var cash = $('#cash').text(); + var credit = $('#credit').text(); + var card = $('#card').text(); + var kbz_amt = "<%= @kbz_pay_amount %>"; + var is_kbz = false; + if (kbz_amt > 0) { + is_kbz = true + } + + var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all'; + calculate_member_discount(sale_id,tax_type); + /* check credit payment or not*/ + var url = "<%= foodcourt_payment_cash_path %>"; + $.ajax({type: "POST", + url: url, + data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type + "&is_kbz=" + is_kbz+"&account_no="+customer_mamber_card_no, + success:function(result){ + /* start delete receipt no in first bill*/ + if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){ + var receipt_no = ($("#receipt_no").html()).trim(); + deleteReceiptNoInFirstBillData(receipt_no); + } + /* end delete receipt no in first bill*/ + localStorage.removeItem("cash"); + window.location.href = "<%= foodcourt_food_court_path %>"; + } + }); + var second_display_lookup = $("#display_type").val(); + if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){ + customer_display_view(null,"reload"); + } + }); + + }else{ + swal({ + title: 'Oops', + text: result.message, + type: 'warning', + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment"; + }); + } + } + }); + }else{ + swal({ + title: 'Oops', + text: data.message, + type: 'error', + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment"; + }); + } + } + }); + }else{ + swal({ + title: 'Oops', + text: 'Please Check Member', + type: 'warning', + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment"; + }); + } + } + + function member_card(cardNo) { var customer_id = ''; var customer_name = ''; var membership_id = ''; var membership_type = ''; var sale_id = $("#sale_id").text() || 0; - var customer_mamber_card_no = 0; - - $("#is_memberModal").hide(); - $("#sxModal").show(); - setTimeout(function(){ - getCardNo(); - $("#sxModal").hide(); - customer_mamber_card_no = $("#paypar_account_no").val(); - - if(sale_id != 0 && customer_mamber_card_no != 0){ - $.ajax({ - type: "POST", - url: "/foodcourt/"+sale_id+"/get_customer" , - data: { filter : customer_mamber_card_no ,type :"card"}, - dataType: "json", - success: function(data) { - if (data[0].customer_id == false) { - swal("Alert!", data[0].message, "error"); - }else{ - customer_id = data[0].customer_id; - customer_name = data[0].name; - membership_id = data[0].membership_id; - membership_type = data[0].membership_type; - update_sale(membership_id, customer_id, customer_name,sale_id); - } + if(sale_id != 0 && cardNo != 0){ + $.ajax({ + type: "POST", + url: "/foodcourt/"+sale_id+"/get_customer" , + data: { filter : cardNo ,type :"card"}, + dataType: "json", + success: function(data) { + if (data[0].customer_id == false) { + swal("Alert!", data[0].message, "error"); + }else{ + customer_id = data[0].customer_id; + customer_name = data[0].name; + membership_id = data[0].membership_id; + membership_type = data[0].membership_type; + update_sale(membership_id, customer_id, customer_name,sale_id); } - }); - } - },100); - }); + + } + }); + } + } // Read NFC card no from java function getCardNo(){ @@ -1197,8 +1326,15 @@ $(document).ready(function(){ // get CardNo from Java function setCardNo(cardNo){ + if(cardNo.length == 16){ $("#paypar_account_no").val(cardNo); + if ($("#sxModal").attr("data-for") == 'member') { + member_card(cardNo); + } else if ($("#sxModal").attr('data-for') == 'payment') { + pay_with_card(cardNo); + } + $("#sxModal").hide(); } } @@ -1460,138 +1596,13 @@ $(document).ready(function(){ // Read Card Reader - Paymal payment for FoodCourt $(".btn_paymal_member").on('click', function (){ - var cardNo = ""; - var sale_id = $("#sale_id").text() || 0; - var receipt_no = ""; - if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){ - receipt_no = ($("#receipt_no").html()).trim(); - } - - var customer_mamber_card_no = 0; - var payment_amount = parseFloat($("#grand_total").text()); - $("#is_paymemberModal").hide(); + $("#sxModal").attr('data-for', 'payment'); $("#sxModal").show(); - setTimeout(function(){ + var cardNo = setTimeout(function(){ getCardNo(); - $("#sxModal").hide(); - customer_mamber_card_no = $("#paypar_account_no").val(); - if (customer_mamber_card_no == 0) { - customer_mamber_card_no = $("#membership_id").text() || 0; - } - if(sale_id != 0 && customer_mamber_card_no !=0){ - $("#loading_wrapper").show(); - $.ajax({ - type: "POST", - url: "/foodcourt/"+sale_id+"/send_account" , - data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no}, - dataType: "json", - success: function(data) { - $("#loading_wrapper").hide(); - if (data.status == true) { - var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount); - // $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0); - $.ajax({ - type: "POST", - url: "<%=foodcourt_payment_paymal_path%>", - data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:customer_mamber_card_no}, - success: function(result){ - if(result.status == true){ - swal({ - title: "Information!", - text: result.message, - type: 'success', - html: true, - closeOnConfirm: true, - closeOnCancel: false, - allowOutsideClick: false - }, function (isConfirm) { - $('.confirm').attr("disabled","disabled"); - sub_total = $('#sub-total').text(); - member = $('#membership_id').text(); - - $( "#loading_wrapper").show(); - var sale_id = $('#sale_id').text(); - // var item_row = $('.is_card'); - - // payment - var cash = $('#cash').text(); - var credit = $('#credit').text(); - var card = $('#card').text(); - var kbz_amt = "<%= @kbz_pay_amount %>"; - var is_kbz = false; - if (kbz_amt > 0) { - is_kbz = true - } - - var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all'; - calculate_member_discount(sale_id,tax_type); - /* check credit payment or not*/ - var url = "<%= foodcourt_payment_cash_path %>"; - $.ajax({type: "POST", - url: url, - data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type + "&is_kbz=" + is_kbz+"&account_no="+customer_mamber_card_no, - success:function(result){ - /* start delete receipt no in first bill*/ - if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){ - var receipt_no = ($("#receipt_no").html()).trim(); - deleteReceiptNoInFirstBillData(receipt_no); - } - /* end delete receipt no in first bill*/ - localStorage.removeItem("cash"); - window.location.href = "<%= foodcourt_food_court_path %>"; - } - }); - var second_display_lookup = $("#display_type").val(); - if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){ - customer_display_view(null,"reload"); - } - }); - - }else{ - swal({ - title: 'Oops', - text: result.message, - type: 'warning', - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment"; - }); - } - } - }); - }else{ - swal({ - title: 'Oops', - text: data.message, - type: 'error', - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment"; - }); - } - } - }); - }else{ - swal({ - title: 'Oops', - text: 'Please Check Member', - type: 'warning', - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment"; - }); - } },100); + setCardNo(cardNo); }); // QR Code Reader diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index e3ed07cb..08b28ab7 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -396,7 +396,6 @@ $("#sxModal").show(); setTimeout(function(){ getCardNo(); - $("#sxModal").hide(); },100); } }); @@ -416,7 +415,6 @@ $("#sxModal").show(); setTimeout(function(){ getCardNo(); - $("#sxModal").hide(); customer_mamber_card_no = $("#search").val(); if(sale_id != 0 && customer_mamber_card_no != 0){ @@ -518,6 +516,7 @@ $("#type").val("card"); } } + $("#sxModal").hide(); } } diff --git a/app/views/origami/dinga/index.html.erb b/app/views/origami/dinga/index.html.erb index 8c326ac2..fd345d4e 100644 --- a/app/views/origami/dinga/index.html.erb +++ b/app/views/origami/dinga/index.html.erb @@ -264,8 +264,7 @@ $("#is_paymemberModal").hide(); $("#sxModal").show(); setTimeout(function(){ - getCardNo(); - $("#sxModal").hide(); + getCardNo(); customer_mamber_card_no = $("#paypar_account_no").val(); if(sale_id != 0 && customer_mamber_card_no != 0){ @@ -332,6 +331,7 @@ function setCardNo(cardNo){ if(cardNo.length == 16){ $("#paypar_account_no").val(cardNo); + $("#sxModal").hide(); } } diff --git a/app/views/origami/paymal/index.html.erb b/app/views/origami/paymal/index.html.erb index 802c1ce4..734a0924 100644 --- a/app/views/origami/paymal/index.html.erb +++ b/app/views/origami/paymal/index.html.erb @@ -258,8 +258,7 @@ $("#is_paymemberModal").hide(); $("#sxModal").show(); setTimeout(function(){ - getCardNo(); - $("#sxModal").hide(); + getCardNo(); customer_mamber_card_no = $("#paypar_account_no").val(); if (customer_mamber_card_no == 0) { customer_mamber_card_no = $("#membership_id").text() || 0; @@ -328,6 +327,7 @@ function setCardNo(cardNo){ if(cardNo.length == 16){ $("#paypar_account_no").val(cardNo); + $("#sxModal").hide(); } } diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index ca2f6ada..42152e20 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -1305,7 +1305,6 @@ $(document).ready(function(){ $("#sxModal").show(); setTimeout(function(){ getCardNo(); - $("#sxModal").hide(); customer_mamber_card_no = $("#paypar_account_no").val(); if(sale_id != 0 && customer_mamber_card_no != 0){ @@ -1342,6 +1341,7 @@ $(document).ready(function(){ function setCardNo(cardNo){ if(cardNo.length == 16){ $("#paypar_account_no").val(cardNo); + $("#sxModal").hide(); } } @@ -1707,7 +1707,6 @@ $(document).ready(function(){ $("#sxModal").show(); setTimeout(function(){ getCardNo(); - $("#sxModal").hide(); customer_mamber_card_no = $("#paypar_account_no").val(); if (customer_mamber_card_no == 0) { customer_mamber_card_no = $("#membership_id").text() || 0; diff --git a/db/migrate/20191129043601_add_is_out_of_stock_to_menu_item_instaces.rb b/db/migrate/20191129043601_add_is_out_of_stock_to_menu_item_instaces.rb index 824c0f24..c99cb0d0 100644 --- a/db/migrate/20191129043601_add_is_out_of_stock_to_menu_item_instaces.rb +++ b/db/migrate/20191129043601_add_is_out_of_stock_to_menu_item_instaces.rb @@ -1,5 +1,5 @@ -class AddIsOutOfStockToMenuItemInstaces < ActiveRecord::Migration[5.1] - def change - add_column :menu_item_instances, :is_out_of_stock, :boolean, :default => 0 - end -end +# class AddIsOutOfStockToMenuItemInstaces < ActiveRecord::Migration[5.1] +# def change +# add_column :menu_item_instances, :is_out_of_stock, :boolean, :default => 0 +# end +# end diff --git a/db/migrate/20191204091822_create_out_of_stocks.rb b/db/migrate/20191204091822_create_out_of_stocks.rb index 0563e793..82f1b2c1 100644 --- a/db/migrate/20191204091822_create_out_of_stocks.rb +++ b/db/migrate/20191204091822_create_out_of_stocks.rb @@ -1,10 +1,10 @@ -class CreateOutOfStocks < ActiveRecord::Migration[5.1] - def change - create_table :out_of_stocks do |t| - t.datetime :date - t.string :item_instance_code + class CreateOutOfStocks < ActiveRecord::Migration[5.1] +# def change +# create_table :out_of_stocks do |t| +# t.datetime :date +# t.string :item_instance_code - t.timestamps - end - end -end +# t.timestamps +# end +# end + end