From 8388192a81be9a92fea7fda086d2a67055018955 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 8 Jun 2017 14:46:35 +0630 Subject: [PATCH 1/2] delete view origami file --- Gemfile | 9 +- Gemfile.lock | 27 +- app/views/origami/home/index.html.erb | 367 ---------------------- app/views/origami/home/index_old.html.erb | 328 ------------------- 4 files changed, 9 insertions(+), 722 deletions(-) delete mode 100644 app/views/origami/home/index.html.erb delete mode 100644 app/views/origami/home/index_old.html.erb diff --git a/Gemfile b/Gemfile index a272cec9..551503f9 100644 --- a/Gemfile +++ b/Gemfile @@ -10,11 +10,11 @@ end gem 'rails', '~> 5.1.0' # Use mysql as the database for Active Record -#gem 'mysql2', '>= 0.3.18', '< 0.5' +gem 'mysql2', '>= 0.3.18', '< 0.5' #Use PosgreSQL -gem 'pg' +#gem 'pg' # redis server for cable @@ -46,9 +46,6 @@ gem 'to_xls-rails' #Reporting gem #gem 'compendium' -# Pagination -gem 'kaminari', :git => "git://github.com/amatsuda/kaminari.git", :branch => 'master' - # Use jquery as the JavaScript library gem 'jquery-rails' # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks @@ -63,7 +60,7 @@ gem 'bcrypt', '~> 3.1.7' gem 'sidekiq' # Pagination -gem 'kaminari', :git => "git://github.com/amatsuda/kaminari.git", :branch => 'master' +gem 'kaminari', '~> 0.16.3' # Use Capistrano for deployment # gem 'capistrano-rails', group: :development diff --git a/Gemfile.lock b/Gemfile.lock index 2c4c94b3..7281b442 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,21 +1,3 @@ -GIT - remote: git://github.com/amatsuda/kaminari.git - revision: bc52ae73d41386d344b5d1b18e689e5a988f1a03 - branch: master - specs: - kaminari (1.0.1) - activesupport (>= 4.1.0) - kaminari-actionview (= 1.0.1) - kaminari-activerecord (= 1.0.1) - kaminari-core (= 1.0.1) - kaminari-actionview (1.0.1) - actionview - kaminari-core (= 1.0.1) - kaminari-activerecord (1.0.1) - activerecord - kaminari-core (= 1.0.1) - kaminari-core (1.0.1) - GEM remote: https://rubygems.org/ specs: @@ -104,6 +86,9 @@ GEM rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) + kaminari (0.16.3) + actionpack (>= 3.0.0) + activesupport (>= 3.0.0) listen (3.0.8) rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) @@ -119,11 +104,11 @@ GEM minitest (5.10.2) multi_json (1.12.1) multi_xml (0.6.0) + mysql2 (0.4.6) nio4r (2.1.0) nokogiri (1.7.2) mini_portile2 (~> 2.1.0) pdf-core (0.7.0) - pg (0.20.0) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) @@ -256,9 +241,9 @@ DEPENDENCIES httparty (~> 0.15.5) jbuilder (~> 2.5) jquery-rails - kaminari! + kaminari (~> 0.16.3) listen (~> 3.0.5) - pg + mysql2 (>= 0.3.18, < 0.5) prawn prawn-table puma (~> 3.0) diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb deleted file mode 100644 index 48de0315..00000000 --- a/app/views/origami/home/index.html.erb +++ /dev/null @@ -1,367 +0,0 @@ -
- -
- - - - - -
- - -
-
- <% - @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 - %> -
-
- -

<%= bko.table_name %>

-

- Receipt No : - - <%= bko.receipt_no %> - -

-

- Order Status : - - <%= bko.order_status %> - - -

-
-
- <% - end - %> -
-
- - -
-
- <% - @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 - %> -
-
- -

<%= rmo.room_name %>

-

- Receipt No : - - <%= rmo.receipt_no %> - -

-

- Order Status : - - <%= rmo.order_status %> - - -

-
-
- <% - end - %> -
-
- - -
-
- <% - @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 - %> -
-
- -

<%= odr.table_name %>

-

- Receipt No : - - <%= odr.receipt_no %> - -

-

- Order Status : - - <%= odr.order_status %> - - -

-
-
- <% - end - %> -
- -
-
- -
- - - -
-
-
-
ORDER DETAILS -
-
-
-
-
-

Receipt No:

-

Cashier:

-
-
-

Date:

-
-
-
- - - - - - - - - -
ItemsQTY - Price -
-
- -
-
-

- -
- - - - - - - - - - - -
-
- - - diff --git a/app/views/origami/home/index_old.html.erb b/app/views/origami/home/index_old.html.erb deleted file mode 100644 index d480cf8d..00000000 --- a/app/views/origami/home/index_old.html.erb +++ /dev/null @@ -1,328 +0,0 @@ -
-
- - - - - - -
- - -
- -
- - <% if @booking_orders %> - <% @booking_orders.each do |booking_order| %> - <% if booking_order.order_status != "new" %> -
-
-

- <%=booking_order.table_name%>

- Receipt No : <%=booking_order.receipt_no%>
- Order Status : <%=booking_order.order_status %> -
-
- <% else %> -
-
-

<%=booking_order.table_name%>

- Order Status : <%=booking_order.order_status %> -
-
- <% end %> - <%end %> - <%end %> -
-
- - -
- -
- - <% if @booking_rooms %> - <% @booking_rooms.each do |booking_room| %> - <% if !booking_room.order_status = 'new'%> -
-
-

