pull origin master

This commit is contained in:
Yan
2017-09-18 13:53:28 +06:30
parent 4f3b831771
commit 8966f290b5
122 changed files with 3964 additions and 2277 deletions

2
.gitignore vendored
View File

@@ -51,7 +51,7 @@ config/deploy/config/*
/dump.rdb
# Fonts
public/fonts/*
# public/fonts/*
# Ruby-Mine IDE folder
/.idea

849
.idea/workspace.xml generated

File diff suppressed because it is too large Load Diff

View File

@@ -18,23 +18,23 @@
//= require cable
$(document).ready(function(){
// auto refresh every 10 seconds
// setTimeout(function(){
// window.location.reload(1);
// }, 10000);
$(".nav-completed").on("click", function(){
$("#completed").removeClass('hide')
$(".oqs_append").addClass('hide')
});
$(".oqs_click").on("click", function(){
$("#completed").addClass('hide')
$(".oqs_append").removeClass('hide')
$(".oqs_click").removeClass('oqs_active');
$(".queue_station").removeClass('queue_station_box');
$("#completed").addClass('hide');
$(".oqs_append").removeClass('hide');
$(this).addClass('oqs_active');
$(".queue_station").addClass('queue_station_box');
var oqs_id = $(this).find(".oqs-id").text();
var url = 'oqs/get_items/'+oqs_id;
show_details(url);
show_details(url);
}); //End Click
@@ -52,7 +52,7 @@ $(document).ready(function(){
for(var field in data) {
var price = parseFloat(data[field].price).toFixed(2);
if (data[field]["options"] == "[]") {
if (data[field]["options"] == "[]" || data[field]["options"] == "") {
var options = "";
}else{
var options = data.options;
@@ -61,7 +61,7 @@ $(document).ready(function(){
var date = new Date(data[field]["created_at"]);
var show_date = date.getDate() + "-" + date.getMonth() + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes();
row ='<div class="card queue_station">'
row ='<div class="card queue_station" data-date="'+data[field]["order_id"]+'">'
+'<div class="card-block">'
+'<h4 class="card-title">'
+'<span class="order-zone-type">'+data[field]["table_type"]+'- </span>'

View File

@@ -8,18 +8,6 @@ $(function(){
});
//End menu category Click
$(".change_qty").change(function(){
qty = $(this).val();
price = $("#unit_price").text();
$("#total_price").text(qty*price);
});
$("#set_change_qty").change(function(){
qty = $(this).val();
price = $("#set_total_price").text();
$("#set_total_price").text(qty*price);
});
//show menu item list when click menu category
function show_menu_item_list(url_item){
var menu_list = $('.menu_items_list');
@@ -34,7 +22,6 @@ $(function(){
var menu_items_list = $('.menu_items_list');
menu_items_list.empty();
menu_items = data.menu_items;
for(var field in menu_items) {
if (menu_items[field].is_sub_item == false) {
instances = menu_items[field].instances ;
@@ -64,6 +51,12 @@ $(function(){
data_target = 'sx_item_detailModal'
}
if (menu_items[field].image) {
image_path = menu_items[field].image;
}else{
image_path = "/image/logo.png";
}
row = '<div class="card custom-card">'
+'<div class="custom-card-head card-head" style="line-height:14px;">'
+'<small class="col-md-9">'+ menu_items[field].name +'</small>'
@@ -73,7 +66,7 @@ $(function(){
+ price +"' data-instance-code = '"+ code +"' data-instance = '"
+ name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '"
+ JSON.stringify(item_attributes) +"' data-options = '"
+ options +"'>"
+ options +"' data-image='"+image_path+"'>"
+"<i class='fa "+fa_plus+" '"
+ 'style="margin-top:4px;">'
+'</i></div>'
@@ -88,7 +81,7 @@ $(function(){
+JSON.stringify(menu_items[field].item_sets)+"' data-toggle='modal' data-target='."+data_target+"'>"
+"<div class='card-block custom-card-block'>"
+"<img id='logo' src='/image/logo.png'>"
+"<img id='logo' src='"+image_path+"'>"
+"</div>"
@@ -105,10 +98,10 @@ $(function(){
}
//end show list function
//click item row for item set
$(document).on('click', '.set_item_box', function(event){
$(".instance-list").empty();
$(".options-list").empty();
$(document).on('click', '.set_item_box', function(event){
$(".instance-list").empty();
$(".options-list").empty();
change_qty_plus_minus("set_count","set_plus","set_minus");
data = $(this).parent().children().children('.add_icon');
instances = $(this).data('instance');
@@ -153,8 +146,10 @@ $(function(){
$('#set_item_instances').text(instances);
$('#set_name').text(data.attr('data-name'));
$('#set_item_code').text(data.attr('data-item-code'));
$('#set_total_price').text(data.attr('data-price'));
// $('#set_total_price').text(data.attr('data-price'));
$('#set_total_price').text(0);
$('#set_unit_price').text(data.attr('data-price'));
// $('#set_unit_price').text(0);
});
// click instance for add item set
$(document).on('click', '.instance_box', function(event){
@@ -180,7 +175,8 @@ $(function(){
sub_total = $('#set_total_price').text();
name = $(this).data('name');
price = $(this).data('price');
qty = $('#set_change_qty').val();
// qty = $('#set_change_qty').val();
qty = document.getElementById("set_count").value;
total = qty*price;
var total_price = +sub_total - +total;
$(this).removeClass('selected-instance');
@@ -188,21 +184,24 @@ $(function(){
$(this).removeAttr('data-options');
$('#instance_option').text('')
}else {
sub_total = $('#set_total_price').text();
name = $(this).data('name');
price = $(this).data('price');
qty = $('#set_change_qty').val();
// qty = $('#set_change_qty').val();
qty = document.getElementById("set_count").value;
total = qty*price;
var total_price = +sub_total + +total;
$(this).addClass('selected-instance');
}
$('#set_unit_price').text(price);
$('#set_total_price').text(total_price);
}); //End selecct attribute buttom
// click add order
$(document).on('click', '.set_order', function(event){
total_price = $('#set_total_price').text();
qty = parseInt($('#set_change_qty').val());
qty = parseInt($('#set_count').val());
item_code = $('#set_item_code').text();
item_name = $('#set_name').text();
@@ -242,6 +241,7 @@ $(function(){
$(document).on('click', '.menu_item_box', function(event){
$('.attributes-list').empty();
$('.options-list').empty();
$('#modal_box_img').empty();
$('.attr-alert').addClass('hide');
$('.add_to_order').removeAttr('data-instance-code');
$('.add_to_order').removeAttr('data-instance');
@@ -253,30 +253,66 @@ $(function(){
$('.add_to_order').removeAttr('data-attributes');
$('.add_to_order').removeAttr('data-options');
change_qty_plus_minus("count","plus","minus");
data = $(this).parent().children().children('.add_icon');
$('#total_price').text(data.attr('data-price'));
attributes = $(this).data('id');
selected_item = $(this).data('item');
instances = $(this).data('instance');
item_options = $(this).data('option');
if (data.attr('data-image')) {
image = "<img id='' src='"+data.attr('data-image')+"'>";
}else{
image = "<img id='' src='/image/logo.png'>";
}
$('#modal_box_img').append(image);
instance_attributes = []
for(var field in instances) {
value = instances[field].values;
$(value).each(function(i){
options = value[i];
instance_attributes.push(options);
options = value[i];
instance_attributes.push(options);
// $.ajax({
// type: "GET",
// url: '../../api/restaurant/menu_item_attributes/'+value[i],
// data: {id:value[i]},
// success:function(result){
// options = result["name"];
// instance_attributes.push(options);
// }
// });
});
}
// selected_arr = []
// $(selected_item).each(function(i){
// $.ajax({
// type: "GET",
// url: '../../api/restaurant/menu_item_attributes/'+selected_item[i],
// data: {id:selected_item[i]},
// success:function(result){
// name = result["name"];
// selected_arr.push(name);
// }
// });
// });
for(var field in attributes) {
value = attributes[field]["values"];
type = attributes[field]["type"]
row = "<h4>"+attributes[field]["type"]+"</h4>"
row = "<h4>"+attributes[field]["type"]+"</h4>";
$(value).each(function(i){
disabled = ""
status ="";
if(parseInt(jQuery.inArray(value[i], selected_item))!== -1){
if(parseInt(jQuery.inArray(value[i], selected_item)) !== -1){
status = "selected-attribute";
}
if(parseInt(jQuery.inArray(value[i], instance_attributes)) == -1){
@@ -302,16 +338,21 @@ $(function(){
$(".options-list").append(row);
}
$('#change_qty').val(1);
$('#count').val(1);
$('#item_instances').text(instances);
$('#title_name').text(data.attr('data-name'));
$('#item_code').text(data.attr('data-item-code'));
$('#instance_name').text(data.attr('data-instance'));
$('#instance_code').text(data.attr('data-instance-code'));
$('#promotion_price').text(data.attr('data-promotion-price'));
$('#total_price').text(data.attr('data-price'));
$('#unit_price').text(data.attr('data-price'));
});
// click select option icon for add
$(document).on('click', '.attribute_btn', function(event){
$('.change_qty').val(1);
value = $(this).data('value');
type = $(this).data('type');
instances = $(this).data('instances');
@@ -331,7 +372,7 @@ $(function(){
var selected_attr = get_selected_attributes('selected-attribute');
qty = $('#change_qty').val();
qty = $('.change_qty').val();
for(var field in instances) {
item_attr = instances[field].values;
@@ -381,23 +422,30 @@ $(function(){
// click add order
$(document).on('click', '.add_to_order', function(event){
total_price = $('#total_price').text();
qty = parseInt($('#change_qty').val());
qty = parseInt($('#count').val());
var item_row = $('.selected-attribute');
var instances = jQuery.parseJSON(item_row.attr('data-instances'));
attribute_arr = get_selected_attributes('selected-attribute');
option_arr = get_selected_attributes('selected-option');
for(var field in instances) {
if (JSON.stringify(attribute_arr) === JSON.stringify(instances[field].values)) {
$('.add_to_order').attr('data-instance-code',instances[field].code);
$('.add_to_order').attr('data-instance',instances[field].name);
$('.add_to_order').attr('data-price',instances[field].price);
$('.add_to_order').attr('data-promotion-price',instances[field].promotion_price);
if (item_row.length>0) {
var instances = jQuery.parseJSON(item_row.attr('data-instances'));
for(var field in instances) {
if (JSON.stringify(attribute_arr) === JSON.stringify(instances[field].values)) {
$('.add_to_order').attr('data-instance-code',instances[field].code);
$('.add_to_order').attr('data-instance',instances[field].name);
$('.add_to_order').attr('data-price',instances[field].price);
$('.add_to_order').attr('data-promotion-price',instances[field].promotion_price);
}
}
}else{
$('.add_to_order').attr('data-instance-code',$('#instance_code').text());
$('.add_to_order').attr('data-instance',$('#instance_name').text());
$('.add_to_order').attr('data-price',$('#unit_price').text());
$('.add_to_order').attr('data-promotion-price',$('#promotion_price').text());
}
$('.add_to_order').attr('data-item-code',$('#item_code').text());
$('.add_to_order').attr('data-qty',qty);
$('.add_to_order').attr('data-name',$('#title_name').text());
@@ -417,7 +465,7 @@ $(function(){
}); //End Add Icon Click
function show_item_detail(data){
console.log(data)
qty = parseInt(data.attr('data-qty'));
append = 0;
price = parseFloat(data.attr('data-price')).toFixed(2);
@@ -599,7 +647,7 @@ $(function(){
var item_row = $('.summary-items tbody tr');
$(item_row).each(function(i){
var order_item = {};
console.log($(item_row[i]).attr('data-options'));
order_item.order_item_id = $(item_row[i]).attr('data-row');
order_item.item_instance_code = $(item_row[i]).attr('data-instance-code');
order_item.quantity = $(item_row[i]).children('#item_qty').text();
@@ -620,4 +668,88 @@ $(function(){
return attribute_arr;
}
//click menu sidebar menu category
$("#back").on("click", function(){
var table_id = $('#table_id').text();
var table_type = $('#table_type').text();
if(table_type == "Table"){
window.location.href = "/origami/table/" + table_id
}else {
window.location.href = "/origami/room/" + table_id
}
});
// Get Selected Class
function change_qty_plus_minus(id,plus,minus) {
var count = 1;
var countEl = document.getElementById(id);
$('#'+plus).on("click", function(){
count++;
countEl.value = count;
if (id == "count") {
price = $("#unit_price").text();
$("#total_price").text(count*price);
}else{
var item_row = $('.selected-instance');
price = $("#set_unit_price").text();
set_total_price = $("#set_total_price").text();
if (item_row.length > 1) {
total = 0 ;
$(item_row).each(function(i){
total += count * $(item_row[i]).attr('data-price');
total_price = total;
});
}else{
total_price = count*price;
}
$("#set_total_price").text(total_price);
}
});
$('#'+minus).on("click", function(){
if (count > 1) {
count--;
countEl.value = count;
if (id=="count") {
price = $("#unit_price").text();
$("#total_price").text(count*price);
}else{
var item_row = $('.selected-instance');
price = $("#set_unit_price").text();
set_total_price = $("#set_total_price").text();
if (item_row.length > 1) {
total = 0 ;
$(item_row).each(function(i){
total += count * $(item_row[i]).attr('data-price');
total_price = total;
});
}else{
total_price = count*price;
}
$("#set_total_price").text(total_price);
}
}
})
}
// $("#set_change_qty").change(function(){
// qty = $(this).val();
// price = $("#set_total_price").text();
// $("#set_total_price").text(qty*price);
// });
// $(".change_qty").change(function(){
// qty = $(this).val();
// price = $("#unit_price").text();
// $("#total_price").text(qty*price);
// });
});

View File

@@ -1,14 +1,14 @@
// Action Cable provides the framework to deal with WebSockets in Rails.
// You can generate new channels where WebSocket features live using the `rails generate channel` command.
//
//= require action_cable
//= require_self
//= require_tree ./channels
// Temp Disable
// (function() {
// this.App || (this.App = {});
(function() {
this.App || (this.App = {});
// App.cable = ActionCable.createConsumer();
App.cable = ActionCable.createConsumer();
// }).call(this);
}).call(this);

View File

@@ -0,0 +1,14 @@
App.order = App.cable.subscriptions.create('BillChannel', {
// App.messages = App.cable.subscriptions.create('MessagesChannel', {
connected: function() {},
disconnected: function() {},
received: function(data) {
$('.table_'+data.table.id).removeClass('blue');
$('.table_'+data.table.id).addClass('red');
$('.new_text_'+data.table.id).removeClass('hide')
}
});

View File

@@ -0,0 +1,14 @@
App.order = App.cable.subscriptions.create('OrderChannel', {
// App.messages = App.cable.subscriptions.create('MessagesChannel', {
connected: function() {},
disconnected: function() {},
received: function(data) {
$('.table_'+data.table.id).removeClass('green');
$('.table_'+data.table.id).addClass('blue');
$('.new_text_'+data.table.id).removeClass('hide')
}
});

View File

@@ -1,24 +1,83 @@
// App.order_queue_station = App.cable.subscriptions.create("OrderQueueStationChannel", {
// connected: function() {},
App.order_queue_station = App.cable.subscriptions.create('OrderQueueStationChannel', {
// App.messages = App.cable.subscriptions.create('MessagesChannel', {
// disconnected: function() {},
connected: function() {},
// received: function(message) {
// alert(message);
// },
disconnected: function() {},
// order: function(message) {
// return this.perform('order', {
// message: message
// });
// }
// });
received: function(data) {
// console.log(data.order);
var oqs_id = $('.oqs_active').attr('data-id');
items = data.order;
for(var field in items) {
var price = parseFloat(items[field].price).toFixed(2);
if (items[field]["options"] == "[]" || items[field]["options"] == "") {
var options = "";
}else{
var options = items.options;
}
//for count
test = document.getElementsByClassName("oqs_count");
for (var i = 0; i < test.length; i++) {
oqs_count_id = $(".oqs_count"+i).attr("data-id");
oqs_count = $(".oqs_count"+i).text();
if ( oqs_count_id == items[field]["order_queue_station_id"]) {
oqs_count_total = +oqs_count +1 ;
$(".oqs_count"+i).text(oqs_count_total)
}
}
//end count
var date = new Date(items[field]["created_at"]);
var show_date = date.getDate() + "-" + date.getMonth() + "-" + date.getFullYear() + ' ' + date.getHours()+ ':' + date.getMinutes();
if (oqs_id == items[field]["order_queue_station_id"]) {
row ='<div class="card queue_station queue_station_box" data-date="'+items[field]["order_id"]+'">'
+'<strong class="hidden">'+items[field]["order_id"]+'</strong>'
+'<div class="card-block">'
+'<h4 class="card-title">'
+'<span class="order-zone-type">'+items[field]["table_type"]+'- </span>'
+'<span class="order-zone">'+ items[field]["zone"] +'</span>'
+'<small class="pull-right">'+ items[field]["order_id"] +'- </small>'
+'</h4>'
+'<h4>'
+'<span class="order-item">'+ items[field]["item_name"] +'- </span>'
+'<span class="order-qty">'+ items[field]["qty"] +'- </span>'
+'</h4>'
+'<p class="card-text item-options">'+ options +'</p>'
+'<p class="card-text">'
+'<small class="text-muted">Order at'
+'<span class="order-at">'+ show_date +'</span> - '
+'<span class="order-by">'+ items[field]["item_order_by"] +'</span> '
+'</small> '
+'</p>'
+'<p class="hidden order-customer">'+ items[field]["customer_name"] +'</p> '
+'<p class="hidden assigned-order-item">'+ items[field]["assigned_order_item_id"] +'</p> '
+'</div>'
+'<div class="card-footer">'
+'<button id="edit_'+ items[field]["assigned_order_item_id"]+'" class="btn btn-warning order-item order-item-edit">EDIT</button>'
+' <button id="assigned_queue_' + items[field]["assigned_order_item_id"] +'" class="btn btn-primary order-item order-complete">COMPLETE</button>'
+'</div>'
+'</div>';
$('.oqs_append').append(row);
}
}//end looping
var $divs = $("div.queue_station");
var SortListDivs = $divs.sort(function (a, b) {
first = $(a).attr('data-date');
next = $(b).attr('data-date');
return parseInt(next.substring(4, 16)) - parseInt(first.substring(4, 16));
});
$("#oqs_container").html(SortListDivs);
},
});
// $(function(){
// $("#submit_order").on('click', function(event) {
// var orderData=$("#new_order").serializeObject();
// App.order_station.order(orderData);
// //orderData='';
// return event.preventDefault();
// });
// });

View File

@@ -25,3 +25,5 @@
font-size: 18px;
margin: 0px 0px 5px 0px;
}

View File

@@ -109,9 +109,9 @@ element.style {
}
#logo{
margin: auto;
width: 50%;
width: 100%;
border: 1px solid #54A5AF;
padding: 10px;
padding: 0px;
}
#instance_img{

View File

@@ -1,3 +1,272 @@
// Place all the styles related to the inventory_definitions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
@import "bootstrap";
@import "font-awesome";
@import "theme";
@import "jquery-ui";
@import "bootstrap-datepicker3";
@import "select2";
@import "jquery.datetimepicker";
/* Show it is fixed to the top */
// body {
// min-height: 75rem;
// padding-top: 4.5rem;
// }
.card-columns {
font-size: 18px !important;
}
.others-payment{
line-height:100px;
text-align:center;
color:white;
width:300px;
height:100px;
font-size:18px;
}
.orders-table {
cursor: pointer;
}
.cashier_number{
width: 33%;
height:70px;
line-height:70px;
text-align:center;
background:#54A5AF;
// float:left;
// margin:2px;
font-size:20px;
color:white;
// cursor:pointer;
}
.del_cashier_number{
opacity:0.6,
}
.pay{
width: 98%;
height:211px;
line-height:211px;
text-align:center;
font-size:20px;
color:white;
}
.payment{
height:70px;line-height:70px;
align:center;
color:white;
font-size:16px;
margin-top:5px;
}
.cash-color{
background-color:#80CBC4;
}
.credit-color{
background-color:#FFCCBC;
}
.other-payment-color{
background-color:#E1BEE7;
}
.cashier_number:hover{
background:#A9F5F2;
}
.action-btn {
white-space: normal !important;
height: 60px;
margin-bottom: 5px;
}
.bottom-5 {
margin-bottom: 5px;
}
.fluid {
width: 100%;
}
.style2 {
border-top: 3px double #8c8b8b;
}
.long{
width:49%;
}
.sold {
background-color: red;
}
.paid {
background-color: green;
}
.selected-item {
color: #fff !important;
background-color: blue !important;
}
.selected-account {
color: #fff !important;
background-color: blue !important;
}
/* Reciept Style */
#order-charges-table td {
border-top: none !important;
}
.charges-name {
width: 80%;
text-align: left;
}
.item-name {
width: 60%;
text-align: left;
}
.item-attr {
width: 20%;
text-align: right;
}
.item-attr-edit{
width: 10%;
text-align: left;
}
.display-none{
display: none;
}
.text-white{
color: #fff;
}
/* Colors */
.purple {
background-color:#7a62d3;
}
.orange{
background-color:#FF7F50;
}
.red {
background-color:#ff0000;
}
.green{
background-color: #009900;
}
.orange{
background-color: #FF8C00;
}
.blue{
background-color: blue;
}
/* End Colors */
.left{
margin-left:1px;
}
.bottom{
margin-bottom: 1px;
}
/*----- Reset -----*/
select.form-control {
height: inherit !important;
}
.form-horizontal .form-group {
margin-right: 0px !important;
}
/* Discount */
.discount-item-row {
cursor: pointer;
}
tr.discount-item-row:hover {
background-color: #e3e3e3 !important;
}
.required abbr{
color: red !important;
}
/* Jquery Confirm */
.jconfirm-box-container{
margin-left:-40px !important;
margin-top:-40px !important;
}
#sxModal {
display: none;
overflow: auto;
width: 100%;
height: 100%;
background-color: #000;
background-color: rgba(0,0,0,0.4);
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1100;
}
#sxModal-Content {
position: relative;
left: 42%;
top: 30%;
background-color: #d9534f;
color: #fff;
text-align: center;
width: 200px;
height: 200px;
padding-top: 5%;
border-radius: 100px;
z-index: 1101;
}
/*Loading gif for payment*/
#loading_wrapper{
position: fixed;
background-color: #C8C8C8 ;
height: 100%;
width: 100%;
left: 0;
opacity: 0.6;
top: 0;
z-index: 9999999;
}
#loading{
position: relative;
height: 100%;
width: 100%;
background-image: url('../../../image/loading-ajax.gif');
background-position: center center;
background-repeat: no-repeat;
opacity: 1;
filter: alpha(opacity=100); /* ie */
-moz-opacity: 1; /* mozilla */
}

View File

