diff --git a/Gemfile.lock b/Gemfile.lock index 1c7e6534..899a471a 100755 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -53,7 +53,7 @@ GEM bcrypt (3.1.11) bindex (0.5.0) builder (3.2.3) - byebug (9.1.0) + byebug (10.0.0) cancancan (1.17.0) capistrano (3.10.1) airbrussh (>= 1.0.0) @@ -66,7 +66,7 @@ GEM capistrano-rails (1.3.1) capistrano (~> 3.1) capistrano-bundler (~> 1.1) - carrierwave (1.2.1) + carrierwave (1.2.2) activemodel (>= 4.0.0) activesupport (>= 4.0.0) mime-types (>= 1.16) @@ -81,7 +81,7 @@ GEM coffee-script-source (1.12.2) concurrent-ruby (1.0.5) connection_pool (2.2.1) - crass (1.0.2) + crass (1.0.3) cups (0.1.10) database_cleaner (1.6.2) diff-lcs (1.3) @@ -92,17 +92,17 @@ GEM factory_girl_rails (4.9.0) factory_girl (~> 4.9.0) railties (>= 3.0.0) - faker (1.8.4) - i18n (~> 0.5) + faker (1.8.7) + i18n (>= 0.7) ffi (1.9.18) - filterrific (2.1.2) - font-awesome-rails (4.7.0.2) + filterrific (5.0.1) + font-awesome-rails (4.7.0.3) railties (>= 3.2, < 5.2) globalid (0.4.1) activesupport (>= 4.2.0) httparty (0.15.6) multi_xml (>= 0.5.2) - i18n (0.9.1) + i18n (0.9.3) concurrent-ruby (~> 1.0) jbuilder (2.7.0) activesupport (>= 4.2.0) @@ -142,32 +142,32 @@ GEM mini_magick (4.8.0) mini_mime (1.0.0) mini_portile2 (2.3.0) - minitest (5.10.3) + minitest (5.11.3) momentjs-rails (2.17.1) railties (>= 3.1) - multi_json (1.12.2) + multi_json (1.13.1) multi_xml (0.6.0) - mysql2 (0.4.9) + mysql2 (0.4.10) nested_form (0.3.2) net-scp (1.2.1) net-ssh (>= 2.6.5) net-ssh (4.2.0) - nio4r (2.1.0) - nokogiri (1.8.1) + nio4r (2.2.0) + nokogiri (1.8.2) mini_portile2 (~> 2.3.0) pdf-core (0.7.0) - pg (0.21.0) + pg (1.0.0) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) prawn-table (0.2.2) prawn (>= 1.3.0, < 3.0.0) - puma (3.10.0) - rack (2.0.3) + puma (3.11.2) + rack (2.0.4) rack-cors (1.0.2) rack-protection (2.0.0) rack - rack-test (0.7.0) + rack-test (0.8.2) rack (>= 1.0, < 3) rails (5.1.4) actioncable (= 5.1.4) @@ -192,12 +192,12 @@ GEM method_source rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (12.2.1) + rake (12.3.0) rb-fsevent (0.10.2) rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) redis (3.3.5) - rspec-core (3.7.0) + rspec-core (3.7.1) rspec-support (~> 3.7.0) rspec-expectations (3.7.0) diff-lcs (>= 1.2.0, < 2.0) @@ -205,7 +205,7 @@ GEM rspec-mocks (3.7.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.7.0) - rspec-rails (3.7.1) + rspec-rails (3.7.2) actionpack (>= 3.0) activesupport (>= 3.0) railties (>= 3.0) @@ -213,14 +213,14 @@ GEM rspec-expectations (~> 3.7.0) rspec-mocks (~> 3.7.0) rspec-support (~> 3.7.0) - rspec-support (3.7.0) + rspec-support (3.7.1) ruby-ole (1.2.12.1) - sass (3.5.3) + sass (3.5.5) sass-listen (~> 4.0.0) sass-listen (4.0.0) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) - sass-rails (5.0.6) + sass-rails (5.0.7) railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) @@ -238,7 +238,7 @@ GEM simple_form (3.5.0) actionpack (> 4, < 5.2) activemodel (> 4, < 5.2) - spreadsheet (1.1.4) + spreadsheet (1.1.5) ruby-ole (>= 1.0) spring (2.0.2) activesupport (>= 4.2) @@ -263,12 +263,12 @@ GEM to_xls-rails (1.3.1) spreadsheet (>= 0.8.5) ttfunk (1.5.1) - turbolinks (5.0.1) - turbolinks-source (~> 5) - turbolinks-source (5.0.3) + turbolinks (5.1.0) + turbolinks-source (~> 5.1) + turbolinks-source (5.1.0) tzinfo (1.2.4) thread_safe (~> 0.1) - uglifier (3.2.0) + uglifier (4.1.5) execjs (>= 0.3.0, < 3) web-console (3.5.1) actionview (>= 5.0) @@ -277,8 +277,8 @@ GEM railties (>= 5.0) websocket-driver (0.6.5) websocket-extensions (>= 0.1.0) - websocket-extensions (0.1.2) - whenever (0.9.7) + websocket-extensions (0.1.3) + whenever (0.10.0) chronic (>= 0.6.3) PLATFORMS diff --git a/README.md b/README.md index 97f43595..cb35bff4 100755 --- a/README.md +++ b/README.md @@ -103,6 +103,9 @@ Change type in mysql => ALTER TABLE [table_name] CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci #for table => ALTER DATABASE [database_name] CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci #for database +For split bill + 1) settings/lookups => { type:split_bill, name:SplitBill, value:1 } + ###please open sudo cat /etc/sudoers ### cope and parse diff --git a/app/assets/javascripts/origami/split_bill.coffee b/app/assets/javascripts/origami/split_bill.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/origami/split_bill.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 30d8a090..623a4618 100755 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -134,7 +134,7 @@ select.form-control { } .credit-color{ - background-color:#FF5722; + background-color:#FFA500; } .other-payment-color{ @@ -390,3 +390,9 @@ i.logout_icon{ } /* End Notify */ + +/* selected color for split bills */ +.selected-split-item { + color: #fff !important; + background-color: #5DADE2 !important; +} diff --git a/app/assets/stylesheets/origami/split_bill.scss b/app/assets/stylesheets/origami/split_bill.scss new file mode 100644 index 00000000..343bce7f --- /dev/null +++ b/app/assets/stylesheets/origami/split_bill.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the origami/split_bill controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/reset.css b/app/assets/stylesheets/reset.css index ea0aaa4f..78f23e15 100644 --- a/app/assets/stylesheets/reset.css +++ b/app/assets/stylesheets/reset.css @@ -68,6 +68,15 @@ background-color: #ccc; } +/*Shop Info color in navbar*/ +.shopinfo { + color: #212529; +} + +.link-buttoon { + text-decoration: none; +} + @media (min-width: 768px){ .dropdown-menu { padding: .3rem 0; diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 4b58e52d..19c54513 100755 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -5,7 +5,7 @@ class Api::BillController < Api::ApiController def create @status = false @error_message = "Order ID or Booking ID is require to request for a bill." - + byebug if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id) #create Bill by Booking ID table = 0 diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e66d7700..3a35a15b 100755 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -6,7 +6,7 @@ class ApplicationController < ActionController::Base # lookup domain for db from provision before_action :lookup_domain, :set_locale - helper_method :current_company,:current_login_employee,:current_user + helper_method :current_company,:current_login_employee,:current_user,:shop_detail # alias_method :current_user, :current_login_employee,:current_user #this is base api base controller to need to inherit. #all token authentication must be done here @@ -101,6 +101,10 @@ class ApplicationController < ActionController::Base end + def shop_detail + @shop = Shop.first + end + def current_login_employee if (!session[:session_token].nil?) @employee = Employee.find_by_token_session(session[:session_token]) diff --git a/app/controllers/base_origami_controller.rb b/app/controllers/base_origami_controller.rb index a43b596b..c6a302a4 100755 --- a/app/controllers/base_origami_controller.rb +++ b/app/controllers/base_origami_controller.rb @@ -19,4 +19,9 @@ class BaseOrigamiController < ActionController::Base # def checkin_process # CheckinJob.set(wait: 1.minute).perform_later() # end + + # Get current Cashier + def get_cashier + @cashier = Employee.where("role = 'cashier' AND token_session <> ''") + end end diff --git a/app/controllers/crm/bookings_controller.rb b/app/controllers/crm/bookings_controller.rb index efaa5419..30a9eb92 100755 --- a/app/controllers/crm/bookings_controller.rb +++ b/app/controllers/crm/bookings_controller.rb @@ -14,5 +14,10 @@ class Crm::BookingsController < BaseCrmController end end - + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index f917538e..12944632 100755 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -398,4 +398,10 @@ end params.require(:customer).permit(:id, :name, :company, :contact_no, :email, :date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type) end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb index 8184c660..4b1eddcc 100755 --- a/app/controllers/crm/dining_queues_controller.rb +++ b/app/controllers/crm/dining_queues_controller.rb @@ -142,4 +142,10 @@ class Crm::DiningQueuesController < BaseCrmController def dining_queue_params params.require(:dining_queue).permit(:customer_id, :name, :contact_no, :queue_no,:status,:seater,:remark) end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/crm/home_controller.rb b/app/controllers/crm/home_controller.rb index 13b4ede3..b5acf59a 100755 --- a/app/controllers/crm/home_controller.rb +++ b/app/controllers/crm/home_controller.rb @@ -55,6 +55,11 @@ class Crm::HomeController < BaseCrmController # end # end - + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/oqs/backhome_controller.rb b/app/controllers/oqs/backhome_controller.rb index 4ac5f0a2..990fa459 100755 --- a/app/controllers/oqs/backhome_controller.rb +++ b/app/controllers/oqs/backhome_controller.rb @@ -30,6 +30,12 @@ class Oqs::HomeController < BaseOqsController @queue_stations_items end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end + # Get Order items def get_order_items items = [] @@ -123,4 +129,9 @@ class Oqs::HomeController < BaseOqsController # completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true'); end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/oqs/edit_controller.rb b/app/controllers/oqs/edit_controller.rb index af37253e..f8bef2de 100755 --- a/app/controllers/oqs/edit_controller.rb +++ b/app/controllers/oqs/edit_controller.rb @@ -50,4 +50,10 @@ class Oqs::EditController < BaseOqsController order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Cancelled)", before_updated_qty ) end end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index d8642df4..371425ca 100755 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -224,7 +224,12 @@ class Oqs::HomeController < BaseOqsController .where("aoi.delivery_status = #{status} AND aoi.created_at >= '#{Time.now.beginning_of_day.utc}' ") query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",) .group("order_queue_stations.id") + end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first end end diff --git a/app/controllers/oqs/print_controller.rb b/app/controllers/oqs/print_controller.rb index 36e5d6d9..5f973c7a 100755 --- a/app/controllers/oqs/print_controller.rb +++ b/app/controllers/oqs/print_controller.rb @@ -101,4 +101,10 @@ class Oqs::PrintController < ApplicationController end end end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end \ No newline at end of file diff --git a/app/controllers/origami/addorders_controller.rb b/app/controllers/origami/addorders_controller.rb index a6e9c737..500e1ff8 100755 --- a/app/controllers/origami/addorders_controller.rb +++ b/app/controllers/origami/addorders_controller.rb @@ -185,4 +185,9 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController # @dining = DiningFacility.find(params[:id]) # end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/bank_integration_controller.rb b/app/controllers/origami/bank_integration_controller.rb index a5e5d59f..6dde10da 100644 --- a/app/controllers/origami/bank_integration_controller.rb +++ b/app/controllers/origami/bank_integration_controller.rb @@ -95,4 +95,10 @@ class Origami::BankIntegrationController < ApplicationController #BaseOrigamiCon end render json: response end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/card_payments_controller.rb b/app/controllers/origami/card_payments_controller.rb index e0c56971..cd08c16a 100755 --- a/app/controllers/origami/card_payments_controller.rb +++ b/app/controllers/origami/card_payments_controller.rb @@ -24,4 +24,9 @@ class Origami::CardPaymentsController < BaseOrigamiController def create end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/cash_ins_controller.rb b/app/controllers/origami/cash_ins_controller.rb index 36860b85..4d7c2b64 100755 --- a/app/controllers/origami/cash_ins_controller.rb +++ b/app/controllers/origami/cash_ins_controller.rb @@ -14,4 +14,10 @@ class Origami::CashInsController < BaseOrigamiController shift.cash_in = shift.cash_in + amount.to_i shift.save end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/cash_mgmt_controller.rb b/app/controllers/origami/cash_mgmt_controller.rb index aaf55c1f..1f48370e 100755 --- a/app/controllers/origami/cash_mgmt_controller.rb +++ b/app/controllers/origami/cash_mgmt_controller.rb @@ -7,4 +7,10 @@ class Origami::CashMgmtController < ApplicationController def create end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/cash_outs_controller.rb b/app/controllers/origami/cash_outs_controller.rb index 048e78b4..cc22516c 100755 --- a/app/controllers/origami/cash_outs_controller.rb +++ b/app/controllers/origami/cash_outs_controller.rb @@ -12,4 +12,10 @@ class Origami::CashOutsController < BaseOrigamiController shift.cash_out = shift.cash_out + amount.to_i shift.save end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/check_in_process_controller.rb b/app/controllers/origami/check_in_process_controller.rb index 2c5b0b38..48d55c9a 100644 --- a/app/controllers/origami/check_in_process_controller.rb +++ b/app/controllers/origami/check_in_process_controller.rb @@ -35,4 +35,10 @@ class Origami::CheckInProcessController < BaseOrigamiController format.json { render json: respond } end end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/credit_payments_controller.rb b/app/controllers/origami/credit_payments_controller.rb index d70ef870..4fd9ba71 100755 --- a/app/controllers/origami/credit_payments_controller.rb +++ b/app/controllers/origami/credit_payments_controller.rb @@ -47,4 +47,10 @@ class Origami::CreditPaymentsController < BaseOrigamiController end end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end + end diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 499f0cd4..b0056fb2 100755 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -132,5 +132,9 @@ class Origami::CustomersController < BaseOrigamiController end end - + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/discounts_controller.rb b/app/controllers/origami/discounts_controller.rb index 17c00af7..bea6e381 100755 --- a/app/controllers/origami/discounts_controller.rb +++ b/app/controllers/origami/discounts_controller.rb @@ -290,5 +290,9 @@ class Origami::DiscountsController < BaseOrigamiController # redirect_to origami_path(sale_id) # end - + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index bf4008a2..9c7ddda1 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -114,6 +114,12 @@ class Origami::HomeController < BaseOrigamiController #for bank integration @checkout_time = Lookup.collection_of('checkout_time') @checkout_alert_time = Lookup.collection_of('checkout_alert_time') + #for split bill + lookup_spit_bill = Lookup.collection_of('split_bill') + @spit_bill = 0 + if !lookup_spit_bill[0].nil? + @spit_bill = lookup_spit_bill[0][1] + end end private @@ -122,4 +128,9 @@ def set_dining @dining = DiningFacility.find(params[:dining_id]) end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/home_controller_bk.rb b/app/controllers/origami/home_controller_bk.rb index 4839f15c..3e414665 100755 --- a/app/controllers/origami/home_controller_bk.rb +++ b/app/controllers/origami/home_controller_bk.rb @@ -81,4 +81,9 @@ class Origami::HomeController < ApplicationController end end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/in_duties_controller.rb b/app/controllers/origami/in_duties_controller.rb index 5607939a..945f3bd9 100755 --- a/app/controllers/origami/in_duties_controller.rb +++ b/app/controllers/origami/in_duties_controller.rb @@ -168,4 +168,10 @@ class Origami::InDutiesController < BaseOrigamiController def in_duty_params params.require(:in_duty).permit(:id, :dinning_id, :commissioner_ids, :in_time, :out_time) end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/jcb_controller.rb b/app/controllers/origami/jcb_controller.rb index e17c773e..0604535e 100755 --- a/app/controllers/origami/jcb_controller.rb +++ b/app/controllers/origami/jcb_controller.rb @@ -58,4 +58,9 @@ class Origami::JcbController < BaseOrigamiController end end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/master_controller.rb b/app/controllers/origami/master_controller.rb index 95710f11..25bebf55 100755 --- a/app/controllers/origami/master_controller.rb +++ b/app/controllers/origami/master_controller.rb @@ -57,4 +57,9 @@ class Origami::MasterController < BaseOrigamiController end end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/moveroom_controller.rb b/app/controllers/origami/moveroom_controller.rb index 47a9fec9..5b53f68c 100755 --- a/app/controllers/origami/moveroom_controller.rb +++ b/app/controllers/origami/moveroom_controller.rb @@ -36,4 +36,10 @@ class Origami::MoveroomController < BaseOrigamiController end end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end + end diff --git a/app/controllers/origami/movetable_controller.rb b/app/controllers/origami/movetable_controller.rb index 52780381..8da417ac 100755 --- a/app/controllers/origami/movetable_controller.rb +++ b/app/controllers/origami/movetable_controller.rb @@ -70,4 +70,10 @@ class Origami::MovetableController < BaseOrigamiController @get_type = Booking.update_dining_facility(booking_array,change_to,change_from) end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/mpu_controller.rb b/app/controllers/origami/mpu_controller.rb index 6eb2a0a0..ce0dccce 100755 --- a/app/controllers/origami/mpu_controller.rb +++ b/app/controllers/origami/mpu_controller.rb @@ -57,4 +57,9 @@ class Origami::MpuController < BaseOrigamiController end end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/orders_controller.rb b/app/controllers/origami/orders_controller.rb index f4b11fc5..ea976ffd 100755 --- a/app/controllers/origami/orders_controller.rb +++ b/app/controllers/origami/orders_controller.rb @@ -39,4 +39,10 @@ class Origami::OrdersController < BaseOrigamiController end end end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/other_charges_controller.rb b/app/controllers/origami/other_charges_controller.rb index 1cc50224..7ed087d4 100755 --- a/app/controllers/origami/other_charges_controller.rb +++ b/app/controllers/origami/other_charges_controller.rb @@ -58,4 +58,10 @@ class Origami::OtherChargesController < BaseOrigamiController dining = {:table_id => table_id, :table_type => table.type } render :json => dining.to_json end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end \ No newline at end of file diff --git a/app/controllers/origami/others_payments_controller.rb b/app/controllers/origami/others_payments_controller.rb index e4a39662..ab755ea1 100755 --- a/app/controllers/origami/others_payments_controller.rb +++ b/app/controllers/origami/others_payments_controller.rb @@ -37,4 +37,9 @@ class Origami::OthersPaymentsController < BaseOrigamiController def create end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 4069edd0..8beede44 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -376,4 +376,10 @@ class Origami::PaymentsController < BaseOrigamiController end end end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end \ No newline at end of file diff --git a/app/controllers/origami/paypar_payments_controller.rb b/app/controllers/origami/paypar_payments_controller.rb index 4a4944ca..04a52f0f 100755 --- a/app/controllers/origami/paypar_payments_controller.rb +++ b/app/controllers/origami/paypar_payments_controller.rb @@ -28,4 +28,10 @@ class Origami::PayparPaymentsController < BaseOrigamiController end end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/product_commissions_controller.rb b/app/controllers/origami/product_commissions_controller.rb index 74dd8095..2ab9a618 100755 --- a/app/controllers/origami/product_commissions_controller.rb +++ b/app/controllers/origami/product_commissions_controller.rb @@ -136,4 +136,10 @@ class Origami::ProductCommissionsController < BaseOrigamiController def product_commission_params params.fetch(:product_commission, {}) end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/redeem_payments_controller.rb b/app/controllers/origami/redeem_payments_controller.rb index 4b0c70f8..76517e8a 100755 --- a/app/controllers/origami/redeem_payments_controller.rb +++ b/app/controllers/origami/redeem_payments_controller.rb @@ -68,4 +68,10 @@ class Origami::RedeemPaymentsController < BaseOrigamiController end @out = false, 0 end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index e0f1d06c..c076a820 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -55,4 +55,10 @@ class Origami::RequestBillsController < ApplicationController # printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details) end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/room_invoices_controller.rb b/app/controllers/origami/room_invoices_controller.rb index 8d805771..9c3b16a6 100755 --- a/app/controllers/origami/room_invoices_controller.rb +++ b/app/controllers/origami/room_invoices_controller.rb @@ -37,4 +37,9 @@ class Origami::RoomInvoicesController < BaseOrigamiController @customer = @sale.customer end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/rooms_controller.rb b/app/controllers/origami/rooms_controller.rb index 7ffac1f0..3902354d 100755 --- a/app/controllers/origami/rooms_controller.rb +++ b/app/controllers/origami/rooms_controller.rb @@ -117,7 +117,17 @@ class Origami::RoomsController < BaseOrigamiController # end # end # end + + lookup_spit_bill = Lookup.collection_of('split_bill') + @spit_bill = 0 + if !lookup_spit_bill[0].nil? + @spit_bill = lookup_spit_bill[0][1] + end end - + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/sale_edit_controller.rb b/app/controllers/origami/sale_edit_controller.rb index e539356a..fa40e41f 100755 --- a/app/controllers/origami/sale_edit_controller.rb +++ b/app/controllers/origami/sale_edit_controller.rb @@ -161,4 +161,10 @@ class Origami::SaleEditController < BaseOrigamiController ProductCommission.remove_product_commission(item) end end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/sales_controller.rb b/app/controllers/origami/sales_controller.rb index f64cef88..c522f9e7 100755 --- a/app/controllers/origami/sales_controller.rb +++ b/app/controllers/origami/sales_controller.rb @@ -51,5 +51,9 @@ class Origami::SalesController < BaseOrigamiController end end - + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index cb2cc830..435a98d1 100755 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -108,4 +108,9 @@ class Origami::ShiftsController < BaseOrigamiController end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb new file mode 100644 index 00000000..9a27010d --- /dev/null +++ b/app/controllers/origami/split_bill_controller.rb @@ -0,0 +1,215 @@ +class Origami::SplitBillController < BaseOrigamiController + authorize_resource :class => false + + def index + dining_id = params[:dining_id] + @table = DiningFacility.find(dining_id) + @booking = @table.get_booking + @orders = Array.new + @order_items = Array.new + @sale_data = Array.new + + table_bookings = Booking.where("dining_facility_id = #{dining_id} and sale_id IS NOT NULL") + if !table_bookings.nil? + table_bookings.each do |table_booking| + @sale_data.push(table_booking.sale) + end + end + + if @booking + @booking.booking_orders.each do |booking_order| + @order = Order.find(booking_order.order_id) + if (@order.status == "new") + @orders.push(@order) + + @order.order_items.each do |item| + if !item.set_menu_items.nil? + instance_item_sets = JSON.parse(item.set_menu_items) + arr_instance_item_sets = Array.new + instance_item_sets.each do |instance_item| + item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name + arr_instance_item_sets.push(item_instance_name) + end + item.set_menu_items = arr_instance_item_sets + end + @order_items.push(item) + end + end + end + else + @booking = nil + end + end + + def create + order_ids = params[:order_ids] + orders = nil + if !params[:orders].empty? + orders = JSON.parse(params[:orders]) + end + order_items = nil + if !params[:order_items].empty? + order_items = JSON.parse(params[:order_items]) + end + + status = false + if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id) + #create Bill by Booking ID + table = 0 + if !params[:booking_id].empty? + booking = Booking.find(params[:booking_id]) + # for Multiple Cashier by Zone + table = DiningFacility.find(booking.dining_facility_id) + + cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id) + + shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil) + get_cashier_by_terminal = Employee.find(shift_by_terminal.employee_id) + + if booking + if booking.sale_id.nil? + sale = Sale.new + status, sale_id = sale.generate_invoice_from_booking(params[:booking_id], current_user, get_cashier_by_terminal) + sale_data = Sale.find_by_sale_id(sale_id) + else + status = true + sale_id = booking.sale_id + sale_data = Sale.find_by_sale_id(sale_id) + end + end + else + if params[:type] == "Table" + type = "TableBooking" + else + type = "RoomBooking" + end + + booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type, + :checkin_at => Time.now.utc, :checkin_by => current_user.name, + :booking_status => "assign" }) + + if !orders.nil? + orders.each do |order| + BookingOrder.create({:booking_id => booking.booking_id, :order_id => order["id"]}) + end + elsif !order_items.nil? + order_item_count = 0 + order_id_count = 0 + order_id = nil + + order_items.each do |order_item| + order_item_count = 0 + order = Order.find(order_item["order_id"]) + if order.order_items.count == 1 + order_id = order.id + order_id_count += 1 + else + order_item_count += 1 + end + end + + if !order_id.nil? + if order_id_count > 1 + updated_order_id = Array.new + order_ids.each do |odr_id| + odr = Order.find(odr_id) + if odr.order_items.count > 1 + updated_order_id.push(odr_id) + end + end + + if !updated_order_id.empty? + order_ids.each do |odr_id| + unless updated_order_id.include?(odr_id) + BookingOrder.find_by_order_id(odr_id).delete + BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id}) + end + end + + order_items.each do |order_item| + if updated_order_id.include?(order_item["order_id"]) + orderItem = OrderItem.find(order_item["id"]) + orderItem.order_id = order_id + orderItem.save! + end + end + else + order_ids.each do |odr_id| + BookingOrder.find_by_order_id(odr_id).delete + BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id}) + end + end + else + BookingOrder.find_by_order_id(order_id).delete + + BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_id}) + order_items.each do |order_item| + orderItem = OrderItem.find(order_item["id"]) + orderItem.order_id = order_id + orderItem.save! + end + end + else + if order_ids.count == 1 && order_item_count == 1 + BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_ids[0]}) + else + customer = Customer.find(params[:customer_id]) + order_type = "dine_in" + if !customer.nil? + if customer.customer_type == "Takeaway" + order_type = "takeaway" + elsif customer.customer_type == "Delivery" + order_type = "delivery" + end + end + + # begin + order = Order.new + order.source = "cashier" + order.order_type = order_type + order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile + order.item_count = order_items.count + order.status = "new" + order.table_id = params[:dining_id] # this is dining facilities's id + order.waiters = current_user.name + order.employee_name = current_user.name + order.guest_info = nil + order.save! + + BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id}) + + order_items.each do |order_item| + orderItem = OrderItem.find(order_item["id"]) + orderItem.order_id = order.order_id + orderItem.save! + end + end + end + end + + sale = Sale.new + status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, get_cashier_by_terminal) + sale_data = Sale.find_by_sale_id(sale_id) + end + + # Bind shift sale id to sale + sale_data.shift_sale_id = shift_by_terminal.id + sale_data.save + + Promotion.promo_activate(sale) + + BillBroadcastJob.perform_later(table) + + render :json => { status: status } + else + render :json => { status: false, error_message: 'No Current Open Shift!'} + end + end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end + +end diff --git a/app/controllers/origami/surveys_controller.rb b/app/controllers/origami/surveys_controller.rb index cfabae01..d7f97a6e 100644 --- a/app/controllers/origami/surveys_controller.rb +++ b/app/controllers/origami/surveys_controller.rb @@ -44,4 +44,10 @@ class Origami::SurveysController < BaseOrigamiController def survey_params params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner, :dining_name,:receipt_no,:shift_id,:created_by,:total_customer,:total_amount) end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/table_invoices_controller.rb b/app/controllers/origami/table_invoices_controller.rb index 655083df..a9d5d340 100755 --- a/app/controllers/origami/table_invoices_controller.rb +++ b/app/controllers/origami/table_invoices_controller.rb @@ -61,4 +61,9 @@ class Origami::TableInvoicesController < BaseOrigamiController @customer = @sale.customer end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/unionpay_controller.rb b/app/controllers/origami/unionpay_controller.rb index 7f084fd4..89adfd3e 100644 --- a/app/controllers/origami/unionpay_controller.rb +++ b/app/controllers/origami/unionpay_controller.rb @@ -56,4 +56,10 @@ class Origami::UnionpayController < BaseOrigamiController @status, @sale = sale_payment.process_payment(saleObj, @user, cash, "unionpay") end end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/visa_controller.rb b/app/controllers/origami/visa_controller.rb index f04ec001..5404789c 100755 --- a/app/controllers/origami/visa_controller.rb +++ b/app/controllers/origami/visa_controller.rb @@ -57,4 +57,9 @@ class Origami::VisaController < BaseOrigamiController end end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/origami/void_controller.rb b/app/controllers/origami/void_controller.rb index 52b2068c..f9ad89a4 100755 --- a/app/controllers/origami/void_controller.rb +++ b/app/controllers/origami/void_controller.rb @@ -112,4 +112,10 @@ class Origami::VoidController < BaseOrigamiController end end end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end \ No newline at end of file diff --git a/app/controllers/origami/voucher_controller.rb b/app/controllers/origami/voucher_controller.rb index c4b3c840..750189df 100755 --- a/app/controllers/origami/voucher_controller.rb +++ b/app/controllers/origami/voucher_controller.rb @@ -78,4 +78,9 @@ class Origami::VoucherController < BaseOrigamiController end end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/reports/bksaleitem_controller.rb b/app/controllers/reports/bksaleitem_controller.rb index 0f91681d..118269bb 100755 --- a/app/controllers/reports/bksaleitem_controller.rb +++ b/app/controllers/reports/bksaleitem_controller.rb @@ -16,4 +16,10 @@ class Reports::SaleitemController < BaseReportController end + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end + end diff --git a/app/controllers/reports/commission_controller.rb b/app/controllers/reports/commission_controller.rb index e97a1a77..9e13bd75 100755 --- a/app/controllers/reports/commission_controller.rb +++ b/app/controllers/reports/commission_controller.rb @@ -49,5 +49,11 @@ class Reports::CommissionController < BaseReportController format.json { render json: out } end end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/reports/credit_payment_controller.rb b/app/controllers/reports/credit_payment_controller.rb index 3b716cc2..abf7a6af 100755 --- a/app/controllers/reports/credit_payment_controller.rb +++ b/app/controllers/reports/credit_payment_controller.rb @@ -59,4 +59,10 @@ authorize_resource :class => false format.json { render json: out } end end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end \ No newline at end of file diff --git a/app/controllers/reports/dailysale_controller.rb b/app/controllers/reports/dailysale_controller.rb index e2102d87..d43355fa 100755 --- a/app/controllers/reports/dailysale_controller.rb +++ b/app/controllers/reports/dailysale_controller.rb @@ -19,4 +19,10 @@ class Reports::DailysaleController < BaseReportController def show end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/reports/payment_method_controller.rb b/app/controllers/reports/payment_method_controller.rb index 01a904ae..0262594f 100644 --- a/app/controllers/reports/payment_method_controller.rb +++ b/app/controllers/reports/payment_method_controller.rb @@ -61,4 +61,10 @@ class Reports::PaymentMethodController < BaseReportController format.json { render json: out } end end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end \ No newline at end of file diff --git a/app/controllers/reports/receipt_no_controller.rb b/app/controllers/reports/receipt_no_controller.rb index faa12eae..ead85d72 100755 --- a/app/controllers/reports/receipt_no_controller.rb +++ b/app/controllers/reports/receipt_no_controller.rb @@ -61,4 +61,10 @@ authorize_resource :class => false format.json { render json: out } end end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end \ No newline at end of file diff --git a/app/controllers/reports/saleitem_controller.rb b/app/controllers/reports/saleitem_controller.rb index a9d23797..58421342 100755 --- a/app/controllers/reports/saleitem_controller.rb +++ b/app/controllers/reports/saleitem_controller.rb @@ -76,5 +76,10 @@ class Reports::SaleitemController < BaseReportController format.json { render json: out } end end - + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/reports/shiftsale_controller.rb b/app/controllers/reports/shiftsale_controller.rb index f9373374..cf722495 100755 --- a/app/controllers/reports/shiftsale_controller.rb +++ b/app/controllers/reports/shiftsale_controller.rb @@ -47,5 +47,11 @@ class Reports::ShiftsaleController < BaseReportController format.json { render json: out } end end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/reports/stock_check_controller.rb b/app/controllers/reports/stock_check_controller.rb index a9188f5d..9a033956 100755 --- a/app/controllers/reports/stock_check_controller.rb +++ b/app/controllers/reports/stock_check_controller.rb @@ -46,5 +46,11 @@ class Reports::StockCheckController < BaseReportController format.json { render json: out } end end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end diff --git a/app/controllers/reports/void_sale_controller.rb b/app/controllers/reports/void_sale_controller.rb index 6169dadc..50a7c57d 100755 --- a/app/controllers/reports/void_sale_controller.rb +++ b/app/controllers/reports/void_sale_controller.rb @@ -58,4 +58,10 @@ authorize_resource :class => false format.json { render json: out } end end + + #Shop Name in Navbor + helper_method :shop_detail + def shop_detail + @shop = Shop.first + end end \ No newline at end of file diff --git a/app/helpers/origami/split_bill_helper.rb b/app/helpers/origami/split_bill_helper.rb new file mode 100644 index 00000000..cc88e5b2 --- /dev/null +++ b/app/helpers/origami/split_bill_helper.rb @@ -0,0 +1,2 @@ +module Origami::SplitBillHelper +end diff --git a/app/models/ability.rb b/app/models/ability.rb index a72a47d2..f0091ef7 100755 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -102,7 +102,9 @@ class Ability can :menage, Booking can :manage, OrderQueueStation can :read, Sale - can :update, Sale + can :update, Sale + + can :manage, Customer can :get_customer, Customer can :add_customer, Customer can :update_sale_by_customer, Customer @@ -126,12 +128,14 @@ class Ability can :move_dining, :moveroom - can :manage, DiningQueue - can :manage, Commission can :manage, Commissioner can :manage, Promotion can :manage, Product + + #ability for split_bill + can :index, :split_bill + can :create, :split_bill elsif user.role == "account" diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 67746ba6..ec0a3c68 100755 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -25,6 +25,13 @@ + + +