<%# requirements: mode, project, and_op, period_begin, period_end %>

<form action="<%= mode.url %>" method="<%= Config[:search_form_method] %>" >
<table>
  <% project.report_type.each do |etype| %>
  <tr>
    <th><%= etype.name %></th>
    <td><%= etype.html_search(@cgi) %></td>
  </tr>
  <% end %>

  <tr>
    <th>Date range</th>
    <td>
      <select name="period_type">
      <% SearchPeriodType.each() do |ptype| %>
        <% selected = @cgi.get_param('period_type') == ptype.id ? 'selected="selected"' : '' %>
        <option value="<%= ptype.id %>" <%= selected %>><%= ptype.name %></option>
      <% end %>
      </select><br>

      From (yyyy/mm/dd) <input type="text" size="4" name="b_year"  
             value="<%= period_begin.year.to_s.escape_h %>"> /
      <input type="text" size="2" name="b_month"
             value="<%= period_begin.month.to_s.escape_h %>"> /
      <input type="text" size="2" name="b_day"   
             value="<%= period_begin.day.to_s.escape_h %>"> to (yyyy/mm/dd)
      <input type="text" size="4" name="e_year"  
             value="<%= period_end.year.to_s.escape_h %>"> /
      <input type="text" size="2" name="e_month" 
             value="<%= period_end.month.to_s.escape_h %>"> /
      <input type="text" size="2" name="e_day"   
             value="<%= period_end.day.to_s.escape_h %>">
    </td>        
  </tr>
</table>

<div>
  <% or_all = !and_op ? 'checked="checked"' : '' %>
  <% and_all = and_op ? 'checked="checked"' : '' %>
  <input type="radio" name="search_op" 
         value="and_all" <%= and_all %>>Search using all fields<br>
  <input type="radio" name="search_op" 
         value="or_all" <%= or_all %>>Search using any field
</div>

<div>
   <input type="checkbox" name="as_csv"> Display results in CSV format<br>
   <input type="checkbox" name="as_csv_file"> Download results in CSV format
</div>

<div>(Empty fields are ignored.)</div>

<div>
  <input type="hidden" name="project" value="<%= project.id %>">
  <input type="hidden" name="action" value="search">
  <input type="hidden" name="search_type" value="search">

  <% if @lang == 'ja' %>
  <input type="hidden" name="jp_enc_test" value="Æü">
  <% end %>

  <input type="submit" value="Search"> 
  <input type="reset" value="Reset">
</div>
</form>
