pull origin master
This commit is contained in:
@@ -1,15 +1,84 @@
|
||||
<%= simple_form_for([:inventory, @inventory_definition]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<%= simple_form_for([:inventory,@inventory_definition]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
<div class="form-inputs">
|
||||
<div class="row">
|
||||
<% arr = MenuItem.active.order("name desc").pluck(:name, :item_code) %>
|
||||
<% Product.order("name desc").pluck(:name, :item_code).each do |p| %>
|
||||
<% arr.push(p) %>
|
||||
<% end %>
|
||||
<div class="col-md-3">
|
||||
<label class="control-label"><abbr title="required">*</abbr> Item</label>
|
||||
<select class="form-control item_code_place" id="item">
|
||||
<% if !@inventory_definition.item_code.nil? %>
|
||||
<% menuiteminstance = MenuItemInstance.find_by_item_instance_code(@inventory_definition.item_code) %>
|
||||
<% if menuiteminstance.nil? %>
|
||||
<% code = @inventory_definition.item_code %>
|
||||
<% else %>
|
||||
<% code = menuiteminstance.menu_item.item_code %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<option value=""></option>
|
||||
<% arr.each do |a| %>
|
||||
<% if a[1] == code %>
|
||||
<option value="<%= a[1] %>" selected><%= a[0] %></option>
|
||||
<% else %>
|
||||
<option value="<%= a[1] %>"><%= a[0] %></option>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.input :item_code %>
|
||||
<%= f.input :min_order_level %>
|
||||
<%= f.input :max_stock_level %>
|
||||
</div>
|
||||
<% sample = [] %>
|
||||
<% if @inventory_definition.item_code.nil? %>
|
||||
<% if !MenuItemInstance.find_by_item_instance_code(@inventory_definition.item_code).nil? %>
|
||||
<% sample = MenuItemInstance.where("item_instance_code=?", @inventory_definition.item_code).pluck(:item_instance_name, :item_instance_code) %>
|
||||
<% else %>
|
||||
<% sample = Product.where("item_code=?", @inventory_definition.item_code).pluck(:name, :item_code) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="col-md-3"><%= f.input :item_code, collection: sample %></div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.button :submit %>
|
||||
</div>
|
||||
<%= f.input :min_order_level %>
|
||||
<%= f.input :max_stock_level %>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= link_to 'Back', inventory_path, class: 'btn btn-success' %>
|
||||
<%= f.button :submit, class: 'btn btn-primary' %>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
||||
<script>
|
||||
|
||||
$(document).ready(function () {
|
||||
$(".item_code_place").select2({
|
||||
placeholder: 'Select Item'
|
||||
});
|
||||
$("select#inventory_definition_item_code").select2();
|
||||
|
||||
$(".item_code_place").on('change', function (event) {
|
||||
var ajax_url = "<%= settings_find_item_instance_path %>";
|
||||
var item_code = this.value;
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: ajax_url,
|
||||
data: 'item_code=' + item_code,
|
||||
success: function (result) {
|
||||
$("#inventory_definition_item_code").empty();
|
||||
var itemlist;
|
||||
for (var i = 0; i < result.length; i++) {
|
||||
itemlist = "<option value ='" + result[i][1] + "'>" + result[i][0] + "</option>";
|
||||
$("select#inventory_definition_item_code").append(itemlist);
|
||||
}
|
||||
// $("select#inventory_definition_item_code").append(itemlist);
|
||||
$("select#inventory_definition_item_code").select2();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
@@ -1,6 +1,10 @@
|
||||
<h1>Editing Inventory Definition</h1>
|
||||
|
||||
<%= render 'form', inventory_definition: @inventory_definition %>
|
||||
|
||||
<%= link_to 'Show', @inventory_definition %> |
|
||||
<%= link_to 'Back', inventory_definitions_path %>
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= root_path %>">Home</a></li>
|
||||
<li><a href="<%= inventory_path %>">Product Inventory</a></li>
|
||||
<li>Edit</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render 'form', inventory: @inventory_definition %>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user