<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="content-style-type" content="text/css">
    <title><%= @title || "管理画面" %></title>
    <%= javascript_include_tag 'admin/feature_products' %>
    <%= stylesheet_link_tag "admin" %>
  </head>

  <body>

<div id="wrapper" class="clearfix">

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

      <h2>特集商品検索</h2>
      <% form_for :condition, :url => {:action => 'product_search'} do | f | %>
        <table cellspacing="1" collpadding="0" class="data">
          <tr>
		    <th>カテゴリ</th>
		    <td><%=
	          categories = Category.find(:all, :order => "position").map {|p| [p.name, p.id.to_s]}
			  f.select :category_id, categories, :include_blank=>true %>
		    </td>
          </tr>
          <tr>
            <th>商品名</th>
            <td><%= f.text_field :keyword %></td>
          </tr>
        </table><br />

        <%= f.submit "検索開始", :action=>"search" %>
        <input type="hidden" name="condition[searched]" value="true"/>
        <!--<%= hidden_field_tag 'recommend_id', @recommend_id %>-->
      <% end %>

      <br />

      <% if @products %>
        <hr/>
        <div><%= @products.total_entries %>件が該当いたしました。</div><br />
        <table cellspacing="1" class="data2">
          <tr>
            <th>画像</th>
            <th>商品番号</th>
            <th>商品名</th>
            <th>決定</th>
          </tr>
          <% @products.each do |style| %>
	      <tr>
	        <td><%= product_image_tag(style.product, :small) %></td>
	        <td><%=h style.code %></td>
	        <td><span id=<%=h style.code %> ><%=h style.product.name  %></span></td>
	        <td><input type="button" class="btn_s" name="decide" value="決定" onclick="fnProductSubmit(<%=h style.product_id %>, <%=h style.product.small_resource_id %>, '<%=h style.product.name.gsub(/\'/, '&#39;') %>'); return false;"></td>
	      </tr>
          <% end %>
        </table>
        <% condition=@condition.nil? ? nil : {:condition => params[:condition]} %>
        <%= will_paginate @products, :params => condition %>
      <% end %>


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