app/views/admin/schools/bill_requests/new.html.erb
<% content_for :page_title, "Request bill from #{@school.name}" %>
<h1>Request bill</h1>
<div class="row">
<div class="col">
<p>Send an email to one or more users at <%= @school.name %> to request they upload
a bill</p>
</div>
</div>
<div class="row">
<div class="col">
<%= simple_form_for :bill_request, url: admin_school_bill_requests_path(@school) do |f| %>
<div class="card-group">
<div class="card bg-light">
<div class="card-header">Which meter(s) should be on the bill?</div>
<div class="card-body">
<% if @meters.present? %>
<div class="form-check">
<%= f.collection_check_boxes(:meter_ids, @meters, :id, :mpan_mprn) do |b| %>
<div class="control-group">
<%= b.check_box(class: "form-check-input", checked: true) %>
<%= b.label(class: "form-check-label") do %>
<%= b.object.mpan_mprn %>
<% end %>
</div>
<% end %>
</div>
<% else %>
<p>No meters pending review</p>
<% end %>
</div>
</div>
<div class="card bg-light">
<div class="card-header">Which user(s) should be emailed?</div>
<div class="card-body">
<% if @users.any? %>
<div class="form-check">
<%= f.collection_check_boxes(:user_ids, @users, :id, :email) do |b| %>
<div class="control-group">
<%= b.check_box(class: "form-check-input") %>
<%= b.label(class: "form-check-label") do %>
<%= b.object.name %> (<%= user_school_role(b.object) %>)
<% end %>
</div>
<% end %>
</div>
<%= link_to "Manage users", school_users_path(@school), class: "btn btn-sm btn-default mt-2" %>
<% else %>
<p>The school has no staff or admin users</p>
<%= link_to "Add user", school_users_path(@school), class: "btn btn-sm btn-default mt-2" %>
<% end %>
</div>
</div>
</div>
<div class="row mt-1 mb-1">
<div class="col">
<div class="mt-4">
<%= f.button :submit, "Request bill", "data-confirm": 'Are you sure?', disabled: @users.empty? %>
<% if @school.bill_requested_at %>
<span class='p-2'>Bill last requested from the school <%= @school.bill_requested_at.strftime("on %m/%d/%Y at %H:%M") %></span>
<% end %>
</div>
<hr>
<div class="btn-group">
<%= link_to "View pending reviews", admin_meter_reviews_path, class: "btn btn-default" %>
</div>
</div>
</div>
<% end %>
</div>
</div>