Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into payment

This commit is contained in:
Nweni
2017-06-28 15:34:14 +06:30
8 changed files with 73 additions and 21 deletions

View File

@@ -19,10 +19,6 @@ class HomeController < ApplicationController
if @employee != nil
session[:session_token] = @employee.token_session
#if cashier => already opening cahshier?
redirect_to origami_root_path
route_by_role(@employee)
else
render :show, flash[:notice] => "Invalid PIN for Employee. Please try again!"
@@ -41,7 +37,7 @@ class HomeController < ApplicationController
redirect_to dashboard_path
elsif @employee.role == "cashier"
session[:session_token] = @employee.token_session
redirect_to origami_root_path
route_by_role(@employee)
elsif @employee.role == "manager"
session[:session_token] = @employee.token_session
redirect_to dashboard_path
@@ -84,13 +80,13 @@ class HomeController < ApplicationController
redirect_to dashboard_path
elsif employee.role == "cashier"
#check if cashier has existing open cashier
# if !ShiftSale.current_open_shift(employee).nil?
# redirect_to origami_root_path
# else
shift = ShiftSale.current_open_shift(employee)
if !shift.nil?
redirect_to origami_root_path
else
redirect_to new_origami_shift_path
# end
elsif employee.role == "checker"
end
elsif employee.role == "manager"
redirect_to oqs_root_path
elsif employee.role == "waiter"
redirect_to oqs_root_path

View File

@@ -19,9 +19,9 @@ class Origami::HomeController < BaseOrigamiController
@orders = Order.get_orders()
end
def item_show
selection(params[:booking_id],1)
end
# def item_show
# selection(params[:booking_id],1)
# end
def selection(selected_id, is_ajax)
str = []
@@ -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

View File

@@ -1,4 +1,5 @@
class Origami::ShiftsController < ApplicationController
class Origami::ShiftsController < BaseOrigamiController
def index
end
@@ -6,6 +7,13 @@ class Origami::ShiftsController < ApplicationController
end
def new
@float = Lookup.where('lookup_type=?','float')
end
def create
opening_balance = params[:opening_balance]
@shift = ShiftSale.new
@shift.create(opening_balance,current_user)
end
def edit

View File

@@ -263,7 +263,6 @@ class Sale < ApplicationRecord
end
private
def product_get_unit_price(item_code)

View File

@@ -247,6 +247,10 @@ class SalePayment < ApplicationRecord
end
self.sale.sale_status = "completed"
self.sale.save!
shift = ShiftSale.current_open_shift(self.sale.cashier_id)
if shift
shift.update(self.sale)
end
table_update_status(sObj)
rebat(sObj)
end

View File

@@ -0,0 +1 @@
json.status true

View File

@@ -1,2 +1,46 @@
<h1>Origami::Shifts#new</h1>
<p>Find me in app/views/origami/shifts/new.html.erb</p>
<h1>Open Cashier</h1>
<br>
<div class="row">
<div class="col-md-4">
<table class='table table-striped'>
<% @float.each do |float| %>
<tr>
<th><%= float.name %></th>
<th><input class='float-value' type='text' data-value ="<%= float.value %>" value='' /></th>
</tr>
<% end %>
<tr>
<th>Total</th>
<th><div id='total'></div></th>
</tr>
</table>
<div class="row">
<div class='col-md-4'></div>
<div class='col-md-2'>
<button class='btn btn-primary' id='open_cashier'>Open Cashier</button>
</div>
</div>
</div>
</div>
<script>
var total = 0
$(document).on('focusout', '.float-value', function(event){
var input_type = $(this).attr("data-value");
var count = $(this).val();
total += input_type * count
$('#total').text(total)
})
$('#open_cashier').on('click',function(){
var amount = $('#total').text();
$.ajax({type: "POST",
url: "<%= origami_shifts_path %>",
data: "opening_balance=" + amount,
success:function(result){
if(result){
window.location.href = '/origami';
}
}
});
})
</script>

View File

@@ -89,7 +89,7 @@ Rails.application.routes.draw do
get 'room/:room_id' => 'rooms#show'
get 'order/:order_id' => "orders#show"
post '/:booking_id' => 'home#item_show'
# post '/:booking_id' => 'home#item_show'
get "/:id/discount" => "discounts#index"
post "/:id/discount" => "discounts#create"