<% if @deliveries %>
  <%= form_tag({:action => 'edit', :tab => 'notifications'}, :class => 'form-box') do %>
    <div class="box tabular settings">
      <p><%= setting_text_field :mail_from %></p>

      <p><%= setting_check_box :bcc_recipients %></p>

      <p><%= setting_check_box :plain_text_mail %></p>

      <p><%= setting_select(:default_notification_option, User.valid_notification_options.collect {|o| [l(o.last), o.first.to_s]}) %></p>

      <p>
        <%= hidden_field_tag('easy_setting[just_one_issue_mail]', '0', :id => nil) -%>
        <% box = check_box_tag('easy_setting[just_one_issue_mail]', '1', EasySetting.value('just_one_issue_mail')) -%>
        <%= label_tag('easy_setting_just_one_issue_mail', box + l(:setting_just_one_issue_mail), :class => 'checkbox inline') %>
      </p>

      <p>
        <%= label_tag('easy_setting_issue_mail_subject_style', l(:label_easy_setting_issue_mail_subject_style)) %>
        <%= select_tag('easy_setting[issue_mail_subject_style]', options_for_select(l(:easy_issue_mail_subject_styles).map{|s, v| [v, s]}, EasySetting.value('issue_mail_subject_style'))) -%>
      </p>
    </div>

    <fieldset id="notified_events" class="box"><legend><%=l(:text_select_mail_notifications)%><span><%= check_all_links('notified_events') %></span></legend>
      <%= hidden_field_tag 'settings[notified_events][]', '' %>

      <div class="splitcontent checkbox-grid">
        <% notification_grid(@notifiables).each do |k, v| %>
          <div class="size-25">
            <div class="checkbox-grid__group">
              <% if k %>
                <div class="checkbox-grid__item"><%= notification_field k %></div>
              <% end %>

              <% if v.any? %>
                <div class="checkbox-grid__group_sub">
                  <% v.each do |ch| %>
                    <div class="checkbox-grid__item"><%= notification_field ch %></div>
                  <% end %>
                </div>
              <% end %>
            </div>
          </div>
        <% end %>
      </div>
    </fieldset>

    <fieldset class="box">
      <p>
        <label><%= l(:setting_emails_header) %></label>
        <%= setting_text_area :emails_header, :label => false, :class => 'wiki-edit', :rows => 5 %>
      </p>
      <p>
        <label><%= l(:setting_emails_footer) %></label>
        <%= setting_text_area :emails_footer, :label => false, :class => 'wiki-edit', :rows => 5 %>
      </p>
    </fieldset>

    <%= call_hook(:view_settings_notifications_bottom) %>

    <div class="form-actions">
      <%= submit_tag l(:button_save),:class => 'button-positive' %>
      <%= link_to l(:label_send_test_email), test_email_path, :method => :post, :class => 'button' %>
    </div>
  <% end %>
<% else %>
  <div class="nodata">
    <%= simple_format(l(:text_email_delivery_not_configured)) %>
  </div>
<% end %>
