From f4b85ad4cc3e431568fc784099c9d75e36bad602 Mon Sep 17 00:00:00 2001 From: phyusin Date: Mon, 24 Sep 2018 10:29:08 +0630 Subject: [PATCH] add req bill and payment #left order and sale --- app/assets/stylesheets/application.scss | 17 ++ app/assets/stylesheets/origami.scss | 7 +- .../origami/payments_controller.rb | 9 +- .../origami/request_bills_controller.rb | 2 +- .../transactions/bookings_controller.rb | 2 +- .../transactions/sales_controller.rb | 3 +- app/models/booking.rb | 8 +- app/views/origami/home/show.html.erb | 32 ++-- app/views/origami/payments/show.html.erb | 55 ++++-- app/views/origami/rooms/show.html.erb | 28 ++-- .../transactions/bookings/index.html.erb | 2 +- app/views/transactions/bookings/show.html.erb | 44 ++++- app/views/transactions/sales/show.html.erb | 157 +++++++++++++++++- 13 files changed, 311 insertions(+), 55 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 639a763b..b1718ee2 100755 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -107,4 +107,21 @@ i.logout_icon{ .float_right{ float : right; +} + +.selected-payment { + color: #fff !important; + background-color: blue !important; +} +.payment_btn { + white-space: normal !important; + margin-bottom: 15px; + margin-right: 15px; + color:#fff !important; + # background-color: green !important; +} + +.payment-btn-box { + width: 130px; + height: 50px; } \ No newline at end of file diff --git a/app/assets/stylesheets/origami.scss b/app/assets/stylesheets/origami.scss index 6383ac89..2558d846 100755 --- a/app/assets/stylesheets/origami.scss +++ b/app/assets/stylesheets/origami.scss @@ -653,4 +653,9 @@ nav.pagination .page a:hover, font-size: 14px; color: #FFFFFF; } -/*customer modal UI */ \ No newline at end of file +/*customer modal UI */ + +.payment-btn-box { + width: 130px; + height: 50px; +} \ No newline at end of file diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index 304e0d90..cc363298 100755 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -255,7 +255,14 @@ class Origami::PaymentsController < BaseOrigamiController def show path = request.fullpath sale_id = params[:sale_id] - @cashier_type = params[:type] + @trans_flag = true + if params[:type] == "transaction" + @trans_flag = false + @cashier_type = "cashier" + else + @cashier_type = params[:type] + end + if path.include? ("credit_payment") @sale_payment = SalePayment.get_credit_amount_due_left(sale_id) end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 22c8d25c..6d57904e 100755 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -65,7 +65,7 @@ class Origami::RequestBillsController < ApplicationController ActionCable.server.broadcast "bill_channel",table: table, from: from if order.source == "quick_service" result = {:status=> @status, :data => @sale.sale_id } - render :json => result.to_json + render :json => result.to_json else #check checkInOut pdf print check_booking = Booking.find_by_sale_id(@sale_id) diff --git a/app/controllers/transactions/bookings_controller.rb b/app/controllers/transactions/bookings_controller.rb index 63090c9c..78e8dc1b 100644 --- a/app/controllers/transactions/bookings_controller.rb +++ b/app/controllers/transactions/bookings_controller.rb @@ -35,7 +35,7 @@ class Transactions::BookingsController < ApplicationController def show @booking = Booking.find(params[:id]) - + @order = [] @order_items = [] @booking.booking_orders.each do |booking_order| @order = Order.find(booking_order.order_id) diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index c1e58f6f..32636ccd 100755 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -89,7 +89,8 @@ class Transactions::SalesController < ApplicationController # GET /transactions/sales/1 # GET /transactions/sales/1.json def show - + @membership = MembershipSetting::MembershipSetting + @payment_methods = PaymentMethodSetting.where("is_active='1'") @sale = Sale.find(params[:id]) @order_items = [] diff --git a/app/models/booking.rb b/app/models/booking.rb index 7e5470d0..1648f255 100755 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -46,14 +46,16 @@ class Booking < ApplicationRecord if filter.blank? keyword = '' else - keyword = "booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%" + keyword = "booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}' OR df.name LIKE ?","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%" end if from.present? && to.present? - booking = Booking.where("DATE_FORMAT(created_at,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(created_at,'%d-%m-%Y') <= ? and NOT booking_status = 'void' ", from,to) + booking = Booking.joins(" LEFT JOIN dining_facilities df ON df.id=bookings.dining_facility_id") + .where("DATE_FORMAT(created_at,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(created_at,'%d-%m-%Y') <= ? and NOT booking_status = 'void' ", from,to) query = booking.where(keyword) else - where("booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%") + joins(" LEFT JOIN dining_facilities df ON df.id=bookings.dining_facility_id") + .where("booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}' OR df.name LIKE ?","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%") end end diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index 98e4f6f5..16bfa3c7 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -557,22 +557,26 @@ - diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index c182e5a5..49c45e39 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -678,10 +678,19 @@ var cashier_type = "<%= @cashier_type %>"; var customer_id = "<%= @customer.id %>"; var customer_name = "<%= @customer.name %>"; var pdf_view = '<%=@pdf_view%>'; - console.log(pdf_view) +var trans_flag = <%= @trans_flag %>; + // console.log(pdf_view) $(document).ready(function(){ setHeaderBreadCrumb(_PAYMENTS_); + /* replace url type*/ + if(!trans_flag){ + localStorage.setItem("trans_flag", trans_flag); + var sale_id = $('#sale_id').text(); + window.location.replace('/origami/sale/'+sale_id+'/cashier/payment'); + } + + /* replace url type*/ /* start check first bill or not*/ var member_id = $('#membership_id').text(); var member_discount = $('#member_discount').text(); @@ -727,11 +736,17 @@ var pdf_view = '<%=@pdf_view%>'; localStorage.removeItem('cash'); customer_display_view(null,"reload"); var sale_id = $('#sale_id').text(); - if (cashier_type=="cashier") { - window.location.href = '/origami/table/'+ dining_id; + var flag = localStorage.getItem("trans_flag"); + if(flag != "true"){ + window.location.href = '/transactions/sales/'+sale_id; }else{ - window.location.href = '/origami/quick_service/pending_order/'+sale_id; - } + if (cashier_type=="cashier") { + window.location.href = '/origami/table/'+ dining_id; + }else{ + window.location.href = '/origami/quick_service/pending_order/'+sale_id; + } + } + }); if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){ @@ -1135,12 +1150,17 @@ var pdf_view = '<%=@pdf_view%>'; } if (pdf_view ==1) { - if (cashier_type=="cashier") { - window.location.href = '/origami'; + var flag = localStorage.getItem("trans_flag"); + if(flag != "true"){ + window.location.href = "/transactions/sales/"+sale_id; }else{ - window.location.href = '/origami/quick_service'; - customer_display_view(null,"reload"); - } + if (cashier_type=="cashier") { + window.location.href = '/origami'; + }else{ + window.location.href = '/origami/quick_service'; + customer_display_view(null,"reload"); + } + } }else{ payment_success_alert(); } @@ -1176,11 +1196,18 @@ var pdf_view = '<%=@pdf_view%>'; $(".btn_pdf_close").on('click',function(){ - if (cashier_type=="cashier") { - window.location.href = '/origami'; + var flag = localStorage.getItem("trans_flag"); + if(flag != "true"){ + var sale_id = $('#sale_id').text(); + window.location.href = "/transactions/sales/"+sale_id; }else{ - window.location.href = '/origami/quick_service'; - } + if (cashier_type=="cashier") { + window.location.href = '/origami'; + }else{ + window.location.href = '/origami/quick_service'; + } + } + }); $(".btn_customer_yes").on('click',function(){ diff --git a/app/views/origami/rooms/show.html.erb b/app/views/origami/rooms/show.html.erb index 918758e4..c78a3cd3 100755 --- a/app/views/origami/rooms/show.html.erb +++ b/app/views/origami/rooms/show.html.erb @@ -575,18 +575,26 @@ - diff --git a/app/views/transactions/bookings/index.html.erb b/app/views/transactions/bookings/index.html.erb index 463ab27c..47cc60db 100755 --- a/app/views/transactions/bookings/index.html.erb +++ b/app/views/transactions/bookings/index.html.erb @@ -19,7 +19,7 @@
- +
diff --git a/app/views/transactions/bookings/show.html.erb b/app/views/transactions/bookings/show.html.erb index 67065b1c..a8276c60 100755 --- a/app/views/transactions/bookings/show.html.erb +++ b/app/views/transactions/bookings/show.html.erb @@ -23,6 +23,7 @@ <%= t :sale_details %> +
@@ -39,13 +40,18 @@ <%= t("views.right_panel.detail.checkout_by") %> <%= t("views.right_panel.detail.booking_status") %> <%= t("views.right_panel.detail.booking_date") %> + <%if (@booking.sale_id.nil?) && (current_login_employee.role == "administrator") && (!@order.nil?) %> + + + + <% end %> <%= @booking.booking_id%> - <%= link_to @booking.sale_id, transactions_sale_path(booking.sale_id) rescue '-' %> + <%= link_to @booking.sale_id, transactions_sale_path(@booking.sale_id) rescue '-' %> <%= @booking.dining_facility.name rescue '' %> <%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> <%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") rescue '-' %> @@ -53,6 +59,9 @@ <%= @booking.checkout_by rescue '-' %> <%= @booking.booking_status %> <%= @booking.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %> + <%if (@booking.sale_id.nil?) && (current_login_employee.role == "administrator") && (!@order.nil?) %> + + <% end %> @@ -135,6 +144,37 @@ - + diff --git a/app/views/transactions/sales/show.html.erb b/app/views/transactions/sales/show.html.erb index 44b2f95f..d39873cd 100755 --- a/app/views/transactions/sales/show.html.erb +++ b/app/views/transactions/sales/show.html.erb @@ -41,10 +41,22 @@ <%= t :cashier %> <%= t("views.right_panel.detail.sales_status") %> <%= t("views.right_panel.detail.receipt_generated_at") %> - <% if @sale["sale_status"] == "completed" %> + <% if @sale.sale_status == "completed" %> +
+ + <% @payment_methods.each_with_index do |pay, pay_index| %> + <%if (pay_index+1)%3 == 0 %> +
+ <% end %> +
+ +
+ <%end %> + +
+ + +
+ +
+ + +