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

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

<h2>商品マスタ管理</h2>
<%=h flash[:notice] %>
<%=h flash[:error] %>
<%= render :partial => "search" %>
<br />

<% form_tag ({:action => 'csv_download'}.merge(:search => @search.to_params)) do %>
  <%- params[:product_status_ids] and params[:product_status_ids].each do |value| -%>
    <%= hidden_field_tag 'product_status_ids[]', value %>
  <%- end -%>
  <br />
  <p>&gt;&gt;検索結果一覧&nbsp;<%=@products.total_entries %>件&nbsp;が該当しました</p>
  <div class="btn_box space20_bottom">
    <%= submit_tag 'CSV DOWNLOAD', :class=>"btn" %>
    <%= image_tag("btn_side.gif", :width => "6", :height => "34", :class => "btn_side") %>
  </div>
<% end %>
<% form_tag :action => "permit_setting" do %>
  <table class="data2 clear" cellspacing="1">
    <tr>
      <th>商品ID</th>
      <th>商品画像</th>
      <th>価格</th>
      <th>商品名</th>
      <th>カテゴリ</th>
      <th>公開</th>
      <th>商品<br />詳細</th>
      <th>規格</th>
      <th>削除</th>
      <th>複製</th>
    </tr>
    <% @products && @products.each do | product | %>
      <tr>
        <td><%= h product.id %></td>
        <td><%= product_image_tag product, :small %></td>
        <td><%= h product.price_range.join('～') %></td>
        <td><%= h product.name %></td>
        <td><%= h product.category_name %></td>
        <td>
          <%= check_box_tag "product_permit[#{product.id}]",true, product.permit%>
          <%= hidden_field_tag "product_permit_ids[]", product.id%>
        </td>
        <td class="t_center">
          <%= link_to "編集", edit_admin_product_path(product.id) %><br />
          <%= link_to_product product,  "確認", {:target => "_blank"} %>
        </td>
        <td class="t_center"><%= link_to "規格", new_admin_product_style_path(:id => product.id) %></td>
        <td class="t_center">
          <%= link_to "削除", admin_product_path(product.id), :confirm => "本当に削除しますか？", :method=>"delete" %>
        </td>
        <td class="t_center">
          <%= link_to "複製", new_admin_product_path(:id => product.id, :copy => true) %>
        </td>
      </tr>
    <% end %>
  </table>

  <% params.each do |key, value| %>
    <% if key == "search" %>
      <% value.each do | key_2, value_2 | %>
        <%= hidden_field_tag key_2, value_2 %>
      <% end %>
    <% elsif key == "action" || key == "controller" %>
    <% else %>
      <%= hidden_field_tag key, value %>
    <% end %>
  <% end %>
  <div class="t_center btn_t"><%= submit_tag "登録", :class=>"btn_s" %></div>
<% end %>
<%= will_paginate @products, :params => {:search => params[:search], :product_status_ids => params[:product_status_ids] } %>

<h3>CSVアップロード</h3>
<br />
<% form_tag({:action => 'csv_upload'}, {:multipart => true}) do %>
<p>アップロードファイル<br>
  <%= file_field_tag(:upload_file) %>
</p>
<%= submit_tag("アップロード") %>
<% end %>

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