<%= stylesheet_link_tag "stock/stock" %>

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

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

<h2>在庫移動</h2>

<h3>商品情報</h3>

<%= error_messages_for :record %>
<% form_for :record, :url => {:action => 'create' } do |f| %>
 <table class="product_info" cellspacing="1">
  <tr>
   <th>商品ID</th>
   <td><%=h @record.product_id %></td>
   <th>商品コード</th>
   <td><%=h @record.product_code %></td>
  </tr>
  <tr>
   <th>商品名</th>
   <td><%=h @record.product_name %></td>
   <th>登録・更新日</th>
   <td><%= date @record.product_style.updated_at %></td>
  </tr>
  <tr>
   <th>規格名称</th>
   <td>
    <%=h @record.product_style.style_category_name1 %>
    <%=h @record.product_style.style_category_name2 %>
   </td>
  </tr>
 </table>

<h3>移動内容入力</h3>

 <table  class="move" cellspacing="1">
  <tr>
   <th>移動理由</th>
   <td colspan="3">
    <%= f.collection_select :reason, Constant.list(Constant::MOVEMENT_REASON), :id, :value %>
   </td>
  </tr>
  <tr>
   <th>受注コード</th>
   <td>
    <%= f.text_field :order_code %>
   </td>
   <th>返品コード</th>
   <td>
    <%= f.text_field :recall_code %>
   </td>
  </tr>
  <tr>
   <th>発注コード</th>
   <td colspan="3">
    <%= f.text_field :purchase_code %>
   </td>
  </tr>
 </table>

 <p>※調整数には移動させる数量を入力してください。
  例：実在庫数を1つ減らす場合、「-1」を入力
 </p>

 <table cellspacing="1">
  <tr>
   <th>発注予定数</th>
   <td><%=h @record.product_style.scheduled_count %></td>
   <th>発注済数</th>
   <td><%=h @record.product_style.purchased_count %></td>
   <th>受注可能数</th>
   <td><%=h @record.product_style.orderable_count %></td>
   <th>実在庫数</th>
   <td><%=h @record.product_style.actual_count %></td>
   <th>不良在庫数</th>
   <td><%=h @record.product_style.broken_count %></td>
   <!--<th>引当可能数</th>
   <td><%=h @record.product_style.assignable_count %></td>-->
  </tr>
  <tr>
   <th>調整数</th>
   <td><%= f.number_field :scheduled_adjustment, :size=>4 %></td>
   <th>調整数</th>
   <td><%= f.number_field :purchased_adjustment, :size=>4 %></td>
   <th>調整数</th>
   <td><%= f.number_field :orderable_adjustment, :size=>4 %></td>
   <th>調整数</th>
   <td><%= f.number_field :actual_adjustment, :size=>4 %></td>
   <th>調整数</th>
   <td><%= f.number_field :broken_adjustment, :size=>4 %></td>
   <!--<th>&nbsp;</th>
   <td>&nbsp;</td>-->
  </tr>
 </table>

 <p>
  コメント
  <%= f.text_area :comment, :cols=>"50", :rows=>"5" %>
 </p>

 <p>
  <%= f.hidden_field :product_style_id %>
  <%= submit_tag '反映する' %>
 </p>

 <h3>未発送受注一覧</h3>
 <% if @active_orders %>
 <table cellspacing="1">
  <tr>
   <th>受注番号</th>
   <th>ステータス</th>
   <th>個数</th>
  </tr>
  <% @active_orders.each do |ao| %>
  <tr>
   <td>
    <%= link_to ao.order_code, :controller=>'admin/order', :action=>:edit, :id=>ao.order_id %>
   </td>
   <td>
    <%=h ao.status %>
   </td>
   <td>
    <%= number_with_delimiter ao.count %>
   </td>
  </tr>
  <% end %>
  <tr>
   <th colspan="2">合計</th>
   <td><%= number_with_delimiter @active_orders_sum %></td>
  </tr>
 </table>
 <% else %>
 <table cellspacing="1" width="100%"><tr><td>なし</td></tr></table>
 <% end %>

<% end %>
</div>
</div>
