From 7cbb67fd3093b0a6b6f0e295f5637a2d60676658 Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 22 Feb 2018 18:51:57 +0630 Subject: [PATCH] add link for oqs in origami --- app/assets/javascripts/OQS.js | 2 +- app/controllers/home_controller.rb | 7 +- app/controllers/oqs/edit_controller.rb | 6 ++ .../origami/dashboard_controller.rb | 1 + app/controllers/origami/home_controller.rb | 5 ++ .../origami/split_bill_controller.rb | 1 + .../origami/table_invoices_controller.rb | 2 + app/models/ability.rb | 3 + app/pdf/receipt_bill_a5_pdf.rb | 6 +- app/pdf/receipt_bill_pdf.rb | 6 +- app/views/layouts/_header.html.erb | 4 +- app/views/oqs/edit/index.html.erb | 34 ++++++++- app/views/origami/dashboard/index.html.erb | 52 +------------ app/views/origami/home/show.html.erb | 63 ++++++++++++---- app/views/origami/payments/show.html.erb | 30 +++++--- app/views/origami/rooms/show.html.erb | 7 +- app/views/origami/sale_edit/edit.html.erb | 46 ++++++++++-- app/views/origami/split_bill/index.html.erb | 15 +++- .../origami/table_invoices/show.html.erb | 74 +++++++++++++++---- config/routes.rb | 2 +- 20 files changed, 257 insertions(+), 109 deletions(-) diff --git a/app/assets/javascripts/OQS.js b/app/assets/javascripts/OQS.js index 35e08b4f..47c16ad1 100755 --- a/app/assets/javascripts/OQS.js +++ b/app/assets/javascripts/OQS.js @@ -185,7 +185,7 @@ $(document).on('turbolinks:load', function() { $(document).on('click', '.order-item-edit', function(event){ var _self = $(this); // To know in ajax return var assigned_item_id=$(this).attr('id').substr(5); - window.location.href = '/oqs/'+ assigned_item_id + "/edit" + window.location.href = '/oqs/'+ assigned_item_id + "/edit/oqs"; }); // complete for queue item diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 1c006be1..97c413c0 100755 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -46,9 +46,12 @@ class HomeController < ApplicationController elsif @employee.role == "manager" session[:session_token] = @employee.token_session redirect_to dashboard_path - elsif @employee.role == "supervisor" || @employee.role == "waiter" + elsif @employee.role == "supervisor" session[:session_token] = @employee.token_session redirect_to origami_root_path + elsif @employee.role == "waiter" + session[:session_token] = @employee.token_session + redirect_to origami_dashboard_path elsif @employee.role == "account" session[:session_token] = @employee.token_session redirect_to reports_dailysale_index_path @@ -160,7 +163,7 @@ class HomeController < ApplicationController elsif employee.role == "manager" redirect_to dashboard_path elsif employee.role == "waiter" - redirect_to oqs_root_path + redirect_to origami_dashboard_path elsif employee.role == "crm" redirect_to crm_root_path elsif @employee.role == "supervisor" diff --git a/app/controllers/oqs/edit_controller.rb b/app/controllers/oqs/edit_controller.rb index f8bef2de..52ebdd2c 100755 --- a/app/controllers/oqs/edit_controller.rb +++ b/app/controllers/oqs/edit_controller.rb @@ -1,6 +1,12 @@ class Oqs::EditController < BaseOqsController def index assigned_item_id = params[:id] + @link_type = params[:type] + @dining_type = nil + if params[:type] != 'oqs' + dining = DiningFacility.find_by_id(params[:type]) + @dining_type = dining.type + end assigned_item = AssignedOrderItem.find(assigned_item_id) @order_item = OrderItem.where("order_id='#{ assigned_item.order_id }' AND item_instance_code='#{ assigned_item.instance_code }'"); end diff --git a/app/controllers/origami/dashboard_controller.rb b/app/controllers/origami/dashboard_controller.rb index e47a8e48..a3d08132 100644 --- a/app/controllers/origami/dashboard_controller.rb +++ b/app/controllers/origami/dashboard_controller.rb @@ -55,6 +55,7 @@ class Origami::DashboardController < BaseOrigamiController # get printer info @print_settings = PrintSetting.get_precision_delimiter() + @current_user = current_user end helper_method :shop_detail diff --git a/app/controllers/origami/home_controller.rb b/app/controllers/origami/home_controller.rb index 3a7501e6..eedbfdfc 100755 --- a/app/controllers/origami/home_controller.rb +++ b/app/controllers/origami/home_controller.rb @@ -62,6 +62,7 @@ class Origami::HomeController < BaseOrigamiController @dining.bookings.active.each do |booking| if booking.sale_id.nil? && booking.booking_status != 'moved' @order_items = Array.new + @assigned_order_items = Array.new if booking.booking_orders.empty? @booking = booking else @@ -84,6 +85,10 @@ class Origami::HomeController < BaseOrigamiController item.set_menu_items = arr_instance_item_sets end @order_items.push(item) + assigned_order_items = AssignedOrderItem.find_by_item_code_and_instance_code_and_order_id(item.item_code,item.item_instance_code,item.order_id) + if !assigned_order_items.nil? + @assigned_order_items.push({item.order_items_id => assigned_order_items.assigned_order_item_id}) + end end accounts = @customer.tax_profiles puts accounts.to_json diff --git a/app/controllers/origami/split_bill_controller.rb b/app/controllers/origami/split_bill_controller.rb index 987f68e7..59dd3a71 100644 --- a/app/controllers/origami/split_bill_controller.rb +++ b/app/controllers/origami/split_bill_controller.rb @@ -8,6 +8,7 @@ class Origami::SplitBillController < BaseOrigamiController @orders = Array.new @order_items = Array.new @sale_data = Array.new + @current_user = current_user table_bookings = Booking.where("dining_facility_id = #{dining_id} and sale_id IS NOT NULL") if !table_bookings.nil? diff --git a/app/controllers/origami/table_invoices_controller.rb b/app/controllers/origami/table_invoices_controller.rb index f2dd132a..09535f4a 100755 --- a/app/controllers/origami/table_invoices_controller.rb +++ b/app/controllers/origami/table_invoices_controller.rb @@ -65,6 +65,8 @@ class Origami::TableInvoicesController < BaseOrigamiController if !lookup_spit_bill[0].nil? @split_bill = lookup_spit_bill[0][1] end + # get printer info + @print_settings = PrintSetting.get_precision_delimiter() end #Shop Name in Navbor diff --git a/app/models/ability.rb b/app/models/ability.rb index 7afb6bc4..33372ac9 100755 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -191,6 +191,9 @@ class Ability elsif user.role == "waiter" can :index, :home can :show, :home + #ability for split_bill + can :index, :split_bill + can :create, :split_bill end end end diff --git a/app/pdf/receipt_bill_a5_pdf.rb b/app/pdf/receipt_bill_a5_pdf.rb index c4666963..b3302485 100644 --- a/app/pdf/receipt_bill_a5_pdf.rb +++ b/app/pdf/receipt_bill_a5_pdf.rb @@ -487,17 +487,17 @@ class ReceiptBillA5Pdf < Prawn::Document move_down 5 y_position = cursor bounding_box([0,y_position], :width =>self.label_width+50) do - text "Individual amount for #{sale_data.equal_persons} persons", :size => self.item_font_size+1,:align => :left + text "Split Bill for #{sale_data.equal_persons} persons", :size => self.item_font_size+1,:align => :left end bounding_box([0,y_position], :width =>self.label_width) do move_down 15 - text "Total Amount", :size => self.item_font_size,:align => :left + text "Amount Due (per person)", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width =>self.item_description_width) do move_down 15 - text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)} per person", :size => self.item_font_size,:align => :right + text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right end end diff --git a/app/pdf/receipt_bill_pdf.rb b/app/pdf/receipt_bill_pdf.rb index aef26a9d..0ae57fea 100755 --- a/app/pdf/receipt_bill_pdf.rb +++ b/app/pdf/receipt_bill_pdf.rb @@ -488,17 +488,17 @@ class ReceiptBillPdf < Prawn::Document move_down 5 y_position = cursor bounding_box([0,y_position], :width =>self.label_width+50) do - text "Individual amount for #{sale_data.equal_persons} persons", :size => self.item_font_size+1,:align => :left + text "Split Bill for #{sale_data.equal_persons} persons", :size => self.item_font_size+1,:align => :left end bounding_box([0,y_position], :width =>self.label_width) do move_down 15 - text "Total Amount", :size => self.item_font_size,:align => :left + text "Amount Due (per person)", :size => self.item_font_size,:align => :left end bounding_box([self.label_width,y_position], :width =>self.item_description_width) do move_down 15 - text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)} per person", :size => self.item_font_size,:align => :right + text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size,:align => :right end end diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index ec0a3c68..45cedcc3 100755 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -14,11 +14,11 @@
+ <% end %> diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index fa4167b2..2a78ee91 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -125,7 +125,13 @@ <% if !@individual_total[0].nil? %> - Individual amount for <%= @individual_total[0]['total_customer'] %> persons + Split Bill for <%= @individual_total[0]['total_customer'] %> persons + + + + + + Amount Due (per person) <%= number_with_precision(@individual_total[0]['per_person_amount'], precision: precision.to_i )%> @@ -445,7 +451,7 @@ console.log("fffffffffffff") swal ( "Oops" , "Please select an table!" , "warning" ); } }else{ - swal("Opps","You are not authorized for Discount","warning") + swal("Oops","You are not authorized for Discount","warning") } return false; }); @@ -461,7 +467,7 @@ console.log("fffffffffffff") } }else{ - swal("Opps","You are not authorized for void","warning") + swal("Oops","You are not authorized for void","warning") } }); @@ -548,23 +554,23 @@ console.log("fffffffffffff") $('#pay').click(function() { sub_total = $('#sub-total').text(); if (payment_type == 'MPU' && $('.mpu').text() == 0 && sub_total != 0.0) { - swal("Opps","Please Pay with MPU Payment","warning"); + swal("Oops","Please Pay with MPU Payment","warning"); }else if(payment_type == "Redeem" && $('#ppamount').text()==0 && sub_total != 0.0){ - swal("Opps","Please Pay with Redeem Payment","warning"); + swal("Oops","Please Pay with Redeem Payment","warning"); }else if(payment_type == "VISA" && $('#visacount').text()==0 && sub_total != 0.0){ - swal("Opps","Please Pay with Visa Payment","warning"); + swal("Oops","Please Pay with Visa Payment","warning"); }else if(payment_type == "JCB" && $('#jcbcount').text()==0 && sub_total != 0.0){ - swal("Opps","Please Pay with jcb Payment","warning"); + swal("Oops","Please Pay with jcb Payment","warning"); } else if(payment_type == "Master" && $('#mastercount').text()==0 && sub_total != 0.0){ - swal("Opps","Please Pay with Master Payment","warning"); + swal("Oops","Please Pay with Master Payment","warning"); } else if(payment_type == "UNIONPAY" && $('#unionpaycount').text()==0 && sub_total != 0.0){ - swal("Opps","Please Pay with UNIONPAY Payment","warning"); + swal("Oops","Please Pay with UNIONPAY Payment","warning"); } else if(payment_type == "Credit" && $('#credit').text()==0 && sub_total != 0.0){ - swal("Opps","Please Pay with Credit Payment","warning"); + swal("Oops","Please Pay with Credit Payment","warning"); }else{ $( "#loading_wrapper").show(); @@ -664,7 +670,7 @@ console.log("fffffffffffff") }) }); }else{ - swal("Opps","You are not authorized for void","warning") + swal("Oops","You are not authorized for void","warning") } }); @@ -722,7 +728,7 @@ console.log("fffffffffffff") } }); }else{ - swal("Opps","You are not authorized for foc","warning") + swal("Oops","You are not authorized for foc","warning") } }); diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 4434d45d..1235f522 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -420,6 +420,7 @@ <% if @status_sale == 'sale' %> + <% if current_login_employee.role != "waiter" %> <% end %> <% end %> + <% if current_login_employee.role != "waiter" %> <% if ENV["SERVER_MODE"] == "cloud" %> @@ -443,8 +446,10 @@ <%end%> <%end%> + <% end %> <% end %> + <% if current_login_employee.role != "waiter" %> "> @@ -475,7 +480,7 @@ - + <% end %> <% end %> diff --git a/app/views/origami/sale_edit/edit.html.erb b/app/views/origami/sale_edit/edit.html.erb index 3f65a8ad..b971ddbd 100755 --- a/app/views/origami/sale_edit/edit.html.erb +++ b/app/views/origami/sale_edit/edit.html.erb @@ -1,7 +1,7 @@
-
+
INVOICE DETAILS
@@ -63,7 +63,8 @@ - + +
- + <% if !@current_user.nil? && @current_user.role == 'cashier' %> + + <% end %> <% if !@orders.empty? %> @@ -689,6 +700,8 @@ function get_selected_order_items(){ var order_item = {}; order_item.id = $(this).attr('id').substr(0,16); order_item.order_id = $(this).find('#item-order-id').text().trim(); + order_item.item_code = $(this).find('#item-code').text().trim(); + order_item.item_instance_code = $(this).find('#item-instance-code').text().trim(); order_item.name = $(this).find('#item-name-price').text().split('@')[0]; order_item.account_id = $(this).find('#item-account-type').text(); order_item.qty = $(this).find('#item-qty').text(); diff --git a/app/views/origami/table_invoices/show.html.erb b/app/views/origami/table_invoices/show.html.erb index 831dab61..3336ffe2 100755 --- a/app/views/origami/table_invoices/show.html.erb +++ b/app/views/origami/table_invoices/show.html.erb @@ -1,11 +1,26 @@
+<% if !@print_settings.nil? %> + <% if @print_settings.precision.to_i > 0 + precision = @print_settings.precision + else + precision = 0 + end + #check delimiter + if @print_settings.delimiter + delimiter = "," + else + delimiter = "" + end + %> +<% end %> +
<% @sale_array.each do |sale| %> -
+
<% if sale.id == @sale.id %> -
+
<%= sale.receipt_no %>
<% else %> @@ -15,7 +30,7 @@ <% end %>
<% end %> -
+
@@ -74,7 +89,7 @@ <%= count %> <%= sale_item.product_name %> <%= sale_item.qty %> - <%= sale_item.price %> + <%= number_with_precision(sale_item.price, precision: precision.to_i ) %> <% # end @@ -93,7 +108,7 @@ <%= count %> <%= order_item.item_name %> <%= order_item.qty %> - <%= order_item.qty*order_item.price %> + <%= number_with_precision(order_item.qty*order_item.price, precision: precision.to_i ) %> <% end @@ -109,7 +124,7 @@ - + <%if @sale.discount_type == 'member_discount'%> @@ -117,19 +132,19 @@ <%else%> <%end%> - + - + - + - +
Sub Total:<%= sub_total %><%= number_with_precision(sub_total, precision: precision.to_i ) %>
Discount:(<%= @sale.total_discount rescue 0%>)(<%= number_with_precision(@sale.total_discount, precision: precision.to_i ) rescue 0%>)
Tax:<%= @sale.total_tax rescue 0%><%= number_with_precision(@sale.total_tax, precision: precision.to_i ) rescue 0%>
Rounding Adj:<%= @sale.rounding_adjustment rescue 0%><%= number_with_precision(@sale.rounding_adjustment, precision: precision.to_i ) rescue 0%>
Grand Total:<%= @sale.grand_total rescue 0%><%= number_with_precision(@sale.grand_total, precision: precision.to_i ) rescue 0%>
@@ -142,7 +157,8 @@
-