<%= stylesheet_link_tag "stock/stock" %>

<%= render :partial => "submenu" %>

<div class="set">
<div class="contents_area">

<h2>在庫管理</h2>
<p><%= flash[:notice] %>
<% form_for :search, :url => {:action => 'search'} do |f| %>
 <table class="product_info" cellspacing="1">
  <tr>
   <th>商品ID</th>
   <td><%= f.text_field :product_id %></td>
   <th>規格名称</th>
   <td><%= f.text_field 'style_category_name' %></td>
  </tr>
  <tr>
   <th>商品コード</th>
   <td><%= f.text_field :code %></td>
   <th>商品名</th>
   <td><%= f.text_field 'product_name' %></td>
  </tr>
  <tr>
   <th>カテゴリ</th>
   <td><%= f.category_select 'product_category_id', :include_blank => true %></td>
   <th>種別</th>
   <td>
    <%= f.select :permit, Product.permit_select, :include_blank => '全体' %>
   </td>
  </tr>
  <tr>
   <th>登録・更新日</th>
   <td colspan="3" style="width:580px;">
    <%= f.date_select 'updated_at_from', :use_month_numbers => true, :include_blank => true  %>
    ～
    <%= f.date_select 'updated_at_to', :use_month_numbers => true, :include_blank => true  %>
   </td>
  </tr>
 </table>
 <p class="submit">
  検索結果表示件数
   <%= f.select :per_page, (10..100).step(10).map(&:to_s) %>件
  <%= submit_tag "この条件で検索する" %>
 </p>
<% end %>
<% if @records %>
 <p>検索結果一覧 <%= @records.total_entries %> 件が該当しました。</p>
 <table class="result" cellspacing="1">
  <tr>
   <th>商品名</th><th>商品コード</th><th>規格名称</th><th>会社名</th><th>登録更新日</th><th>発注予定数</th><th>発注済み数</th><th>受注可能数</th><th>実在庫数</th><th>在庫移動</th>
  </tr>
 <% @records.each do |record| %>
  <tr>
   <td><%=h record.product.name %></td>
   <td><%=h record.code %></td>
   <td>
    <%=h record.style_category_name1 %>
    <%=h record.style_category_name2 %>
   </td>
   <td><%=h record.product.supplier_name %></td>
   <td><%=date record.updated_at %></td>
   <td><%=h record.scheduled_count %></td>
   <td><%=h record.purchased_count %></td>
   <td><%=h record.orderable_count %></td>
   <td><%=h record.actual_count %></td>
   <td><%= link_to '在庫移動', :action=>'new', :id=>record.id %></td>
  </tr>
 <% end %>
</table>
<%= will_paginate @records, :params=>{:search => params[:search]} %>
<% end %>

</div>
</div>
