Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
superuser
2017-06-16 19:56:56 +06:30
30 changed files with 436 additions and 218 deletions

View File

@@ -51,6 +51,7 @@ $(document).ready(function(){
var customer_id=$(this).find(".customer-id").text(); var customer_id=$(this).find(".customer-id").text();
show_customer_details(customer_id); show_customer_details(customer_id);
$("#re-print").val(unique_id);
var cashier=""; var cashier="";
var receipt_date=""; var receipt_date="";
@@ -200,6 +201,14 @@ $(document).ready(function(){
return false; return false;
}); });
$('#re-print').click(function() {
var sale_id = $(".selected-item").find(".orders-id").text();
window.location.href = '/origami/'+ sale_id + "/reprint"
return false;
});
function show_customer_details(customer_id){ function show_customer_details(customer_id){
if(window.location.pathname.substring(0, 12) == "/origami/SAL"){ if(window.location.pathname.substring(0, 12) == "/origami/SAL"){
@@ -218,20 +227,24 @@ $(document).ready(function(){
dataType: "json", dataType: "json",
success: function(data) { success: function(data) {
$("#customer_name").text(data["customer"].name); $("#customer_name").text(data["customer"].name);
$.each(data["response_data"]["data"], function (i) { if (data["response_data"]["data"].length) {
if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){ $.each(data["response_data"]["data"], function (i) {
var balance = data["response_data"]["data"][i]["balance"]; if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){
if (data["response_data"]["status"]==true) { var balance = data["response_data"]["data"][i]["balance"];
$('.rebate_amount').removeClass('hide'); if (data["response_data"]["status"]==true) {
row = $('.rebate_amount').removeClass('hide');
'<td class="charges-name">' + data["response_data"]["data"][i]["accountable_type"] +'</td>' row =
+'<td class="item-attr">' + balance + '</td>'; '<td class="charges-name">' + data["response_data"]["data"][i]["accountable_type"] +'</td>'
+'<td class="item-attr">' + balance + '</td>';
$(".rebate_amount").html(row); $(".rebate_amount").html(row);
} }
} }
}); });
}else{
$('.rebate_amount').addClass('hide');
}
} }
}); });
//End Ajax //End Ajax
@@ -298,19 +311,25 @@ function control_button(order_status){
$("#request_bills").prop('disabled', true); $("#request_bills").prop('disabled', true);
$("#discount").prop('disabled', false); $("#discount").prop('disabled', false);
$("#pay-bill").prop('disabled', false); $("#pay-bill").prop('disabled', false);
$("#re-print").prop('disabled', true);
} }
else if(order_status=="new") { else if(order_status=="new") {
$("#customer").prop('disabled', false); $("#customer").prop('disabled', false);
$("#request_bills").prop('disabled', false); $("#request_bills").prop('disabled', false);
$("#discount").prop('disabled', true); $("#discount").prop('disabled', true);
$("#pay-bill").prop('disabled', true); $("#pay-bill").prop('disabled', true);
$("#re-print").prop('disabled', true);
}else if(order_status=="completed"){
$("#re-print").prop('disabled', false);
} }
else { else {
$("#customer").prop('disabled', true); $("#customer").prop('disabled', true);
$("#request_bills").prop('disabled', true); $("#request_bills").prop('disabled', true);
$("#discount").prop('disabled', true); $("#discount").prop('disabled', true);
$("#pay-bill").prop('disabled', true); $("#pay-bill").prop('disabled', true);
$("#re-print").prop('disabled', true);
} }
} }
/* For Receipt - Update Balance */ /* For Receipt - Update Balance */

View File

@@ -31,7 +31,7 @@ class Api::OrdersController < Api::ApiController
@order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile @order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
@order.items = params[:order_items] @order.items = params[:order_items]
@order.guest = params[:guest_info] @order.guest = params[:guest_info]
@order.table_id = params[:table_id] @order.table_id = params[:table_id] # this is dining facilities's id
@order.new_booking = true @order.new_booking = true
@order.employee_name = current_login_employee.name @order.employee_name = current_login_employee.name
#Create Table Booking or Room Booking #Create Table Booking or Room Booking

View File

@@ -15,6 +15,7 @@ class Crm::DiningQueuesController < BaseCrmController
# GET /crm/dining_queues/new # GET /crm/dining_queues/new
def new def new
@dining_queue = DiningQueue.new @dining_queue = DiningQueue.new
@queue_no = DiningQueue.generate_queue_no
end end
# GET /crm/dining_queues/1/edit # GET /crm/dining_queues/1/edit
@@ -28,6 +29,15 @@ class Crm::DiningQueuesController < BaseCrmController
respond_to do |format| respond_to do |format|
if @dining_queue.save if @dining_queue.save
unique_code = "QueueNoPdf"
# get printer info
print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_queue_no(print_settings,@dining_queue)
format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully created.' } format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully created.' }
format.json { render :show, status: :created, location: @dining_queue } format.json { render :show, status: :created, location: @dining_queue }
else else

View File