- <%=booking_room.room_name%>

- Receipt No : <%=booking_room.receipt_no%>
- Order Status : <%=booking_room.order_status %> -
-
- <% else %> -
-
-

<%=booking_room.room_name%>ddd

\ - Order Status : <%=booking_room.order_status %> -
-
- <% end %> - <%end %> - <%end %> -
-
- - -
- - -
- - <% if @orders %> - <% @orders.each do |order| %> - <% if !order.order_status = 'new'%> -
-
-

- Order No:<%=order.order_id%>

- Receipt No : <%=order.receipt_no%>
- Order Status : <%=order.order_status %> -
-
- <% else %> -
-
-

Order No:<%=order.order_id%>

- Order Status : <%=order.order_status %> -
-
- <% end %> - <%end %> - <%end %> -
-
- -
- -
- -
-
-
-
ORDER DETAILS -

-
-
-
-
- - - - - - -
ItemsQTY - Price -
-
-
- - - - - - - - - -
- - - - - -
-
- - -
-
-
- -
- - - - - - - - - - - - -
-
- - From ea4f50e77942a7ccaa988af4dedd8cb4665b59c7 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Thu, 8 Jun 2017 16:52:50 +0630 Subject: [PATCH 2/2] update print --- app/assets/javascripts/orgiami.js | 13 + app/controllers/crm/home_controller.rb | 16 +- .../origami/request_bills_controller.rb | 2 + app/models/printer/receipt_printer.rb | 4 +- app/pdf/crm_order_pdf.rb | 155 +++++++----- app/views/crm/home/_booking.html.erb | 35 +-- app/views/crm/home/_queue.html.erb | 1 + app/views/crm/home/index.html.erb | 5 - app/views/layouts/_header_crm.html.erb | 2 +- app/views/origami/home/index.html.erb | 225 ++++++++++++++++++ 10 files changed, 372 insertions(+), 86 deletions(-) create mode 100644 app/views/origami/home/index.html.erb diff --git a/app/assets/javascripts/orgiami.js b/app/assets/javascripts/orgiami.js index cd8622c3..ad77aea9 100644 --- a/app/assets/javascripts/orgiami.js +++ b/app/assets/javascripts/orgiami.js @@ -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; + }); }); diff --git a/app/controllers/crm/home_controller.rb b/app/controllers/crm/home_controller.rb index 43cc322a..9ae2b413 100644 --- a/app/controllers/crm/home_controller.rb +++ b/app/controllers/crm/home_controller.rb @@ -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 diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index c5b87b6b..ed7aa466 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -27,3 +27,5 @@ class Origami::RequestBillsController < BaseOrigamiController redirect_to origami_root_path end +end + diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 523b9ec9..d203568f 100644 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -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 diff --git a/app/pdf/crm_order_pdf.rb b/app/pdf/crm_order_pdf.rb index 36aed0a1..94fc5503 100644 --- a/app/pdf/crm_order_pdf.rb +++ b/app/pdf/crm_order_pdf.rb @@ -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 diff --git a/app/views/crm/home/_booking.html.erb b/app/views/crm/home/_booking.html.erb index 53bc6b82..3a2a7684 100644 --- a/app/views/crm/home/_booking.html.erb +++ b/app/views/crm/home/_booking.html.erb @@ -6,7 +6,8 @@ <% @booking.each do |booking| %> <% if booking.booking_status == "new" %>
-
+
+

<%= @i += 1 %> . <%= booking.dining_facility.name %> - <%= booking.id %> @@ -36,50 +37,50 @@ diff --git a/app/views/layouts/_header_crm.html.erb b/app/views/layouts/_header_crm.html.erb index 7e497f1e..31dee08d 100644 --- a/app/views/layouts/_header_crm.html.erb +++ b/app/views/layouts/_header_crm.html.erb @@ -4,7 +4,7 @@ CRM

- Queue | Bookings | Online Orders | Customers + Queue | Bookings | Online Orders | <%= link_to 'Customer', crm_customers_path, :html=>":color:white" %>
diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb new file mode 100644 index 00000000..61813a7c --- /dev/null +++ b/app/views/origami/home/index.html.erb @@ -0,0 +1,225 @@ +
+ +
+ + + + + +
+ + +
+
+ <% + @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 + %> +
+
+ +

<%= bko.table_name %>

+

+ Receipt No : + + <%= bko.receipt_no %> + +

+

+ Order Status : + + <%= bko.order_status %> + + +

+
+
+ <% + end + %> +
+
+ + +
+
+ <% + @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 + %> +
+
+ +

<%= rmo.room_name %>

+

+ Receipt No : + + <%= rmo.receipt_no %> + +

+

+ Order Status : + + <%= rmo.order_status %> + + +

+
+
+ <% + end + %> +
+
+ + +
+
+ <% + @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 + %> +
+
+ +

<%= odr.table_name %>

+

+ Receipt No : + + <%= odr.receipt_no %> + +

+

+ Order Status : + + <%= odr.order_status %> + + +

+
+
+ <% + end + %> +
+ +
+
+ +
+ + + +
+
+
+
ORDER DETAILS -
+
+
+
+
+

Receipt No:

+

Cashier:

+
+
+

Date:

+
+
+
+ + + + + + + + + +
ItemsQTY + Price +
+
+ +
+
+
+ + +
+ + + + + + + + + + + +
+