-
-
Notifications
You must be signed in to change notification settings - Fork 572
Expand file tree
/
Copy pathindex.html.erb
More file actions
156 lines (150 loc) · 6.33 KB
/
index.html.erb
File metadata and controls
156 lines (150 loc) · 6.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<% content_for :title, "Distributions - #{current_organization.name}" %>
<h1>
Distributions
<small>for <%= current_organization.name %></small>
</h1>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item"><%= link_to(dashboard_path) do %>
<i class="fa fa-dashboard"></i> Home
<% end %>
</li>
<li class="breadcrumb-item"><a href="#">Distributions</a></li>
</ol>
</div>
</div>
</div><!-- /.container-fluid -->
</section>
<!-- Main content -->
<section class="content">
<div class="container-fluid">
<div class="row">
<!-- left column -->
<div class="col-12">
<!-- jquery validation -->
<div class="card card-primary">
<div class="card-header">
<h3 class="card-title">Distribution Filters</h3>
</div>
<!-- /.card-header -->
<!-- form start -->
<div class="card-body">
<%= form_tag(distributions_path, method: :get) do |f| %>
<div class="row">
<% if @items.present? %>
<div class="form-group col-lg-2 col-md-2 col-sm-6 col-xs-12">
<%= filter_select(label: "Filter by Item", scope: :by_item_id, collection: @items, selected: @selected_item) %>
</div>
<% end %>
<% if @item_categories.present? %>
<div class="form-group col-lg-2 col-md-2 col-sm-6 col-xs-12">
<%= filter_select(label: "Filter by Item Category", scope: :by_item_category_id, collection: @item_categories, selected: @selected_item_category) %>
</div>
<% end %>
<% if @partners.present? %>
<div class="form-group col-lg-2 col-md-2 col-sm-6 col-xs-12">
<%= filter_select(label: "Filter by Partner", scope: :by_partner, collection: @partners, selected: @selected_partner) %>
</div>
<% end %>
<% if @storage_locations.present? %>
<div class="form-group col-lg-3 col-md-3 col-sm-6 col-xs-12">
<%= filter_select(label: "Filter by Source Inventory", scope: :by_location, collection: @storage_locations, selected: @selected_location) %>
</div>
<% end %>
<div class="form-group col-lg-2 col-md-2 col-sm-6 col-xs-12">
<%= filter_select(label: "Filter by Status", scope: :by_state, collection: @statuses, key: :last, value: :first, selected: @selected_status) %>
</div>
<div class="form-group col-lg-3 col-md-3 col-sm-6 col-xs-12">
<%= label_tag "Date Range", "Date Range" %>
<%= render partial: "shared/date_range_picker", locals: {css_class: "form-control"} %>
</div>
</div><!-- /.row -->
<div class="card-footer">
<%= filter_button %>
<%= clear_filter_button %>
<span class="float-right">
<%=
if @distributions.any?
download_button_to(
distributions_path(export_csv: true, filters: filter_params.merge(date_range: date_range_params)),
text: "Export Distributions"
)
end
%>
<%= new_button_to new_distribution_path, {text: "New Distribution"} %>
</span>
</div>
<% end # form %>
</div>
</div>
</div>
</div><!-- /.container-fluid -->
</div>
</section>
<section class="content">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<!-- Default box -->
<div class="card">
<div class="card-body table-responsive p-0">
<table class="table table-hover">
<thead>
<tr>
<th>ID</th>
<th>Partner</th>
<th class="date text-left">Initial Allocation</th>
<th class="date text-left">Date of Distribution</th>
<th>Source Inventory</th>
<% filtered_item_name = @selected_item ? @items.find { |i| i.id == filter_params[:by_item_id].to_i }&.name : nil %>
<% filtered_category_name = @selected_item_category ? @item_categories.find { |ic| ic.id == filter_params[:by_item_category_id].to_i }&.name : nil %>
<!-- Quantity -->
<% if filtered_item_name %>
<th class="numeric">Total <%= filtered_item_name %></th>
<% elsif filtered_category_name %>
<th class="numeric">Total in <%= filtered_category_name %></th>
<% else %>
<th class="numeric">Total Items</th>
<% end %>
<!-- End Quantity -->
<!-- Value -->
<% if filtered_item_name %>
<th class="numeric">Value of <%= filtered_item_name %></th>
<% elsif filtered_category_name %>
<th class="numeric">Value of <%= filtered_category_name %></th>
<% else %>
<th class="numeric">Total Value</th>
<% end %>
<!-- End Value -->
<th>Delivery Method</th>
<th class="text-right">Shipping Cost</th>
<th>Comments</th>
<th>Status</th>
<th class="text-right" style="width: 400px">Actions</th>
</tr>
</thead>
<tbody>
<%= render partial: "distribution_row", collection: @paginated_distributions %>
</tbody>
<tfoot>
<%= render partial: "distribution_total" %>
</tfoot>
</table>
</div>
<!-- /.card-body -->
<div class="card-footer">
<%= paginate @paginated_distributions %>
</div>
<!-- /.card-footer-->
</div>
<!-- /.card -->
</div>
</div>
</div>
</section>
<%= render "shared/csv_download" %>