@@ -6,13 +6,13 @@ class Oqs::PrintController < ApplicationController
assigned_item=AssignedOrderItem.find(assigned_item_id) assigned_item=AssignedOrderItem.find(assigned_item_id)
assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'"); assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
# printer for each stations # order queue stations
printer_name = assigned_item.order_queue_station.printer_name oqs = assigned_item.order_queue_station
# print when complete click # print when complete click
print_settings=PrintSetting.find_by_unique_code(unique_code) print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_item(printer_name,assigned_item.order_id, assigned_item.item_code ) order_queue_printer.print_order_item(oqs,assigned_item.order_id, assigned_item.item_code )
# update print status for completed same order items # update print status for completed same order items
assigned_items.each do |ai| assigned_items.each do |ai|
@@ -28,13 +28,13 @@ class Oqs::PrintController < ApplicationController
assigned_item=AssignedOrderItem.find(assigned_item_id) assigned_item=AssignedOrderItem.find(assigned_item_id)
assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'"); assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'");
# printer for each stations # order queue stations
printer_name = assigned_item.order_queue_station.printer_name oqs = assigned_item.order_queue_station
# print when complete click # print when complete click
print_settings=PrintSetting.find_by_unique_code(unique_code) print_settings=PrintSetting.find_by_unique_code(unique_code)
order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) order_queue_printer= Printer::OrderQueuePrinter.new(print_settings)
order_queue_printer.print_order_summary(printer_name,assigned_item.order_id) order_queue_printer.print_order_summary(oqs,assigned_item.order_id)
# update print status for completed same order items # update print status for completed same order items
assigned_items.each do |ai| assigned_items.each do |ai|

View File

@@ -77,4 +77,28 @@ class Origami::PaymentsController < BaseOrigamiController
end end
end end
end end
def reprint
sale_id = params[:sale_id]
saleObj = Sale.find(sale_id)
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
# get member information
member_info = Customer.get_member_account(customer)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info)
end
end end

View File

@@ -71,6 +71,6 @@ class Settings::OrderQueueStationsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through. # Never trust parameters from the scary internet, only allow the white list through.
def settings_order_queue_station_params def settings_order_queue_station_params
params.require(:order_queue_station).permit(:station_name, :is_active, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by) params.require(:order_queue_station).permit(:station_name, :is_active, :auto_print, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by)
end end
end end

View File

@@ -0,0 +1,77 @@
class Transactions::ManualSalesController < ApplicationController
def void
@sale = params[:sale_id]
@reason = Lookup.where("lookup_type = 'void_reason'")
respond_to do |format|
format.html # index.html.erb
format.json { render json: @sales }
end
end
def manual_void_sale
sale_id = params[:sale_id]
reason = params[:reason]
sale = Sale.find(sale_id)
sale.sale_status = 'void'
sale.requested_by = current_login_employee.id
if sale.save
@sale = SaleAudit.record_audit_void(sale_id, current_login_employee.id, current_login_employee.id, reason)
if sale.sale_orders
sale.sale_orders.each do |bo|
order =Order.find(bo.order_id)
order.status= 'void'
order.save
booking_order = BookingOrder.find_by_order_id(bo.order_id)
if booking_order.booking_id
booking = Booking.find(booking_order.booking_id)
dining_facility = booking.dining_facility
dining_facility.status = 'available'
dining_facility.save
end
end
end
end
respond_to do |format|
format.html { redirect_to transactions_sales_url, notice: 'Sale was successfully void.' }
end
end
def manual_complete_sale
sale_id = params[:sale_id]
sale = Sale.find(sale_id)
sale.sale_status = 'completed'
sale.requested_by = current_login_employee.id
remark = "Complete for Sale ID #{sale_id} By #{current_login_employee.name}"
if sale.save
@sale = SaleAudit.record_audit_complete(sale_id, remark, current_login_employee.id)
if sale.sale_orders
sale.sale_orders.each do |bo|
# order =Order.find(bo.order_id)
# order.status= 'void'
# order.save
booking_order = BookingOrder.find_by_order_id(bo.order_id)
if booking_order.booking_id
booking = Booking.find(booking_order.booking_id)
dining_facility = booking.dining_facility
dining_facility.status = 'available'
dining_facility.save
end
end
end
end
redirect_to transactions_sales_path
end
end

View File

@@ -60,7 +60,7 @@ class Transactions::SalesController < ApplicationController
else else
@membership = 0 @membership = 0
end end
#end customer amount #end customer amount
respond_to do |format| respond_to do |format|
format.html # show.html.erb format.html # show.html.erb
@@ -117,38 +117,6 @@ class Transactions::SalesController < ApplicationController
end end
end end
def void
@sale = params[:sale_id]
@reason = Lookup.where("lookup_type = 'void_reason'")
end
def manual_void_sale
sale_id = params[:sale_id]
reason = params[:reason]
sale = Sale.find(sale_id)
sale.sale_status = 'void'
sale.requested_by = current_login_employee.id
if sale.save
@sale = SaleAudit.record_audit_void(sale_id, current_login_employee.id, current_login_employee.id, reason)
end
respond_to do |format|
format.html { redirect_to transactions_sales_url, notice: 'Sale was successfully void.' }
end
end
def manual_complete_sale
sale_id = params[:sale_id]
sale = Sale.find(sale_id)
sale.sale_status = 'completed'
sale.requested_by = current_login_employee.id
remark = remark = "Complete for Sale ID #{sale_id} By #{current_login_employee.name}"
if sale.save
sale = SaleAudit.record_audit_complete(sale_id, remark, current_login_employee.id)
end
redirect_to transactions_sales_path
end
private private
# Use callbacks to share common setup or constraints between actions. # Use callbacks to share common setup or constraints between actions.
def set_transactions_sale def set_transactions_sale

