<% form_for :condition, :url => {:action => 'search'} do |f| %>
  <%= f.error_messages %>
  <%= flash[:magazine]%>
  <%= flash[:magazine_e]%>
  <%= hidden_field_tag "on_form", true %>
  <table class="data" cellspacing="1">
    <tr>
      <th>顧客名</th>
      <td><%= f.text_field :customer_name_kanji, :class=>"data_m" %></td>
      <th>顧客名（カナ）</th>
      <td><%= f.text_field :customer_name_kana, :class=>"data_m" %></td>
    </tr>
    <tr>
      <th>都道府県</th><td><%=
        prefectures = Prefecture.find(:all, :order => "position").map {|p| [p.name, p.id.to_s]}
        f.select :prefecture_id, prefectures, :include_blank=>true %></td>
      <th>TEL</th>
      <td><%= f.text_field :tel_no %></td>
    </tr>
    <tr>
      <th>性別</th>
      <td>
        <%= f.check_box :sex_male, {}, "1", "0" %>男性&nbsp;
        <%= f.check_box :sex_female, {}, "1", "0" %>女性
      </td>
      <th>誕生月</th>
      <td><%= f.select :birth_month, ((1..12).map &:to_s), :include_blank=>true %></td>
    </tr>
    <tr>
      <th>配信形式</th>
      <td>
        <%= f.radio_button :form_type, 0, {:checked=>true} %>両方
        <%= f.radio_button :form_type, MailMagazineTemplate::HTML %>HTML
        <%= f.radio_button :form_type, MailMagazineTemplate::TEXT %>TEXT
      </td>
      <th>購入回数</th>
      <td>
        <%= f.text_field :order_count_up, :size => 5 %>&nbsp;回 ～
        <%= f.text_field :order_count_down, :size => 5 %>&nbsp;回
      </td>
    </tr>
    <tr>
      <th>購入商品コード</th><td><%= f.text_field :product_code, :class=>"data_m" %></td>
      <th>購入金額</th>
      <td>
        <%= f.text_field :total_up, :class=>"data_s" %>&nbsp;円 ～
        <%= f.text_field :total_down, :class=>"data_s" %>&nbsp;円
      </td>
    </tr>
    <tr>
      <th>メールアドレス</th>
      <td colspan="3"><%= f.text_field :email, :class=>"data_m" %></td>
    </tr>
    <tr>
      <th>配信メールアドレス種別</th>
      <td colspan="3" style="width:600px;">
        <%= f.radio_button :mail_type, 0, {:checked=>true} %>パソコン用アドレス
        <%= f.radio_button :mail_type, 1 %>携帯用アドレス
      </td>
    </tr>
    <tr>
      <th>職業</th>
      <td colspan="3" style="width:600px">
        <% Occupation.find(:all, :order => 'position').each do |occupation| %>
          <%= check_box_tag "condition[occupation_id][]", occupation.id,
            (@condition.occupation_id || []).include?(occupation.id.to_s) %>
          <%= occupation.name %>
        <% end %>
      </td>
    </tr>
    <tr>
      <th>誕生日</th>
      <td colspan="3" style="width:600px">
        <%= f.birthday_select :birthday_from, :use_month_numbers => true, :include_blank=>true %>&nbsp～&nbsp
        <%= f.birthday_select :birthday_to, :use_month_numbers => true, :include_blank=>true %>
      </td>
    </tr>
    <tr>
      <th>登録日</th>
      <td colspan="3" style="width:600px">
        <%= f.date_select :updated_at_from, :use_month_numbers => true, :include_blank=>true %>&nbsp～&nbsp
        <%= f.date_select :updated_at_to, :use_month_numbers => true, :include_blank=>true %>
      </td>
    </tr>
    <tr>
      <th>最終購入日</th>
      <td colspan="3" style="width:600px">
        <%= f.date_select :last_order_from, :use_month_numbers => true, :include_blank=>true %>&nbsp;～&nbsp;
        <%= f.date_select :last_order_to, :use_month_numbers => true, :include_blank=>true %>
      </td>
    </tr>
    <tr>
      <th>購入商品名</th><td><%= f.text_field :product_name, :class=>"data_m" %></td>
      <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 colspan="3"><%=
        campaigns = Campaign.find(:all, :order => 'updated_at DESC').map {|rec| [rec.name, rec.id.to_s]}
        f.select :campaign_id, campaigns, :include_blank=>true %>
      </td>
    </tr><!-- favoriteCharactors deleted -->
      <td colspan="4" class="submit" >
      検索結果表示件数
      <%= f.select :search_par_page, (10..100).step(10).map(&:to_s) %>
          件
      <%= f.submit 'この条件で検索する', :class=>"btn_s" %></td>
    </tr>
  </table>
<% end %>
