diff --git a/app/controllers/origami/card_payments_controller.rb b/app/controllers/origami/card_payments_controller.rb deleted file mode 100644 index 2df4b266..00000000 --- a/app/controllers/origami/card_payments_controller.rb +++ /dev/null @@ -1,10 +0,0 @@ -class Origami::CardPaymentsController < BaseOrigamiController - - - def index - end - - def create - end - -end diff --git a/app/controllers/origami/others_payments_controller.rb b/app/controllers/origami/others_payments_controller.rb new file mode 100644 index 00000000..e92c9535 --- /dev/null +++ b/app/controllers/origami/others_payments_controller.rb @@ -0,0 +1,10 @@ +class Origami::OthersPaymentsController < BaseOrigamiController + + + def index + end + + def create + end + +end diff --git a/app/controllers/origami/payments_controller.rb b/app/controllers/origami/payments_controller.rb index f64e27e3..45b03c79 100644 --- a/app/controllers/origami/payments_controller.rb +++ b/app/controllers/origami/payments_controller.rb @@ -5,13 +5,17 @@ class Origami::PaymentsController < BaseOrigamiController end def create - #payment type - #sale status - #point - get [ food amount ] + cash = params[:cash] + card = params[:card] + + #process_payment(invoice, action_by) end def show - + sale_id = params[:sale_id] + if Sale.exists?(sale_id) + @sale_data = Sale.find_by_sale_id(sale_id) + end end end diff --git a/app/controllers/origami/request_bills_controller.rb b/app/controllers/origami/request_bills_controller.rb index 31766599..9e14e9ea 100644 --- a/app/controllers/origami/request_bills_controller.rb +++ b/app/controllers/origami/request_bills_controller.rb @@ -25,13 +25,5 @@ class Origami::RequestBillsController < BaseOrigamiController printer.print_receipt_bill(print_settings,@sale_items,@sale,@sale_data) end - - - def show - sale_id = params[:sale_id] - if Sale.exists?(sale_id) - @sale_data = Sale.find_by_sale_id(sale_id) - end - end - + end diff --git a/app/views/origami/card_payments/index.html.erb b/app/views/origami/others_payments/index.html.erb similarity index 100% rename from app/views/origami/card_payments/index.html.erb rename to app/views/origami/others_payments/index.html.erb diff --git a/app/views/origami/request_bills/show.html.erb b/app/views/origami/payments/show.html.erb similarity index 92% rename from app/views/origami/request_bills/show.html.erb rename to app/views/origami/payments/show.html.erb index 6de89ab8..e35696d2 100644 --- a/app/views/origami/request_bills/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -87,7 +87,7 @@
-
CARD
+
OTHERS PAYMENT
0.0

@@ -150,8 +150,8 @@
-
DEL
-
CLR
+
DEL
+
CLR
@@ -191,6 +191,10 @@ $(document).on('click', '.cashier_number', function(event){ update_balance(); break; + case 'clr': + $('#cash').text("0.0"); + update_balance(); + break; } event.handled = true; } else { @@ -207,16 +211,28 @@ $( document ).ready(function() { $('#card_payment').click(function() { var sale_id = $('#sale_id').text(); - window.location.href = '/origami/sale/'+ sale_id + "/payment/card_payment" + window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment" return false; }); $('#pay').click(function() { - console.log("pay") - if($('#amount_due').text() > 0){ - console.log("greater") + + if($('#balance').text() > 0){ + alert(" Insufficient Amount!") }else{ - console.log("less") + // payment + var cash = $('#cash').text(); + var credit = $('#credit').text(); + var card = $('#card').text(); + + $.ajax({type: "POST", + url: "<%= origami_payment_process_path %>", + data: "cash="+ cash, + success:function(result){ + alert("THANK YOU") + } + }); + } }); diff --git a/config/routes.rb b/config/routes.rb index 64b5feeb..558e2c2d 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -68,14 +68,16 @@ Rails.application.routes.draw do namespace :origami do root "home#index" get "/:booking_id" => "home#show" do #origami/:booking_id will show - resources :payments, only: [:index, :new, :create ] #add payment by payment_method resources :discounts, only: [:index,:new, :create ] #add discount type resources :customers, only: [:index,:new, :create ] #add customer type end - # resources :request_bills, only: [:show] - get 'sale/:sale_id/payment' => 'request_bills#show' + + get 'sale/:sale_id/payment' => 'payments#show' + post 'payment_process' => 'payments#create' + get 'sale/:sale_id/payment/credit_payment' => "credit_payments#index" - get 'sale/:sale_id/payment/card_payment' => "card_payments#index" + get 'sale/:sale_id/payment/others_payment' => "others_payments#index" + end #--------- Waiter/Ordering Station ------------#