View File

@@ -1,7 +1,7 @@
class OrderQueueProcessorJob < ApplicationJob class OrderQueueProcessorJob < ApplicationJob
queue_as :default queue_as :default
def perform(order_id) def perform(order_id, table_id)
# Do something later # Do something later
#Order ID #Order ID
order = Order.find(order_id) order = Order.find(order_id)
@@ -10,7 +10,7 @@ class OrderQueueProcessorJob < ApplicationJob
#Execute orders and send to order stations #Execute orders and send to order stations
if order if order
oqs = OrderQueueStation.new oqs = OrderQueueStation.new
oqs.process_order(order) oqs.process_order(order, table_id)
end end
end end

View File

@@ -1,2 +1,7 @@
class DiningQueue < ApplicationRecord class DiningQueue < ApplicationRecord
def self.generate_queue_no
queue_no = DiningQueue.all.count + 1
return queue_no
end
end end

View File

@@ -199,7 +199,7 @@ class Order < ApplicationRecord
#Process order items and send to order queue #Process order items and send to order queue
def process_order_queue def process_order_queue
#Send to background job for processing #Send to background job for processing
OrderQueueProcessorJob.perform_later(self.id) OrderQueueProcessorJob.perform_later(self.id, self.table_id)
end end

View File

@@ -8,8 +8,10 @@ class OrderQueueStation < ApplicationRecord
scope :active, -> {where(is_active: true)} scope :active, -> {where(is_active: true)}
def process_order (order) def process_order (order, table_id)
oqs_stations = OrderQueueStation.active oqs_stations = OrderQueueStation.active
dining=DiningFacility.find(table_id)
oqpbz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id)
order_items = order.order_items order_items = order.order_items
#Assign OQS id to order Items #Assign OQS id to order Items
@@ -17,16 +19,17 @@ class OrderQueueStation < ApplicationRecord
#Get List of items - #Get List of items -
pq_items = JSON.parse(oqs.processing_items) pq_items = JSON.parse(oqs.processing_items)
#Loop through the processing items if oqs.id == oqpbz.order_queue_station_id
pq_items.each do |pq_item| #Loop through the processing items
#Processing through the looping items pq_items.each do |pq_item|
order_items.each do |order_item| #Processing through the looping items
if (pq_item == order_item.item_code) order_items.each do |order_item|
#Same Order_items can appear in two location. if (pq_item == order_item.item_code)
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) #Same Order_items can appear in two location.
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
end
end end
end end
end end
end end

View File

@@ -1,25 +1,42 @@
class Printer::OrderQueuePrinter < Printer::PrinterWorker class Printer::OrderQueuePrinter < Printer::PrinterWorker
def print_order_item(printer_name,order_id, item_code) def print_order_item(oqs,order_id, item_code)
#Use CUPS service #Use CUPS service
#Generate PDF #Generate PDF
#Print #Print
order_item= print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code) order_item= print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code)
pdf = OrderItemPdf.new(order_item[0]) pdf = OrderItemPdf.new(order_item[0])
pdf.render_file "tmp/receipt.pdf" pdf.render_file "tmp/receipt.pdf"
self.print("tmp/receipt.pdf", printer_name) if oqs.print_copy
self.print("tmp/receipt.pdf", oqs.printer_name)*2
else
self.print("tmp/receipt.pdf", oqs.printer_name)
end
end end
def print_order_summary(printer_name,order_id) def print_order_summary(oqs,order_id)
#Use CUPS service #Use CUPS service
#Generate PDF #Generate PDF
#Print #Print
order=print_query('order_summary',order_id) order=print_query('order_summary',order_id)
filename = "tmp/order_summary_#{order_id}" + ".pdf" # For Print Per Item
pdf = OrderSummaryPdf.new(order) if oqs.cut_per_item
pdf.render_file filename order.each do|odi|
pdf = OrderItemPdf.new(odi)
self.print(filename, printer_name) pdf.render_file "tmp/receipt.pdf"
if oqs.print_copy
self.print("tmp/receipt.pdf", oqs.printer_name)*2
else
self.print("tmp/receipt.pdf", oqs.printer_name)
end
end
# For Print Order Summary
else
filename = "tmp/order_summary_#{order_id}" + ".pdf"
pdf = OrderSummaryPdf.new(order)
pdf.render_file filename
self.print(filename, printer_name)
end
end end
# Query for OQS with status # Query for OQS with status

View File

@@ -74,6 +74,16 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
self.print("tmp/receipt_bill.pdf") self.print("tmp/receipt_bill.pdf")
end end
#Queue No Print
def print_queue_no(printer_settings,queue)
#Use CUPS service
#Generate PDF
#Print
pdf = QueueNoPdf.new(printer_settings,queue)
pdf.render_file "tmp/print_queue_no.pdf"
self.print("tmp/print_queue_no.pdf")
end
#Bill Receipt Print #Bill Receipt Print
def print_crm_order(booking,order_items,setting) def print_crm_order(booking,order_items,setting)
#Use CUPS service #Use CUPS service

58
app/pdf/queue_no_pdf.rb Normal file
View File

