diff --git a/.code2lab.env b/.code2lab.env new file mode 100644 index 00000000..0a6c7f0b --- /dev/null +++ b/.code2lab.env @@ -0,0 +1 @@ +RAILS_ENV=production diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..6be8c8f3 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,2 @@ +.git +.dockerignore diff --git a/.gitignore b/.gitignore index 4f0ac524..66f5a09c 100755 --- a/.gitignore +++ b/.gitignore @@ -24,8 +24,10 @@ capybara-*.html /public/image /public/system/* /public/assets/* +/public/menus/* /public/uploads/* /public/swf/* +/public/receipts/ /coverage/ /spec/tmp/* *.orig @@ -35,9 +37,11 @@ pickle-email-*.html /gems/* ._*.* .rbenv-version + +/config/initializers/* config/deploy/config/* config/puma.rb -config/shops.json +#config/shops.json !/log/.keep !/tmp/.keep .ruby-version diff --git a/Capfile b/Capfile new file mode 100644 index 00000000..9cfa1807 --- /dev/null +++ b/Capfile @@ -0,0 +1,31 @@ +# Load DSL and set up stages +require "capistrano/setup" + +# Include default deployment tasks +require "capistrano/deploy" + +# Include tasks from other gems included in your Gemfile +# +# For documentation on these, see for example: +# +# https://github.com/capistrano/rvm +# https://github.com/capistrano/rbenv +# https://github.com/capistrano/chruby +# https://github.com/capistrano/bundler +# https://github.com/capistrano/rails +# https://github.com/capistrano/passenger +# +# require "capistrano/rvm" +require "capistrano/rbenv" +# require "capistrano/chruby" +require "capistrano/bundler" +require "capistrano/rails" +require "capistrano/rails/assets" +require "capistrano/rails/migrations" +# require "capistrano/passenger" + +# Load custom tasks from `lib/capistrano/tasks` if you have any defined +Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r } +Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r } +Dir.glob('lib/capistrano/**/*.rb').each { |r| import r } + diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..69f0f58e --- /dev/null +++ b/Dockerfile @@ -0,0 +1,12 @@ +FROM ruby:2.4.1 +RUN apt-get update -qq && apt-get install -y build-essential libmysqlclient-dev libcups2-dev libpq-dev nodejs +RUN mkdir /sxrestaurant +RUN mkdir -p /sxrestaurant/tmp/puma +ENV RAILS_ENV production +WORKDIR /sxrestaurant +COPY Gemfile /sxrestaurant/Gemfile +COPY Gemfile.lock /sxrestaurant/Gemfile.lock +RUN bundle install --without development test +RUN bundle exec rails assets:precompile +COPY . /sxrestaurant + diff --git a/Gemfile b/Gemfile old mode 100755 new mode 100644 index de22a68c..6005cae2 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source 'https://rubygems.org' -ruby '2.4.0' +ruby '2.4.1' git_source(:github) do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") "https://github.com/#{repo_name}.git" @@ -41,14 +41,18 @@ gem 'rack-cors' # image upload gem 'carrierwave', '~> 1.0' gem 'mini_magick' +gem 'jquery-fileupload-rails' #Report and Printing gems -gem 'cups', '~> 0.0.7' +gem 'cups' gem 'prawn' gem 'prawn-table' -gem 'spreadsheet' gem 'to_xls-rails' - +gem 'rubyzip', '= 1.0.0' +gem 'axlsx', '= 2.0.1' +gem 'axlsx_rails' +gem 'roo' +gem 'pdfjs_viewer-rails' #Reporting gem #gem 'compendium' #gem "cancan" @@ -81,7 +85,6 @@ gem 'kaminari', '~> 1.0.1' gem 'filterrific' gem 'cancancan', '~> 1.10' - #pageless no need for current # gem 'will_paginate' # gem 'pageless-rails', github: 'rorlab/pageless-rails' @@ -95,6 +98,9 @@ gem 'cancancan', '~> 1.10' #end group :development do + # Call 'byebug' anywhere in the code to stop execution and get a debugger console + gem 'byebug', platform: :mri + # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. gem 'web-console', '>= 3.3.0' gem 'listen', '~> 3.0.5' @@ -126,4 +132,4 @@ gem 'momentjs-rails' # for date-range selector # gem 'bootstrap-datepicker-rails' # date picker # gem 'jquery-datetimepicker-rails' # gem 'select2-rails' # for multi-select and auto-complete select box -gem "chartkick" #chart lib +gem "chartkick" #chart lib \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock old mode 100755 new mode 100644 index b7804803..b7f4b2ca --- a/Gemfile.lock +++ b/Gemfile.lock @@ -50,9 +50,17 @@ GEM airbrussh (1.3.0) sshkit (>= 1.6.1, != 1.7.0) arel (8.0.0) + axlsx (2.0.1) + htmlentities (~> 4.3.1) + nokogiri (>= 1.4.1) + rubyzip (~> 1.0.0) + axlsx_rails (0.5.1) + actionpack (>= 3.1) + axlsx (>= 2.0.1) bcrypt (3.1.11) bindex (0.5.0) builder (3.2.3) + byebug (9.1.0) cancancan (1.17.0) capistrano (3.10.1) airbrussh (>= 1.0.0) @@ -81,7 +89,7 @@ GEM concurrent-ruby (1.0.5) connection_pool (2.2.1) crass (1.0.2) - cups (0.0.7) + cups (0.1.10) database_cleaner (1.6.2) diff-lcs (1.3) erubi (1.7.0) @@ -99,6 +107,7 @@ GEM railties (>= 3.2, < 5.2) globalid (0.4.1) activesupport (>= 4.2.0) + htmlentities (4.3.4) httparty (0.15.6) multi_xml (>= 0.5.2) i18n (0.9.1) @@ -106,12 +115,17 @@ GEM jbuilder (2.7.0) activesupport (>= 4.2.0) multi_json (>= 1.2) + jquery-fileupload-rails (0.4.7) + actionpack (>= 3.1) + railties (>= 3.1) + sass (>= 3.2) jquery-rails (4.3.1) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) jquery-ui-rails (6.0.1) railties (>= 3.2.16) + json (2.1.0) kaminari (1.0.1) activesupport (>= 4.1.0) kaminari-actionview (= 1.0.1) @@ -155,6 +169,10 @@ GEM nokogiri (1.8.1) mini_portile2 (~> 2.3.0) pdf-core (0.7.0) + pdfjs_viewer-rails (0.2.0) + json (> 1.8.4) + rails (> 4.2.0) + sass-rails (~> 5.0) pg (0.21.0) prawn (2.2.2) pdf-core (~> 0.7.0) @@ -196,6 +214,10 @@ GEM rb-inotify (0.9.10) ffi (>= 0.5.0, < 2) redis (3.3.5) + roo (1.13.2) + nokogiri + rubyzip + spreadsheet (> 0.6.4) rspec-core (3.7.0) rspec-support (~> 3.7.0) rspec-expectations (3.7.0) @@ -214,6 +236,7 @@ GEM rspec-support (~> 3.7.0) rspec-support (3.7.0) ruby-ole (1.2.12.1) + rubyzip (1.0.0) sass (3.5.3) sass-listen (~> 4.0.0) sass-listen (4.0.0) @@ -285,7 +308,10 @@ PLATFORMS DEPENDENCIES aescrypt + axlsx (= 2.0.1) + axlsx_rails bcrypt (~> 3.1.7) + byebug cancancan (~> 1.10) capistrano capistrano-bundler @@ -294,7 +320,7 @@ DEPENDENCIES carrierwave (~> 1.0) chartkick coffee-rails (~> 4.2) - cups (~> 0.0.7) + cups database_cleaner factory_girl_rails (~> 4.0) faker @@ -302,6 +328,7 @@ DEPENDENCIES font-awesome-rails (~> 4.7, >= 4.7.0.2) httparty (~> 0.15.5) jbuilder (~> 2.5) + jquery-fileupload-rails jquery-rails jquery-ui-rails kaminari (~> 1.0.1) @@ -311,6 +338,7 @@ DEPENDENCIES momentjs-rails mysql2 (>= 0.3.18, < 0.5) nested_form + pdfjs_viewer-rails pg prawn prawn-table @@ -318,13 +346,14 @@ DEPENDENCIES rack-cors rails (~> 5.1.0) redis (~> 3.0) + roo rspec-rails (~> 3.5) + rubyzip (= 1.0.0) sass-rails (~> 5.0) schema_to_scaffold shoulda-matchers (~> 3.1) sidekiq simple_form - spreadsheet spring spring-watcher-listen (~> 2.0.0) tether-rails @@ -336,7 +365,7 @@ DEPENDENCIES whenever RUBY VERSION - ruby 2.4.0p0 + ruby 2.4.1p111 BUNDLED WITH 1.16.1 diff --git a/README.md b/README.md index 5ff1aeda..43a2091e 100755 --- a/README.md +++ b/README.md @@ -8,39 +8,194 @@ Things you may want to cover: ruby 2.4.1p111 * Membership Details +Osaka => + Auth Token => wu8YvlLmah0CL => New => v3 + => rj0MJ0XI5GsKZehE => Old => v2 + => code2lab => Old - Osaka + Merchant account => RxzaYyAGzm7VqAZ4hKnv + Campaign Id => {"campaign_type_id": 5} - Auth Token => rj0MJ0XI5GsKZehE => New +BITP + Auth Token => pZBHXEFbGNj/G => New => V3 + => rj0MJ0XI5GsKZehE => Old => V2 + => code2lab => Old - => code2lab => Old - - Merchant account => RxzaYyAGzm7VqAZ4hKnv - - Campaign Id => {"campaign_type_id": 5} - - - - BITP - - Auth Token => rj0MJ0XI5GsKZehE => New - - => code2lab => Old - - Merchant account => vWSsseoZCzxd6xcNf_uS - - Campaign Id => {"campaign_type_id": 1} + Merchant account => vWSsseoZCzxd6xcNf_uS + Campaign Id => {"campaign_type_id": 1} java -jar ~/Documents/Jade.jar http://192.168.1.88:3002 +java -jar ~/Documents/c2l_jade.jar http://192.168.1.151:3002 + +Person and Extra Time + category_code = SPL... //for menu categories special + 1) must create Person in settings/accounts + 2) must create Adult and Child in settings/item_attributes + 3) must be PSA_[a-z/0-9] for Adult and PSC_[a-z/0-9] for Child in settings/menu_categories/[cat_id]/simple_menu_items + 3) must be PSAI_[a-z/0-9] for Adult and PSCI_[a-z/0-9] for Child in settings/simple_menu_items/[item_id]/menu_item_instances + +For Extra Time + item_instance_code + * must start with 'Ext'[a..z]'_'[1..100] + * note : don't add character after '_' + +For Order Item & Order Summary Slim + *** change OrderItemPdf to OrderItemSlimPdf and OrderSummaryPdf to OrderSummarySlimPdf + 1) settings/print_settings + (a) Font is present => {Header font size:11, Item Font Size:9} + (b) Font is blank => {Header font size:12, Item Font Size:10} + 2) settings/lookups => { type:print_settings, name:OrderSlimPdf, value:1 } + * no need to change these files + { app/controllers/oqs/edit_controller.rb + app/controllers/oqs/print_controller.rb + app/models/order_queue_station.rb + app/models/printer/order_queue_printer.rb + app/models/printer/receipt_printer.rb + } + +For ReceiptBillA5Pdf + *** change ReceiptBillPdf to ReceiptBillA5Pdf + 1) settings/print_settings , width:680, height:1450, Header font Size:16, Item font size:14 + 2) settings/lookups => { type:print_settings, name:ReceiptBillA5Pdf, value:1 } + +For ReceiptBillAltName options + 1) settings/lookups => { type:print_settings, name:ReceiptBillAltName, value:1 } + +For OrderSetPdf options + *** change OrderItemPdf to OrderSetItemPdf and OrderSummaryPdf to OrderSummarySetPdf + 1) settings/lookups => { type:print_settings, name:OrderSetPdf, value:1 } + 2) settings/print_settings + (a) Font is present => {Header font size:11, Item Font Size:9} + (b) Font is blank => {Header font size:12, Item Font Size:10} + +For Bank Integration setting + 1) rake db:migrate for card_sale_trans, card_settle_trans + 2) settings/lookups => { type:bank_integration, name: Bank Integration, value:1 } + +For checkout time and checkout alert time + 1) checkout time => { type: checkout_time, name: 9:00 AM - 12:00 PM, value: 120 } + 2) checkout alert time => { type: checkout_alert_time, name: 8:00 AM - 12:00 PM, value: 60 } + * you can add multiple record for checkout time and checkout alert time + * type must be 'checkout_time' and 'checkout_alert_time' + * you can change name and value + * name must be time range [12hr => 8:30 AM - 1:45 PM, 24hr => 8:00 - 13:45] + * value must be minutes[60] + +For call waiter pdf + * Backend > Printer > Print Settings > New + i) Name : Calling Waiter + ii) Unique Code: CallWaiterPdf + iii)Template: ... + iv) Font: Zawgyi-One + v) Printer: #printer name + +Membership Actions SQL + * update membership_actions set additional_parameter='{\"campaign_type_id\":5}' where id=10; + +SQL Update after rake clear:data runned + * update seed_generators + i) TableBooking, Order, OrderItem, sale, SaleOrder, SaleItem, SaleTax, SalePayment, SaleAudit, AssignedOrderItem => { current:0, next:0 } + ** Note :: do not update Customer + +Change type in mysql + *run if you got font error for Myanmar, Chinese, etc... + => ALTER TABLE [table_name] CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci #for table + => ALTER DATABASE [database_name] CHARACTER SET utf8 COLLATE utf8_unicode_ci #for database + +For split bill + 1) settings/lookups => { type:split_bill, name:SplitBill, value:1 } + +For Sidekiq + 1) If you want to use sidekiq + => Create New Lookups => lookup_type = sidekiq, Name = sidekiq , Value = 1 or 0 + +For Clear Menu + 1) rake clear:menu # menu,menu item,menu category,menu item instance,account,item option,item attribute,item set + +For Check CUp status +###please open +sudo cat /etc/sudoers +### cope and parse +%superuser ALL=(ALL) NOPASSWD: ALL + +<---- Extra Fields Script -----> +DROP TABLE IF EXISTS `display_images`; +CREATE TABLE `display_images` ( + `id` bigint(20) NOT NULL AUTO_INCREMENT, + `shop_id` int(11) DEFAULT NULL, + `image` blob, + `created_by` varchar(255) DEFAULT NULL, + `created_at` datetime NOT NULL, + `updated_at` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +ALTER TABLE customers +ADD COLUMN image_path VARCHAR(255); + +ALTER TABLE employees +ADD COLUMN image_path VARCHAR(255); + +ALTER TABLE commissioners +ADD COLUMN image_path VARCHAR(255); + +ALTER TABLE sales +ADD COLUMN equal_persons INT(11) after rebate_status; + +ALTER TABLE sale_items +ADD COLUMN remark VARCHAR(255) after status; + +ALTER TABLE shops +ADD COLUMN shop_code VARCHAR(255) after name, +ADD COLUMN client_name VARCHAR(255) after shop_code, +ADD COLUMN client_code VARCHAR(255) after client_name; + +ALTER TABLE print_settings +ADD COLUMN brand_name VARCHAR(255) after api_settings, +ADD COLUMN type VARCHAR(255) after brand_name; + +ALTER TABLE tax_profiles +ADD COLUMN group_type VARCHAR(255) after name; + +<---- Extra Fields Script -----> +For CloseCashierCustomisePdf in lookups + *** change CloseCashierPdf to CloseCashierCustomisePdf + 1) settings/print_settings + 2) settings/lookups => { type:print_settings, name: CloseCashierCustomisePdf, value:1 } + +<---- Extra Fields Script -----> +For MoveTablePdf in lookups + *** Both Table and Room Moving *** + 1) settings/lookups => { type:print_settings, name: MoveTablePdf, value:1 } + +For MoveTablePdf in print settings + * Backend > Printer > Print Settings > New + i) Name : Move Table + ii) Unique Code: MoveTablePdf + iii)Template: ... + iv) Font: Zawgyi-One v) Printer: #printer name + +/* Tax Profile Group Types in lookups */ +1) settings/lookups => { type:tax_profiles, name: Cashier, value:cashier } +2) settings/lookups => { type:tax_profiles, name: Quick Service, value: quick_service } +3) settings/lookups => { type:tax_profiles, name: Doemal, value: doemal } +/* Tax Profile Group Types in lookups */ + +Add Kitchen Role of Employee + => 1) settings/lookups => { type:employee_roles, name: Kitchen, value:kitchen } + +Add Base URL for DOEMAL + 1) settings/lookups => { type:order_reservation, name: BaseURL, value:'{doemal url}' } + 2) settings/lookups => { type:order_reservation, name: Token, value:'{doemal token}' } * ToDo list -1. Cloud Sync -2. Action Cable -3. Shop Setup -4. Payment Integation +1. Migration +2. Quick Service +3. Order & Reservation + -* System dependencies +* System Dependencies * Configuration diff --git a/app/assets/images/slider/s1.jpg b/app/assets/images/slider/s1.jpg new file mode 100644 index 00000000..cf5cfb0b Binary files /dev/null and b/app/assets/images/slider/s1.jpg differ diff --git a/app/assets/images/slider/s2.jpg b/app/assets/images/slider/s2.jpg new file mode 100644 index 00000000..2e3e9332 Binary files /dev/null and b/app/assets/images/slider/s2.jpg differ diff --git a/app/assets/images/slider/s3.jpg b/app/assets/images/slider/s3.jpg new file mode 100644 index 00000000..e3b4de10 Binary files /dev/null and b/app/assets/images/slider/s3.jpg differ diff --git a/app/assets/images/slider/s4.jpg b/app/assets/images/slider/s4.jpg new file mode 100644 index 00000000..73decfb9 Binary files /dev/null and b/app/assets/images/slider/s4.jpg differ diff --git a/app/assets/javascripts/CRM.js b/app/assets/javascripts/CRM.js index 03450eb1..b616453c 100755 --- a/app/assets/javascripts/CRM.js +++ b/app/assets/javascripts/CRM.js @@ -23,6 +23,7 @@ //= require bootstrap-notify/bootstrap-notify.js //= require node-waves/waves.js //= require sweetalert/sweetalert.min.js +//= require fileinput.min //= require BSBMaterial/turbolink_admin.js //= require BSBMaterial/demo.js //= require custom.js @@ -34,4 +35,24 @@ $(document).on('turbolinks:load', function() { weekStart: 1, time: false }); -}); \ No newline at end of file + + $("#customer_image_path").fileinput({ + previewFileType: "image", + allowedFileExtensions: ["jpg", "gif", "png"], + browseClass: "btn btn-success", + browseLabel: "Pick Image", + browseIcon: " ", + removeClass: "btn btn-danger", + removeLabel: "Delete", + removeIcon: " ", + showUpload: false, + // uploadClass: "btn btn-info", + // uploadLabel: "Upload", + // uploadIcon: " ", + previewTemplates: { + image: '
\n' + + ' {caption}\n' + + '
\n', + } + }); +}); diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index 6068b53f..1409c829 100755 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -25,34 +25,80 @@ //= require custom.js $(document).on('turbolinks:load', function() { + var oqs_id = ""; $(".nav-completed").on("click", function(){ $("#completed").removeClass('hide') $(".oqs_append").addClass('hide') }); + $(".tables").on("click", function(){ + + var table_id = $(this).val(); + $('#table_id').val(table_id); + oqs_id = $("#oqs_id").val(); + if (table_id){ + var table = table_id + }else{ + var table = null + } + + if (oqs_id > 0) { + $(".oqs_click").removeClass('oqs_active'); + $(".queue_station").removeClass('queue_station_box'); + $("#completed").addClass('hide'); + $(".oqs_append").removeClass('hide'); + $("#oqs_active").addClass('oqs_active'); + $(".queue_station").addClass('queue_station_box'); + // oqs_id = $(this).find(".oqs-id").text(); + $("#oqs_active").attr('data-id',oqs_id); + var url = 'oqs/get_items/'+oqs_id; + + show_details(url,table); + }else{ + $("#completed").removeClass('hide') + $(".oqs_append").addClass('hide') + } + }); + $(".oqs_click").on("click", function(){ - $(".oqs_click").removeClass('oqs_active'); - $(".queue_station").removeClass('queue_station_box'); - $("#completed").addClass('hide'); - $(".oqs_append").removeClass('hide'); - $(this).addClass('oqs_active'); - $(".queue_station").addClass('queue_station_box'); - var oqs_id = $(this).find(".oqs-id").text(); - var url = 'oqs/get_items/'+oqs_id; - - show_details(url); + oqs_id = $(this).val(); + var table_id = $('#table_id').val(); + if (table_id){ + var table = table_id + }else{ + var table = null + } + + if (oqs_id > 0) { + $(".oqs_click").removeClass('oqs_active'); + $(".queue_station").removeClass('queue_station_box'); + $("#completed").addClass('hide'); + $(".oqs_append").removeClass('hide'); + $("#oqs_active").addClass('oqs_active'); + $(".queue_station").addClass('queue_station_box'); + // oqs_id = $(this).find(".oqs-id").text(); + $("#oqs_active").attr('data-id',oqs_id); + var url = 'oqs/get_items/'+oqs_id; + + show_details(url,table); + }else{ + $("#completed").removeClass('hide') + $(".oqs_append").addClass('hide') + } + }); //End Click - function show_details(url){ + function show_details(url,table_id){ var oqs_append = $('.oqs_append'); oqs_append.empty(); var filter = $('.filter').text(); + //Start Ajax $.ajax({ type: "GET", url: url, - data: {'filter':filter}, + data: {'filter':filter,'table_id':table_id}, dataType: "json", success: function(data) { for(var field in data) { @@ -65,12 +111,30 @@ $(document).on('turbolinks:load', function() { } var date = new Date(data[field]["created_at"]); - var show_date = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes(); - + // var show_date = date.getDate() + "-" + (date.getMonth()+1) + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes(); + var show_date =date.getHours()+ ':' + date.getMinutes() +' '+(date.getHours() >= 12 ? 'PM' : 'AM'); + var set_menu_items = data[field]["set_menu_items"]; + var set_instance_items = ""; + if(set_menu_items!=null){ + if(set_menu_items.length > 0){ + $.each(set_menu_items, function(k,val){ + set_instance_items += '
'+val+''; + }); + } + } + + var table_type = ''; + if (data[field]["table_type"]!=null) { + table_type = data[field]["table_type"] +'-'+data[field]["zone"] + }else{ + table_type = "No Table" + + } + row ='
' +'
' +'
' - +''+data[field]["table_type"]+'-'+ data[field]["zone"] +'' + +''+table_type +'' +'' +''+data[field]["order_id"]+'' +'
' @@ -78,9 +142,10 @@ $(document).on('turbolinks:load', function() { +'