@@ -7,8 +7,12 @@ module ApplicationCable
end
# Order Queue Station Channel
class OQSChannel < ActionCable::Channel::Base
class OrderQueueStationChannel < ActionCable::Channel::Base
end
# Order Queue Station Channel
class BillChannel < ActionCable::Channel::Base
end
end

View File

@@ -1,4 +1,7 @@
module ApplicationCable
class Connection < ActionCable::Connection::Base
def connect
logger.add_tags "ActionCable"
end
end
end

View File

@@ -0,0 +1,10 @@
class BillChannel < ApplicationCable::Channel
def subscribed
stream_from "bill_channel"
end
def unsubscribed
# Any cleanup needed when channel is unsubscribed
stop_all_streams
end
end

View File

@@ -0,0 +1,10 @@
class OrderChannel < ApplicationCable::Channel
def subscribed
stream_from "order_channel"
end
def unsubscribed
stop_all_streams
# Any cleanup needed when channel is unsubscribed
end
end

View File

@@ -4,6 +4,7 @@ class OrderQueueStationChannel < ApplicationCable::Channel
end
def unsubscribed
stop_all_streams
# Any cleanup needed when channel is unsubscribed
end

View File

@@ -7,8 +7,11 @@ class Api::BillController < Api::ApiController
@error_message = "Order ID or Booking ID is require to request for a bill."
if ShiftSale.current_shift
#create Bill by Booking ID
table = 0
if (params[:booking_id])
booking = Booking.find(params[:booking_id])
# for Job
table = DiningFacility.find(booking.dining_facility_id)
if booking
if booking.sale_id.nil?
@@ -23,8 +26,14 @@ class Api::BillController < Api::ApiController
elsif (params[:order_id])
@sale = Sale.new
@status, @sale_id = @sale.generate_invoice_from_order(params[:order_id], current_login_employee, get_cashier)
# for Job
booking = Booking.find_by_sale_id(@sale_id)
table = DiningFacility.find(booking.dining_facility_id)
end
Promotion.promo_activate(@sale)
BillBroadcastJob.perform_later(table)
else
@status = false
@error_message = "No Current Open Shift"

View File

@@ -1,9 +1,12 @@
class Api::Restaurant::MenuItemAttributesController < Api::ApiController
skip_before_action :authenticate
#Description
# Pull the default menu details and also other available (active) menus
# Input Params - order_id
def index
@menu_attributes = MenuItemAttribute.all
end
def show
@attribute = MenuItemAttribute.find(params[:id])
end
end

View File

@@ -58,14 +58,7 @@ class HomeController < ApplicationController
end
def dashboard
# if @employee && @employee.role == "cashier"
#
# elsif @employee && @employee.role == "waiter"
# elsif @employee && @employee.role == "administrator"
# elsif @employee && @employee.role == "manager"
# elsif @employee && @employee.role == "supervisour"
# redirect_to dashboard_path
# end
@shop = Shop.first
end
def destroy

View File

@@ -25,7 +25,7 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
# POST /inventory_definitions.json
def create
@inventory_definition = InventoryDefinition.new(inventory_definition_params)
@inventory_definition.created_by = current_user.id
respond_to do |format|
if @inventory_definition.save
format.html { redirect_to inventory_path, notice: 'Inventory definition was successfully created.' }

View File

@@ -1,7 +1,7 @@
class Inventory::StockChecksController < BaseInventoryController
def index
@check = StockCheck.new
@inventory_definitions = InventoryDefinition.active.all
end
def create
@@ -28,87 +28,86 @@ class Inventory::StockChecksController < BaseInventoryController
stockcheck = StockCheck.find(stock_id)
stockcheck_items = stockcheck.stock_check_items
member_info = nil
unique_code = "StockPrint"
unique_code = 'StockPrint'
shop_details = Shop.find(1)
checker = Employee.find(stockcheck.check_by)
print_settings=PrintSetting.find_by_unique_code(unique_code)
print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_stock_check_result(print_settings,stockcheck, stockcheck_items,checker.name, shop_details)
printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, shop_details)
end
# before_action :set_stock_check, only: [:show, :edit, :update, :destroy]
# GET /stock_checks
# GET /stock_checks.json
# def index
# @stock_checks = StockCheck.all
# end
#
# # GET /stock_checks/1
# # GET /stock_checks/1.json
# def show
# end
#
# # GET /stock_checks/new
# def new
# @stock_check = StockCheck.new
# end
#
# # GET /stock_checks/1/edit
# def edit
# end
#
# # POST /stock_checks
# # POST /stock_checks.json
# def create
# @stock_check = StockCheck.new(stock_check_params)
#
# respond_to do |format|
# if @stock_check.save
# format.html { redirect_to @stock_check, notice: 'Stock check was successfully created.' }
# format.json { render :show, status: :created, location: @stock_check }
# else
# format.html { render :new }
# format.json { render json: @stock_check.errors, status: :unprocessable_entity }
# end
# end
# end
#
# # PATCH/PUT /stock_checks/1
# # PATCH/PUT /stock_checks/1.json
# def update
# respond_to do |format|
# if @stock_check.update(stock_check_params)
# format.html { redirect_to @stock_check, notice: 'Stock check was successfully updated.' }
# format.json { render :show, status: :ok, location: @stock_check }
# else
# format.html { render :edit }
# format.json { render json: @stock_check.errors, status: :unprocessable_entity }
# end
# end
# end
#
# # DELETE /stock_checks/1
# # DELETE /stock_checks/1.json
# def destroy
# @stock_check.destroy
# respond_to do |format|
# format.html { redirect_to stock_checks_url, notice: 'Stock check was successfully destroyed.' }
# format.json { head :no_content }
# end
# end
#
# private
# # Use callbacks to share common setup or constraints between actions.
# def set_stock_check
# @stock_check = StockCheck.find(params[:id])
# end
#
# # Never trust parameters from the scary internet, only allow the white list through.
# def stock_check_params
# params.fetch(:stock_check, {})
# end
# def index
# @stock_checks = StockCheck.all
# end
#
# # GET /stock_checks/1
# # GET /stock_checks/1.json
# def show
# end
#
# # GET /stock_checks/new
# def new
# @stock_check = StockCheck.new
# end
#
# # GET /stock_checks/1/edit
# def edit
# end
#
# # POST /stock_checks
# # POST /stock_checks.json
# def create
# @stock_check = StockCheck.new(stock_check_params)
#
# respond_to do |format|
# if @stock_check.save
# format.html { redirect_to @stock_check, notice: 'Stock check was successfully created.' }
# format.json { render :show, status: :created, location: @stock_check }
# else
# format.html { render :new }
# format.json { render json: @stock_check.errors, status: :unprocessable_entity }
# end
# end
# end
#
# # PATCH/PUT /stock_checks/1
# # PATCH/PUT /stock_checks/1.json
# def update
# respond_to do |format|
# if @stock_check.update(stock_check_params)
# format.html { redirect_to @stock_check, notice: 'Stock check was successfully updated.' }
# format.json { render :show, status: :ok, location: @stock_check }
# else
# format.html { render :edit }
# format.json { render json: @stock_check.errors, status: :unprocessable_entity }
# end
# end
# end
#
# # DELETE /stock_checks/1
# # DELETE /stock_checks/1.json
# def destroy
# @stock_check.destroy
# respond_to do |format|
# format.html { redirect_to stock_checks_url, notice: 'Stock check was successfully destroyed.' }
# format.json { head :no_content }
# end
# end
#
# private
# # Use callbacks to share common setup or constraints between actions.
# def set_stock_check
# @stock_check = StockCheck.find(params[:id])
# end
#
# # Never trust parameters from the scary internet, only allow the white list through.
# def stock_check_params
# params.fetch(:stock_check, {})
# end
end

View File

@@ -131,6 +131,7 @@ class Oqs::HomeController < BaseOqsController
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.delivery_status = #{status} AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' #{oqs} ")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.order("assigned_order_items.assigned_order_item_id desc")
.group("assigned_order_items.assigned_order_item_id")
end

View File

@@ -30,10 +30,19 @@ class Origami::AddordersController < BaseOrigamiController
else
@booking = nil
end
end
def get_menu_category ()
if (params[:id])
#Pull this menu
@menu = MenuCategory.find_by_id(params[:id])
return @menu
else
MenuCategory.current_menu
end
end
def create
Rails.logger.debug "Order Source - " + params[:order_source].to_s
Rails.logger.debug "Table ID - " + params[:table_id].to_s

View File

@@ -127,88 +127,91 @@ class Origami::DiscountsController < BaseOrigamiController
# Member Discount
def member_discount
sale_id = params[:sale_id]
# account_types = JSON.parse(params[:account_types])
account_types = Account.where("discount=?",true)
sub_total = params[:sub_total]
sale = Sale.find(sale_id)
price = SaleItem.calculate_price_by_accounts(sale.sale_items)
arr = Array.new;
account_types.each do |at|
price.each do |pc|
if pc[:name] == at.title && pc[:price]>0
str={type:pc[:name],amount:pc[:price]}
arr.push(str)
end
end
end
generic_customer_id = sale.customer.membership_id
receipt_no = sale.receipt_no
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("member_discount")
merchant_uid = memberaction.merchant_account_id.to_s
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
# Check for items for Paypar Cloud
if arr.length > 0
begin
response = HTTParty.post(url,
:body => { account_no: nil,
generic_customer_id:generic_customer_id ,
campaign_type_id: campaign_type_id,
receipt_no: receipt_no,
merchant_uid:merchant_uid,
campaign_method:arr.to_json,
total_sale_transaction_amount: sale.grand_total,
auth_token:auth_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}, :timeout => 10)
rescue HTTParty::Error
response = {:status=> false, :message => "Can't open membership server " }
rescue Net::OpenTimeout
response = {:status=> false, :message => "Can't open membership server " }
rescue OpenURI::HTTPError
response = {:status=> false, :message => "Can't open membership server " }
rescue SocketError
response = {:status=> false, :message => "Can't open membership server " }
end
else
response = {:status=> false, :message => "You have no selected discount item" }
end
table_id = sale.bookings[0].dining_facility_id
table_type = DiningFacility.find(table_id).type
# Re-calc All Amount in Sale
if response["status"] == true
discount_amount = response["discount_earned"]
if response["discount_bonus_earned"]
discount_amount = discount_amount + response["discount_bonus_earned"]
end
sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount')
result = {:status=> "Success",:title=>"Member Discount", :table_id => table_id,:table_type => table_type }
end
if response["status"] == "500"
result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
end
if !response.nil?
if response[:status] == false
result = {:status=> response[:message],:title=>"Alert", :table_id => table_id,:table_type => table_type }
end
end
render :json => result.to_json
sale_id = params[:sale_id]
is_card = params[:is_card]
sub_total = params[:sub_total]
sale = Sale.find(sale_id)
# Check for Card Payment
is_card_payment = SaleItem.get_sale_payments_by_card(sale.sale_payments)
if is_card_payment != true
account_types = Account.where("discount=?",true)
table_id = sale.bookings[0].dining_facility_id
table_type = DiningFacility.find(table_id).type
# Get Prices for each accounts (eg: food, beverage)
account_price = SaleItem.calculate_price_by_accounts(sale.sale_items)
acc_prices = Array.new;
account_types.each do |at|
account_price.each do |pc|
if pc[:name] == at.title && pc[:price]>0
str={type:pc[:name],amount:pc[:price]}
acc_prices.push(str)
end
end
end
generic_customer_id = sale.customer.membership_id
receipt_no = sale.receipt_no
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("member_discount")
merchant_uid = memberaction.merchant_account_id.to_s
campaign_type_id = memberaction.additional_parameter["campaign_type_id"]
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
# Check for items for Paypar Cloud
if acc_prices.length > 0
begin
response = HTTParty.post(url,
:body => { account_no: nil,
generic_customer_id:generic_customer_id ,
campaign_type_id: campaign_type_id,
receipt_no: receipt_no,
merchant_uid:merchant_uid,
campaign_method:acc_prices.to_json,
total_sale_transaction_amount: sale.grand_total,
is_card: is_card,
auth_token:auth_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}, :timeout => 10)
rescue HTTParty::Error
response = {"status": false, "message": "Can't open membership server " }
rescue Net::OpenTimeout
response = {"status": false, "message": "Can't open membership server " }
rescue OpenURI::HTTPError
response = {"status": false, "message": "Can't open membership server " }
rescue SocketError
response = {"status": false, "message": "Can't open membership server " }
end
else
response = {"status": false, "message": "You have no selected discount item" }
end
# Re-calc All Amount in Sale
if response["status"] == true
discount_amount = response["discount_earned"]
if response["discount_bonus_earned"]
discount_amount = discount_amount + response["discount_bonus_earned"]
end
sale.compute_by_sale_items(sale_id, sale.sale_items, discount_amount, 'member_discount')
result = {:status=> "Success",:title=>"Member Discount", :table_id => table_id,:table_type => table_type }
elsif response["status"] == "500"
result = {:status=> response["error"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
else
result = {:status=> response["message"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
end
render :json => result.to_json
end #end Is Card Payment
end
#discount for selected order

View File

@@ -0,0 +1,170 @@
class Origami::InDutiesController < BaseOrigamiController
before_action :set_in_duty, only: %i[show edit update edit_in_duty update_for_in_duty destroy destroy_in_duty]
# GET /in_duties
# GET /in_duties.json
def index
@in_duties = InDuty.all
end
def index_in_duty
@duty_in = InDuty.where('dinning_id=?', params[:table_id])
@table = DiningFacility.find(params[:table_id])
@in_duty = InDuty.new
@duties_in = Kaminari.paginate_array(@duty_in).page(params[:page]).per(10)
end
# GET /in_duties/1
# GET /in_duties/1.json
def show; end
# GET /in_duties/new
def new
# this one use for new
@in_duty = InDuty.new
@table = DiningFacility.find(params[:table_id])
@commissioner = @in_duty.commissioner
render partial: 'form'
end
# GET /in_duties/1/edit
def edit; end
def edit_in_duty
@in_duty = InDuty.find(params[:id])
@table = DiningFacility.find(params[:table_id])
@commissioner = @in_duty.commissioner
# render json: {in_duty: @in_duty, commissioner: @commissioner}
render partial: 'form'
end
def assign_in_duty
@in_duty = InDuty.new
@table = DiningFacility.find(params[:table_id])
end
# POST /in_duties
# POST /in_duties.json
def create
@in_duty = InDuty.new(in_duty_params)
respond_to do |format|
if @in_duty.save
format.html { redirect_to origami_in_duties_path, notice: 'In duty was successfully created.' }
format.json { render :show, status: :created, location: @in_duty }
else
format.html { render :new }
format.json { render json: @in_duty.errors, status: :unprocessable_entity }
end
end
end
def create_for_in_duty
# this one use for create and update
in_duty = in_duty_params
in_time = DateTime.new in_duty['in_time(1i)'].to_i, in_duty['in_time(2i)'].to_i, in_duty['in_time(3i)'].to_i, in_duty['in_time(4i)'].to_i, in_duty['in_time(5i)'].to_i
in_time = in_time.change(offset: '+06:30')
out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i
out_time = out_time.change(offset: '+06:30')
@in_duty = InDuty.new
in_duty_id = in_duty[:id]
unless in_duty_id.empty?
@in_duty = InDuty.find(in_duty_id.to_i)
end
@in_duty.dinning_id = in_duty_params[:dinning_id]
@in_duty.commissioner_ids = in_duty_params[:commissioner_ids]
@in_duty.in_time = in_time
@in_duty.out_time = out_time
respond_to do |format|
if @in_duty.save
if in_duty_id.nil?
format.html { redirect_to origami_index_in_duty_path(in_duty_params[:dinning_id]), notice: 'In duty was successfully created.' }
format.json { render :show, status: :created, location: @in_duty }
else
format.html { redirect_to origami_index_in_duty_path(in_duty_params[:dinning_id]), notice: 'In duty was successfully updated.' }
format.json { render :show, status: :created, location: @in_duty }
end
else
format.html { render :new }
format.json { render json: @in_duty.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /in_duties/1
# PATCH/PUT /in_duties/1.json
def update
in_duty = in_duty_params
in_time = DateTime.new in_duty['in_time(1i)'].to_i, in_duty['in_time(2i)'].to_i, in_duty['in_time(3i)'].to_i, in_duty['in_time(4i)'].to_i, in_duty['in_time(5i)'].to_i
in_time = in_time.change(offset: '+06:30')
out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i
out_time = out_time.change(offset: '+06:30')
@in_duty.commissioner_ids = in_duty_params[:commissioner_ids]
@in_duty.in_time = in_time
@in_duty.out_time = out_time
respond_to do |format|
if @in_duty.save
format.html { redirect_to origami_index_in_duty_path(in_duty_params[:dinning_id]), notice: 'In duty was successfully updated.' }
format.json { render :show, status: :ok, location: @in_duty }
else
format.html { render :edit }
format.json { render json: @in_duty.errors, status: :unprocessable_entity }
end
end
end
def update_for_in_duty
in_duty = in_duty_params
in_time = DateTime.new in_duty['in_time(1i)'].to_i, in_duty['in_time(2i)'].to_i, in_duty['in_time(3i)'].to_i, in_duty['in_time(4i)'].to_i, in_duty['in_time(5i)'].to_i
in_time = in_time.change(offset: '+06:30')
out_time = DateTime.new in_duty['out_time(1i)'].to_i, in_duty['out_time(2i)'].to_i, in_duty['out_time(3i)'].to_i, in_duty['out_time(4i)'].to_i, in_duty['out_time(5i)'].to_i
out_time = out_time.change(offset: '+06:30')
@in_duty.commissioner_ids = in_duty_params[:commissioner_ids]
@in_duty.in_time = in_time
@in_duty.out_time = out_time
respond_to do |format|
if @in_duty.save
format.html { redirect_to origami_index_in_duty_path(in_duty_params[:dinning_id]), notice: 'In duty was successfully updated.' }
format.json { render :show, status: :ok, location: @in_duty }
else
format.html { render :edit }
format.json { render json: @in_duty.errors, status: :unprocessable_entity }
end
end
end
# DELETE /in_duties/1
# DELETE /in_duties/1.json
def destroy
@in_duty.destroy
respond_to do |format|
format.html { redirect_to origami_in_duties_path, notice: 'In duty was successfully removed.' }
format.json { head :no_content }
end
end
def destroy_in_duty
@table_id = params[:table_id]
@in_duty.destroy
respond_to do |format|
format.html { redirect_to origami_index_in_duty_path(@table_id), notice: 'In duty was successfully removed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_in_duty
@in_duty = InDuty.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def in_duty_params
params.require(:in_duty).permit(:id, :dinning_id, :commissioner_ids, :in_time, :out_time)
end
end

View File

@@ -1,172 +0,0 @@
class Origami::InJutiesController < BaseOrigamiController
before_action :set_in_juty, only: %i[show edit update edit_in_juty update_for_in_juty destroy destroy_in_juty]
# GET /in_juties
# GET /in_juties.json
def index
@in_juties = InJuty.all
end
def index_in_juty
@juty_in = InJuty.where('dinning_id=?', params[:table_id])
@table = DiningFacility.find(params[:table_id])
@in_juty = InJuty.new
@juties_in = Kaminari.paginate_array(@juty_in).page(params[:page]).per(10)
end
# GET /in_juties/1
# GET /in_juties/1.json
def show
end
# GET /in_juties/new
def new
# this one use for new
@in_juty = InJuty.new
@table = DiningFacility.find(params[:table_id])
@commissioner = @in_juty.commissioner
render partial: 'form'
end
# GET /in_juties/1/edit
def edit
end
def edit_in_juty
@in_juty = InJuty.find(params[:id])
@table = DiningFacility.find(params[:table_id])
@commissioner = @in_juty.commissioner
# render json: {in_juty: @in_juty, commissioner: @commissioner}
render partial: 'form'
end
def assign_in_juty
@in_juty = InJuty.new
@table = DiningFacility.find(params[:table_id])
end
# POST /in_juties
# POST /in_juties.json
def create
@in_juty = InJuty.new(in_juty_params)
respond_to do |format|
if @in_juty.save
format.html { redirect_to origami_in_juties_path, notice: 'In juty was successfully created.' }
format.json { render :show, status: :created, location: @in_juty }
else
format.html { render :new }
format.json { render json: @in_juty.errors, status: :unprocessable_entity }
end
end
end
def create_for_in_juty
# this one use for create and update
in_juty = in_juty_params
in_time = DateTime.new in_juty['in_time(1i)'].to_i, in_juty['in_time(2i)'].to_i, in_juty['in_time(3i)'].to_i, in_juty['in_time(4i)'].to_i, in_juty['in_time(5i)'].to_i
in_time = in_time.change(offset: '+06:30')
out_time = DateTime.new in_juty['out_time(1i)'].to_i, in_juty['out_time(2i)'].to_i, in_juty['out_time(3i)'].to_i, in_juty['out_time(4i)'].to_i, in_juty['out_time(5i)'].to_i
out_time = out_time.change(offset: '+06:30')
@in_juty = InJuty.new
in_juty_id = in_juty[:id]
unless in_juty_id.nil?
@in_juty = InJuty.find(in_juty_id.to_i)
end
@in_juty.dinning_id = in_juty_params[:dinning_id]
@in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
@in_juty.in_time = in_time
@in_juty.out_time = out_time
respond_to do |format|
if @in_juty.save
if in_juty_id.nil?
format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), notice: 'In juty was successfully created.' }
format.json { render :show, status: :created, location: @in_juty }
else
format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), notice: 'In juty was successfully updated.' }
format.json { render :show, status: :created, location: @in_juty }
end
else
format.html { render :new }
format.json { render json: @in_juty.errors, status: :unprocessable_entity }
end
end
end
# PATCH/PUT /in_juties/1
# PATCH/PUT /in_juties/1.json
def update
in_juty = in_juty_params
in_time = DateTime.new in_juty['in_time(1i)'].to_i, in_juty['in_time(2i)'].to_i, in_juty['in_time(3i)'].to_i, in_juty['in_time(4i)'].to_i, in_juty['in_time(5i)'].to_i
in_time = in_time.change(offset: '+06:30')
out_time = DateTime.new in_juty['out_time(1i)'].to_i, in_juty['out_time(2i)'].to_i, in_juty['out_time(3i)'].to_i, in_juty['out_time(4i)'].to_i, in_juty['out_time(5i)'].to_i
out_time = out_time.change(offset: '+06:30')
@in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
@in_juty.in_time = in_time
@in_juty.out_time = out_time
respond_to do |format|
if @in_juty.save
format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), notice: 'In juty was successfully updated.' }
format.json { render :show, status: :ok, location: @in_juty }
else
format.html { render :edit }
format.json { render json: @in_juty.errors, status: :unprocessable_entity }
end
end
end
def update_for_in_juty
in_juty = in_juty_params
in_time = DateTime.new in_juty['in_time(1i)'].to_i, in_juty['in_time(2i)'].to_i, in_juty['in_time(3i)'].to_i, in_juty['in_time(4i)'].to_i, in_juty['in_time(5i)'].to_i
in_time = in_time.change(offset: '+06:30')
out_time = DateTime.new in_juty['out_time(1i)'].to_i, in_juty['out_time(2i)'].to_i, in_juty['out_time(3i)'].to_i, in_juty['out_time(4i)'].to_i, in_juty['out_time(5i)'].to_i
out_time = out_time.change(offset: '+06:30')
@in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
@in_juty.in_time = in_time
@in_juty.out_time = out_time
respond_to do |format|
if @in_juty.save
format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), notice: 'In juty was successfully updated.' }
format.json { render :show, status: :ok, location: @in_juty }
else
format.html { render :edit }
format.json { render json: @in_juty.errors, status: :unprocessable_entity }
end
end
end
# DELETE /in_juties/1
# DELETE /in_juties/1.json
def destroy
@in_juty.destroy
respond_to do |format|
format.html { redirect_to origami_in_juties_path, notice: 'In juty was successfully removed.' }
format.json { head :no_content }
end
end
def destroy_in_juty
@table_id = params[:table_id]
@in_juty.destroy
respond_to do |format|
format.html { redirect_to origami_index_in_juty_path(@table_id), notice: 'In juty was successfully removed.' }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_in_juty
@in_juty = InJuty.find(params[:id])
end
# Never trust parameters from the scary internet, only allow the white list through.
def in_juty_params
params.require(:in_juty).permit(:id, :dinning_id, :commissioner_ids, :in_time, :out_time)
end
end