@@ -0,0 +1,58 @@
class QueueNoPdf < Prawn::Document
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width
def initialize(printer_settings, queue)
self.page_width = 210
self.page_height = 2500
self.margin = 5
self.price_width = 35
self.qty_width = 20
self.total_width = 35
self.item_width = self.page_width - ((self.price_width + self.qty_width + self.total_width))
self.item_height = 15
self.item_description_width = (self.page_width-20) / 2
self.label_width = 100
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
self.header_font_size = 10
self.item_font_size = 8
header( "Beauty In the Pot", printer_settings.name)
queue_no(queue)
stroke_horizontal_rule
date_info(queue)
end
def header (printer_name, name)
text "#{printer_name}", :left_margin => -10, :size => self.header_font_size,:align => :center
text "#{name}", :size => self.header_font_size,:align => :center
# move_down self.item_height
move_down 5
stroke_horizontal_rule
move_down 5
end
def queue_no (queue)
move_down 5
text "#{queue.queue_no}", :size => 100,:align => :center
end
def date_info(queue)
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Date:", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.item_width) do
text "#{queue.created_at.strftime('%Y-%m-%d %I:%M %p')}" , :size => self.item_font_size,:align => :left
end
move_down 5
end
end

View File

@@ -206,18 +206,20 @@ class ReceiptBillPdf < Prawn::Document
# show member information # show member information
def member_info(member_info) def member_info(member_info)
move_down 7 move_down 7
if member_info["data"] == true if member_info["status"] == true
member_info["data"].each do |res| member_info["data"].each do |res|
stroke_horizontal_rule
move_down 5 move_down 5
y_position = cursor y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do text "#{ res["accountable_type"] }", :size => self.item_font_size,:align => :left
text "#{ res["accountable_type"] } : #{ res["balance"] }", :size => self.item_font_size,:align => :left end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{ res["balance"] }" , :size => self.item_font_size,:align => :right
end end
move_down 5
end end
end end
end end
@@ -227,7 +229,7 @@ class ReceiptBillPdf < Prawn::Document
stroke_horizontal_rule stroke_horizontal_rule
move_down 5 move_down 5
text "*** Thank You ***", :left_margin => -10, :size => self.header_font_size,:align => :center text "Thank You! See you Again", :left_margin => -10, :size => self.header_font_size,:align => :center
move_down 5 move_down 5
end end

View File

@@ -1,26 +1,8 @@
<div class="row"> <div class="row">
<div class="col-lg-10 col-md-10 col-sm-10"> <div class="col-lg-11 col-md-11 col-sm-11">
<!-- Column One --> <!-- Column One -->
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#queue" role="tab">Customer Details </a>
</li>
<li class="nav-item">
<a class="nav-link " data-toggle="tab" href="#booking" role="tab">Orders </a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#customer" role="tab">Sales</a>
</li>
</ul>
<!-- Nav tabs - End -->
<div class="tab-content">
<div class="tab-pane active" id="queue" role="tabpanel""> <div class="tab-pane active" id="queue" role="tabpanel"">
<div class="row"> <div class="row">
<div class="col-md-3"></div>
<div class="col-md-6"> <div class="col-md-6">
<br> <br>
<h4>Customer Profile</h4> <h4>Customer Profile</h4>
@@ -51,11 +33,8 @@
</table> </table>
</div> </div>
</div> </div>
</div>
<hr>
<div class="row">
<div class="col-md-3"></div>
<div class="col-md-6"> <div class="col-md-6">
<br>
<h4>Membership Detail</h4> <h4>Membership Detail</h4>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped"> <table class="table table-striped">
@@ -78,8 +57,22 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<!-- <li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#queue" role="tab">Customer Details </a>
</li> -->
<li class="nav-item">
<a class="nav-link " data-toggle="tab" href="#booking" role="tab">Orders </a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#customer" role="tab">Sales</a>
</li>
</ul>
<!-- Nav tabs - End -->
<div class="tab-content">
<div class="tab-pane" id="booking" role="tabpanel"> <div class="tab-pane" id="booking" role="tabpanel">
<h3>Order Details</h3> <h3>Order Details</h3>
<div class="table-responsive"> <div class="table-responsive">
@@ -114,9 +107,8 @@
</table> </table>
</div> </div>
</div> </div>
<div class="tab-pane" id="customer" role="tabpanel"> <div class="tab-pane" id="customer" role="tabpanel">
<h3>Sale Details</h3> <h3>Sale Details</h3>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
@@ -146,7 +138,6 @@
</table> </table>
</div> </div>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -1,16 +1,25 @@
<%= simple_form_for([:crm,@dining_queue]) do |f| %> <%= simple_form_for([:crm,@dining_queue]) do |f| %>
<%= f.error_notification %> <%= f.error_notification %>
<p class="hidden generate_no"><%= @queue_no %></p>
<div class="form-inputs"> <div class="form-inputs">
<%= f.input :name %> <%= f.input :name %>
<%= f.input :contact_no %> <%= f.input :contact_no %>
<%= f.input :queue_no %> <%= f.input :queue_no , :class => "dining",:id => "dining", :readonly => true%>
</div> </div>
<br>
<div class="form-actions"> <div class="form-actions">
<%= f.button :submit %> <%= f.button :submit %>
</div> </div>
<% end %> <% end %>
<script type="text/javascript">
$(document).ready(function(){
if($('form').attr('id') == "new_dining_queue"){
var queue_no = $('.generate_no').text();
$('#dining_queue_queue_no').val(queue_no);
}
});
</script>

