add out of stock
This commit is contained in:
742
app/views/settings/out_of_stock/_form.html.erb
Normal file
742
app/views/settings/out_of_stock/_form.html.erb
Normal file
@@ -0,0 +1,742 @@
|
||||
<%= stylesheet_link_tag 'addorder', media: 'all', '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>
|
||||
</div>
|
||||
<div class="row m-t--20">
|
||||
<div class="col-lg-2 col-md-2 col-sm-2 hidden" id="menu_data">
|
||||
<li class="list-menu">
|
||||
<a href="javascript:void(0);" class="menu-toggle dropdown-toggle toggled my-toggle " style="">
|
||||
|
||||
<span class="main_menu" id="main_menu menu_name" >
|
||||
<%if @menu.present? %>
|
||||
<%=@menus[0].name%>
|
||||
<% end%>
|
||||
</span>
|
||||
</a>
|
||||
<ul class="ml-menu menu_list aria-hidden " style="border-top: 1px solid #fff">
|
||||
<% @menus.each do |menu| %>
|
||||
<li class="nav-item menu_click" data-name="<%=menu.name%>" data-id="<%=menu.id%>" style="">
|
||||
<a class="nav-link" data-toggle="tab" href="" role="tab" style="text-transform: lowercase;"><%=menu.name%></a>
|
||||
</li>
|
||||
<%end%>
|
||||
</ul>
|
||||
</li>
|
||||
<div id="menu1-slimscroll" data-height="0">
|
||||
<ul class="nav nav-tabs flex-column category_list" role="tablist" id="ul-navbar">
|
||||
<li class="nav-item product" data-ref="<%= origami_get_all_product_path %>">
|
||||
<a class="nav-link" data-toggle="tab" href="" role="tab">Products</a>
|
||||
</li>
|
||||
<% @menu.each do |menu| %>
|
||||
<% if !menu.valid_time.nil? %>
|
||||
<% if menu.menu_category_id.nil? %>
|
||||
<!--if type quick_service or cashier for table -->
|
||||
<% if !menu.code.include? "SPL" %>
|
||||
<li class="nav-item ">
|
||||
<p class="hidden menu-id"><%= menu.id %></p>
|
||||
<a class="nav-link menu_category sub_click first_<%=menu.id%>" data-toggle="tab" href="" role="tab" data-id="<%=menu.id%>" data-sub-id="<%=menu.get_sub_category%>"> <%= menu.name%>
|
||||
</a>
|
||||
<ul class=" sub_category_list hidden fadeInTop animated" id="sub_category_list"></ul>
|
||||
</li>
|
||||
<% end%>
|
||||
<% end%>
|
||||
<% end %>
|
||||
<%end %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-2 col-sm-2 hidden" id="menu_cache">
|
||||
<li class="list-menu">
|
||||
<a href="javascript:void(0);" class="menu-toggle dropdown-toggle toggled my-toggle " style="">
|
||||
<span class="main_menu menu_cache_name" id="main_menu menu_cache_name"></span>
|
||||
</a>
|
||||
<ul class="ml-menu menu_list aria-hidden menu_cache_list" style="border-top: 1px solid #fff">
|
||||
</ul>
|
||||
</li>
|
||||
<div id="menu-slimscroll" data-height="0">
|
||||
<ul class="nav nav-tabs flex-column category_list category_cache_list" role="tablist" id="ul-navbar">
|
||||
<li class="nav-item product" data-ref="<%= origami_get_all_product_path %>">
|
||||
<a class="nav-link" data-toggle="tab" href="" role="tab">Products</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-7 col-lg-7 col-sm-7 m-t-10" >
|
||||
<div class="card">
|
||||
<div class="card-block" style="">
|
||||
<div class="card-text" id="custom-slimscroll">
|
||||
<div class="row menu_items_list" style="margin:0px 1px 0px 1px ;">
|
||||
<!-- append data -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-3 col-sm-3" >
|
||||
<button type="button" class="btn btn-lg btn-block btn-default waves-effect m-t-5" id='back'>
|
||||
<i class="material-icons">reply</i>Back
|
||||
</button>
|
||||
|
||||
<div class="card-block">
|
||||
<div class="card-text" id="order-detail-slimscroll" data-height="140">
|
||||
<table class="table table-striped summary-items" id="order-items-table" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th>#</th>
|
||||
<th class="item-name">Items</th>
|
||||
<!-- <th class="item-qty">Min Qty</th>
|
||||
<th class="item-attr">Max Qty</th> -->
|
||||
<!-- <th></th> -->
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="font-13" >
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<button type="button" class="btn btn-lg btn-block btn-primary waves-effect m-t-5" id='add_out_of_stock' disabled="disabled">
|
||||
Add Out Of Stock
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</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="modal-dialog custom-modal-dialog modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="background-color: #54A5AF;padding-top:10px !important;">
|
||||
<h4 class="modal-title" style="color:#fff;" id="title_name"></h4>
|
||||
<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="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">
|
||||
</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 class="modal-footer">
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<button type="button" class="btn btn-default " data-dismiss="modal" id="close">Close</button>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<button type="button" class="btn btn-primary submit " data-dismiss="modal" id="submit">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<style type="text/css">
|
||||
.fadeInRight{
|
||||
-webkit-animation-duration: 350ms !important;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
var cashier_type = $('#cashier_type').val();
|
||||
|
||||
jQuery(function(){
|
||||
var menus = JSON.parse(localStorage.getItem("menus"));
|
||||
if (menus != null) {
|
||||
var id = menus[0]["categories"][0]["id"];
|
||||
// console.log(id);
|
||||
}else{
|
||||
var id = 1;
|
||||
}
|
||||
jQuery('.first_'+id).click();
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
var menus = JSON.parse(localStorage.getItem("menus"));
|
||||
if (menus != null) {
|
||||
menu_cache_append(menus);
|
||||
}else{
|
||||
$("#menu_data").removeClass("hidden");
|
||||
}
|
||||
|
||||
function menu_cache_append(menus){
|
||||
$("#menu_cache").removeClass("hidden");
|
||||
$(".menu_cache_name").text(menus[0]["name"])
|
||||
for(var i in menus) {
|
||||
menu_list_template(menus[i]);
|
||||
}
|
||||
var category = menus[0]["categories"];
|
||||
|
||||
for(var ii in category) {
|
||||
if (category[ii]["is_available"]== true){
|
||||
if (category[ii]["valid_time"]== true){
|
||||
if (category[ii]["parent_id"] == null ){
|
||||
if (category[ii]["code"].includes("SPL") != true) {
|
||||
category_list_template(category[ii]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('click', '.menu_click', function(event){
|
||||
|
||||
$('.my-toggle').removeClass('toggled');
|
||||
$('.menu_list').css('display', 'none');
|
||||
var menu_id = $(this).attr("data-id");
|
||||
var name = $(this).attr("data-name");
|
||||
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);
|
||||
}
|
||||
});
|
||||
//End menu category Click
|
||||
|
||||
function menu_click_cache_append(name,menus,menu_id) {
|
||||
var menu_list = $('.menu_items_list');
|
||||
menu_list.empty();
|
||||
|
||||
var menu_cat = $('.category_list');
|
||||
menu_cat.empty();
|
||||
|
||||
$(".main_menu").text(name);
|
||||
|
||||
for(var i in menus) {
|
||||
|
||||
if (menu_id == menus[i]["id"] && menus[i]["is_active"] == true) {
|
||||
|
||||
// menu_list_template(menus[i]);
|
||||
var category = menus[i]["categories"];
|
||||
|
||||
for(var ii in category) {
|
||||
if (category[ii]["is_available"]== true){
|
||||
if (category[ii]["valid_time"]== true){
|
||||
if (category[ii]["parent_id"] == null ){
|
||||
|
||||
if (category[ii]["code"].includes("SPL") != true) {
|
||||
category_list_template(category[ii]);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function category_list_template(menu) {
|
||||
row = '<li class="nav-item">'
|
||||
+'<p class="hidden menu-id">'+menu.id+'</p> '
|
||||
+'<a class="nav-link menu_category sub_click first_'+menu.id+'" '
|
||||
+'data-toggle="tab" href="" role="tab" data-id="'+menu.id+'" '
|
||||
+'data-sub-id="'+menu.sub_category+'">'+menu.name+''
|
||||
+'</a>'
|
||||
+'<ul class="sub_category_list hidden fadeInTop animated" '
|
||||
+'id="sub_category_list">'
|
||||
+'</ul>'
|
||||
|
||||
+' </li>';
|
||||
$(".category_cache_list").append(row);
|
||||
}
|
||||
|
||||
function menu_list_template(menu) {
|
||||
row = '<li class="nav-item menu_click" data-name="'+menu.name+'" '
|
||||
+' data-id="'+menu.id+'" style="">'
|
||||
+' <a class="nav-link" data-toggle="tab" href="" role="tab"'
|
||||
+' style="text-transform: lowercase;">'+menu.name+'</a>'
|
||||
+'</li>';
|
||||
$(".menu_cache_list").append(row);
|
||||
}
|
||||
|
||||
//show menu item list when click menu category
|
||||
function show_menu_cat_list(name, url_item){
|
||||
var menu_list = $('.menu_items_list');
|
||||
menu_list.empty();
|
||||
|
||||
var menu_cat = $('.category_list');
|
||||
menu_cat.empty();
|
||||
|
||||
$(".main_menu").text(name);
|
||||
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url_item,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
for(var i in data) {
|
||||
if (data[i].is_available == true) {
|
||||
list = '<li class="nav-item menu_category sub_click" data-id="'+ data[i].id +'">'
|
||||
+'<p class="hidden menu-id">'+ data[i].id +'</p> '
|
||||
+'<a class="nav-link" data-toggle="tab" href="" role="tab"> '+ data[i].name +''
|
||||
+'<ul class=" sub_category_list hidden fadeInTop animated"'
|
||||
+'id="sub_category_list">'
|
||||
+'</ul>'
|
||||
+'</a>'
|
||||
+'</li>';
|
||||
$('.category_list').append(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
//end Ajax
|
||||
}
|
||||
//end show list function
|
||||
|
||||
//click menu sidebar menu category
|
||||
$(document).on('click', '.menu_category', function(e){
|
||||
e.preventDefault();
|
||||
$('.sub_category_list').addClass("hidden");
|
||||
var menu_id = $(this).attr("data-id");
|
||||
var url = "/inventory/get_menu_category/"+menu_id;
|
||||
show_menu_item_list(url,menu_id);
|
||||
var sub_id = $(this).attr("data-sub-id");
|
||||
if (sub_id == "true") {
|
||||
var sub_url = "/inventory/get_menu_sub_category/"+menu_id;
|
||||
sub_category = $(this).siblings('.sub_category_list');
|
||||
show_sub_category_list(sub_url,sub_category,menu_id);
|
||||
}
|
||||
});
|
||||
//End menu category Click
|
||||
|
||||
//click menu sidebar menu category
|
||||
$(document).on('click', '.menu_sub_category', function(event){
|
||||
// event.preventDefault();
|
||||
// $(".menu_sub_category").on("click", function(){
|
||||
$('.sub_category_list').addClass("hidden");
|
||||
var menu_id = $(this).attr("data-id");
|
||||
var url = "/inventory/get_menu_category/"+menu_id;
|
||||
show_menu_item_list(url,menu_id);
|
||||
});
|
||||
//End menu category Click
|
||||
|
||||
//show menu item list when click menu category
|
||||
function show_menu_item_list(url_item,menu_id){
|
||||
var menu_list = $('.menu_items_list');
|
||||
menu_list.empty();
|
||||
|
||||
menus = JSON.parse(localStorage.getItem("menus"));
|
||||
if (menus != null) {
|
||||
for(var i in menus) {
|
||||
var categories = menus[i]["categories"];
|
||||
for(var ii in categories) {
|
||||
if (categories[ii]["id"] == menu_id) {
|
||||
var menu_items = categories[ii]["items"];
|
||||
show_menu_list(menu_items);
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url_item,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
var menu_items_list = $('.menu_items_list');
|
||||
menu_items_list.empty();
|
||||
menu_items = data.menu_items;
|
||||
show_menu_list(menu_items);
|
||||
}
|
||||
});
|
||||
//end Ajax
|
||||
}
|
||||
}
|
||||
//end show list function
|
||||
function show_menu_list(menu_items) {
|
||||
var menu_list = $('.menu_items_list');
|
||||
menu_list.empty();
|
||||
for(var field in menu_items) {
|
||||
if (menu_items[field].is_sub_item == false) {
|
||||
instances = menu_items[field].instances ;
|
||||
|
||||
if (!instances.length > 0) {
|
||||
swal("Hello Please Check!","Does not have instance item in this menu items ("+ menu_items[field].name+")","warning");
|
||||
}
|
||||
if (instances.length > 0) {
|
||||
qty = 1;
|
||||
options = [];
|
||||
price = 0;
|
||||
|
||||
fa_plus = 'material-icons';
|
||||
add = 'view_list'
|
||||
menu_item_box = 'menu_item_box';
|
||||
data_target = 'sx_item_detailModal';
|
||||
data_modal = ''
|
||||
add_icon = "add_icon"
|
||||
|
||||
$(instances).each(function(i){
|
||||
if (instances[i].is_default === true) {
|
||||
code = instances[i].code;
|
||||
name = instances[i].name;
|
||||
price = parseFloat(instances[i].price).toFixed(2);
|
||||
is_available = instances[i].is_available ;
|
||||
is_on_promotion = instances[i].is_on_promotion;
|
||||
item_attributes = instances[i].values;
|
||||
promotion_price = instances[i].promotion_price;
|
||||
code = instances[i].code;
|
||||
out_of_stock = instances[i].out_of_stock;
|
||||
}
|
||||
});
|
||||
|
||||
if (menu_items[field].image) {
|
||||
image_path = menu_items[field].image;
|
||||
|
||||
}else{
|
||||
image_path = "image/logo.png";
|
||||
}
|
||||
|
||||
if (out_of_stock === true) {
|
||||
// oos_item = out_of_stock_item
|
||||
oos_item = '<div class="card custom-card testimonial-card fadeInRight card-box"'
|
||||
+'data-toggle="modal" data-target=".'+data_target+'" '
|
||||
+'style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat; pointer-events: none;opacity: 0.4;">'
|
||||
}else{
|
||||
oos_item = '<div class="card custom-card testimonial-card fadeInRight card-box"'
|
||||
+'data-toggle="modal" data-target=".'+data_target+'" '
|
||||
+'style="height:100%;background-image:url(../../'+image_path+');background-repeat: no-repeat;">'
|
||||
}
|
||||
|
||||
row = '<div class="col-md-3">'
|
||||
+ oos_item
|
||||
+'<div class="custom-card-head card-head row" style="line-height:14px;margin:0px;" style="">'
|
||||
+'<div class="col-md-10 " style="padding:0px !important;">'+ menu_items[field].name +'</div>'
|
||||
+"<div class='col-md-2 "+menu_item_box+" ' data-item-code='"
|
||||
+ menu_items[field].code +"' data-instance = '"
|
||||
+JSON.stringify(menu_items[field].instances)+"' data-id = '"
|
||||
+JSON.stringify(menu_items[field].attributes)+"' data-item = '"
|
||||
+JSON.stringify(item_attributes)+"' data-option = '"
|
||||
+JSON.stringify(menu_items[field].options)+"'data-opt = '"
|
||||
+JSON.stringify(menu_items[field].options)+"' data-item-sets = '"
|
||||
+JSON.stringify(menu_items[field].item_sets)+"' data-toggle='modal' data-target='."+data_target+"' style='padding:0px 5px 0px 5px'>"
|
||||
+"<i class='m-l--5 fa "+fa_plus+" '>"
|
||||
+add+ '</i>'
|
||||
+'</div>'
|
||||
+'</div>'
|
||||
+"<div class='"+add_icon+" p-t-65 m-r-' data-item-code='"
|
||||
+ menu_items[field].code +"' data-name='"
|
||||
+ menu_items[field].name +"' data-qty = '"+ qty +"' data-price = '"
|
||||
+ price +"' data-instance-code = '"+ code +"' data-instance = '"
|
||||
+ name +"' data-promotion-price = '"+ promotion_price +"' data-attributes = '"
|
||||
+ JSON.stringify(item_attributes) +"' data-options = '"
|
||||
+ JSON.stringify(menu_items[field].options) +"' data-opt = '"
|
||||
+ JSON.stringify(menu_items[field].options) +"' data-image='"+image_path+"' data-toggle='"
|
||||
+data_modal+"' data-target='."+data_target+"' data-item-sets = '"
|
||||
+JSON.stringify(menu_items[field].item_sets)+"'data-instances = '"
|
||||
+JSON.stringify(menu_items[field].instances)+"'>"
|
||||
|
||||
// +"<div class='card-block custom-card-block'>"
|
||||
// +"<img id='logo' height='' src='"+image_path+"'>"
|
||||
// +"</div>"
|
||||
|
||||
+'</div>'
|
||||
+'</div>'; ;
|
||||
$('.menu_items_list').append(row);
|
||||
}
|
||||
//end instances in menu-items alest 1 instance
|
||||
}
|
||||
//end is_sub_item false
|
||||
}
|
||||
}
|
||||
|
||||
//click item row for add order
|
||||
$(document).on('click', '.card-box', 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');
|
||||
|
||||
// $('#item_code').val(item_data.attr('data-item-code'));
|
||||
// $('#item_name').val(item_data.attr('data-name'));
|
||||
// $('#instance_code').val(item_data.attr('data-instance-code'));
|
||||
|
||||
// $('.attributes-list').empty();
|
||||
|
||||
// data = $(this).children().children('.menu_item_box');
|
||||
// data = $(this).parent().siblings('.add_icon');
|
||||
|
||||
// attributes = $(data).data('id');
|
||||
// selected_item = $(data).data('item');
|
||||
// instances = $(data).data('instance');
|
||||
|
||||
instance_attributes = []
|
||||
for(var field in instances) {
|
||||
value = instances[field].values;
|
||||
$(value).each(function(i){
|
||||
options = value[i];
|
||||
instance_attributes.push(options);
|
||||
});
|
||||
}
|
||||
|
||||
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');
|
||||
r_option = $(item_row[i]).attr('data-opt');
|
||||
|
||||
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>'
|
||||
+'</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);
|
||||
}
|
||||
// for(var field in attributes) {
|
||||
// value = attributes[field]["values"];
|
||||
// type = attributes[field]["type"]
|
||||
// row = "";
|
||||
//
|
||||
// $(value).each(function(i){
|
||||
// disabled = ""
|
||||
// status ="";
|
||||
// if(parseInt(jQuery.inArray(value[i], selected_item)) !== -1){
|
||||
// status = "selected-attribute";
|
||||
// }
|
||||
// if(parseInt(jQuery.inArray(value[i], instance_attributes)) == -1){
|
||||
// disabled = "disabled";
|
||||
// }
|
||||
// row +="<button type='button' id='selected-attribute' data-instances='"+JSON.stringify(instances)+"' data-type='"
|
||||
// +type+"' data-value='"+value[i]+"' class='btn btn- waves-effect attribute_btn "
|
||||
// + status +" "+ type +" '"+ disabled +" >"
|
||||
// +value[i]
|
||||
// +"</button>";
|
||||
// });
|
||||
// $(".attributes-list").append(row);
|
||||
// }
|
||||
});
|
||||
|
||||
$('#add_out_of_stock').on('click', function () {
|
||||
$(this).attr('disabled', 'disabled');
|
||||
|
||||
var oos_items = JSON.stringify(get_order_item_rows());
|
||||
console.log(oos_items);
|
||||
|
||||
var params = {'item_instance_code': oos_items};
|
||||
var ajax_url = '../out_of_stock/update';
|
||||
$.ajax({
|
||||
type: "PATCH",
|
||||
url: ajax_url,
|
||||
data: params,
|
||||
dataType: "json",
|
||||
success:function(result){
|
||||
if (result.status) {
|
||||
swal("Success",result.message,"success");
|
||||
}else{
|
||||
swal("Opps",result.message,"warning");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function get_order_item_rows(){
|
||||
var order_items = [];
|
||||
var item_row = $('.summary-items tbody tr');
|
||||
$(item_row).each(function(i){
|
||||
var order_item = {};
|
||||
|
||||
// order_item.item_name = $(item_row[i]).attr('data-item-name');
|
||||
order_item.item_instance_code = $(item_row[i]).attr('data-instance-code');
|
||||
|
||||
order_items.push(order_item);
|
||||
});
|
||||
return order_items;
|
||||
}
|
||||
|
||||
// click select option icon for add
|
||||
$(document).on('click', '.attribute_btn', function(event){
|
||||
|
||||
// $('.change_qty').val(1);
|
||||
value = $(this).data('value');
|
||||
type = $(this).data('type');
|
||||
instances = $(this).data('instances');
|
||||
|
||||
attributes = $(".attribute_btn");
|
||||
$(attributes).each(function(i){
|
||||
if ($(attributes[i]).attr('data-type')==type){
|
||||
$('.'+type).removeClass("selected-attribute");
|
||||
}
|
||||
});
|
||||
$(this).addClass('selected-attribute');
|
||||
|
||||
var selected_attr = get_selected_attributes('selected-attribute');
|
||||
|
||||
for(var field in instances) {
|
||||
item_attr = instances[field].values;
|
||||
|
||||
if(JSON.stringify(item_attr) == JSON.stringify(selected_attr)){
|
||||
$('#instance_code').val(instances[field].code);
|
||||
}
|
||||
}
|
||||
|
||||
}); //End selecct attribute buttom
|
||||
|
||||
// Get Selected Class
|
||||
function get_selected_attributes(selected_class) {
|
||||
var item_row = $('.'+selected_class);
|
||||
var attribute_arr = [];
|
||||
$(item_row).each(function(i){
|
||||
value = $(item_row[i]).attr('data-value');
|
||||
str = value;
|
||||
attribute_arr.push(str);
|
||||
});
|
||||
return attribute_arr;
|
||||
}
|
||||
|
||||
$(document).on('click', '.cashier_number', function(event){
|
||||
if(event.handled !== true) {
|
||||
var original_value;
|
||||
original_value = $('#modal-qty').attr('data-value');
|
||||
original_qty = $('#modal-qty').val();
|
||||
var input_type = $(this).attr("data-type");
|
||||
|
||||
switch (input_type) {
|
||||
case 'num':
|
||||
var input_value = $(this).attr("data-value");
|
||||
if (original_value == "0"){
|
||||
$('#modal-qty').val(input_value);
|
||||
$('#modal-qty').attr('data-value',input_value);
|
||||
// update_total_amount();
|
||||
}else{
|
||||
$('#modal-qty').val(original_qty + input_value);
|
||||
$('#modal-qty').attr('data-value',original_qty + input_value);
|
||||
// update_total_amount();
|
||||
}
|
||||
break;
|
||||
case 'add':
|
||||
|
||||
case 'del' :
|
||||
|
||||
case 'clr':
|
||||
$('#modal-qty').val(1);
|
||||
$('#modal-qty').attr('data-value',0);
|
||||
// update_total_amount();
|
||||
break;
|
||||
|
||||
}
|
||||
event.handled = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// click select option icon for add
|
||||
$(document).on('click', '.submit', function(event){
|
||||
|
||||
var item_code = $("#instance_code").val();
|
||||
var min_qty = $("#min_qty").val();
|
||||
var max_qty = $("#max_qty").val();
|
||||
var item_name = $("#item_name").val();
|
||||
|
||||
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>'
|
||||
});
|
||||
|
||||
|
||||
$('#back').on('click', function () {
|
||||
window.location.href = '/settings/out_of_stock';
|
||||
});
|
||||
$('#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>
|
||||
73
app/views/settings/out_of_stock/_out_of_stock_list.html.erb
Normal file
73
app/views/settings/out_of_stock/_out_of_stock_list.html.erb
Normal file
@@ -0,0 +1,73 @@
|
||||
<table class="table table-striped">
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.product") %></th>
|
||||
<th><%= t("views.right_panel.detail.status") %></th>
|
||||
<th><%= t("views.right_panel.detail.action") %></th>
|
||||
</tr>
|
||||
|
||||
<% cate_arr = Array.new %>
|
||||
<%
|
||||
count = 0
|
||||
@menu_items.each do |item|
|
||||
count += 1
|
||||
%>
|
||||
|
||||
<tr>
|
||||
<td><%= item.name rescue '-' %></td>
|
||||
<td>
|
||||
<% if item.is_out_of_stock %>
|
||||
<div class="badge badge-success">Active</div>
|
||||
<% else %>
|
||||
<div class="badge badge-danger">Inactive</div>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" class="delete btn btn-danger btn-sm waves-effect" data-ref="<%= settings_out_of_stock_path(item) %>" data-method="delete">
|
||||
<%= t("views.btn.reset") %>
|
||||
</button>
|
||||
<span class="hidden" id="delete_text">
|
||||
<h6>Are you sure you want to delete this row ?</h6>
|
||||
<h6>This action can't be undo. </h6>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
<script>
|
||||
|
||||
$('.show_track').on('click', function () {
|
||||
var ID = $(this).attr("data-value");
|
||||
window.location.href = '/inventory/'+ID+'/show';
|
||||
});
|
||||
|
||||
$(document).on('click', '.update', function(event){
|
||||
|
||||
var item_code = $("#instance_code").val();
|
||||
var min_qty = $("#min_qty").val();
|
||||
var max_qty = $("#max_qty").val();
|
||||
var item_name = $("#item_name").val();
|
||||
|
||||
console.log(item_code);
|
||||
console.log(min_qty);
|
||||
console.log(max_qty);
|
||||
var params = {'item_code': item_code,
|
||||
'min_order_level': min_qty,
|
||||
'max_stock_level': max_qty};
|
||||
var ajax_url = 'settings_update_menu_items_path';
|
||||
$.ajax({
|
||||
type: "PATCH",
|
||||
url: ajax_url,
|
||||
data: params,
|
||||
dataType: "json",
|
||||
success:function(result){
|
||||
if (result.status) {
|
||||
swal("Success",result.message,"success");
|
||||
}else{
|
||||
swal("Opps",result.message,"warning");
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
45
app/views/settings/out_of_stock/index.html.erb
Normal file
45
app/views/settings/out_of_stock/index.html.erb
Normal file
@@ -0,0 +1,45 @@
|
||||
<div class="page-header">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="<%= dashboard_path %>"><%= t("views.right_panel.button.home") %></a></li>
|
||||
<li class="breadcrumb-item active"><%= t :out_of_stock %></li>
|
||||
<span class="float-right">
|
||||
<%= link_to t('.back', :default => t("views.btn.back")), dashboard_path %>
|
||||
</span>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<div class="row ">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4" style="padding-left: 17px;">
|
||||
<%= form_tag inventory_path, :id => "filter_form", :method => :get do %>
|
||||
<input type="text" class="form-control" name="filter" id="Product" type="text" placeholder="Product" style="height: 32px;">
|
||||
</div>
|
||||
|
||||
<div class="col-lg-2 col-md-2 col-sm-2 text-">
|
||||
<input type="submit" value="Filter" class='btn btn-primary'>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="col-lg-6 col-md-6 col-sm-6" style="padding-right: 15px;">
|
||||
<button type="button" class="delete btn btn-danger btn-sm float-right waves-effect" style='margin-left:5px;' data-ref="<%= settings_reset_all_path %>" data-method="delete">
|
||||
<%= t("views.btn.reset_all") %>
|
||||
</button>
|
||||
<button id='new_out_of_stock' class='btn btn-primary float-right waves-effect' style='margin-left:5px;'><%= (t :new_out_of_stock) +" " %> <%= t("views.right_panel.detail.item") %></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
|
||||
<div class="card">
|
||||
<%= render 'out_of_stock_list' %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
$('#new_out_of_stock').on('click',function(){
|
||||
window.location.href = '/settings/out_of_stock/new';
|
||||
});
|
||||
|
||||
</script>
|
||||
2
app/views/settings/out_of_stock/new.html.erb
Normal file
2
app/views/settings/out_of_stock/new.html.erb
Normal file
@@ -0,0 +1,2 @@
|
||||
<br>
|
||||
<%= render 'form'%>
|
||||
Reference in New Issue
Block a user