update inventory
This commit is contained in:
@@ -26,26 +26,44 @@ class Inventory::InventoryDefinitionsController < BaseInventoryController
|
||||
# POST /inventory_definitions
|
||||
# POST /inventory_definitions.json
|
||||
def create
|
||||
inventory = InventoryDefinition.find_by_item_code(inventory_definition_params[:item_code])
|
||||
inventory = InventoryDefinition.find_by_item_code(params[:item_code])
|
||||
if inventory.nil?
|
||||
@inventory_definition = InventoryDefinition.new(inventory_definition_params)
|
||||
|
||||
@inventory_definition = InventoryDefinition.new
|
||||
@inventory_definition.item_code = params[:item_code]
|
||||
@inventory_definition.min_order_level = params[:min_order_level]
|
||||
@inventory_definition.max_stock_level = params[:max_stock_level]
|
||||
@inventory_definition.save
|
||||
else
|
||||
@inventory_definition = InventoryDefinition.find(inventory.id)
|
||||
@inventory_definition.min_order_level = inventory_definition_params[:min_order_level]
|
||||
@inventory_definition.max_stock_level = inventory.max_stock_level.to_i + inventory_definition_params[:max_stock_level].to_i
|
||||
@inventory_definition.min_order_level = params[:min_order_level]
|
||||
@inventory_definition.max_stock_level = inventory.max_stock_level.to_i + params[:max_stock_level].to_i
|
||||
end
|
||||
@inventory_definition.created_by = current_user.id
|
||||
respond_to do |format|
|
||||
if @inventory_definition.save
|
||||
format.html { redirect_to inventory_path, notice: 'Inventory definition was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @inventory_definition }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @inventory_definition.errors, status: :unprocessable_entity }
|
||||
end
|
||||
if @inventory_definition.save
|
||||
result = {:status=> true, :message => "Inventory definition was created successfully",:data=> @inventory_definition}
|
||||
else
|
||||
result = {:status=> false, :message => "Inventory definition was created successfully",:data=> @inventory_definition}
|
||||
end
|
||||
|
||||
|
||||
render :json => result.to_json
|
||||
# inventory = InventoryDefinition.find_by_item_code(inventory_definition_params[:item_code])
|
||||
# if inventory.nil?
|
||||
# @inventory_definition = InventoryDefinition.new(inventory_definition_params)
|
||||
# else
|
||||
# @inventory_definition = InventoryDefinition.find(inventory.id)
|
||||
# @inventory_definition.min_order_level = inventory_definition_params[:min_order_level]
|
||||
# @inventory_definition.max_stock_level = inventory.max_stock_level.to_i + inventory_definition_params[:max_stock_level].to_i
|
||||
# end
|
||||
# @inventory_definition.created_by = current_user.id
|
||||
# respond_to do |format|
|
||||
# if @inventory_definition.save
|
||||
# format.html { redirect_to inventory_path, notice: 'Inventory definition was successfully created.' }
|
||||
# format.json { render :show, status: :created, location: @inventory_definition }
|
||||
# else
|
||||
# format.html { render :new }
|
||||
# format.json { render json: @inventory_definition.errors, status: :unprocessable_entity }
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
# PATCH/PUT /inventory_definitions/1
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<button type="button" data-value="<%= item.id %>" class="btn bg-blue waves-effect btn-link show_track"><%= t("views.btn.show") %> <%= t("views.right_panel.detail.stock_check") %></button>
|
||||
<button type="button" data-value="<%= item.id %>" class="btn bg-blue waves-effect btn-link show_track"> <%= t("views.right_panel.detail.stock_ledger") %></button>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- <tr>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<!-- <button id="stock_check_report" type="button" class="btn bg-blue float-right waves-effect" style='margin-left:5px;'> <%= t("views.btn.stock_check_report") %>
|
||||
</button> -->
|
||||
<button id="stock_taking" type="button" class="btn bg-blue float-right waves-effect" style='margin-left:5px;'> <%= t("views.btn.stock_taking") %></button>
|
||||
<button id='new_inventory_product' class='btn btn-primary float-right waves-effect' style='margin-left:5px;'><%= (t :track) +" "+ t("views.btn.new") + " " + (t :inventory) %>
|
||||
<button id='new_inventory_product' class='btn btn-primary float-right waves-effect' style='margin-left:5px;'><%= (t :track) +" "+ t("views.btn.new") + " " %> <%= t("views.right_panel.detail.item") %>
|
||||
</button>
|
||||
</div>
|
||||
<div class="card">
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-9 col-lg-9 col-sm-9 m-t-10" >
|
||||
<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">
|
||||
@@ -73,10 +73,33 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-1 col-sm-1" >
|
||||
<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>
|
||||
</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='stock_taking'>Stock Taking
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -88,31 +111,34 @@
|
||||
<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">
|
||||
<%= simple_form_for([:inventory, @inventory_definition]) do |f| %>
|
||||
|
||||
|
||||
<div class="form-inputs">
|
||||
|
||||
<div class="form-group">
|
||||
<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>
|
||||
<%= f.input :item_code , :as => :hidden,:input_html=>{:id=>"instance_code"} %>
|
||||
</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>
|
||||
<%= f.input :min_order_level,:input_html=>{:value=>"1",:class=>"col-md-5"} %>
|
||||
<%= f.input :max_stock_level,:input_html=>{:value=>"1",:class=>"col-md-5"} %>
|
||||
<div class="form-actions">
|
||||
<%= f.submit t("views.btn.submit"), class: 'btn bg-blue waves-effect' %>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="attribute">Min Order Level</label>
|
||||
<input type="text" name="min_order_level" id="min_qty" value="1" class="col-md-5 form-control">
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="attribute">Max Order Level</label>
|
||||
<input type="text" name="max_order_level" id="max_qty" value="1" class="col-md-5 form-control">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<!-- <div class="modal-footer">
|
||||
<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>
|
||||
@@ -121,8 +147,8 @@
|
||||
<button type="button" class="btn btn-primary submit " data-dismiss="modal" id="submit">Submit</button>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<style type="text/css">
|
||||
@@ -563,26 +589,49 @@
|
||||
|
||||
// click select option icon for add
|
||||
$(document).on('click', '.submit', function(event){
|
||||
var params = { 'item_code': $("#item_code").val(),
|
||||
'min_order_level': $("#min_qty").val(),
|
||||
'max_stock_level': $("#max_qty").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();
|
||||
|
||||
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 = '<%=inventory_inventory_definitions_path%>';
|
||||
console.log(ajax_url)
|
||||
$.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="">' + item_name +'</td>'
|
||||
+'<td class="">' + min_qty + '</td>'
|
||||
+'<td class="">' + max_qty + '</td>'
|
||||
+'</tr>';
|
||||
$(".summary-items tbody").append(row);
|
||||
swal("Success",result.message,"success");
|
||||
}else{
|
||||
swal("Opps",result.message,"warning");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
$('#back').on('click', function () {
|
||||
window.location.href = '/inventory';
|
||||
});
|
||||
$('#stock_taking').on('click', function () {
|
||||
window.location.href = '/inventory/stock_checks';
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
@@ -71,10 +71,7 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group">
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="attribute">Stock Check Reason</label>
|
||||
<input type='text' id='stock_check_reason' class='form-control' placeholder="Set Stock Check Reason" value=''/>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="attribute">Item</label>
|
||||
<input type='text' id='item' class='form-control' readonly="true" value=''/>
|
||||
@@ -87,7 +84,12 @@
|
||||
<input type="hidden" id="item_code" value="">
|
||||
<input type="hidden" id="item_name" value="">
|
||||
<input type="hidden" id="instance_name" value="">
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label" for="attribute">Stock Check Reason</label>
|
||||
<input type='text' id='stock_check_reason' class='form-control' placeholder="Set Stock Check Reason" value=''/>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="button" class="btn btn-primary" data-dismiss="modal" id="save_to_stock_check">Save</button>
|
||||
<!-- <button type="button" class="btn btn-primary add_to_order " data-dismiss="modal" id="add_to_order">Add to Order<div class="ripple-container"></div></button> -->
|
||||
|
||||
@@ -19,7 +19,7 @@ class ActionController::Base
|
||||
render :json => [{ status: false, message: 'Invalid Access!'}]
|
||||
end
|
||||
else
|
||||
# check for license file
|
||||
check for license file
|
||||
if check_license
|
||||
current_license(ENV["SX_PROVISION_URL"])
|
||||
else
|
||||
|
||||
@@ -346,6 +346,7 @@ en:
|
||||
inventory: "inventory"
|
||||
stock_taking: "Stock Taking"
|
||||
stock_check: "Stock Check"
|
||||
stock_ledger: "Stock Ledger"
|
||||
stock_check_report: "Stock Check Report"
|
||||
min_order: "Min Order"
|
||||
max_stock: "Max Stock"
|
||||
|
||||
@@ -340,6 +340,7 @@ mm:
|
||||
inventory: "ကုန်လှောင်ရုံစာရင်း"
|
||||
stock_taking: "စတော့ကောက်သည်"
|
||||
stock_check: "စတော့စစ်ဆေးသည်"
|
||||
stock_ledger: "စတော့စစ်ဆေးသည်"
|
||||
stock_check_report: "စတော့စစ်ဆေးမှုမှတ်တမ်း"
|
||||
min_order: "အနည်းဆုံးမှာယူမှု"
|
||||
max_stock: "အများဆုံးစတော့"
|
||||
|
||||
@@ -522,6 +522,8 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
get ':inventory_definition_id/show' => 'inventory#show'
|
||||
|
||||
get 'get_menu_category/:id' => "stock_checks#get_menu_category",:as => "get_menu_category", :defaults => { :format => 'json' }
|
||||
|
||||
post 'inventory_definitions/create_inventory' => 'inventory_definitions#create_inventory'
|
||||
end
|
||||
#mount_compendium at: '/report' #, controller: 'reports'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user