update print
This commit is contained in:
@@ -22,6 +22,13 @@ $(document).ready(function(){
|
||||
var receipt_no=$(this).find(".orders-receipt-no").text();
|
||||
var unique_id=$(this).find(".orders-id").text();
|
||||
|
||||
//for customer button
|
||||
if(unique_id.charAt(0) == 'S'){
|
||||
$("#customer").removeAttr('disabled');
|
||||
}else{
|
||||
$("#customer").attr('disabled','disabled');
|
||||
}
|
||||
|
||||
var cashier="";
|
||||
var receipt_date="";
|
||||
var sub_total=0;
|
||||
@@ -96,6 +103,12 @@ $(document).ready(function(){
|
||||
window.location.href = '/origami/sale/'+ sale_id + "/payment"
|
||||
return false;
|
||||
});
|
||||
|
||||
$('#customer').click(function() {
|
||||
var sale_id=$(".selected-item").find(".orders-id").text();
|
||||
window.location.href = '/crm/customers/'+ sale_id + "/assign_sale_id"
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,20 @@ class Crm::HomeController < BaseCrmController
|
||||
def print_order
|
||||
|
||||
@booking = Booking.find(params[:id])
|
||||
|
||||
@total_amount = 0.00
|
||||
@total_tax = 0.00
|
||||
|
||||
if @booking.booking_orders
|
||||
order_items = []
|
||||
@booking.booking_orders.each do |bo|
|
||||
order = Order.find(bo.order_id)
|
||||
#if (order.status == "new")
|
||||
order_items = order_items + order.order_items
|
||||
#end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
unique_code="CrmOrderPdf"
|
||||
|
||||
@@ -20,7 +34,7 @@ class Crm::HomeController < BaseCrmController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
printer.print_crm_order(@booking,print_settings)
|
||||
printer.print_crm_order(@booking,order_items,print_settings)
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -27,3 +27,5 @@ class Origami::RequestBillsController < BaseOrigamiController
|
||||
redirect_to origami_root_path
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -74,11 +74,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
end
|
||||
|
||||
#Bill Receipt Print
|
||||
def print_crm_order(booking,setting)
|
||||
def print_crm_order(booking,order_items,setting)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
pdf = CrmOrderPdf.new(booking,setting)
|
||||
pdf = CrmOrderPdf.new(booking,order_items,setting)
|
||||
pdf.render_file "tmp/print_crm_order.pdf"
|
||||
self.print("tmp/print_crm_order.pdf")
|
||||
end
|
||||
|
||||
@@ -1,71 +1,106 @@
|
||||
class CrmOrderPdf < 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(booking,order_items,print_settings)
|
||||
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
|
||||
|
||||
def initialize(order_item, print_settings)
|
||||
super(:margin => [10, 5, 30, 5], :page_size => [200,400])
|
||||
@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 = 7
|
||||
self.item_font_size = 9
|
||||
|
||||
# font "public/fonts/#{font_name}".to_s + ".ttf".to_s
|
||||
# font "public/fonts/Zawgyi-One.ttf"
|
||||
# font "public/fonts/padauk.ttf"
|
||||
font_size 9
|
||||
text "#{order_item.type}", :size => 15
|
||||
stroke_horizontal_rule
|
||||
move_down 5
|
||||
header( booking.type, booking.dining_facility.name)
|
||||
stroke_horizontal_rule
|
||||
order_detail(booking.checkin_by,booking.checkin_at,booking.dining_facility.name)
|
||||
line_items(order_items)
|
||||
#all_total(order_items)
|
||||
|
||||
#order_info
|
||||
order_info(order_item.checkin_by,order_item.checkin_at, order_item.customer_id)
|
||||
|
||||
# order items
|
||||
order_items(order_item)
|
||||
|
||||
end
|
||||
|
||||
# Write Order Information to PDF
|
||||
def order_info(order_by, order_at, customer)
|
||||
y_position = cursor
|
||||
def header (type, name)
|
||||
text "#{type}", :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
|
||||
|
||||
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.sale_id}", :size => 7,:align => :left
|
||||
end
|
||||
|
||||
bounding_box([160,y_position], :width => 20, :height => 20) do
|
||||
text "#{order_item.sale_id}", :size => 7,:align => :right
|
||||
end
|
||||
|
||||
move_down 5
|
||||
stroke_horizontal_rule
|
||||
|
||||
end
|
||||
|
||||
def order_detail(order_by,order_at,customer)
|
||||
move_down 5
|
||||
move_down 2
|
||||
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 "Order By", :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 "Order At", :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 "Customer", :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
|
||||
|
||||
}
|
||||
|
||||
move_down 5
|
||||
stroke_horizontal_rule
|
||||
y_position = cursor
|
||||
pad_top(15) {
|
||||
|
||||
text_box "#{order_by}", :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 "#{order_at.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 "#{customer}", :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
|
||||
|
||||
}
|
||||
end
|
||||
|
||||
def line_items(order_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
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
end
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
<% @booking.each do |booking| %>
|
||||
<% if booking.booking_status == "new" %>
|
||||
<div class="card">
|
||||
<div class="card-block booking_click" data-id="sfddf" data-ref="<%= api_booking_path booking.id%>" id="card-block booking_block" style="width:100%;" >
|
||||
<div class="card-block booking_click" data-id="sfddf" data-ref="<%= api_booking_path booking.id%>" id="card-block booking_block" >
|
||||
<p class="hidden booking-id"><%= booking.id %></p>
|
||||
<h4 class="card-title">
|
||||
<%= @i += 1 %> . <%= booking.dining_facility.name %>
|
||||
- <%= booking.id %>
|
||||
@@ -36,50 +37,50 @@
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
|
||||
|
||||
|
||||
$(".booking_click").on("click", function(){
|
||||
$(".booking_click").on("click", function(){
|
||||
$(".summary-items tbody tr").remove();
|
||||
$("#cancel").removeAttr("disabled");
|
||||
$("#assign").removeAttr("disabled");
|
||||
|
||||
|
||||
$("#crm_print").removeAttr("disabled");
|
||||
var booking_id = $(this).find(".booking-id").text();
|
||||
$("#crm_print").val(booking_id);
|
||||
$("#crm_print").removeAttr("disabled");
|
||||
|
||||
var url = $(this).attr('data-ref');
|
||||
show_details(url);
|
||||
});
|
||||
|
||||
$('.crm_print').click(function() {
|
||||
var id = $(this).val();
|
||||
alert(id)
|
||||
});
|
||||
|
||||
$('.crm_print').click(function() {
|
||||
var booking_id = $('#crm_print').val();
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "crm/print/"+id,
|
||||
url: "crm/print/"+booking_id,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$('.assign').click(function(e){
|
||||
$('.assign').click(function(e){
|
||||
var booking_id = $(this).val()
|
||||
var type = $(this).attr("data-type")
|
||||
|
||||
update_booking(booking_id,type)
|
||||
});
|
||||
});
|
||||
|
||||
$('.cancel').click(function(e){
|
||||
$('.cancel').click(function(e){
|
||||
var booking_id = $(this).val()
|
||||
var type = $(this).attr("data-type")
|
||||
|
||||
update_booking(booking_id,type)
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
function show_details(url_item){
|
||||
$.ajax({
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<% if booking.booking_status == "assign" %>
|
||||
<div class="card booking_click" data-ref="<%= api_booking_path booking.id%>" id="booking_block">
|
||||
<div class="card-block" id="card-block" style="width:100%;">
|
||||
<p class="hidden booking-id"><%= booking.id %></p>
|
||||
<h4 class="card-title">
|
||||
<%= @i += 1 %> . <%= booking.dining_facility.name %>
|
||||
- <%= booking.id %>
|
||||
|
||||
@@ -102,10 +102,5 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$( document ).ready(function() {
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<strong>CRM</strong>
|
||||
</div>
|
||||
<div style="float:left;margin-top:3px;text-align:left; width:600px">
|
||||
Queue | Bookings | Online Orders | Customers
|
||||
Queue | Bookings | Online Orders | <%= link_to 'Customer', crm_customers_path, :html=>":color:white" %>
|
||||
</div>
|
||||
|
||||
<div style="float:right; margin-top:3px; text-align:right;width:200px;color:#ffffff">
|
||||
|
||||
225
app/views/origami/home/index.html.erb
Normal file
225
app/views/origami/home/index.html.erb
Normal file
@@ -0,0 +1,225 @@
|
||||
<div class="row">
|
||||
<!-- Column One -->
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#tables" role="tab">Tables</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#rooms" role="tab">Rooms</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#orders" role="tab">Orders</a>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- Nav tabs - End -->
|
||||
|
||||
<div class="tab-content" style="min-height:670px; max-height:670px; overflow:auto">
|
||||
|
||||
<!--- Panel 0 - Table Orders -->
|
||||
<div class="tab-pane active" id="tables" role="tabpanel">
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
|
||||
<%
|
||||
@booking_orders.each do |bko|
|
||||
# Assigned Id for new Order? Sale?
|
||||
unique_id=""
|
||||
# For CSS- Class for Order? Sale?
|
||||
sale_status=""
|
||||
if bko.order_status == 'new'
|
||||
unique_id=bko.booking_id
|
||||
else
|
||||
unique_id=bko.sale_id
|
||||
sale_status="sold"
|
||||
end
|
||||
%>
|
||||
<div class="card orders <%= sale_status %>">
|
||||
<div class="card-block">
|
||||
<p class="hidden orders-id"><%= unique_id %></p>
|
||||
<h4 class="card-title orders-table"><%= bko.table_name %></h4>
|
||||
<p class="card-text">
|
||||
Receipt No :
|
||||
<span class="orders-receipt-no">
|
||||
<%= bko.receipt_no %>
|
||||
</span>
|
||||
</p>
|
||||
<p class="card-text">
|
||||
Order Status :
|
||||
<span class="orders-order-status">
|
||||
<%= bko.order_status %>
|
||||
</span>
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<%
|
||||
end
|
||||
%>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--- Panel 1 - Room Orders -->
|
||||
<div class="tab-pane active" id="rooms" role="tabpanel">
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
|
||||
<%
|
||||
@booking_rooms.each do |rmo|
|
||||
# Assigned Id for new Order? Sale?
|
||||
unique_id=""
|
||||
# For CSS- Class for Order? Sale?
|
||||
sale_status=""
|
||||
if rmo.order_status == 'new'
|
||||
unique_id=rmo.booking_id
|
||||
else
|
||||
unique_id=rmo.sale_id
|
||||
sale_status="sold"
|
||||
end
|
||||
%>
|
||||
<div class="card orders <%= sale_status %>">
|
||||
<div class="card-block">
|
||||
<p class="hidden orders-id"><%= unique_id %></p>
|
||||
<h4 class="card-title orders-table"><%= rmo.room_name %></h4>
|
||||
<p class="card-text">
|
||||
Receipt No :
|
||||
<span class="orders-receipt-no">
|
||||
<%= rmo.receipt_no %>
|
||||
</span>
|
||||
</p>
|
||||
<p class="card-text">
|
||||
Order Status :
|
||||
<span class="orders-order-status">
|
||||
<%= rmo.order_status %>
|
||||
</span>
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<%
|
||||
end
|
||||
%>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!--- Panel 2 - Orders -->
|
||||
<div class="tab-pane active" id="orders" role="tabpanel">
|
||||
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
|
||||
<%
|
||||
@orders.each do |odr|
|
||||
# Assigned Id for new Order? Sale?
|
||||
unique_id=""
|
||||
# For CSS- Class for Order? Sale?
|
||||
sale_status=""
|
||||
if odr.order_status == 'new'
|
||||
unique_id=odr.booking_id
|
||||
else
|
||||
unique_id=odr.sale_id
|
||||
sale_status="sold"
|
||||
end
|
||||
%>
|
||||
<div class="card orders <%= sale_status %>">
|
||||
<div class="card-block">
|
||||
<p class="hidden orders-id"><%= unique_id %></p>
|
||||
<h4 class="card-title orders-table"><%= odr.table_name %></h4>
|
||||
<p class="card-text">
|
||||
Receipt No :
|
||||
<span class="orders-receipt-no">
|
||||
<%= odr.receipt_no %>
|
||||
</span>
|
||||
</p>
|
||||
<p class="card-text">
|
||||
Order Status :
|
||||
<span class="orders-order-status">
|
||||
<%= odr.order_status %>
|
||||
</span>
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<%
|
||||
end
|
||||
%>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<!-- tabs - End -->
|
||||
</div>
|
||||
<!-- Column One -->
|
||||
|
||||
<!-- Column Two -->
|
||||
<div class="col-lg-5 col-md-5 col-sm-5">
|
||||
<div class="card" >
|
||||
<div class="card-header">
|
||||
<div><strong id="order-title">ORDER DETAILS -</strong></div>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-title row">
|
||||
<div class="col-lg-6 col-md-6 col-sm-6">
|
||||
<p>Receipt No: <span id="receipt_no"></span></p>
|
||||
<p>Cashier: <span id="cashier"></span></p>
|
||||
</div>
|
||||
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
|
||||
<p>Date: <span id="receipt_date"></span></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-text">
|
||||
<table class="table table-striped" id="order-items-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="item-name">Items</th>
|
||||
<th class="item-attr">QTY</td>
|
||||
<th class="item-attr">Price</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- Append Javascript Template -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<table class="table" id="order-charges-table" border="0">
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Sub Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-sub-total"></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Food:</strong></td>
|
||||
<td class="item-attr"><strong id="order-food"></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Beverage:</strong></td>
|
||||
<td class="item-attr"><strong id="order-beverage"></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Discount:</strong></td>
|
||||
<td class="item-attr"><strong id="order-discount"></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Tax:</strong></td>
|
||||
<td class="item-attr"><strong id="order-Tax"></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="charges-name"><strong>Grand Total:</strong></td>
|
||||
<td class="item-attr"><strong id="order-grand-total"></strong></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Column Three -->
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<!-- Waiter Buttons -->
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Add Order</button>
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Edit</button>
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Move</button>
|
||||
<button type="button" id="customer" class="btn btn-primary btn-lg btn-block" disabled="disabled">Customer</button>
|
||||
<button type="button" id="request_bills" class="btn btn-primary btn-lg btn-block">Req.Bill</button>
|
||||
<!-- Cashier Buttons -->
|
||||
<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">Tax</button>
|
||||
<button type="button" id="pay" 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>
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user