shift73k/lib/shift73k_web/templates/user_shifts_csv/new.html.heex

75 lines
2.2 KiB
Text
Raw Normal View History

<div class="row justify-content-center">
<div class="col-12 col-md-10 col-xl-8">
<h2>
<i class="bi bi-file-earmark-spreadsheet me-1"></i> CSV Export
</h2>
<p class="lead">Select a date range for which to export a CSV of your scheduled shifts, or click "Export All" to export everything.</p>
<div class="row justify-content-center">
<div class="col-12 col-sm-9 col-md-8 col-lg-6 col-xxl-5">
<% min_date = min_user_shift_date(@current_user.id) %>
<% max_date = max_user_shift_date(@current_user.id) %>
<% today = Date.utc_today() %>
<%= form_for :csv_export, Routes.user_shifts_csv_path(@conn, :export), fn csv_range -> %>
<div class="row gx-2 gx-sm-3 mb-3">
<%= hidden_input csv_range, :user_id, value: @current_user.id %>
<div class="col-6">
<%= label csv_range, :date_min, "From", class: "form-label" %>
<%= date_input csv_range, :date_min,
value: Date.beginning_of_month(today),
min: min_date,
max: max_date,
class: "form-control"
%>
</div>
<div class="col-6">
<%= label csv_range, :date_max, "To", class: "form-label" %>
<%= date_input csv_range, :date_max,
value: Date.end_of_month(today),
min: min_date,
max: max_date,
class: "form-control"
%>
</div>
</div>
<div class="row gx-2 gx-sm-3 mb-3">
<div class="col text-end">
<%= submit "Export for selected dates", class: "btn btn-primary" %>
</div>
</div>
<% end %>
<%= form_for :csv_export, Routes.user_shifts_csv_path(@conn, :export), fn csv_all -> %>
<%= hidden_input csv_all, :user_id, value: @current_user.id %>
<%= hidden_input csv_all, :date_min, value: min_date %>
<%= hidden_input csv_all, :date_max, value: max_date %>
<div class="row gx-2 gx-sm-3 mb-3">
<div class="col text-end">
<%= submit "Export all", class: "btn btn-outline-primary" %>
</div>
</div>
<% end %>
</div>
</div>
</div>
</div>