diff --git a/Gemfile b/Gemfile index 23f3c908..789e27f3 100644 --- a/Gemfile +++ b/Gemfile @@ -9,8 +9,8 @@ end # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.1.0' # Use mysql as the database for Active Record -gem 'mysql2', '>= 0.3.18', '< 0.5' -#gem 'pg' +# gem 'mysql2', '>= 0.3.18', '< 0.5' +gem 'pg' # redis server for cable gem 'redis', '~> 3.0' diff --git a/Gemfile.lock b/Gemfile.lock index 829845e5..9d85889c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -96,7 +96,6 @@ GEM mini_portile2 (2.1.0) minitest (5.10.2) multi_json (1.12.1) - mysql2 (0.4.6) nio4r (2.1.0) nokogiri (1.7.2) mini_portile2 (~> 2.1.0) @@ -233,7 +232,6 @@ DEPENDENCIES jbuilder (~> 2.5) jquery-rails listen (~> 3.0.5) - mysql2 (>= 0.3.18, < 0.5) pg prawn prawn-table diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index fc91e269..091b6822 100644 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -15,3 +15,23 @@ //= require jquery_ujs //= require turbolinks //= require cable + +$(document).ready(function(){ + $('.queue_station').on('click',function(){ + var title=$(this).children().children('.card-title').text(); + var titles=title.split(' '); + + var orderBy=$(this).children().children().children().children('.order-by').text(); + var orderAt=$(this).children().children().children().children('.order-at').text(); + var orderCustomer=$(this).children().children('.order-customer').text(); + + $('#order-title').text($('#order-title').text() + titles[0]); + $('#order-by').text(orderBy); + $('#order-at').text(orderAt); + $('#order-customer').text(orderCustomer); + $('#order-from').text(titles[0]); + + $('#order-items').text(titles[1]); + $('#order-qty').text(titles[2].substr(2).replace(']','')); + }); +}); diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 07f12b93..356508c4 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -2,12 +2,34 @@ class Oqs::HomeController < BaseOqsController def index @queue_stations=OrderQueueStation.all + #sample Data + @queue_items_details = { :queue_id => 1, :order_id => 1, :station_name => 'Queue Station 1', :zone => 'Table4', :item_name => 'beef', :price => 10.00, :qty => 2, :customer => 'Wathon', :item_order_by => 'Yan', :created_at => '2007-05-17'} + # @queue_items_details = OrderItem.select("oqs as queue_id, oqs.station_name, oqs.is_active, oqpz.zone_id, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.created_at") + # .joins("join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = order_queue_items.order_queue_station_id") + # .joins("right join order_queue_stations as oqs ON oqs.id = order_queue_items.order_queue_station_id") + # .joins("right join orders as od ON od.id = order_queue_items.order_id") + # .joins("right join order_items as odt ON odt.item_code = order_queue_items.item_code") + # .order("odt.item_name DESC") + + # puts @queue_items_details # @queue_stations.each do |que| - # Contact.find(:all, :joins => ['left join sales s on s.customer_id = contacts.id'], :conditions => ["contact_type = 'Customer' AND name IS NOT NULL"],:group => ["contacts.id"]) - # AssignedOrderItem.find(:all, :conditions=>["order_queue_station_id=#{que.id}"], :group => ["order_queue_station_id"]) + # zone_id = OrderQueueProcessByZone.where('order_queue_station_id=#{que.id}').select(:zone_id).take + # type = DiningFacility.find_by_zone_id(zone_id).select(:type).take + # end + # @queue_items_details = { :queue_id, :zone_id, :item_code, :item_name, :item_options, :price, :qty, :order_by, :order_at } + # @queue_stations.each do |que| + # # Contact.find(:all, :joins => ['left join sales s on s.customer_id = contacts.id'], :conditions => ["contact_type = 'Customer' AND name IS NOT NULL"],:group => ["contacts.id"]) + # assigned_items=AssignedOrderItem.find(:all, :conditions=>["order_queue_station_id = #{que.id}"], :group => ["order_queue_station_id"]) + # assigned_items.each do |ass_items| + # order_item_details=OrderItems.joins('left join order').where("item_code = #{ ass_items.item_code } AND order_item_status = 1") + # end # # AssignedOrderItem.where("order_queue_station_id = :que_id", {:que_id => que_id}).get # end end + def show end end + + + diff --git a/app/models/order_queue_item.rb b/app/models/order_queue_item.rb index 7f94fbec..fed1139d 100644 --- a/app/models/order_queue_item.rb +++ b/app/models/order_queue_item.rb @@ -1,2 +1,15 @@ class OrderQueueItem < ApplicationRecord + belongs_to :order + belongs_to :order_queue_station + + def self.add_order_item (order, item_code, order_queue_station ) + order_queue_item = OrderQueueItem.new() + order_queue_item.order = order + order_queue_item.item_code = item_code + order_queue_item.order_queue_station = order_queue_station + order_queue_item.print_status = false + order_queue_item.delivery_status = false + order_queue_item.queue_status = true + order_queue_item.save + end end diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index b2feb596..ffd7e110 100644 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -8,7 +8,7 @@ class OrderQueueStation < ApplicationRecord scope :active, -> {where(is_active: true)} - def process_order (order) + def process_order (order) oqs_stations = OrderQueueStation.active order_items = order.order_items @@ -20,10 +20,11 @@ class OrderQueueStation < ApplicationRecord #Loop through the processing items pq_items.each do |pq_item| #Processing through the looping items - order_items.each do |order_item| + order_items.each do |order_item| if (pq_item == order_item.item_code) #Same Order_items can appear in two location. AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) + OrderQueueItem.add_order_item(order, order_item.item_code, oqs) end end diff --git a/app/models/test.rb b/app/models/test.rb new file mode 100644 index 00000000..fe0afa77 --- /dev/null +++ b/app/models/test.rb @@ -0,0 +1,2 @@ +class Test < ApplicationRecord +end diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 1f449cbc..24fa00d0 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -6,31 +6,25 @@
Medium, Fries, Salad
-Order at 12:23, Kyaw Lwin
-This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
---Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.
- -
This card has supporting text below as a natural lead-in to additional content.
-Last updated 3 mins ago
---Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat.
- -
This card has supporting text below as a natural lead-in to additional content.
-Last updated 3 mins ago
-This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.
-Last updated 3 mins ago
+ <% + @queue_stations.each do |que| + %> + +Medium, Fries, Salad
++ Order at + + <%= @queue_items_details[:created_at] %> + - + + <%= @queue_items_details[:item_order_by] %> + + +
+<%= @queue_items_details[:customer] %>
+This card has supporting text below as a natural lead-in to additional content.
-Last updated 3 mins ago
-This card has supporting text below as a natural lead-in to additional content.
-Last updated 3 mins ago
-|
- Menu Items Name - Less Sweet, No MSG + | + | -- 5 + | + |