second display
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
|
||||
// App.messages = App.cable.subscriptions.create('MessagesChannel', {
|
||||
// App.messages = App.cable.subscriptions.create('MessagesChannel', {
|
||||
|
||||
connected: function() {},
|
||||
|
||||
disconnected: function() {},
|
||||
|
||||
received: function(data) {
|
||||
received: function(data) {
|
||||
var hostname = location.hostname.trim();
|
||||
if(data.from == "" || hostname == data.from){
|
||||
if(data.from == "" || hostname == data.from){
|
||||
var items = data.data;
|
||||
var tax = data.tax_profiles;
|
||||
var status= data.status
|
||||
@@ -16,8 +16,8 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
|
||||
}
|
||||
$('#second_display_slider').addClass("hidden")
|
||||
$('#second_display_items').removeClass("hidden")
|
||||
|
||||
|
||||
|
||||
|
||||
// append items
|
||||
if (status == "add") {
|
||||
for(var i in items) {
|
||||
@@ -34,15 +34,15 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
|
||||
|
||||
// d_option = items[i].options;
|
||||
// if (d_option){
|
||||
// option_name = "-"+items[i].options;
|
||||
// option_name = "-"+items[i].options;
|
||||
// }else{
|
||||
// option_name = '';
|
||||
// }
|
||||
|
||||
d_option = items[i].opt;
|
||||
if (items[i].click_type != "add_icon"){
|
||||
option_name = "-"+items[i].options;
|
||||
data_option = items[i].options ;
|
||||
option_name = "-"+items[i].options;
|
||||
data_option = items[i].options ;
|
||||
}else{
|
||||
option_name = ' ';
|
||||
data_option = '[]';
|
||||
@@ -56,25 +56,25 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
|
||||
var instance_code = $(item_row[j]).attr('data-instance-code');
|
||||
var r_option = $(item_row[j]).attr('data-options');
|
||||
if (item_code == items[i].item_code && instance_code == items[i].instance_code && r_option==d_option) {
|
||||
if (qty > 1) {
|
||||
if (qty > 1) {
|
||||
qty = parseInt($(item_row[j]).children('#item_qty').text()) + qty;
|
||||
}else{
|
||||
}else{
|
||||
qty = parseInt($(item_row[j]).children('#item_qty').text()) + 1;
|
||||
}
|
||||
|
||||
|
||||
$(item_row[j]).children('#item_qty').text(qty);
|
||||
parseFloat($(item_row[j]).children('#item_price').text(parseFloat(price*qty).toFixed(2)));
|
||||
append =1;
|
||||
}else{
|
||||
if (qty > 1) {
|
||||
if (qty > 1) {
|
||||
qty = qty;
|
||||
}else{
|
||||
}else{
|
||||
qty = 1;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
if (append===0) {
|
||||
row ="<tr class='item_box_"+items[i].item_code+"' data-price ='"
|
||||
row ="<tr class='item_box_"+items[i].instance_code+"' data-price ='"
|
||||
+price+ "' 'data-instance ='"
|
||||
+instance+ "' data-code='"+items[i].item_code+"' data-instance-code='"
|
||||
+items[i].instance_code+"' data-attributes='"
|
||||
@@ -84,12 +84,12 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
|
||||
+'<td class="item-cell-no">'+rowCount+'</td>'
|
||||
+'<td class="item-cell-name" id="item_name" >' + items[i].name+ ' ' + instance + ' ' + option_name +'</td>'
|
||||
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
|
||||
+'<td class="item-cell-price" id="item_price">'
|
||||
+'<td class="item-cell-price" id="item_price">'
|
||||
+ parseFloat(price).toFixed(2)
|
||||
+'</td>'
|
||||
+'</td>'
|
||||
+'</tr>';
|
||||
$(".second_display_items tbody").append(row);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,28 +117,29 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
|
||||
+'<td class="item-cell-no">'+rowCount+'</td>'
|
||||
+'<td class="item-cell-name" id="item_name" >' + item_name+ ' ' + name + ''+option+'</td>'
|
||||
+'<td class="item-cell-qty" id="item_qty">' + qty + '</td>'
|
||||
+'<td class="item-cell-price" id="item_price">'
|
||||
+'<td class="item-cell-price" id="item_price">'
|
||||
+ parseFloat(total).toFixed(2)
|
||||
+'</td>'
|
||||
+'</td>'
|
||||
+'</tr>';
|
||||
$(".second_display_items tbody").append(row);
|
||||
rowCount = rowCount + 1;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//remove item
|
||||
if(status == "remove"){
|
||||
for(var i in items) {
|
||||
var item_code = items[i].item_code;
|
||||
var item_code = items[i].instance_code;
|
||||
$("#order-items-table tbody > tr.item_box_"+item_code+"").remove();
|
||||
}
|
||||
}
|
||||
//remove item
|
||||
//update item qty
|
||||
if(status == "update_qty"){
|
||||
|
||||
for(var i in items) {
|
||||
var item_code = items[i].item_code;
|
||||
var item_code = items[i].instance_code;
|
||||
var item_qty = parseInt(items[i].qty);
|
||||
var item_price = parseFloat(items[i].price);
|
||||
var item_total = parseFloat(item_qty * item_price).toFixed(2);
|
||||
@@ -157,8 +158,8 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
|
||||
$(item_row).each(function(i){
|
||||
var unit_price = parseFloat($(item_row[i]).attr('data-price'));
|
||||
var qty = parseFloat($(item_row[i]).children('#item_qty').text());
|
||||
total_price += qty*unit_price;
|
||||
});
|
||||
total_price += qty*unit_price;
|
||||
});
|
||||
//calculate Tax Amount
|
||||
for(var i in tax) {
|
||||
// substract , to give after discount
|
||||
@@ -177,13 +178,12 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
|
||||
var fixed_taxable_amount = parseFloat(total_tax_amount).toFixed(2);
|
||||
var fixed_grand_total = parseFloat(total_price + total_tax_amount).toFixed(2);
|
||||
|
||||
$('#s_sub_total').empty();
|
||||
$('#s_sub_total').empty();
|
||||
$('#s_sub_total').append(fixed_total_price);
|
||||
$('#s_tatal_tax').empty();
|
||||
$('#s_tatal_tax').empty();
|
||||
$('#s_tatal_tax').append(fixed_taxable_amount);
|
||||
$('#s_grand_total').empty();
|
||||
$('#s_grand_total').empty();
|
||||
$('#s_grand_total').append(fixed_grand_total);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user