View File

@@ -383,6 +383,6 @@
<button type="button" id="discount" class="btn btn-primary btn-lg btn-block">Discount</button> <button type="button" id="discount" class="btn btn-primary btn-lg btn-block">Discount</button>
<!-- <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Tax</button> --> <!-- <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Tax</button> -->
<button type="button" id="pay-bill" class="btn btn-primary btn-lg btn-block">Pay</button> <button type="button" id="pay-bill" class="btn btn-primary btn-lg btn-block">Pay</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Re.Print</button> <button type="button" id="re-print" class="btn btn-primary btn-lg btn-block">Re.Print</button>
</div> </div>
</div> </div>

View File

@@ -4,6 +4,7 @@
<div class="form-inputs"> <div class="form-inputs">
<%= f.input :station_name %> <%= f.input :station_name %>
<%= f.input :is_active %> <%= f.input :is_active %>
<%= f.input :auto_print %>
<%= f.input :printer_name %> <%= f.input :printer_name %>
<%= f.input :font_size %> <%= f.input :font_size %>
<%= f.input :print_copy %> <%= f.input :print_copy %>

View File

@@ -17,6 +17,7 @@
<tr> <tr>
<th>Station name</th> <th>Station name</th>
<th>Is active</th> <th>Is active</th>
<th>Auto Print</th>
<th>Print copy</th> <th>Print copy</th>
<th>Printer name</th> <th>Printer name</th>
<th>Cut per item</th> <th>Cut per item</th>
@@ -31,6 +32,7 @@
<tr> <tr>
<td><%= link_to settings_order_queue_station.station_name, settings_order_queue_station_path(settings_order_queue_station) %></td> <td><%= link_to settings_order_queue_station.station_name, settings_order_queue_station_path(settings_order_queue_station) %></td>
<td><%= settings_order_queue_station.is_active %></td> <td><%= settings_order_queue_station.is_active %></td>
<td><%= settings_order_queue_station.auto_print %></td>
<td><%= settings_order_queue_station.print_copy %></td> <td><%= settings_order_queue_station.print_copy %></td>
<td><%= settings_order_queue_station.printer_name %></td> <td><%= settings_order_queue_station.printer_name %></td>
<td><%= settings_order_queue_station.cut_per_item %></td> <td><%= settings_order_queue_station.cut_per_item %></td>

View File

@@ -18,6 +18,11 @@
<%= @settings_order_queue_station.is_active %> <%= @settings_order_queue_station.is_active %>
</p> </p>
<p>
<strong>Auto Print:</strong>
<%= @settings_order_queue_station.auto_print %>
</p>
<p> <p>
<strong>Processing items:</strong> <strong>Processing items:</strong>
<%= @settings_order_queue_station.processing_items %> <%= @settings_order_queue_station.processing_items %>

View File

@@ -34,7 +34,6 @@
<th>Order status</th> <th>Order status</th>
<th>Order date</th> <th>Order date</th>
<th>Items Count</th> <th>Items Count</th>
<th>Action</th>
</tr> </tr>
</thead> </thead>
@@ -42,13 +41,13 @@
<% @orders.each do |order| %> <% @orders.each do |order| %>
<tr> <tr>
<td><%= order.order_id %></td> <td><%= link_to order.order_id, transactions_order_path(order) %></td>
<td><%= order.order_type %></td> <td><%= order.order_type %></td>
<td><%= order.customer.name rescue '-' %></td> <td><%= order.customer.name rescue '-' %></td>
<td><%= order.status %></td> <td><%= order.status %></td>
<td> <%= order.date.strftime("%d-%m-%Y") %> </td> <td> <%= order.date.strftime("%d-%m-%Y") %> </td>
<td> <%= order.item_count %> </td> <td> <%= order.item_count %> </td>
<td><%= link_to 'Show', transactions_order_path(order) %></td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>

View File

@@ -8,13 +8,18 @@
<li class="active"> <li class="active">
<a href="<%= transactions_orders_path %>"><%= @order.order_id %></a> <a href="<%= transactions_orders_path %>"><%= @order.order_id %></a>
</li> </li>
<span style="float: right">
<a href="<%= transactions_orders_path%>" class="btn btn-primary btn-sm">
<i class="fa fa-arrow-left fa-xs"></i> Back
</a>
</span>
</ol> </ol>
</div> </div>
</div> </div>
<hr> <hr>
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-11 col-md-11 col-sm-11">
<div class="main-box-body clearfix"> <div class="main-box-body clearfix">
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped"> <table class="table table-striped">
@@ -46,7 +51,7 @@
<th>Qty</th> <th>Qty</th>
<th> Unit Price</th> <th> Unit Price</th>
<th>Total Price</th> <th>Total Price</th>
<th>Option</th> <!-- <th>Option</th> -->
<th>Status</th> <th>Status</th>
<th>Order By</th> <th>Order By</th>
<th>Created at</th> <th>Created at</th>
@@ -62,7 +67,7 @@
<td><%= order.qty %></td> <td><%= order.qty %></td>
<td><%= order.price %></td> <td><%= order.price %></td>
<td><%= order.qty * order.price %></td> <td><%= order.qty * order.price %></td>
<td> <%= order.options %> </td> <!-- <td> <%= order.options %> </td> -->
<td> <%= order.order_item_status %> </td> <td> <%= order.order_item_status %> </td>
<td> <%= order.item_order_by %> </td> <td> <%= order.item_order_by %> </td>
<td> <%= order.created_at.strftime("%d-%m-%Y") %> </td> <td> <%= order.created_at.strftime("%d-%m-%Y") %> </td>
@@ -70,13 +75,16 @@
<% end %> <% end %>
</tbody> </tbody>
</table> </table>
<a href="<%= transactions_orders_path%>" class="btn btn-primary pull-left">
<i class="fa fa-arrow-left fa-xs"></i> Back
</a>
</div> </div>
</div> </div>
</div> </div>
<!-- <div class="col-lg-1 col-md-1 col-sm-1">
<a href="<%= transactions_orders_path%>" class="btn btn-primary">
<i class="fa fa-arrow-left fa-xs"></i> Back
</a>
</div> -->
</div> </div>