View File

@@ -17,6 +17,9 @@ class Origami::JcbController < BaseOrigamiController
end
@can_jcb = total - @jcbcount - others
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
end
def create

View File

@@ -16,6 +16,9 @@ class Origami::MasterController < BaseOrigamiController
end
end
@can_master = total - @mastercount - others
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
end
def create

View File

@@ -5,9 +5,10 @@ class Origami::MpuController < BaseOrigamiController
# limit mpu_amount
sale_data = Sale.find_by_sale_id(@sale_id)
total = sale_data.grand_total
total = sale_data.grand_total
@mpucount = 0
others = 0
others = 0
sale_data.sale_payments.each do |sale_payment|
if sale_payment.payment_method == "mpu"
@mpucount = @mpucount + sale_payment.payment_amount
@@ -17,6 +18,9 @@ class Origami::MpuController < BaseOrigamiController
end
@can_mpu = total - @mpucount - others
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
end
def create

View File

@@ -75,6 +75,8 @@ class Origami::PaymentsController < BaseOrigamiController
def show
sale_id = params[:sale_id]
@member_discount = MembershipSetting.find_by_discount(1)
if Sale.exists?(sale_id)
@cash = 0.0

View File

@@ -1,4 +1,4 @@
class Origami::ProductCommissionsController < ApplicationController
class Origami::ProductCommissionsController < BaseOrigamiController
before_action :set_product_commission, only: [:show, :edit, :update, :destroy]
# GET /product_commissions

View File

@@ -1,5 +1,5 @@
class Origami::SaleEditController < BaseOrigamiController
authorize_resource :class => false
authorize_resource class: false
# Index for sale item void OR edit
def edit
sale_id = params[:sale_id]
@@ -19,12 +19,13 @@ class Origami::SaleEditController < BaseOrigamiController
@newsaleitem.qty = saleitemObj.qty * -1
@newsaleitem.price = saleitemObj.price * -1
@newsaleitem.is_taxable = 1
@newsaleitem.product_name = saleitemObj.product_name + " - void"
@newsaleitem.product_name = saleitemObj.product_name + ' - void'
@newsaleitem.save
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
saleObj.compute_without_void
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
end
def item_foc
@@ -44,6 +45,7 @@ class Origami::SaleEditController < BaseOrigamiController
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
saleObj.compute_without_void
ProductCommission.create_product_commission(@newsaleitem, saleitemObj)
end
# def item_edit
@@ -77,14 +79,19 @@ class Origami::SaleEditController < BaseOrigamiController
saleitemObj.unit_price = update_price
saleitemObj.taxable_price = update_qty.to_f * update_price.to_f
# saleitemObj.remark = 'edit'
saleitemObj.product_name = saleitemObj.product_name + " - updated"
unless saleitemObj.product_name.include? 'updated'
saleitemObj.product_name = saleitemObj.product_name + ' - updated'
end
saleitemObj.save
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
saleObj.compute_without_void
end
ProductCommission.edit_product_commission(saleitemObj)
end
# make cancel void item
def item_void_cancel
@@ -102,6 +109,7 @@ class Origami::SaleEditController < BaseOrigamiController
# re-calc tax
saleObj = Sale.find(saleitemObj.sale_id)
saleObj.compute_without_void
ProductCommission.remove_product_commission(saleitemObj)
end
# remove all void items
@@ -115,6 +123,7 @@ class Origami::SaleEditController < BaseOrigamiController
item.remark = nil
end
item.save
ProductCommission.remove_product_commission(item)
end
# re-calc tax
@@ -125,5 +134,8 @@ class Origami::SaleEditController < BaseOrigamiController
sale_id = params[:sale_id]
saleObj = Sale.find(sale_id)
saleObj.compute_without_void
saleObj.sale_items.each do |item|
ProductCommission.remove_product_commission(item)
end
end
end

View File

@@ -16,6 +16,9 @@ class Origami::VisaController < BaseOrigamiController
end
end
@can_visa = total - @visacount - others
@member_discount = MembershipSetting.find_by_discount(1)
@sub_total = sale_data.total_amount
@membership_id = sale_data.customer.membership_id
end
def create

View File

@@ -0,0 +1,48 @@
class Reports::StockCheckController < BaseReportController
# authorize_resource :class => false
def index
from_date = DateTime.now.beginning_of_day.utc.getlocal
to_date = DateTime.now.end_of_day.utc.getlocal
unless params[:daterange].blank?
from_date = Date.parse(params[:daterange].split(' - ')[0]).beginning_of_day.utc.getlocal
to_date = Date.parse(params[:daterange].split(' - ')[1]).end_of_day.utc.getlocal
@daterange = params[:daterange]
end
@item_code = params[:item_code]
@inventory_definitions = InventoryDefinition.active.all
@transaction = StockCheckItem.get_transaction(from_date, to_date, @item_code)
@from = from_date
@to = to_date
respond_to do |format|
format.html
format.xls
end
end
def show
from, to = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
date_arr = Array.new
@sale_data.each do |sale|
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
shift_id = sale.id.nil? ? '-' : sale.id
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
date_arr.push(str)
end
out = {:status => 'ok', :message => date_arr}
respond_to do |format|
format.json { render json: out }
end
end
end

View File

@@ -92,12 +92,14 @@ class Settings::MenuItemInstancesController < ApplicationController
category = MenuCategory.find(id)
# Bind for Item Sets
if params[:menu_item_instance][:item_sets].count > 1
if params[:menu_item_instance][:item_sets].count > 0
params[:menu_item_instance][:item_sets].delete_at(0)
sets = ItemSet.find(params[:menu_item_instance][:item_sets])
if sets.count > 0
if sets.count >= 0
# destroy all item sets for edit
@settings_menu_item_instances.item_sets.destroy
@settings_menu_item_instances.item_sets = sets
end
end

View File

@@ -69,6 +69,9 @@ class Settings::PromotionsController < ApplicationController
# DELETE /promotions/1
# DELETE /promotions/1.json
def destroy
@promotion.promotion_products.each do |pp|
pp.destroy
end
@promotion.destroy
respond_to do |format|
format.html { redirect_to settings_promotions_path, notice: 'Promotion was successfully destroyed.' }
@@ -87,6 +90,21 @@ class Settings::PromotionsController < ApplicationController
end
end
def find_parent_item
res = []
item = MenuItemInstance.find_by_item_instance_code(params[:item_instance_code])
if item.nil?
product = Product.where("item_code = ?",params[:item_instance_code]).pluck(:name,:item_code)
res.push(product.name)
res.push(product.item_code)
else
# menu_item = item.menu_item.pluck(:name,:item_code)
res.push(item.item_instance_name)
res.push(item.menu_item.item_code)
end
render json: res
end
private
# Use callbacks to share common setup or constraints between actions.
def set_promotion

View File

@@ -75,12 +75,14 @@ class Settings::SetMenuItemsController < ApplicationController
params[:set_menu_item][:item_options].delete_at(0)
# Bind for Item Sets
if params[:set_menu_item][:item_sets].count > 1
if params[:set_menu_item][:item_sets].count > 0
params[:set_menu_item][:item_sets].delete_at(0)
sets = ItemSet.find(params[:set_menu_item][:item_sets])
if sets.count > 0
if sets.count >= 0
# destroy all item sets for edit
@settings_menu_item.item_sets.destroy
@settings_menu_item.item_sets = sets
end
end

View File

@@ -98,12 +98,14 @@ class Settings::SimpleMenuItemsController < ApplicationController
params[:simple_menu_item][:item_options].delete_at(0)
# Bind for Item Sets
if params[:simple_menu_item][:item_sets].count > 1
if params[:simple_menu_item][:item_sets].count > 0
params[:simple_menu_item][:item_sets].delete_at(0)
sets = ItemSet.find(params[:simple_menu_item][:item_sets])
if sets.count > 0
if sets.count >= 0
# destroy all item sets for edit
@settings_menu_item.item_sets.destroy
@settings_menu_item.item_sets = sets
end
end

View File

@@ -0,0 +1,2 @@
module Origami::InDutiesHelper
end

View File

@@ -1,2 +0,0 @@
module Origami::InJutiesHelper
end

View File

@@ -0,0 +1,7 @@
class BillBroadcastJob < ApplicationJob
queue_as :default
def perform(table)
ActionCable.server.broadcast "bill_channel",table: table
end
end

View File

@@ -1,9 +1,7 @@
class OrderBroadcastJob < ApplicationJob
queue_as :default
def perform(message)
order = Order.find(message) # message come as order_id
ApplicationCable.server.broadcast "order_queue_station_channel", order: order
def perform(table)
ActionCable.server.broadcast "order_channel",table: table
end
end

View File

@@ -4,14 +4,24 @@ class OrderQueueProcessorJob < ApplicationJob
def perform(order_id, table_id)
# Do something later
#Order ID
order = Order.find(order_id)
#Loop through the order stations and process the items
order = Order.find(order_id)
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)
#Execute orders and send to order stations
if order
oqs = OrderQueueStation.new
oqs.process_order(order, table_id)
end
ActionCable.server.broadcast "order_queue_station_channel",order: assign_order
end
# private
# def render_order(assign_order)
# ApplicationController.renderer.render(partial: 'oqs/oqs_test',
# locals: { order: assign_order})
# end
# Read more at https://www.pluralsight.com/guides/ruby-ruby-on-rails/creating-a-chat-using-rails-action-cable#TehYiuqlHDOXaQQk.99
end

View File

