fixed out of stock
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<%= stylesheet_link_tag 'addorder', media: 'all', 'data-turbolinks-track': 'reload' %>
|
||||
|
||||
<%= javascript_include_tag 'addorder', 'data-turbolinks-track': 'reload' %>
|
||||
<div class="container-fluid " style="padding:0px 3px 0px 3px;">
|
||||
<div id="oqs_loading_wrapper" style="display:none;">
|
||||
<div id="oqs_loading"></div>
|
||||
@@ -106,7 +106,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="item-modal modal sx_item_detailModal" id="sx_item_detailModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="item-modal modal sx_item_detailModal" id="sx_item_detailModal" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog custom-modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="background-color: #54A5AF;padding-top:10px !important;">
|
||||
@@ -114,21 +114,26 @@
|
||||
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#fff;">×</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-inputs">
|
||||
|
||||
<div class="form-group">
|
||||
<div class="row no-set-item">
|
||||
<div class="col-md-5">
|
||||
<p style="text-align: center;" id="modal_box_img"></p>
|
||||
</div>
|
||||
<div class="col-md-7 item-detail">
|
||||
<div class="form-inputs">
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="attribute">Menu Item</label>
|
||||
<input class="form-control col-md-6" type="text" value="" id="item_name" readonly="true">
|
||||
<!-- <input type="hidden" name="item_code" id="instance_code">
|
||||
<input type="hidden" name="instance_name" id="instance_name"> -->
|
||||
<div class="form-group">
|
||||
<div class='instance-label' style='margin-bottom: 8px;'>
|
||||
<label class="control-label" for="attribute">Instances</label>
|
||||
</div>
|
||||
<!-- <div class="attributes-list col-md-6"></div> -->
|
||||
<select class="form-control" name="item_instance" id="instance_select" multiple="multiple"></select>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="item_code" id="instance_code">
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="attribute">Instances</label>
|
||||
<div class="attributes-list col-md-6"></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="row">
|
||||
@@ -140,9 +145,9 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<style type="text/css">
|
||||
.fadeInRight{
|
||||
-webkit-animation-duration: 350ms !important;
|
||||
@@ -155,9 +160,8 @@
|
||||
var menus = JSON.parse(localStorage.getItem("menus"));
|
||||
if (menus != null) {
|
||||
var id = menus[0]["categories"][0]["id"];
|
||||
// console.log(id);
|
||||
}else{
|
||||
var id = 1;
|
||||
var id = 1;
|
||||
}
|
||||
jQuery('.first_'+id).click();
|
||||
});
|
||||
@@ -202,10 +206,8 @@
|
||||
var menus = JSON.parse(localStorage.getItem("menus"));
|
||||
|
||||
if (menus != null) {
|
||||
console.log("hi")
|
||||
menu_click_cache_append(name,menus,menu_id);
|
||||
}else{
|
||||
console.log("sssdfdf")
|
||||
var url = "/origami/addorders/get_menu/"+menu_id;
|
||||
show_menu_cat_list(name, url);
|
||||
}
|
||||
@@ -332,6 +334,66 @@
|
||||
});
|
||||
//End menu category Click
|
||||
|
||||
//show menu item list when click menu category
|
||||
function show_sub_category_list(url,sub_category,menu_id){
|
||||
|
||||
var sub_category_list = $('.sub_category_list');
|
||||
sub_category_list.empty();
|
||||
|
||||
menus = JSON.parse(localStorage.getItem("menus"));
|
||||
if (menus != null) {
|
||||
for(var j in menus) {
|
||||
var categories = menus[j]["categories"];
|
||||
for(var ii in categories) {
|
||||
if (menu_id == categories[ii]["parent_id"]) {
|
||||
$(sub_category).removeClass('hidden');
|
||||
row = '<li class="menu_sub_category fadeInTop" data-id="'+categories[ii].id+'">'
|
||||
+'<a class="nav-link" data-toggle="tab" href="" role="tab">'+ categories[ii].name+'</a>'
|
||||
+'</li>' ;
|
||||
$(sub_category).append(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
if (type != -1 && modify_order != -1) {
|
||||
var url = "../../../addorders/"+url;
|
||||
}if(modify_order== -1 && type != -1){
|
||||
var url = 'addorders/'+url;
|
||||
}
|
||||
if (type ==-1 && modify_order == -1){
|
||||
var url = url;
|
||||
}
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
var sub_category_list = $('.sub_category_list');
|
||||
sub_category_list.empty();
|
||||
data = data.sub_category;
|
||||
if (data.length > 0) {
|
||||
// if ((sub_category.hasClass('hidden'))) {
|
||||
$(sub_category).removeClass('hidden');
|
||||
// }else{
|
||||
// $(sub_category).addClass('hidden');
|
||||
// }
|
||||
for(var i in data) {
|
||||
|
||||
row = '<li class="menu_sub_category fadeInTop" data-id="'+data[i].id+'">'
|
||||
+'<a class="nav-link" data-toggle="tab" href="" role="tab">'+ data[i].name+'</a>'
|
||||
+'</li>' ;
|
||||
$(sub_category).append(row);
|
||||
//end is_sub_item false
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//end Ajax
|
||||
}
|
||||
}
|
||||
|
||||
//show menu item list when click menu category
|
||||
function show_menu_item_list(url_item,menu_id){
|
||||
var menu_list = $('.menu_items_list');
|
||||
@@ -386,8 +448,9 @@
|
||||
add = 'view_list'
|
||||
menu_item_box = 'menu_item_box';
|
||||
data_target = 'sx_item_detailModal';
|
||||
data_modal = ''
|
||||
data_modal = 'modal'
|
||||
add_icon = "add_icon"
|
||||
menu_instances = [];
|
||||
|
||||
$(instances).each(function(i){
|
||||
if (instances[i].is_default === true) {
|
||||
@@ -401,6 +464,7 @@
|
||||
code = instances[i].code;
|
||||
out_of_stock = instances[i].out_of_stock;
|
||||
}
|
||||
menu_instances.push(item_attributes);
|
||||
});
|
||||
|
||||
if (menu_items[field].image) {
|
||||
@@ -464,54 +528,37 @@
|
||||
}
|
||||
|
||||
//click item row for add order
|
||||
$(document).on('click', '.card-box', function(event){
|
||||
$(document).on('click', '.add_icon', function(event){
|
||||
});
|
||||
|
||||
// item_data = $(this).children().siblings('.add_icon');
|
||||
var disable_item = $(this);
|
||||
var item_data = $(this).children().last();
|
||||
item_instance_name = item_data.attr('data-name');
|
||||
item_instance_code = item_data.attr('data-instance-code');
|
||||
|
||||
instance_attributes = []
|
||||
for(var field in instances) {
|
||||
value = instances[field].values;
|
||||
$(value).each(function(i){
|
||||
options = value[i];
|
||||
instance_attributes.push(options);
|
||||
$(document).on('click', '.menu_item_box', function(event){
|
||||
$('#instance_select').empty();
|
||||
$('#instance_select').select2({placeholder: "Select Instance"});
|
||||
$('#instance_select').on('select2:select', function(e){
|
||||
$(this).select2('open');
|
||||
});
|
||||
var instances = $(this).data('menu-instances');
|
||||
var item_row = $('.summary-items tbody tr');
|
||||
if(item_row.length > 0){
|
||||
$(instances).each(function(i){
|
||||
var append = 0;
|
||||
if (instances[i][1] != ""){ instance_name = instances[i][1]; }else{ instance_name = instances[i][2][0]; };
|
||||
$(item_row).each(function(e){
|
||||
instance_code = $(item_row[e]).attr('data-instance-code');
|
||||
if(instances[i][0] == instance_code){
|
||||
append = 1;
|
||||
}
|
||||
});
|
||||
if(append == 0){
|
||||
$('#instance_select').append('<option class="instance_name"' + 'id=' + instances[i][0] + ' value=' + instances[i][0] + '>' + instance_name + '</option>');
|
||||
}
|
||||
});
|
||||
}else{
|
||||
$(instances).each(function(i){
|
||||
if (instances[i][1] != ""){ instance_name = instances[i][1]; }else{ instance_name = instances[i][2][0]; };
|
||||
$('#instance_select').append('<option class="instance_name"' + 'id=' + instances[i][0] + ' value=' + instances[i][0] + '>' + instance_name + '</option>');
|
||||
});
|
||||
}
|
||||
|
||||
var rowCount = $('.summary-items tbody tr').length+1;
|
||||
var item_row = $('.summary-items tbody tr');
|
||||
|
||||
$(item_row).each(function(i){
|
||||
item_name = $(item_row[i]).attr('data-item-name');
|
||||
instance_code = $(item_row[i]).attr('data-instance-code');
|
||||
|
||||
if (item_name == item_data.attr('data-name') && instance_code == item_data.attr('data-instance-code')) {
|
||||
|
||||
}else{
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
row ="<tr class='item_box' data-instance-code='"
|
||||
+item_data.attr('data-instance-code')+"' data-item-name='"
|
||||
+item_data.attr('data-name')+"' data-row='"
|
||||
+rowCount+"'>"
|
||||
+'<td class="">'+rowCount+'</td>'
|
||||
+'<td class="hidden" id="item_instance_code">' + item_instance_code +'</td>'
|
||||
+'<td class="">' + item_instance_name +'</td>'
|
||||
+"<td class='delete_item'> <i class='material-icons' style='cursor: pointer;'>delete</i> </td>"
|
||||
+'</tr>';
|
||||
$(".summary-items tbody").append(row);
|
||||
$(disable_item).css({"pointer-events": "none", "opacity": "0.4"});
|
||||
|
||||
if ($('.summary-items tbody tr').length > 0) {
|
||||
$('#add_out_of_stock').removeAttr("disabled", false);
|
||||
}else{
|
||||
$('#add_out_of_stock').attr("disabled", true);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.delete_item', function(event){
|
||||
@@ -522,6 +569,11 @@
|
||||
tmp.appendTo(item.parent());
|
||||
enable_item = $("div:contains("+item_name+")");
|
||||
$(enable_item).css({"pointer-events": "", "opacity": ""});
|
||||
if ($('.summary-items tbody tr').length == 0) {
|
||||
$('#add_out_of_stock').attr("disabled", true);
|
||||
}else{
|
||||
$('#add_out_of_stock').removeAttr("disabled", false);
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '#clear_all', function(event){
|
||||
@@ -637,7 +689,6 @@
|
||||
}else{
|
||||
$('#modal-qty').val(original_qty + input_value);
|
||||
$('#modal-qty').attr('data-value',original_qty + input_value);
|
||||
// update_total_amount();
|
||||
}
|
||||
break;
|
||||
case 'add':
|
||||
@@ -659,40 +710,66 @@
|
||||
|
||||
// click select option icon for add
|
||||
$(document).on('click', '.submit', function(event){
|
||||
total_price = $('#total_price').text();
|
||||
qty = parseInt($('#count').val());
|
||||
|
||||
var item_code = $("#instance_code").val();
|
||||
var min_qty = $("#min_qty").val();
|
||||
var max_qty = $("#max_qty").val();
|
||||
var item_name = $("#item_name").val();
|
||||
var item_row = $('.selected-attribute');
|
||||
attribute_arr = get_selected_attributes('selected-attribute');
|
||||
option_arr = get_selected_attributes('selected-option');
|
||||
|
||||
console.log(item_code);
|
||||
console.log(min_qty);
|
||||
console.log(max_qty);
|
||||
var params = {'item_code': item_code};
|
||||
var ajax_url = 'settings_update_menu_items_path';
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: ajax_url,
|
||||
data: params,
|
||||
dataType: "json",
|
||||
success:function(result){
|
||||
if (result.status) {
|
||||
var rowCount = $('.summary-items tbody tr').length+1;
|
||||
row ="<tr class=''>"
|
||||
+'<td class="">'+rowCount+'</td>'
|
||||
+'<td class="hidden" id="itemCodeee">' + item_code +'</td>'
|
||||
+'<td class="">' + item_name +'</td>'
|
||||
+'</tr>';
|
||||
$(".summary-items tbody").append(row);
|
||||
swal("Success",result.message,"success");
|
||||
}else{
|
||||
swal("Opps",result.message,"warning");
|
||||
}
|
||||
}
|
||||
});
|
||||
// +'<td class="" onClick="remove()"><i class="material-icons"style="cursor: pointer;">delete_forever</i></td>'
|
||||
data = $("#instance_select").select2('data');
|
||||
if (data != null){
|
||||
instance_code = data[0].id;
|
||||
instance_name = data[0].text;
|
||||
code_name = [instance_code,instance_name];
|
||||
}
|
||||
|
||||
$('.submit').attr('data-item-code',$('#item_code').text());
|
||||
$('.submit').attr('data-instance-arr',JSON.stringify(data));
|
||||
$('.submit').attr('data-name',$('#title_name').text());
|
||||
$('.submit').attr('data-attributes',JSON.stringify(attribute_arr));
|
||||
$('.submit').attr('data-options',JSON.stringify(option_arr));
|
||||
$('.submit').attr('data-opt',JSON.stringify(option_arr));
|
||||
var item_data = $(this);
|
||||
show_item_detail(item_data,"add_to_order");
|
||||
});
|
||||
|
||||
function show_item_detail(data,click_type){
|
||||
testqty = parseInt($('.item_box').children('data_qty').text());
|
||||
qty = parseInt(data.attr('data-qty'));
|
||||
append = 0;
|
||||
price = data.attr('data-price');
|
||||
instance_name = data.attr('data-instance');
|
||||
instance_arr = JSON.parse(data.attr('data-instance-arr'));
|
||||
|
||||
for(var i in instance_arr){
|
||||
if (instance_name == "undefined"){
|
||||
instance = '';
|
||||
}else{
|
||||
instance = "("+instance_arr[i].text+")";
|
||||
}
|
||||
|
||||
var rowCount = $('.summary-items tbody tr').length+1;
|
||||
var item_row = $('.summary-items tbody tr');
|
||||
|
||||
row ="<tr class='item_box' data-price ='"
|
||||
+price+ " 'data-toggle='modal' data-target='#sx_itemModal' data-instance ='"
|
||||
+instance+ "' data-qty='"+qty +"' data-code='"+data.attr('data-item-code')+"' data-instance-code='"
|
||||
+instance_arr[i].id+"' data-attributes='"
|
||||
+data.attr('data-attributes')
|
||||
+"' data-row ='"+rowCount+ "'>"
|
||||
+'<td class="item-cell-no">'+rowCount+'</td>'
|
||||
+'<td class="item-cell-name" id="item_name" >' + data.attr('data-name')+ ' ' + instance +'</td>'
|
||||
+"<td class='delete_item'> <i class='material-icons' style='cursor: pointer;'>delete</i> </td>"
|
||||
+'</tr>';
|
||||
$(".summary-items tbody").append(row);
|
||||
}
|
||||
if ($('.summary-items tbody tr').length == 0) {
|
||||
$('#add_out_of_stock').attr("disabled", true);
|
||||
}else{
|
||||
$('#add_out_of_stock').removeAttr("disabled", false);
|
||||
}
|
||||
}
|
||||
|
||||
$('#back').on('click', function () {
|
||||
window.location.href = '/settings/out_of_stock';
|
||||
@@ -700,38 +777,4 @@
|
||||
$('#stock_taking').on('click', function () {
|
||||
window.location.href = '/inventory/stock_checks';
|
||||
});
|
||||
|
||||
// });
|
||||
|
||||
// $('.remove_row').on('click', function(){
|
||||
// window.location.href = '/inventory';
|
||||
// console.log('remove row!!!!!');
|
||||
// alert('Are you suer?');
|
||||
// });
|
||||
|
||||
// function remove(){
|
||||
// var itemCode = $("#itemCodeee").text();
|
||||
//
|
||||
// var params = {'item_code': itemCode};
|
||||
// var ajax_url = '<%=inventory_inventory_definitions_path%>';
|
||||
// $.ajax({
|
||||
// type: "POST",
|
||||
// url: ajax_url,
|
||||
// data: params,
|
||||
// dataType: "json",
|
||||
// success:function(result){
|
||||
// if (result.status) {
|
||||
// var rowCount = $('.summary-items tbody tr').length+1;
|
||||
// row =
|
||||
// $(".summary-items tbody").append(row);
|
||||
// swal("Success",result.message,"success");
|
||||
// }else{
|
||||
// swal("Opps",result.message,"warning");
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// console.log('remove row!!!!!');
|
||||
// console.log(itemCode);
|
||||
// }
|
||||
</script>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.product") %></th>
|
||||
<th><%= t("views.right_panel.detail.instance_name") %></th>
|
||||
<th><%= t("views.right_panel.detail.atrribute_name") %></th>
|
||||
<th><%= t("views.right_panel.detail.status") %></th>
|
||||
<th><%= t("views.right_panel.detail.action") %></th>
|
||||
</tr>
|
||||
@@ -14,6 +16,12 @@
|
||||
|
||||
<tr>
|
||||
<td><%= item.name rescue '-' %></td>
|
||||
<% if !item.item_instance_name.blank? %>
|
||||
<td><%= item.item_instance_name rescue '-' %></td>
|
||||
<% else %>
|
||||
<td><p style="font-size: 20px;">-</p></td>
|
||||
<% end %>
|
||||
<td><%= JSON.parse(MenuItemAttribute.where(id: item.item_attributes).pluck(:name).to_s).join(', ') %></td>
|
||||
<td>
|
||||
<% if item.is_out_of_stock %>
|
||||
<div class="badge badge-success">Active</div>
|
||||
|
||||
@@ -30,8 +30,26 @@
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function (){
|
||||
getAllMenu();
|
||||
});
|
||||
|
||||
$('#new_out_of_stock').on('click',function(){
|
||||
window.location.href = '/settings/out_of_stock/new';
|
||||
});
|
||||
|
||||
function getAllMenu(){
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: '/foodcourt/get_all_menu',
|
||||
data: {},
|
||||
success:function(result){
|
||||
if (result != null ) {
|
||||
var menus = JSON.stringify(result);
|
||||
localStorage.setItem("menus", menus);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user