View File

@@ -36,7 +36,6 @@
<th>Cashier</th> <th>Cashier</th>
<th>Sales status</th> <th>Sales status</th>
<th>Receipt Date</th> <th>Receipt Date</th>
<th>Action</th>
</tr> </tr>
</thead> </thead>
@@ -44,14 +43,13 @@
<% if @sales != 0 %> <% if @sales != 0 %>
<% @sales.each do |sale| %> <% @sales.each do |sale| %>
<tr> <tr>
<td><%= sale.sale_id %></td> <td><%= link_to sale.sale_id, transactions_sale_path(sale) %></td>
<td><%= sale.receipt_no %></td> <td><%= sale.receipt_no %></td>
<td><%= sale.grand_total rescue '-' %></td> <td><%= sale.grand_total rescue '-' %></td>
<td><%= sale.total_tax %></td> <td><%= sale.total_tax %></td>
<td><%= sale.cashier_name rescue '-' %></td> <td><%= sale.cashier_name rescue '-' %></td>
<td> <%= sale.sale_status %> </td> <td> <%= sale.sale_status %> </td>
<td> <%= sale.receipt_date.strftime("%d-%m-%Y") %> </td> <td> <%= sale.receipt_date.strftime("%d-%m-%Y") %> </td>
<td><%= link_to 'Show', transactions_sale_path(sale) %></td>
</tr> </tr>
<% end %> <% end %>
<% else %> <% else %>

View File

