diff --git a/app/models/ability.rb b/app/models/ability.rb index 548cc1cd..6bcdd204 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -31,6 +31,7 @@ class Ability can :manage, Sale can :manage, Customer + can :manage, DiningQueue can :index, :dailysale can :index, :saleitem diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index f80ee72d..8023742c 100644 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -10,7 +10,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # check for item not to show if order_item[0].price != 0 - pdf = OrderItemPdf.new(order_item[0], print_status, options) + pdf = OrderItemPdf.new(order_item[0], print_status, options, oqs.use_alternate_name) pdf.render_file filename if oqs.print_copy @@ -31,6 +31,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker #Generate PDF #Print order=print_query('order_summary', order_id) + # For Print Per Item if oqs.cut_per_item order_items.each do|odi| @@ -40,7 +41,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # check for item not to show if odi.price != 0 || odi.price != 10 - pdf = OrderItemPdf.new(odi, print_status, options) + pdf = OrderItemPdf.new(odi, print_status, options, oqs.use_alternate_name) # pdf.render_file "tmp/order_item.pdf" pdf.render_file filename if oqs.print_copy @@ -54,7 +55,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # For Print Order Summary else filename = "tmp/order_summary_#{ order_id }" + ".pdf" - pdf = OrderSummaryPdf.new(order, print_status, order_items) + pdf = OrderSummaryPdf.new(order, print_status, order_items, oqs.use_alternate_name) pdf.render_file filename if oqs.print_copy self.print(filename, oqs.printer_name) @@ -80,7 +81,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # check for item not to show if odi.price != 0 - pdf = OrderItemPdf.new(odi, print_status, options) + pdf = OrderItemPdf.new(odi, print_status, options,oqs.use_alternate_name) pdf.render_file filename if oqs.print_copy @@ -97,7 +98,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # For Print Order Summary else filename = "tmp/booking_summary_#{ booking_id }" + ".pdf" - pdf = OrderSummaryPdf.new(order, print_status) + pdf = OrderSummaryPdf.new(order, print_status,oqs.use_alternate_name) pdf.render_file filename if oqs.print_copy self.print(filename, oqs.printer_name) @@ -114,31 +115,34 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker # Query for OQS with status def print_query(type, id) if type == "order_item" - OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining") + OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name") .joins("left join orders ON orders.order_id = order_items.order_id left join booking_orders AS bo ON bo.order_id=order_items.order_id left join bookings AS b ON b.booking_id = bo.booking_id left join dining_facilities AS df ON df.id = b.dining_facility_id - left join customers as cus ON cus.customer_id = orders.customer_id") + left join customers as cus ON cus.customer_id = orders.customer_id + left join menu_items as item ON item.item_code = order_items.item_code") .where("order_items.item_code = '#{ id }' AND order_items.price != 0") .group("order_items.item_code") elsif type == "order_summary" - OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining") + OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name") .joins("left join orders ON orders.order_id = order_items.order_id left join booking_orders AS bo ON bo.order_id=order_items.order_id left join bookings AS b ON b.booking_id = bo.booking_id left join dining_facilities AS df ON df.id = b.dining_facility_id - left join customers as cus ON cus.customer_id = orders.customer_id") + left join customers as cus ON cus.customer_id = orders.customer_id + left join menu_items as item ON item.item_code = order_items.item_code") .where("orders.order_id = '#{ id }' AND order_items.price != 0") .group("order_items.order_items_id") else # order summary for booking - OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining") + OrderItem.select("order_items.order_id, order_items.item_code, order_items.item_name, order_items.qty, order_items.price, order_items.options, order_items.item_order_by as order_by, order_items.created_at as order_at, cus.name as customer, df.type, df.name as dining,item.alt_name as alt_name") .joins("left join orders ON orders.order_id = order_items.order_id left join booking_orders AS bo ON bo.order_id=order_items.order_id left join bookings AS b ON b.booking_id = bo.booking_id left join dining_facilities AS df ON df.id = b.dining_facility_id - left join customers as cus ON cus.customer_id = orders.customer_id") + left join customers as cus ON cus.customer_id = orders.customer_id + left join menu_items as item ON item.item_code = order_items.item_code") .where("b.booking_id = '#{ id }' AND order_items.price != 0") end diff --git a/app/pdf/order_item_pdf.rb b/app/pdf/order_item_pdf.rb index b6c821fc..3f697e06 100644 --- a/app/pdf/order_item_pdf.rb +++ b/app/pdf/order_item_pdf.rb @@ -1,6 +1,6 @@ class OrderItemPdf < 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(order_item, print_status, options) + def initialize(order_item, print_status, options, alt_name) self.page_width = 210 self.page_height = 1450 self.margin = 5 @@ -15,9 +15,9 @@ class OrderItemPdf < Prawn::Document super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) # super(:margin => [10, 5, 30, 5], :page_size => [200,400]) - # font "public/fonts/#{font_name}".to_s + ".ttf".to_s - # font "public/fonts/Zawgyi-One.ttf" - # font "public/fonts/padauk.ttf" + # font "public/fonts/#{font_name}".to_s + ".ttf".to_s + font "public/fonts/Zawgyi-One.ttf" + font "public/fonts/padauk.ttf" self.header_font_size = 12 self.item_font_size = 10 @@ -29,7 +29,7 @@ class OrderItemPdf < Prawn::Document order_info(order_item.order_id, order_item.order_by,order_item.order_at) # order items - order_items(order_item, options) + order_items(order_item, options, alt_name) end # Write Order Information to PDF @@ -57,11 +57,11 @@ class OrderItemPdf < Prawn::Document end # Write Order items to PDF - def order_items(order_item, options) + def order_items(order_item, options, alt_name) y_position = cursor #Add Order Item - add_order_items(order_item, options) + add_order_items(order_item, options, alt_name) dash(1, :space => 1, :phase => 1) stroke_horizontal_line 0, (self.page_width - self.margin) @@ -69,7 +69,7 @@ class OrderItemPdf < Prawn::Document end # Add order items under order info - def add_order_items(order_item, options) + def add_order_items(order_item, options, alt_name) y_position = cursor move_down 5 @@ -82,6 +82,14 @@ class OrderItemPdf < Prawn::Document text "[#{order_item.qty.to_i}]", :size => self.item_font_size,:align => :left end + move_down 3 + if alt_name + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "(#{order_item.alt_name})", :size => self.item_font_size,:align => :left + end + end + move_down 5 # add option diff --git a/app/pdf/order_summary_pdf.rb b/app/pdf/order_summary_pdf.rb index 89eac43c..d5b11d23 100644 --- a/app/pdf/order_summary_pdf.rb +++ b/app/pdf/order_summary_pdf.rb @@ -1,6 +1,6 @@ class OrderSummaryPdf < 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(order, print_status, order_items = nil) + def initialize(order, print_status, order_items = nil,alt_name) self.page_width = 210 self.page_height = 1450 self.margin = 5 @@ -15,8 +15,8 @@ class OrderSummaryPdf < Prawn::Document super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height]) # font "public/fonts/#{font_name}".to_s + ".ttf".to_s - # font "public/fonts/Zawgyi-One.ttf" - # font "public/fonts/padauk.ttf" + font "public/fonts/Zawgyi-One.ttf" + font "public/fonts/padauk.ttf" self.header_font_size = 12 self.item_font_size = 10 @@ -31,7 +31,7 @@ class OrderSummaryPdf < Prawn::Document if order_items == nil order_items(order) else - order_items(order_items) + order_items(order_items, alt_name) end end @@ -60,7 +60,7 @@ class OrderSummaryPdf < Prawn::Document end # Write Order items to PDF - def order_items(order_item) + def order_items(order_item, alt_name) y_position = cursor bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do @@ -75,12 +75,12 @@ class OrderSummaryPdf < Prawn::Document move_down 5 #Add Order Item - add_order_items(order_item) + add_order_items(order_item, alt_name) end # Add order items under order info - def add_order_items(order_item) + def add_order_items(order_item, alt_name) y_position = cursor move_down 5 @@ -98,6 +98,13 @@ class OrderSummaryPdf < Prawn::Document text "#{odi.qty}", :size => self.item_font_size,:align => :left end + move_down 3 + if alt_name + y_position = cursor + bounding_box([0,y_position], :width => self.item_width, :height => self.item_height) do + text "(#{odi.alt_name})", :size => self.item_font_size,:align => :left + end + end move_down 5 # add option diff --git a/app/views/reports/saleitem/index.xls.erb b/app/views/reports/saleitem/index.xls.erb index 2807ec3f..3773619b 100644 --- a/app/views/reports/saleitem/index.xls.erb +++ b/app/views/reports/saleitem/index.xls.erb @@ -49,22 +49,6 @@ <% @sale_data.order("total_item desc").each do |sale| %> - <% if !acc_arr.include?(sale.account_id) %> -