From 58bc13e8b66e0d28b6d2d28361bf13b7b9cc04b5 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 16 Jun 2017 11:14:47 +0630 Subject: [PATCH 01/17] add auto_print field to migration --- db/migrate/20170403151731_create_order_queue_stations.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/db/migrate/20170403151731_create_order_queue_stations.rb b/db/migrate/20170403151731_create_order_queue_stations.rb index 6ad93bb1..6c327b8e 100644 --- a/db/migrate/20170403151731_create_order_queue_stations.rb +++ b/db/migrate/20170403151731_create_order_queue_stations.rb @@ -9,6 +9,7 @@ class CreateOrderQueueStations < ActiveRecord::Migration[5.1] t.integer :font_size, :null => false, :default => 10 t.boolean :cut_per_item, :null => false, :default => false t.boolean :use_alternate_name, :null => false, :default => false + t.boolean :auto_print, :null => false, :default => false t.string :created_by, :null => false t.timestamps end From c40a2c78e7ef58974f74e6361d41bf31e680b658 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 16 Jun 2017 13:44:39 +0630 Subject: [PATCH 02/17] oqs autoprint developing --- app/controllers/oqs/print_controller.rb | 12 +++---- .../order_queue_stations_controller.rb | 2 +- app/models/printer/order_queue_printer.rb | 33 ++++++++++++++----- .../order_queue_stations/_form.html.erb | 1 + .../order_queue_stations/index.html.erb | 2 ++ .../order_queue_stations/show.html.erb | 5 +++ 6 files changed, 40 insertions(+), 15 deletions(-) diff --git a/app/controllers/oqs/print_controller.rb b/app/controllers/oqs/print_controller.rb index ecbc94e7..9fc2a2d7 100644 --- a/app/controllers/oqs/print_controller.rb +++ b/app/controllers/oqs/print_controller.rb @@ -6,13 +6,13 @@ class Oqs::PrintController < ApplicationController assigned_item=AssignedOrderItem.find(assigned_item_id) assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'"); - # printer for each stations - printer_name = assigned_item.order_queue_station.printer_name + # order queue stations + oqs = assigned_item.order_queue_station # print when complete click print_settings=PrintSetting.find_by_unique_code(unique_code) order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) - order_queue_printer.print_order_item(printer_name,assigned_item.order_id, assigned_item.item_code ) + order_queue_printer.print_order_item(oqs,assigned_item.order_id, assigned_item.item_code ) # update print status for completed same order items assigned_items.each do |ai| @@ -28,13 +28,13 @@ class Oqs::PrintController < ApplicationController assigned_item=AssignedOrderItem.find(assigned_item_id) assigned_items=AssignedOrderItem.where("item_code='" + assigned_item.item_code + "' AND " + "order_id='" + assigned_item.order_id + "'"); - # printer for each stations - printer_name = assigned_item.order_queue_station.printer_name + # order queue stations + oqs = assigned_item.order_queue_station # print when complete click print_settings=PrintSetting.find_by_unique_code(unique_code) order_queue_printer= Printer::OrderQueuePrinter.new(print_settings) - order_queue_printer.print_order_summary(printer_name,assigned_item.order_id) + order_queue_printer.print_order_summary(oqs,assigned_item.order_id) # update print status for completed same order items assigned_items.each do |ai| diff --git a/app/controllers/settings/order_queue_stations_controller.rb b/app/controllers/settings/order_queue_stations_controller.rb index e8b9bbe0..408519d2 100644 --- a/app/controllers/settings/order_queue_stations_controller.rb +++ b/app/controllers/settings/order_queue_stations_controller.rb @@ -71,6 +71,6 @@ class Settings::OrderQueueStationsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def settings_order_queue_station_params - params.require(:order_queue_station).permit(:station_name, :is_active, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by) + params.require(:order_queue_station).permit(:station_name, :is_active, :auto_print, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by) end end diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index 9b3f5205..57a819c9 100644 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -1,25 +1,42 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker - def print_order_item(printer_name,order_id, item_code) + def print_order_item(oqs,order_id, item_code) #Use CUPS service #Generate PDF #Print order_item= print_query('order_item', item_code) #OrderItem.find_by_item_code(item_code) pdf = OrderItemPdf.new(order_item[0]) pdf.render_file "tmp/receipt.pdf" - self.print("tmp/receipt.pdf", printer_name) + if oqs.print_copy + self.print("tmp/receipt.pdf", oqs.printer_name)*2 + else + self.print("tmp/receipt.pdf", oqs.printer_name) + end end - def print_order_summary(printer_name,order_id) + def print_order_summary(oqs,order_id) #Use CUPS service #Generate PDF #Print order=print_query('order_summary',order_id) - filename = "tmp/order_summary_#{order_id}" + ".pdf" - pdf = OrderSummaryPdf.new(order) - pdf.render_file filename - - self.print(filename, printer_name) + # For Print Per Item + if oqs.cut_per_item + order.each do|odi| + pdf = OrderItemPdf.new(odi) + pdf.render_file "tmp/receipt.pdf" + if oqs.print_copy + self.print("tmp/receipt.pdf", oqs.printer_name)*2 + else + self.print("tmp/receipt.pdf", oqs.printer_name) + end + end + # For Print Order Summary + else + filename = "tmp/order_summary_#{order_id}" + ".pdf" + pdf = OrderSummaryPdf.new(order) + pdf.render_file filename + self.print(filename, printer_name) + end end # Query for OQS with status diff --git a/app/views/settings/order_queue_stations/_form.html.erb b/app/views/settings/order_queue_stations/_form.html.erb index db7ed5fd..bc76f044 100644 --- a/app/views/settings/order_queue_stations/_form.html.erb +++ b/app/views/settings/order_queue_stations/_form.html.erb @@ -4,6 +4,7 @@
<%= f.input :station_name %> <%= f.input :is_active %> + <%= f.input :auto_print %> <%= f.input :printer_name %> <%= f.input :font_size %> <%= f.input :print_copy %> diff --git a/app/views/settings/order_queue_stations/index.html.erb b/app/views/settings/order_queue_stations/index.html.erb index 03da3c23..287fb10b 100644 --- a/app/views/settings/order_queue_stations/index.html.erb +++ b/app/views/settings/order_queue_stations/index.html.erb @@ -17,6 +17,7 @@ Station name Is active + Auto Print Print copy Printer name Cut per item @@ -31,6 +32,7 @@ <%= link_to settings_order_queue_station.station_name, settings_order_queue_station_path(settings_order_queue_station) %> <%= settings_order_queue_station.is_active %> + <%= settings_order_queue_station.auto_print %> <%= settings_order_queue_station.print_copy %> <%= settings_order_queue_station.printer_name %> <%= settings_order_queue_station.cut_per_item %> diff --git a/app/views/settings/order_queue_stations/show.html.erb b/app/views/settings/order_queue_stations/show.html.erb index 1a80c2c0..e92ed0bb 100644 --- a/app/views/settings/order_queue_stations/show.html.erb +++ b/app/views/settings/order_queue_stations/show.html.erb @@ -18,6 +18,11 @@ <%= @settings_order_queue_station.is_active %>

+

+ Auto Print: + <%= @settings_order_queue_station.auto_print %> +

+

Processing items: <%= @settings_order_queue_station.processing_items %> From 9ff5122b72f90a45d4703d5ce317655eca47e561 Mon Sep 17 00:00:00 2001 From: Nweni Date: Fri, 16 Jun 2017 18:21:57 +0630 Subject: [PATCH 03/17] Update --- app/views/origami/home/index.html.erb | 20 ++++++++++---------- lib/tasks/clear_data.rake | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 9f6cd7d6..ad09225b 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -82,10 +82,10 @@

-
+
<% @booking_orders.each do |bko| - # No Show completed + # No Show completed if bko.sale_status == 'completed' next end @@ -146,7 +146,7 @@
<% @booking_rooms.each do |rmo| - # No Show completed + # No Show completed if rmo.sale_status == 'completed' next end @@ -207,8 +207,8 @@
<% - @orders.each do |odr| - # No Show completed + @orders.each do |odr| + # No Show completed if odr.sale_status == 'completed' next end @@ -289,7 +289,7 @@

Customer :

