diff --git a/Dockerfile b/Dockerfile index 02daa8b6..a3e46f4d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,8 @@ FROM ruby:2.4.1 RUN apt-get update -qq && apt-get install -y build-essential libmysqlclient-dev libcups2-dev libpq-dev nodejs RUN mkdir /sxrestaurant RUN mkdir -p /sxrestaurant/tmp/puma -ENV RAILS_ENV production +ENV RAILS_ENV staging +ENV RACK_ENV staging WORKDIR /sxrestaurant COPY Gemfile /sxrestaurant/Gemfile COPY Gemfile.lock /sxrestaurant/Gemfile.lock @@ -10,4 +11,5 @@ RUN bundle install --without development test RUN echo "Asia/Rangoon" > /etc/timezone RUN dpkg-reconfigure -f noninteractive tzdata COPY . /sxrestaurant -RUN bundle exec rails assets:precompile +RUN bundle exec rake assets:precompile +CMD ["bundle", "exec", "puma", "-C", "config/puma.rb"] \ No newline at end of file diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index 5e866699..378ae434 100755 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -26,6 +26,21 @@ $(document).on('turbolinks:load', function() { var oqs_id = ""; + + if ($('.oqs_click').val()>0) { + $(".oqs_click").removeClass('oqs_active'); + $(".queue_station").removeClass('queue_station_box'); + $("#completed").addClass('hide'); + $(".oqs_append").removeClass('hide'); + $("#oqs_active").addClass('oqs_active'); + $(".queue_station").addClass('queue_station_box'); + // oqs_id = $(this).find(".oqs-id").text(); + $("#oqs_active").attr('data-id',$('.oqs_click').val()); + var url = 'oqs/get_items/'+$('.oqs_click').val(); + + show_details(url,null); + } + $(".nav-completed").on("click", function(){ $("#completed").removeClass('hide') $(".oqs_append").addClass('hide') @@ -339,12 +354,16 @@ $(document).on('turbolinks:load', function() { var assigned_item_id = $('.selected-item').children('.card-block').children('.assigned-order-item').text(); var options = $('.selected-item').children('.card-block').find('.item-options').text(); var params = { 'options':options }; - $.ajax({ - type: 'POST', + type: 'GET', url: '/oqs/print/print/'+assigned_item_id, data: params, - success: function(data){ } + success: function(result){ + // For Server Print - from jade + if ($("#server_mode").val() == "cloud") { + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } + } }); }); @@ -359,7 +378,12 @@ $(document).on('turbolinks:load', function() { type: 'GET', url: '/oqs/print/print_order_summary/'+assigned_item_id, data: params, - success: function(data){ } + success: function(result){ + // For Server Print - from jade + if ($("#server_mode").val() == "cloud") { + code2lab.printFile(result.filepath.substr(6), result.printer_url); + } + } }); }); }); diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 48e686b6..be896f1e 100755 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -11,7 +11,7 @@ class Oqs::HomeController < BaseOqsController @filter = params[:filter] - @queue_stations = OrderQueueStation.all + @queue_stations = OrderQueueStation.active @queue_completed_item = completed_order(@filter) if !@queue_completed_item.empty? diff --git a/app/controllers/oqs/print_controller.rb b/app/controllers/oqs/print_controller.rb index fc65f2da..6a59025e 100755 --- a/app/controllers/oqs/print_controller.rb +++ b/app/controllers/oqs/print_controller.rb @@ -2,7 +2,7 @@ class Oqs::PrintController < ApplicationController authorize_resource :class => false # Print Order Item def print - if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf printer = PrintSetting.all unique_code="OrderItemPdf" @@ -41,19 +41,30 @@ class Oqs::PrintController < ApplicationController # print when complete click 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,oqs, assigned_item.order_id, order_item.order_items_id, print_status, "", options ) + filename, receipt_no, cashier_printer = order_queue_printer.print_order_item(print_settings,oqs, assigned_item.order_id, order_item.order_items_id, print_status, "", options ) # update print status for completed same order items assigned_items.each do |ai| ai.print_status=true ai.save - end - end + end + + # filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount) + if ENV["SERVER_MODE"] == "cloud" + result = { + :filepath => filename, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings + } + # Mobile Print + render :json => result.to_json + end + # end end # Print Order Details with booking id def print_order_summary - if ENV["SERVER_MODE"] != "cloud" #no print in cloud server + # if ENV["SERVER_MODE"] != "cloud" #no print in cloud server order_slim_pdf = Lookup.collection_of("print_settings") #print_settings with name:OrderSlimPdf printer = PrintSetting.all unique_code="OrderSummaryPdf" @@ -98,14 +109,25 @@ class Oqs::PrintController < ApplicationController # print when complete click print_settings = PrintSetting.find_by_unique_code(unique_code) order_queue_printer = Printer::OrderQueuePrinter.new(print_settings) - order_queue_printer.print_booking_summary(print_settings,oqs, booking_id, print_status) + filename, receipt_no, cashier_printer = order_queue_printer.print_booking_summary(print_settings,oqs, booking_id, print_status) # update print status for completed same order items assigned_items.each do |ai| ai.print_status = true ai.save end - end + + # filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_detail, "Frt",current_balance,nil,other_amount) + if ENV["SERVER_MODE"] == "cloud" + result = { + :filepath => filename, + :printer_model => print_settings.brand_name, + :printer_url => print_settings.api_settings + } + # Mobile Print + render :json => result.to_json + end + # end end end \ No newline at end of file diff --git a/app/controllers/settings/employees_controller.rb b/app/controllers/settings/employees_controller.rb index 323bb6da..baefd752 100755 --- a/app/controllers/settings/employees_controller.rb +++ b/app/controllers/settings/employees_controller.rb @@ -30,6 +30,9 @@ class Settings::EmployeesController < ApplicationController # POST /employees # POST /employees.json def create + puts "puts ssssssssssssssssssssssssss" + puts employee_params.to_json + @employee = Employee.new(employee_params) respond_to do |format| @@ -72,6 +75,6 @@ class Settings::EmployeesController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def employee_params - params.require(:employee).permit(:name, :role, :is_active, :emp_id, :password, :image_path) + params.require(:employee).permit(:name, :role, :is_active, :emp_id, :password,:order_queue_station_id, :image_path) end end diff --git a/app/models/employee.rb b/app/models/employee.rb index 66f9a7f0..7bc5c4a4 100755 --- a/app/models/employee.rb +++ b/app/models/employee.rb @@ -2,6 +2,7 @@ class Employee < ApplicationRecord has_secure_password has_many :commissioners has_many :shit_sales + belongs_to :order_queue_station validates_presence_of :name, :role validates_presence_of :password, :on => [:create] diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index a0372498..e9cbfd26 100755 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -7,6 +7,7 @@ class OrderQueueStation < ApplicationRecord has_many :order_items has_many :order_queue_process_by_zones has_many :zones, through: :order_queue_process_by_zones + belongs_to :employee scope :active, -> {where(is_active: true)} diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index 267772f2..b50d83f9 100755 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -1,9 +1,6 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker def print_order_item(print_settings,oqs, order_id, order_item_id, print_status, before_updated_qty="", options="") - #Use CUPS service - #Generate PDF - #Print # Must be one print if print_settings.print_copies == 0 print_settings.print_copies = 1 @@ -12,7 +9,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker order_item = print_query('order_item', order_item_id) #OrderItem.find_by_item_code(item_code) - filename = "tmp/order_item_#{order_id}_#{order_item_id}" + ".pdf" + # filename = "tmp/order_item_#{order_id}_#{order_item_id}" + ".pdf" pdf = OrderItemPdf.new(print_settings,order_item[0], print_status, options, oqs.use_alternate_name, before_updated_qty) print_setting = PrintSetting.all @@ -39,6 +36,12 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker end # end + shop = Shop.first + directory_name = 'public/orders_'+shop.shop_code + Dir.mkdir(directory_name) unless File.exists?(directory_name) + + filename = directory_name + "/order_item_#{order_id}_#{order_item_id}" + ".pdf" + pdf.render_file filename if oqs.print_copy @@ -56,7 +59,9 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker if ENV["SERVER_MODE"] != "cloud" self.print(filename, oqs.printer_name) end - end + end + + return filename, order_id, oqs.printer_name end # Query for per order @@ -72,12 +77,19 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker print_setting = PrintSetting.all.order("id ASC") order=print_query('order_summary', order_id) + + shop = Shop.first + directory_name = 'public/orders_'+shop.shop_code + Dir.mkdir(directory_name) unless File.exists?(directory_name) + # For Print Per Item if oqs.cut_per_item order_items.each do|odi| - odi_item=print_query('order_item', odi.order_items_id) - filename = "tmp/order_item_#{order_id}" + ".pdf" + odi_item=print_query('order_item', odi.order_items_id) + + filename = directory_name + "/order_item_#{order_id}" + ".pdf" + # filename = "tmp/order_item_#{order_id}" + ".pdf" # For Item Options options = odi.options == "[]"? "" : odi.options @@ -122,7 +134,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker end # For Print Order Summary else - filename = "tmp/order_summary_#{order_id}" + ".pdf" + filename = directory_name + "/order_summary_#{order_id}" + ".pdf" + # filename = "tmp/order_summary_#{order_id}" + ".pdf" pdf = OrderSummaryPdf.new(print_settings,order, print_status, order_items, oqs.use_alternate_name,before_updated_qty) if !print_setting.empty? print_setting.each do |print_settings| @@ -160,6 +173,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker end end end + return filename, order_id, oqs.printer_name end # Print for orders in booking @@ -173,10 +187,16 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker print_setting = PrintSetting.all.order("id ASC") order=print_query('booking_summary', booking_id) + + shop = Shop.first + directory_name = 'public/orders_'+shop.shop_code + Dir.mkdir(directory_name) unless File.exists?(directory_name) + # For Print Per Item if oqs.cut_per_item order.each do|odi| - filename = "tmp/order_item_#{booking_id}" + ".pdf" + # filename = "tmp/order_item_#{booking_id}" + ".pdf" + filename = directory_name + "/order_item_#{booking_id}" + ".pdf" # For Item Options options = odi.options == "[]"? "" : odi.options @@ -222,7 +242,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker end # For Print Order Summary else - filename = "tmp/booking_summary_#{booking_id}" + ".pdf" + # filename = "tmp/booking_summary_#{booking_id}" + ".pdf" + filename = directory_name + "/booking_summary_#{booking_id}" + ".pdf" pdf = OrderSummaryPdf.new(print_settings,order, print_status,oqs.use_alternate_name,before_updated_qty) if !print_setting.empty? @@ -261,6 +282,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker end end end + return filename, booking_id, oqs.printer_name end # Query for OQS with status diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index fe7f4b4e..57a4471f 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -10,8 +10,12 @@ <% @queue_stations.each do |qsi| %> <% if qsi.is_active != false %> + <% selected = ""%> + <%if qsi.id == current_user.order_queue_station_id %> + <% selected = 'selected=""'%> + <%end%>
<%= qsi.id %>
- + <% end %> <% end %> @@ -172,12 +176,15 @@