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

This commit is contained in:
Yan
2017-10-31 13:41:36 +06:30
21 changed files with 319 additions and 167 deletions

View File

@@ -55,7 +55,8 @@ gem 'to_xls-rails'
gem 'jquery-rails'
gem 'jquery-ui-rails'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
gem 'turbolinks'
gem 'jquery-turbolinks', '~> 2.1'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production

View File

@@ -87,6 +87,9 @@ GEM
rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
jquery-turbolinks (2.1.0)
railties (>= 3.1.0)
turbolinks
jquery-ui-rails (6.0.1)
railties (>= 3.2.16)
kaminari (1.0.1)
@@ -263,6 +266,7 @@ DEPENDENCIES
httparty (~> 0.15.5)
jbuilder (~> 2.5)
jquery-rails
jquery-turbolinks (~> 2.1)
jquery-ui-rails
kaminari (~> 1.0.1)
listen (~> 3.0.5)
@@ -287,7 +291,7 @@ DEPENDENCIES
spring-watcher-listen (~> 2.0.0)
tether-rails
to_xls-rails
turbolinks (~> 5)
turbolinks
tzinfo-data
uglifier (>= 1.3.0)
web-console (>= 3.3.0)

View File

@@ -11,8 +11,11 @@
// about supported directives.
//
//= require jquery
//= require jquery_nested_form
//= require jquery_ujs
//= require tether
//= require bootstrap/js/popper.min
//= require bootstrap/js/bootstrap-material-design.min
//= require jquery_nested_form
//= require cable
//= require tether
//= require bootstrap/js/popper.min
@@ -34,6 +37,7 @@
//= require BSBMaterial/demo.js
//= require custom.js
$(document).ready(function() {
$('.count-to').countTo();

View File

@@ -25,6 +25,8 @@ $(document).ready(function() {
var method = $(this).attr('data-method');
var url = $(this).attr('data-ref');
var html_text = $(this).siblings( "#delete_text" ).html();
//var page = url.substring(url.lastIndexOf('/') + 1);
console.log(location.href);
swal({
title: "Confirmation",
text: html_text,

View File

@@ -6,8 +6,6 @@ class BaseOrigamiController < ActionController::Base
protect_from_forgery with: :exception
rescue_from CanCan::AccessDenied do |exception|
flash[:warning] = exception.message
puts "ssssssssssss"
puts flash
redirect_to origami_root_path
end

View File

@@ -104,6 +104,10 @@ class Origami::CustomersController < BaseOrigamiController
order = Order.find(sale_order.order_id)
status = order.update_attributes(customer_id: customer_id,order_type:customer.customer_type)
end
action_by = current_user.id
remark = "Assign Customer Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} | Customer ID ->#{customer.customer_id}- Customer Name ->#{customer.name}"
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"ASSIGNCUSTOMER" )
else
@booking = BookingOrder.find_by_order_id(params[:sale_id])
@orders = BookingOrder.where("booking_id = ? ", @booking.booking_id)

View File

@@ -21,7 +21,7 @@ class Origami::DiscountsController < BaseOrigamiController
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
table_id = sale.bookings[0].dining_facility_id
table_type = DiningFacility.find(table_id).type
table = DiningFacility.find(table_id)
# sale.total_discount = overall_discount.to_f
# sale.total_amount = sub_total.to_f
# sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
@@ -46,14 +46,24 @@ class Origami::DiscountsController < BaseOrigamiController
sale_item.price = di["price"]
sale_item.save
action_by = current_user.id
remark = "Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} "
sale_audit = SaleAudit.record_audit_discount(sale_item.sale_id,sale.cashier_id, action_by,remark,"ITEMDISCOUNT" )
end
end
# Re-calc All Amount in Sale
if overall_discount.to_f > 0
action_by = current_user.id
remark = "Discount Overall Price [#{overall_discount}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"OVERALLDISCOUNT" )
end
sale.compute_by_sale_items(sale_id, sale.sale_items, overall_discount.to_f)
result = {:status=> "Success", :table_id => table_id, :table_type => table_type }
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
else
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table_type }
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
end
@@ -67,13 +77,18 @@ class Origami::DiscountsController < BaseOrigamiController
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
table_id = sale.bookings[0].dining_facility_id
table_type = DiningFacility.find(table_id).type
table = DiningFacility.find(table_id)
if discount_items.length > 0
#destroy sale item for discount
discount_items.each do |di|
sale_item = SaleItem.find(di["id"])
sale.total_amount = (sale.total_amount + sale_item.price.abs)
action_by = current_user.id
remark = "Remove Item Discount Item Name ->#{sale_item.product_name}-Product Code ->#{sale_item.product_code} | Price [#{sale_item.price}] | Receipt No #{sale.receipt_no} | Table- #{table.name} "
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"REMOVEITEMDISCOUNT" )
sale_item.destroy
end
end
@@ -82,9 +97,9 @@ class Origami::DiscountsController < BaseOrigamiController
# sale.save
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
result = {:status=> "Success", :table_id => table_id, :table_type => table_type }
result = {:status=> "Success", :table_id => table_id, :table_type => table.type }
else
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table_type }
result = {:status=> "Please, Check Again!", :table_id => table_id, :table_type => table.type }
end
render :json => result.to_json
@@ -115,6 +130,10 @@ class Origami::DiscountsController < BaseOrigamiController
#destroy in sale.sale_items
sale.sale_items.destroy(discount_items)
action_by = current_user.id
remark = "Remove Discount Sale Id [#{sale.sale_id}]| Receipt No #{sale.receipt_no} | Table- #{table.name} "
sale_audit = SaleAudit.record_audit_discount(sale.sale_id,sale.cashier_id, action_by,remark,"REMOVEALLDISCOUNT" )
# Re-calc All Amount in Sale
sale.compute_by_sale_items(sale_id, sale.sale_items, 0)
result = {:status=> "Success", :table_id => table_id, :table_type => table_type }

View File

@@ -16,7 +16,7 @@ class Origami::OtherChargesController < BaseOrigamiController
if Sale.exists?(sale_id)
sale = Sale.find(sale_id)
table_id = sale.bookings[0].dining_facility_id
table_type = DiningFacility.find(table_id).type
table = DiningFacility.find(table_id)
# sale.total_amount = sub_total.to_f
# sale.grand_total = sub_total.to_f + sale.total_tax;
@@ -41,6 +41,11 @@ class Origami::OtherChargesController < BaseOrigamiController
sale_item.price = di["price"]
sale_item.save
action_by = current_user.id
remark = "Add Other Charges - Receipt No #{sale.receipt_no} | Sale ID #{sale.sale_id} |Charges ->#{di["price"]} For ->#{di["name"]}- Table ->#{table.name}"
sale_audit = SaleAudit.record_audit_for_edit(sale.sale_id,sale.cashier_id, action_by,remark,"ADDOTHERCHARGES" )
end
end
@@ -48,7 +53,7 @@ class Origami::OtherChargesController < BaseOrigamiController
sale.compute_by_sale_items(sale_id, sale.sale_items, sale.total_discount)
end
dining = {:table_id => table_id, :table_type => table_type }
dining = {:table_id => table_id, :table_type => table.type }
render :json => dining.to_json
end
end

View File

@@ -24,6 +24,11 @@ class Origami::SaleEditController < BaseOrigamiController
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
action_by = current_user.id
remark = "Void Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"SALEITEMVOID" )
saleObj.compute_without_void
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
end
@@ -44,6 +49,11 @@ class Origami::SaleEditController < BaseOrigamiController
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
action_by = current_user.id
remark = "FOC Sale Item ID #{saleitemObj.sale_item_id} | Receipt No #{saleObj.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}Receipt No #{saleObj.receipt_no}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"SALEITEMFOC" )
saleObj.compute_without_void
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
end
@@ -73,11 +83,16 @@ class Origami::SaleEditController < BaseOrigamiController
update_qty = params[:update_qty]
update_price = params[:update_price]
saleitemObj = SaleItem.find(saleitemId)
sale = Sale.find(saleitemObj.sale_id)
saleitemObj.qty = update_qty
saleitemObj.price = update_qty.to_f * update_price.to_f
saleitemObj.unit_price = update_price
saleitemObj.taxable_price = update_qty.to_f * update_price.to_f
action_by = current_user.id
remark = "Update Qty #{update_qty} Price [#{saleitemObj.price}]| Receipt No #{sale.receipt_no} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,sale.cashier_id, action_by,remark,"SALEITEMEDIT" )
# saleitemObj.remark = 'edit'
unless saleitemObj.product_name.include? 'updated'
@@ -108,6 +123,11 @@ class Origami::SaleEditController < BaseOrigamiController
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
action_by = current_user.id
remark = "Cancle Void Sale Item ID #{saleitemObj.sale_item_id} | Item Name ->#{saleitemObj.product_name}-Product Code ->#{saleitemObj.product_code}-Instance Code ->#{saleitemObj.item_instance_code}|Receipt No #{saleObj.receipt_no}"
sale_audit = SaleAudit.record_audit_for_edit(saleitemObj.sale_id,saleObj.cashier_id, action_by,remark,"ITEMCANCELVOID" )
saleObj.compute_without_void
ProductCommission.remove_product_commission(saleitemObj)
end

View File

@@ -1,4 +1,4 @@
class Origami::SalesController < ApplicationController#BaseOrigamiController
class Origami::SalesController < BaseOrigamiController
def show
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')

View File

@@ -41,6 +41,12 @@ class Origami::VoidController < BaseOrigamiController
table.save
end
# FOr Sale Audit
action_by = current_user.id
remark = "Void Sale ID #{sale_id} | Receipt No #{sale.receipt_no} | Receipt No #{sale.receipt_no} | Table ->#{table.name}"
sale_audit = SaleAudit.record_audit_for_edit(sale_id,sale.cashier_id, action_by,remark,"SALEVOID" )
# update complete order items in oqs
SaleOrder.where("sale_id = '#{ sale_id }'").find_each do |sodr|
AssignedOrderItem.where("order_id = '#{ sodr.order_id }'").find_each do |aoi|

View File

@@ -38,6 +38,7 @@ class ProductCommission < ApplicationRecord
commission = Commission.where('product_code = ? AND is_active = ?', menu_item.id, true).take
product_commission = ProductCommission.where('sale_item_id = ?', saleItemObj.id).take
if !product_commission.nil?
return if commission.nil?
product_commission.qty = saleItemObj.qty
if commission.commission_type == 'Percentage'
@@ -48,6 +49,7 @@ class ProductCommission < ApplicationRecord
product_commission.amount = product_commission.price * saleItemObj.qty
end
product_commission.save
end
puts 'Edit Product Commission Success'
end

View File

@@ -30,11 +30,11 @@ class SaleAudit < ApplicationRecord
sale_audit.save!
end
def record_audit_discount(sale_id, discount_by, approved_by, reason)
def self.record_audit_discount(sale_id, discount_by, approved_by, reason,type)
#sale_audit
sale_audit = SaleAudit.new()
sale_audit.sale_id = sale_id
sale_audit.action = "SALEDISCOUNT"
sale_audit.action = type
sale_audit.action_at = DateTime.now.utc
sale_audit.action_by = discount_by
sale_audit.approved_by = approved_by
@@ -43,7 +43,7 @@ class SaleAudit < ApplicationRecord
#sale_audit.
end
def record_audit_foc(sale_id, cashier_id, approved_by, reason)
def self.record_audit_foc(sale_id, cashier_id, approved_by, reason)
#sale_audit
sale_audit = SaleAudit.new()
sale_audit.sale_id = sale_id
@@ -55,6 +55,18 @@ class SaleAudit < ApplicationRecord
sale_audit.save!
end
def self.record_audit_for_edit(sale_id, cashier_id, approved_by, reason,type)
#sale_audit
sale_audit = SaleAudit.new()
sale_audit.sale_id = sale_id
sale_audit.action = type
sale_audit.action_at = DateTime.now.utc
sale_audit.action_by = cashier_id
sale_audit.approved_by = approved_by
sale_audit.remark = reason
sale_audit.save!
end
def self.record_payment(sale_id, remark, action_by)
sale_audit = SaleAudit.new()
sale_audit.sale_id = sale_id

View File

@@ -36,9 +36,9 @@
<!-- <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous"></script> -->
<%= javascript_include_tag 'login', 'data-turbolinks-track': 'reload' %>
</head>
</head>
<body class="login-page">
<body class="login-page">
<!-- Page Loader -->
<div class="page-loader-wrapper">
<div class="loader">
@@ -56,7 +56,22 @@
</div>
</div>
<!-- #END# Page Loader -->
<% flash.each do |type, message| %>
<%
if type == "notice"
color = "alert-success"
elsif type == "error"
color = "alert-danger"
elsif type == "warning"
color = "alert-warning"
else
color = "bg-black"
end %>
<p id="noti" class="hidden noti" data-placement-from="top" data-message="<%=message%>" data-placement-align="center"
data-animate-enter="" data-animate-exit="" data-color-name="<%=color%>" >
</p>
<% end %>
<div class="login-box">
<div class="logo text-center">
<img src="/image/SX-logo.png" width="150px" height="150px">
@@ -73,6 +88,7 @@
<%= f.input :password, label: "Access PIN", required: false, class: "form-control" %>
</div>
</div>
<div class="card-content">
<div class='col-md-12'>
<div class='row bottom'>
@@ -116,9 +132,42 @@
$("#login_form_password").val(old_value + value);
}
});
});
</script>
function showNotification(colorName, text, placementFrom, placementAlign, animateEnter, animateExit) {
if (colorName === null || colorName === '') { colorName = 'bg-black'; }
if (animateEnter === null || animateEnter === '') { animateEnter = 'animated fadeInDown'; }
if (animateExit === null || animateExit === '') { animateExit = 'animated fadeOutUp'; }
var allowDismiss = true;
$.notify({
message: text
},
{
type: colorName,
allow_dismiss: allowDismiss,
newest_on_top: true,
timer: 1000,
placement: {
from: placementFrom,
align: placementAlign
},
animate: {
enter: animateEnter,
exit: animateExit
},
template: '<div data-notify="container" class="bootstrap-notify-container alert alert-dismissible {0} ' + (allowDismiss ? "p-r-30" : "") + '" role="alert">' +
'<button type="button" aria-hidden="true" class="close float-right m-l-20 m-t--5" data-notify="dismiss">×</button>' +
'<span data-notify="icon"></span> ' +
'<span data-notify="title">{1}</span> ' +
'<span data-notify="message">{2}</span>' +
'<div class="progress" data-notify="progressbar">' +
'<div class="progress-bar progress-bar-{0}" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;"></div>' +
'</div>' +
'<a href="{3}" target="{4}" data-notify="url"></a>' +
'</div>'
});
}
//end Notificaiotn message
</script>
</body>
</html>

