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

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 */
}