<% content_for :head do %>
 <%= javascript_include_tag 'admin/order_status' %>
<% end %>

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

<div id="main"><!-- メイン -->

<h2>ステータス管理</h2>


<div>
<%-
@statuses = OrderDelivery::STATUS_NAMES.sort_by do | status, name |
  status
end
-%>
<ul class="status_list">
 <% @statuses.each do | status, name | %>
  <li><%= link_to name, { :action => "index", :select => status } %></li>
 <% end %>
</ul>
</div>
<% form_tag :action => "update" do %>
 <div class="t_center">
  <%= hidden_field_tag 'select', @selected_status %>
  <%= select_tag 'new_status', options_for_select(@statuses.map{|a,b|[b,a]}) %>
  <span class="btn_t"><%= submit_tag "反映", :class=>"btn_s" %></span>
 </div>
 <p class="btn_t t_right">
  <input type="button" class="checkall btn_s" value="全て選択" />
  <input type="button" class="uncheckall btn_s" value="全て解除" />
 </p>
 <%=h flash[:status] %>
 <%=h flash[:status_e] %>
 <table class="data2" cellspacing="1">
  <tr>
   <th>受注番号</th>
   <th>受注日</th>
   <th>顧客名</th>
   <th>支払方法</th>
   <th>発送伝票番号</th>
   <th>発送日</th>
   <th>対応状況</th>
   <th>選択</th>
  </tr>
  <tr>
  <% @order_deliveries.each do | order_delivery | %>
   <tr>
    <td><%= link_to(order_delivery.order_code, {:controller => 'admin/orders', :action => :show, :id => order_delivery.order_id}, :target=>'_blank') %></td>
    <td><%= date(order_delivery.received_at) %></td>
    <td><%=h order_delivery.family_name %> <%=h order_delivery.first_name %></td>
    <td><%=h order_delivery.payment_name %></td>
    <td>
      <%= text_field_tag "order_delivery_ticket_code[#{order_delivery.id}]", order_delivery.ticket_code %>
    </td>
    <td><%= date(order_delivery.shipped_at) %></td>
    <td><%=h order_delivery.status_view %></td>
    <td><%= check_box_tag "id_array[]", order_delivery.id %></td>
   </tr>
  <% end %>
 </table>
 <p class="btn_t t_right">
  <input type="button" class="checkall btn_s" value="全て選択" />
  <input type="button" class="uncheckall btn_s" value="全て解除" />
 </p>
<%= will_paginate @order_deliveries %>
<% end %>

<br />

<h3>CSVステータス更新</h3>
<br />
<% form_tag({:action => 'csv_upload'}, {:multipart => 'true'}) do %>
<p>CSVからステータスを更新します。</p>
<p>アップロードファイル<br />
  <%= file_field_tag(:upload_file) %>
</p>
<br />
<div class="btn_t">
  <%= submit_tag "アップロード", :class=>"btn_s" %>
</div>
<% end %>

</div><!-- /メイン -->
