update addorder bugs
This commit is contained in:
@@ -8,12 +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();
|
||||
@@ -34,7 +28,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 +57,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 +72,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 +87,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>"
|
||||
|
||||
@@ -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');
|
||||
@@ -254,11 +254,21 @@ $(function(){
|
||||
$('.add_to_order').removeAttr('data-options');
|
||||
|
||||
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;
|
||||
@@ -303,10 +313,13 @@ $(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'));
|
||||
});
|
||||
@@ -382,23 +395,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());
|
||||
@@ -621,4 +641,40 @@ $(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
|
||||
}
|
||||
});
|
||||
|
||||
var count = 1;
|
||||
var countEl = document.getElementById("count");
|
||||
$("#plus").on("click", function(){
|
||||
count++;
|
||||
countEl.value = count;
|
||||
|
||||
price = $("#unit_price").text();
|
||||
$("#total_price").text(count*price);
|
||||
});
|
||||
$("#minus").on("click", function(){
|
||||
if (count > 1) {
|
||||
count--;
|
||||
countEl.value = count;
|
||||
|
||||
price = $("#unit_price").text();
|
||||
$("#total_price").text(count*price);
|
||||
}
|
||||
})
|
||||
|
||||
// $(".change_qty").change(function(){
|
||||
// qty = $(this).val();
|
||||
// price = $("#unit_price").text();
|
||||
// $("#total_price").text(qty*price);
|
||||
// });
|
||||
|
||||
});
|
||||
@@ -109,9 +109,9 @@ element.style {
|
||||
}
|
||||
#logo{
|
||||
margin: auto;
|
||||
width: 50%;
|
||||
width: 100%;
|
||||
border: 1px solid #54A5AF;
|
||||
padding: 10px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
#instance_img{
|
||||
|
||||
@@ -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="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>
|
||||
|
||||
@@ -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(){
|
||||
|
||||
Reference in New Issue
Block a user