@@ -17,6 +17,29 @@ class AssignedOrderItem < ApplicationRecord
assigned_order_item.save
end
def self.assigned_order_item_by_job(order_id)
order_item = AssignedOrderItem.select("assigned_order_items.assigned_order_item_id,
assigned_order_items.order_queue_station_id,
oqs.id as station_id, oqs.station_name,
oqs.is_active, oqpz.zone_id,
df.name as zone, df.type as table_type,
odt.order_id, odt.item_code, odt.item_name,
odt.price, odt.qty, odt.item_order_by, odt.options,
cus.name as customer_name, odt.created_at")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join order_queue_process_by_zones as oqpz on oqpz.order_queue_station_id = oqs.id
left join orders as od ON od.order_id = assigned_order_items.order_id
left join order_items as odt ON odt.item_code = assigned_order_items.item_code AND odt.order_id = assigned_order_items.order_id
left join customers as cus ON cus.customer_id = od.customer_id
left join booking_orders as bo on bo.order_id = assigned_order_items.order_id
left join bookings as bk on bk.booking_id = bo.booking_id
left join dining_facilities as df on df.id = bk.dining_facility_id")
.where("assigned_order_items.order_id = '#{order_id}' AND assigned_order_items.delivery_status = false AND odt.price <> 0 AND assigned_order_items.created_at >= '#{Time.now.beginning_of_day.utc}' ")
.order("assigned_order_items.assigned_order_item_id desc")
.group("assigned_order_items.assigned_order_item_id")
return order_item
end
private
def generate_custom_id
self.assigned_order_item_id = SeedGenerator.generate_id(self.class.name, "AOI")

View File

@@ -8,8 +8,8 @@ class DiningCharge < ApplicationRecord
price = 0
minutes = DiningCharge.time_diff(checkout, checkin)
free_time = DiningCharge.convert_to_minutes(dining_charges_obj.minimum_free_time.utc.localtime.strftime('%H:%M'))
dining_minutes = minutes - free_time # stayminutes - free minutes
if dining_minutes <= 0
dining_minutes = minutes #- free_time # stayminutes - free minutes
if dining_minutes <= free_time
price = 0
else
charge_type = dining_charges_obj.charge_type

View File

@@ -1,4 +1,4 @@
class InJuty < ApplicationRecord
class InDuty < ApplicationRecord
belongs_to :dining_facility, foreign_key: 'dinning_id'
belongs_to :commissioner, foreign_key: 'commissioner_ids'
end

View File

@@ -6,14 +6,24 @@ class MenuItemInstance < ApplicationRecord
# before_create :generate_menu_item_instance_code
def self.findParentCategory(item)
if item.menu_category_id
return item.menu_category_id
if item.menu_category_id
item.menu_category_id
else
parentitem = MenuItem.find(item.menu_item_id)
findParentCategory(parentitem)
end
end
def self.get_item_name(item_code)
menu_item = MenuItemInstance.find_by_item_instance_code(item_code)
if menu_item.nil?
item_name = Product.find_by_item_code(item_code).name
else
item_name = menu_item.menu_item.name + ' - ' + menu_item.item_instance_name
end
item_name
end
# private
# def generate_menu_item_instance_code

View File

@@ -49,7 +49,7 @@ class Order < ApplicationRecord
process_order_queue
#send order to broadcast job
#send_order_broadcast
send_order_broadcast(booking)
return true, booking
@@ -214,9 +214,10 @@ class Order < ApplicationRecord
#send order items and send to order queue
def send_order_broadcast
def send_order_broadcast(booking)
table = DiningFacility.find(booking.dining_facility_id)
#Send to background job for processing
OrderBroadcastJob.perform_later(self.id)
OrderBroadcastJob.perform_later(table)
end
#Origami: Cashier : to view order Table

View File

@@ -5,14 +5,67 @@ class ProductCommission < ApplicationRecord
belongs_to :sale_item, foreign_key: 'sale_item_id'
belongs_to :sale, foreign_key: 'sale_id'
def self.create_product_commission(newSaleItem, oldSaleItem)
old_product_commission = ProductCommission.find_by_sale_item_id(oldSaleItem.id)
return if old_product_commission.nil?
menu_item = MenuItem.find_by_item_code(newSaleItem.product_code)
return if menu_item.nil?
product_commission = ProductCommission.new
commission = Commission.where('product_code = ? AND is_active = ?', menu_item.id, true).take
product_commission.product_code = menu_item.id
product_commission.product_type = 'menu_item' # use for dummy data ToDo::need to change product type
unless commission.nil?
product_commission.commission_id = commission.id
if commission.commission_type == 'Percentage'
product_commission.price = newSaleItem.unit_price * (commission.amount / 100.0)
product_commission.amount = product_commission.price * newSaleItem.qty
elsif commission.commission_type == 'Net Amount'
product_commission.price = commission.amount
product_commission.amount = product_commission.price * newSaleItem.qty
end
end
unless old_product_commission.nil?
product_commission.commissioner_id = old_product_commission.commissioner_id
end
product_commission.qty = newSaleItem.qty
product_commission.sale_id = newSaleItem.sale_id
product_commission.sale_item_id = newSaleItem.sale_item_id
product_commission.save
end
def self.edit_product_commission(saleItemObj)
menu_item = MenuItem.find_by_item_code(saleItemObj.product_code)
commission = Commission.where('product_code = ? AND is_active = ?', menu_item.id, true).take
product_commission = ProductCommission.where('sale_item_id = ?', saleItemObj.id).take
return if commission.nil?
product_commission.qty = saleItemObj.qty
if commission.commission_type == 'Percentage'
product_commission.price = saleItemObj.unit_price * (commission.amount / 100.0)
product_commission.amount = product_commission.price * saleItemObj.qty
elsif commission.commission_type == 'Net Amount'
product_commission.price = commission.amount
product_commission.amount = product_commission.price * saleItemObj.qty
end
product_commission.save
puts 'Edit Product Commission Success'
end
def self.remove_product_commission(sale_item_id)
transaction = ProductCommission.find_by_sale_item_id(sale_item_id)
return if transaction.nil?
transaction.destroy
puts 'Remove Product Commission Success'
end
def self.get_transaction(from, to, commissioner)
transaction = self.all
transaction = all
if !from.nil? && !to.nil?
transaction = transaction.where('updated_at between ? and ?', from, to)
end
if commissioner != 0
transaction = transaction.where(commissioner_id: commissioner)
end
return transaction
transaction
end
end

View File

@@ -1,5 +1,5 @@
class Promotion < ApplicationRecord
validates_presence_of :promo_code,:promo_start_date,:promo_end_date,:promo_start_hour,:promo_end_hour,:promo_day,:promo_type,:original_product,:min_qty
validates_presence_of :promo_code,:promo_start_date,:promo_end_date,:promo_start_hour,:promo_end_hour,:promo_type,:original_product,:min_qty
has_many :promotion_products
@@ -23,13 +23,18 @@ class Promotion < ApplicationRecord
end
def self.is_between_promo_datetime(current_day,current_time) #database is not local time
promoList = Promotion.where("(TO_CHAR(promo_start_date, 'YYYY-MM-DD') <=? AND TO_CHAR(promo_end_date, 'YYYY-MM-DD') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time)
promoList = Promotion.where("(Date_Format(promo_start_date, 'YYYY-MM-DD') <=? AND Date_Format(promo_end_date, 'YYYY-MM-DD') >=?) AND (promo_start_hour < ? AND promo_end_hour > ?)", current_day, current_day, current_time, current_time)
return promoList
end
def self.combine_item(saleObj)
order_id = saleObj.sale_orders[0].order_id
itemList = OrderItem.where("order_id = ?", order_id).group(:item_instance_code).sum(:qty)
# order_id = saleObj.sale_orders[0].order_id
# itemList = OrderItem.where("order_id = ?", order_id).group(:item_instance_code).sum(:qty)
itemList = []
saleObj.sale_orders.each do |so|
itemList << OrderItem.where("order_id = ?",so.order_id).group(:item_instance_code).sum(:qty)
end
return itemList
end
def self.is_promo_day(promoList, day, orderitemList, sale_id)
@@ -46,20 +51,29 @@ class Promotion < ApplicationRecord
def self.find_promo_item(promo, orderitem, sale_id)
# item_code = OrderItem.find_by_item_instance_code(orderitem[0]).item_code
if promo.original_product.to_s == orderitem[0]
if promo.min_qty.to_i > orderitem[1].to_i
return false
else
check_promo_type(promo,orderitem, sale_id)
end
end
orderitem.each do |odr_item|
if promo.original_product.to_s == odr_item[0]
if promo.min_qty.to_i > odr_item[1].to_i
return false
else
check_promo_type(promo,odr_item, sale_id)
end
end
end
end
def self.check_promo_type(promo, orderitem, sale_id)
same, promo_product = check_giveaway_product(promo, orderitem[0])
promo.promotion_products.each do |promo_product|
if promo_product.item_code == orderitem[0]
same = true
else
# return false, promo_product
same = false
end
# same, promo_product = check_giveaway_product(promo, orderitem[0])
if promo.promo_type == Promotion::PROMO_TYPE1
if same
give_promotion_same_product(orderitem[1], promo.min_qty, promo_product.min_qty, orderitem, sale_id)
give_promotion_same_product(orderitem[1], promo.min_qty, promo_product.min_qty, orderitem, sale_id,promo_product.item_code)
else
give_promotion_second_product(orderitem[1], promo.min_qty, promo_product.item_code, orderitem, sale_id)
end
@@ -73,19 +87,23 @@ class Promotion < ApplicationRecord
elsif promo.promo_type == Promotion::PROMO_TYPE4
give_promotion_discount(same,promo_product,promo.min_qty, orderitem, sale_id)
end
end
end
def self.check_giveaway_product(promo, orderitem)
promo.promotion_products.each do |promo_product|
if promo_product.item_code == orderitem
return true, promo_product
else
return false, promo_product
end
end
# promo_pp = []
# flag = false
# promo.promotion_products.each do |promo_product|
# if promo_product.item_code == orderitem
# # return true, promo_product
# promo_pp.push(promo_product)
# else
# # return false, promo_product
# end
# end
end
def self.give_promotion_same_product(qty, promoqty, foc_min_qty, orderitem, sale_id)
def self.give_promotion_same_product(qty, promoqty, foc_min_qty, orderitem, sale_id,promo_product)
puts " Order qty: " + qty.to_s + " / promoqty: " + promoqty.to_s + " / giveaway: " + foc_min_qty.to_s
multiple = qty.to_i / promoqty.to_i # loop count
charge_qty = 0
@@ -113,7 +131,7 @@ class Promotion < ApplicationRecord
charge_qty += qty
end
item = OrderItem.find_by_item_instance_code(orderitem[0])
if promo_product == OrderItem.find_by_item_instance_code(orderitem[0]).item_code
if promo_product == OrderItem.find_by_item_instance_code(orderitem[0]).item_instance_code
item = OrderItem.find_by_item_instance_code(orderitem[0])
else
item = OrderItem.find_by_item_code(promo_product)
@@ -126,7 +144,6 @@ class Promotion < ApplicationRecord
# AA - 10 # 3 # BB # orderList, #S34345
def self.give_promotion_second_product(orderitem_count, foc_min_qty, promo_product, orderitem, sale_id)
puts "..... orderitem_count: " + orderitem_count.to_s + " / foc_min_qty: " + foc_min_qty.to_s + " /promo_product: " + promo_product + " orderitem: " + orderitem.to_s
byebug
promotion_qty = orderitem_count.to_i / foc_min_qty.to_i # get foc item qty
foc_qty = find_second_item_qty(sale_id, promo_product)
if (foc_qty < promotion_qty)
@@ -212,9 +229,11 @@ class Promotion < ApplicationRecord
saleObj = Sale.find_by_sale_id(sale_id)
itemList = combine_item(saleObj)
itemList.each do |item|
if item[0] == promo_item
return item[1]
end
item.each do |i|
if i[0] == promo_item
return i[1]
end
end
end
return 0
end

View File

@@ -158,6 +158,7 @@ class Sale < ApplicationRecord
#pull
sale_item.product_code = item.item_code
sale_item.item_instance_code = item.item_instance_code
sale_item.product_name = item.item_name
sale_item.product_alt_name = item.alt_name
sale_item.account_id = item.account_id
@@ -177,7 +178,7 @@ class Sale < ApplicationRecord
sale_item = SaleItem.new
sale_item.product_code = chargeObj.item_code
sale_item.product_name = dining_name.to_s + " ( " + dining_time.to_s + " )"
# sale_item.account_id = item.account_id
sale_item.account_id = 0
sale_item.product_alt_name = "-"
sale_item.qty = 1
sale_item.unit_price = chargeObj.unit_price
@@ -186,7 +187,10 @@ class Sale < ApplicationRecord
sale_item.sale_id = self.id
sale_item.price = diningprice
sale_item.save
self.compute
# Re-calc
sale = Sale.find(self.id)
self.compute_by_sale_items(self.id, sale.sale_items, self.total_discount)
end
def update_item (item)
@@ -223,7 +227,9 @@ class Sale < ApplicationRecord
subtotal_price = subtotal_price + item.price
total_taxable = total_taxable + (item.taxable_price * item.qty)
end
apply_tax (total_taxable)
self.total_amount = subtotal_price
self.total_discount = total_discount
self.grand_total = (self.total_amount - self.total_discount) + self.total_tax
@@ -291,6 +297,8 @@ class Sale < ApplicationRecord
# Tax Re-Calculte
def compute_tax(sale, total_taxable, total_discount = 0)
shop = Shop.first();
#if tax is not apply create new record
SaleTax.where("sale_id='#{sale.sale_id}'").find_each do |existing_tax|
#delete existing and create new
@@ -321,7 +329,9 @@ class Sale < ApplicationRecord
total_tax_amount = total_tax_amount + sale_tax.tax_payable_amount
end
#new taxable amount is standard rule for step by step
# total_taxable = total_taxable + sale_tax.tax_payable_amount
if shop.calc_tax_order
total_taxable = total_taxable + sale_tax.tax_payable_amount
end
sale_tax.inclusive = tax.inclusive
sale_tax.save
@@ -334,6 +344,8 @@ class Sale < ApplicationRecord
# Tax Calculate
def apply_tax(total_taxable)
shop = Shop.first();
#if tax is not apply create new record
SaleTax.where("sale_id='#{self.sale_id}'").find_each do |existing_tax|
#delete existing and create new
@@ -345,7 +357,7 @@ class Sale < ApplicationRecord
tax_profiles = TaxProfile.all.order("order_by asc")
customer = Customer.find(self.customer_id)
puts customer
#Create new tax records
tax_profiles.each do |tax|
customer.tax_profiles.each do |cus_tax|
@@ -367,7 +379,9 @@ class Sale < ApplicationRecord
end
#new taxable amount is standard rule for step by step
# total_taxable = total_taxable + sale_tax.tax_payable_amount
if shop.calc_tax_order
total_taxable = total_taxable + sale_tax.tax_payable_amount
end
sale_tax.inclusive = tax.inclusive
sale_tax.save

View File

@@ -107,7 +107,17 @@ class SaleItem < ApplicationRecord
return price,type
end
# Check for Card Payment
def self.get_sale_payments_by_card(sale_payments)
# Check for Card Payment
sale_payments.each do |sp|
if sp.payment_method == "jcb" || sp.payment_method == "mpu" || sp.payment_method == "visa" || sp.payment_method == "master"
return true;
end
end
end
# def self.get_overall_discount(sale_id)
# price = 0.0
# item=SaleItem.where("product_code=?", sale_id)

View File

@@ -263,6 +263,8 @@ class SalePayment < ApplicationRecord
end
def sale_update_payment_status(paid_amount)
puts paid_amount
puts "parid Masssssssssssssssssssssssssssssssssssssssss"
#update amount_outstanding
self.sale.amount_received = self.sale.amount_received.to_f + paid_amount.to_f
self.sale.save!

View File

@@ -1,17 +1,16 @@
class StockCheck < ApplicationRecord
has_many :stock_check_items
def create(user, eason, item_list)
def create(user, reason, item_list)
self.reason = reason
self.check_by = user.id
self.check_start = Time.now
self.check_end = Time.now
self.save
save
item_list.each do |item|
stockItem = StockCheckItem.new
stockItem.create(self.id,item)
stockItem.create(id, item)
end
return self
self
end
end

View File

@@ -1,5 +1,4 @@
class StockCheckItem < ApplicationRecord
belongs_to :stock_check
def create(stock_id, item)
@@ -33,4 +32,15 @@ class StockCheckItem < ApplicationRecord
return 'missing stock', stock_check_qty.to_i - journal_balance.to_i
end
end
def self.get_transaction(from, to, item_code)
transaction = all
if !from.nil? && !to.nil?
transaction = transaction.where('created_at between ? and ?', from, to)
end
if item_code.present?
transaction = transaction.where(item_code: item_code)
end
transaction
end
end

View File

@@ -1,8 +1,8 @@
class StockResultPdf < Prawn::Document
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
attr_accessor :label_width, :price_column_width, :page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size, :item_height, :qty_width, :total_width, :item_description_width, :text_width
def initialize(printer_settings,stockcheck, stockcheck_items,checker_name, shop_details)
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
def initialize(printer_settings, stockcheck, stockcheck_items, checker_name, shop_details)
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
self.page_height = printer_settings.page_height
self.margin = 5
self.price_width = 40
@@ -27,66 +27,68 @@ class StockResultPdf < Prawn::Document
self.header_font_size = 10
self.item_font_size = 8
header( shop_details)
header(shop_details)
stroke_horizontal_rule
detail(stockcheck,stockcheck_items, checker_name)
detail(stockcheck, stockcheck_items, checker_name)
end
def header (shop_details)
move_down 7
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size,:align => :center
text "#{shop_details.name}", :left_margin => -10, :size => self.header_font_size, :align => :center
move_down 5
text "#{shop_details.address}", :size => self.item_font_size,:align => :center
text "#{shop_details.address}", :size => self.item_font_size, :align => :center
# move_down self.item_height
move_down 5
text "#{shop_details.phone_no}", :size => self.item_font_size,:align => :center
text "#{shop_details.phone_no}", :size => self.item_font_size, :align => :center
move_down 5
stroke_horizontal_rule
end
def detail(stockcheck, stockcheck_items, checker_name)
move_down 7
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Checker : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
text "#{checker_name}" , :size => self.item_font_size,:align => :left
end
move_down 7
y_position = cursor
bounding_box([0, y_position], :width => self.label_width, :height => self.item_height) do
text "Checker : ", :size => self.item_font_size, :align => :left
end
bounding_box([self.label_width, y_position], :width => self.label_width, :height => self.item_height) do
text "#{checker_name}", :size => self.item_font_size, :align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Check Start Time : ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
text "#{ stockcheck.check_start.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0, y_position], :width => self.label_width, :height => self.item_height) do
text "Check Start Time : ", :size => self.item_font_size, :align => :left
end
bounding_box([self.label_width, y_position], :width => self.label_width, :height => self.item_height) do
text "#{ stockcheck.check_start.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }", :size => self.item_font_size, :align => :left
end
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
text "Check End Time ", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width => self.label_width, :height => self.item_height) do
text "#{ stockcheck.check_start.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }" , :size => self.item_font_size,:align => :left
end
y_position = cursor
bounding_box([0, y_position], :width => self.label_width, :height => self.item_height) do
text "Check End Time ", :size => self.item_font_size, :align => :left
end
bounding_box([self.label_width, y_position], :width => self.label_width, :height => self.item_height) do
text "#{ stockcheck.check_start.utc.getlocal.strftime('%d-%m-%Y %I:%M %p') }", :size => self.item_font_size, :align => :left
end
if stockcheck_items.length > 0
stockcheck_items.each do |st|
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
text "#{ st.item_code }", :size => self.item_font_size,:align => :left
end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{st.stock_count.to_i}" , :size => self.item_font_size,:align => :right
end
end
end
if stockcheck_items.length > 0
stockcheck_items.each do |st|
move_down 5
stroke_horizontal_rule
y_position = cursor
item_name = MenuItemInstance.get_item_name(st.item_code)
bounding_box([0, y_position], :width => self.item_description_width, :height => self.item_height) do
text item_name.to_s, :size => self.item_font_size, :align => :left
end
bounding_box([self.item_description_width, y_position], :width => self.label_width) do
text "#{st.stock_count.to_i}", :size => self.item_font_size, :align => :right
end
end
end
move_down 5
stroke_horizontal_rule
end
end

View File

@@ -92,9 +92,9 @@ json.options opt_format
json.instances item.menu_item_instances do |is|
# Convert id to name for attributes
instance_attr = []
is.item_attributes do |ia|
mItemAttr = MenuItemAttribute.find(is)
instance_attr.push(ia.name)
is.item_attributes.each do |ia|
# mItemAttr = MenuItemAttribute.find(is)
instance_attr.push(ia)
end
json.id is.id

View File

@@ -0,0 +1,8 @@
if(@attribute)
json.id @attribute.id
json.type @attribute.attribute_type
json.name @attribute.name
json.value @attribute.value
else
json.success false
end

View File

@@ -1,20 +1,3 @@
<div class="row">
<div class="col-md-4 col-sm-6 col-md-offset-4 col-sm-offset-3">
<% if current_login_employee.role = "admin" %>
<% elsif current_login_employee.role = "cashier" %>
<%= link_to "Cashier Station", origami_path %>
<% elsif current_login_employee = "account" %>
<%= link_to "Cashier Station", oishi_path %>
<% else %>
<%= link_to "Cashier Station", oishi_path %>
<% end %>
<% shop = Shop.first %>
</div>
</div>
<div class="row">
<div class="col-md-9 col-lg-9">
<h4><strong>Role Features</strong></h4>
@@ -205,14 +188,14 @@
<div class="card">
<div class="page-header center-text">
<h4 class="footer-header">
<%= shop.name %>
<%= @shop.name %>
</h4>
</div>
<div class="center-text">
<%= shop.address %>
<%= @shop.address %>
</div>
<div class="center-text">
<%= shop.phone_no %>
<%= @shop.phone_no %>
</div>
</div>
</div>

View File

@@ -22,11 +22,19 @@
%>
<tr>
<td><%= count %></td>
<td><%= item.item_code rescue ""%></td>
<td>
<% menu_item = MenuItemInstance.find_by_item_instance_code(item.item_code)%>
<% if menu_item.nil? %>
<%= Product.find_by_item_code(item.item_code).name rescue "-" %>
<% else %>
<%= menu_item.menu_item.name rescue "-" %>
- <%= menu_item.item_instance_name rescue "-" %>
<% end %>
</td>
<td><%= item.min_order_level %></td>
<td><%= item.max_stock_level %></td>
<td><%= item.created_by%></td>
<td><%= item.created_at%></td>
<td><%= Employee.find(item.created_by).name rescue '-' %></td>
<td><%= item.created_at.utc.getlocal.strftime("%e %b %Y %I:%M %p") rescue '-' %></td>
</tr>
<% end %>
</table>

View File

@@ -1,22 +1,27 @@
<div class="row">
<div class="row">
<div class="col-lg-10 col-md-10 col-sm-10">
<%= render 'inventory_list' %>
<%= render 'inventory_list' %>
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<%if current_login_employee.role == "administrator" || current_login_employee.role == "manager" %>
<button id="back" type="button" class="btn btn-block btn-primary"> Back </button>
<%end%>
<button id="stock_taking" type="button" class="btn btn-block btn-primary"> New Stock Taking </button>
<% if current_login_employee.role == "administrator" || current_login_employee.role == 'manager' %>
<button id="back" type="button" class="btn btn-block btn-primary"> Back</button>
<% end %>
<button id="stock_taking" type="button" class="btn btn-block btn-primary"> New Stock Taking</button>
<button id="stock_check_report" type="button" class="btn btn-block btn-primary"> Stock Check Report</button>
</div>
</div>
<script>
$('#stock_taking').on('click',function(){
window.location.href = '/inventory/stock_checks';
})
$('#stock_check_report').on('click', function(){
window.location.href = '';
})
$('#stock_taking').on('click', function () {
window.location.href = '<%= inventory_stock_checks_path %>';
});
$('#stock_check_report').on('click', function () {
window.location.href = '<%= reports_stock_check_index_path %>';
});
$('#back').on('click', function () {
window.location.href = '<%= dashboard_path %>';
});
</script>

View File

@@ -1,15 +1,84 @@
<%= simple_form_for([:inventory, @inventory_definition]) do |f| %>
<%= f.error_notification %>
<%= simple_form_for([:inventory,@inventory_definition]) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
<div class="row">
<% arr = MenuItem.active.order("name desc").pluck(:name, :item_code) %>
<% Product.order("name desc").pluck(:name, :item_code).each do |p| %>
<% arr.push(p) %>
<% end %>
<div class="col-md-3">
<label class="control-label"><abbr title="required">*</abbr> Item</label>
<select class="form-control item_code_place" id="item">
<% if !@inventory_definition.item_code.nil? %>
<% menuiteminstance = MenuItemInstance.find_by_item_instance_code(@inventory_definition.item_code) %>
<% if menuiteminstance.nil? %>
<% code = @inventory_definition.item_code %>
<% else %>
<% code = menuiteminstance.menu_item.item_code %>
<% end %>
<% end %>
<option value=""></option>
<% arr.each do |a| %>
<% if a[1] == code %>
<option value="<%= a[1] %>" selected><%= a[0] %></option>
<% else %>
<option value="<%= a[1] %>"><%= a[0] %></option>
<% end %>
<% end %>
</select>
</div>
<div class="form-inputs">
<%= f.input :item_code %>
<%= f.input :min_order_level %>
<%= f.input :max_stock_level %>
</div>
<% sample = [] %>
<% if @inventory_definition.item_code.nil? %>
<% if !MenuItemInstance.find_by_item_instance_code(@inventory_definition.item_code).nil? %>
<% sample = MenuItemInstance.where("item_instance_code=?", @inventory_definition.item_code).pluck(:item_instance_name, :item_instance_code) %>
<% else %>
<% sample = Product.where("item_code=?", @inventory_definition.item_code).pluck(:name, :item_code) %>
<% end %>
<% end %>
<div class="col-md-3"><%= f.input :item_code, collection: sample %></div>
</div>
<div class="form-actions">
<%= f.button :submit %>
</div>
<%= f.input :min_order_level %>
<%= f.input :max_stock_level %>
</div>
<div class="form-actions">
<%= link_to 'Back', inventory_path, class: 'btn btn-success' %>
<%= f.button :submit, class: 'btn btn-primary' %>
</div>
<% end %>
<script>
$(document).ready(function () {
$(".item_code_place").select2({
placeholder: 'Select Item'
});
$("select#inventory_definition_item_code").select2();
$(".item_code_place").on('change', function (event) {
var ajax_url = "<%= settings_find_item_instance_path %>";
var item_code = this.value;
$.ajax({
type: "GET",
url: ajax_url,
data: 'item_code=' + item_code,
success: function (result) {
$("#inventory_definition_item_code").empty();
var itemlist;
for (var i = 0; i < result.length; i++) {
itemlist = "<option value ='" + result[i][1] + "'>" + result[i][0] + "</option>";
$("select#inventory_definition_item_code").append(itemlist);
}
// $("select#inventory_definition_item_code").append(itemlist);
$("select#inventory_definition_item_code").select2();
}
});
});
});
</script>

View File

@@ -1,6 +1,10 @@
<h1>Editing Inventory Definition</h1>
<%= render 'form', inventory_definition: @inventory_definition %>
<%= link_to 'Show', @inventory_definition %> |
<%= link_to 'Back', inventory_definitions_path %>
<div class="span12">
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= root_path %>">Home</a></li>
<li><a href="<%= inventory_path %>">Product Inventory</a></li>
<li>Edit</li>
</ul>
</div>
<%= render 'form', inventory: @inventory_definition %>
</div>

View File

@@ -7,17 +7,29 @@
</div>
<div class="row">
<div class="col-md-12">
<input type='text' id='stock_check_reason' class='form-control' placeholder="Set Stock Check Reason" value=''></input>
</div>
<input type='text' id='stock_check_reason' class='form-control' placeholder="Set Stock Check Reason" value=''/>
</div>
</div>
<br>
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-2">
Product
Item
</div>
<div class="col-md-7">
<input type='text' class='form-control' placeholder="Product Name" id='product_sku' value=''></input>
<select class='form-control' id='product_sku'>
<option value="">Select Product</option>
<% @inventory_definitions.each do |id| %>
<option value="<%= id.item_code %>">
<% menu_item = MenuItemInstance.find_by_item_instance_code(id.item_code) %>
<% if menu_item.nil? %>
<%= Product.find_by_item_code(id.item_code).name rescue "-" %>
<% else %>
<%= menu_item.menu_item.name rescue '-' %> - <%= menu_item.item_instance_name rescue '-' %>
<% end %>
</option>
<% end %>
</select>
</div>
</div>
<br>
@@ -27,14 +39,14 @@
Qty
</div>
<div class="col-md-7">
<input type='text' class='form-control' placeholder="Qty" id='product_qty' value=''></input>
<input type='text' class='form-control' placeholder="Qty" id='product_qty' value=''/>
</div>
</div>
<br>
<div class="row">
<div class="col-md-4"></div>
<div class="col-md-7">
<button class="btn btn-primary form-control" id='save_to_stock_check'> Save </button>
<button class="btn btn-primary form-control" id='save_to_stock_check'> Save</button>
</div>
</div>
</div>
@@ -44,9 +56,10 @@
<div class="col-md-12">
<table class="table table-striped" id='stock_item'>
<tr>
<th>#</th>
<!--<th>#</th>-->
<th>Product</th>
<th>Balance</th>
<th></th>
</tr>
</table>
</div>
@@ -54,49 +67,69 @@
</div>
<div class="col-md-1">
<div class="row">
<button class="btn btn-primary pull-right form-control" style='margin-bottom:2px;' id='finish'> Finish </button>
<button class="btn btn-primary pull-right form-control" style='margin-bottom:2px;' id='back'> Back</button>
<button class="btn btn-primary pull-right form-control" style='margin-bottom:2px;' id='finish'> Finish</button>
</div>
</div>
</div>
<script>
var count = 0
$(document).ready(function () {
$('#product_sku').select2({
allowClear: true,
placeholder: 'Select Product'
})
});
$('#save_to_stock_check').on('click', function(){
count += 1;
product_sku = $('#product_sku').val();
product_qty = $('#product_qty').val();
var tr = '<tr>'
+ '<td>'+ count +'</td>'
+ '<td><input type=text value="'+ product_sku +'" id="item_sku_'+ count +'" name='+count+'></input></td>'
+ '<td><input type=text value="'+ product_qty +'" id="item_qty_'+ count +'" name='+count+'></input></td>'
+ '</tr>'
$('#stock_item').append(tr)
$('#product_sku').val('');
var count = 0;
$('#save_to_stock_check').on('click', function () {
count += 1;
product_sku = $('#product_sku').val();
product_qty = $('#product_qty').val();
product_name = $("#product_sku").find("option:selected").text();
var tr = '<tr>'
//+ '<td>' + count + '</td>'
+ '<td><input type=hidden value="' + product_sku + '" id="item_sku_' + count + '" name=' + count + '/>'
+ product_name + '</td>'
+ '<td><input type=text value="' + product_qty + '" id="item_qty_' + count + '" name=' + count + '/></td>'
+ '<td><input type=button value="X" id="item_remove_' + count + '" name=' + count + ' onclick="remove_row('+ count +')"/></td>'
+ '</tr>';
$('#stock_item').append(tr);
// $('#product_sku').val('');
$('#product_qty').val('');
})
});
$('#finish').on('click',function(){
var reason = $('#stock_check_reason').val();
var arr = [];
var jsonStr = ''
$('#finish').on('click', function () {
var reason = $('#stock_check_reason').val();
var arr = [];
var jsonStr = '';
for(var i = 1; i <= count; i++){
itemname = $('#item_sku_'+i ).val();
itemqty = $('#item_qty_'+i ).val();
arr.push({sku:itemname, qty:itemqty})
jsonStr = JSON.stringify(arr)
for (var i = 1; i <= count; i++) {
itemname = $('#item_sku_' + i).val();
itemqty = $('#item_qty_' + i).val();
if(itemname !== undefined){
arr.push({sku: itemname, qty: itemqty});
}
jsonStr = JSON.stringify(arr);
}
console.log(jsonStr);
$.ajax({
type: 'Post',
url: '<%= inventory_stock_check_save_path %>',
data: 'stock_item=' + jsonStr + '&reason=' + reason,
success: function (data) {
window.location.href = '/inventory/stock_checks/' + data['stock_id'];
}
})
});
$('#back').on('click', function () {
window.location.href = '/inventory';
});
function remove_row(row) {
$("#item_remove_"+row).parent().parent().remove();
}
console.log(jsonStr)
$.ajax({
type: 'Post',
url: '<%= inventory_stock_check_save_path %>',
data:'stock_item='+ jsonStr + '&reason='+ reason,
success:function(data){
alert(data['stock_id'])
window.location.href = '/inventory/stock_checks/'+ data['stock_id'];
}
})
})
</script>

View File

@@ -3,81 +3,96 @@
<div class="col-md-10">
<div class="row">
<div class="col-md-2">
Check by
Check by
</div>
<div class="col-md-8">
<%= @check.check_by %>
<%= Employee.find(@check.check_by).name rescue '' %>
</div>
</div>
<div class="row">
<div class="col-md-2">
Check At
Check At
</div>
<div class="col-md-8">
<%= @check.created_at %></div>
<%= @check.created_at.utc.getlocal.strftime("%e %b %Y %I:%M %p") rescue '-' %></div>
</div>
<div class="row">
<div class="col-md-2">
Reason
Reason
</div>
<div class="col-md-8">
<%= @check.reason %>
<%= @check.reason %>
</div>
</div>
<br>
<div class="row">
<table class="table table-striped col-md-12">
<tr>
<th>#</th>
<th>Product</th>
<th>Stock Count</th>
<th>Stock Balance</th>
<th>Different</th>
<th>Remark</th>
</tr>
<%
count = 0
@check.stock_check_items.each do |item|
count += 1
%>
<table class="table table-striped col-md-12">
<tr>
<td><%= count %></td>
<td><%= item.item_code %></td>
<td><%= item.stock_count %></td>
<td><%= item.stock_balance %></td>
<td><%= item.different %></td>
<td><%= item.remark %></td>
<th>#</th>
<th>Product</th>
<th>Stock Count</th>
<th>Stock Balance</th>
<th>Different</th>
<th>Remark</th>
</tr>
<% end %>
</table>
<%
count = 0
@check.stock_check_items.each do |item|
count += 1
%>
<tr>
<td><%= count %></td>
<td>
<% menu_item = MenuItemInstance.find_by_item_instance_code(item.item_code)%>
<% if menu_item.nil? %>
<%= Product.find_by_item_code(item.item_code).name rescue "-" %>
<% else %>
<%= menu_item.menu_item.name rescue "-" %>
- <%= menu_item.item_instance_name rescue "-" %>
<% end %>
</td>
<td><%= item.stock_count %></td>
<td><%= item.stock_balance %></td>
<td><%= item.different %></td>
<td><%= item.remark %></td>
</tr>
<% end %>
</table>
</div>
</div>
</div>
<div class="col-md-2">
<button id="back" type="button" class="btn btn-block btn-primary"> Back </button>
<button id="save_to_journal" type="button" class="btn btn-block btn-primary"> Save to Journal </button>
<button id="print" type="button" class="btn btn-block btn-primary"> Print </button>
<button id="back" type="button" class="btn btn-block btn-primary"> Back</button>
<button id="save_to_journal" type="button" class="btn btn-block btn-primary"> Save to Journal</button>
<button id="print" type="button" class="btn btn-block btn-primary"> Print</button>
</div>
</div>
<script>
$('#save_to_journal').on('click', function(){
check_id = $('#stock_check_id').val();
$.ajax({
type: 'post',
url: '<%= inventory_save_to_journal_path %>',
data: 'data='+ check_id,
success: function(){
alert('success')
}
})
})
$('#print').on('click',function(){
check_id = $('#stock_check_id').val();
$.ajax({
type: 'post',
url: '<%= inventory_print_stock_check_path %>',
data: 'stock_check_id='+ check_id
})
})
$('#save_to_journal').on('click', function () {
check_id = $('#stock_check_id').val();
$.ajax({
type: 'post',
url: '<%= inventory_save_to_journal_path %>',
data: 'data=' + check_id,
success: function () {
alert('Successfully saved to journal.');
window.location.href = '/inventory';
}
})
});
$('#print').on('click', function () {
check_id = $('#stock_check_id').val();
$.ajax({
type: 'post',
url: '<%= inventory_print_stock_check_path %>',
data: 'stock_check_id=' + check_id
})
});
$('#back').on('click', function () {
window.location.href = '/inventory';
});
</script>

View File

@@ -56,6 +56,7 @@
<li><%= link_to "Credit Sale Report", reports_credit_payment_index_path, :tabindex =>"-1" %></li>
<li><%= link_to "Void Sale Report", reports_void_sale_index_path, :tabindex =>"-1" %></li>
<li><%= link_to "Commission Report", reports_commission_index_path, :tabindex =>"-1" %></li>
<li><%= link_to "Stock Check Report", reports_stock_check_index_path, :tabindex =>"-1" %></li>
</ul>
</li>
<li class="navbar-nav mr-auto">

View File

@@ -0,0 +1,38 @@
<div class="container-fluid" style="min-height:30px; padding-left:0px !important; padding-right:0px !important; background:#54A5AF; margin-bottom:5px">
<div style="padding-top:5px;padding-bottom:5px;margin-left:15px; margin-right:15px;">
<div style="float:left;margin-top:3px;text-align:left;color:#ffffff">
<strong>Inventory - <span id="clockbox"></span></strong>
</div>
<div style="float:right; margin-top:3px; text-align:right;width:200px;color:#ffffff">
<% if current_login_employee %>
<%= current_login_employee.name %> | <%= link_to 'Logout', logout_path, method: :delete, data: { confirm: 'Are you sure?' } %>
<% end %>
</div>
</div>
</div>
<script type="text/javascript">
tday=new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
tmonth=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
function GetClock(){
var d=new Date();
var nday=d.getDay(),nmonth=d.getMonth(),ndate=d.getDate(),nyear=d.getFullYear();
var nhour=d.getHours(),nmin=d.getMinutes(),nsec=d.getSeconds(),ap;
if(nhour==0){ap=" AM";nhour=12;}
else if(nhour<12){ap=" AM";}
else if(nhour==12){ap=" PM";}
else if(nhour>12){ap=" PM";nhour-=12;}
if(nmin<=9) nmin="0"+nmin;
if(nsec<=9) nsec="0"+nsec;
document.getElementById('clockbox').innerHTML=""+tday[nday]+", "+tmonth[nmonth]+" "+ndate+", "+nyear+" "+nhour+":"+nmin+":"+nsec+ap+"";
}
window.onload=function(){
GetClock();
setInterval(GetClock,1000);
}
</script>
<div id="clockbox"></div>

View File

@@ -9,14 +9,14 @@
<title>SmartSales : Restaurant</title>
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'origami', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag 'inventory_definitions', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
<%= stylesheet_link_tag 'jquery-confirm', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'jquery-confirm', 'data-turbolinks-track': 'reload' %>
</head>
<body>
<%= render 'layouts/header_orgiami' %>
<%= render 'layouts/header_inventory' %>
<div class="container-fluid">
<% flash.each do |type, message| %>
<% if !flash["errors"]%>

View File

@@ -0,0 +1,51 @@
<% order.each do |qid|%>
<p class="hidden"><%=qid.order_queue_station_id%></p>
<div class="card queue_station">
<div class="card-block">
<h4 class="card-title">
<span class="order-zone-type"><%= qid.table_type %> - </span>
<span class="order-zone"><%= qid.zone %></span>
<small class="pull-right"><%= qid.order_id %></small>
</h4>
<h4>
<span class="order-item">
<%= qid.item_name %>
</span> [x
<span class="order-qty">
<%= qid.qty %>
</span> ]
</h4>
<p class="card-text item-options">
<%= qid.options == "[]"? "" : qid.options %>
</p>
<p class="card-text">
<small class="text-muted">Order at
<span class="order-at">
<%= qid.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %>
</span> -
<span class="order-by">
<%= qid.item_order_by %>
</span>
</small>
</p>
<p class="hidden order-customer"><%= qid.customer_name %></p>
<p class="hidden assigned-order-item"><%= qid.assigned_order_item_id %></p>
<div class="card-footer">
<button id="edit_<%= qid.assigned_order_item_id %>" class="btn btn-warning order-item order-item-edit">EDIT</button>
<button id="assigned_queue_<%= qid.assigned_order_item_id %>" class="btn btn-primary order-item order-complete">COMPLETE</button>
</div>
</div>
</div>
<%end%>
<style type="text/css">
.order-completed {
background-color: #CCFFDD;
}
.order-item {
width: 49%;
font-size: 18px;
margin: 0px 0px 5px 0px;
}
</style>

View File

@@ -1,58 +1,60 @@
<br>
<div class="row">
<div class="col-md-6">
<%= form_tag oqs_root_path, :method => :get do %>
<div class="form-group col-md-8">
<input type="text" name="filter" class="form-control input-md" placeholder="">
</div>
<div class="form-group col-md-1">
<input type="submit" value="Search" class='btn btn-primary btn-md'>
</div>
<% end %>
</div>
</div>
<hr>
<!-- Column One -->
<div class="row">
<div class="col-lg-8 col-md-8 col-sm-8">
<div class="col-lg-8 col-md-8 col-sm-8">
<div class="row">
<div class="col-md-12">
<%= form_tag oqs_root_path, :method => :get do %>
<div class="form-group col-md-6">
<input type="text" name="filter" class="form-control input-md" placeholder="">
</div>
<div class="form-group col-md-6">
<input type="submit" value="Search" class='btn btn-primary btn-md'>
</div>
<% end %>
</div>
</div>
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<!-- <li class="nav-item nav-search <%= @filter.to_s.length > 0? " " : "hide"%>">
<a class="nav-link <%= @filter.to_s.length > 0? "active" : " "%>" data-toggle="tab" href="#search" role="tab">Searching .. <span class="badge badge-pill badge-default" id="completed_count"><%= @queue_completed_item.length %></span></a>
</li> -->
<li class="nav-item nav-completed">
<a class="nav-link" data-toggle="tab" href="#completed" role="tab">Processed <span class="badge badge-pill badge-default" id="completed_count"><%= @queue_completed_item.length %></span></a>
<a class="nav-link active" data-toggle="tab" href="#completed" role="tab">Processed <span class="badge badge-pill badge-default" id="completed_count"><%= @queue_completed_item.length %></span></a>
</li>
<% # For Tab Disable for Station is inactive
status=""
i=0
@queue_stations.each do |qsi|
if qsi.is_active == false
status="disabled"
end %>
<li class="nav-item oqs_click" >
<p class="hidden oqs-id"><%= qsi.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab" <%= status %>>
<%= qsi.station_name %>
<% if @filter.nil? %>
<span class="badge badge-pill badge-default" id=""> <%= qsi.assigned_order_items.where("delivery_status=0").count %>
</span>
<%else%>
<span class="badge badge-pill badge-default" id="">
<% @count.each do |c|%>
<% if qsi.id == c.station_id %>
<%= c.total %>
<%end %>
<%end %>
</span>
<%end%>
<% if qsi.auto_print %>
<span>(ap)</span>
<% end %>
</a>
</li>
<li class="nav-item oqs_click" data-id="<%= qsi.id %>">
<p class="hidden oqs-id"><%= qsi.id %></p>
<a class="nav-link" data-id="<%= qsi.id %>" data-toggle="tab" href="" role="tab" <%= status %>>
<%= qsi.station_name %>
<% if @filter.nil? %>
<span class="badge badge-pill badge-default oqs_count<%= i%> oqs_count" data-id="<%= qsi.id %>"> <%= qsi.assigned_order_items.where("delivery_status=0 AND created_at >= '#{Time.now.beginning_of_day.utc}'").count %>
</span>
<%else%>
<span class="badge badge-pill badge-default" data-id="<%= qsi.id %>">
<% @count.each do |c|%>
<% if qsi.id == c.station_id %>
<%= c.total %>
<%end %>
<%end %>
</span>
<%end%>
<% if qsi.auto_print %>
<span>(ap)</span>
<% end %>
</a>
</li>
<% i+=1%>
<% end %>
</ul>
<!-- Nav tabs - End -->
@@ -107,9 +109,8 @@
<!-- End Panel 0 - Completed -->
<!--- Order Items -->
<div class="card-columns oqs_append" style="padding-top:10px; column-gap: 1.2rem;">
<div class="card-columns oqs_append" id="oqs_container" style="padding-top:10px; column-gap: 1.2rem;">
</div>
<!--- end of Items-->
</div>

View File

@@ -0,0 +1,117 @@
# Format for attributes json
attr_format = []
# Format for attributes json
if item.item_attributes.count > 0
item.item_attributes.each do|attr_id|
menu_attr = MenuItemAttribute.find(attr_id)
if attr_format.count == 0
attr_format.push({ type: menu_attr.attribute_type, values: [menu_attr.name] })
next
end
attr_format.each do |af|
if menu_attr.attribute_type.in? attr_format.map {|k| k[:type]}
if menu_attr.attribute_type == af[:type]
af[:values].push(menu_attr.name)
end
else
new_attr = {type: menu_attr.attribute_type, values: [ menu_attr.name ] }
attr_format.push(new_attr)
break
end
end
end
end
# Format for option json
opt_format = []
# Format for attributes json
if item.item_options.count > 0
item.item_options.each do|opt|
menu_opt = MenuItemOption.find(opt)
if opt_format.count == 0
opt_format.push({ type: menu_opt.option_type, values: [menu_opt.name] })
next
end
opt_format.each do |of|
if menu_opt.option_type.in? opt_format.map {|k| k[:type]}
if menu_opt.option_type == of[:type]
of[:values].push(menu_opt.name)
end
else
new_opt = {type: menu_opt.option_type, values: [ menu_opt.name ] }
opt_format.push(new_opt)
break
end
end
end
end
#Menu Item Information
json.id item.id
json.code item.item_code
json.name item.name
json.alt_name item.alt_name
json.image item.image_path.url
json.description item.description
json.information item.information
json.type item.type
json.account_id item.account_id
json.min_qty item.min_qty
json.is_available item.is_available
json.is_sub_item item.is_sub_item
json.unit item.unit
# Item Sets of Menu Item
json.item_sets item.item_sets do |its|
json.id its.id
json.name its.name
json.alt_name its.alt_name
json.min_selectable_qty its.min_selectable_qty
json.max_selectable_qty its.max_selectable_qty
json.instances its.menu_item_instances do |i|
json.id i.id
end
end
json.attributes attr_format
json.options opt_format
# json.min_selectable_item item.min_selectable_item
# json.max_selectable_item item.max_selectable_item
#Item instance
# if item.menu_item_instances.count == 1 then
# item_instance = item.menu_item_instances[0]
# json.price = item_instance.price
# json.is_available = item_instance.is_available
# json.is_on_promotion = item_instance.is_on_promotion
# json.promotion_price = item_instance.promotion_price
# json.item_attributes = item_instance.item_attributes
json.instances item.menu_item_instances do |is|
# Convert id to name for attributes
instance_attr = []
is.item_attributes.each do |ia|
mItemAttr = MenuItemAttribute.find(ia).name
instance_attr.push(mItemAttr)
end
json.id is.id
json.code is.item_instance_code
json.name is.item_instance_name
json.price is.price
json.is_available is.is_available
json.is_default is.is_default
json.is_on_promotion is.is_on_promotion
json.promotion_price is.promotion_price
json.values instance_attr
# json.item_sets is.item_sets
end
#Child Menu items
# if (item.children) then
# json.set_items item.children.each do |item|
# json.partial! 'api/restaurant/menu/menu_item', item: item
# end
# end

View File

@@ -4,7 +4,7 @@
<div class="col-lg-2 col-md-2 col-sm-2">
<ul class="nav nav-tabs flex-column" role="tablist" >
<% @menu.each do |menu| %>
<li class="nav-item menu_category" data-ref="<%= api_restaurant_menu_category_path menu.id%>">
<li class="nav-item menu_category" data-ref="<%= origami_get_menu_category_path menu.id%>">
<p class="hidden menu-id"><%= menu.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab"> <%= menu.name%></a>
@@ -19,9 +19,11 @@
</div>
<div class="col-md-3 col-lg-3 col-sm-3">
<button type="button" class="btn btn-primary btn-md pull-right" id="back"><i class="fa fa-arrow-left"></i> BACK </button> <br><br>
<div class="card-header">
<div>
<strong id="order-title">ORDER DETAILS </strong> | Table <%=@table_id%>
<strong id="order-title">ORDER DETAILS </strong> | Table <%=@table.name%>
<p class="hidden" id="table_id"><%=@table_id%></p>
<p class="hidden" id="table_type"><%=@table.type%></p>
<p class="hidden" id="booking_id"><%=@booking_id%></p>
@@ -106,12 +108,26 @@
<div class="modal-body">
<div class="row no-set-item">
<div class="col-md-5">
<p style="text-align: center;"> <%= image_tag "logo.png" ,width: '', height: '', :id => 'logo' %></p>
<br><br>
<div class="form-group">
<label class="col-md-6" style="margin-top:5px">Quantity</label>
<input type="number" name="qty" class="form-control col-md-5 input-number change_qty" id="change_qty" value="" min="1" max="100">
</div>
<p style="text-align: center;" id="modal_box_img"></p>
<!-- <label class="col-md-6" style="margin-top:5px">Quantity</label>
<input type="number" name="qty" class="form-control col-md-5 input-number change_qty" id="change_qty" value="" min="1" max="100"> -->
<div class="input-group">
<span class="input-group-btn">
<button type="button" class="btn btn-danger btn-number" value="-" id="minus">
<span class="glyphicon glyphicon-minus"></span>
</button>
</span>
<input type="text" value="1" id="count" class="change_qty form-control col-md-12 ">
<span class="input-group-btn">
<button type="button" class="btn btn-success btn-number" value="+" id="plus">
<span class="glyphicon glyphicon-plus"></span>
</button>
</span>
</div>
<p class="hidden" id="unit_price"></p>
<p class="hidden" id="instance_code"></p>
<p class="hidden" id="instance_name"></p>
@@ -155,10 +171,25 @@
<div class="row set-item">
<div class="col-md-4">
<p style="text-align: center;"> <%= image_tag "logo.png" ,width: '', height: '', :id => 'logo' %></p>
<div class="form-group">
<!-- <div class="form-group">
<label class="col-md-6" style="margin-top:5px">Quantity</label>
<input type="number" name="qty" class="form-control col-md-5 input-number change_qty" id="set_change_qty" value="" min="1" max="100">
</div>
</div> -->
<div class="input-group">
<span class="input-group-btn">
<button type="button" class="btn btn-danger btn-number" value="-" id="set_minus">
<span class="glyphicon glyphicon-minus"></span>
</button>
</span>
<input type="text" value="1" id="set_count" class="set_change_qty form-control col-md-12 ">
<span class="input-group-btn">
<button type="button" class="btn btn-success btn-number" value="+" id="set_plus">
<span class="glyphicon glyphicon-plus"></span>
</button>
</span>
</div>
<p class="hidden" id="set_unit_price"></p>
<p class="hidden" id="set_instance_code"></p>
<p class="hidden" id="set_instance_name"></p>

View File

@@ -0,0 +1,5 @@
if @menu.menu_items
json.menu_items @menu.menu_items do |item|
json.partial! 'origami/addorders/menu_item', item: item
end
end

View File

@@ -510,7 +510,7 @@ $(document).ready(function(){
url: ajax_url,
data: params,
success:function(result){
console.log(result)
if (result.status == "Success") {
type = 'green'
btn_color = 'btn-green'

View File

@@ -38,30 +38,30 @@
<div class="tab-pane dining active" id="tables" role="tabpanel">
<div class="card-columns">
<% @tables.each do |table| %>
<% if table.status == 'occupied' %>
<% if table.get_booking.nil? %>
<div class="card tables red text-white" data-id="<%= table.id %>">
<div class="card-block">
Zone <%= table.zone_id %> <br>
Table <%= table.name %> ( <%= table.seater %> Seat )
</div>
</div>
<% if table.status == 'occupied' %>
<% if table.get_booking.nil? %>
<div class="card tables red text-white" data-id="<%= table.id %>">
<div class="card-block">
Zone <%= table.zone_id %> <br>
Table <%= table.name %> ( <%= table.seater %> Seat )
</div>
</div>
<% else %>
<div class="card tables blue text-white" data-id="<%= table.id %>">
<div class="card-block">
Zone <%= table.zone_id %> <br>
Table <%= table.name %> ( <%= table.seater %> Seat )
</div>
</div>
<% end %>
<% else %>
<div class="card tables blue text-white" data-id="<%= table.id %>">
<div class="card tables green text-white table_<%= table.id %>" data-id="<%= table.id %>">
<div class="card-block">
Zone <%= table.zone_id %> <br>
Table <%= table.name %> ( <%= table.seater %> Seat )
Zone <%= table.zone_id %> <br>
Table <%= table.name %> ( <%= table.seater %> Seat )
</div>
</div>
<% end %>
<% else %>
<div class="card tables green text-white" data-id="<%= table.id %>">
<div class="card-block">
Zone <%= table.zone_id %> <br>
Table <%= table.name %> ( <%= table.seater %> Seat )
</div>
</div>
<% end %>
<% end %>
</div>
</div>
@@ -70,19 +70,19 @@
<div class="tab-pane dining" id="rooms" role="tabpanel">
<div class="card-columns">
<% @rooms.each do |room| %>
<% if room.status == 'occupied' %>
<div class="card rooms red text-white" data-id="<%= room.id %>">
<div class="card-block">
<%= room.name %>
</div>
</div>
<% else %>
<div class="card rooms green text-white" data-id="<%= room.id %>">
<div class="card-block">
<%= room.name %>
</div>
</div>
<% end %>
<% if room.status == 'occupied' %>
<div class="card rooms red text-white" data-id="<%= room.id %>">
<div class="card-block">
<%= room.name %>
</div>
</div>
<% else %>
<div class="card rooms green text-white table_<%= room.id %>" data-id="<%= room.id %>">
<div class="card-block">
<%= room.name %>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
@@ -98,13 +98,13 @@
</div>
<% end %>
</div>
</div>
</div>
<!-- tabs - End -->
</div>
<div class="col-lg-2 col-md-2 col-sm-2">
<button id="refreshbutton" type="button" class="btn btn-block radius-btn"> Refresh off </button>
<!-- <button id="refreshbutton" type="button" class="btn btn-block radius-btn"> Refresh off </button> -->
<button id="cash_in" type="button" class="btn btn-block btn-primary"> Cash In </button>
<button id="cash_out" type="button" class="btn btn-block btn-primary"> Cash Out </button>
<!-- Temporary Disabled -->
@@ -146,72 +146,72 @@ $(document).ready(function(){
})
});
$(function() {
var timer;
// $(function() {
// var timer;
function start() {
timer = setTimeout(function() { console.log("refresh");window.location.reload()}, 10000); //10000
};
// function start() {
// timer = setTimeout(function() { console.log("refresh");window.location.reload()}, 10000); //10000
// };
function stop() {
clearTimeout(timer);
};
// function stop() {
// clearTimeout(timer);
// };
if(localStorage.getItem("refreshflag") != null){
if (localStorage.getItem("refreshflag") == 0) {
$('#refreshbutton').html("Refresh off");
$('#refreshbutton').css("background-color","red");
stop();
}
else{
$('#refreshbutton').html("Refresh on");
$('#refreshbutton').css("background-color","green");
start();
}
}
else{
localStorage.setItem("refreshflag", 0);
}
var url = location.href;
if (location.href.slice(-1) == "/"){
url = url.substring(0, url.length - 1);
}
var arr = url.split("/");
// if(localStorage.getItem("refreshflag") != null){
// if (localStorage.getItem("refreshflag") == 0) {
// $('#refreshbutton').html("Refresh off");
// $('#refreshbutton').css("background-color","red");
// stop();
// }
// else{
// $('#refreshbutton').html("Refresh on");
// $('#refreshbutton').css("background-color","green");
// start();
// }
// }
// else{
// localStorage.setItem("refreshflag", 0);
// }
// var url = location.href;
// if (location.href.slice(-1) == "/"){
// url = url.substring(0, url.length - 1);
// }
// var arr = url.split("/");
if(arr[arr.length-1] != "origami"){
stop();
}
$('#refreshbutton').bind("click", function(){
if(localStorage.getItem("refreshflag") == "0"){
localStorage.setItem("refreshflag", 1);
$(this).html("Refresh on");
$(this).css("background-color","green");
// $(this).html("Auto Refresh on<span class='glyphicon glyphicon-ok'></span>");
start();
}
else{
stop();
localStorage.setItem("refreshflag", 0);
$(this).html("Refresh off");
$(this).css("background-color","red");
}
});
function refreshing(){
if(localStorage.getItem("refreshflag") == "0"){
localStorage.setItem("refreshflag", 1);
$(this).html("Refresh on");
$(this).css("background-color","green");
// $(this).html("Auto Refresh on<span class='glyphicon glyphicon-ok'></span>");
start();
}
else{
stop();
localStorage.setItem("refreshflag", 0);
$(this).html("Refresh off");
$(this).css("background-color","red");
}
}
});
// if(arr[arr.length-1] != "origami"){
// stop();
// }
// $('#refreshbutton').bind("click", function(){
// if(localStorage.getItem("refreshflag") == "0"){
// localStorage.setItem("refreshflag", 1);
// $(this).html("Refresh on");
// $(this).css("background-color","green");
// // $(this).html("Auto Refresh on<span class='glyphicon glyphicon-ok'></span>");
// start();
// }
// else{
// stop();
// localStorage.setItem("refreshflag", 0);
// $(this).html("Refresh off");
// $(this).css("background-color","red");
// }
// });
// function refreshing(){
// if(localStorage.getItem("refreshflag") == "0"){
// localStorage.setItem("refreshflag", 1);
// $(this).html("Refresh on");
// $(this).css("background-color","green");
// // $(this).html("Auto Refresh on<span class='glyphicon glyphicon-ok'></span>");
// start();
// }
// else{
// stop();
// localStorage.setItem("refreshflag", 0);
// $(this).html("Refresh off");
// $(this).css("background-color","red");
// }
// }
// });
$('#cash_in').on('click',function(){
window.location.href = '/origami/cash_ins/new';

View File

@@ -43,25 +43,26 @@
<% if table.status == 'occupied' %>
<% if table.get_booking.nil? %>
<div class="card tables red text-white" data-id="<%= table.id %>">
<div class="card tables red text-white table_<%= table.id %>" data-id="<%= table.id %>">
<div class="card-block">
<%= table.name %>
<span class="pull-right font-12"> billed</span>
<span class="pull-right font-12 new_text_<%= table.id %>"> billed</span>
<div style="font-size:12px;"></div>
</div>
</div>
<% else %>
<div class="card tables blue text-white" data-id="<%= table.id %>">
<div class="card tables blue text-white table_<%= table.id %>" data-id="<%= table.id %>">
<div class="card-block">
<%= table.name %>
<span class="pull-right font-12"> new</span>
<span class="pull-right font-12 new_text_<%= table.id %>"> new</span>
</div>
</div>
<% end %>
<% else %>
<div class="card tables green text-white" data-id="<%= table.id %>">
<div class="card tables green text-white table_<%= table.id %>" data-id="<%= table.id %>">
<div class="card-block">
<%= table.name %>
<span class="pull-right font-12 new_text_<%= table.id %> hide"> new</span>
</div>
</div>
<% end %>
@@ -75,20 +76,21 @@
<% @rooms.each do |room| %>
<% if room.status == 'occupied' %>
<div class="card rooms red text-white" data-id="<%= room.id %>">
<div class="card rooms red text-white table_<%= room.id %>" data-id="<%= room.id %>">
<div class="card-block">
<%= room.name %>
<% if room.get_booking.nil? %>
<span class="pull-right font-12"> billed</span>
<span class="pull-right font-12 new_text_<%= room.id %>"> billed</span>
<% else %>
<span class="pull-right font-12"> new</span>
<span class="pull-right font-12 new_text_<%= room.id %>"> new</span>
<% end %>
</div>
</div>
<% else %>
<div class="card rooms green text-white" data-id="<%= room.id %>">
<div class="card rooms green text-white table_<%= room.id %>" data-id="<%= room.id %>">
<div class="card-block">
<%= room.name %>
<span class="pull-right font-12 new_text_<%= room.id %> hide">
</div>
</div>
<% end %>
@@ -330,7 +332,7 @@
<button type="button" id="discount" class="btn btn-primary btn-block">Discount</button>
<button type="button" id="other-charges" class="btn btn-primary btn-block">Charges</button>
<button type="button" id="commissions" class="btn btn-primary btn-block">Commissions</button>
<button type="button" id="in_juties" class="btn btn-primary btn-block">In Juties</button>
<button type="button" id="in_duties" class="btn btn-primary btn-block">In Duties</button>
<button type="button" class="btn btn-primary btn-block" id='move' disabled="">Move</button>
<button type="button" id="request_bills" class="btn btn-primary btn-block" disabled> Req.Bill</button>
<button type="button" id="first_bill" class="btn btn-primary btn-block">First Bill</button>
@@ -577,9 +579,9 @@
window.location.href = '/origami/table/' + dining_id + "/sale/" + sale_id + "/load_commissioners";
});
$('#in_juties').on('click', function () {
$('#in_duties').on('click', function () {
var dining_id = "<%= @dining.id %>"
window.location.href = '/origami/assign_in_juty/'+ dining_id;
window.location.href = '/origami/assign_in_duty/'+ dining_id;
});
$('#void').on('click', function () {

View File

@@ -4,22 +4,11 @@
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-inputs">
<%= f.hidden_field :dinning_id, :value => @table.id, :class => "form-control col-md-4 " %>
<label>Dining Name:</label>
<%= @table.name %>
<br/>
<br/>
<label>Commissioner Name:</label>
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %>
<br/><br/>
<%= f.input :in_time, :placeholder => "From Date", :class => "form-control" %>
<%= f.input :out_time, :placeholder => "To Date", :class => "form-control" %>
</div><br>
<div class="form-group">

View File

@@ -1,4 +1,4 @@
<%= simple_form_for([:origami, @in_juty]) do |f| %>
<%= simple_form_for([:origami, @in_duty]) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">

View File

@@ -1,25 +1,18 @@
<%= simple_form_for @in_juty, :url => origami_index_in_juty_path(@table.id), :method => :post do |f| %>
<%= simple_form_for @in_duty, :url => origami_index_in_duty_path(@table.id), :method => :post do |f| %>
<span class="patch_method"></span>
<%= f.error_notification %>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-inputs">
<%= f.hidden_field :dinning_id, :value => @table.id, :class => "form-control col-md-4 " %>
<label>Dining Name:</label>
<%= @table.name %>
<br/>
<br/>
<br/><br/>
<%= f.hidden_field :dinning_id, :value => @table.id, :class => "form-control col-md-4 " %>
<label>Commissioner Name:</label>
<%= f.collection_select :commissioner_ids, Commissioner.all, :id, :name, {prompt: 'Select Commissioner'}, {class: 'form-control'} %>
<br/><br/>
<br/>
<%= f.input :in_time, :placeholder => "From Date", :class => "form-control" %>
<%= f.input :out_time, :placeholder => "To Date", :class => "form-control" %>
</div><br>
<div class="form-group">

View File

@@ -0,0 +1,2 @@
json.extract! in_duty, :id, :created_at, :updated_at
json.url in_duty_url(in_duty, format: :json)

View File

@@ -1,9 +1,9 @@
<div class="span12">
<div class="page-header">
<h3>Create In Juty</h3>
<h3>Create In Duty</h3>
</div>
<div class="col-md-3">
<%= simple_form_for([:origami,@in_juty]) do |f| %>
<%= simple_form_for([:origami,@in_duty]) do |f| %>
<%= f.error_notification %>
<div class="form-inputs">
@@ -22,10 +22,10 @@
<div class="form-actions">
<div class='row'>
<div class="col-md-2">
<%= link_to 'Back', origami_index_in_juty_path(@table.id), class: 'btn btn-success' %>
<%= link_to 'Back', origami_index_in_duty_path(@table.id), class: 'btn btn-success' %>
</div>
<div class="col-md-10">
<button type="button" class="btn btn-primary btn-block" id='in_juty'>Create In Juty</button>
<button type="button" class="btn btn-primary btn-block" id='in_duty'>Create In Duty</button>
</div>
</div>
</div>
@@ -45,18 +45,18 @@ $(function() {
$('.datepicker').css('cursor','pointer');
});
$('#in_juty').on('click', function () {
var ajax_url = "/origami/assign_in_juty";
var commissioner_ids = $('#in_juty_commissioner_ids').val();
var in_time = $('#in_juty_in_time').val();
var out_time = $('#in_juty_out_time').val();
$('#in_duty').on('click', function () {
var ajax_url = "/origami/assign_in_duty";
var commissioner_ids = $('#in_duty_commissioner_ids').val();
var in_time = $('#in_duty_in_time').val();
var out_time = $('#in_duty_out_time').val();
var dining_id = '<%= @table.id %>'
$.ajax({
type: "POST",
url: ajax_url,
data: 'dining_id=' + dining_id + "&commissioner_ids=" + commissioner_ids +'&in_time=' + in_time + "&out_time=" + out_time,
success: function (result) {
window.location.href = '/origami/assign_in_juty/'+ dining_id;
window.location.href = '/origami/assign_in_duty/'+ dining_id;
}
});
})

View File

@@ -2,9 +2,9 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li><a href="<%= origami_in_juties_path %>">In Juties</a></li>
<li><a href="<%= origami_in_duties_path %>">In Duties</a></li>
<li>Edit</li>
</ul>
</div>
<%= render 'form', in_juty: @in_juty %>
<%= render 'form', in_duty: @in_duty %>
</div>

View File

@@ -0,0 +1,6 @@
<div class="span12">
<div class="page-header">
<h3>Update In Duty</h3>
</div>
<%= render 'edit_in_duty', in_duty: @in_duty %>
</div>

View File

@@ -14,27 +14,27 @@
</thead>
<tbody>
<% @juties_in.each do |in_juty| %>
<tr class="injuty_tr" data-ref="<%= in_juty.id %>">
<% @duties_in.each do |in_duty| %>
<tr class="induty_tr" data-ref="<%= in_duty.id %>">
<td>
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check"></td>
<td><%= in_juty.dining_facility.name rescue '-' %></td>
<td><%= in_juty.commissioner.name rescue '-' %></td>
<td><%= in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
<td><%= in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
<td><%= link_to 'Destroy', origami_destroy_in_juty_path(in_juty.dining_facility.id, in_juty), method: :delete, data: {confirm: 'Are you sure?'} %></td>
<td><%= in_duty.dining_facility.name rescue '-' %></td>
<td><%= in_duty.commissioner.name rescue '-' %></td>
<td><%= in_duty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
<td><%= in_duty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
<td><%= link_to 'Destroy', origami_destroy_in_duty_path(in_duty.dining_facility.id, in_duty), method: :delete, data: {confirm: 'Are you sure?'} %></td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @juties_in %>
<%= paginate @duties_in %>
</div>
<div class="col-md-4 partial">
<%= render 'form', in_juty: @in_juty, table: @table %>
<%= render 'form', in_duty: @in_duty, table: @table %>
</div>
<span style="float: right">
<%= link_to t('.new', :default => t("helpers.links.new")), new_origami_in_juty_path, :class => 'btn btn-primary btn-sm' %>
<%= link_to t('.new', :default => t("helpers.links.new")), new_origami_in_duty_path, :class => 'btn btn-primary btn-sm' %>
</span>
</div>
@@ -43,13 +43,13 @@
</div>
<script type="text/javascript">
$(document).on('click', ".injuty_tr", function () {
$(document).on('click', ".induty_tr", function () {
$(this).closest('tr').find('.checkbox_check').prop("checked", true);
var in_juty_id = $(this).attr('data-ref');
var in_duty_id = $(this).attr('data-ref');
var table_id = "<%= @table.id %>";
var url = "/origami/assign_in_juty/table/" + table_id + "/in_juty/" + in_juty_id + "/edit";
var url = "/origami/assign_in_duty/table/" + table_id + "/in_duty/" + in_duty_id + "/edit";
$.ajax({
type: "GET",
@@ -59,22 +59,22 @@
success: function (data) {
debugger;
$('.partial').empty().append(data);
// $('#in_juty_id').val(data.in_juty.id);
// $('#in_juty_commissioner_ids').val(data.commissioner.id);
// $('#in_juty_in_time').val(data.in_juty.in_time);
// $('#in_juty_out_time').val(data.in_juty.out_time);
// $('#in_duty_id').val(data.in_duty.id);
// $('#in_duty_commissioner_ids').val(data.commissioner.id);
// $('#in_duty_in_time').val(data.in_duty.in_time);
// $('#in_duty_out_time').val(data.in_duty.out_time);
//
// $('#update').removeAttr('disabled').val('');
// $('#update').attr('value', 'Update');
// $('#create').attr('disabled', 'disabled');
//
// $("#new_in_juty").attr('class', 'simple_form edit_in_juty');
// var id = "edit_in_juty_" + in_juty_id;
// $("#new_in_juty").attr('id', id);
// $("#new_in_duty").attr('class', 'simple_form edit_in_duty');
// var id = "edit_in_duty_" + in_duty_id;
// $("#new_in_duty").attr('id', id);
//
// $(".edit_in_juty").attr('id', id);
// $(".edit_in_juty").attr('action', '/origami/edit_in_juty/' + $('#in_juty_id').val());
// $(".edit_in_juty").attr('action', '/origami/edit_in_juty/' + $('#in_juty_id').val());
// $(".edit_in_duty").attr('id', id);
// $(".edit_in_duty").attr('action', '/origami/edit_in_duty/' + $('#in_duty_id').val());
// $(".edit_in_duty").attr('action', '/origami/edit_in_duty/' + $('#in_duty_id').val());
// $(".patch_method").html('<input type="hidden" name="_method" value="patch">');
// setInterval(function () {

View File

@@ -0,0 +1 @@
json.array! @in_duties, partial: 'in_duties/in_duty', as: :in_duty

View File

@@ -1,6 +1,10 @@
<div class="row">
<div class="col-md-8">
<div class="col-md-7">
<label>Dining Name:</label>
<%= @table.name %>
<br/>
<table class="table table-striped">
<thead>
<tr>
@@ -14,40 +18,40 @@
</thead>
<tbody>
<% @juties_in.each do |in_juty| %>
<tr class="injuty_tr" data-ref="<%= in_juty.id %>">
<% @duties_in.each do |in_duty| %>
<tr class="induty_tr" data-ref="<%= in_duty.id %>">
<td>
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check"></td>
<td><%= in_juty.dining_facility.name rescue '-' %></td>
<td><%= in_juty.commissioner.name rescue '-' %></td>
<td><%= in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
<td><%= in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
<td><%= link_to 'Remove', origami_destroy_in_juty_path(in_juty.dining_facility.id, in_juty), method: :delete, data: {confirm: 'Are you sure?'} %></td>
<td><%= in_duty.dining_facility.name rescue '-' %></td>
<td><%= in_duty.commissioner.name rescue '-' %></td>
<td><%= in_duty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
<td><%= in_duty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
<td><%= link_to 'Remove', origami_destroy_in_duty_path(in_duty.dining_facility.id, in_duty), method: :delete, data: {confirm: 'Are you sure?'} %></td>
</tr>
<% end %>
</tbody>
</table>
<%= paginate @juties_in %>
<%= paginate @duties_in %>
</div>
<div class="col-md-4 partial">
<%= render 'form', in_juty: @in_juty, table: @table %>
<%= render 'form', in_duty: @in_duty, table: @table %>
</div>
<div class="col-md-1">
<button type="button" class="form-control btn btn-primary btn-block" id='back'>Back</button>
<button class="form-control btn btn-info btn-block" id="reset">New</button>
</div>
</div>
<div class="row">
&nbsp;&nbsp;<button type="button" class="col-md-1 btn btn-primary btn-block" id='back'>Back</button>&nbsp;&nbsp;
<button class="col-md-1 btn btn-info" id="reset">New</button>
</div>
<script type="text/javascript">
$(document).on('click', ".injuty_tr", function () {
$(document).on('click', ".induty_tr", function () {
$(this).closest('tr').find('.checkbox_check').prop("checked", true);
var in_juty_id = $(this).attr('data-ref');
var in_duty_id = $(this).attr('data-ref');
var table_id = "<%= @table.id %>";
var url = "/origami/assign_in_juty/table/" + table_id + "/in_juty/" + in_juty_id + "/edit";
var url = "/origami/assign_in_duty/table/" + table_id + "/in_duty/" + in_duty_id + "/edit";
$.ajax({
type: "GET",
@@ -57,22 +61,22 @@
success: function (data) {
debugger;
$('.partial').empty().append(data);
// $('#in_juty_id').val(data.in_juty.id);
// $('#in_juty_commissioner_ids').val(data.commissioner.id);
// $('#in_juty_in_time').val(data.in_juty.in_time);
// $('#in_juty_out_time').val(data.in_juty.out_time);
// $('#in_duty_id').val(data.in_duty.id);
// $('#in_duty_commissioner_ids').val(data.commissioner.id);
// $('#in_duty_in_time').val(data.in_duty.in_time);
// $('#in_duty_out_time').val(data.in_duty.out_time);
//
// $('#update').removeAttr('disabled').val('');
// $('#update').attr('value', 'Update');
// $('#create').attr('disabled', 'disabled');
//
// $("#new_in_juty").attr('class', 'simple_form edit_in_juty');
// var id = "edit_in_juty_" + in_juty_id;
// $("#new_in_juty").attr('id', id);
// $("#new_in_duty").attr('class', 'simple_form edit_in_duty');
// var id = "edit_in_duty_" + in_duty_id;
// $("#new_in_duty").attr('id', id);
//
// $(".edit_in_juty").attr('id', id);
// $(".edit_in_juty").attr('action', '/origami/edit_in_juty/' + $('#in_juty_id').val());
// $(".edit_in_juty").attr('action', '/origami/edit_in_juty/' + $('#in_juty_id').val());
// $(".edit_in_duty").attr('id', id);
// $(".edit_in_duty").attr('action', '/origami/edit_in_duty/' + $('#in_duty_id').val());
// $(".edit_in_duty").attr('action', '/origami/edit_in_duty/' + $('#in_duty_id').val());
// $(".patch_method").html('<input type="hidden" name="_method" value="patch">');
// setInterval(function () {
@@ -87,14 +91,14 @@
});
$('#reset').click(function () {
var url = "<%= new_origami_in_juty_path %>";
var url = "<%= new_origami_in_duty_path %>";
$.ajax({
type: "GET",
url: url,
data: { table_id: <%= @table.id %> },
success: function (data) {
$('.partial').empty().append(data);
$('.injuty_tr > td > .checkbox_check').prop("checked", false);
$('.induty_tr > td > .checkbox_check').prop("checked", false);
}
});
});

View File

@@ -2,9 +2,9 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li><a href="<%= origami_in_juties_path %>">In Juties</a></li>
<li><a href="<%= origami_in_juties_path %>">In Duties</a></li>
<li>New</li>
</ul>
</div>
<%= render 'form', in_juty: @in_juty, table: @table %>
<%= render 'form', in_duty: @in_duty, table: @table %>
</div>

View File

@@ -1,7 +1,7 @@
<div class="page-header">
<ul class="breadcrumb">
<li><a href="<%= origami_root_path %>">Home</a></li>
<li><a href="<%= origami_in_juties_path %>">In Juties</a></li>
<li><a href="<%= origami_in_duties_path %>">In Duties</a></li>
<span style="float: right">
</span>
@@ -9,34 +9,34 @@
</div>
<div class="card">
<div class="card-block">
<h4 class="card-title">In Juty</h4>
<h4 class="card-title">In Duty</h4>
<table class="table">
<tbody>
<tr>
<td style="width:20%">Dining Facility Name</td>
<td><%= @in_juty.dining_facility.name%></td>
<td><%= @in_duty.dining_facility.name%></td>
</tr>
<tr>
<td style="width:20%">Commissioner Name</td>
<td>
<%= @in_juty.commissioner.name rescue '-' %>
<%= @in_duty.commissioner.name rescue '-' %>
</td>
</tr>
<tr>
<td style="width:20%">In Time</td>
<td><%= @in_juty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
<td><%= @in_duty.in_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
</tr>
<tr>
<td style="width:20%">Out Time</td>
<td><%= @in_juty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
<td><%= @in_duty.out_time.utc.getlocal.strftime("%Y-%m-%d/%I:%M %p") rescue '-' %></td>
</tr>
</tbody>
</table>
<%= link_to 'Back', origami_in_juties_path, class: 'btn btn-success' %>
<%= link_to 'Edit', edit_origami_in_juty_path(@in_juty), class: 'btn btn-info' %>
<%= link_to 'Destroy', origami_in_juty_path(@in_juty), method: :delete, data: {confirm: 'Are you sure?'}, class: 'btn btn-danger' %>
<%= link_to 'Back', origami_in_duties_path, class: 'btn btn-success' %>
<%= link_to 'Edit', edit_origami_in_duty_path(@in_duty), class: 'btn btn-info' %>
<%= link_to 'Destroy', origami_in_duty_path(@in_duty), method: :delete, data: {confirm: 'Are you sure?'}, class: 'btn btn-danger' %>
</div>
</div>

View File

@@ -0,0 +1 @@
json.partial! "in_duties/in_duty", in_duty: @in_duty

View File

@@ -1,2 +0,0 @@
json.extract! in_juty, :id, :created_at, :updated_at
json.url in_juty_url(in_juty, format: :json)

View File

@@ -1,6 +0,0 @@
<div class="span12">
<div class="page-header">
<h3>Update In Juty</h3>
</div>
<%= render 'edit_in_juty', in_juty: @in_juty %>
</div>

View File

@@ -1 +0,0 @@
json.array! @in_juties, partial: 'in_juties/in_juty', as: :in_juty

View File

@@ -1 +0,0 @@
json.partial! "in_juties/in_juty", in_juty: @in_juty

View File

@@ -7,163 +7,197 @@
<h2>JCB</h2>
</div>
</div>
<div class="card" style="margin-top:10px;padding-top:20px;">
<div class="rebate-form">
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">You can pay up to </label>
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@can_jcb %>" data-member-value="">
</div>
<hr>
<span class="hidden" id="membership_id"><%= @membership_id%></span>
<span class="hidden" id="member_discount"><%= @member_discount%></span>
<span class="hidden" id="sub-total"><%= @sub_total%></span>
<div class="card" style="margin-top:10px;padding-top:20px;">
<div class="rebate-form">
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">You can pay up to </label>
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@can_jcb %>" data-member-value="">
</div>
<% if @jcbcount != 0 %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Recent JCB paid amount </label>
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@jcbcount %>" data-member-value="">
</div>
<hr>
<hr>
</div>
<% if @jcbcount != 0 %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Recent JCB paid amount </label>
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@jcbcount %>" data-member-value="">
</div>
<% end %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Reference Number</label>
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
</div>
<hr>
</div>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Amount</label>
<div id="amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
</div>
<hr>
</div>
</div>
<hr>
</div>
<% end %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Reference Number</label>
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
</div>
<hr>
</div>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Amount</label>
<div id="amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
</div>
<hr>
</div>
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6" style="margin-top:75px;">
<div class="col-lg-6 col-md-6 col-sm-6" style="margin-top:75px;">
<div class="row">
<div class="col-lg-6 col-md-1 col-sm-1">
<div class="row bottom">
<div class=" cashier_number " data-value="1" data-type="num">1</div>
<div class=" cashier_number left" data-value="2" data-type="num">2</div>
<div class=" cashier_number left" data-value="3" data-type="num">3</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="4" data-type="num">4</div>
<div class=" cashier_number left" data-value="5" data-type="num">5</div>
<div class=" cashier_number left" data-value="6" data-type="num">6</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="7" data-type="num">7</div>
<div class=" cashier_number left" data-value="8" data-type="num">8</div>
<div class=" cashier_number left" data-value="9" data-type="num">9</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="0" data-type="num">0</div>
<div class=" cashier_number left" data-value="." data-type="num">.</div>
<div class=" cashier_number left" data-value="00" data-type="num">00</div>
</div>
<div class="row bottom">
<div class=" cashier_number green" data-type="nett" >Nett</div>
<div class=" cashier_number red left" data-type="del">Del</div>
<div class=" cashier_number orange left" data-type="clr">Clr</div>
</div>
</div>
<div class="col-lg-6 col-md-1 col-sm-1">
<div class="row bottom">
<div class="cashier_number long" data-value="1000" data-type="add">1000</div>
<div class="cashier_number long left" data-value="3000" data-type="add">3000</div>
</div>
<div class="row bottom">
<div class="cashier_number long" data-value="5000" data-type="add">5000</div>
<div class="cashier_number long left" data-value="10000" data-type="add">10000</div>
</div>
<div class="row bottom">
<div class="pay purple" id="jcb_pay">Pay</div>
</div>
</div>
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn btn-primary btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/payment/others_payment';"> Back </button>
<div class="row">
<div class="col-lg-6 col-md-1 col-sm-1">
<div class="row bottom">
<div class=" cashier_number " data-value="1" data-type="num">1</div>
<div class=" cashier_number left" data-value="2" data-type="num">2</div>
<div class=" cashier_number left" data-value="3" data-type="num">3</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="4" data-type="num">4</div>
<div class=" cashier_number left" data-value="5" data-type="num">5</div>
<div class=" cashier_number left" data-value="6" data-type="num">6</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="7" data-type="num">7</div>
<div class=" cashier_number left" data-value="8" data-type="num">8</div>
<div class=" cashier_number left" data-value="9" data-type="num">9</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="0" data-type="num">0</div>
<div class=" cashier_number left" data-value="." data-type="num">.</div>
<div class=" cashier_number left" data-value="00" data-type="num">00</div>
</div>
<div class="row bottom">
<div class=" cashier_number green" data-type="nett" >Nett</div>
<div class=" cashier_number red left" data-type="del">Del</div>
<div class=" cashier_number orange left" data-type="clr">Clr</div>
</div>
</div>
<div class="col-lg-6 col-md-1 col-sm-1">
<div class="row bottom">
<div class="cashier_number long" data-value="1000" data-type="add">1000</div>
<div class="cashier_number long left" data-value="3000" data-type="add">3000</div>
</div>
<div class="row bottom">
<div class="cashier_number long" data-value="5000" data-type="add">5000</div>
<div class="cashier_number long left" data-value="10000" data-type="add">10000</div>
</div>
<div class="row bottom">
<div class="pay purple" id="jcb_pay">Pay</div>
</div>
</div>
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn btn-primary btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/payment/others_payment';"> Back </button>
</div>
</div>
<script>
$(document).ready(function() {
$(document).ready(function() {
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_jcb %>") - parseFloat(localStorage.getItem("cash")));
}
});
else {
$('#validamount').attr("value",parseFloat("<%= @can_jcb %>") - parseFloat(localStorage.getItem("cash")));
}
});
// number key pad
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
event.preventDefault();
if(event.handled !== true) {
var original_value;
original_value = $('#amount').text();
event.stopPropagation();
event.preventDefault();
if(event.handled !== true) {
var original_value;
original_value = $('#amount').text();
var input_value = $(this).attr("data-value");
var input_value = $(this).attr("data-value");
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
if (original_value == "0.0"){
$('#amount').text(input_value);
}else{
$('#amount').append(input_value);
}
break;
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
if (original_value == "0.0"){
$('#amount').text(input_value);
}else{
$('#amount').append(input_value);
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#amount').html(amount);
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#amount').html(amount);
break;
case 'clr':
$('#amount').html("0.0");
break;
case 'del' :
var cash=$('#amount').text();
$('#amount').text(cash.substr(0,cash.length-1));
break;
case 'nett':
var remain_amount = $('#validamount').val();
$('#amount').text(remain_amount);
break;
break;
case 'clr':
$('#amount').html("0.0");
break;
case 'del' :
var cash=$('#amount').text();
$('#amount').text(cash.substr(0,cash.length-1));
break;
case 'nett':
var remain_amount = $('#validamount').val();
$('#amount').text(remain_amount);
break;
}
event.handled = true;
} else {
return false;
}
}
event.handled = true;
} else {
return false;
}
});
$('#jcb_pay').on('click',function(){
var amount = $('#amount').text();
var sale_id = "<%= @sale_id %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){
$('#jcb_pay').on('click',function(){
var amount = $('#amount').text();
var sale_id = "<%= @sale_id %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){
//start member discount 5% by pay card
var sub_total = $('#sub-total').text();
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
if (member_id && member_discount) {
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// success:function(result){
// }
});
}
//end member discount
$.ajax({type: "POST",
url: "<%= origami_payment_jcb_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
alert("Payment success")
window.location.href = '/origami/sale/'+ sale_id + "/payment";
}
}
url: "<%= origami_payment_jcb_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
$.confirm({
title: 'Infomation!',
content: 'Payment Successfully',
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
action: function(){
window.location.href = '/origami/sale/'+ sale_id + "/payment";
}
}
}
});
}
}
});
}else{
alert("Paid Amount is over!");
}
})
}else{
$.alert({
title: 'Alert!',
content: "Paid Amount is over!",
type: 'red',
typeAnimated: true,
btnClass: 'btn-danger',
});
}
})
</script>

View File

@@ -7,160 +7,194 @@
<h2>Master</h2>
</div>
</div>
<div class="card" style="margin-top:10px;padding-top:20px;">
<div class="rebate-form">
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">You can pay up to </label>
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@can_master %>" data-member-value="">
</div>
<hr>
</div>
<% if @mastercount != 0 %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Recent Master paid amount </label>
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@mastercount %>" data-member-value="">
</div>
<hr>
</div>
<% end %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Reference Number</label>
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
</div>
<hr>
</div>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Amount</label>
<div id="amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
</div>
<hr>
</div>
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6" style="margin-top:75px;">
<div class="row">
<div class="col-lg-6 col-md-1 col-sm-1">
<div class="row bottom">
<div class=" cashier_number " data-value="1" data-type="num">1</div>
<div class=" cashier_number left" data-value="2" data-type="num">2</div>
<div class=" cashier_number left" data-value="3" data-type="num">3</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="4" data-type="num">4</div>
<div class=" cashier_number left" data-value="5" data-type="num">5</div>
<div class=" cashier_number left" data-value="6" data-type="num">6</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="7" data-type="num">7</div>
<div class=" cashier_number left" data-value="8" data-type="num">8</div>
<div class=" cashier_number left" data-value="9" data-type="num">9</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="0" data-type="num">0</div>
<div class=" cashier_number left" data-value="." data-type="num">.</div>
<div class=" cashier_number left" data-value="00" data-type="num">00</div>
</div>
<div class="row bottom">
<div class=" cashier_number green" data-type="nett" >Nett</div>
<div class=" cashier_number red left" data-type="del">Del</div>
<div class=" cashier_number orange left" data-type="clr">Clr</div>
</div>
</div>
<div class="col-lg-6 col-md-1 col-sm-1">
<div class="row bottom">
<div class="cashier_number long" data-value="1000" data-type="add">1000</div>
<div class="cashier_number long left" data-value="3000" data-type="add">3000</div>
</div>
<div class="row bottom">
<div class="cashier_number long" data-value="5000" data-type="add">5000</div>
<div class="cashier_number long left" data-value="10000" data-type="add">10000</div>
</div>
<div class="row bottom">
<div class="pay purple" id="master_pay">Pay</div>
</div>
</div>
<span class="hidden" id="membership_id"><%= @membership_id%></span>
<span class="hidden" id="member_discount"><%= @member_discount%></span>
<span class="hidden" id="sub-total"><%= @sub_total%></span>
<div class="card" style="margin-top:10px;padding-top:20px;">
<div class="rebate-form">
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">You can pay up to </label>
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@can_master %>" data-member-value="">
</div>
<hr>
</div>
<% if @mastercount != 0 %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Recent Master paid amount </label>
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@mastercount %>" data-member-value="">
</div>
<hr>
</div>
<% end %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Reference Number</label>
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
</div>
<hr>
</div>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Amount</label>
<div id="amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
</div>
<hr>
</div>
</div>
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn btn-primary btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/payment/others_payment';"> Back </button>
</div>
<div class="col-lg-6 col-md-6 col-sm-6" style="margin-top:75px;">
<div class="row">
<div class="col-lg-6 col-md-1 col-sm-1">
<div class="row bottom">
<div class=" cashier_number " data-value="1" data-type="num">1</div>
<div class=" cashier_number left" data-value="2" data-type="num">2</div>
<div class=" cashier_number left" data-value="3" data-type="num">3</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="4" data-type="num">4</div>
<div class=" cashier_number left" data-value="5" data-type="num">5</div>
<div class=" cashier_number left" data-value="6" data-type="num">6</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="7" data-type="num">7</div>
<div class=" cashier_number left" data-value="8" data-type="num">8</div>
<div class=" cashier_number left" data-value="9" data-type="num">9</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="0" data-type="num">0</div>
<div class=" cashier_number left" data-value="." data-type="num">.</div>
<div class=" cashier_number left" data-value="00" data-type="num">00</div>
</div>
<div class="row bottom">
<div class=" cashier_number green" data-type="nett" >Nett</div>
<div class=" cashier_number red left" data-type="del">Del</div>
<div class=" cashier_number orange left" data-type="clr">Clr</div>
</div>
</div>
<div class="col-lg-6 col-md-1 col-sm-1">
<div class="row bottom">
<div class="cashier_number long" data-value="1000" data-type="add">1000</div>
<div class="cashier_number long left" data-value="3000" data-type="add">3000</div>
</div>
<div class="row bottom">
<div class="cashier_number long" data-value="5000" data-type="add">5000</div>
<div class="cashier_number long left" data-value="10000" data-type="add">10000</div>
</div>
<div class="row bottom">
<div class="pay purple" id="master_pay">Pay</div>
</div>
</div>
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn btn-primary btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/payment/others_payment';"> Back </button>
</div>
</div>
<script>
$(document).ready(function() {
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_master %>") - parseFloat(localStorage.getItem("cash")));
}
});
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
event.preventDefault();
if(event.handled !== true) {
var original_value;
original_value = $('#amount').text();
$(document).ready(function() {
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_master %>") - parseFloat(localStorage.getItem("cash")));
}
});
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
event.preventDefault();
if(event.handled !== true) {
var original_value;
original_value = $('#amount').text();
var input_value = $(this).attr("data-value");
var input_value = $(this).attr("data-value");
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
if (original_value == "0.0"){
$('#amount').text(input_value);
}else{
$('#amount').append(input_value);
}
break;
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
if (original_value == "0.0"){
$('#amount').text(input_value);
}else{
$('#amount').append(input_value);
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#amount').html(amount);
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#amount').html(amount);
break;
case 'clr':
$('#amount').html("0.0");
break;
case 'del' :
var cash=$('#amount').text();
$('#amount').text(cash.substr(0,cash.length-1));
break;
case 'nett':
var remain_amount = $('#validamount').val();
$('#amount').text(remain_amount);
break;
break;
case 'clr':
$('#amount').html("0.0");
break;
case 'del' :
var cash=$('#amount').text();
$('#amount').text(cash.substr(0,cash.length-1));
break;
case 'nett':
var remain_amount = $('#validamount').val();
$('#amount').text(remain_amount);
break;
}
event.handled = true;
} else {
return false;
}
}
event.handled = true;
} else {
return false;
}
});
$('#master_pay').on('click',function(){
var amount = $('#amount').text();
var sale_id = "<%= @sale_id %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){
$.ajax({type: "POST",
url: "<%= origami_payment_master_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
alert("Payment success")
window.location.href = '/origami/sale/'+ sale_id + "/payment";
}
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){
//start member discount 5% by pay card
var sub_total = $('#sub-total').text();
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
if (member_id && member_discount) {
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// success:function(result){
// }
});
}
});
}else{
alert("Paid Amount is over!");
}
//end member discount
$.ajax({type: "POST",
url: "<%= origami_payment_master_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
$.confirm({
title: 'Infomation!',
content: 'Payment Successfully',
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
action: function(){
window.location.href = '/origami/sale/'+ sale_id + "/payment";
}
}
}
});
}
}
});
}else{
$.alert({
title: 'Alert!',
content: "Paid Amount is over!",
type: 'red',
typeAnimated: true,
btnClass: 'btn-danger',
});
}
})
</script>