View File

@@ -54,6 +54,7 @@
data-animate-enter="" data-animate-exit="" data-color-name="<%=color%>" >
</p>
<% end %>
<!-- #END# Page Loader -->
<div class="container">
<div class="row">
@@ -158,7 +159,7 @@
$(document).ready(function () {
// for Notificaiotn message
console.log("hi");
var placementFrom = $("#noti").attr('data-placement-from');
var placementAlign = $("#noti").attr('data-placement-align');
var animateEnter = $("#noti").attr('data-animate-enter');

View File

@@ -22,10 +22,10 @@
<td> <%= t :payment_method %>
</td>
<td>
<button class='btn bg-blue waves-effect payment-type' data-id='cash' id='cash'><%= t("views.btn.cash") %></button>
<button class='btn bg-blue waves-effect payment-type' data-id='mpu' id='mpu'><%= t("views.btn.mpu") %></button>
<button class='btn bg-blue waves-effect payment-type' data-id='visa' id='visa'><%= t("views.btn.visa") %></button>
<button class='btn bg-blue waves-effect payment-type' data-id='jcb' id='jcb'><%= t("views.btn.jcb") %></button>
<button class='btn bg- waves-effect payment-type' data-id='cash' id='cash' style="background-color: #7a62d3;"><%= t("views.btn.cash") %></button>
<button class='btn bg- waves-effect payment-type' data-id='mpu' id='mpu' style="background-color: #7a62d3;"><%= t("views.btn.mpu") %></button>
<button class='btn bg- waves-effect payment-type' data-id='visa' id='visa' style="background-color: #7a62d3;"><%= t("views.btn.visa") %></button>
<button class='btn bg- waves-effect payment-type' data-id='jcb' id='jcb' style="background-color: #7a62d3;"><%= t("views.btn.jcb") %></button>
</td>
</tr>
<tr>

View File

@@ -110,6 +110,7 @@
<div class="form-group">
<input type="text" id="discount-amount" name="discount-amount" value="<%= @sale_data.total_discount rescue 0 %>" class="form-control" />
</div>
<br>
<div class="form-group">
<%
@accounts.each do |acc|
@@ -122,7 +123,7 @@
</div>
<hr />
<div class="p-l-20">
<div class="row">
<div class="col-md-9">
<div class="row bottom">
@@ -202,6 +203,7 @@
</div>
</div>
</div>
</div>
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">

View File

@@ -6,7 +6,7 @@
<!-- Nav tabs -->
<ul class="nav nav-tabs tab-col-teal" role="tablist">
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#Completed" role="tab"><%= t :competed %></a>
<a class="nav-link" data-toggle="tab" href="#complete" role="tab"><%= t :competed %></a>
</li>
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#tables" role="tab"><%= t :tables %></a>
@@ -22,7 +22,7 @@
<div class="tab-content m-t-10" id="custom-slimscroll">
<!--- Panel 0 - Completed Orders -->
<div class="tab-pane dining" id="Completed " role="tabpanel">
<div class="tab-pane dining" id="complete" role="tabpanel">
<div class="card-columns">
<% @complete.each do |sale| %>
<div class="card sales red text-white" data-id = "<%= sale.sale_id %>">

View File

@@ -109,6 +109,7 @@
<div class="row">
<div class="col-xs-9 col-sm-9 col-md-9 col-lg-9">
<div class="p-l-20">
<div class="row bottom">
<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
<div class="fluid cashier_number" data-value="3000" data-type="add">3000</div>
@@ -172,6 +173,7 @@
<div class="col-md-3 left cashier_number green" data-type="clr">CLR</div>
</div>
</div>
</div>
</div>
</div>

View File

@@ -50,7 +50,7 @@
</div>
</div>
<% else %>
<div class="card tables bg-green text-white" data-id="<%= table.id %>">
<div class="card tables green text-white" data-id="<%= table.id %>">
<div class="card-block">
<%= table.name %>
</div>
@@ -76,7 +76,7 @@
</div>
</div>
<% else %>
<div class="card rooms bg-green text-white" data-id="<%= room.id %>">
<div class="card rooms green text-white" data-id="<%= room.id %>">
<div class="card-block">
<%= room.name %>
</div>
@@ -231,20 +231,43 @@ $('#back').on('click',function(){
window.location.href = '/origami/';
})
$('#void').on('click',function () {
var sure = confirm("Are you sure want to Void");
if (sure == true) {
// $('#void').on('click',function () {
// var sure = confirm("Are you sure want to Void");
// if (sure == true) {
// // var sale_id = $('#sale_id').val();
// // var ajax_url = "/origami/sale/" + sale_id + '/void';
// // $.ajax({
// // type: 'POST',
// // url: ajax_url,
// // success: function () {
// // window.location.href = '/origami/';
// // }
// // });
// }
// });
$('#void').on('click', function () {
swal({
title: "Alert",
text: "Are you sure want to Void?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, void it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
var sale_id = $('#sale_id').val();
var ajax_url = "/origami/sale/" + sale_id + '/void';
$.ajax({
type: 'POST',
url: ajax_url,
success: function () {
window.location.href = '/origami/';
window.location.href = '/origami/sale/'+sale_id;
}
});
}
});
});
$('#re-print').click(function() {
var sale_id = $('#sale_id').val();

View File

@@ -10,7 +10,7 @@
<%= f.collection_select :product_code, MenuItem.all.order('name asc'), :id, :name, {prompt: 'Select a Product'}, {class: 'form-control'} %><br/>
<%= f.input :commission_type, :collection => ['Percentage','Net Amount'], prompt: 'Select Commission Type', class: 'form-control' %>
<%= f.input :amount %>
<%= f.input :is_active %> Active
<%= f.input :is_active,:class => "filled-in" ,:id => "" %>
</div><br>
<div class="form-actions">
@@ -43,5 +43,3 @@
</div>
</div>
</div>