diff --git a/.gitignore b/.gitignore index c29faad2..02338531 100644 --- a/.gitignore +++ b/.gitignore @@ -43,5 +43,5 @@ config/deploy/config/* .byebug_history # Gem files -Gemfile -Gemfile.lock \ No newline at end of file +#Gemfile +#Gemfile.lock diff --git a/Gemfile b/Gemfile index 08464196..f64229aa 100644 --- a/Gemfile +++ b/Gemfile @@ -9,13 +9,14 @@ 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' #Use PosgreSQL #gem 'pg' # redis server for cable -gem 'redis', '~> 3.0' +# gem 'redis', '~> 3.0' # Use Puma as the app server gem 'puma', '~> 3.0' @@ -59,6 +60,9 @@ gem 'bcrypt', '~> 3.1.7' gem 'sidekiq' +# Pagination +gem 'kaminari', :git => "git://github.com/amatsuda/kaminari.git", :branch => 'master' + # Use Capistrano for deployment # gem 'capistrano-rails', group: :development @@ -87,3 +91,5 @@ end # Windows does not include zoneinfo files, so bundle the tzinfo-data gem gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] + +gem 'httparty', '~> 0.15.5' \ No newline at end of file diff --git a/Gemfile.lock b/Gemfile.lock index 79a0d2f8..bd6f0991 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,6 +1,6 @@ GIT remote: git://github.com/amatsuda/kaminari.git - revision: c3c853a944cd2bff072ae05e48c563b2c9a29597 + revision: bc52ae73d41386d344b5d1b18e689e5a988f1a03 branch: master specs: kaminari (1.0.1) @@ -92,7 +92,9 @@ GEM railties (>= 3.2, < 5.2) globalid (0.4.0) activesupport (>= 4.2.0) - i18n (0.8.1) + httparty (0.15.5) + multi_xml (>= 0.5.2) + i18n (0.8.4) jbuilder (2.6.4) activesupport (>= 3.0.0) multi_json (>= 1.2) @@ -114,6 +116,9 @@ GEM mini_portile2 (2.1.0) minitest (5.10.2) multi_json (1.12.1) + + multi_xml (0.6.0) + mysql2 (0.4.6) nio4r (2.1.0) nokogiri (1.7.2) @@ -124,7 +129,7 @@ GEM ttfunk (~> 1.5) prawn-table (0.2.2) prawn (>= 1.3.0, < 3.0.0) - puma (3.8.2) + puma (3.9.1) rack (2.0.3) rack-cors (0.4.1) rack-protection (2.0.0) @@ -247,6 +252,7 @@ DEPENDENCIES factory_girl_rails (~> 4.0) faker font-awesome-rails + httparty (~> 0.15.5) jbuilder (~> 2.5) jquery-rails kaminari! @@ -257,7 +263,6 @@ DEPENDENCIES puma (~> 3.0) rack-cors rails (~> 5.1.0) - redis (~> 3.0) rspec-rails (~> 3.5) sass-rails (~> 5.0) schema_to_scaffold diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index 091b6822..7df365ec 100644 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -17,21 +17,77 @@ //= require cable $(document).ready(function(){ - $('.queue_station').on('click',function(){ - var title=$(this).children().children('.card-title').text(); - var titles=title.split(' '); + $('.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(); - 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-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(orderItem); + $('#order-qty').text(orderQty); - $('#order-items').text(titles[1]); - $('#order-qty').text(titles[2].substr(2).replace(']','')); + $('.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){ } + }); + }); + + $('#print_order_summary').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_order_summary/'+assigned_item_id, + success: function(data){ } + }); + }); }); diff --git a/app/assets/javascripts/origami/request_bills.coffee b/app/assets/javascripts/origami/request_bills.coffee new file mode 100644 index 00000000..24f83d18 --- /dev/null +++ b/app/assets/javascripts/origami/request_bills.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/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/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/application.scss b/app/assets/stylesheets/application.scss index 7aa6d6c5..9456be10 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -9,6 +9,29 @@ // 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; +} + /*----- Order Processing Items -----*/ .opi_ul { display:block; @@ -33,4 +56,4 @@ /*----- Header Bar -----*/ -/*----- Header Bar -----*/ \ No newline at end of file +/*----- Header Bar -----*/ diff --git a/app/assets/stylesheets/origami/request_bills.scss b/app/assets/stylesheets/origami/request_bills.scss new file mode 100644 index 00000000..20719090 --- /dev/null +++ b/app/assets/stylesheets/origami/request_bills.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the origami/RequestBills 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/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/scaffolds.scss b/app/assets/stylesheets/scaffolds.scss index e69de29b..60451880 100644 --- a/app/assets/stylesheets/scaffolds.scss +++ b/app/assets/stylesheets/scaffolds.scss @@ -0,0 +1,84 @@ +body { + background-color: #fff; + color: #333; + margin: 33px; + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; +} + +a { + color: #000; + + &:visited { + color: #666; + } + + &:hover { + color: #fff; + background-color: #000; + } +} + +th { + padding-bottom: 5px; +} + +td { + padding: 0 5px 7px; +} + +div { + &.field, &.actions { + margin-bottom: 10px; + } +} + +#notice { + color: green; +} + +.field_with_errors { + padding: 2px; + background-color: red; + display: table; +} + +#error_explanation { + width: 450px; + border: 2px solid red; + padding: 7px 7px 0; + margin-bottom: 20px; + background-color: #f0f0f0; + + h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px -7px 0; + background-color: #c00; + color: #fff; + } + + ul li { + font-size: 12px; + list-style: square; + } +} + +label { + display: block; +} diff --git a/app/controllers/api/bookings_controller.rb b/app/controllers/api/bookings_controller.rb index 8f10655f..401cd4a8 100644 --- a/app/controllers/api/bookings_controller.rb +++ b/app/controllers/api/bookings_controller.rb @@ -1,6 +1,5 @@ class Api::BookingsController < Api::ApiController - - + skip_before_action :authenticate #Show customer by ID def index @customer = Customer.find_by(params[:id]) diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index 607a7bef..df9b1542 100644 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -7,7 +7,10 @@ class Api::OrdersController < Api::ApiController order = Order.find(params[:order_id]) order.order_items end - + def get_order + order = Order.find(params[:order_id]) + order.order_items + end # Description # This API allow new order creation @@ -25,7 +28,7 @@ class Api::OrdersController < Api::ApiController @order = Order.new @order.source = params[:order_source] @order.order_type = params[:order_type] - @order.customer_id = params[:customer_id] + @order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile @order.items = params[:order_items] @order.guest = params[:guest_info] @order.table_id = params[:table_id] diff --git a/app/controllers/crm/bookings_controller.rb b/app/controllers/crm/bookings_controller.rb new file mode 100644 index 00000000..eeb19f75 --- /dev/null +++ b/app/controllers/crm/bookings_controller.rb @@ -0,0 +1,18 @@ +class Crm::BookingsController < ApplicationController + + def update_booking + booking = Booking.find(params[:booking_id]) + + + status = booking.update_attributes(booking_status: params[:type]) + + if status == true + render json: JSON.generate({:status => true ,:type => params[:type]}) + + else + render json: JSON.generate({:status => false, :error_message => "Record not found"}) + + end + end + +end diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 4e97faec..896d9d14 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -4,7 +4,7 @@ class Crm::CustomersController < ApplicationController # GET /crm/customers # GET /crm/customers.json def index - @crm_customers = Crm::Customer.all + @crm_customers = Customer.all end # GET /crm/customers/1 @@ -14,7 +14,8 @@ class Crm::CustomersController < ApplicationController # GET /crm/customers/new def new - @crm_customer = Crm::Customer.new + @crm_customer = Customer.new + @membership = Customer.get_member_group end # GET /crm/customers/1/edit @@ -24,7 +25,7 @@ class Crm::CustomersController < ApplicationController # POST /crm/customers # POST /crm/customers.json def create - @crm_customer = Crm::Customer.new(crm_customer_params) + @crm_customer = Customer.new(crm_customer_params) respond_to do |format| if @crm_customer.save @@ -64,7 +65,7 @@ class Crm::CustomersController < ApplicationController private # Use callbacks to share common setup or constraints between actions. def set_crm_customer - @crm_customer = Crm::Customer.find(params[:id]) + @crm_customer = Customer.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. diff --git a/app/controllers/crm/home_controller.rb b/app/controllers/crm/home_controller.rb index 2a7153f8..083f2bf7 100644 --- a/app/controllers/crm/home_controller.rb +++ b/app/controllers/crm/home_controller.rb @@ -1,22 +1,22 @@ class Crm::HomeController < BaseCrmController def index - # @booking = Booking.all - - @booking = Booking.select("bookings.id as booking_id, - bookings.checkin_at, - bookings.checkin_by, - bookings.dining_facility_id, - od.customer_id as customer, - od.item_count as count, - odt.id as order_item_id, - odt.item_name as item_name") - .joins("join booking_orders as bko ON bko.booking_id = bookings.id") - .joins("right join orders as od ON od.id = bko.order_id") - .joins("right join order_items as odt ON odt.order_id=od.id") - .order("bookings.id DESC") - + @booking = Booking.all @customer = Customer.all + + #@booking = Booking.select("bookings.id as booking_id, + # bookings.checkin_at, + # bookings.checkin_by, + # bookings.dining_facility_id, + # od.customer_id as customer, + # od.id as order_id, + # od.item_count as count, + # odt.id as order_item_id, + # odt.item_name as item_name") + # .joins("join booking_orders as bko ON bko.booking_id = bookings.id") + # .joins("right join orders as od ON od.id = bko.order_id") + # .joins("right join order_items as odt ON odt.order_id=od.id") + # .order("bookings.id DESC") end def show diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 0f73d20d..0c680624 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -1,31 +1,50 @@ class Oqs::HomeController < BaseOqsController def index - @queue_stations=OrderQueueStation.all + queue_stations=OrderQueueStation.all + + @queue_items_details = queue_items_query(0) - #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") + @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 - # Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price, - # order_items.id as order_items_id,dining_facilities.name as table_name") - # .joins("left join booking_orders on booking_orders.order_id = orders.id - # left join bookings on bookings.id = booking_orders.id - # 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") + @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.assigned_order_item_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.order_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.customer_id = od.customer_id") + .where("assigned_order_items.delivery_status = #{status}") + .group("assigned_order_items.assigned_order_item_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..1b48fae6 --- /dev/null +++ b/app/controllers/oqs/print_controller.rb @@ -0,0 +1,31 @@ +class Oqs::PrintController < ApplicationController + def print + unique_code="OrderItemPdf" + assigned_item_id=params[:id] + assigned_order_item=AssignedOrderItem.select("order_id, item_code").where('assigned_order_item_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 + + def print_order_summary + unique_code="OrderSummaryPdf" + assigned_item_id=params[:id] + assigned_order_item=AssignedOrderItem.select("order_id").where('assigned_order_item_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_summary(print_settings,assigned_order_item[0].order_id) + + # 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/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index cbca1424..18a5819c 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -1,15 +1,24 @@ class Origami::HomeController < BaseOrigamiController def index - @order_table = Order.get_order_table() - @order_rooms = Order.get_order_rooms() + @booking_orders = Order.get_booking_order_table() + @booking_rooms = Order.get_booking_order_rooms() @orders = Order.get_orders() end def show str = [] - @order_details = OrderItem.get_order_items_details(params[:order_id]) - @order_details.each do |ord_detail| - str.push(ord_detail) - end - render :json => str.to_json + + if !params[:sale_id].nil? + @order_details = SaleItem.get_order_items_details(params[:sale_id]) + @order_details.each do |ord_detail| + str.push(ord_detail) + end + render :json => str.to_json + else + @order_details = OrderItem.get_order_items_details(params[:order_id]) + @order_details.each do |ord_detail| + str.push(ord_detail) + end + render :json => str.to_json + end end end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb new file mode 100644 index 00000000..59039da8 --- /dev/null +++ b/app/controllers/origami/request_bills_controller.rb @@ -0,0 +1,27 @@ +class Origami::RequestBillsController < BaseOrigamiController + def show + @sale = Sale.new + + booking_id = params[:id] + check_booking = Booking.find_by_booking_id(booking_id) + if check_booking.sale_id.nil? + #check if it doesn't exist + @status = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee.name) + @sale_data = Sale.find_by_sale_id(check_booking.sale_id) + @sale_items = SaleItem.where("sale_id=?",check_booking.sale_id) + else + @sale_data = Sale.find_by_sale_id(check_booking.sale_id) + @sale_items = SaleItem.where("sale_id=?",check_booking.sale_id) + end + + unique_code="ReceiptBillPdf" + print_settings=PrintSetting.find_by_unique_code(unique_code) + + printer = Printer::ReceiptPrinter.new(print_settings) + + printer.print_receipt_bill(print_settings,@sale_items,@sale,@sale_data) + + + 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/accounts_controller.rb b/app/controllers/settings/accounts_controller.rb new file mode 100644 index 00000000..74f27c84 --- /dev/null +++ b/app/controllers/settings/accounts_controller.rb @@ -0,0 +1,73 @@ +class Settings::AccountsController < ApplicationController + before_action :set_account, only: [:show, :edit, :update, :destroy] + + # GET /settings/accounts + # GET /settings/accounts.json + def index + @settings_accounts = Account.all + end + + # GET /settings/accounts/1 + # GET /settings/accounts/1.json + def show + end + + # GET /settings/accounts/new + def new + @settings_account = Account.new + end + + # GET /settings/accounts/1/edit + def edit + end + + # POST /settings/accounts + # POST /settings/accounts.json + def create + @settings_account = Account.new(account_params) + respond_to do |format| + if @settings_account.save! + format.html { redirect_to settings_accounts_url, notice: 'Account was successfully created.' } + format.json { render :index, status: :created, location: @settings_account } + else + format.html { render :new } + format.json { render json: settings_accounts_url.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /settings/accounts/1 + # PATCH/PUT /settings/accounts/1.json + def update + respond_to do |format| + if @settings_account.update(account_params) + format.html { redirect_to settings_accounts_url, notice: 'Account was successfully updated.' } + format.json { render :index, status: :ok, location: @settings_account } + else + format.html { render :edit } + format.json { render json: settings_accounts_url.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /settings/accounts/1 + # DELETE /settings/accounts/1.json + def destroy + @settings_account.destroy + respond_to do |format| + format.html { redirect_to settings_accounts_url, notice: 'Account was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_account + @settings_account = Account.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def account_params + params.require(:account).permit(:title, :account_type) + end +end 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..f9c20a2d --- /dev/null +++ b/app/controllers/settings/menu_item_instances_controller.rb @@ -0,0 +1,116 @@ +class Settings::MenuItemInstancesController < ApplicationController + before_action :set_settings_menu_item_instance, only: [:show, :edit, :update, :destroy] + before_action :set_settings_menu_item, only: [ :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 + @category = MenuCategory.find(@item.menu_category_id) + end + + # GET /settings/menu_item_instances/new + def new + @category = MenuCategory.find(@item.menu_category_id) + @settings_menu_item_instances = MenuItemInstance.new + end + + # GET /settings/menu_item_instances/1/edit + def edit + @category = MenuCategory.find(@item.menu_category_id) + end + + # POST /settings/menu_item_instances + # POST /settings/menu_item_instances.json + def create + @settings_menu_item_instances = MenuItemInstance.new(settings_menu_item_instance_params) + + if params[:simple_menu_item_id] + @settings_menu_item_instances.menu_item_id = params[:simple_menu_item_id] + catID = MenuItem.find(params[:simple_menu_item_id]) + else + @settings_menu_item_instances.menu_item_id = params[:set_menu_item_id] + catID = MenuItem.find(params[:set_menu_item_id]) + end + + category = MenuCategory.find(catID.menu_category_id) + respond_to do |format| + if @settings_menu_item_instances.save + @settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].reject(&:blank?) + @settings_menu_item_instances.save + format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), notice: 'Menu item instance was successfully created.' } + format.json { render :show, status: :created, location: @settings_menu_item_instances } + else + format.html { render :new } + format.json { render json: @settings_menu_item_instances.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /settings/menu_item_instances/1 + # PATCH/PUT /settings/menu_item_instances/1.json + def update + puts "params[:menu_item_instance][:item_attributes]" + puts params[:menu_item_instance][:item_attributes] + if params[:simple_menu_item_id] + catID = MenuItem.find(params[:simple_menu_item_id]) + else + catID = MenuItem.find(params[:set_menu_item_id]) + end + category = MenuCategory.find(catID.menu_category_id) + respond_to do |format| + + if @settings_menu_item_instances.update(settings_menu_item_instance_params) + @settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].reject(&:blank?) + @settings_menu_item_instances.save + format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), notice: 'Menu item instance was successfully updated.' } + format.json { render :show, status: :ok, location: @settings_menu_item_instances } + else + format.html { render :edit } + format.json { render json: @settings_menu_item_instances.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_instances.destroy + if params[:simple_menu_item_id] + catID = MenuItem.find(params[:simple_menu_item_id]) + else + catID = MenuItem.find(params[:set_menu_item_id]) + end + category = MenuCategory.find(catID.menu_category_id) + respond_to do |format| + format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), 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 + @settings_menu_item_instances = MenuItemInstance.find(params[:id]) + end + + def set_settings_menu_item + if params[:simple_menu_item_id] + @item = MenuItem.find(params[:simple_menu_item_id]) + else + @item = MenuItem.find(params[:set_menu_item_id]) + end + 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, :item_attributes, :is_on_promotion, :promotion_price, :is_available,:menu_category_id,:menu_item_id) + + end +end diff --git a/app/controllers/settings/order_queue_stations_controller.rb b/app/controllers/settings/order_queue_stations_controller.rb index ec85e56a..46fcb54d 100644 --- a/app/controllers/settings/order_queue_stations_controller.rb +++ b/app/controllers/settings/order_queue_stations_controller.rb @@ -1,10 +1,10 @@ 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 def index - @settings_order_queue_stations = OrderQueueStation.all + @settings_order_queue_stations = OrderQueueStation.all.active end # GET /settings/order_queue_stations/1 @@ -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 } @@ -40,6 +40,7 @@ class Settings::OrderQueueStationsController < ApplicationController # PATCH/PUT /settings/order_queue_stations/1 # PATCH/PUT /settings/order_queue_stations/1.json def update + params[:order_queue_station][:processing_items] = params[:order_queue_station][:processing_items].split(/,/).inspect respond_to do |format| if @settings_order_queue_station.update(settings_order_queue_station_params) format.html { redirect_to settings_order_queue_station_path(@settings_order_queue_station), notice: 'Order queue station was successfully updated.' } diff --git a/app/controllers/settings/set_menu_items_controller.rb b/app/controllers/settings/set_menu_items_controller.rb index b488ac6f..f6771548 100644 --- a/app/controllers/settings/set_menu_items_controller.rb +++ b/app/controllers/settings/set_menu_items_controller.rb @@ -6,10 +6,14 @@ class Settings::SetMenuItemsController < ApplicationController def index @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 diff --git a/app/controllers/settings/simple_menu_items_controller.rb b/app/controllers/settings/simple_menu_items_controller.rb index 6b3c4bb4..e0d45fcb 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, :update] + 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.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 @@ -76,6 +78,6 @@ class Settings::SimpleMenuItemsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def settings_menu_item_params - params.require(:simple_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(:simple_menu_item).permit(:item_code, :name, :alt_name, :type, :menu_category_id,:item_attributes, :menu_item_id, :min_qty, :min_selectable_item, :max_selectable_item, :created_by) end end diff --git a/app/models/login_form.rb b/app/forms/login_form.rb similarity index 100% rename from app/models/login_form.rb rename to app/forms/login_form.rb diff --git a/app/forms/shop_form.rb b/app/forms/shop_form.rb new file mode 100644 index 00000000..19af84a5 --- /dev/null +++ b/app/forms/shop_form.rb @@ -0,0 +1,7 @@ +#Form object to use during the installation process - will handle creation of shop model into db after verification from the cloud +#provising service through license verification + +class ShopForm < ActiveModel + :attr_accessor :logo, :name, :address, :township, :city, :state, :country, :license, :base_currency, :password, :password_confirmation + +end diff --git a/app/helpers/crm/bookings_helper.rb b/app/helpers/crm/bookings_helper.rb new file mode 100644 index 00000000..2d775cd1 --- /dev/null +++ b/app/helpers/crm/bookings_helper.rb @@ -0,0 +1,2 @@ +module Crm::BookingsHelper +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/origami/request_bills_helper.rb b/app/helpers/origami/request_bills_helper.rb new file mode 100644 index 00000000..a33f7c3e --- /dev/null +++ b/app/helpers/origami/request_bills_helper.rb @@ -0,0 +1,2 @@ +module Origami::RequestBillsHelper +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/settings/accounts_helper.rb b/app/helpers/settings/accounts_helper.rb new file mode 100644 index 00000000..de8b6ad9 --- /dev/null +++ b/app/helpers/settings/accounts_helper.rb @@ -0,0 +1,2 @@ +module Settings::AccountsHelper +end diff --git a/app/jobs/order_broadcast_job.rb b/app/jobs/order_broadcast_job.rb index b29f4cd8..28a152ce 100644 --- a/app/jobs/order_broadcast_job.rb +++ b/app/jobs/order_broadcast_job.rb @@ -1,8 +1,9 @@ class OrderBroadcastJob < ApplicationJob queue_as :default - def perform(message) - order = Order.find(message) # message come as order_id + 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 e9a8c13f..eb298976 100644 --- a/app/jobs/order_queue_processor_job.rb +++ b/app/jobs/order_queue_processor_job.rb @@ -1,5 +1,5 @@ class OrderQueueProcessorJob < ApplicationJob - queue_as :default + queue_as :oqs def perform(order_id) # Do something later diff --git a/app/models/account.rb b/app/models/account.rb new file mode 100644 index 00000000..e1cdc6d3 --- /dev/null +++ b/app/models/account.rb @@ -0,0 +1,7 @@ +class Account < ApplicationRecord + validates_presence_of :title, :account_type + + has_many :menu_items + # belongs_to :lookup , :class_name => "Lookup" + +end diff --git a/app/models/assigned_order_item.rb b/app/models/assigned_order_item.rb index c2d2e8b0..ed8b0c82 100644 --- a/app/models/assigned_order_item.rb +++ b/app/models/assigned_order_item.rb @@ -1,4 +1,6 @@ class AssignedOrderItem < ApplicationRecord + before_create :generate_custom_id + belongs_to :order belongs_to :order_queue_station @@ -11,4 +13,9 @@ class AssignedOrderItem < ApplicationRecord assigned_order_item.delivery_status = false assigned_order_item.save end + + private + def generate_custom_id + self.assigned_order_item_id = SeedGenerator.generate_id(self.class.name, "AOI") + end end diff --git a/app/models/booking.rb b/app/models/booking.rb index c6a6452e..64eefbad 100644 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -1,8 +1,14 @@ class Booking < ApplicationRecord + before_create :generate_custom_id + #primary key - need to be unique belongs_to :dining_facility, :optional => true belongs_to :sale, :optional => true has_many :booking_orders + has_many :orders, :through => :booking_orders - + private + def generate_custom_id + self.booking_id = SeedGenerator.generate_id(self.class.name, "BKI") + end end diff --git a/app/models/booking_order.rb b/app/models/booking_order.rb index c0883967..c9f748f0 100644 --- a/app/models/booking_order.rb +++ b/app/models/booking_order.rb @@ -1,4 +1,6 @@ class BookingOrder < ApplicationRecord + #primary key - need to be unique + belongs_to :booking belongs_to :order end diff --git a/app/models/cashier_login_log.rb b/app/models/cashier_login_log.rb index d64860ce..353e9c90 100644 --- a/app/models/cashier_login_log.rb +++ b/app/models/cashier_login_log.rb @@ -1,4 +1,11 @@ class CashierLoginLog < ApplicationRecord + before_create :generate_custom_id + belongs_to :cashier_station belongs_to :employee + + private + def generate_custom_id + self.cashier_login_log_id = SeedGenerator.generate_id(self.class.name, "CLO") + end end diff --git a/app/models/customer.rb b/app/models/customer.rb index 42247791..625e8fb2 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -1,4 +1,8 @@ class Customer < ApplicationRecord + + #self.primary_key = :customer_id + + before_create :generate_custom_id has_many :orders has_many :sales @@ -8,4 +12,9 @@ class Customer < ApplicationRecord def lastest_invoices sales.where(:customer_id => self.id).order("created_at desc").limit(5) end + + private + def generate_custom_id + self.customer_id = SeedGenerator.generate_id(self.class.name, "CUS") + end end diff --git a/app/models/lookup.rb b/app/models/lookup.rb index 1784b7a7..e1b141df 100644 --- a/app/models/lookup.rb +++ b/app/models/lookup.rb @@ -1,4 +1,6 @@ class Lookup < ApplicationRecord + + has_many :accounts def available_types {'Employee Roles' => 'employee_roles', diff --git a/app/models/menu_item.rb b/app/models/menu_item.rb index 70528e83..40c80ad6 100644 --- a/app/models/menu_item.rb +++ b/app/models/menu_item.rb @@ -1,11 +1,19 @@ 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" + validates_presence_of :item_code, :name, :type, :min_qty, :taxable, :min_selectable_item, :max_selectable_item + default_scope { order('item_code asc') } + scope :simple_menu_item, -> { where(type: 'SimpleMenuItem') } + scope :set_menu_item, -> { where(type: 'SetMenuItem') } + def self.collection MenuItem.select("id, name").map { |e| [e.name, e.id] } end diff --git a/app/models/menu_item_attribute.rb b/app/models/menu_item_attribute.rb index ebaa060e..a2fd0d1c 100644 --- a/app/models/menu_item_attribute.rb +++ b/app/models/menu_item_attribute.rb @@ -1,4 +1,6 @@ class MenuItemAttribute < ApplicationRecord validates_presence_of :attribute_type, :name, :value - + def self.collection + MenuItemAttribute.select("id, name").map { |e| [e.name, e.id] } + end end diff --git a/app/models/order.rb b/app/models/order.rb index 4bbe4a28..68e13fc6 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -1,4 +1,6 @@ class Order < ApplicationRecord + #primary key - need to be unique + before_create :generate_custom_id before_create :set_order_date belongs_to :customer @@ -16,14 +18,14 @@ class Order < ApplicationRecord # option_values : [], # sub_order_items : [], # } - + def generate booking = nil if self.new_booking booking = Booking.create({:dining_facility_id => self.table_id,:type => "TableBooking", :checkin_at => Time.now.utc, :checkin_by => self.employee_name, - :booking_status => "new" }) + :booking_status => "assign" }) else if (self.booking_id.to_i > 0 ) booking = Booking.find(self.booking_id) @@ -38,7 +40,7 @@ class Order < ApplicationRecord self.adding_line_items #Add Order Table and Room relation afrer order creation - BookingOrder.create({:booking_id => booking.id, :order => self}) + BookingOrder.create({:booking_id => booking.booking_id, :order => self}) #Send order to queue one it done! process_order_queue @@ -180,14 +182,6 @@ class Order < ApplicationRecord return new_items_list end - private - def validate_api_inputs - - end - - def set_order_date - self.date = Time.now.utc - end #Update Items Count and Quantity changes whenever there is changes def update_products_and_quantity_count @@ -196,7 +190,7 @@ class Order < ApplicationRecord # Count number of different items self.item_count = self.order_items.item_count self.quantity_count = quantity_count - # Counter number of quantity + # Counter number of quantityf end #Process order items and send to order queue @@ -213,36 +207,75 @@ class Order < ApplicationRecord 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, - order_items.id as order_items_id,dining_facilities.name as table_name") - .joins("left join booking_orders on booking_orders.order_id = orders.id - left join bookings on bookings.id = booking_orders.id - 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") + + def self.get_booking_order_table + booking_orders = Booking.select("sales.receipt_no,orders.status as order_status, + bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") + .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") + .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") + .joins("left join orders on orders.order_id = booking_orders.order_id") + .joins("left join sale_orders on sale_orders.order_id = orders.order_id") + .joins("left join sales on sales.sale_id = sale_orders.sale_id") + .where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true) + .group("bookings.booking_id") + + end + #Origami: Cashier : to view order type Room + def self.get_booking_order_rooms + booking_rooms = Booking.select("sales.receipt_no,orders.status as order_status,bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as room_name") + .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") + .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") + .joins("left join orders on orders.order_id = booking_orders.order_id") + .joins("left join sale_orders on sale_orders.order_id = orders.order_id") + .joins("left join sales on sales.sale_id = sale_orders.sale_id") + .where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true) + .group("bookings.booking_id") end #Origami: Cashier : to view order type Room def self.get_order_rooms - order_rooms = Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price, + order_rooms = Order.select("orders.order_id as order_id,sum(order_items.qty*order_items.price) as total_price, order_items.id as order_items_id,dining_facilities.name as room_name") - .joins("left join booking_orders on booking_orders.order_id = orders.id - left join bookings on bookings.id = booking_orders.id + .joins("left join booking_orders on booking_orders.order_id = orders.order_id + left join bookings on bookings.booking_id = booking_orders.order_id left join dining_facilities on dining_facilities.id = bookings.dining_facility_id - left join order_items on order_items.order_id = orders.id") + left join order_items on order_items.order_id = orders.order_id") .where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,"dine_in",true) - .group("orders.id") + .group("orders.order_id,order_items.id,dining_facilities.name") + end #Origami: Cashier : to view orders def self.get_orders - orders = Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price, - order_items.id as order_items_id,dining_facilities.name as table_or_room_name") - .joins("left join booking_orders on booking_orders.order_id = orders.id - left join bookings on bookings.id = booking_orders.id + from = Time.now.beginning_of_day.utc + to = Time.now.end_of_day.utc + orders = Order.select("orders.order_id as order_id,sales.receipt_no,orders.status as order_status,bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") + .joins("left join booking_orders on booking_orders.order_id = orders.order_id + left join bookings on bookings.booking_id = booking_orders.order_id 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.is_active=?",true) - .group("orders.id") + + left join order_items on order_items.order_id = orders.order_id + left join sale_orders on sale_orders.order_id = orders.order_id + left join sales on sales.sale_id = sale_orders.sale_id") + .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) + .group("orders.order_id") + + # Booking.select("sales.receipt_no,orders.status as order_status,bookings.booking_id,sales.sale_id as sale_id,dining_facilities.name as table_name") + # .joins("left join booking_orders on booking_orders.booking_id = bookings.booking_id") + # .joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id") + # .joins("left join orders on orders.order_id = booking_orders.order_id") + # .joins("left join sale_orders on sale_orders.order_id = orders.order_id") + # .joins("left join sales on sales.sale_id = sale_orders.sale_id") + # .where("booking_orders.order_id IS NOT NULL and dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) + # .group("orders.order_id") + end + + + + private + def generate_custom_id + self.order_id = SeedGenerator.generate_id(self.class.name, "ODR") + end + + def set_order_date + self.date = Time.now.utc end end diff --git a/app/models/order_item.rb b/app/models/order_item.rb index f839ad99..039aa406 100644 --- a/app/models/order_item.rb +++ b/app/models/order_item.rb @@ -1,4 +1,7 @@ class OrderItem < ApplicationRecord + #primary key - need to be unique + before_create :generate_custom_id + #Associations belongs_to :order, autosave: true @@ -34,9 +37,23 @@ class OrderItem < ApplicationRecord end #Origami : Cashier : to show order items details - def self.get_order_items_details(order_id) - order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price") - .joins("left join orders on orders.id = order_items.order_id") - .where("order_items.order_id=?",order_id) + + def self.get_order_items_details(booking_id) + booking_orders = BookingOrder.where("booking_id=?",booking_id) + if booking_orders + booking_orders.each do |book_order| + order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price") + .joins("left join orders on orders.order_id = order_items.order_id") + .where("order_items.order_id=?",book_order.order) + return order_details + end + else + return false + end + end + + private + def generate_custom_id + self.order_items_id = SeedGenerator.generate_id(self.class.name, "ODI") 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..3428bb98 100644 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -1,22 +1,48 @@ 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,order_id) #Use CUPS service #Generate PDF #Print - filename = "tmp/order_summary_#{booking_id}" + ".pdf" - pdf = OrderSummaryPdf.new + order=print_query('order_summary',order_id) + filename = "tmp/order_summary_#{order_id}" + ".pdf" + 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.qty, order_items.price, 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.order_id = order_items.order_id + left join booking_orders AS bo ON bo.order_id=order_items.order_id + left join bookings AS b ON b.booking_id = bo.booking_id + left join dining_facilities AS df ON df.dining_facility_id = b.dining_facility_id + left join customers as cus ON cus.customer_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, order_items.qty, order_items.price, 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.order_id = order_items.order_id + left join booking_orders AS bo ON bo.order_id=order_items.order_id + left join bookings AS b ON b.booking_id = bo.booking_id + left join dining_facilities AS df ON df.dining_facility_id = b.dining_facility_id + left join customers as cus ON cus.customer_id = orders.customer_id") + .where("orders.order_id=" + code.to_s) + .group("order_items.item_code") + end + + end end diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 521b87e0..86d43190 100644 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -63,4 +63,13 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker self.print(filename) end +#Bill Receipt Print + def print_receipt_bill(printer_settings,sale_items,sale,sale_data) + #Use CUPS service + #Generate PDF + #Print + pdf = ReceiptBillPdf.new(printer_settings,sale_items,sale,sale_data) + pdf.render_file "tmp/receipt_bill.pdf" + self.print("tmp/receipt_bill.pdf") + end end diff --git a/app/models/room_booking.rb b/app/models/room_booking.rb index fb7c0dac..7efa52cb 100644 --- a/app/models/room_booking.rb +++ b/app/models/room_booking.rb @@ -1,3 +1,4 @@ class RoomBooking < Booking - + has_many :orders + end diff --git a/app/models/sale.rb b/app/models/sale.rb index 37819c9b..ec4831e5 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -1,4 +1,6 @@ class Sale < ApplicationRecord + #primary key - need to be unique generated for multiple shops + before_create :generate_custom_id #before_create :generate_receipt_no belongs_to :cashier, :optional => true belongs_to :customer, :optional => true @@ -20,9 +22,9 @@ class Sale < ApplicationRecord #get all order attached to this booking and combine into 1 invoice booking.booking_orders.each do |order| if booking.sale_id - status, sale_id = generate_invoice_from_order(order.order_id, nil, requested_by) + status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by) else - status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, requested_by) + status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, booking, requested_by) end booking.sale_id = sale_id end @@ -31,7 +33,7 @@ class Sale < ApplicationRecord end end - def generate_invoice_from_order (order_id, sale_id, requested_by) + def generate_invoice_from_order (order_id, sale_id, booking, requested_by) taxable = true #if sale_id is exsit and validate #add order to that invoice @@ -62,8 +64,8 @@ class Sale < ApplicationRecord add_item(item) end - link_order_sale(order.id) - + link_order_sale(order.id) + end @@ -73,6 +75,11 @@ class Sale < ApplicationRecord #Update the order items that is billed order.update_items_status_to_billed(nil) + order.status = "billed" + order.save + + booking.sale_id = self.id + booking.save return true, self.id end @@ -188,7 +195,8 @@ class Sale < ApplicationRecord sale_tax.tax_name = tax.name sale_tax.tax_rate = tax.rate #include or execulive - sale_tax.tax_payable_amount = total_taxable * tax.rate + # sale_tax.tax_payable_amount = total_taxable * tax.rate + sale_tax.tax_payable_amount = total_taxable * tax.rate / 100 #new taxable amount total_taxable = total_taxable + sale_tax.tax_payable_amount @@ -239,4 +247,8 @@ class Sale < ApplicationRecord end end + private + def generate_custom_id + self.sale_id = SeedGenerator.generate_id(self.class.name, "SAL") + end end diff --git a/app/models/sale_audit.rb b/app/models/sale_audit.rb index 15fee460..4ace962d 100644 --- a/app/models/sale_audit.rb +++ b/app/models/sale_audit.rb @@ -1,4 +1,6 @@ class SaleAudit < ApplicationRecord + #primary key - need to be unique generated for multiple shops + belongs_to :sale def record_audit_void(sale_id, void_by, approved_by, reason) @@ -48,4 +50,9 @@ class SaleAudit < ApplicationRecord sale_audit.remark = remark sale_audit.save! end + + private + def generate_custom_id + self.sale_audit_id = SeedGenerator.generate_id(self.class.name, "SAI") + end end diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index 82b20237..254e8b8b 100644 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -1,7 +1,31 @@ class SaleItem < ApplicationRecord + #primary key - need to be unique generated for multiple shops + before_create :generate_custom_id + belongs_to :sale #compute items - discount, tax, price_change def compute_item end + + + def self.get_order_items_details(sale_id) + sale_orders = SaleOrder.where("sale_id=?",sale_id) + if sale_orders + sale_orders.each do |sale_order| + order_details = SaleItem.select("sales.total_discount as discount_amount,DATE_FORMAT(sales.receipt_date,'%Y-%m-%d %h:%m') as receipt_date,sales.cashier_name,sales.receipt_no,sale_items.product_name as item_name,sale_items.qty,sale_items.price,sale_items.unit_price as total_price") + .joins("left join sales on sales.id = sale_items.sale_id") + .where("sale_items.sale_id=?",sale_order.sale_id) + return order_details + end + else + return false + end + end + + private + def generate_custom_id + self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI") + + end end diff --git a/app/models/sale_order.rb b/app/models/sale_order.rb index 7a27f5a3..ba39234b 100644 --- a/app/models/sale_order.rb +++ b/app/models/sale_order.rb @@ -1,4 +1,12 @@ class SaleOrder < ApplicationRecord +#primary key - need to be unique generated for multiple shops + before_create :generate_custom_id + belongs_to :sale belongs_to :order + + private + def generate_custom_id + self.sale_order_id = SeedGenerator.generate_id(self.class.name, "SOI") + end end diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 71793f4c..76d2869a 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -1,4 +1,7 @@ class SalePayment < ApplicationRecord + #primary key - need to be unique generated for multiple shops + before_create :generate_custom_id + belongs_to :sale :attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status @@ -154,4 +157,8 @@ class SalePayment < ApplicationRecord end + private + def generate_custom_id + self.sale_payment_id = SeedGenerator.generate_id(self.class.name, "SPI") + end end diff --git a/app/models/sale_tax.rb b/app/models/sale_tax.rb index cb3fae0b..2eb24312 100644 --- a/app/models/sale_tax.rb +++ b/app/models/sale_tax.rb @@ -1,3 +1,10 @@ class SaleTax < ApplicationRecord +#primary key - need to be unique generated for multiple shops + before_create :generate_custom_id belongs_to :sale + + private + def generate_custom_id + self.sale_tax_id = SeedGenerator.generate_id(self.class.name, "STI") + end end diff --git a/app/models/seed_generator.rb b/app/models/seed_generator.rb index 573e0ff6..5e7864b6 100644 --- a/app/models/seed_generator.rb +++ b/app/models/seed_generator.rb @@ -1,4 +1,26 @@ class SeedGenerator < ApplicationRecord + def self.generate_id(model, prefix) + seed = SeedGenerator.find_by_model(model) + new_receipt_no = 0 + if (seed.nil?) + seed = SeedGenerator.new() + seed.model = model + new_receipt_no = seed.next + seed.save + + else + current_no = seed.next + seed.next = seed.next + seed.increase_by + seed.current = current_no + seed.save + end + + padding_len = 15 - prefix.length + + return prefix +"-"+ seed.current.to_s.to_s.rjust((14-prefix.length)+1,'0') + + end + def self.new_receipt_no seed = SeedGenerator.find_by_model("sale") new_receipt_no = 0 diff --git a/app/models/shop.rb b/app/models/shop.rb new file mode 100644 index 00000000..1cf1119c --- /dev/null +++ b/app/models/shop.rb @@ -0,0 +1,2 @@ +class Shop < ApplicationRecord +end diff --git a/app/models/test.rb b/app/models/test.rb deleted file mode 100644 index fe0afa77..00000000 --- a/app/models/test.rb +++ /dev/null @@ -1,2 +0,0 @@ -class Test < ApplicationRecord -end diff --git a/app/models/transactions.rb b/app/models/transactions.rb deleted file mode 100644 index 9cffb0d1..00000000 --- a/app/models/transactions.rb +++ /dev/null @@ -1,5 +0,0 @@ -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..3044c578 100644 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -5,14 +5,67 @@ 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 + #order_info + order_info(order_item.order_by,order_item.order_at, order_item.customer) + + # order items + order_items(order_item) + end + + # Write Order Information to PDF + def order_info(order_by, order_at, customer) + y_position = cursor + + bounding_box([0,y_position], :width => 200, :height => 15) do + text "OrderBy:#{order_by} Customer:#{customer} Date:#{order_at.strftime("%Y-%m-%d")}", :size => 7,:align => :left + end + + stroke_horizontal_rule + + move_down 20 + end + + # Write Order items to PDF + def order_items(order_item) + y_position = cursor + + bounding_box([0,y_position], :width => 180, :height => 15) do + text "Item", :size => 7,:align => :left + end + + bounding_box([160,y_position], :width => 20, :height => 15) do + text "Qty", :size => 7,:align => :right + end + + stroke_horizontal_rule + move_down 5 + + #Add Order Item + add_order_items(order_item) + end + + # Add order items under order info + def add_order_items(order_item) + y_position = cursor + + move_down 5 + + bounding_box([0,y_position], :width => 180, :height => 20) do + text "#{order_item.item_name}", :size => 7,:align => :left + end + + bounding_box([160,y_position], :width => 20, :height => 20) do + text "#{order_item.qty}", :size => 7,:align => :right + end + + move_down 5 + end end diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index 8b79b40e..8a7a1ad9 100644 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -7,11 +7,68 @@ class OrderSummaryPdf < Prawn::Document # font "public/fonts/Zawgyi-One.ttf" # font "public/fonts/padauk.ttf" - font_size 9 - text "#{"table_name"}", :size => 15 + text "#{order[0].dining}", :size => 15 stroke_horizontal_rule move_down 5 + #order_info + order_info(order[0].order_by,order[0].order_at, order[0].customer) + + # order items + order_items(order) + + end + + # Write Order Information to PDF + def order_info(order_by, order_at, customer) + y_position = cursor + + bounding_box([0,y_position], :width => 200, :height => 15) do + text "OrderBy:#{order_by} Customer:#{customer} Date:#{order_at.strftime("%Y-%m-%d")}", :size => 7,:align => :left + end + + stroke_horizontal_rule + + move_down 20 + end + + # Write Order items to PDF + def order_items(order_item) + y_position = cursor + + bounding_box([0,y_position], :width => 180, :height => 15) do + text "Item", :size => 7,:align => :left + end + + bounding_box([160,y_position], :width => 20, :height => 15) do + text "Qty", :size => 7,:align => :right + end + + stroke_horizontal_rule + move_down 5 + + #Add Order Item + add_order_items(order_item) + end + + # Add order items under order info + def add_order_items(order_item) + y_position = cursor + + move_down 5 + + order_item.each do|odi| + bounding_box([0,y_position], :width => 180, :height => 20) do + text "#{odi.item_name}", :size => 7,:align => :left + end + + bounding_box([160,y_position], :width => 20, :height => 20) do + text "#{odi.qty}", :size => 7,:align => :right + end + end + + move_down 5 + end end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb new file mode 100644 index 00000000..ffce7da2 --- /dev/null +++ b/app/pdf/receipt_bill_pdf.rb @@ -0,0 +1,177 @@ +class ReceiptBillPdf < Prawn::Document + attr_accessor :receipt_width,:price_column_width,:p_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_column_width,:item_description_width + def initialize(printer_settings, sale_items,sale, sale_data) + self.p_width = 200 + self.page_height = 1450 + self.margin = 10 + # self.price_width = self.p_width / 2 + self.price_width=80 + self.item_width = self.p_width - self.price_width + self.item_height = self.item_height + self.qty_column_width = self.p_width / 2 + self.item_description_width=self.p_width - self.price_width + self.receipt_width=130 + + @item_width = self.p_width.to_i / 2 + @qty_width = @item_width.to_i / 3 + @double = @qty_width * 1.3 + @half_qty = @qty_width / 2 + #setting page margin and width + super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.p_width, self.page_height]) + self.header_font_size = 10 + self.item_font_size = 6 + + header( printer_settings.printer_name, printer_settings.name) + stroke_horizontal_rule + cashier_info(sale.receipt_no,sale.customer, sale.receipt_date) + line_items(sale_items) + all_total(sale_data) + + + end + + def header (printer_name, name) + text "#{printer_name}", :size => self.header_font_size,:align => :center + move_down 5 + text "#{name}", :size => self.header_font_size,:align => :center + # move_down self.item_height + move_down 5 + + stroke_horizontal_rule + + end + + def cashier_info(receipt_no, customer, receipt_date) + move_down 5 + move_down 2 + y_position = cursor + bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do + text "Receipt No:", :size => self.item_font_size,:align => :left + end + + bounding_box([self.price_width, y_position], :width =>self.receipt_width) do + text "#{receipt_no}" , :size => self.item_font_size, :align => :left + end + move_down 5 + + y_position = cursor + bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do + text "Customer:", :size => self.item_font_size,:align => :left + end + bounding_box([self.price_width,y_position], :width =>self.price_width) do + text "#{customer}" , :size => self.item_font_size,:align => :left + end + move_down 5 + + y_position = cursor + bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do + text "Date:", :size => self.item_font_size,:align => :left + end + bounding_box([self.price_width,y_position], :width =>self.price_width) do + text "#{receipt_date}" , :size => self.item_font_size,:align => :left + end + # stroke_horizontal_rule + move_down 5 + end + + def line_items(sale_items) + y_position = cursor + qty_column_width = self.p_width * 0.2 + item_description_width = self.p_width * 0.5 + price_column_width = self.p_width * 0.3 + + + + stroke_horizontal_rule + move_down 5 + y_position = cursor + pad_top(15) { + # @item_width.to_i + @half_qty.to_i + text_box "Items", :at =>[0,y_position], :width => @item_width.to_i - @half_qty.to_i , :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size + text_box "Price", :at =>[@item_width.to_i - @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right + text_box "Qty", :at =>[@item_width.to_i-@qty_width,y_position], :width => @half_qty, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right + text_box "Total", :at =>[@item_width.to_i + @half_qty.to_i,y_position], :width => @double, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right + + } + + move_down 5 + stroke_horizontal_rule + + add_line_item_row(sale_items) + + + end + + def add_line_item_row(sale_items) + y_position = cursor + move_down 5 + sub_total = 0.0 + sale_items.each do |item| + + sub_total += item.qty*item.unit_price + qty = item.qty + total_price = item.qty*item.unit_price + price = item.unit_price + product_name = item.product_name + + + y_position = cursor + + pad_top(15) { + # @item_width.to_i + @half_qty.to_i + text_box "#{product_name}", :at =>[0,y_position], :width => @item_width.to_i - @half_qty.to_i , :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size + text_box "#{price}", :at =>[@item_width.to_i - @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right + text_box "#{qty.to_i}", :at =>[@item_width.to_i-@qty_width,y_position], :width => @half_qty, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right + text_box "#{total_price}", :at =>[@item_width.to_i + @half_qty.to_i,y_position], :width => @double, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right + + } + move_down 3 + end + stroke_horizontal_rule + move_down 5 + y_position = cursor + bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do + text "Sub Total", :size => self.item_font_size,:align => :left + end + bounding_box([self.price_width,y_position], :width =>self.price_width) do + text "#{sub_total}" , :size => self.item_font_size,:align => :right + end + end + + def all_total(sale_data) + + move_down 5 + y_position =cursor + + bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do + text "Discount", :size => self.item_font_size,:align => :left + end + bounding_box([self.price_width,y_position], :width =>self.price_width) do + text "( " +"#{sale_data.total_discount}" +" )" , :size => self.item_font_size,:align => :right + end + + move_down 5 + y_position =cursor + + bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do + text "Total Tax", :size => self.item_font_size,:align => :left + end + bounding_box([self.price_width,y_position], :width =>self.price_width) do + text "( " +"#{sale_data.total_tax}" +" )" , :size => self.item_font_size,:align => :right + end + + move_down 5 + y_position = cursor + move_down 5 + bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do + text "Grand Total", :size => self.item_font_size,:align => :left + end + bounding_box([self.price_width,y_position], :width =>self.price_width) do + text "#{sale_data.grand_total}" , :size => self.item_font_size,:align => :right + end + move_down 5 + # stroke_horizontal_rule + + end + +end diff --git a/app/views/api/bookings/show.json.jbuilder b/app/views/api/bookings/show.json.jbuilder index d579810c..cbd1575a 100644 --- a/app/views/api/bookings/show.json.jbuilder +++ b/app/views/api/bookings/show.json.jbuilder @@ -1,7 +1,9 @@ if (@booking) - json.id @booking.id + json.id @booking.booking_id json.status @booking.booking_status json.checkin_at @booking.checkin_at + json.checkin_by @booking.checkin_by + json.table_name @booking.dining_facility.name if @booking.type == "TableBooking" json.table_id @booking.dining_facility_id @@ -10,7 +12,8 @@ if (@booking) end @total_amount = 0.00 @total_tax = 0.00 - + + @booking_orders = BookingOrder.where("booking_id = #{@booking.booking_id}").all; if @booking.booking_orders order_items = [] @booking.booking_orders.each do |bo| diff --git a/app/views/crm/customers/_form.html.erb b/app/views/crm/customers/_form.html.erb index c5adac88..7c37a2fe 100644 --- a/app/views/crm/customers/_form.html.erb +++ b/app/views/crm/customers/_form.html.erb @@ -1,4 +1,5 @@ -<%= simple_form_for(@crm_customer) do |f| %> + +<%= simple_form_for([:crm,@crm_customer]) do |f| %> <%= f.error_notification %>
Medium, Fries, Salad -
-- - Order at <%= booking.checkin_at.strftime("%H,%m") %>, <%= booking.checkin_by %> - -
-+ + Order at <%= booking.checkin_at.strftime("%H,%m") %>, <%= booking.checkin_by %> + +
+Well Done, Fries, Salad
-- Order at 12:23, Kyaw Lwin | - Printed at 12:23 | - Completed at 12:43 -
- - -Well Done, Fries, Salad
-Order at 12:23, Kyaw Lwin
-Well Done, Fries, Salad
-Order at 12:23, Kyaw Lwin
-+ + Order at <%= booking.checkin_at.strftime("%H,%m") %>, <%= booking.checkin_by %> + +
+