View File

@@ -218,8 +218,20 @@ $(document).ready(function(){
$(this).addClass('selected-item');
var dining_name = $(this).attr("data-name");
var dining_id = $(this).attr("data-id");
$('#moved').text(" ' " + dining_name + " ' ")
$('#change_table_value').val(dining_id);
var change_from = "<%= @dining.id %>";
if (dining_id == change_from) {
$.alert({
title: 'Alert!',
content: 'Please Select Another Table',
type: 'red',
typeAnimated: true,
btnClass: 'btn-danger',
});
}else{
$('#moved').text(" ' " + dining_name + " ' ")
$('#change_table_value').val(dining_id);
}
})
$(".rooms").on('click', function(){
@@ -227,8 +239,19 @@ $(document).ready(function(){
$(this).addClass('selected-item');
var dining_name = $(this).attr("data-name");
var dining_id = $(this).attr("data-id");
$('#moved').text(dining_name)
$('#change_table_value').val(dining_id);
var change_from = "<%= @dining.id %>";
if (dining_id == change_from) {
$.alert({
title: 'Alert!',
content: 'Please Select Another Table',
type: 'red',
typeAnimated: true,
btnClass: 'btn-danger',
});
}else{
$('#moved').text(dining_name)
$('#change_table_value').val(dining_id);
}
})
$('#move_table').on('click',function(){

View File

@@ -7,160 +7,195 @@
<h2>MPU</h2>
</div>
</div>
<div class="card" style="margin-top:10px;padding-top:20px;">
<div class="rebate-form">
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">You can pay up to </label>
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@can_mpu %>" data-member-value="">
</div>
<hr>
</div>
<% if @mpucount != 0 %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Recent MPU paid amount </label>
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@mpucount %>" data-member-value="">
</div>
<hr>
</div>
<% end %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Reference Number</label>
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
</div>
<hr>
</div>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Amount</label>
<div id="amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
</div>
<hr>
</div>
</div>
<span class="hidden" id="membership_id"><%= @membership_id%></span>
<span class="hidden" id="member_discount"><%= @member_discount%></span>
<span class="hidden" id="sub-total"><%= @sub_total%></span>
<div class="card" style="margin-top:10px;padding-top:20px;">
<div class="rebate-form">
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">You can pay up to </label>
<input type="text" name="validamount" id="validamount" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@can_mpu %>" data-member-value="">
</div>
<hr>
</div>
<% if @mpucount != 0 %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Recent MPU paid amount </label>
<input type="text" name="" id="" class="form-control col-lg-7 col-md-7 col-sm-7" readonly="" value="<%=@mpucount %>" data-member-value="">
</div>
<hr>
</div>
<% end %>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Reference Number</label>
<input type="text" name="valid_amount" id="valid_amount" class="form-control col-lg-7 col-md-7 col-sm-7" value="" data-value="<%=@sale_id %>" data-member-value="">
</div>
<hr>
</div>
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="col-lg-4 col-md-4 col-sm-4">Amount</label>
<div id="amount" class="form-control col-lg-7 col-md-7 col-sm-7">0.0</div>
</div>
<hr>
</div>
</div>
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6" style="margin-top:75px;">
<div class="col-lg-6 col-md-6 col-sm-6" style="margin-top:75px;">
<div class="row">
<div class="col-lg-6 col-md-1 col-sm-1">
<div class="row bottom">
<div class=" cashier_number " data-value="1" data-type="num">1</div>
<div class=" cashier_number left" data-value="2" data-type="num">2</div>
<div class=" cashier_number left" data-value="3" data-type="num">3</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="4" data-type="num">4</div>
<div class=" cashier_number left" data-value="5" data-type="num">5</div>
<div class=" cashier_number left" data-value="6" data-type="num">6</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="7" data-type="num">7</div>
<div class=" cashier_number left" data-value="8" data-type="num">8</div>
<div class=" cashier_number left" data-value="9" data-type="num">9</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="0" data-type="num">0</div>
<div class=" cashier_number left" data-value="." data-type="num">.</div>
<div class=" cashier_number left" data-value="00" data-type="num">00</div>
</div>
<div class="row bottom">
<div class=" cashier_number green" data-type="nett" >Nett</div>
<div class=" cashier_number red left" data-type="del">Del</div>
<div class=" cashier_number orange left" data-type="clr">Clr</div>
</div>
</div>
<div class="col-lg-6 col-md-1 col-sm-1">
<div class="row bottom">
<div class="cashier_number long" data-value="1000" data-type="add">1000</div>
<div class="cashier_number long left" data-value="3000" data-type="add">3000</div>
</div>
<div class="row bottom">
<div class="cashier_number long" data-value="5000" data-type="add">5000</div>
<div class="cashier_number long left" data-value="10000" data-type="add">10000</div>
</div>
<div class="row bottom">
<div class="pay purple" id="mpu_pay">Pay</div>
</div>
</div>
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn btn-primary btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/payment/others_payment';"> Back </button>
<div class="row">
<div class="col-lg-6 col-md-1 col-sm-1">
<div class="row bottom">
<div class=" cashier_number " data-value="1" data-type="num">1</div>
<div class=" cashier_number left" data-value="2" data-type="num">2</div>
<div class=" cashier_number left" data-value="3" data-type="num">3</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="4" data-type="num">4</div>
<div class=" cashier_number left" data-value="5" data-type="num">5</div>
<div class=" cashier_number left" data-value="6" data-type="num">6</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="7" data-type="num">7</div>
<div class=" cashier_number left" data-value="8" data-type="num">8</div>
<div class=" cashier_number left" data-value="9" data-type="num">9</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="0" data-type="num">0</div>
<div class=" cashier_number left" data-value="." data-type="num">.</div>
<div class=" cashier_number left" data-value="00" data-type="num">00</div>
</div>
<div class="row bottom">
<div class=" cashier_number green" data-type="nett" >Nett</div>
<div class=" cashier_number red left" data-type="del">Del</div>
<div class=" cashier_number orange left" data-type="clr">Clr</div>
</div>
</div>
<div class="col-lg-6 col-md-1 col-sm-1">
<div class="row bottom">
<div class="cashier_number long" data-value="1000" data-type="add">1000</div>
<div class="cashier_number long left" data-value="3000" data-type="add">3000</div>
</div>
<div class="row bottom">
<div class="cashier_number long" data-value="5000" data-type="add">5000</div>
<div class="cashier_number long left" data-value="10000" data-type="add">10000</div>
</div>
<div class="row bottom">
<div class="pay purple" id="mpu_pay">Pay</div>
</div>
</div>
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn btn-primary btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/payment/others_payment';"> Back </button>
</div>
</div>
<script>
$(document).ready(function() {
$(document).ready(function() {
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#validamount').attr("value",parseFloat("<%= @can_mpu %>") - parseFloat(localStorage.getItem("cash")));
}
});
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
event.preventDefault();
if(event.handled !== true) {
var original_value;
original_value = $('#amount').text();
else {
$('#validamount').attr("value",parseFloat("<%= @can_mpu %>") - parseFloat(localStorage.getItem("cash")));
}
});
$(document).on('click', '.cashier_number', function(event){
event.stopPropagation();
event.preventDefault();
if(event.handled !== true) {
var original_value;
original_value = $('#amount').text();
var input_value = $(this).attr("data-value");
var input_value = $(this).attr("data-value");
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
if (original_value == "0.0"){
$('#amount').text(input_value);
}else{
$('#amount').append(input_value);
}
break;
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
if (original_value == "0.0"){
$('#amount').text(input_value);
}else{
$('#amount').append(input_value);
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#amount').html(amount);
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#amount').html(amount);
break;
case 'clr':
$('#amount').html("0.0");
break;
case 'del' :
var cash=$('#amount').text();
$('#amount').text(cash.substr(0,cash.length-1));
break;
case 'nett':
var remain_amount = $('#validamount').val();
$('#amount').text(remain_amount);
break;
break;
case 'clr':
$('#amount').html("0.0");
break;
case 'del' :
var cash=$('#amount').text();
$('#amount').text(cash.substr(0,cash.length-1));
break;
case 'nett':
var remain_amount = $('#validamount').val();
$('#amount').text(remain_amount);
break;
}
event.handled = true;
} else {
return false;
}
});
$('#mpu_pay').on('click',function(){
var amount = $('#amount').text();
var sale_id = "<%= @sale_id %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){
$.ajax({type: "POST",
url: "<%= origami_payment_mpu_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
alert("Payment success")
window.location.href = '/origami/sale/'+ sale_id + "/payment";
}
}
});
}else{
alert("Paid Amount is over!")
}
event.handled = true;
} else {
return false;
}
})
</script>
});
$('#mpu_pay').on('click',function(){
var amount = $('#amount').text();
var sale_id = "<%= @sale_id %>";
if(parseFloat(amount) <= parseFloat($("#validamount").attr("value")) ){
//start member discount 5% by pay card
var sub_total = $('#sub-total').text();
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
if (member_id && member_discount) {
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':true },
// success:function(result){
// }
});
}
//end member discount
//Mpu Payment
$.ajax({type: "POST",
url: "<%= origami_payment_mpu_path %>",
data: "amount="+ amount + "&sale_id="+ sale_id,
success:function(result){
if(result){
$.confirm({
title: 'Infomation!',
content: 'Payment Successfully',
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
action: function(){
window.location.href = '/origami/sale/'+ sale_id + "/payment";
}
}
}
});
}
}
});
}else{
$.alert({
title: 'Alert!',
content: "Paid Amount is over!",
type: 'red',
typeAnimated: true,
btnClass: 'btn-danger',
});
}
})
</script>

