update addorder set multiple
This commit is contained in:
@@ -315,6 +315,7 @@ $(function() {
|
||||
$(".options-list").empty();
|
||||
|
||||
rowCount = $('.selected-instance');
|
||||
setCount = $('.selected-set');
|
||||
item_options = $(this).data('option');
|
||||
|
||||
min_qty = $(this).data('min-qty');
|
||||
@@ -335,19 +336,19 @@ $(function() {
|
||||
$(".options-list").append(row);
|
||||
}
|
||||
}
|
||||
if($(this).hasClass('selected-instance') == true){
|
||||
sub_total = $('#set_total_price').text();
|
||||
name = $(this).data('name');
|
||||
price = $(this).data('price');
|
||||
// qty = $('#set_change_qty').val();
|
||||
qty = document.getElementById("set_count").value;
|
||||
total = qty*price;
|
||||
var total_price = +sub_total - +total;
|
||||
$(this).removeClass('selected-instance');
|
||||
$(".options-list").empty();
|
||||
$(this).removeAttr('data-options');
|
||||
$('#instance_option').text('')
|
||||
}else {
|
||||
// if($(this).hasClass('selected-instance') == true){
|
||||
// sub_total = $('#set_total_price').text();
|
||||
// name = $(this).data('name');
|
||||
// price = $(this).data('price');
|
||||
// // qty = $('#set_change_qty').val();
|
||||
// qty = document.getElementById("set_count").value;
|
||||
// total = qty*price;
|
||||
// var total_price = +sub_total - +total;
|
||||
// $(this).removeClass('selected-instance');
|
||||
// $(".options-list").empty();
|
||||
// $(this).removeAttr('data-options');
|
||||
// $('#instance_option').text('')
|
||||
// }else {
|
||||
if (rowCount.length+1 <= max_qty) {
|
||||
sub_total = $('#set_total_price').text();
|
||||
name = $(this).data('name');
|
||||
@@ -358,13 +359,56 @@ $(function() {
|
||||
total = qty*price;
|
||||
var total_price = +sub_total + +total;
|
||||
$(this).addClass('selected-instance');
|
||||
|
||||
set = "<div class='selected-set card custom-card' style='margin-bottom:10px !important'"
|
||||
+"' data-name='"+$(this).data('name')
|
||||
+"' data-code='"+code
|
||||
+"' data-price='"+$(this).data('price')
|
||||
+"' data-option='"+JSON.stringify($(this).data('option'))
|
||||
+"' data-min-qty='"+$(this).data('min-qty')
|
||||
+"' data-max-qty='"+$(this).data('max-qty')
|
||||
+"' data-parent-code='"+$(this).data('parent-code')
|
||||
+"' data-parent-id='"+$(this).data('parent-id')
|
||||
+"' data-sub-item='true"
|
||||
+"'>"
|
||||
|
||||
+'<div class="card-block" style="background-color:#54A5AF;">'
|
||||
+' <button type="button" class="close" id="remove_set" style="font-size: 20px;">×</button>'
|
||||
+'<span style="color:#fff">'+$(this).data('name')+'</span>'
|
||||
+'</div>'
|
||||
+'<div class="card-block custom-card-block">'
|
||||
|
||||
+' <small style="float:" id="instance_option"></small>'
|
||||
+'</div>'
|
||||
// +'<div class="card-footer custom-card-footer">'
|
||||
// +' <span>'+$(this).data('price')+'</span>'
|
||||
// // +' <small style="float:right" id="instance_option"></small>'
|
||||
// +'</div>'
|
||||
+'</div>'
|
||||
$(".selected-set-list").append(set);
|
||||
}else{
|
||||
swal("Alert !", 'Maximum Qty is ' + max_qty + " items", "warning");
|
||||
}
|
||||
}
|
||||
// }
|
||||
$('#set_unit_price').text(price);
|
||||
$('#set_total_price').text(total_price);
|
||||
|
||||
}); //End selecct attribute buttom
|
||||
|
||||
// click add order
|
||||
$(document).on('click', '#remove_set', function(event){
|
||||
code = $(this).parent().parent('.selected-set').attr('data-code');
|
||||
instance = $(".selected-instance");
|
||||
console.log(code)
|
||||
$(instance).each(function(i){
|
||||
if ($(instance[i]).attr('data-code')==code){
|
||||
console.log($(instance[i]))
|
||||
$(instance[i]).removeClass("selected-instance")
|
||||
}
|
||||
});
|
||||
$(this).parent().parent('.selected-set').remove();
|
||||
});
|
||||
|
||||
// click add order
|
||||
$(document).on('click', '.set_order', function(event){
|
||||
total_price = $('#set_total_price').text();
|
||||
@@ -637,15 +681,17 @@ $(function() {
|
||||
|
||||
|
||||
if(group == "set_menu"){
|
||||
|
||||
instance = $(".selected-instance");
|
||||
$(instance).each(function(i){
|
||||
if ($(instance[i]).attr('data-code')==code){
|
||||
option_arr = get_selected_attributes('selected-option');
|
||||
$(instance[i]).attr('data-options',JSON.stringify(option_arr));
|
||||
$(instance[i]).children().children('#instance_option').text(option_arr);
|
||||
}
|
||||
});
|
||||
option_arr = get_selected_attributes('selected-option');
|
||||
$(".selected-set:last").attr('data-options',JSON.stringify(option_arr));
|
||||
$(".selected-set:last").children().children('#instance_option').text(option_arr);
|
||||
// instance = $(".selected-instance");
|
||||
// $(instance).each(function(i){
|
||||
// if ($(instance[i]).attr('data-code')==code){
|
||||
// option_arr = get_selected_attributes('selected-option');
|
||||
// $(instance[i]).attr('data-options',JSON.stringify(option_arr));
|
||||
// $(instance[i]).children().children('#instance_option').text(option_arr);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
if(group == "set_menu_default"){
|
||||
|
||||
@@ -405,9 +405,15 @@
|
||||
<p class="hidden" id="set_item_code"></p>
|
||||
<p></p>
|
||||
|
||||
<div class="options-list">
|
||||
<div class="" id="modal-slimscroll" data-height="250">
|
||||
<div class="options-list" style="margin-top:-5px">
|
||||
</div>
|
||||
|
||||
<div class='selected-set-list'>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="col-md-8">
|
||||
<div class="instance-list row"></div>
|
||||
|
||||
Reference in New Issue
Block a user