update queue no print
This commit is contained in:
@@ -29,6 +29,15 @@ class Crm::DiningQueuesController < BaseCrmController
|
||||
|
||||
respond_to do |format|
|
||||
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.json { render :show, status: :created, location: @dining_queue }
|
||||
else
|
||||
|
||||
@@ -74,6 +74,16 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
self.print("tmp/receipt_bill.pdf")
|
||||
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
|
||||
def print_crm_order(booking,order_items,setting)
|
||||
#Use CUPS service
|
||||
|
||||
58
app/pdf/queue_no_pdf.rb
Normal file
58
app/pdf/queue_no_pdf.rb
Normal 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
|
||||
@@ -206,6 +206,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
|
||||
# show member information
|
||||
def member_info(member_info)
|
||||
|
||||
move_down 7
|
||||
if member_info["status"] == true
|
||||
member_info["data"].each do |res|
|
||||
|
||||
@@ -1,16 +1,25 @@
|
||||
|
||||
<%= simple_form_for([:crm,@dining_queue]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<p class="hidden generate_no"><%= @queue_no %></p>
|
||||
<div class="form-inputs">
|
||||
<%= f.input :name %>
|
||||
<%= f.input :contact_no %>
|
||||
<%= f.input :queue_no %>
|
||||
<%= f.input :queue_no , :class => "dining",:id => "dining", :readonly => true%>
|
||||
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<div class="form-actions">
|
||||
<%= f.button :submit %>
|
||||
</div>
|
||||
<% 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>
|
||||
|
||||
Reference in New Issue
Block a user