' +''+ data[field]["item_name"] +'- ' +' [x'+ data[field]["qty"] +'] ' + +set_instance_items +'

' - +'

'+ options +'

' + +'

'+ options +'

' +'' +'Order at - ' @@ -132,16 +197,53 @@ $(document).on('turbolinks:load', function() { type: 'GET', url: '/oqs/' + orderNo, data: { 'status' : order_status }, - success: function(res){ - - for (i = 0; i < res.length; i++) { - var data = JSON.stringify(res[i]); + success: function(res){ + // console.log(res); + for (i = 0; i < res["items"].length; i++) { + var data = JSON.stringify(res["items"][i]); var parse_data = JSON.parse(data); + var assigned_order_items = []; + var assigned_order_item_id = ''; + if(res["assigned_order_items"]!= undefined && res["assigned_order_items"]!=''){ + assigned_order_items = JSON.parse(JSON.stringify(res["assigned_order_items"])); + $.each(assigned_order_items,function(key,value){ + if(value[parse_data.order_items_id] != undefined){ + assigned_order_item_id = value[parse_data.order_items_id]; + } + }); + } + // console.log(assigned_order_item_id); - var order_item_row = "" + - "" + parse_data.item_name + "" + + var set_menu_items = parse_data.set_menu_items; + var set_instance_items = ""; + if(set_menu_items!=null){ + if(set_menu_items.length > 0){ + $.each(set_menu_items, function(k,val){ + set_instance_items += '
'+val+''; + }); + } + } + + if (oqs_id > 0){ + if(assigned_order_item_id != ''){ + var order_item_row = "" + + "" + parse_data.item_name + set_instance_items + "" + + "" + parse_data.qty + "" + + ""; + }else{ + var order_item_row = "" + + "" + parse_data.item_name + set_instance_items + "" + + "" + parse_data.qty + "" + + ""; + } + + }else{ + var order_item_row = "" + + "" + parse_data.item_name + set_instance_items + "" + "" + parse_data.qty + "" + ""; + } + $("#oqs-order-details-table").children("tbody").append(order_item_row); } } @@ -157,7 +259,7 @@ $(document).on('turbolinks:load', function() { $(document).on('click', '.order-item-edit', function(event){ var _self = $(this); // To know in ajax return var assigned_item_id=$(this).attr('id').substr(5); - window.location.href = '/oqs/'+ assigned_item_id + "/edit" + window.location.href = '/oqs/'+ assigned_item_id + "/edit/oqs"; }); // complete for queue item diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js index d8608481..1044bc6f 100755 --- a/app/assets/javascripts/addorder.js +++ b/app/assets/javascripts/addorder.js @@ -1,4 +1,7 @@ $(function() { + var role = $('#role').val(); + type = window.location.href.indexOf("quick_service"); + modify_order = window.location.href.indexOf("modify_order"); //click menu sidebar menu category $(".product").on("click", function(){ var url = $(this).attr('data-ref'); @@ -9,6 +12,16 @@ $(function() { var menu_list = $('.menu_items_list'); menu_list.empty(); + + if (type != -1 && modify_order != -1) { + url_item = '../../../../../'+url_item; + } + if(modify_order == -1 && type != -1){ + url_item = '../../../../'+url_item; + } + if (type ==-1 && modify_order == -1){ + url_item = url_item + } //Start Ajax $.ajax({ type: "GET", @@ -28,37 +41,47 @@ $(function() { item_attributes = []; if (product[field].image_path) { - image_path = product[field].image_path.url; + if (type != -1 && modify_order != -1) { + image_path = '../../'+product[field].image_path.url; + } + if(modify_order == -1 && type != -1){ + image_path = '../../../../'+product[field].image_path.url; + } + if (type ==-1 && modify_order == -1){ + image_path = product[field].image_path.url; + } }else{ image_path = "/image/logo.png"; } - row = '
' + row = '
' +'
' +'
'+ product[field].name +'
' - +"
" + +"" + +'view_list' + +'
' + +'
' + + +"
" - +"" - +'add' - +'
' - +'
' + + JSON.stringify(menu_items[field].options) +"' data-opt = '" + + JSON.stringify(menu_items[field].options) +"' data-image='"+image_path+"'>" - +"