@@ -8,11 +8,24 @@
<li class="active"> <li class="active">
<a href="<%= transactions_sale_path(@sale.sale_id) %>"><%= @sale.sale_id %></a> <a href="<%= transactions_sale_path(@sale.sale_id) %>"><%= @sale.sale_id %></a>
</li> </li>
<span style="float: right">
<a href="<%= transactions_sales_path%>" class="btn btn-primary btn-sm">
<i class="fa fa-arrow-left fa-lg"></i> Back
</a>
<a href="<%= transactions_void_path(@sale)%>" class="btn btn-danger btn-sm">
<i class="fa fa-trash fa-lg"></i> Void Sale
</a>
<a href="<%= transactions_manual_complete_sale_path(@sale)%>" class="btn btn-success btn-sm" disabled>
<i class="fa fa-invoice fa-lg"></i> Complete Sale
</a>
</span>
</ol> </ol>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-lg-10 col-md-10 col-sm-10"> <div class="col-lg-12 col-md-12 col-sm-12">
<!-- Column One --> <!-- Column One -->
<!-- Nav tabs --> <!-- Nav tabs -->
@@ -29,7 +42,7 @@
</ul> </ul>
<!-- Nav tabs - End --> <!-- Nav tabs - End -->
<div class="tab-content" style="min-height:670px; max-height:670px; overflow-y:scroll"> <div class="tab-content" style="min-height:670px; max-height:670px;">
<div class="tab-pane active" id="queue" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:"> <div class="tab-pane active" id="queue" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:">
<div class="table-responsive"> <div class="table-responsive">
@@ -53,7 +66,7 @@
<td><%= @sale.receipt_no %></td> <td><%= @sale.receipt_no %></td>
<td><%= @sale.cashier_name rescue '-' %></td> <td><%= @sale.cashier_name rescue '-' %></td>
<td> <%= @sale.sale_status %> </td> <td> <%= @sale.sale_status %> </td>
<td> <%= @sale.requested_at.strftime("%d-%m-%Y") %> </td> <td> <%= @sale.requested_at %> </td>
</tr> </tr>
<tr style="border-top:2px solid #000"> <tr style="border-top:2px solid #000">
<th>Sale item name</th> <th>Sale item name</th>
@@ -82,12 +95,13 @@
<td>Discount</td> <td>Discount</td>
<td colspan="2"><%= number_with_precision(@sale.total_discount, :precision => 2, :delimiter => ',') rescue ' '%></td> <td colspan="2"><%= number_with_precision(@sale.total_discount, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr> </tr>
<% @sale.sale_taxes.each do |r|%>
<tr> <tr>
<td colspan=2 style="text-align:center"></td> <td colspan=2 style="text-align:center"></td>
<td>Tax</td> <td><%= r.tax_name %> </td>
<td colspan="2"><%= number_with_precision(@sale.total_tax, :precision => 2, :delimiter => ',') rescue ' '%></td> <td colspan="2"><%= number_with_precision(r.tax_payable_amount, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr> </tr>
<% end %>
<tr> <tr>
<td colspan=2 style="text-align:center"></td> <td colspan=2 style="text-align:center"></td>
<td>Grand Total</td> <td>Grand Total</td>
@@ -99,21 +113,24 @@
<td>Pay Amount</td> <td>Pay Amount</td>
<td colspan="2"><%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%></td> <td colspan="2"><%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr> </tr>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Change</td>
<td colspan="2"><%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
<% @sale_receivables.each do |r|%> <% @sale_receivables.each do |r|%>
<tr> <tr>
<td colspan=2 style="text-align:center"></td> <td colspan=2 style="text-align:center"></td>
<td>Payment <%= r.payment_method rescue ' '%></td> <td>Payment <%= r.payment_method rescue ' '%></td>
<td colspan="2"><%= number_with_precision(r.payment_amount, :precision => 2, :delimiter => ',') rescue ' '%> <td colspan="2"><%= number_with_precision(r.payment_amount, :precision => 2, :delimiter => ',') rescue ' '%>
</td> </td>
</tr> </tr>
<% end %> <% end %>
<tr>
<td colspan=2 style="text-align:center"></td>
<td>Change</td>
<td colspan="2"><%= number_with_precision(@sale.amount_changed, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr>
</tbody> </tbody>
</table> </table>
@@ -160,67 +177,61 @@
<div class="tab-pane" id="customer" role="tabpanel"> <div class="tab-pane" id="customer" role="tabpanel">
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped"> <div class="row">
<div class="col-md-6">
<br>
<h4>Customer Profile</h4>
<div class="table-responsive">
<table class="table table-striped">
<tbody>
<tr>
<th>Name</th>
<td><%= @customer.name %></td>
</tr>
<tr>
<th>Email</th>
<td><%= @customer.email %></td>
</tr>
<tr>
<th>Contact no</th>
<td><%= @customer.contact_no %></td>
</tr>
<tr>
<th>Company</th>
<td><%= @customer.company %></td>
</tr>
<tr>
<th>Date Of Birth</th>
<td><%= @customer.date_of_birth %> </td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-md-6">
<br>
<h4>Membership Detail</h4>
<div class="table-responsive">
<table class="table table-striped">
<tbody>
<% if @membership == 0 %>
<tr>
<td colspan="2">"There is no membership data"</td>
</tr>
<% else %>
<% @membership.each do |member| %>
<tr>
<th><%= member["accountable_type"] %></th>
<td><%= member["balance"] %></td>
</tr>
<% end %>
<tbody> <% end %>
<tr> </tbody>
<td colspan="3"></td> </table>
</tr> </div>
<tr> </div>
<th width="20%"><h4>Customer Details</h4></th> </div>
<th width="20%"></th>
<td></td>
</tr>
<tr>
<th width="20%"></th>
<th width="20%">Name</th>
<td><%= @customer.name %></td>
</tr>
<tr>
<th width="20%"></th>
<th width="20%">Email</th>
<td><%= @customer.email %></td>
</tr>
<tr>
<th width="20%"></th>
<th width="20%">Contact no</th>
<td><%= @customer.contact_no %></td>
</tr>
<tr>
<th width="20%"></th>
<th width="20%">Company</th>
<td><%= @customer.company rescue '-' %></td>
</tr>
<tr>
<th width="20%"></th>
<th width="20%">Date Of Birth</th>
<td><%= @customer.date_of_birth rescue '-' %> </td>
</tr>
<tr>
<th width="20%"><h4>Membership Details</h4></th>
<td width="20%"></td>
<td></td>
</tr>
<% if @membership == 0 %>
<tr>
<td colspan="2">"There is no membership data"</td>
</tr>
<% else %>
<% @membership.each do |member| %>
<tr>
<td width="20%"></td>
<th width="20%"><%= member["accountable_type"] %></th>
<td><%= member["balance"] %></td>
</tr>
<% end %>
<% end %>
</tr>
</tbody>
</table>
</div> </div>
</div> </div>
@@ -228,20 +239,19 @@
</div> </div>
<div class="col-lg-2 col-md-2 col-sm-2"> <!-- <div class="col-lg-2 col-md-2 col-sm-2">
<a href="<%= transactions_sales_path%>" style="margin-top: 10px " class="btn btn-primary pull-right btn-lg"> <a href="<%= transactions_sales_path%>" style="margin-top: 10px " class="btn btn-primary btn-lg">
<i class="fa fa-arrow-left fa-lg"></i> Back <i class="fa fa-arrow-left fa-lg"></i> Back
</a> </a>
<!-- Temporary No Needs -->
<a href="<%= transactions_void_path(@sale)%>" style="margin-top: 10px " class="btn btn-danger pull-right btn-lg">
<a href="<%= transactions_void_path(@sale)%>" style="margin-top: 10px " class="btn btn-danger btn-lg">
<i class="fa fa-trash fa-lg"></i> Void Sale <i class="fa fa-trash fa-lg"></i> Void Sale
</a> </a>
<!-- <a href="<%= transactions_manual_complete_sale_path(@sale)%>" style="margin-top: 10px " class="btn btn-success pull-right btn-lg"> <a href="<%= transactions_manual_complete_sale_path(@sale)%>" style="margin-top: 10px " class="btn btn-success btn-lg">
<i class="fa fa-invoice fa-lg"></i> Complete Sale <i class="fa fa-invoice fa-lg"></i> Complete Sale
</a> --> </a>
</div> </div> -->
</div> </div>

View File

@@ -83,7 +83,7 @@ Rails.application.routes.draw do
post "/:id/discount" => "discounts#create" post "/:id/discount" => "discounts#create"
get "/:id/request_bills" => "request_bills#print" get "/:id/request_bills" => "request_bills#print"
get '/:sale_id/reprint' => 'payments#reprint' ,:defaults => { :format => 'json' }
#--------- Payment ------------# #--------- Payment ------------#
get 'sale/:sale_id/payment' => 'payments#show' get 'sale/:sale_id/payment' => 'payments#show'
@@ -199,9 +199,9 @@ Rails.application.routes.draw do
resources :sales resources :sales
resources :orders resources :orders
get "/sales/:sale_id/manual_complete_sale" =>"sales#manual_complete_sale", :as => "manual_complete_sale" get "/sales/:sale_id/manual_complete_sale" =>"manual_sales#manual_complete_sale", :as => "manual_complete_sale"
get "/sales/:sale_id/void" =>"sales#void", :as => "void" get "/sales/:sale_id/void" =>"manual_sales#void", :as => "void"
post "sales/:sale_id/manual_void_sale", to: "sales#manual_void_sale", :as => "manual_void_sale" post "sales/:sale_id/manual_void_sale", to: "manual_sales#manual_void_sale", :as => "manual_void_sale"
end end
#--------- Reports Controller Sections ------------# #--------- Reports Controller Sections ------------#

View File

@@ -9,6 +9,7 @@ class CreateOrderQueueStations < ActiveRecord::Migration[5.1]
t.integer :font_size, :null => false, :default => 10 t.integer :font_size, :null => false, :default => 10
t.boolean :cut_per_item, :null => false, :default => false t.boolean :cut_per_item, :null => false, :default => false
t.boolean :use_alternate_name, :null => false, :default => false t.boolean :use_alternate_name, :null => false, :default => false
t.boolean :auto_print, :null => false, :default => false
t.string :created_by, :null => false t.string :created_by, :null => false
t.timestamps t.timestamps
end end

View File

@@ -147,10 +147,11 @@ admin_employee = Employee.create({name: "Waiter", role: "waiter", password: "111
admin_employee = Employee.create({name: "Waiter 2", role: "waiter", password: "22222", emp_id:"222", created_by: "SYSTEM DEFAULT"}) admin_employee = Employee.create({name: "Waiter 2", role: "waiter", password: "22222", emp_id:"222", created_by: "SYSTEM DEFAULT"})
admin_employee = Employee.create({name: "Cashier", role: "cashier", password: "33333", emp_id:"333", created_by: "SYSTEM DEFAULT"}) admin_employee = Employee.create({name: "Cashier", role: "cashier", password: "33333", emp_id:"333", created_by: "SYSTEM DEFAULT"})
order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "EPSON-TM-T82-S-A"}) # order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "EPSON-TM-T82-S-A"})
order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "EPSON-TM-T82-S-A"}) # order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "EPSON-TM-T82-S-A"})
request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "EPSON-TM-T82-S-A"}) request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "EPSON-TM-T82-S-A"})
crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "EPSON-TM-T82-S-A"}) crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "EPSON-TM-T82-S-A"})
queue_no_printer=PrintSetting.create({name: "Queue No", unique_code: "QueueNoPdf", printer_name: "EPSON-TM-T82-S-A"})
member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) member_setting = MembershipSetting.create({membership_type:"paypar_url",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"})
@@ -163,10 +164,10 @@ member_actions= MembershipAction.create([{membership_type:"get_account_balance",
{membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"} {membership_type:"get_all_member_account",gateway_url:"/api/generic_customer/get_membership_data",merchant_account_id:"vWSsseoZCzxd6xcNf_uS",auth_token:"code2lab"}
]) ])
payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http//192.168.1.47:3006"}) payment_methods = PaymentMethodSetting.create({payment_method:"MPU",gateway_url: "http://192.168.1.47:3006"})
payment_methods = PaymentMethodSetting.create({payment_method:"VISA",gateway_url: "http//192.168.1.47:3006"}) payment_methods = PaymentMethodSetting.create({payment_method:"VISA",gateway_url: "http://192.168.1.47:3006"})
payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http//192.168.1.47:3006"}) payment_methods = PaymentMethodSetting.create({payment_method:"JCB",gateway_url: "http://192.168.1.47:3006"})
payment_methods = PaymentMethodSetting.create({payment_method:"Master",gateway_url: "http//192.168.1.47:3006"}) payment_methods = PaymentMethodSetting.create({payment_method:"Master",gateway_url: "http://192.168.1.47:3006"})
payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"}) payment_methods = PaymentMethodSetting.create({payment_method:"Redeem",gateway_url: "http://192.168.1.47:3006",merchant_account_id:"vWSsseoZCzxd6xcNf_uS"})
puts " Finished System Default Set Up Data " puts " Finished System Default Set Up Data "