From 138850fb2483f68461a3c0ecf2a274f5633ed211 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Sat, 3 Jun 2017 13:44:10 +0630 Subject: [PATCH] origin pull master --- .gitignore | 4 + Gemfile | 10 +- Gemfile.lock | 21 +- app/assets/javascripts/OQS.js | 66 +++ app/assets/javascripts/cable.js | 2 +- .../channels/order_queue_station.js | 24 + app/assets/javascripts/print_settings.coffee | 3 + .../javascripts/transactions/sales.coffee | 3 + app/assets/stylesheets/OQS.scss | 4 + app/assets/stylesheets/print_settings.scss | 3 + app/assets/stylesheets/settings.scss | 32 ++ .../stylesheets/transactions/sales.scss | 3 + app/channels/application_cable/channel.rb | 14 +- app/channels/order_queue_station_channel.rb | 13 + app/controllers/api/orders_controller.rb | 4 +- app/controllers/oqs/home_controller.rb | 44 ++ app/controllers/oqs/print_controller.rb | 16 + app/controllers/print_settings_controller.rb | 74 +++ .../settings/menu_categories_controller.rb | 4 +- .../menu_item_instances_controller.rb | 79 ++++ app/controllers/settings/menus_controller.rb | 7 +- .../order_queue_stations_controller.rb | 6 +- .../settings/set_menu_items_controller.rb | 23 +- .../settings/simple_menu_items_controller.rb | 23 +- .../transactions/sales_controller.rb | 74 +++ app/helpers/oqs/print_helper.rb | 2 + app/helpers/print_settings_helper.rb | 2 + app/helpers/transactions/sales_helper.rb | 2 + app/jobs/order_broadcast_job.rb | 8 + app/jobs/order_queue_processor_job.rb | 3 +- app/models/menu.rb | 4 +- app/models/menu_item.rb | 6 +- app/models/order.rb | 14 +- app/models/order_queue_station.rb | 6 +- app/models/print_setting.rb | 2 + app/models/printer/order_queue_printer.rb | 34 +- app/models/sale_discount.rb | 3 - app/models/test.rb | 2 + app/models/transactions.rb | 5 + app/pdf/order_item_pdf.rb | 21 +- app/views/layouts/_header.html.erb | 8 +- app/views/layouts/application.html.erb | 1 + app/views/oqs/home/index.html.erb | 443 ++++++------------ app/views/oqs/print/print.html.erb | 2 + app/views/print_settings/_form.html.erb | 22 + .../_print_setting.json.jbuilder | 2 + app/views/print_settings/edit.html.erb | 6 + app/views/print_settings/index.html.erb | 49 ++ app/views/print_settings/index.json.jbuilder | 1 + app/views/print_settings/new.html.erb | 5 + app/views/print_settings/show.html.erb | 64 +++ app/views/print_settings/show.json.jbuilder | 1 + .../settings/menu_categories/index.html.erb | 1 + .../settings/menu_categories/show.html.erb | 47 +- .../menu_item_attributes/show.html.erb | 2 +- .../menu_item_instances/_form.html.erb | 18 + .../_settings_menu_item.json.jbuilder | 2 + .../menu_item_instances/edit.html.erb | 12 + .../menu_item_instances/index.html.erb | 93 ++++ .../menu_item_instances/index.json.jbuilder | 1 + .../settings/menu_item_instances/new.html.erb | 17 + .../menu_item_instances/show.html.erb | 96 ++++ .../menu_item_instances/show.json.jbuilder | 1 + .../settings/menu_item_options/edit.html.erb | 2 +- app/views/settings/menus/index.html.erb | 9 +- app/views/settings/menus/show.html.erb | 11 +- .../order_queue_stations/edit.html.erb | 16 +- .../order_queue_stations/show.html.erb | 8 + .../settings/processing_items/_form.html.erb | 2 + .../settings/set_menu_items/_form.html.erb | 7 +- .../settings/set_menu_items/edit.html.erb | 11 +- .../settings/set_menu_items/index.html.erb | 25 +- .../settings/set_menu_items/new.html.erb | 4 +- .../settings/set_menu_items/show.html.erb | 58 ++- .../settings/simple_menu_items/_form.html.erb | 3 +- .../settings/simple_menu_items/edit.html.erb | 9 +- .../settings/simple_menu_items/index.html.erb | 24 +- .../settings/simple_menu_items/new.html.erb | 2 +- .../settings/simple_menu_items/show.html.erb | 97 +++- app/views/transactions/sales/_form.html.erb | 27 ++ .../sales/_transactions_sale.json.jbuilder | 2 + app/views/transactions/sales/edit.html.erb | 6 + app/views/transactions/sales/index.html.erb | 59 +++ .../transactions/sales/index.json.jbuilder | 1 + app/views/transactions/sales/new.html.erb | 5 + app/views/transactions/sales/show.html.erb | 89 ++++ .../transactions/sales/show.json.jbuilder | 1 + config/environments/development.rb | 3 + config/initializers/assets.rb | 2 + config/routes.rb | 21 +- .../20170403162221_create_sale_discounts.rb | 13 - .../20170602093159_create_print_settings.rb | 20 + db/scaffold_structure | 2 + dump.rdb | Bin 485 -> 1669 bytes spec/controllers/oqs/print_controller_spec.rb | 12 + .../print_settings_controller_spec.rb | 141 ++++++ .../transactions/sales_controller_spec.rb | 141 ++++++ spec/helpers/oqs/print_helper_spec.rb | 15 + spec/helpers/print_settings_helper_spec.rb | 15 + .../helpers/transactions/sales_helper_spec.rb | 15 + spec/jobs/order_broadcast_job_spec.rb | 5 + ...discount_spec.rb => print_setting_spec.rb} | 2 +- spec/models/test_spec.rb | 5 + spec/models/transactions/sale_spec.rb | 5 + spec/requests/print_settings_spec.rb | 10 + .../transactions/transactions_sales_spec.rb | 10 + spec/routing/print_settings_routing_spec.rb | 39 ++ .../transactions/sales_routing_spec.rb | 39 ++ spec/views/oqs/print/print.html.erb_spec.rb | 5 + .../print_settings/edit.html.erb_spec.rb | 51 ++ .../print_settings/index.html.erb_spec.rb | 52 ++ .../views/print_settings/new.html.erb_spec.rb | 51 ++ .../print_settings/show.html.erb_spec.rb | 36 ++ .../transactions/sales/edit.html.erb_spec.rb | 60 +++ .../transactions/sales/index.html.erb_spec.rb | 61 +++ .../transactions/sales/new.html.erb_spec.rb | 60 +++ .../transactions/sales/show.html.erb_spec.rb | 42 ++ test/system/print_settings_test.rb | 9 + test/system/sales_test.rb | 9 + 119 files changed, 2531 insertions(+), 462 deletions(-) create mode 100644 app/assets/javascripts/channels/order_queue_station.js create mode 100644 app/assets/javascripts/print_settings.coffee create mode 100644 app/assets/javascripts/transactions/sales.coffee create mode 100644 app/assets/stylesheets/print_settings.scss create mode 100644 app/assets/stylesheets/settings.scss create mode 100644 app/assets/stylesheets/transactions/sales.scss create mode 100644 app/channels/order_queue_station_channel.rb create mode 100644 app/controllers/oqs/print_controller.rb create mode 100644 app/controllers/print_settings_controller.rb create mode 100644 app/controllers/settings/menu_item_instances_controller.rb create mode 100644 app/controllers/transactions/sales_controller.rb create mode 100644 app/helpers/oqs/print_helper.rb create mode 100644 app/helpers/print_settings_helper.rb create mode 100644 app/helpers/transactions/sales_helper.rb create mode 100644 app/jobs/order_broadcast_job.rb create mode 100644 app/models/print_setting.rb delete mode 100644 app/models/sale_discount.rb create mode 100644 app/models/test.rb create mode 100644 app/models/transactions.rb create mode 100644 app/views/oqs/print/print.html.erb create mode 100644 app/views/print_settings/_form.html.erb create mode 100644 app/views/print_settings/_print_setting.json.jbuilder create mode 100644 app/views/print_settings/edit.html.erb create mode 100644 app/views/print_settings/index.html.erb create mode 100644 app/views/print_settings/index.json.jbuilder create mode 100644 app/views/print_settings/new.html.erb create mode 100644 app/views/print_settings/show.html.erb create mode 100644 app/views/print_settings/show.json.jbuilder create mode 100644 app/views/settings/menu_item_instances/_form.html.erb create mode 100644 app/views/settings/menu_item_instances/_settings_menu_item.json.jbuilder create mode 100644 app/views/settings/menu_item_instances/edit.html.erb create mode 100644 app/views/settings/menu_item_instances/index.html.erb create mode 100644 app/views/settings/menu_item_instances/index.json.jbuilder create mode 100644 app/views/settings/menu_item_instances/new.html.erb create mode 100644 app/views/settings/menu_item_instances/show.html.erb create mode 100644 app/views/settings/menu_item_instances/show.json.jbuilder create mode 100644 app/views/transactions/sales/_form.html.erb create mode 100644 app/views/transactions/sales/_transactions_sale.json.jbuilder create mode 100644 app/views/transactions/sales/edit.html.erb create mode 100644 app/views/transactions/sales/index.html.erb create mode 100644 app/views/transactions/sales/index.json.jbuilder create mode 100644 app/views/transactions/sales/new.html.erb create mode 100644 app/views/transactions/sales/show.html.erb create mode 100644 app/views/transactions/sales/show.json.jbuilder delete mode 100644 db/migrate/20170403162221_create_sale_discounts.rb create mode 100644 db/migrate/20170602093159_create_print_settings.rb create mode 100644 spec/controllers/oqs/print_controller_spec.rb create mode 100644 spec/controllers/print_settings_controller_spec.rb create mode 100644 spec/controllers/transactions/sales_controller_spec.rb create mode 100644 spec/helpers/oqs/print_helper_spec.rb create mode 100644 spec/helpers/print_settings_helper_spec.rb create mode 100644 spec/helpers/transactions/sales_helper_spec.rb create mode 100644 spec/jobs/order_broadcast_job_spec.rb rename spec/models/{sale_discount_spec.rb => print_setting_spec.rb} (65%) create mode 100644 spec/models/test_spec.rb create mode 100644 spec/models/transactions/sale_spec.rb create mode 100644 spec/requests/print_settings_spec.rb create mode 100644 spec/requests/transactions/transactions_sales_spec.rb create mode 100644 spec/routing/print_settings_routing_spec.rb create mode 100644 spec/routing/transactions/sales_routing_spec.rb create mode 100644 spec/views/oqs/print/print.html.erb_spec.rb create mode 100644 spec/views/print_settings/edit.html.erb_spec.rb create mode 100644 spec/views/print_settings/index.html.erb_spec.rb create mode 100644 spec/views/print_settings/new.html.erb_spec.rb create mode 100644 spec/views/print_settings/show.html.erb_spec.rb create mode 100644 spec/views/transactions/sales/edit.html.erb_spec.rb create mode 100644 spec/views/transactions/sales/index.html.erb_spec.rb create mode 100644 spec/views/transactions/sales/new.html.erb_spec.rb create mode 100644 spec/views/transactions/sales/show.html.erb_spec.rb create mode 100644 test/system/print_settings_test.rb create mode 100644 test/system/sales_test.rb diff --git a/.gitignore b/.gitignore index 9dde67bb..02338531 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,7 @@ config/deploy/config/* # Ignore Byebug command history file. .byebug_history + +# Gem files +#Gemfile +#Gemfile.lock diff --git a/Gemfile b/Gemfile index d42da647..ac3052b5 100644 --- a/Gemfile +++ b/Gemfile @@ -10,7 +10,13 @@ end gem 'rails', '~> 5.1.0' # Use mysql as the database for Active Record gem 'mysql2', '>= 0.3.18', '< 0.5' -#gem 'pg' + +#Use PosgreSQL +gem 'pg' + +# redis server for cable +# gem 'redis', '~> 3.0' + # Use Puma as the app server gem 'puma', '~> 3.0' # Use SCSS for stylesheets @@ -37,6 +43,8 @@ gem 'to_xls-rails' #Reporting gem #gem 'compendium' +# Pagination +gem 'kaminari', :git => "git://github.com/amatsuda/kaminari.git", :branch => 'master' # Use jquery as the JavaScript library gem 'jquery-rails' diff --git a/Gemfile.lock b/Gemfile.lock index 6936e5f1..e2c1dd73 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,3 +1,21 @@ +GIT + remote: git://github.com/amatsuda/kaminari.git + revision: c3c853a944cd2bff072ae05e48c563b2c9a29597 + branch: master + specs: + kaminari (1.0.1) + activesupport (>= 4.1.0) + kaminari-actionview (= 1.0.1) + kaminari-activerecord (= 1.0.1) + kaminari-core (= 1.0.1) + kaminari-actionview (1.0.1) + actionview + kaminari-core (= 1.0.1) + kaminari-activerecord (1.0.1) + activerecord + kaminari-core (= 1.0.1) + kaminari-core (1.0.1) + GEM remote: https://rubygems.org/ specs: @@ -231,6 +249,7 @@ DEPENDENCIES font-awesome-rails jbuilder (~> 2.5) jquery-rails + kaminari! listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) prawn @@ -255,4 +274,4 @@ DEPENDENCIES web-console (>= 3.3.0) BUNDLED WITH - 1.14.6 + 1.15.0 diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index fc91e269..80a09b47 100644 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -15,3 +15,69 @@ //= require jquery_ujs //= require turbolinks //= require cable + +$(document).ready(function(){ + $('.queue_station').on('click',function(){ + var orderZone=$(this).children().children().children('.order-zone').text(); + var orderItem=$(this).children().children().children('.order-item').text(); + var orderQty=$(this).children().children().children('.order-qty').text(); + 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 DETAILS - " + orderZone); + $('#order-by').text(orderBy); + $('#order-at').text(orderAt); + $('#order-customer').text(orderCustomer); + $('#order-from').text(orderZone); + + $('#order-items').text(orderItem); + $('#order-qty').text(orderQty); + + $('.queue_station').removeClass('selected-item'); + $(this).addClass('selected-item'); + }); + + // complete for queue item + $('.order-complete').on('click',function(){ + var _self= $(this); + var assigned_item_id=$(this).attr('id').substr(15); + var params = { 'id':assigned_item_id }; + var station=$(this).parent().parent(".queue_station").parent().parent().attr('id'); + + $.ajax({ + type: 'POST', + url: '/oqs/update_delivery', + data: params, + dataType: 'json', + success: function(data){ + var queue_station=_self.parent().parent(".queue_station"); + + // Remove a queue card from current station + queue_station.remove(); + + // Remove a queue card from current station + queue_station.children('.card-footer').remove(); + + // Add removed queue card from station to completed + $("#completed").children('.card-columns').append(queue_station); + + // update queue item count in station + $("#"+station+"_count").text(parseInt($("#"+station+"_count").text())-1); + $("#completed_count").text(parseInt($("#completed_count").text())+1); + + alert("updated!"); + } + }); + }); + + $('#print_order_item').on('click',function(){ + var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text(); + var params = { 'id':assigned_item_id }; + $.ajax({ + type: 'GET', + url: '/oqs/print/print/'+assigned_item_id, + success: function(data){ } + }); + }); +}); diff --git a/app/assets/javascripts/cable.js b/app/assets/javascripts/cable.js index 71ee1e66..739aa5f0 100644 --- a/app/assets/javascripts/cable.js +++ b/app/assets/javascripts/cable.js @@ -1,5 +1,5 @@ // Action Cable provides the framework to deal with WebSockets in Rails. -// You can generate new channels where WebSocket features live using the rails generate channel command. +// You can generate new channels where WebSocket features live using the `rails generate channel` command. // //= require action_cable //= require_self diff --git a/app/assets/javascripts/channels/order_queue_station.js b/app/assets/javascripts/channels/order_queue_station.js new file mode 100644 index 00000000..00151e5e --- /dev/null +++ b/app/assets/javascripts/channels/order_queue_station.js @@ -0,0 +1,24 @@ +App.order_queue_station = App.cable.subscriptions.create("OrderQueueStationChannel", { + connected: function() {}, + + disconnected: function() {}, + + received: function(message) { + alert(message); + }, + + order: function(message) { + return this.perform('order', { + message: message + }); + } +}); + +// $(function(){ +// $("#submit_order").on('click', function(event) { +// var orderData=$("#new_order").serializeObject(); +// App.order_station.order(orderData); +// //orderData=''; +// return event.preventDefault(); +// }); +// }); diff --git a/app/assets/javascripts/print_settings.coffee b/app/assets/javascripts/print_settings.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/print_settings.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/javascripts/transactions/sales.coffee b/app/assets/javascripts/transactions/sales.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/transactions/sales.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/OQS.scss b/app/assets/stylesheets/OQS.scss index 23a49d41..07c98b85 100644 --- a/app/assets/stylesheets/OQS.scss +++ b/app/assets/stylesheets/OQS.scss @@ -14,3 +14,7 @@ .order-void { background-color: #FFCCDD; } + +.selected-item { + background-color: blue; +} diff --git a/app/assets/stylesheets/print_settings.scss b/app/assets/stylesheets/print_settings.scss new file mode 100644 index 00000000..7dd1ef04 --- /dev/null +++ b/app/assets/stylesheets/print_settings.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the print_settings 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/settings.scss b/app/assets/stylesheets/settings.scss new file mode 100644 index 00000000..37064f07 --- /dev/null +++ b/app/assets/stylesheets/settings.scss @@ -0,0 +1,32 @@ +@import "bootstrap"; +@import "font-awesome"; +@import "theme"; + +/* Show it is fixed to the top */ +// body { +// min-height: 75rem; +// padding-top: 4.5rem; +// } + +.setting_nav{ + background-color: #2f5663; +} + +ul.navbar-nav li a{ + text-decoration :none; + color :#e6e6e6; +} + +ul.dropdown-menu li a{ + text-decoration :none; + color :#525252; +} + +.setting_breadcrumb{ + background-color: transparent !important; + margin-bottom: 0px !important; +} +.page-header{ + border-bottom :0px solid #000 !important; + margin :0px !important; +} \ No newline at end of file diff --git a/app/assets/stylesheets/transactions/sales.scss b/app/assets/stylesheets/transactions/sales.scss new file mode 100644 index 00000000..2ab00c12 --- /dev/null +++ b/app/assets/stylesheets/transactions/sales.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the transactions/Sales controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/channels/application_cable/channel.rb b/app/channels/application_cable/channel.rb index d6726972..a66bc071 100644 --- a/app/channels/application_cable/channel.rb +++ b/app/channels/application_cable/channel.rb @@ -1,4 +1,14 @@ module ApplicationCable - class Channel < ActionCable::Channel::Base - end + class Channel < ActionCable::Channel::Base + end + # Order Queue Station Channel + class OrderChannel < ActionCable::Channel::Base + + end + + # Order Queue Station Channel + class OQSChannel < ActionCable::Channel::Base + + end + end diff --git a/app/channels/order_queue_station_channel.rb b/app/channels/order_queue_station_channel.rb new file mode 100644 index 00000000..8206c64b --- /dev/null +++ b/app/channels/order_queue_station_channel.rb @@ -0,0 +1,13 @@ +class OrderQueueStationChannel < ApplicationCable::Channel + def subscribed + stream_from "order_queue_station_channel" + end + + def unsubscribed + # Any cleanup needed when channel is unsubscribed + end + + def order(message) + # ToDo + end +end diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index be600853..443a754b 100644 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -39,8 +39,8 @@ class Api::OrdersController < Api::ApiController #Create Table Booking or Room Booking if !params["booking_id"].nil? && params[:booking_id].to_i > 0 - @order.new_booking = false - # @order.new_booking = true + #@order.new_booking = false + @order.new_booking = true @order.booking_id = params[:booking_id] end diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index acf99e41..1292a5e6 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -1,6 +1,50 @@ class Oqs::HomeController < BaseOqsController def index + queue_stations=OrderQueueStation.all + + @queue_items_details = queue_items_query(0) + + @queue_completed_item = queue_items_query(1) + + @queue_stations_items=Array.new + + # Calculate Count for each station tab + queue_stations.each do |que| + i=0 + @queue_items_details.each do |qid| + if qid.station_name == que.station_name + i=i+1 + end + end + @queue_stations_items.push({:station_name => que.station_name, :is_active => que.is_active ,:item_count => i }) + end + + @queue_stations_items end + def show end + + # update delivery status when complete click + def update_delivery_status + assigned_item_id = params[:id] + assigned_item=AssignedOrderItem.find(assigned_item_id) + assigned_item.delivery_status=true + assigned_item.save + end + + # Query for OQS with status + def queue_items_query(status) + AssignedOrderItem.select("assigned_order_items.id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at") + .joins("join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id + left join dining_facilities as df on df.zone_id = oqpz.zone_id + left join order_queue_stations as oqs ON oqs.id = assigned_order_items.order_queue_station_id + left join orders as od ON od.id = assigned_order_items.order_id + left join order_items as odt ON odt.item_code = assigned_order_items.item_code + left join customers as cus ON cus.id = od.customer_id") + .where("assigned_order_items.delivery_status = #{status}") + .group("assigned_order_items.id") + .order("odt.item_name DESC") + end end + diff --git a/app/controllers/oqs/print_controller.rb b/app/controllers/oqs/print_controller.rb new file mode 100644 index 00000000..368a513d --- /dev/null +++ b/app/controllers/oqs/print_controller.rb @@ -0,0 +1,16 @@ +class Oqs::PrintController < ApplicationController + def print + unique_code="OrderItemPdf" + assigned_item_id=params[:id] + assigned_order_item=AssignedOrderItem.select("order_id, item_code").where('id='+assigned_item_id) + + print_settings=PrintSetting.find_by_unique_code(unique_code) + order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) + order_queue_printer.print_order_item(print_settings,assigned_order_item[0].order_id, assigned_order_item[0].item_code ) + + # update print status when complete click + assigned_item=AssignedOrderItem.find(assigned_item_id) + assigned_item.print_status=true + assigned_item.save + end +end diff --git a/app/controllers/print_settings_controller.rb b/app/controllers/print_settings_controller.rb new file mode 100644 index 00000000..fa5af7e8 --- /dev/null +++ b/app/controllers/print_settings_controller.rb @@ -0,0 +1,74 @@ +class PrintSettingsController < ApplicationController + before_action :set_print_setting, only: [:show, :edit, :update, :destroy] + + # GET /print_settings + # GET /print_settings.json + def index + @print_settings = PrintSetting.all + end + + # GET /print_settings/1 + # GET /print_settings/1.json + def show + end + + # GET /print_settings/new + def new + @print_setting = PrintSetting.new + end + + # GET /print_settings/1/edit + def edit + end + + # POST /print_settings + # POST /print_settings.json + def create + @print_setting = PrintSetting.new(print_setting_params) + + respond_to do |format| + if @print_setting.save + format.html { redirect_to @print_setting, notice: 'Print setting was successfully created.' } + format.json { render :show, status: :created, location: @print_setting } + else + format.html { render :new } + format.json { render json: @print_setting.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /print_settings/1 + # PATCH/PUT /print_settings/1.json + def update + respond_to do |format| + if @print_setting.update(print_setting_params) + format.html { redirect_to @print_setting, notice: 'Print setting was successfully updated.' } + format.json { render :show, status: :ok, location: @print_setting } + else + format.html { render :edit } + format.json { render json: @print_setting.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /print_settings/1 + # DELETE /print_settings/1.json + def destroy + @print_setting.destroy + respond_to do |format| + format.html { redirect_to print_settings_url, notice: 'Print setting was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_print_setting + @print_setting = PrintSetting.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def print_setting_params + params.require(:print_setting).permit(:name, :unique_code, :template, :db_name, :db_type, :db_username, :db_password, :printer_name, :api_settings, :page_width, :page_height, :print_copies) + end +end diff --git a/app/controllers/settings/menu_categories_controller.rb b/app/controllers/settings/menu_categories_controller.rb index daa76d62..d7f373aa 100644 --- a/app/controllers/settings/menu_categories_controller.rb +++ b/app/controllers/settings/menu_categories_controller.rb @@ -5,7 +5,7 @@ class Settings::MenuCategoriesController < ApplicationController # GET /settings/menu_categories # GET /settings/menu_categories.json def index - @settings_menu_categories = MenuCategory.all + @settings_menu_categories = MenuCategory.all.page(params[:page]).per(10) end # GET /settings/menu_categories/1 @@ -63,7 +63,7 @@ class Settings::MenuCategoriesController < ApplicationController # DELETE /settings/menu_categories/1 # DELETE /settings/menu_categories/1.json def destroy - @settings_menu_category.destroy + # @settings_menu_category.destroy respond_to do |format| format.html { redirect_to settings_menu_categories_path, notice: 'Menu category was successfully destroyed.' } format.json { head :no_content } diff --git a/app/controllers/settings/menu_item_instances_controller.rb b/app/controllers/settings/menu_item_instances_controller.rb new file mode 100644 index 00000000..00f980e9 --- /dev/null +++ b/app/controllers/settings/menu_item_instances_controller.rb @@ -0,0 +1,79 @@ +class Settings::MenuItemInstancesController < ApplicationController + before_action :set_settings_menu_item_instance, only: [:show, :edit, :update, :destroy] + before_action :set_settings_menu_item, only: [:index, :show, :edit, :new, :update] + + # GET /settings/menu_item_instances + # GET /settings/menu_item_instances.json + def index + @settings_menu_item_instances = MenuItemInstance.all + end + + # GET /settings/menu_item_instances/1 + # GET /settings/menu_item_instances/1.json + def show + end + + # GET /settings/menu_item_instances/new + def new + @settings_menu_item_instance = MenuItemInstance.new + end + + # GET /settings/menu_item_instances/1/edit + def edit + end + + # POST /settings/menu_item_instances + # POST /settings/menu_item_instances.json + def create + @settings_menu_item_instance = MenuItemInstance.new(settings_menu_item_instance_params) + + respond_to do |format| + if @settings_menu_item_instance.save + format.html { redirect_to settings_menu_item_instances_path, notice: 'Menu item instance was successfully created.' } + format.json { render :show, status: :created, location: @settings_menu_item_instance } + else + format.html { render :new } + format.json { render json: @settings_menu_item_instance.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /settings/menu_item_instances/1 + # PATCH/PUT /settings/menu_item_instances/1.json + def update + respond_to do |format| + if @settings_menu_item_instance.update(settings_menu_item_instance_params) + format.html { redirect_to settings_menu_item_instance_path(@settings_menu_item_instance), notice: 'Menu item instance was successfully updated.' } + format.json { render :show, status: :ok, location: @settings_menu_item_instance } + else + format.html { render :edit } + format.json { render json: @settings_menu_item_instance.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /settings/menu_item_instances/1 + # DELETE /settings/menu_item_instances/1.json + def destroy + # @settings_menu_item_instance.destroy + respond_to do |format| + format.html { redirect_to settings_menu_item_instances_path, notice: 'Menu item instance was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_settings_menu_item_instance + @set_settings_menu_item_instances = MenuItemInstance.find(params[:id]) + end + + def set_settings_menu_item + @item = MenuItem.find(params[:menu_item_id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def settings_menu_item_instance_params + params.require(:menu_item_instance).permit(:item_instance_code, :item_instance_name, :price, :is_on_promotion, :promotion_price, :is_available) + end +end diff --git a/app/controllers/settings/menus_controller.rb b/app/controllers/settings/menus_controller.rb index b10f31c9..e0ecde30 100644 --- a/app/controllers/settings/menus_controller.rb +++ b/app/controllers/settings/menus_controller.rb @@ -4,12 +4,13 @@ class Settings::MenusController < ApplicationController # GET /settings/menus # GET /settings/menus.json def index - @settings_menus = Menu.all + @settings_menus = Menu.all.page(params[:page]).per(10) end # GET /settings/menus/1 # GET /settings/menus/1.json def show + @settings_menu_categories = @settings_menu.menu_categories.page(params[:page]).per(10) end # GET /settings/menus/new @@ -25,7 +26,7 @@ class Settings::MenusController < ApplicationController # POST /settings/menus.json def create @settings_menu = Menu.new(settings_menu_params) - + @settings_menu.created_by = current_login_employee.name respond_to do |format| if @settings_menu.save format.html { redirect_to settings_menus_path, notice: 'Menu was successfully created.' } @@ -42,7 +43,7 @@ class Settings::MenusController < ApplicationController def update respond_to do |format| if @settings_menu.update(settings_menu_params) - format.html { redirect_to settings_menu_path(@settings_menu), notice: 'Menu was successfully updated.' } + format.html { redirect_to settings_menus_path, notice: 'Menu was successfully updated.' } format.json { render :show, status: :ok, location: @settings_menu } else format.html { render :edit } diff --git a/app/controllers/settings/order_queue_stations_controller.rb b/app/controllers/settings/order_queue_stations_controller.rb index ec85e56a..e0cf0d08 100644 --- a/app/controllers/settings/order_queue_stations_controller.rb +++ b/app/controllers/settings/order_queue_stations_controller.rb @@ -1,5 +1,5 @@ class Settings::OrderQueueStationsController < ApplicationController - before_action :set_settings_order_queue_station, only: [:show, :edit,:new, :update, :destroy] + before_action :set_settings_order_queue_station, only: [:show, :edit, :update, :destroy] # GET /settings/order_queue_stations # GET /settings/order_queue_stations.json @@ -25,10 +25,10 @@ class Settings::OrderQueueStationsController < ApplicationController # POST /settings/order_queue_stations.json def create @settings_order_queue_station = OrderQueueStation.new(settings_order_queue_station_params) - + @settings_order_queue_station.created_by = current_login_employee.name respond_to do |format| if @settings_order_queue_station.save - format.html { redirect_to @settings_order_queue_station, notice: 'Order queue station was successfully created.' } + format.html { redirect_to settings_order_queue_stations_path, notice: 'Order queue station was successfully created.' } format.json { render :show, status: :created, location: @settings_order_queue_station } else format.html { render :new } diff --git a/app/controllers/settings/set_menu_items_controller.rb b/app/controllers/settings/set_menu_items_controller.rb index 1f227246..cc5e89e8 100644 --- a/app/controllers/settings/set_menu_items_controller.rb +++ b/app/controllers/settings/set_menu_items_controller.rb @@ -1,20 +1,22 @@ class Settings::SetMenuItemsController < ApplicationController before_action :set_settings_menu_item, only: [:show, :edit, :update, :destroy] - before_action :set_settings_menu_category, only: [:index, :show, :edit, :new] + before_action :set_settings_menu_category, only: [:index, :show, :edit, :new, :update] # GET /settings/menu_items # GET /settings/menu_items.json def index - @settings_menu_items = @category.menu_items + @settings_menu_items = @category.menu_items.page(params[:page]).per(10) end - + # GET /settings/menu_items/1 # GET /settings/menu_items/1.json def show + @sub_menu = MenuItem.where("menu_item_id=?",params[:id]).page(params[:page]).per(10) end # GET /settings/menu_items/new def new @settings_menu_item = MenuItem.new + @settings_menu_item.type = "SetMenuItem" end # GET /settings/menu_items/1/edit @@ -25,10 +27,13 @@ class Settings::SetMenuItemsController < ApplicationController # POST /settings/menu_items.json def create @settings_menu_item = MenuItem.new(settings_menu_item_params) - + if params[:simple_menu_item][:menu_item_id] == '' + @settings_menu_item.menu_category_id = params[:menu_category_id] + end + @settings_menu_item.created_by = current_login_employee.name respond_to do |format| if @settings_menu_item.save - format.html { redirect_to settings_menu_items_path, notice: 'Menu item was successfully created.' } + format.html { redirect_to settings_menu_category_set_menu_items_path, notice: 'Menu item was successfully created.' } format.json { render :show, status: :created, location: @settings_menu_item } else format.html { render :new } @@ -42,7 +47,7 @@ class Settings::SetMenuItemsController < ApplicationController def update respond_to do |format| if @settings_menu_item.update(settings_menu_item_params) - format.html { redirect_to settings_menu_item_path(@settings_menu_item), notice: 'Menu item was successfully updated.' } + format.html { redirect_to settings_menu_category_set_menu_items_path, notice: 'Menu item was successfully updated.' } format.json { render :show, status: :ok, location: @settings_menu_item } else format.html { render :edit } @@ -54,9 +59,9 @@ class Settings::SetMenuItemsController < ApplicationController # DELETE /settings/menu_items/1 # DELETE /settings/menu_items/1.json def destroy - @settings_menu_item.destroy + # @settings_menu_item.destroy respond_to do |format| - format.html { redirect_to settings_menu_items_path, notice: 'Menu item was successfully destroyed.' } + format.html { redirect_to settings_menu_category_set_menu_items_path, notice: 'Menu item was successfully destroyed.' } format.json { head :no_content } end end @@ -73,6 +78,6 @@ class Settings::SetMenuItemsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def settings_menu_item_params - params.require(:menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by) + params.require(:set_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by) end end diff --git a/app/controllers/settings/simple_menu_items_controller.rb b/app/controllers/settings/simple_menu_items_controller.rb index c9114330..d2083e59 100644 --- a/app/controllers/settings/simple_menu_items_controller.rb +++ b/app/controllers/settings/simple_menu_items_controller.rb @@ -1,15 +1,17 @@ class Settings::SimpleMenuItemsController < ApplicationController - before_action :set_settings_menu_item, only: [:show, :edit, :update, :destroy] - before_action :set_settings_menu_category, only: [:index, :show, :edit, :new] + before_action :set_settings_menu_item, only: [:show, :edit, :update, :destroy ] + before_action :set_settings_menu_category, only: [:index, :show, :edit, :new, :update ,:create] # GET /settings/menu_items # GET /settings/menu_items.json def index - @settings_menu_items = @category.menu_items + @settings_menu_items = @category.menu_items.page(params[:page]).per(10) end - + # GET /settings/menu_items/1 # GET /settings/menu_items/1.json def show + @sub_menu = MenuItem.where("menu_item_id=?",params[:id]).page(params[:page]).per(10) + @menu_item_instance = MenuItemInstance.where("menu_item_id=?",params[:id]).page(params[:page]).per(10) end # GET /settings/menu_items/new @@ -25,10 +27,13 @@ class Settings::SimpleMenuItemsController < ApplicationController # POST /settings/menu_items.json def create @settings_menu_item = MenuItem.new(settings_menu_item_params) - + if params[:simple_menu_item][:menu_item_id] == '' + @settings_menu_item.menu_category_id = params[:menu_category_id] + end + @settings_menu_item.created_by = current_login_employee.name respond_to do |format| if @settings_menu_item.save - format.html { redirect_to settings_menu_items_path, notice: 'Menu item was successfully created.' } + format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully created.' } format.json { render :show, status: :created, location: @settings_menu_item } else format.html { render :new } @@ -42,7 +47,7 @@ class Settings::SimpleMenuItemsController < ApplicationController def update respond_to do |format| if @settings_menu_item.update(settings_menu_item_params) - format.html { redirect_to settings_menu_item_path(@settings_menu_item), notice: 'Menu item was successfully updated.' } + format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully updated.' } format.json { render :show, status: :ok, location: @settings_menu_item } else format.html { render :edit } @@ -54,9 +59,9 @@ class Settings::SimpleMenuItemsController < ApplicationController # DELETE /settings/menu_items/1 # DELETE /settings/menu_items/1.json def destroy - @settings_menu_item.destroy + # @settings_menu_item.destroy respond_to do |format| - format.html { redirect_to settings_menu_items_path, notice: 'Menu item was successfully destroyed.' } + format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully destroyed.' } format.json { head :no_content } end end diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb new file mode 100644 index 00000000..ea9e8ccd --- /dev/null +++ b/app/controllers/transactions/sales_controller.rb @@ -0,0 +1,74 @@ +class Transactions::SalesController < ApplicationController + before_action :set_transactions_sale, only: [:show, :edit, :update, :destroy] + + # GET /transactions/sales + # GET /transactions/sales.json + def index + @transactions_sales = Sale.all + end + + # GET /transactions/sales/1 + # GET /transactions/sales/1.json + def show + end + + # GET /transactions/sales/new + def new + @transactions_sale = Sale.new + end + + # GET /transactions/sales/1/edit + def edit + end + + # POST /transactions/sales + # POST /transactions/sales.json + def create + @transactions_sale = Sale.new(transactions_sale_params) + + respond_to do |format| + if @transactions_sale.save + format.html { redirect_to @transactions_sale, notice: 'Sale was successfully created.' } + format.json { render :show, status: :created, location: @transactions_sale } + else + format.html { render :new } + format.json { render json: @transactions_sale.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /transactions/sales/1 + # PATCH/PUT /transactions/sales/1.json + def update + respond_to do |format| + if @transactions_sale.update(transactions_sale_params) + format.html { redirect_to @transactions_sale, notice: 'Sale was successfully updated.' } + format.json { render :show, status: :ok, location: @transactions_sale } + else + format.html { render :edit } + format.json { render json: @transactions_sale.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /transactions/sales/1 + # DELETE /transactions/sales/1.json + def destroy + @transactions_sale.destroy + respond_to do |format| + format.html { redirect_to transactions_sales_url, notice: 'Sale was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_transactions_sale + @transactions_sale = Sale.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def transactions_sale_params + params.require(:transactions_sale).permit(:cashier_id, :cashier_name, :requested_by, :requested_at, :receipt_no, :receipt_date, :customer_id, :payment_status, :sale_status, :total_amount, :total_discount, :total_tax, :tax_type, :grand_total, :rounding_adjustment, :amount_received, :amount_changed) + end +end diff --git a/app/helpers/oqs/print_helper.rb b/app/helpers/oqs/print_helper.rb new file mode 100644 index 00000000..8deee2c2 --- /dev/null +++ b/app/helpers/oqs/print_helper.rb @@ -0,0 +1,2 @@ +module Oqs::PrintHelper +end diff --git a/app/helpers/print_settings_helper.rb b/app/helpers/print_settings_helper.rb new file mode 100644 index 00000000..3e712d7c --- /dev/null +++ b/app/helpers/print_settings_helper.rb @@ -0,0 +1,2 @@ +module PrintSettingsHelper +end diff --git a/app/helpers/transactions/sales_helper.rb b/app/helpers/transactions/sales_helper.rb new file mode 100644 index 00000000..95aa5c87 --- /dev/null +++ b/app/helpers/transactions/sales_helper.rb @@ -0,0 +1,2 @@ +module Transactions::SalesHelper +end diff --git a/app/jobs/order_broadcast_job.rb b/app/jobs/order_broadcast_job.rb new file mode 100644 index 00000000..b29f4cd8 --- /dev/null +++ b/app/jobs/order_broadcast_job.rb @@ -0,0 +1,8 @@ +class OrderBroadcastJob < ApplicationJob + queue_as :default + + def perform(message) + order = Order.find(message) # message come as order_id + ApplicationCable.server.broadcast "order_queue_station_channel", order: order + end +end diff --git a/app/jobs/order_queue_processor_job.rb b/app/jobs/order_queue_processor_job.rb index 33380674..e9a8c13f 100644 --- a/app/jobs/order_queue_processor_job.rb +++ b/app/jobs/order_queue_processor_job.rb @@ -3,8 +3,9 @@ class OrderQueueProcessorJob < ApplicationJob def perform(order_id) # Do something later - #Order ID + #Order ID order = Order.find(order_id) + #Loop through the order stations and process the items #Execute orders and send to order stations if order diff --git a/app/models/menu.rb b/app/models/menu.rb index 44daca13..0c956a1e 100644 --- a/app/models/menu.rb +++ b/app/models/menu.rb @@ -1,8 +1,8 @@ class Menu < ApplicationRecord has_many :menu_categories, dependent: :destroy - validates_presence_of :name, :is_active, :valid_days, :valid_time_from, :valid_time_to - + validates_presence_of :name, :valid_days, :valid_time_from, :valid_time_to + validates_format_of :valid_days, :with => /\A([0-7]{1}(,[0-7]{1})*)?\Z/i #Default Scope to pull the active version only default_scope { where(is_active: true).order("created_at desc") } diff --git a/app/models/menu_item.rb b/app/models/menu_item.rb index 62d18424..e83c2eed 100644 --- a/app/models/menu_item.rb +++ b/app/models/menu_item.rb @@ -1,10 +1,12 @@ class MenuItem < ApplicationRecord + belongs_to :account belongs_to :menu_category, :optional => true has_many :menu_item_instances belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true has_many :children, :class_name => "MenuItem", foreign_key: "menu_item_id" - belongs_to :account - + + validates_presence_of :item_code, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item + default_scope { order('item_code asc') } def self.collection diff --git a/app/models/order.rb b/app/models/order.rb index 452db6c7..fb110e38 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -8,7 +8,6 @@ class Order < ApplicationRecord #internal references attributes for business logic control attr_accessor :items, :guest, :table_id, :new_booking, :booking_type, :employee_name, :booking_id - #Main Controller method to create new order - validate all inputs and generate new order # order_item : { # order_item_code : "", @@ -17,6 +16,7 @@ class Order < ApplicationRecord # option_values : [], # sub_order_items : [], # } + def generate booking = nil @@ -43,6 +43,9 @@ class Order < ApplicationRecord #Send order to queue one it done! process_order_queue + #send order to broadcast job + send_order_broadcast + return true, booking end @@ -202,6 +205,13 @@ class Order < ApplicationRecord OrderQueueProcessorJob.perform_later(self.id) end + + #send order items and send to order queue + def send_order_broadcast + #Send to background job for processing + OrderBroadcastJob.perform_later(self.id) + end + #Origami: Cashier : to view order type Table def self.get_order_table order_table = Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price, @@ -211,7 +221,7 @@ class Order < ApplicationRecord left join dining_facilities on dining_facilities.id = bookings.dining_facility_id left join order_items on order_items.order_id = orders.id") .where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,"dine_in",true) - .group("orders.id") + .group("orders.id") end #Origami: Cashier : to view order type Room def self.get_order_rooms diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index b2feb596..b0619af2 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,10 @@ 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) + AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) end end diff --git a/app/models/print_setting.rb b/app/models/print_setting.rb new file mode 100644 index 00000000..b715af52 --- /dev/null +++ b/app/models/print_setting.rb @@ -0,0 +1,2 @@ +class PrintSetting < ApplicationRecord +end diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index 4e520ed9..6a8a4b78 100644 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -1,22 +1,46 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker - def print_order_item(order_queue_id) + def print_order_item(printer_settings,order_id, item_code) #Use CUPS service #Generate PDF #Print - pdf = OrderItemPdf.new - pdf.render_file "tmp/order_item_queue_#{order_id}_#{order_item_id}" + ".pdf" + order_item= print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code) + pdf = OrderItemPdf.new(order_item[0],printer_settings) + pdf.render_file "tmp/receipt.pdf" self.print("tmp/receipt.pdf") end - def print_order_summary(booking_id) + def print_order_summary(printer_settings,booking_id) #Use CUPS service #Generate PDF #Print + order=print_query('booking',booking_id) filename = "tmp/order_summary_#{booking_id}" + ".pdf" - pdf = OrderSummaryPdf.new + pdf = OrderSummaryPdf.new(order,printer_settings) pdf.render_file filename self.print(filename) end + + # Query for OQS with status + def print_query(type, code) + if type == 'order_item' + OrderItem.select("order_items.item_code, order_items.item_name,order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.name as dining") + .joins("left join orders ON orders.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.id = bo.booking_id + left join dining_facilities AS df ON df.id = b.dining_facility_id + left join customers as cus ON cus.id = orders.customer_id") + .where("order_items.item_code=" + code) + .group("order_items.item_code") + else + OrderItem.select("order_items.item_code, order_items.item_name, df.name as dining") + .joins("left join orders ON orders.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.id = bo.booking_id + left join dining_facilities AS df ON df.id = b.dining_facility_id") + .where("booking.id=" + code) + end + + end end diff --git a/app/models/sale_discount.rb b/app/models/sale_discount.rb deleted file mode 100644 index 1d18c856..00000000 --- a/app/models/sale_discount.rb +++ /dev/null @@ -1,3 +0,0 @@ -class SaleDiscount < ApplicationRecord - belongs_to :sale -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/models/transactions.rb b/app/models/transactions.rb new file mode 100644 index 00000000..9cffb0d1 --- /dev/null +++ b/app/models/transactions.rb @@ -0,0 +1,5 @@ +module Transactions + def self.table_name_prefix + 'transactions_' + end +end diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index 76df37e2..356327b4 100644 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -5,14 +5,27 @@ class OrderItemPdf < Prawn::Document # font "public/fonts/#{font_name}".to_s + ".ttf".to_s # font "public/fonts/Zawgyi-One.ttf" - # font "public/fonts/padauk.ttf" - - + # font "public/fonts/padauk.ttf" font_size 9 - text "#{"table_name"}", :size => 15 + text "#{order_item.dining}", :size => 15 stroke_horizontal_rule move_down 5 + cashier_info(order_item.order_by,order_item.order_at, order_item.customer) + + end + + def cashier_info(order_by, order_at, customer) + move_down 5 + y_position = cursor + + bounding_box([0,y_position], :width =>200, :height => 20) do + text "OrderBy:#{order_by} Customer:#{customer} Date:#{order_at.strftime("%Y %m %d")}", :size => 7,:align => :left + end + + stroke_horizontal_rule + + move_down 5 end end diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index b73cc5ae..47c10ac9 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -1,8 +1,8 @@ -