- +
@@ -300,14 +300,14 @@ - + <% # For Sale Items sub_total = 0 if @selected_item_type == "Sale" @selected_item.sale_items.each do |sale_item| sub_total += (sale_item.qty*sale_item.unit_price) - %> + %> @@ -319,7 +319,7 @@ %> <% - # For Order Items + # For Order Items if @selected_item_type == "Order" @selected_item.order_items.each do |order_item| sub_total += (order_item.qty*order_item.unit_price) @@ -363,7 +363,7 @@ - +
Price
<%= sale_item.product_name %> <%= sale_item.qty %><%=@selected_item.grand_total rescue 0%>
diff --git a/lib/tasks/clear_data.rake b/lib/tasks/clear_data.rake index 552c2a60..9d4e0ddd 100644 --- a/lib/tasks/clear_data.rake +++ b/lib/tasks/clear_data.rake @@ -11,7 +11,7 @@ namespace :clear do Sale.delete_all SaleAudit.delete_all SalePayment.delete_all - + DiningFacility.update_all(status:'available') puts "Clear Data Done." end end From 841f74b4066ba9ec1e547a6d7afc4732143e09c6 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 16 Jun 2017 18:22:18 +0630 Subject: [PATCH 04/17] update footer in req bill --- app/pdf/receipt_bill_pdf.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 2d67989d..524ee7e5 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -229,7 +229,7 @@ class ReceiptBillPdf < Prawn::Document stroke_horizontal_rule move_down 5 - text "*** Thank You ***", :left_margin => -10, :size => self.header_font_size,:align => :center + text "Thank You! See you Again", :left_margin => -10, :size => self.header_font_size,:align => :center move_down 5 end From 0a496f227446325ffa7723438f3324279aed9a8c Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 16 Jun 2017 18:55:14 +0630 Subject: [PATCH 05/17] update order for oqs --- app/jobs/order_queue_processor_job.rb | 4 ++-- app/models/order.rb | 2 +- app/models/order_queue_station.rb | 24 ++++++++++++++---------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/jobs/order_queue_processor_job.rb b/app/jobs/order_queue_processor_job.rb index e92faa36..5b3423dc 100644 --- a/app/jobs/order_queue_processor_job.rb +++ b/app/jobs/order_queue_processor_job.rb @@ -1,7 +1,7 @@ class OrderQueueProcessorJob < ApplicationJob queue_as :default - def perform(order_id) + def perform(order_id, table_id) # Do something later #Order ID order = Order.find(order_id) @@ -10,7 +10,7 @@ class OrderQueueProcessorJob < ApplicationJob #Execute orders and send to order stations if order oqs = OrderQueueStation.new - oqs.process_order(order) + oqs.process_order(order, table_id) end end diff --git a/app/models/order.rb b/app/models/order.rb index f3ae798c..2ea76a98 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -199,7 +199,7 @@ class Order < ApplicationRecord #Process order items and send to order queue def process_order_queue #Send to background job for processing - OrderQueueProcessorJob.perform_later(self.id) + OrderQueueProcessorJob.perform_later(self.id, self.table_id) end diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index b0619af2..062c2c65 100644 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -8,26 +8,30 @@ class OrderQueueStation < ApplicationRecord scope :active, -> {where(is_active: true)} - def process_order (order) + def process_order (order, table_id) oqs_stations = OrderQueueStation.active + dining=DiningFacility.find_by_name(table_id) + oqpbz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id) order_items = order.order_items #Assign OQS id to order Items oqs_stations.each do |oqs| #Get List of items - - pq_items = JSON.parse(oqs.processing_items) + pq_items = JSON.parse(oqs.processing_items) - #Loop through the processing items - pq_items.each do |pq_item| - #Processing through the looping items - order_items.each do |order_item| - if (pq_item == order_item.item_code) - #Same Order_items can appear in two location. - AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) + if oqs.id == oqpbz.order_queue_station_id + #Loop through the processing items + pq_items.each do |pq_item| + #Processing through the looping items + order_items.each do |order_item| + if (pq_item == order_item.item_code) + #Same Order_items can appear in two location. + AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) + end end end - end + end #Print OQS where printing is require From 9f3acad10d29c6d461c86a8b5b344331a0080a81 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 16 Jun 2017 19:26:21 +0630 Subject: [PATCH 06/17] update order for oqs --- app/controllers/api/orders_controller.rb | 2 +- app/models/order_queue_station.rb | 3 +-- db/seeds.rb | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/api/orders_controller.rb b/app/controllers/api/orders_controller.rb index 08847f6f..c383fafb 100644 --- a/app/controllers/api/orders_controller.rb +++ b/app/controllers/api/orders_controller.rb @@ -31,7 +31,7 @@ class Api::OrdersController < Api::ApiController @order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile @order.items = params[:order_items] @order.guest = params[:guest_info] - @order.table_id = params[:table_id] + @order.table_id = params[:table_id] # this is dining facilities's id @order.new_booking = true @order.employee_name = current_login_employee.name #Create Table Booking or Room Booking diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index 062c2c65..d6e21c64 100644 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -10,7 +10,7 @@ class OrderQueueStation < ApplicationRecord def process_order (order, table_id) oqs_stations = OrderQueueStation.active - dining=DiningFacility.find_by_name(table_id) + dining=DiningFacility.find(table_id) oqpbz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id) order_items = order.order_items @@ -31,7 +31,6 @@ class OrderQueueStation < ApplicationRecord end end end - end #Print OQS where printing is require diff --git a/db/seeds.rb b/db/seeds.rb index 56591e2c..07e5746c 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -147,8 +147,8 @@ admin_employee = Employee.create({name: "Waiter", role: "waiter", password: "111 admin_employee = Employee.create({name: "Waiter 2", role: "waiter", password: "22222", emp_id:"222", created_by: "SYSTEM DEFAULT"}) admin_employee = Employee.create({name: "Cashier", role: "cashier", password: "33333", emp_id:"333", created_by: "SYSTEM DEFAULT"}) -order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "EPSON-TM-T82-S-A"}) -order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "EPSON-TM-T82-S-A"}) +# order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "EPSON-TM-T82-S-A"}) +# order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "EPSON-TM-T82-S-A"}) request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "EPSON-TM-T82-S-A"}) crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "EPSON-TM-T82-S-A"}) queue_no_printer=PrintSetting.create({name: "Queue No", unique_code: "QueueNoPdf", printer_name: "EPSON-TM-T82-S-A"}) From 2cf9c6947c397e899f6be408817d1435501ff805 Mon Sep 17 00:00:00 2001 From: Yan Date: Fri, 16 Jun 2017 21:06:33 +0630 Subject: [PATCH 07/17] print for oqs --- app/models/printer/order_queue_printer.rb | 8 +++++--- db/seeds.rb | 4 ++-- dump.rdb | Bin 18287 -> 18163 bytes 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/models/printer/order_queue_printer.rb b/app/models/printer/order_queue_printer.rb index 57a819c9..dae1ad53 100644 --- a/app/models/printer/order_queue_printer.rb +++ b/app/models/printer/order_queue_printer.rb @@ -8,7 +8,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker pdf = OrderItemPdf.new(order_item[0]) pdf.render_file "tmp/receipt.pdf" if oqs.print_copy - self.print("tmp/receipt.pdf", oqs.printer_name)*2 + self.print("tmp/receipt.pdf", oqs.printer_name) + self.print("tmp/receipt.pdf", oqs.printer_name) else self.print("tmp/receipt.pdf", oqs.printer_name) end @@ -25,7 +26,8 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker pdf = OrderItemPdf.new(odi) pdf.render_file "tmp/receipt.pdf" if oqs.print_copy - self.print("tmp/receipt.pdf", oqs.printer_name)*2 + self.print("tmp/receipt.pdf", oqs.printer_name) + self.print("tmp/receipt.pdf", oqs.printer_name) else self.print("tmp/receipt.pdf", oqs.printer_name) end @@ -35,7 +37,7 @@ class Printer::OrderQueuePrinter < Printer::PrinterWorker filename = "tmp/order_summary_#{order_id}" + ".pdf" pdf = OrderSummaryPdf.new(order) pdf.render_file filename - self.print(filename, printer_name) + self.print(filename, oqs.printer_name) end end diff --git a/db/seeds.rb b/db/seeds.rb index 07e5746c..56591e2c 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -147,8 +147,8 @@ admin_employee = Employee.create({name: "Waiter", role: "waiter", password: "111 admin_employee = Employee.create({name: "Waiter 2", role: "waiter", password: "22222", emp_id:"222", created_by: "SYSTEM DEFAULT"}) admin_employee = Employee.create({name: "Cashier", role: "cashier", password: "33333", emp_id:"333", created_by: "SYSTEM DEFAULT"}) -# order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "EPSON-TM-T82-S-A"}) -# order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "EPSON-TM-T82-S-A"}) +order_station1=PrintSetting.create({name: "OrderItemPdf", unique_code: "OrderItemPdf", printer_name: "EPSON-TM-T82-S-A"}) +order_station2=PrintSetting.create({name: "Order Summary", unique_code: "OrderSummaryPdf", printer_name: "EPSON-TM-T82-S-A"}) request_bill_printer=PrintSetting.create({name: "Receipt Bill", unique_code: "ReceiptBillPdf", printer_name: "EPSON-TM-T82-S-A"}) crm_order_printer=PrintSetting.create({name: "CRM Order", unique_code: "CrmOrderPdf", printer_name: "EPSON-TM-T82-S-A"}) queue_no_printer=PrintSetting.create({name: "Queue No", unique_code: "QueueNoPdf", printer_name: "EPSON-TM-T82-S-A"}) diff --git a/dump.rdb b/dump.rdb index 7202f930a656071a72de3c35f817a6055656ddcb..b21f067994bac5cdd41cbb593e9e26e89dcc0cab 100644 GIT binary patch delta 4439 zcmb_fYjBj+8UDV#WD^LbPN&oU z+j(cd^Pcy8p7(j5^VxIe-=8)2ST~_h*WC9-^*~=H9qGz+9sTxevy3aoKW{K~+%v~# ziQGNT55L974;p)KTc}sAo2$R+nQPMswsOXo&$Zn z7AHR6mhR4;iP+1r*Y^J7<|xOQNEx-Mg{f?8*tR9z;C|EC(4X3jn78lI-V7qXf!aQ(LxX(&JpeYtH_WC$Ox}jc)7h>B#g!;p5ulsoFk}8OZc`ygl3d0_jX= zYG7+WR6gG+*k|)x7=A2l^3)VR>NBrjvDe?5>F<3kG!g$O@f{sz!+Lnm$zUDa5mU>G zV$5x&s7^IMsDJ&9U}N(5P|(;iX&9NuzAL;Gs-i*2jy4o|nsHYQ!*9;x@pyivxzpCj* zb|cC>x-HXz20RF_2nUAZ;}06~Y?HAz_C2)F>$Gap+)>8`VGOWhmSquvvw!t%>gXBh zj^zxoym;l8W6Uc!$zNDlOerf0A1RCSiTEE9Nj+2S)=%8}=8R(Twq&-@58Z&~u>g8x zOaDV?Sx@{2;U;rg%VhQGT-*58T^F>yY~iZCljf+GN+GjX%uO9=W$ax8=d(8D#sl0Y zj7U*v6eTvZqfU%rIT8Ob(eAeWnHx{m*OnS(3&xXrG#XkU%9(eBZ8!57v^m)}-o5K0 zaZmXNl^(OAlK@;Aob&lX^sr~*io#Y)L35e`bqmi9#aY+{p}{A|^!QqkDr zlIq*%Z;)Onh-R6yej;OSF3y`Yk(gkefisL0bcho`%*Beh#I+*9FB2fy`LM)a2w7}CNhFDVM=}T4IW=s?s47!9BbOAyNW4(Xz)B5e| z6EjW0(eFJlqR5XvGz3CA6uv*cJNJT*Nv0SYPJUiEdIG%~bJ@_8I|L0@lv;%u;FM6| zG+04@pc!YO!Ojf47(7u|!VaK{8Aaq2mqc9;IWM=Ug)SLo9>{V2d>zx|lz%5a6U6&6KlZ;Hn-%qr;*sW@KV`o{hh%E@=s3bCL9q@*) z1us7I8yCFSD#7b>!Se%n8?FIw$BeSbP(fw(Vxhrrlr*L(_fmjKp#ZVLpd%pwDd&3RPi3rR3B(JO+mo8}zGuI64-e={kdw4%^wm{~z=%6RFzpgB<|#<|P*{EGO@ zb7ZHZy2ol9V?;n_lq_HQzuysP*L8Qqj@q)!*o2_L>i7qlON-cu@)>RcZhspx!WT;Hrx1{e&K^ z`-(HPz%aWjy%|=z1l|>fVP$z3nsSat0S74`oatI$*f@>>ffxY=KcnOJlX^0etFQ`K zpp~v3E}Flz?0vez$h)isEA;4)9KUPy5ER@!XpiHT9V-@ET4BYoV3tFO2ROI^t7yf(!Ujhgt-_o+?n8n!0*^2S zO`g&y_>}&Mc(cL>I}ePQUKDP ze4jSw+@NQz?phkMJGrz{oJB}V@CZ%AV_1p|jR3wXl~$eJcHY^c53IKI7r}Y@Z>#6d zr#4GVlD5E?wX+PYb_&Q7cwp>VptsfBI9J$F2QNWEb2>M zp0f4D*plXIPNE< zCXJAv3N?5|UyKJmH=omA#_#bNBk=?J?!@;!D-P)2CAN4!i9E06ntN+Kf|2lzkmo|Q zMekiRw;Js^Uvq~KT*OOjp7SgY=vA#7y&v<-dS9!W?rl$JD86da$a+25s?aBa=To~q zR#YtSf@=m3BtwhWfBf@HH3}?Es)MJsT6=4?k#;ZX*N?B=5S*%i(GORJEqZ>&o#Eq2 zePL~^-kZ*3E{$lUh!`RR9R-uAPqKqpZds?W8BYR_D*4NaOMblM!e>d>cF<}z1L N$vN*ly{GZ~zX47x65{{> delta 4413 zcmb7IZERKL9Y5#3^wL+#iy%z6r=`4E?%{cVDHQI#wBS&{Dkf-DdVBA=+6b+*y%S=H zAl2yyo%$?c$u?6$+icl~4XblmLM#@hW!XzcG@Hw2tH!u5Q_y9}bh!UHxAzuIP39+( z6YhEb&+q?xJN@(-`{QTr=g^J0z_4xwZWI{_ROAs{f zgeo8I>&<%o{a(L)!;wr+3u6qoFe;eRm};IQ){_2#%s@*%(|y4FY0H`vlH(m;ym9x% zpWSO)R%GtqL?T^<{v+d7^iZMO8;A__6}(7yPri2|c_#Vl^Z#9qm=;uUmk6%8rW+a` z?#?v^M{j5x$XE|JBHVwt&vRI$(3j~MaJHJ;?QidWq4S}->qcul8tL*f0}CAmPU{o_W+aS;o`r`o*!FgT0^ngaJ0`G z=sOahNWGKZWe%->(tObT+O3v!8beenCmw-A5q6wtUte$E{(}wM?aTwo!P;%Tg#)>s zwF6GRyC>&lnq$r*-2)FgYkO0VG&te4t%Ny;kEwHekH2O1G^}VJtQC@Su9V9Wrc@1G zw)bb9=Hz)x9ILmwr|ga6FUKUp8Vho?cvnFPR<8eyVmXm|FMXHks5@bLmtR~B)2*t4 z>0H6NP?|eVRdG7lF--S_UFd1pY4&VxTzIx}Tc+!P*RrcOS8&db?>N_Mj;~nKIuhlI z6Q+hfjqK0%7J8DuDb0b#UkOQqoz1p9x*)(@5GtCx;*pN^A?`D-IVomg%F5yIdeP8lz^WKf#J>*slTW12wwa1g>NjZ zlbjGmk*fu#ic7~an>TMW7Z)vW4a3+vd7|@^nFA)SJ3vy(%J5Mssd6n(hE_A2;J0C+p_{xCl}0GUs+13CC>O+y>AtZ9Oq%osK91 zU=5Yg9V$|D${LH3YoTQl7{LhTM3ULvjVyk1ehrK+ImfPMp#M%&6=~b&JlMJ8Tu*3s z@2<{Pt37#xvm)#p&6GVj1((u7Q9bviqMT46N_QdzNmm1Fu>`!{PN&U+C4=S`=j?o6 ztd)Tr08K|NP7|Cd zUwC^1g`n`{d}nDjY!qBbrS*#*;1R8Xz}`O>DPWZcD+YfJ+67L|LUKCtDI@o5Uu z{pQM5&ed7vwhxAVia3wOfFguaq=)7fE)Yc1vL72D3B&yW;)R{GZ%>zK1K3}BbG!!+S8g8vQ%?(1-8;HyvFcy=e~u%W0!4)H9Uc%(Ap+*woMVumPZN#Bw>zTT3?hoe+TP0AtGdA_JB2yp~GT*myy#AV;5>!iNE;qU6u6T1>u}lQU1}%XMT`A&oq3mmZnSe8tEV(Dp0^-(Z zB_d!Zm(ttdltI(fbT&98?7OG4F3f~va7u4;`ArbqQQ$r)jVlO(P6r4<)`B=ou2j1Q z>Hy)?Z!8oDqPZVht=4cC`rY%--d1pAJD4aAG7~peoR%vrZFaQZeg8aI3tfOuh*ddl+ z0)8e-Fs`BYIU|Rwh_;vvB3G>Iqb>qXXgYnJp z+_sx%n_mU^FD0e)hLs9H0v^FSCQ^S%?;bm}zTJLo76yn|81kFj3oqGA=ngOIthQTP zj>Rf=_YQ3LE8u7;m9JqJCzzE0H7Db>afzS|Yh1R%U{ZKS1M0R1)cqcR?ON(8h!*No zH|FmQ{MXzYZ)z`ETTq#xz^XZ{El4pc6fdu>NIgv@q}i;qwLelOt*1KuGiqqMH_P{AvBExm{O?TK3!?%x;R7q_f4D=ce~Wu=D9sa1=NyY=Ae z#Tw-?%Xlo2!HOlIO=S~sUR^c!x;&3kppB;H+*V|sZd`7vlgl2aqgPMc4WrhJ z(?g?+ab75t5j;UNQY2UovxJfjqt(!EbS9_sT_T@txS{j2X*_Dt=>!{H$}rCIz2M7gsP0l%OW3cJXv85rEaQvW$<)fw z+V7ZGQyroFNmG-4G}L^nc{<%4{wUFE{*}ISl`Z){54{!B`AnuOo5`+!w+7?9Cl&1? zq>CdsHe?Fho((leOtkI3@Q30D#%t4+Ru{WS-sShZ=BI7i`A6)%%wPz)a@|3TP1g^1 z##inB;3tsor^`e-froH{%g^lw4%G(-7qc9}Yk@stF9XDs%lXX_E zCA;cATY9(re!6=2h3!AO+s@N1Jk*6G{b6M;%W;N!DwkKk{-EmP7!))`l#7}^yHXRM zvg6Jr`{5m<`bA2KB;$Pu^_1B7XFIit6IJ@_| Kzxvk5p8o+G914X1 From 29b76adba72e3a66c3904860c1ad29935600ff95 Mon Sep 17 00:00:00 2001 From: Nweni Date: Sat, 17 Jun 2017 11:35:17 +0630 Subject: [PATCH 08/17] Update --- app/controllers/origami/home_controller.rb | 30 +++++++++---------- app/models/order.rb | 4 +-- app/views/origami/home/index.html.erb | 16 +++++----- .../origami/redeem_payments/index.html.erb | 7 +++-- 4 files changed, 30 insertions(+), 27 deletions(-) diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index dbde3293..aac40da5 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -1,8 +1,8 @@ class Origami::HomeController < BaseOrigamiController def index if params[:booking_id] != nil - type=params[:booking_id].split('-')[0]; - # Sale + type=params[:booking_id].split('-')[0]; + # Sale if type == "SAL" @selected_item = Sale.find(params[:booking_id]) @selected_item_type="Sale" @@ -10,23 +10,23 @@ class Origami::HomeController < BaseOrigamiController else @selected_item = Order.find(params[:booking_id]) @selected_item_type="Order" - end - end + end + end @completed_orders = Order.get_completed_order() @booking_orders = Order.get_booking_order_table() - @booking_rooms = Order.get_booking_order_rooms() + @booking_rooms = Order.get_booking_order_rooms() @orders = Order.get_orders() - end + end def item_show selection(params[:booking_id],1) - end + end def selection(selected_id, is_ajax) str = [] - type=selected_id.split('-')[0]; - # Sale + type=selected_id.split('-')[0]; + # Sale if type == "SAL" @order_details = SaleItem.get_order_items_details(params[:booking_id]) @order_details.each do |ord_detail| @@ -37,8 +37,8 @@ class Origami::HomeController < BaseOrigamiController @order_details = OrderItem.get_order_items_details(params[:booking_id]) @order_details.each do |ord_detail| str.push(ord_detail) - end - end + end + end if is_ajax == 1 render :json => str.to_json else @@ -54,21 +54,21 @@ class Origami::HomeController < BaseOrigamiController else sale = Order.find(params[:sale_id]) end - + status = sale.update_attributes(customer_id: params[:customer_id]) - + if status == true render json: JSON.generate({:status => true}) else render json: JSON.generate({:status => false, :error_message => "Record not found"}) - end + end end def get_customer @customer = Customer.find(params[:customer_id]) - + response = Customer.get_member_account(@customer) respond_to do |format| diff --git a/app/models/order.rb b/app/models/order.rb index f3ae798c..9c65304b 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -231,7 +231,7 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::TABLE_TYPE,true) - .group("bookings.booking_id") + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id") # For PG # booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true # sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id @@ -262,7 +262,7 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("(orders.status = 'new' or orders.status = 'billed') and (dining_facilities.type=? and dining_facilities.is_active=?)",DiningFacility::ROOM_TYPE,true) - .group("bookings.booking_id") + .group("bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id") # For PG # booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true # sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.customer_id,orders.order_id diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 05d0f28d..ca15cc4c 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -354,14 +354,14 @@ Discount: (<%=@selected_item.total_discount rescue 0%>) - - Tax: - <%=@selected_item.total_tax rescue 0%> - - - Grand Total: - <%=@selected_item.grand_total rescue 0%> - + + Tax: + <%=@selected_item.total_tax rescue 0%> + + + Grand Total: + <%=@selected_item.grand_total rescue 0%> + diff --git a/app/views/origami/redeem_payments/index.html.erb b/app/views/origami/redeem_payments/index.html.erb index 0991e562..edca5471 100644 --- a/app/views/origami/redeem_payments/index.html.erb +++ b/app/views/origami/redeem_payments/index.html.erb @@ -21,7 +21,7 @@ <% end %>
- +

