diff --git a/app/assets/javascripts/addorder.js b/app/assets/javascripts/addorder.js
index 31209c99..a8de44b1 100755
--- a/app/assets/javascripts/addorder.js
+++ b/app/assets/javascripts/addorder.js
@@ -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,12 +359,55 @@ $(function() {
total = qty*price;
var total_price = +sub_total + +total;
$(this).addClass('selected-instance');
+
+ set = "
"
+
+ +'
'
+ +' '
+ +''+$(this).data('name')+''
+ +'
'
+ +'
'
+
+ +' '
+ +'
'
+ // +''
+ +'
'
+ $(".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){
@@ -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"){
diff --git a/app/views/origami/addorders/detail.html.erb b/app/views/origami/addorders/detail.html.erb
index 607f4c0e..93569170 100755
--- a/app/views/origami/addorders/detail.html.erb
+++ b/app/views/origami/addorders/detail.html.erb
@@ -405,9 +405,15 @@
-