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

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

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

<h2>配信先検索条件設定</h2>
<%=h flash[:notice] %>
<%=h flash[:errors] %>
<%= render :partial => "form"%>

<% form_for :condition, :url => {:action => 'template_search'} do | f | %>
  <p>&gt;&gt;検索結果一覧&nbsp;<%=@customers.total_entries %>件&nbsp;が該当しました</p>
  <div class="btn_box space20_bottom">
    <%= submit_tag '配信内容を設定する', :class=>"btn" %>
    <%= image_tag("btn_side.gif", :width => "6", :height => "34", :class => "btn_side") %>
  </div>
  <table class="data2 clear" cellspacing="1">
    <tr>
      <th>#</th>
      <th>会員番号</th>
      <th>受注番号</th>
      <th>名前</th>
      <th>メールアドレス</th>
      <th>希望配信</th>
      <th>登録日</th>
      <th>
        <%= check_box_tag "check_all", @customer_ids, @check_all,
          :onchange => remote_function(
            :url => {:action => 'except_customers'},
            :with => "'customer_ids='+value+'&checked='+this.checked",
            :complete => "all_check()") %>除外
      </th>
    </tr>
    <%= hidden_field_tag 'customer_ids', @customer_ids %>
    <% @customers.each_with_index do |c, i| %>
    <tr>
      <td><%=h (@customers.offset + (i+1)) %></td>
      <td><%=h c.id %></td>
      <td><%=h c.last_order_code %></td>
      <td>
        <%=h c.name_kanji %>／
        <%=h c.name_kana %>
      </td>
      <td><%=h c.email %></td>
      <td><%= Customer::MAILMAGAZINE_NAMES[c.receive_mailmagazine.to_i] %></td>
      <td><%= c.updated_at.strftime("%Y-%m-%d") %></td>
      <td>
        <%= check_box_tag 'checked[]', c.id, c.excepted,
              :onchange => remote_function(
                           :url => {:action => 'except_customer'},
                           :with => "'id='+value+'&checked='+this.checked") %>
      </td>
    </tr>
    <% end %>
  </table>
<% end %>
<% condition=@condition.nil? ? nil : {:condition => params[:condition]} %>
<%= will_paginate @customers, :params => condition %>

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