diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index b1dc732d..b39a4c6e 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -51,6 +51,7 @@ $(document).ready(function(){ var customer_id=$(this).find(".customer-id").text(); show_customer_details(customer_id); + $("#re-print").val(unique_id); var cashier=""; var receipt_date=""; @@ -200,6 +201,14 @@ $(document).ready(function(){ 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){ if(window.location.pathname.substring(0, 12) == "/origami/SAL"){ @@ -298,19 +307,25 @@ function control_button(order_status){ $("#request_bills").prop('disabled', true); $("#discount").prop('disabled', false); $("#pay-bill").prop('disabled', false); + $("#re-print").prop('disabled', true); } else if(order_status=="new") { $("#customer").prop('disabled', false); $("#request_bills").prop('disabled', false); $("#discount").prop('disabled', true); $("#pay-bill").prop('disabled', true); + $("#re-print").prop('disabled', true); + }else if(order_status=="completed"){ + $("#re-print").prop('disabled', false); } else { $("#customer").prop('disabled', true); $("#request_bills").prop('disabled', true); $("#discount").prop('disabled', true); $("#pay-bill").prop('disabled', true); + $("#re-print").prop('disabled', true); } + } /* For Receipt - Update Balance */ diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb index 9e8cd06c..41655d98 100644 --- a/app/controllers/crm/dining_queues_controller.rb +++ b/app/controllers/crm/dining_queues_controller.rb @@ -15,6 +15,7 @@ class Crm::DiningQueuesController < BaseCrmController # GET /crm/dining_queues/new def new @dining_queue = DiningQueue.new + @queue_no = DiningQueue.generate_queue_no end # GET /crm/dining_queues/1/edit @@ -25,9 +26,18 @@ class Crm::DiningQueuesController < BaseCrmController # POST /crm/dining_queues.json def create @dining_queue = DiningQueue.new(dining_queue_params) - + 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 diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 01cedcbe..ca497b81 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -77,4 +77,28 @@ class Origami::PaymentsController < BaseOrigamiController 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 diff --git a/app/controllers/transactions/manual_sales_controller.rb b/app/controllers/transactions/manual_sales_controller.rb new file mode 100644 index 00000000..77dd4371 --- /dev/null +++ b/app/controllers/transactions/manual_sales_controller.rb @@ -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 diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index 8088e0a3..fed62a34 100644 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -60,7 +60,7 @@ class Transactions::SalesController < ApplicationController else @membership = 0 end - #end customer amount + #end customer amount respond_to do |format| format.html # show.html.erb @@ -117,38 +117,6 @@ class Transactions::SalesController < ApplicationController 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 # Use callbacks to share common setup or constraints between actions. def set_transactions_sale diff --git a/app/models/dining_queue.rb b/app/models/dining_queue.rb index ea6a1381..09f8b6b5 100644 --- a/app/models/dining_queue.rb +++ b/app/models/dining_queue.rb @@ -1,2 +1,7 @@ class DiningQueue < ApplicationRecord + + def self.generate_queue_no + queue_no = DiningQueue.all.count + 1 + return queue_no + end end diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index e8fb111a..92468b0e 100644 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -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 diff --git a/app/pdf/queue_no_pdf.rb b/app/pdf/queue_no_pdf.rb new file mode 100644 index 00000000..704dbfdb --- /dev/null +++ b/app/pdf/queue_no_pdf.rb @@ -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 diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 9d5742d6..2d67989d 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -206,18 +206,20 @@ class ReceiptBillPdf < Prawn::Document # show member information def member_info(member_info) + move_down 7 - if member_info["data"] == true + if member_info["status"] == true member_info["data"].each do |res| - stroke_horizontal_rule + move_down 5 y_position = cursor - - bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do - text "#{ res["accountable_type"] } : #{ res["balance"] }", :size => self.item_font_size,:align => :left + bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do + text "#{ res["accountable_type"] }", :size => self.item_font_size,:align => :left end - - move_down 5 + 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 end end diff --git a/app/views/crm/dining_queues/_form.html.erb b/app/views/crm/dining_queues/_form.html.erb index a99f6b76..7f02ac15 100644 --- a/app/views/crm/dining_queues/_form.html.erb +++ b/app/views/crm/dining_queues/_form.html.erb @@ -1,16 +1,25 @@ <%= simple_form_for([:crm,@dining_queue]) do |f| %> <%= f.error_notification %> - +
<%= @queue_no %>
| - | ||
Customer Details |
- - | - |
|---|---|---|
| - | Name | -<%= @customer.name %> | -
| - | <%= @customer.email %> | -|
| - | Contact no | -<%= @customer.contact_no %> | -
| - | Company | -<%= @customer.company rescue '-' %> | -
| - | Date Of Birth | -<%= @customer.date_of_birth rescue '-' %> | -
Membership Details |
- - | - |
| "There is no membership data" | -||
| - | <%= member["accountable_type"] %> | -<%= member["balance"] %> | -