@@ -66,7 +66,7 @@
00
-
Nett
+
Nett
Del
Clr
@@ -123,6 +123,9 @@ $(document).on('click', '.cashier_number', function(event){ case 'del' : var cash=$('#used_amount').text(); $('#used_amount').text(cash.substr(0,cash.length-1)); + case 'nett': + alert($('#valid_amount').text()) + $('#used_amount').text($('#valid_amount').text()); break; } From 1d2fb7b6ab8d45e37048b15cca8b69c040a68b03 Mon Sep 17 00:00:00 2001 From: Yan Date: Sat, 17 Jun 2017 12:13:01 +0630 Subject: [PATCH 09/17] dump.rdb --- dump.rdb | Bin 18163 -> 18163 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/dump.rdb b/dump.rdb index b21f067994bac5cdd41cbb593e9e26e89dcc0cab..211fd505548a6a60b85596d4201ab6d1155b4f22 100644 GIT binary patch delta 64 zcmV-G0Kfn9jREtG0gx~f0`x;!`UrJ%Wn?XFWo^QsClHZBkpuh*a*@{Q3^g@5IW9Ok WIXN*gHnYnCAVmn`cg^DNkRg;y{2B!S delta 64 zcmV-G0Kfn9jREtG0gx~fAnZd~`UrJ%Wn?XFWo^Pxwi1y-kpqrKQ<2u`3^O%2GcGqc WIX5&gIJ3(EAVmnvI2O=|kSyay+8EdX From 064f13290619b9a3d88b6c5de608cb69dd2c1bd4 Mon Sep 17 00:00:00 2001 From: Nweni Date: Sat, 17 Jun 2017 12:13:38 +0630 Subject: [PATCH 10/17] Update --- app/views/settings/order_queue_stations/_form.html.erb | 2 +- app/views/settings/order_queue_stations/index.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/settings/order_queue_stations/_form.html.erb b/app/views/settings/order_queue_stations/_form.html.erb index bc76f044..61f134c7 100644 --- a/app/views/settings/order_queue_stations/_form.html.erb +++ b/app/views/settings/order_queue_stations/_form.html.erb @@ -4,7 +4,7 @@
<%= f.input :station_name %> <%= f.input :is_active %> - <%= f.input :auto_print %> + <%= f.input :printer_name %> <%= f.input :font_size %> <%= f.input :print_copy %> diff --git a/app/views/settings/order_queue_stations/index.html.erb b/app/views/settings/order_queue_stations/index.html.erb index 287fb10b..90339f11 100644 --- a/app/views/settings/order_queue_stations/index.html.erb +++ b/app/views/settings/order_queue_stations/index.html.erb @@ -32,7 +32,7 @@ <%= link_to settings_order_queue_station.station_name, settings_order_queue_station_path(settings_order_queue_station) %> <%= settings_order_queue_station.is_active %> - <%= settings_order_queue_station.auto_print %> + <%= settings_order_queue_station.print_copy %> <%= settings_order_queue_station.printer_name %> <%= settings_order_queue_station.cut_per_item %> From b2ed77947eb2f10a8b3f313647100ee082140dd3 Mon Sep 17 00:00:00 2001 From: Nweni Date: Sat, 17 Jun 2017 13:32:16 +0630 Subject: [PATCH 11/17] Update --- app/controllers/api/bill_controller.rb | 16 ++++++++++++++++ app/controllers/origami/payments_controller.rb | 13 ++++++------- app/models/printer/receipt_printer.rb | 3 ++- app/pdf/receipt_bill_pdf.rb | 14 ++++++-------- .../settings/order_queue_stations/_form.html.erb | 4 ++-- .../settings/order_queue_stations/index.html.erb | 2 +- 6 files changed, 33 insertions(+), 19 deletions(-) diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 6b1fb225..5b3ef646 100644 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -22,6 +22,22 @@ class Api::BillController < Api::ApiController @status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee) end + + unique_code = "ReceiptBillPdf" + customer= Customer.where('customer_id=' + @sale.customer_id) + + # get printer info + print_settings=PrintSetting.find_by_unique_code(unique_code) + + # find order id by sale id + # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id) + + # Calculate Food and Beverage Total + food_total, beverage_total = SaleItem.calculate_food_beverage(@sale.sale_items) + + printer = Printer::ReceiptPrinter.new(print_settings) + printer.print_receipt_bill(print_settings,@sale.sale_items,@sale,customer.name, food_total, beverage_total) + end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index ca497b81..27062c31 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -12,7 +12,7 @@ class Origami::PaymentsController < BaseOrigamiController sale_payment = SalePayment.new sale_payment.process_payment(saleObj, @user, cash, "cash") - unique_code = "ReceiptBillPdf" + unique_code = "ReceiptBillPdf" customer= Customer.find(saleObj.customer_id) # get member information @@ -20,11 +20,10 @@ class Origami::PaymentsController < BaseOrigamiController # 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 = 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 @@ -41,7 +40,7 @@ class Origami::PaymentsController < BaseOrigamiController @sale_data = Sale.find_by_sale_id(sale_id) #get customer amount - @customer = Customer.find(@sale_data.customer_id) + @customer = Customer.find(@sale_data.customer_id) # get member information response = Customer.get_member_account(@customer) @@ -84,19 +83,19 @@ class Origami::PaymentsController < BaseOrigamiController saleObj = Sale.find(sale_id) - unique_code = "ReceiptBillPdf" + 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 = Printer::ReceiptPrinter.new(print_settings) printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info) end diff --git a/app/models/printer/receipt_printer.rb b/app/models/printer/receipt_printer.rb index 92468b0e..bfef5588 100644 --- a/app/models/printer/receipt_printer.rb +++ b/app/models/printer/receipt_printer.rb @@ -52,7 +52,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker self.print(filename) end - + def print_receipt_payment_by_foc(sale_id) #Use CUPS service #Generate PDF @@ -70,6 +70,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker #Generate PDF #Print pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info) + pdf.render_file "tmp/receipt_bill.pdf" self.print("tmp/receipt_bill.pdf") end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 524ee7e5..c0d8aa74 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -11,7 +11,6 @@ class ReceiptBillPdf < Prawn::Document self.item_height = 15 self.item_description_width = (self.page_width-20) / 2 self.label_width = 100 - # @item_width = self.page_width.to_i / 2 # @qty_width = @item_width.to_i / 3 # @double = @qty_width * 1.3 @@ -36,7 +35,6 @@ class ReceiptBillPdf < Prawn::Document if member_info != nil member_info(member_info) end - footer end @@ -206,10 +204,10 @@ 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| + if member_info["status"] == true + member_info["data"].each do |res| move_down 5 y_position = cursor @@ -219,9 +217,9 @@ class ReceiptBillPdf < Prawn::Document 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 + end end def footer diff --git a/app/views/settings/order_queue_stations/_form.html.erb b/app/views/settings/order_queue_stations/_form.html.erb index 61f134c7..789d1d27 100644 --- a/app/views/settings/order_queue_stations/_form.html.erb +++ b/app/views/settings/order_queue_stations/_form.html.erb @@ -4,14 +4,14 @@
<%= f.input :station_name %> <%= f.input :is_active %> - + <%= f.input :printer_name %> <%= f.input :font_size %> <%= f.input :print_copy %> <%= f.input :cut_per_item %> <%= f.input :use_alternate_name %> <%= f.input :processing_items, as: :hidden %> - + <%= f.input :auto_print %>
diff --git a/app/views/settings/order_queue_stations/index.html.erb b/app/views/settings/order_queue_stations/index.html.erb index 90339f11..287fb10b 100644 --- a/app/views/settings/order_queue_stations/index.html.erb +++ b/app/views/settings/order_queue_stations/index.html.erb @@ -32,7 +32,7 @@ <%= link_to settings_order_queue_station.station_name, settings_order_queue_station_path(settings_order_queue_station) %> <%= settings_order_queue_station.is_active %> - + <%= settings_order_queue_station.auto_print %> <%= settings_order_queue_station.print_copy %> <%= settings_order_queue_station.printer_name %> <%= settings_order_queue_station.cut_per_item %> From 420e1b9cbc4e253261986a9504f92d6fa5425aa7 Mon Sep 17 00:00:00 2001 From: Yan Date: Sat, 17 Jun 2017 14:15:08 +0630 Subject: [PATCH 12/17] all info details in oqs --- app/assets/javascripts/OQS.js | 42 ++++++++++++++++++++------ app/controllers/oqs/home_controller.rb | 16 ++++++++++ app/views/oqs/home/index.html.erb | 16 ++-------- config/routes.rb | 1 + 4 files changed, 53 insertions(+), 22 deletions(-) diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index 9ad540ab..8e252749 100644 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -23,21 +23,42 @@ $(document).ready(function(){ // }, 10000); $('.queue_station').on('click',function(){ - var orderZone=$(this).children().children().children('.order-zone').text(); - var orderItem=$(this).children().children().children('.order-item').text(); - var orderQty=$(this).children().children().children('.order-qty').text(); - var orderBy=$(this).children().children().children().children('.order-by').text(); - var orderAt=$(this).children().children().children().children('.order-at').text(); - var orderCustomer=$(this).children().children('.order-customer').text(); + var orderZone=$(this).children().children().children('.order-zone').text().trim(); + // var orderItem=$(this).children().children().children('.order-item').text(); + //var assigned_item_id = $(this).children().find(".assigned-order-item").text(); + var orderQty = $(this).children().children().children('.order-qty').text(); + var orderBy = $(this).children().children().children().children('.order-by').text(); + var orderAt = $(this).children().children().children().children('.order-at').text(); + var orderCustomer = $(this).children().children('.order-customer').text(); $('#order-title').text("ORDER DETAILS - " + orderZone); $('#order-by').text(orderBy); $('#order-at').text(orderAt); $('#order-customer').text(orderCustomer); $('#order-from').text(orderZone); + // clear order items + $("#oqs-order-details-table").children("tbody").empty(); - $('#order-items').text(orderItem); - $('#order-qty').text(orderQty); + // Call get_order_items() for Order Items by dining + $.ajax({ + type: 'GET', + url: '/oqs/' + orderZone, + success: function(res){ + for (i = 0; i < res.length; i++) { + var data = JSON.stringify(res[i]); + var parse_data = JSON.parse(data); + + var order_item_row = "" + + "" + parse_data.item_name + "" + + "" + parse_data.qty + "" + + ""; + $("#oqs-order-details-table").children("tbody").append(order_item_row); + } + } + }) + + // $('#order-items').text(orderItem); + // $('#order-qty').text(orderQty); $('.queue_station').removeClass('selected-item'); $(this).addClass('selected-item'); @@ -49,7 +70,8 @@ $(document).ready(function(){ var _self = $(this); // To know in ajax return var assigned_item_id=$(this).attr('id').substr(15); var params = { 'id':assigned_item_id }; - + + // Call update_delivery_status() for changed delivery and move to delivery $.ajax({ type: 'POST', url: '/oqs/update_delivery', @@ -84,6 +106,7 @@ $(document).ready(function(){ }); }); + // Print Order Item $('#print_order_item').on('click',function(){ var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text(); var params = { 'id':assigned_item_id }; @@ -94,6 +117,7 @@ $(document).ready(function(){ }); }); + // Print Order Summary $('#print_order_summary').on('click',function(){ var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text(); var params = { 'id':assigned_item_id }; diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 7af42166..67f96a26 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -22,6 +22,22 @@ class Oqs::HomeController < BaseOqsController @queue_stations_items end + # Get Order items + def get_order_items + items = [] + table_name = params[:table_id] + dining = DiningFacility.find_by_name(table_name); + booking_id = dining.get_current_booking + BookingOrder.where("booking_id='#{ booking_id }'").find_each do |bo| + order=Order.find(bo.order_id); + order.order_items.each do |oi| + items.push(oi) + end + end + + render :json => items.to_json + end + def show end diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index f2120cde..1f13383d 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -133,7 +133,7 @@
-
ORDER DETAILS -
+
ORDER DETAILS - Table
@@ -159,7 +159,7 @@
- +
@@ -167,17 +167,7 @@ - - - - - - +
Items
- - - -
diff --git a/config/routes.rb b/config/routes.rb index 19b07979..3a1e5295 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -129,6 +129,7 @@ Rails.application.routes.draw do #--------- Order Queue Station ------------# namespace :oqs do root "home#index" + get "/:table_id", to: "home#get_order_items" post 'update_delivery', to: "home#update_delivery_status" From e55ab32fad0f1793fdf3971a255c59925495c0ab Mon Sep 17 00:00:00 2001 From: Nweni Date: Sat, 17 Jun 2017 16:00:56 +0630 Subject: [PATCH 13/17] Update --- app/assets/javascripts/OQS.js | 33 ++++++++++++------------ app/controllers/oqs/home_controller.rb | 33 ++++++++++++------------ app/views/origami/payments/show.html.erb | 2 +- 3 files changed, 34 insertions(+), 34 deletions(-) diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index 9ad540ab..0e44876d 100644 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -17,15 +17,16 @@ //= require cable $(document).ready(function(){ + // auto refresh every 10 seconds // setTimeout(function(){ // window.location.reload(1); // }, 10000); - $('.queue_station').on('click',function(){ + $('.queue_station').on('click',function(){ var orderZone=$(this).children().children().children('.order-zone').text(); var orderItem=$(this).children().children().children('.order-item').text(); - var orderQty=$(this).children().children().children('.order-qty').text(); + var orderQty=$(this).children().children().children('.order-qty').text(); var orderBy=$(this).children().children().children().children('.order-by').text(); var orderAt=$(this).children().children().children().children('.order-at').text(); var orderCustomer=$(this).children().children('.order-customer').text(); @@ -44,19 +45,19 @@ $(document).ready(function(){ }); // complete for queue item - $('.order-complete').on('click',function(e){ + $('.order-complete').on('click',function(e){ //e.preventDefault(); - var _self = $(this); // To know in ajax return - var assigned_item_id=$(this).attr('id').substr(15); + var _self = $(this); // To know in ajax return + var assigned_item_id=$(this).attr('id').substr(15); var params = { 'id':assigned_item_id }; - + $.ajax({ type: 'POST', url: '/oqs/update_delivery', data: params, dataType: 'json', - success: function(data){ - for (i = 0; i < data.length; i++) { + success: function(data){ + for (i = 0; i < data.length; i++) { var queue_station = $('#assigned_queue_' + data[i]).parent().parent(".queue_station"); var station = queue_station.parent().parent().attr('id'); @@ -65,7 +66,7 @@ $(document).ready(function(){ // Remove a queue card from current station queue_station.children('.card-footer').remove(); - + // Add removed queue card from station to completed $("#completed").children('.card-columns').append(queue_station); @@ -73,33 +74,33 @@ $(document).ready(function(){ var station_count=parseInt($("#"+station+"_count").text()) - 1; $("#"+station+"_count").text(station_count); } - - // update queue item count in completed station + + // update queue item count in completed station $("#completed_count").text(parseInt($("#completed_count").text()) + data.length); alert("updated!"); // Page reload location.reload(); } - }); + }); }); $('#print_order_item').on('click',function(){ - var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text(); + var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text(); var params = { 'id':assigned_item_id }; $.ajax({ type: 'GET', - url: '/oqs/print/print/'+assigned_item_id, + url: '/oqs/print/print/'+assigned_item_id, success: function(data){ } }); }); $('#print_order_summary').on('click',function(){ - var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text(); + var assigned_item_id=$('.selected-item').children('.card-block').children('.assigned-order-item').text(); var params = { 'id':assigned_item_id }; $.ajax({ type: 'GET', - url: '/oqs/print/print_order_summary/'+assigned_item_id, + url: '/oqs/print/print_order_summary/'+assigned_item_id, success: function(data){ } }); }); diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 7af42166..fc439640 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -1,22 +1,22 @@ class Oqs::HomeController < BaseOqsController def index queue_stations=OrderQueueStation.all - + @queue_items_details = queue_items_query(0) - @queue_completed_item = queue_items_query(1) - + @queue_completed_item = queue_items_query(1) + @queue_stations_items=Array.new # Calculate Count for each station tab - queue_stations.each do |que| + queue_stations.each do |que| i=0 - @queue_items_details.each do |qid| - if qid.station_name == que.station_name - i=i+1 - end - end - @queue_stations_items.push({:station_name => que.station_name, :is_active => que.is_active ,:item_count => i }) + @queue_items_details.each do |qid| + if qid.station_name == que.station_name + i=i+1 + end + end + @queue_stations_items.push({:station_name => que.station_name, :is_active => que.is_active ,:item_count => i }) end @queue_stations_items @@ -35,24 +35,23 @@ class Oqs::HomeController < BaseOqsController # update delivery status for completed same order items assigned_items.each do |ai| ai.delivery_status=true - ai.save + ai.save removed_item.push(ai.assigned_order_item_id) - end - render :json => removed_item.to_json + end + render :json => removed_item.to_json end # Query for OQS with status def queue_items_query(status) AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at") - .joins(" left join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id + .joins("left join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id left join dining_facilities as df on df.zone_id = oqpz.zone_id left join order_queue_stations as oqs ON oqs.id = assigned_order_items.order_queue_station_id left join orders as od ON od.order_id = assigned_order_items.order_id left join order_items as odt ON odt.item_code = assigned_order_items.item_code left join customers as cus ON cus.customer_id = od.customer_id") - .where("assigned_order_items.delivery_status = #{status}") + .where("assigned_order_items.delivery_status = #{status}") .group("assigned_order_items.assigned_order_item_id") - .order("odt.item_name DESC") + .order("odt.item_name DESC") end end - diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 995e13e9..9ac19b1a 100644 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -235,7 +235,7 @@
- +
From b093a993ba002c92659bbb34338c55c031c11d87 Mon Sep 17 00:00:00 2001 From: Phyo Date: Sat, 17 Jun 2017 18:00:59 +0630 Subject: [PATCH 14/17] Zone and OQS --- .../order_queue_stations_controller.rb | 2 +- app/controllers/settings/rooms_controller.rb | 81 +++++++++++++ app/controllers/settings/tables_controller.rb | 81 +++++++++++++ app/controllers/settings/zones_controller.rb | 10 +- app/models/employee.rb | 3 + app/models/order_queue_station.rb | 8 +- app/models/zone.rb | 5 + app/views/layouts/_header.html.erb | 1 + .../order_queue_stations/_form.html.erb | 7 ++ app/views/settings/rooms/_form.html.erb | 16 +++ .../rooms/_settings_room.json.jbuilder | 2 + app/views/settings/rooms/edit.html.erb | 10 ++ app/views/settings/rooms/index.html.erb | 51 ++++++++ app/views/settings/rooms/new.html.erb | 11 ++ app/views/settings/rooms/show.html.erb | 49 ++++++++ app/views/settings/tables/_form.html.erb | 16 +++ .../tables/_settings_table.json.jbuilder | 2 + app/views/settings/tables/edit.html.erb | 10 ++ app/views/settings/tables/index.html.erb | 49 ++++++++ app/views/settings/tables/new.html.erb | 11 ++ app/views/settings/tables/show.html.erb | 47 ++++++++ app/views/settings/zones/_form.html.erb | 4 +- app/views/settings/zones/edit.html.erb | 16 ++- app/views/settings/zones/index.html.erb | 64 +++++----- app/views/settings/zones/show.html.erb | 110 +++++++++++++++--- ...20170403142424_create_dining_facilities.rb | 2 +- 26 files changed, 608 insertions(+), 60 deletions(-) create mode 100644 app/controllers/settings/rooms_controller.rb create mode 100644 app/controllers/settings/tables_controller.rb create mode 100644 app/views/settings/rooms/_form.html.erb create mode 100644 app/views/settings/rooms/_settings_room.json.jbuilder create mode 100644 app/views/settings/rooms/edit.html.erb create mode 100644 app/views/settings/rooms/index.html.erb create mode 100644 app/views/settings/rooms/new.html.erb create mode 100644 app/views/settings/rooms/show.html.erb create mode 100644 app/views/settings/tables/_form.html.erb create mode 100644 app/views/settings/tables/_settings_table.json.jbuilder create mode 100644 app/views/settings/tables/edit.html.erb create mode 100644 app/views/settings/tables/index.html.erb create mode 100644 app/views/settings/tables/new.html.erb create mode 100644 app/views/settings/tables/show.html.erb diff --git a/app/controllers/settings/order_queue_stations_controller.rb b/app/controllers/settings/order_queue_stations_controller.rb index e8b9bbe0..6a0a52ae 100644 --- a/app/controllers/settings/order_queue_stations_controller.rb +++ b/app/controllers/settings/order_queue_stations_controller.rb @@ -71,6 +71,6 @@ class Settings::OrderQueueStationsController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def settings_order_queue_station_params - params.require(:order_queue_station).permit(:station_name, :is_active, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by) + params.require(:order_queue_station).permit(:station_name, :is_active, :processing_items, :print_copy, :printer_name, :font_size, :cut_per_item, :use_alternate_name, :created_by,{ zone_ids: [] }) end end diff --git a/app/controllers/settings/rooms_controller.rb b/app/controllers/settings/rooms_controller.rb new file mode 100644 index 00000000..69e3ec22 --- /dev/null +++ b/app/controllers/settings/rooms_controller.rb @@ -0,0 +1,81 @@ +class Settings::RoomsController < ApplicationController + before_action :set_settings_room, only: [:show, :edit, :update, :destroy] + before_action :set_settings_zone, only: [:index, :show, :edit, :new, :update,:create] + # GET /settings/rooms + # GET /settings/rooms.json + def index + @settings_rooms = @zone.rooms + end + + # GET /settings/rooms/1 + # GET /settings/rooms/1.json + def show + @room = Room.find(params[:id]) + end + + # GET /settings/rooms/new + def new + @settings_room = Room.new + end + + # GET /settings/rooms/1/edit + def edit + end + + # POST /settings/rooms + # POST /settings/rooms.json + def create + @settings_room = Room.new(settings_room_params) + @settings_room.type = DiningFacility::ROOM_TYPE + @settings_room.zone_id = params[:zone_id] + respond_to do |format| + if @settings_room.save + format.html { redirect_to settings_zone_rooms_path, notice: 'Room was successfully created.' } + format.json { render :show, status: :created, location: @settings_room } + else + puts "abc" + format.html { render :new } + format.json { render json: @settings_room.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /settings/rooms/1 + # PATCH/PUT /settings/rooms/1.json + def update + respond_to do |format| + if @settings_room.update(settings_room_params) + format.html { redirect_to settings_zone_rooms_path, notice: 'Room was successfully updated.' } + format.json { render :show, status: :ok, location: @settings_room } + else + format.html { render :edit } + format.json { render json: @settings_room.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /settings/rooms/1 + # DELETE /settings/rooms/1.json + def destroy + @settings_room.destroy + respond_to do |format| + format.html { redirect_to settings_zones_path, notice: 'Room was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_settings_room + @settings_room = Room.find(params[:id]) + end + + def set_settings_zone + @zone = Zone.find(params[:zone_id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def settings_room_params + params.require(:room).permit(:name, :status, :seater, :order_by,:is_active ,:id, :zone_id, :created_by) + end +end diff --git a/app/controllers/settings/tables_controller.rb b/app/controllers/settings/tables_controller.rb new file mode 100644 index 00000000..124a0d94 --- /dev/null +++ b/app/controllers/settings/tables_controller.rb @@ -0,0 +1,81 @@ +class Settings::TablesController < ApplicationController + before_action :set_settings_table, only: [:show, :edit, :update, :destroy] + before_action :set_settings_zone, only: [:index, :show, :edit, :new, :update,:create] + # GET /settings/tables + # GET /settings/tables.json + def index + @settings_tables = @zone.tables + end + + # GET /settings/tables/1 + # GET /settings/tables/1.json + def show + @table = Table.find(params[:id]) + end + + # GET /settings/tables/new + def new + @settings_table = Table.new + end + + # GET /settings/tables/1/edit + def edit + end + + # POST /settings/tables + # POST /settings/tables.json + def create + @settings_table = Table.new(settings_table_params) + @settings_table.type = DiningFacility::TABLE_TYPE + @settings_table.zone_id = params[:zone_id] + respond_to do |format| + if @settings_table.save + format.html { redirect_to settings_zone_tables_path, notice: 'Table was successfully created.' } + format.json { render :show, status: :created, location: @settings_table } + else + puts "abc" + format.html { render :new } + format.json { render json: @settings_table.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /settings/tables/1 + # PATCH/PUT /settings/tables/1.json + def update + respond_to do |format| + if @settings_table.update(settings_table_params) + format.html { redirect_to settings_zone_tables_path, notice: 'Table was successfully updated.' } + format.json { render :show, status: :ok, location: @settings_table } + else + format.html { render :edit } + format.json { render json: @settings_table.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /settings/tables/1 + # DELETE /settings/tables/1.json + def destroy + @settings_table.destroy + respond_to do |format| + format.html { redirect_to settings_zones_path, notice: 'Table was successfully destroyed.' } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_settings_table + @settings_table = Table.find(params[:id]) + end + + def set_settings_zone + @zone = Zone.find(params[:zone_id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def settings_table_params + params.require(:table).permit(:name, :status, :seater, :order_by,:is_active ,:id, :zone_id, :created_by) + end +end diff --git a/app/controllers/settings/zones_controller.rb b/app/controllers/settings/zones_controller.rb index 779c03fe..5752b5e3 100644 --- a/app/controllers/settings/zones_controller.rb +++ b/app/controllers/settings/zones_controller.rb @@ -10,6 +10,8 @@ class Settings::ZonesController < ApplicationController # GET /settings/zones/1 # GET /settings/zones/1.json def show + @settings_tables = @settings_zone.tables + @settings_rooms = @settings_zone.rooms end # GET /settings/zones/new @@ -28,7 +30,7 @@ class Settings::ZonesController < ApplicationController respond_to do |format| if @settings_zone.save - format.html { redirect_to @settings_zone, notice: 'Zone was successfully created.' } + format.html { redirect_to settings_zone_path(@settings_zone), notice: 'Zone was successfully created.' } format.json { render :show, status: :created, location: @settings_zone } else format.html { render :new } @@ -42,7 +44,7 @@ class Settings::ZonesController < ApplicationController def update respond_to do |format| if @settings_zone.update(settings_zone_params) - format.html { redirect_to @settings_zone, notice: 'Zone was successfully updated.' } + format.html { redirect_to settings_zone_path(@settings_zone), notice: 'Zone was successfully updated.' } format.json { render :show, status: :ok, location: @settings_zone } else format.html { render :edit } @@ -56,7 +58,7 @@ class Settings::ZonesController < ApplicationController def destroy @settings_zone.destroy respond_to do |format| - format.html { redirect_to settings_zones_url, notice: 'Zone was successfully destroyed.' } + format.html { redirect_to settings_zones_path, notice: 'Zone was successfully destroyed.' } format.json { head :no_content } end end @@ -69,6 +71,6 @@ class Settings::ZonesController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def settings_zone_params - params.require(:settings_zone).permit(:name, :is_active, :created_by) + params.require(:zone).permit(:name, :is_active, :created_by) end end diff --git a/app/models/employee.rb b/app/models/employee.rb index 1f3cace0..98b8380b 100644 --- a/app/models/employee.rb +++ b/app/models/employee.rb @@ -6,6 +6,9 @@ class Employee < ApplicationRecord validates :emp_id, uniqueness: true, numericality: true, length: {in: 1..4}, allow_blank: true validates :password, numericality: true, length: {in: 3..9}, allow_blank: true + def self.collection + Employee.select("id, name").map { |e| [e.name, e.id] } + end def self.login(emp_id, password) user = Employee.find_by_emp_id(emp_id) diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index b0619af2..874f2fb0 100644 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -5,10 +5,12 @@ class OrderQueueStation < ApplicationRecord has_many :assigned_order_items has_many :order_items + has_many :order_queue_process_by_zones + has_many :zones, through: :order_queue_process_by_zones scope :active, -> {where(is_active: true)} - def process_order (order) + def process_order (order) oqs_stations = OrderQueueStation.active order_items = order.order_items @@ -20,10 +22,10 @@ class OrderQueueStation < ApplicationRecord #Loop through the processing items pq_items.each do |pq_item| #Processing through the looping items - order_items.each do |order_item| + order_items.each do |order_item| if (pq_item == order_item.item_code) #Same Order_items can appear in two location. - AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) + AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) end end diff --git a/app/models/zone.rb b/app/models/zone.rb index e5ad15c7..164b80f4 100644 --- a/app/models/zone.rb +++ b/app/models/zone.rb @@ -2,7 +2,12 @@ class Zone < ApplicationRecord # model association has_many :tables, dependent: :destroy has_many :rooms, dependent: :destroy + has_many :order_queue_stations # validations validates_presence_of :name, :created_by + + def self.collection + Zone.select("id, name").map { |e| [e.name, e.id] } + end end diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 58ecd9b5..a385806c 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -14,6 +14,7 @@
  • <%= link_to "Menu Item Options",settings_menu_item_options_path, :tabindex =>"-1" %>

  • <%= link_to "Order Queue Stations",settings_order_queue_stations_path, :tabindex =>"-1" %>
  • +
  • <%= link_to "Zones", settings_zones_path, :tabindex =>"-1" %>

  • <%= link_to "Cashier Terminals ", settings_cashier_terminals_path, :tabindex =>"-1" %>
  • <%= link_to "Employees", settings_employees_path, :tabindex =>"-1" %>
  • diff --git a/app/views/settings/order_queue_stations/_form.html.erb b/app/views/settings/order_queue_stations/_form.html.erb index db7ed5fd..d54b69b9 100644 --- a/app/views/settings/order_queue_stations/_form.html.erb +++ b/app/views/settings/order_queue_stations/_form.html.erb @@ -1,3 +1,8 @@ + <%= simple_form_for([:settings,@settings_order_queue_station]) do |f| %> <%= f.error_notification %> @@ -7,6 +12,8 @@ <%= f.input :printer_name %> <%= f.input :font_size %> <%= f.input :print_copy %> + <%= f.label "Select Zones", :class => 'control-label' %> + <%= f.collection_check_boxes :zone_ids , Zone.all, :id, :name , :class => 'ta'%> <%= f.input :cut_per_item %> <%= f.input :use_alternate_name %> <%= f.input :processing_items, as: :hidden %> diff --git a/app/views/settings/rooms/_form.html.erb b/app/views/settings/rooms/_form.html.erb new file mode 100644 index 00000000..c164ab67 --- /dev/null +++ b/app/views/settings/rooms/_form.html.erb @@ -0,0 +1,16 @@ +<%= simple_form_for([:settings,@zone,@settings_room]) do |f| %> + <%= f.error_notification %> + +
    + <%= f.input :name %> + <%= f.input :status %> + <%= f.input :seater %> + <%= f.input :order_by %> + <%= f.input :is_active %> + <%= f.input :created_by, :collection => Employee.collection %> +
    + +
    + <%= f.button :submit %> +
    +<% end %> diff --git a/app/views/settings/rooms/_settings_room.json.jbuilder b/app/views/settings/rooms/_settings_room.json.jbuilder new file mode 100644 index 00000000..3b3010d8 --- /dev/null +++ b/app/views/settings/rooms/_settings_room.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! settings_table, :id, :name, :status, :seater, :order_by, :is_active, :created_by, :created_at, :updated_at +json.url settings_table_url(settings_room, format: :json) diff --git a/app/views/settings/rooms/edit.html.erb b/app/views/settings/rooms/edit.html.erb new file mode 100644 index 00000000..7ae2b31d --- /dev/null +++ b/app/views/settings/rooms/edit.html.erb @@ -0,0 +1,10 @@ +
    + + <%= render 'form', settings_table: @settings_room %> +
    diff --git a/app/views/settings/rooms/index.html.erb b/app/views/settings/rooms/index.html.erb new file mode 100644 index 00000000..1480682d --- /dev/null +++ b/app/views/settings/rooms/index.html.erb @@ -0,0 +1,51 @@ + + + + +
    +
    + + + + + + + + + + + + + + + + + <% @settings_rooms.each do |room| %> + + + + + + + + <% if Employee.exists?(room.created_by) %> + + <% else %> + + <% end %> + + + + + <% end %> + +
    NameStatusTypeSeaterOrder byis ActiveCreated ByCreated At
    <%= link_to room.name, settings_menu_path(room) %><%= room.status %>Room<%= room.seater rescue "-" %><%= room.order_by rescue "-" %><%= room.is_active %><%= Employee.find(room.created_by).name %><%= room.created_by %><%= room.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %><%= link_to 'Edit', edit_settings_zone_room_path(@zone,room) %><%= link_to 'Destroy', settings_zone_room_path(@zone,room), method: :delete, data: { confirm: 'Are you sure?' } %>
    +
    diff --git a/app/views/settings/rooms/new.html.erb b/app/views/settings/rooms/new.html.erb new file mode 100644 index 00000000..60bd48ee --- /dev/null +++ b/app/views/settings/rooms/new.html.erb @@ -0,0 +1,11 @@ + +
    + + <%= render 'form', settings_table: @settings_room %> +
    diff --git a/app/views/settings/rooms/show.html.erb b/app/views/settings/rooms/show.html.erb new file mode 100644 index 00000000..893ea325 --- /dev/null +++ b/app/views/settings/rooms/show.html.erb @@ -0,0 +1,49 @@ + + +
    +
    +
    +

    Room

    + + + + + + + + + + + + + + + + + + + + + + + <% if Employee.exists?(@room.created_by) %> + + <% else %> + + <% end %> + + + + + +
    NameStatusRoomSeaterOrder byis ActiveCreated ByCreated At
    <%= link_to @room.name, settings_menu_path(@room) %><%= @room.status %>Room<%= @room.seater rescue "-" %><%= @room.order_by rescue "-" %><%= @room.is_active rescue "-" %><%= Employee.find(@room.created_by).name %><%= @room.created_by %><%= @room.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %><%= link_to 'Edit', edit_settings_zone_room_path(@zone,@room) %><%= link_to 'Destroy', settings_zone_room_path(@zone,@room), method: :delete, data: { confirm: 'Are you sure?' } %>
    +
    +
    diff --git a/app/views/settings/tables/_form.html.erb b/app/views/settings/tables/_form.html.erb new file mode 100644 index 00000000..a411175c --- /dev/null +++ b/app/views/settings/tables/_form.html.erb @@ -0,0 +1,16 @@ +<%= simple_form_for([:settings,@zone,@settings_table]) do |f| %> + <%= f.error_notification %> + +
    + <%= f.input :name %> + <%= f.input :status %> + <%= f.input :seater %> + <%= f.input :order_by %> + <%= f.input :is_active %> + <%= f.input :created_by, :collection => Employee.collection %> +
    + +
    + <%= f.button :submit %> +
    +<% end %> diff --git a/app/views/settings/tables/_settings_table.json.jbuilder b/app/views/settings/tables/_settings_table.json.jbuilder new file mode 100644 index 00000000..97a32ec3 --- /dev/null +++ b/app/views/settings/tables/_settings_table.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! settings_table, :id, :name, :status, :seater, :order_by, :is_active, :created_by, :created_at, :updated_at +json.url settings_table_url(settings_table, format: :json) diff --git a/app/views/settings/tables/edit.html.erb b/app/views/settings/tables/edit.html.erb new file mode 100644 index 00000000..325aaf39 --- /dev/null +++ b/app/views/settings/tables/edit.html.erb @@ -0,0 +1,10 @@ +
    + + <%= render 'form', settings_table: @settings_table %> +
    diff --git a/app/views/settings/tables/index.html.erb b/app/views/settings/tables/index.html.erb new file mode 100644 index 00000000..c1e509b7 --- /dev/null +++ b/app/views/settings/tables/index.html.erb @@ -0,0 +1,49 @@ + + + + +
    +
    + + + + + + + + + + + + + + + + <% @settings_tables.each do |table| %> + + + + + + + <% if Employee.exists?(table.created_by) %> + + <% else %> + + <% end %> + + + + + <% end %> + +
    NameStatusSeaterOrder byis ActiveCreated ByCreated At
    <%= link_to table.name, settings_menu_path(table) %><%= table.status %><%= table.seater rescue "-" %><%= table.order_by rescue "-" %><%= table.is_active %><%= Employee.find(table.created_by).name %><%= table.created_by %><%= table.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %><%= link_to 'Edit', edit_settings_zone_table_path(@zone,table) %><%= link_to 'Destroy', settings_zone_table_path(@zone,table), method: :delete, data: { confirm: 'Are you sure?' } %>
    +
    diff --git a/app/views/settings/tables/new.html.erb b/app/views/settings/tables/new.html.erb new file mode 100644 index 00000000..52b87627 --- /dev/null +++ b/app/views/settings/tables/new.html.erb @@ -0,0 +1,11 @@ + +
    + + <%= render 'form', settings_table: @settings_table %> +
    diff --git a/app/views/settings/tables/show.html.erb b/app/views/settings/tables/show.html.erb new file mode 100644 index 00000000..7b8bd8ed --- /dev/null +++ b/app/views/settings/tables/show.html.erb @@ -0,0 +1,47 @@ + + +
    +
    +
    +

    Table

    + + + + + + + + + + + + + + + + + + + + + <% if Employee.exists?(@table.created_by) %> + + <% else %> + + <% end %> + + + + + +
    NameStatusSeaterOrder byis ActiveCreated ByCreated At
    <%= link_to @table.name, settings_menu_path(@table) %><%= @table.status %><%= @table.seater rescue "-" %><%= @table.order_by rescue "-" %><%= @table.is_active rescue "-" %><%= Employee.find(@table.created_by).name %><%= @table.created_by %><%= @table.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %><%= link_to 'Edit', edit_settings_zone_table_path(@zone,@table) %><%= link_to 'Destroy', settings_zone_table_path(@zone,@table), method: :delete, data: { confirm: 'Are you sure?' } %>
    +
    +
    diff --git a/app/views/settings/zones/_form.html.erb b/app/views/settings/zones/_form.html.erb index c43a3244..a7740211 100644 --- a/app/views/settings/zones/_form.html.erb +++ b/app/views/settings/zones/_form.html.erb @@ -1,10 +1,10 @@ -<%= simple_form_for(@settings_zone) do |f| %> +<%= simple_form_for([:settings,@settings_zone]) do |f| %> <%= f.error_notification %>
    <%= f.input :name %> <%= f.input :is_active %> - <%= f.input :created_by %> + <%= f.input :created_by, :collection => Employee.collection %>
    diff --git a/app/views/settings/zones/edit.html.erb b/app/views/settings/zones/edit.html.erb index 177c4c61..b9b19f7e 100644 --- a/app/views/settings/zones/edit.html.erb +++ b/app/views/settings/zones/edit.html.erb @@ -1,6 +1,10 @@ -

    Editing Settings Zone

    - -<%= render 'form', settings_zone: @settings_zone %> - -<%= link_to 'Show', @settings_zone %> | -<%= link_to 'Back', settings_zones_path %> +
    + + <%= render 'form', settings_zone: @settings_zone %> +
    diff --git a/app/views/settings/zones/index.html.erb b/app/views/settings/zones/index.html.erb index 40ee09c8..cdbe1f80 100644 --- a/app/views/settings/zones/index.html.erb +++ b/app/views/settings/zones/index.html.erb @@ -1,31 +1,41 @@ -

    <%= notice %>

    -

    Settings Zones

    - - - - - - - - - - - - - <% @settings_zones.each do |settings_zone| %> - - - - - - - - - <% end %> - -
    NameIs activeCreated by
    <%= settings_zone.name %><%= settings_zone.is_active %><%= settings_zone.created_by %><%= link_to 'Show', settings_zone %><%= link_to 'Edit', edit_settings_zone_path(settings_zone) %><%= link_to 'Destroy', settings_zone, method: :delete, data: { confirm: 'Are you sure?' } %>
    +
    +
    + + + + + + + + + -<%= link_to 'New Settings Zone', new_settings_zone_path %> + + <% @settings_zones.each do |settings_zone| %> + + + + <% if Employee.exists?(settings_zone.created_by) %> + + <% else %> + + <% end %> + + + + + <% end %> + +
    NameIs activeCreated by
    <%= settings_zone.name %><%= settings_zone.is_active %><%= Employee.find(settings_zone.created_by).name %><%= settings_zone.created_by %><%= link_to 'Show', settings_zone_path(settings_zone) %><%= link_to 'Edit', edit_settings_zone_path(settings_zone) %><%= link_to 'Destroy', settings_zone_path(settings_zone), method: :delete, data: { confirm: 'Are you sure?' } %>
    +
    diff --git a/app/views/settings/zones/show.html.erb b/app/views/settings/zones/show.html.erb index 4c0b93dd..33e8487c 100644 --- a/app/views/settings/zones/show.html.erb +++ b/app/views/settings/zones/show.html.erb @@ -1,19 +1,97 @@ -

    <%= notice %>

    + -

    - Name: - <%= @settings_zone.name %> -

    +
    +
    +
    +

    Zone

    + + + + + + + + + -

    - Is active: - <%= @settings_zone.is_active %> -

    + + + + + <% if Employee.exists?(@settings_zone.created_by) %> + + <% else %> + + <% end %> + + + + +
    NameIs activeCreated by
    <%= @settings_zone.name %><%= @settings_zone.is_active %><%= Employee.find(@settings_zone.created_by).name %><%= @settings_zone.created_by %><%= link_to 'Edit', edit_settings_zone_path(@settings_zone) %><%= link_to 'Destroy', settings_zone_path(@settings_zone), method: :delete, data: { confirm: 'Are you sure?' } %>
    +
    +
    +
    +
    +
    +

    Dining Facilities + + <%= link_to "New Table",new_settings_zone_table_path(@settings_zone),:class => 'btn btn-primary btn-sm' %> + <%= link_to "New Room",new_settings_zone_room_path(@settings_zone),:class => 'btn btn-primary btn-sm' %> + +

    + + + + + + + + + + + -

    - Created by: - <%= @settings_zone.created_by %> -

    - -<%= link_to 'Edit', edit_settings_zone_path(@settings_zone) %> | -<%= link_to 'Back', settings_zones_path %> + + <% @settings_tables.each do |settings_table|%> + + + + + + <% if Employee.exists?(settings_table.created_by) %> + + <% else %> + + <% end %> + + + + <% end %> + <% @settings_rooms.each do |room|%> + + + + + + <% if Employee.exists?(room.created_by) %> + + <% else %> + + <% end %> + + + + <% end %> + +
    NameTypeSeaterIs activeCreated by
    <%= link_to settings_table.name, settings_zone_table_path(@settings_zone,settings_table) %>Table<%= settings_table.seater %><%= settings_table.is_active %><%= Employee.find(settings_table.created_by).name %><%= settings_table.created_by %><%= settings_table.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %><%= link_to 'Edit', edit_settings_zone_table_path(@settings_zone, settings_table) %>
    <%= link_to room.name, settings_zone_room_path(@settings_zone,room) %>Room<%= room.seater %><%= room.is_active %><%= Employee.find(room.created_by).name %><%= room.created_by %><%= room.created_at.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") %><%= link_to 'Edit', edit_settings_zone_room_path(@settings_zone, room) %>
    +
    +
    diff --git a/db/migrate/20170403142424_create_dining_facilities.rb b/db/migrate/20170403142424_create_dining_facilities.rb index 599151c6..cf81e775 100644 --- a/db/migrate/20170403142424_create_dining_facilities.rb +++ b/db/migrate/20170403142424_create_dining_facilities.rb @@ -4,7 +4,7 @@ class CreateDiningFacilities < ActiveRecord::Migration[5.1] t.references :zone, foreign_key: true t.string :name, :null => false t.string :status, :null => false, :default => "available" - t.string :type, :null => false, :default => "table" + t.string :type, :null => false, :default => "Table" t.integer :seater, :null => false, :default => 2 t.integer :order_by From 80320b6d3ed5a00cfaedbfe177ad57f8e6a8b1b4 Mon Sep 17 00:00:00 2001 From: Yan Date: Sun, 18 Jun 2017 00:45:39 +0630 Subject: [PATCH 15/17] oqs updated --- app/assets/javascripts/OQS.js | 2 ++ app/controllers/oqs/home_controller.rb | 26 ++++++++++++++++++++------ app/models/dining_facility.rb | 20 ++++++++++++++++++-- app/models/order_queue_station.rb | 18 +++++++++--------- app/views/oqs/home/index.html.erb | 1 + 5 files changed, 50 insertions(+), 17 deletions(-) diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index 8e252749..1ffc71b8 100644 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -30,6 +30,7 @@ $(document).ready(function(){ var orderBy = $(this).children().children().children().children('.order-by').text(); var orderAt = $(this).children().children().children().children('.order-at').text(); var orderCustomer = $(this).children().children('.order-customer').text(); + var order_status = $(this).children().children('.order-status').text(); $('#order-title').text("ORDER DETAILS - " + orderZone); $('#order-by').text(orderBy); @@ -43,6 +44,7 @@ $(document).ready(function(){ $.ajax({ type: 'GET', url: '/oqs/' + orderZone, + data: { 'status' : order_status }, success: function(res){ for (i = 0; i < res.length; i++) { var data = JSON.stringify(res[i]); diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index 67f96a26..a6898e85 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -26,15 +26,29 @@ class Oqs::HomeController < BaseOqsController def get_order_items items = [] table_name = params[:table_id] + status = params[:status] dining = DiningFacility.find_by_name(table_name); - booking_id = dining.get_current_booking - BookingOrder.where("booking_id='#{ booking_id }'").find_each do |bo| - order=Order.find(bo.order_id); - order.order_items.each do |oi| - items.push(oi) - end + oqpz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id) + if status == "" + AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=0").find_each do |aoi| + oi = OrderItem.find_by_item_code(aoi.item_code) + items.push(oi) + end + else + AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=1").find_each do |aoi| + oi = OrderItem.find_by_item_code(aoi.item_code) + items.push(oi) + end end + # booking_id = dining.get_new_booking + # BookingOrder.where("booking_id='#{ booking_id }'").find_each do |bo| + # order=Order.find(bo.order_id); + # order.order_items.each do |oi| + # items.push(oi) + # end + # end + render :json => items.to_json end diff --git a/app/models/dining_facility.rb b/app/models/dining_facility.rb index a3f8948f..6f898989 100644 --- a/app/models/dining_facility.rb +++ b/app/models/dining_facility.rb @@ -9,8 +9,24 @@ class DiningFacility < ApplicationRecord scope :active, -> {where(is_active: true)} def get_current_booking - puts "enter booking" - booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1) + puts "enter booking" + booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and checkin_at between '#{DateTime.now.utc - 5.hours}' and '#{DateTime.now.utc}' and checkout_at is null").limit(1) + + if booking.count > 0 then + return booking[0].booking_id + else + return nil + end + end + + def get_new_booking + # query for new + # if status + # to ask when req bill booking_status? + booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and sale_id is null and checkout_at is null").limit(1) + # else + # booking = Booking.where("dining_facility_id = #{self.id} and booking_status ='assign' and sale_id not null").limit(1) + # end if booking.count > 0 then return booking[0].booking_id diff --git a/app/models/order_queue_station.rb b/app/models/order_queue_station.rb index d6e21c64..86a781d2 100644 --- a/app/models/order_queue_station.rb +++ b/app/models/order_queue_station.rb @@ -18,19 +18,19 @@ class OrderQueueStation < ApplicationRecord oqs_stations.each do |oqs| #Get List of items - pq_items = JSON.parse(oqs.processing_items) - - if oqs.id == oqpbz.order_queue_station_id + #Loop through the processing items - pq_items.each do |pq_item| - #Processing through the looping items - order_items.each do |order_item| - if (pq_item == order_item.item_code) + pq_items.each do |pq_item| + #Processing through the looping items + order_items.each do |order_item| + if (pq_item == order_item.item_code) + if oqs.id == oqpbz.order_queue_station_id #Same Order_items can appear in two location. - AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) - end + AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) + end end end - end + end end #Print OQS where printing is require diff --git a/app/views/oqs/home/index.html.erb b/app/views/oqs/home/index.html.erb index 1f13383d..18e72880 100644 --- a/app/views/oqs/home/index.html.erb +++ b/app/views/oqs/home/index.html.erb @@ -60,6 +60,7 @@

    +
    From f33f11df64d0db6c23e47434cbb7dece54c8f389 Mon Sep 17 00:00:00 2001 From: Yan Date: Sun, 18 Jun 2017 03:20:19 +0630 Subject: [PATCH 16/17] rescue member call and update oqs and js route bug --- app/assets/javascripts/origami.js | 13 ++--- app/controllers/api/bill_controller.rb | 21 +++++++- app/controllers/oqs/home_controller.rb | 48 +++++++++++++------ app/controllers/origami/home_controller.rb | 1 + .../origami/payments_controller.rb | 2 +- app/models/customer.rb | 7 ++- app/models/order.rb | 2 +- app/models/sale.rb | 36 +++++++------- app/models/sale_item.rb | 2 + app/models/sale_payment.rb | 9 +++- app/pdf/receipt_bill_pdf.rb | 8 ++-- app/views/origami/home/index.html.erb | 4 +- 12 files changed, 102 insertions(+), 51 deletions(-) diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 6149a2bc..78a21c3b 100644 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -121,7 +121,7 @@ $(document).ready(function(){ // Bill Request $('#request_bills').click(function() { - var order_id=$(".selected-item").find(".orders-id").text(); + var order_id=$(".selected-item").find(".orders-id").text().substr(0,16); if(order_id!=""){ window.location.href = '/origami/' + order_id + '/request_bills' } @@ -133,7 +133,8 @@ $(document).ready(function(){ // Discount for Payment $('#discount').click(function() { - var order_id=$(".selected-item").find(".orders-id").text(); + var order_id=$(".selected-item").find(".orders-id").text().substr(0,16); + if(order_id!=""){ window.location.href = '/origami/' + order_id + '/discount' } @@ -148,7 +149,7 @@ $(document).ready(function(){ $("#pay-discount").on('click', function(e){ e.preventDefault(); var sale_id = $('#sale-id').text(); - var sale_item_id = $('.selected-item').attr('id'); + var sale_item_id = $('.selected-item').attr('id').substr(0,16); var sub_total = $('#order-sub-total').text(); var grand_total = $('#order-grand-total').text(); var discount_type = $('#discount-type').val(); @@ -178,7 +179,7 @@ $(document).ready(function(){ // Payment for Bill $('#pay-bill').click(function() { - var sale_id=$(".selected-item").find(".orders-id").text(); + var sale_id=$(".selected-item").find(".orders-id").text().substr(0,16); if(sale_id!=""){ window.location.href = '/origami/sale/'+ sale_id + "/payment" } @@ -190,7 +191,7 @@ $(document).ready(function(){ }); $('#customer').click(function() { - var sale = $(".selected-item").find(".orders-id").text(); + var sale = $(".selected-item").find(".orders-id").text().substr(0,16); if (sale.substring(0, 3)=="SAL") { var sale_id = sale }else{ @@ -202,7 +203,7 @@ $(document).ready(function(){ }); $('#re-print').click(function() { - var sale_id = $(".selected-item").find(".orders-id").text(); + var sale_id = $(".selected-item").find(".orders-id").text().substr(0,16); window.location.href = '/origami/'+ sale_id + "/reprint" diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index 6b1fb225..75d412e7 100644 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -15,13 +15,32 @@ class Api::BillController < Api::ApiController @status, @sale_id = @sale.generate_invoice_from_booking(params[:booking_id], current_login_employee) else @status = true + @sale_id = booking.sale_id end end elsif (params[:order_id]) @sale = Sale.new @status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee) - end + + @sale_data = Sale.find_by_sale_id(@sale_id) + @sale_items = SaleItem.where("sale_id=?",@sale_id) + + unique_code = "ReceiptBillPdf" + customer= Customer.where('customer_id=' + @sale_data.customer_id) + + # get printer info + print_settings=PrintSetting.find_by_unique_code(unique_code) + + # find order id by sale id + # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id) + + # Calculate Food and Beverage Total + food_total, beverage_total = SaleItem.calculate_food_beverage(@sale_items) + + printer = Printer::ReceiptPrinter.new(print_settings) + printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total) + redirect_to origami_path(@sale_data.sale_id) end diff --git a/app/controllers/oqs/home_controller.rb b/app/controllers/oqs/home_controller.rb index a6898e85..979c5b88 100644 --- a/app/controllers/oqs/home_controller.rb +++ b/app/controllers/oqs/home_controller.rb @@ -28,16 +28,24 @@ class Oqs::HomeController < BaseOqsController table_name = params[:table_id] status = params[:status] dining = DiningFacility.find_by_name(table_name); - oqpz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id) - if status == "" - AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=0").find_each do |aoi| - oi = OrderItem.find_by_item_code(aoi.item_code) - items.push(oi) - end - else - AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=1").find_each do |aoi| - oi = OrderItem.find_by_item_code(aoi.item_code) - items.push(oi) + # oqpz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id) + # if status == "" + # AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=0").find_each do |aoi| + # oi = OrderItem.find_by_item_code(aoi.item_code) + # items.push(oi) + # end + # else + # AssignedOrderItem.where("order_queue_station_id=#{ oqpz.order_queue_station_id } AND delivery_status=1").find_each do |aoi| + # oi = OrderItem.find_by_item_code(aoi.item_code) + # items.push(oi) + # end + # end + + booking = Booking.find_by_dining_facility_id(dining.id) + BookingOrder.where("booking_id='#{ booking.booking_id }'").find_each do |bo| + order=Order.find(bo.order_id) + order.order_items.each do |oi| + items.push(oi) end end @@ -73,16 +81,26 @@ class Oqs::HomeController < BaseOqsController # Query for OQS with status def queue_items_query(status) + # AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at") + # .joins(" left join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id + # left join dining_facilities as df on df.zone_id = oqpz.zone_id + # left join order_queue_stations as oqs ON oqs.id = assigned_order_items.order_queue_station_id + # left join orders as od ON od.order_id = assigned_order_items.order_id + # left join order_items as odt ON odt.item_code = assigned_order_items.item_code + # left join customers as cus ON cus.customer_id = od.customer_id") + # .where("assigned_order_items.delivery_status = #{status}") + # .group("assigned_order_items.assigned_order_item_id") + # .order("odt.item_name DESC") AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, cus.name as customer_name, odt.created_at") - .joins(" left join order_queue_process_by_zones as oqpz ON oqpz.order_queue_station_id = assigned_order_items.order_queue_station_id - left join dining_facilities as df on df.zone_id = oqpz.zone_id - left join order_queue_stations as oqs ON oqs.id = assigned_order_items.order_queue_station_id + .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id left join orders as od ON od.order_id = assigned_order_items.order_id left join order_items as odt ON odt.item_code = assigned_order_items.item_code - left join customers as cus ON cus.customer_id = od.customer_id") + left join customers as cus ON cus.customer_id = od.customer_id + left join booking_orders as bo on bo.order_id = assigned_order_items.order_id + left join bookings as bk on bk.booking_id = bo.booking_id + left join dining_facilities as df on df.id = bk.dining_facility_id") .where("assigned_order_items.delivery_status = #{status}") .group("assigned_order_items.assigned_order_item_id") - .order("odt.item_name DESC") end end diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index dbde3293..49ad4806 100644 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -39,6 +39,7 @@ class Origami::HomeController < BaseOrigamiController str.push(ord_detail) end end + if is_ajax == 1 render :json => str.to_json else diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index ca497b81..2cb218da 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -48,7 +48,7 @@ class Origami::PaymentsController < BaseOrigamiController @balance = 0.00 @accountable_type = '' - if response["data"]==true + if response["status"]==true response["data"].each do |res| if res["accountable_type"] == "RebateAccount" @balance = res["balance"] diff --git a/app/models/customer.rb b/app/models/customer.rb index 0cbf8d58..0fda2bb9 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -39,12 +39,17 @@ class Customer < ApplicationRecord auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s + begin response = HTTParty.get(url, :body => { membership_id: customer.membership_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' - } + }, + :timeout => 10 ) + rescue Net::OpenTimeout + response = { status: false } + end return response; diff --git a/app/models/order.rb b/app/models/order.rb index 2ea76a98..a4328d76 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -246,7 +246,7 @@ class Order < ApplicationRecord .joins("left join orders on orders.order_id = booking_orders.order_id") .joins("left join sales on sales.sale_id = bookings.sale_id") .where("sales.sale_status='completed'") - .group("sales.sale_id,bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id") + .group("sales.sale_id") # For PG #bookings.booking_id,sales.receipt_no,orders.status,sales.sale_id,dining_facilities.name,orders.status,orders.order_id end diff --git a/app/models/sale.rb b/app/models/sale.rb index 9683c2b2..1edd835e 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -195,28 +195,28 @@ class Sale < ApplicationRecord existing_tax.delete end - total_tax_amount = 0 - #tax_profile - list by order_by - tax_profiles = TaxProfile.all.order("order_by asc") + # total_tax_amount = 0 + # #tax_profile - list by order_by + # tax_profiles = TaxProfile.all.order("order_by asc") - #Creat new tax records - tax_profiles.each do |tax| - sale_tax = SaleTax.new(:sale => self) - sale_tax.tax_name = tax.name - sale_tax.tax_rate = tax.rate - #include or execulive - # sale_tax.tax_payable_amount = total_taxable * tax.rate - sale_tax.tax_payable_amount = total_taxable * tax.rate / 100 - #new taxable amount - total_taxable = total_taxable + sale_tax.tax_payable_amount + # #Creat new tax records + # tax_profiles.each do |tax| + # sale_tax = SaleTax.new(:sale => self) + # sale_tax.tax_name = tax.name + # sale_tax.tax_rate = tax.rate + # #include or execulive + # # sale_tax.tax_payable_amount = total_taxable * tax.rate + # sale_tax.tax_payable_amount = total_taxable * tax.rate / 100 + # #new taxable amount + # total_taxable = total_taxable + sale_tax.tax_payable_amount - sale_tax.inclusive = tax.inclusive - sale_tax.save + # sale_tax.inclusive = tax.inclusive + # sale_tax.save - total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount - end + # total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount + # end - self.total_tax = total_tax_amount + # self.total_tax = total_tax_amount end diff --git a/app/models/sale_item.rb b/app/models/sale_item.rb index ef852bbd..71373f2d 100644 --- a/app/models/sale_item.rb +++ b/app/models/sale_item.rb @@ -30,6 +30,7 @@ class SaleItem < ApplicationRecord # end end + # Calculate food total and beverage total def self.calculate_food_beverage(sale_items) food_prices=0 beverage_prices=0 @@ -43,6 +44,7 @@ class SaleItem < ApplicationRecord return food_prices, beverage_prices end + # get food price or beverage price for item def self.get_price(sale_item_id) food_price=0 beverage_price=0 diff --git a/app/models/sale_payment.rb b/app/models/sale_payment.rb index 731fa321..2b0035f3 100644 --- a/app/models/sale_payment.rb +++ b/app/models/sale_payment.rb @@ -260,12 +260,17 @@ class SalePayment < ApplicationRecord campaign_type_id = memberaction.additional_parameter["campaign_type_id"] auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s - response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id, + + begin + response = HTTParty.post(url, :body => { generic_customer_id:generic_customer_id ,merchant_uid:merchant_uid,total_amount: total_amount,campaign_type_id: campaign_type_id, receipt_no: receipt_no,auth_token:auth_token}.to_json, :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json' - }) + }, :timeout => 10) + rescue Net::OpenTimeout + response = { status: false } + end puts response.to_json end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index 524ee7e5..b04d85ce 100644 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -121,9 +121,9 @@ class ReceiptBillPdf < Prawn::Document pad_top(15) { text_box "#{product_name}", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :overflow => :shrink_to_fix, :size => self.item_font_size, :overflow => :shrink_to_fix - text_box "#{price.to_i}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix - text_box "#{qty.to_i}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix - text_box "#{total_price.to_i}", :at =>[(item_name_width),y_position], :width =>self.total_width+5, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{price}", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix + text_box "#{qty}", :at =>[item_name_width,y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix + text_box "#{total_price}", :at =>[(item_name_width),y_position], :width =>self.total_width+5, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix } move_down 3 end @@ -174,7 +174,7 @@ class ReceiptBillPdf < Prawn::Document text "#{ st.tax_name }", :size => self.item_font_size,:align => :left end bounding_box([self.item_description_width,y_position], :width =>self.label_width) do - text "( " +"#{ st.tax_payable_amount }" +" )" , :size => self.item_font_size,:align => :right + text "#{ st.tax_payable_amount }" , :size => self.item_font_size,:align => :right end end else diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index 66d65aea..607f24b2 100644 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -354,14 +354,14 @@ Discount: (<%=@selected_item.total_discount rescue 0%>) - + From 5906dde74166838f3050c06a11649e55d6d256ed Mon Sep 17 00:00:00 2001 From: Yan Date: Sun, 18 Jun 2017 13:18:53 +0630 Subject: [PATCH 17/17] uncomment for sale taxes --- app/models/sale.rb | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/app/models/sale.rb b/app/models/sale.rb index 1edd835e..3714c21e 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -23,6 +23,8 @@ class Sale < ApplicationRecord if (booking) Rails.logger.debug "Booking -> Booking Order Count -> " + booking.booking_orders.count.to_s #get all order attached to this booking and combine into 1 invoice + + puts booking.booking_orders.length booking.booking_orders.each do |order| if booking.sale_id status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by) @@ -195,28 +197,28 @@ class Sale < ApplicationRecord existing_tax.delete end - # total_tax_amount = 0 - # #tax_profile - list by order_by - # tax_profiles = TaxProfile.all.order("order_by asc") + total_tax_amount = 0 + #tax_profile - list by order_by + tax_profiles = TaxProfile.all.order("order_by asc") # #Creat new tax records - # tax_profiles.each do |tax| - # sale_tax = SaleTax.new(:sale => self) - # sale_tax.tax_name = tax.name - # sale_tax.tax_rate = tax.rate - # #include or execulive - # # sale_tax.tax_payable_amount = total_taxable * tax.rate - # sale_tax.tax_payable_amount = total_taxable * tax.rate / 100 - # #new taxable amount - # total_taxable = total_taxable + sale_tax.tax_payable_amount + tax_profiles.each do |tax| + sale_tax = SaleTax.new(:sale => self) + sale_tax.tax_name = tax.name + sale_tax.tax_rate = tax.rate + #include or execulive + # sale_tax.tax_payable_amount = total_taxable * tax.rate + sale_tax.tax_payable_amount = total_taxable * tax.rate / 100 + #new taxable amount + total_taxable = total_taxable + sale_tax.tax_payable_amount - # sale_tax.inclusive = tax.inclusive - # sale_tax.save + sale_tax.inclusive = tax.inclusive + sale_tax.save - # total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount - # end + total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount + end - # self.total_tax = total_tax_amount + self.total_tax = total_tax_amount end