Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into adminbsb_ui_changes
This commit is contained in:
@@ -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"]
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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?
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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)}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -10,8 +10,12 @@
|
||||
<option value="0" data-id="0">Processed</option>
|
||||
<% @queue_stations.each do |qsi| %>
|
||||
<% if qsi.is_active != false %>
|
||||
<% selected = ""%>
|
||||
<%if qsi.id == current_user.order_queue_station_id %>
|
||||
<% selected = 'selected=""'%>
|
||||
<%end%>
|
||||
<p class="hidden oqs-id"><%= qsi.id %></p>
|
||||
<option value="<%= qsi.id %>" data-id="<%= qsi.id %>" style="padding:5px 20px !important;"> <%= qsi.station_name %></option>
|
||||
<option value="<%= qsi.id %>" data-id="<%= qsi.id %>" <%=selected%> style="padding:5px 20px !important;"> <%= qsi.station_name %></option>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</select>
|
||||
@@ -172,12 +176,15 @@
|
||||
<!-- OQS Buttons -->
|
||||
<br>
|
||||
<a href="<%= dashboard_path %>" class="btn btn-sm btn-block btn-default waves-effect" role="button" aria-haspopup="true"><i class="material-icons">reply</i> Back </a>
|
||||
<% if ENV["SERVER_MODE"] != "cloud" %>
|
||||
|
||||
<button type="button" title="Print Order Item" id="print_order_item" class="btn bg-blue btn-block btn-lg waves-effect">Print</a>
|
||||
|
||||
<button type="button" class="btn bg-blue btn-block btn-lg waves-effect" id="print_order_summary">Print <br/>Order<br/>Summary</button>
|
||||
<% if ENV["SERVER_MODE"] != "cloud" %>
|
||||
<%end%>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" id="server_mode" value="<%=ENV["SERVER_MODE"]%>">
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).on('turbolinks:load', function() {
|
||||
@@ -186,5 +193,6 @@
|
||||
});
|
||||
});
|
||||
document.getElementById("defaultOpen").click();
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
</script>
|
||||
@@ -9,15 +9,18 @@
|
||||
<%= f.input :name %>
|
||||
<%= f.input :is_active,:input_html=>{:class=>"col-md-9"} %>
|
||||
<% if current_user.role == "administrator" %>
|
||||
<%= f.input :role, :collection => Lookup.collection_of("employee_roles"),:class=>'form-group' %>
|
||||
<%= f.input :role, :collection => Lookup.collection_of("employee_roles"),:class=>'form-group employee_roles' %>
|
||||
<% elsif current_user.role == "supervisor" %>
|
||||
<%= f.input :role, :collection => Lookup.collection_of("employee_roles").select{|r| r[1] == "cashier" || r[1] == "waiter"},:class=>'form-group' %>
|
||||
<%= f.input :role, :collection => Lookup.collection_of("employee_roles").select{|r| r[1] == "cashier" || r[1] == "waiter"},:class=>'form-group employee_roles' %>
|
||||
<% else %>
|
||||
<%= f.input :role, :collection => Lookup.collection_of("employee_roles").select{|r| r[1] != "administrator"},:class=>'form-group' %>
|
||||
<%= f.input :role, :collection => Lookup.collection_of("employee_roles").select{|r| r[1] != "administrator"},:class=>'form-group employee_roles' %>
|
||||
<% end %>
|
||||
<div class="form-group order_queue_station_id bmd-form-group hidden">
|
||||
<%= f.label :order_queue_station, 'Order Queue Station'%>
|
||||
<%= f.select :order_queue_station_id, OrderQueueStation.active.map {|l| [l.station_name, l.id]}, { :include_blank => 'Choose Order Queue Station'}, {class: 'form-control'} %>
|
||||
</div>
|
||||
<%= f.input :emp_id, :label => "Employee Numberic ID (*Unique)" %>
|
||||
<%= f.input :password %>
|
||||
|
||||
</div>
|
||||
<div class="form-inputs p-l-15">
|
||||
<label>Employee Image</label>
|
||||
@@ -68,7 +71,19 @@
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).on('turbolinks:load', function() {
|
||||
$('body').bootstrapMaterialDesign();
|
||||
// $(document).on('turbolinks:load', function() {
|
||||
// alert("hi")
|
||||
// $('body').bootstrapMaterialDesign();
|
||||
$(function() {
|
||||
if ($("#employee_role").val()=="kitchen") {
|
||||
$('.order_queue_station_id').removeClass("hidden");
|
||||
}
|
||||
$(document).on('click', '#employee_role', function(event){
|
||||
if ($(this).val()=="kitchen") {
|
||||
$('.order_queue_station_id').removeClass("hidden");
|
||||
}else{
|
||||
$('.order_queue_station_id').addClass("hidden");
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -36,6 +36,12 @@
|
||||
<th><%= t("views.right_panel.detail.role") %></th>
|
||||
<td><%= @employee.role %></td>
|
||||
</tr>
|
||||
<% if @employee.role == "kitchen"%>
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.station_name") %></th>
|
||||
<td><%= @employee.order_queue_station.station_name %></td>
|
||||
</tr>
|
||||
<% end%>
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.created_at") %></th>
|
||||
<td><%= @employee.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %></td>
|
||||
|
||||
@@ -357,7 +357,7 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
post "/:id", to: "edit#update"
|
||||
|
||||
# Pass assigned_order_item_id
|
||||
post 'print/print/:id', to: "print#print"
|
||||
get 'print/print/:id', to: "print#print"
|
||||
get 'print/print_order_summary/:id', to: "print#print_order_summary"
|
||||
|
||||
get "/get_items/:id" => "home#get_items_by_oqs", :as => "get_order_items_by_oqs"
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
version: '3'
|
||||
services:
|
||||
code2lab:
|
||||
build: .
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./Dockerfile
|
||||
links:
|
||||
- redis
|
||||
command: bundle exec puma -C config/puma.rb
|
||||
volumes:
|
||||
- .:/sxrestaurant
|
||||
env_file:
|
||||
- .code2lab.env
|
||||
ports:
|
||||
- '8081:62158'
|
||||
- '8082:62158'
|
||||
environment:
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
sidekiq:
|
||||
@@ -22,10 +23,9 @@ services:
|
||||
- .:/sxrestaurant
|
||||
environment:
|
||||
- REDIS_URL=redis://redis:6379/0
|
||||
|
||||
redis:
|
||||
image: redis
|
||||
ports:
|
||||
- '6379:6379'
|
||||
- '6380:6379'
|
||||
volumes:
|
||||
- ../data/redis:/data
|
||||
- ../data/redis:/data
|
||||
Reference in New Issue
Block a user