View File

@@ -38,7 +38,7 @@
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @tables.each do |table| %>
<% if table.status == 'occupied' %>
<div class="card tables red text-white" data-id="<%= table.id %>">
<div class="card tables red text-white table_<%= table.id %>" data-id="<%= table.id %>">
<div class="card-block">
<%= table.name %>
<% if table.get_booking.nil? %>

View File

@@ -1,8 +1,8 @@
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<div id="loading"></div>
</div>
<div class="row">
<div class="col-lg-6 col-md-6 col-sm-3">
<div class="col-lg-6 col-md-6 col-sm-3">
<div class="card" >
<div class="card-header">
<div id="order-title">
@@ -17,6 +17,8 @@
</tr>
<tr>
<td style="width:50%;"><strong>Customer :</strong> <%= @sale_data.customer.name%></td>
<span class="hidden" id="membership_id"><%= @sale_data.customer.membership_id%></span>
<span class="hidden" id="member_discount"><%= @member_discount%></span>
<td style="width:50%;"><strong>Customer ID :</strong> <%= @sale_data.customer.customer_id%></td>
</tr>
</table>
@@ -26,82 +28,82 @@
<div class="card-title">
<table >
<!-- <thead> -->
<tr>
<th style="width:5%">#</th>
<th style="width:76%;">Items</th>
<th style="width:20%;">QTY</td>
<tr>
<th style="width:5%">#</th>
<th style="width:76%;">Items</th>
<th style="width:20%;">QTY</td>
<th style="width:20%;">Price</td>
</tr>
<!-- </thead> -->
</table>
</div>
<div id="table-details" class="card-text" style="min-height:400px; max-height:400px; overflow-x:scroll">
<table class="table" id="append-table">
<tbody>
<% sub_total = 0
count = 0
%>
<% @sale_data.sale_items.each do |sale_item|
count += 1
%>
</tr>
<!-- </thead> -->
</table>
</div>
<div id="table-details" class="card-text" style="min-height:400px; max-height:400px; overflow-x:scroll">
<table class="table" id="append-table">
<tbody>
<% sub_total = 0
count = 0
%>
<% @sale_data.sale_items.each do |sale_item|
count += 1
%>
<% sub_total += sale_item.price%>
<tr>
<% sub_total += sale_item.price%>
<tr>
<td><%= count %></td>
<td style="width:60%; text-align:left">
<span id="item-name-price"><%=sale_item.product_name%>@<%=sale_item.unit_price%></span>
</td>
<td style="width:20%; text-align:right">
<span id="item-qty"><%=sale_item.qty%></span>
</td>
<td style="width:20%; text-align:right">
<span id="item-total-price"><%=(sale_item.price)%></span>
</td>
</tr>
<%end %>
</tbody>
</table>
</div>
<div class="card-footer">
<table class="table" style="margin-bottom:0px">
<tfooter>
<tr>
<td style="width:80%; text-align:left; border-top:none"><strong>Sub Total</strong></td>
<td style="width:20%; text-align:right; border-top:none"><strong><span id="sub-total"><%=sub_total%></span></strong></td>
</tr>
<tr>
<%if @sale_data.discount_type == 'member_discount'%>
<td style="width:80%; text-align:left; border-top:none"><strong>Member Discount:</strong></td>
<%else%>
<td style="width:80%; text-align:left; border-top:none"><strong>(Discount)</strong></td>
<%end%>
<td style="width:20%; text-align:right; border-top:none"><strong><span>(<%=@sale_data.total_discount rescue 0%>)</span></strong></td>
</tr>
<tr>
<td style="width:80%; text-align:left; border-top:none"><strong>Tax</strong></td>
<td style="width:20%; text-align:right; border-top:none"><strong><span><%=@sale_data.total_tax rescue 0%></span></strong></td>
</tr>
<tr>
<td style="width:80%; text-align:left; border-top:none"><strong>Rounding Adj:</strong></td>
<td style="width:20%; text-align:right; border-top:none"><strong><span><%=@sale_data.rounding_adjustment rescue 0%></span></strong></td>
</tr>
<tr>
<td style="width:80%; text-align:left; border-top:none"><strong>Grand Total</strong></td>
<td style="width:20%; text-align:right; border-top:none"><strong><span><%=@sale_data.grand_total rescue 0%></span></strong></td>
</tr>
<%if @balance > 0%>
<tr>
<td style="width:80%; text-align:left; border-top:none"><strong><%= @accountable_type %></strong></td>
<td style="width:20%; text-align:right; border-top:none"><strong><span><%=@balance%></span></strong></td>
</tr>
<% end %>
</tfooter>
</table>
</div>
<div style='text-align:center;margin-top:20px'>
<span id="item-name-price"><%=sale_item.product_name%>@<%=sale_item.unit_price%></span>
</td>
<td style="width:20%; text-align:right">
<span id="item-qty"><%=sale_item.qty%></span>
</td>
<td style="width:20%; text-align:right">
<span id="item-total-price"><%=(sale_item.price)%></span>
</td>
</tr>
<%end %>
</tbody>
</table>
</div>
<div class="card-footer">
<table class="table" style="margin-bottom:0px">
<tfooter>
<tr>
<td style="width:80%; text-align:left; border-top:none"><strong>Sub Total</strong></td>
<td style="width:20%; text-align:right; border-top:none"><strong><span id="sub-total"><%=sub_total%></span></strong></td>
</tr>
<tr>
<%if @sale_data.discount_type == 'member_discount'%>
<td style="width:80%; text-align:left; border-top:none"><strong>Member Discount:</strong></td>
<%else%>
<td style="width:80%; text-align:left; border-top:none"><strong>(Discount)</strong></td>
<%end%>
<td style="width:20%; text-align:right; border-top:none"><strong><span>(<%=@sale_data.total_discount rescue 0%>)</span></strong></td>
</tr>
<tr>
<td style="width:80%; text-align:left; border-top:none"><strong>Tax</strong></td>
<td style="width:20%; text-align:right; border-top:none"><strong><span><%=@sale_data.total_tax rescue 0%></span></strong></td>
</tr>
<tr>
<td style="width:80%; text-align:left; border-top:none"><strong>Rounding Adj:</strong></td>
<td style="width:20%; text-align:right; border-top:none"><strong><span><%=@sale_data.rounding_adjustment rescue 0%></span></strong></td>
</tr>
<tr>
<td style="width:80%; text-align:left; border-top:none"><strong>Grand Total</strong></td>
<td style="width:20%; text-align:right; border-top:none"><strong><span><%=@sale_data.grand_total rescue 0%></span></strong></td>
</tr>
<%if @balance > 0%>
<tr>
<td style="width:80%; text-align:left; border-top:none"><strong><%= @accountable_type %></strong></td>
<td style="width:20%; text-align:right; border-top:none"><strong><span><%=@balance%></span></strong></td>
</tr>
<% end %>
</tfooter>
</table>
</div>
<div style='text-align:center;margin-top:20px'>
<!-- <INPUT TYPE="Button" class='btn btn-primary' VALUE="Reprint" onClick="" style='width:120px'/>
<INPUT TYPE="Submit" class='btn btn-primary' VALUE="CANCEL" action="origami/index" style='width:120px'/> -->
<INPUT TYPE="Submit" class='btn btn-primary' VALUE="CANCEL" action="origami/index" style='width:120px'/> -->
</div>
</div>
</div>
@@ -123,159 +125,159 @@
<div class="col-md-4" id="credit"><%= @credit %></div>
</div>
<% if @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0%>
<div class="row payment other-payment-color" id="card_payment" >
<div class="col-md-8">Other Payments</div>
<div class="col-md-4" id="others"><%= @other %></div>
</div>
<div class="row payment other-payment-color" id="card_payment" >
<div class="col-md-8">Other Payments</div>
<div class="col-md-4" id="others"><%= @other %></div>
</div>
<% else %>
<div class="row payment other-payment-color" id="card_payment" >
<div class="col-md-12">Other Payments</div>
</div>
<div class="row payment other-payment-color" id="card_payment" >
<div class="col-md-12">Other Payments</div>
</div>
<% end %>
<!-- mpu -->
<% if @other != 0.0 %>
<div class="row payment other-payment-color" style="line-height:30px;height: 30px;margin-bottom: 0px;">
<div class="col-md-5"></div>
<div class="col-md-3">MPU</div>
<div class="col-md-4" id="others"><%= @other %></div>
</div>
<% else %>
<div class="row" style="display:none">
<div class="col-md-5"></div>
<div class="col-md-3">MPU</div>
<div class="col-md-4" id="others">0.0</div>
</div>
<% end %>
<!-- paypar -->
<% if @ppamount != 0.0 %>
<div class="row payment other-payment-color" style="line-height:30px;height: 30px;margin-bottom: 0px;">
<div class="col-md-5"></div>
<div class="col-md-3">Redeem</div>
<div class="col-md-4" id="ppamount"><%= @ppamount %></div>
</div>
<% else %>
<div class="row" style="display:none">
<div class="col-md-5"></div>
<div class="col-md-3">Redeem</div>
<div class="col-md-4" id="ppamount">0.0</div>
</div>
<% end %>
<!-- Visa -->
<% if @visacount != 0.0 %>
<div class="row payment other-payment-color" style="line-height:30px;height: 30px;margin-bottom: 0px;">
<div class="col-md-5"></div>
<div class="col-md-3">Visa</div>
<div class="col-md-4" id="visacount"><%= @visacount %></div>
</div>
<% else %>
<div class="row" style="display:none">
<div class="col-md-5"></div>
<div class="col-md-3">Visa</div>
<div class="col-md-4" id="visacount">0.0</div>
</div>
<% end %>
<!-- JCB -->
<% if @jcbcount != 0.0 %>
<div class="row payment other-payment-color" style="line-height:30px;height: 30px;margin-bottom: 0px;">
<div class="col-md-5"></div>
<div class="col-md-3">JCB</div>
<div class="col-md-4" id="jcbcount"><%= @jcbcount %></div>
</div>
<% else %>
<div class="row" style="display:none">
<div class="col-md-5"></div>
<div class="col-md-3">JCB</div>
<div class="col-md-4" id="jcbcount">0.0</div>
</div>
<% end %>
<!-- Master -->
<% if @mastercount != 0.0 %>
<div class="row payment other-payment-color" style="line-height:30px;height: 30px;margin-bottom: 0px;">
<div class="col-md-5"></div>
<div class="col-md-3">Master</div>
<div class="col-md-4" id="mastercount"><%= @mastercount %></div>
</div>
<% else %>
<div class="row" style="display:none">
<div class="col-md-5"></div>
<div class="col-md-3">Master</div>
<div class="col-md-4" id="mastercount">0.0</div>
</div>
<% end %>
<br>
<!-- mpu -->
<% if @other != 0.0 %>
<div class="row payment other-payment-color" style="line-height:30px;height: 30px;margin-bottom: 0px;">
<div class="col-md-5"></div>
<div class="col-md-3">MPU</div>
<div class="col-md-4 mpu is_card" id="others"><%= @other %></div>
</div>
<% else %>
<div class="row" style="display:none">
<div class="col-md-5"></div>
<div class="col-md-3">MPU</div>
<div class="col-md-4" id="others">0.0</div>
</div>
<% end %>
<!-- paypar -->
<% if @ppamount != 0.0 %>
<div class="row payment other-payment-color" style="line-height:30px;height: 30px;margin-bottom: 0px;">
<div class="col-md-5"></div>
<div class="col-md-3">Redeem</div>
<div class="col-md-4" id="ppamount"><%= @ppamount %></div>
</div>
<% else %>
<div class="row" style="display:none">
<div class="col-md-5"></div>
<div class="col-md-3">Redeem</div>
<div class="col-md-4" id="ppamount">0.0</div>
</div>
<% end %>
<!-- Visa -->
<% if @visacount != 0.0 %>
<div class="row payment other-payment-color" style="line-height:30px;height: 30px;margin-bottom: 0px;">
<div class="col-md-5"></div>
<div class="col-md-3">Visa</div>
<div class="col-md-4 visa is_card" id="visacount"><%= @visacount %></div>
</div>
<% else %>
<div class="row" style="display:none">
<div class="col-md-5"></div>
<div class="col-md-3">Visa</div>
<div class="col-md-4" id="visacount">0.0</div>
</div>
<% end %>
<!-- JCB -->
<% if @jcbcount != 0.0 %>
<div class="row payment other-payment-color" style="line-height:30px;height: 30px;margin-bottom: 0px;">
<div class="col-md-5"></div>
<div class="col-md-3">JCB</div>
<div class="col-md-4 jcb is_card" id="jcbcount"><%= @jcbcount %></div>
</div>
<% else %>
<div class="row" style="display:none">
<div class="col-md-5"></div>
<div class="col-md-3">JCB</div>
<div class="col-md-4" id="jcbcount">0.0</div>
</div>
<% end %>
<!-- Master -->
<% if @mastercount != 0.0 %>
<div class="row payment other-payment-color" style="line-height:30px;height: 30px;margin-bottom: 0px;">
<div class="col-md-5"></div>
<div class="col-md-3">Master</div>
<div class="col-md-4 master is_card" id="mastercount"><%= @mastercount %></div>
</div>
<% else %>
<div class="row" style="display:none">
<div class="col-md-5"></div>
<div class="col-md-3">Master</div>
<div class="col-md-4" id="mastercount">0.0</div>
</div>
<% end %>
<br>
<div class="row">
<div class="col-md-8"><strong style="font-size:18px;">Balance</strong></div>
<div class="col-md-4"><strong style="font-size:18px;"><span id='balance'><%= @sale_data.grand_total %></span></strong></div>
</div>
<br>
<div class="row">
<div class="col-lg-6 col-md-1 col-sm-1">
<div class="row bottom">
<div class=" cashier_number " data-value="1" data-type="num">1</div>
<div class=" cashier_number left" data-value="2" data-type="num">2</div>
<div class=" cashier_number left" data-value="3" data-type="num">3</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="4" data-type="num">4</div>
<div class=" cashier_number left" data-value="5" data-type="num">5</div>
<div class=" cashier_number left" data-value="6" data-type="num">6</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="7" data-type="num">7</div>
<div class=" cashier_number left" data-value="8" data-type="num">8</div>
<div class=" cashier_number left" data-value="9" data-type="num">9</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="0" data-type="num">0</div>
<div class=" cashier_number left" data-value="." data-type="num">.</div>
<div class=" cashier_number left" data-value="00" data-type="num">00</div>
</div>
<div class="row bottom">
<div class=" cashier_number green" data-type="nett">Nett</div>
<div class=" cashier_number red left" data-type="del">Del</div>
<div class=" cashier_number orange left" data-type="clr">Clr</div>
</div>
</div>
<div class="col-lg-6 col-md-1 col-sm-1">
<div class="row bottom">
<div class="cashier_number long" data-value="1000" data-type="add">1000</div>
<div class="cashier_number long left" data-value="3000" data-type="add">3000</div>
</div>
<div class="row bottom">
<div class="cashier_number long" data-value="5000" data-type="add">5000</div>
<div class="cashier_number long left" data-value="10000" data-type="add">10000</div>
</div>
<div class="row bottom">
<div class="pay purple" id="pay">Pay</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-6 col-md-1 col-sm-1">
<div class="row bottom">
<div class=" cashier_number " data-value="1" data-type="num">1</div>
<div class=" cashier_number left" data-value="2" data-type="num">2</div>
<div class=" cashier_number left" data-value="3" data-type="num">3</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="4" data-type="num">4</div>
<div class=" cashier_number left" data-value="5" data-type="num">5</div>
<div class=" cashier_number left" data-value="6" data-type="num">6</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="7" data-type="num">7</div>
<div class=" cashier_number left" data-value="8" data-type="num">8</div>
<div class=" cashier_number left" data-value="9" data-type="num">9</div>
</div>
<div class="row bottom">
<div class=" cashier_number " data-value="0" data-type="num">0</div>
<div class=" cashier_number left" data-value="." data-type="num">.</div>
<div class=" cashier_number left" data-value="00" data-type="num">00</div>
</div>
<div class="row bottom">
<div class=" cashier_number green" data-type="nett">Nett</div>
<div class=" cashier_number red left" data-type="del">Del</div>
<div class=" cashier_number orange left" data-type="clr">Clr</div>
</div>
</div>
<div class="col-lg-6 col-md-1 col-sm-1">
<div class="row bottom">
<div class="cashier_number long" data-value="1000" data-type="add">1000</div>
<div class="cashier_number long left" data-value="3000" data-type="add">3000</div>
</div>
<div class="row bottom">
<div class="cashier_number long" data-value="5000" data-type="add">5000</div>
<div class="cashier_number long left" data-value="10000" data-type="add">10000</div>
</div>
<div class="row bottom">
<div class="pay purple" id="pay">Pay</div>
</div>
</div>
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- Waiter Buttons -->
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- Waiter Buttons -->
<button type="button" class="btn btn-primary btn-block" onclick="localStorage.removeItem('cash');window.location.href = '/origami';"> Back </button>
<button type="button" class="btn btn-primary btn-block" id="foc"> FOC </button>
<button type="button" class="btn btn-primary btn-block" id="void"> Void </button>
</div>
<button type="button" class="btn btn-primary btn-block" onclick="localStorage.removeItem('cash');window.location.href = '/origami';"> Back </button>
<button type="button" class="btn btn-primary btn-block" id="foc"> FOC </button>
<button type="button" class="btn btn-primary btn-block" id="void"> Void </button>
</div>
</div>
</div>
<script>
$(document).ready(function(){
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#cash').text(localStorage.getItem("cash"));
}
update_balance();
})
$(document).ready(function(){
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
else {
$('#cash').text(localStorage.getItem("cash"));
}
update_balance();
})
$(document).on('click', '.cashier_number', function(event){
if(event.handled !== true) {
$(document).on('click', '.cashier_number', function(event){
if(event.handled !== true) {
var original_value;
original_value = $('#cash').text();
@@ -293,79 +295,86 @@ $(document).on('click', '.cashier_number', function(event){
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#cash').text(amount);
update_balance();
var input_value = $(this).attr("data-value");
amount = parseInt(input_value) + parseInt(original_value);
$('#cash').text(amount);
update_balance();
break;
case 'del' :
var cash=$('#cash').text();
if(cash.length == 1)
$('#cash').text("0.0");
else
$('#cash').text(cash.substr(0,cash.length-1));
update_balance();
var cash=$('#cash').text();
if(cash.length == 1)
$('#cash').text("0.0");
else
$('#cash').text(cash.substr(0,cash.length-1));
update_balance();
break;
case 'clr':
$('#cash').text("0.0");
update_balance();
$('#cash').text("0.0");
update_balance();
break;
case 'nett':
var credit1 = $('#credit').text();
var card1 = $('#others').text();
var paypar1 = $('#ppamount').text();
var visa1 = $('#visacount').text();
var jcb1 = $('#jcbcount').text();
var master1 = $('#mastercount').text();
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1);
var total = $('#amount_due').text();
var amt = parseFloat(total) - othertotal;
$('#cash').text(amt);
update_balance();
var credit1 = $('#credit').text();
var card1 = $('#others').text();
var paypar1 = $('#ppamount').text();
var visa1 = $('#visacount').text();
var jcb1 = $('#jcbcount').text();
var master1 = $('#mastercount').text();
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1);
var total = $('#amount_due').text();
var amt = parseFloat(total) - othertotal;
$('#cash').text(amt);
update_balance();
break;
}
}
event.handled = true;
} else {
return false;
return false;
}
});
});
$( document ).ready(function() {
$( document ).ready(function() {
// Disable click event cash to prevent
$(".payment .cash-color").off('click');
$('#credit_payment').click(function() {
var sale_id = $('#sale_id').text();
window.location.href = '/origami/sale/'+ sale_id + "/payment/credit_payment"
return false;
});
window.location.href = '/origami/sale/'+ sale_id + "/payment/credit_payment"
return false;
});
$('#card_payment').click(function() {
$('#card_payment').click(function() {
localStorage.setItem("cash",$('#cash').text() );
var sale_id = $('#sale_id').text();
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment"
return false;
window.location.href = '/origami/sale/'+ sale_id + "/payment/others_payment"
return false;
});
$('#pay').click(function() {
$('#pay').click(function() {
$('#pay').text("Processing, Please wait!")
$( "#loading_wrapper" ).show();
$( "#loading_wrapper" ).show();
if($('#balance').text() > 0){
alert(" Insufficient Amount!")
$( "#loading_wrapper" ).hide();
}else{
var sale_id = $('#sale_id').text();
var item_row = $('.is_card');
if (item_row.length < 1) {
calculate_member_discount(sale_id);
}
if($('#balance').text() > 0){
alert(" Insufficient Amount!")
$( "#loading_wrapper" ).hide();
}else{
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
var sale_id = $('#sale_id').text();
$.ajax({type: "POST",
url: "<%= origami_payment_cash_path %>",
data: "cash="+ cash + "&sale_id=" + sale_id,
async: false,
success:function(result){
localStorage.removeItem("cash");
if (result.status) {
var msg = result.message;
@@ -380,24 +389,23 @@ $( document ).ready(function() {
content: 'Changed amount ' + $('#balance').text() * (-1),
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
text: 'Ok',
btnClass: 'btn-green',
action: function(){
window.location.href = '/origami';
}
}
}
});
}
else{
}else{
$('#pay').text("Pay")
$.confirm({
title: 'Infomation!',
content: 'Thank you !',
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
text: 'Ok',
btnClass: 'btn-green',
action: function(){
window.location.href = '/origami';
}
@@ -408,75 +416,91 @@ $( document ).ready(function() {
}
});
}
});
});
$('#void').on('click',function () {
$('#void').on('click',function () {
var sure = confirm("Are you sure want to Void");
if (sure == true) {
var sale_id = $('#sale_id').text();
var ajax_url = "/origami/sale/" + sale_id + '/void';
$.ajax({
type: 'POST',
url: ajax_url,
success: function () {
window.location.href = '/origami/';
}
})
var sale_id = $('#sale_id').text();
var ajax_url = "/origami/sale/" + sale_id + '/void';
$.ajax({
type: 'POST',
url: ajax_url,
success: function () {
window.location.href = '/origami/';
}
})
} else {
}
});
});
});
function update_balance(){
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#others').text();
var paypar = $('#ppamount').text();
var visa = $('#visacount').text();
var jcb = $('#jcbcount').text();
var master = $('#mastercount').text();
var amount_due = $('#amount_due').text();
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master)
var result = amount_due - total;
$('#balance').text(result.toFixed(2));
}
function update_balance(){
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#others').text();
var paypar = $('#ppamount').text();
var visa = $('#visacount').text();
var jcb = $('#jcbcount').text();
var master = $('#mastercount').text();
var amount_due = $('#amount_due').text();
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master)
var result = amount_due - total;
$('#balance').text(result.toFixed(2));
}
$('#foc').click(function() {
$( "#loading_wrapper" ).show();
$('#foc').click(function() {
$( "#loading_wrapper" ).show();
// payment
var cash = $('#amount_due').text();
var sub_total = $('#sub-total').text();
var sale_id = $('#sale_id').text();
var params = { 'cash':cash,'sale_id':sale_id,'sub_total':sub_total };
$.ajax({type: "POST",
url: "<%= origami_payment_foc_path %>",
data: params,
success:function(result){
$( "#loading_wrapper" ).hide();
if (cash > 0) {
$.confirm({
if (cash > 0) {
$.confirm({
title: 'Infomation!',
content: 'Thank you !',
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
text: 'Ok',
btnClass: 'btn-green',
action: function(){
window.location.href = '/origami';
}
}
}
});
}
}
}
});
});
function calculate_member_discount(sale_id) {
var sub_total = $('#sub-total').text();
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
});
if (member_id && member_discount) {
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':false },
async: false,
success:function(result){
}
});
}
}
</script>

View File

@@ -7,6 +7,7 @@
</div>
<div class="card-block">
<div class="card-columns" id="commissioners" style="float: left; padding-top:10px; column-gap: 1.2rem; min-height:600px; max-height:600px; overflow-x:scroll;">
<div style="color: gray"><i>* Select One Item</i></div>
<% @commissioners.each do |commissioner| %>
<div class="card tables green text-white commissioner" data-commissioner-id="<%= commissioner.id %>" data-commissioner-name="<%= commissioner.name %>">
<div class="card-block">
@@ -77,7 +78,7 @@
<%= sale_item.qty %>
</td>
<td class='unit_price' width="20%">
<%= sale_item.unit_price %>
<%= sale_item.price %>
</td>
<td class='commissioner' width="20%">
<% product_commission = ProductCommission.find_by_sale_item_id(sale_item.id) %>

Some files were not shown because too many files have changed in this diff Show More