summaryrefslogtreecommitdiff
path: root/sstreasury/jinja2/sstreasury/budget_view.html
blob: d4d37ea8a28d85e1a596ad450299e8308cd67a3b (plain)
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
1{% extends 'sstreasury/base.html' %}
2
3{#
4    Society Self-Service
5    Copyright © 2018–2020  Yingtong Li (RunasSudo)
6
7    This program is free software: you can redistribute it and/or modify
8    it under the terms of the GNU Affero General Public License as published by
9    the Free Software Foundation, either version 3 of the License, or
10    (at your option) any later version.
11
12    This program is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15    GNU Affero General Public License for more details.
16
17    You should have received a copy of the GNU Affero General Public License
18    along with this program.  If not, see <https://www.gnu.org/licenses/>.
19#}
20
21{% block title %}{{ revision.name }}{% endblock %}
22
23{% block maincontent %}
24	<h1>{{ revision.name }}</h1>
25	
26	<form class="ui form" action="{{ url('budget_action', kwargs={'id': revision.budget.id}) }}" method="POST">
27		<span class="ui header">Status: {{ revision.get_state_display() }}</span>
28		
29		{% if is_latest %}
30			{% if revision.can_submit(request.user) %}
31				<button class="ui mini labeled primary icon button" data-action="Submit" style="margin-left: 1em;" onclick="return uiConfirm(this);"><i class="paper plane icon"></i> Submit</button>
32			{% endif %}
33			{% if revision.can_endorse(request.user) %}
34				<button class="ui mini labeled positive icon button" data-action="Endorse" style="margin-left: 1em;" onclick="return uiConfirm(this);"><i class="check icon"></i> Endorse</button>
35				
36				<button class="ui mini labeled basic negative icon button" data-action="Return" onclick="return uiConfirm(this);"><i class="undo icon"></i> Return for re-drafting</button>
37			{% endif %}
38			{% if revision.can_approve(request.user) %}
39				<button class="ui mini labeled positive icon button" data-action="Approve" style="margin-left: 1em;" onclick="return uiConfirm(this);"><i class="check icon"></i> Approve</button>
40				
41				<button class="ui mini labeled basic negative icon button" data-action="CmteReturn" onclick="return uiConfirm(this);"><i class="undo icon"></i> Return for re-drafting</button>
42			{% endif %}
43			{% if revision.can_withdraw(request.user) %}
44				<button class="ui mini labeled basic negative icon button" data-action="Withdraw" style="margin-left: 1em;" onclick="return uiConfirm(this);"><i class="undo icon"></i> Withdraw</button>
45			{% endif %}
46			
47			{% if revision.can_edit(request.user) %}
48				<a class="ui mini labeled right floated icon button" href="{{ url('budget_edit', kwargs={'id': revision.budget.id}) }}"><i class="edit icon"></i> Edit</a>
49			{% endif %}
50			
51			<a class="ui mini labeled right floated icon button" href="{{ url('budget_print', kwargs={'id': revision.budget.id}) }}" target="_blank"><i class="print icon"></i> Print</a>
52			
53			{% if not revision.can_edit(request.user) and revision.can_withdraw(request.user) %}
54				<div class="ui message">
55					<p>This budget has been submitted and is now awaiting approval. If you wish to edit this budget, you must first withdraw it. This will revert the budget to a draft.</p>
56				</div>
57			{% endif %}
58			
59			<input type="hidden" name="action" value="">
60			<input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
61		{% else %}
62			<a class="ui mini labeled right floated icon button" href="{{ url('budget_print', kwargs={'id': revision.budget.id}) }}?revision={{ revision.id }}" target="_blank"><i class="print icon"></i> Print</a>
63			
64			<div class="ui visible warning message">
65				<p>You are viewing an older version of this budget. To make any changes, <a href="{{ url('budget_view', kwargs={'id': revision.budget.id}) }}">click here</a> to return to the current version.</p>
66			</div>
67		{% endif %}
68	</form>
69	
70	<table class="ui mydefinition table">
71		<tbody>
72			<tr>
73				<td class="two wide">ID</td>
74				<td class="fourteen wide">BU-{{ revision.budget.id }}</td>
75			</tr>
76			<tr>
77				<td>Title</td>
78				<td>{{ revision.name }}</td>
79			</tr>
80			<tr>
81				<td>Due date</td>
82				<td>{{ revision.date or '' }}</td>
83			</tr>
84			<tr>
85				<td>Event details</td>
86				<td>
87					{% if revision.event_dt %}{{ localtime(revision.event_dt) }}.{% endif %}
88					{% if revision.event_attendees %}{{ revision.event_attendees }} attendees.{% endif %}
89					{% if not revision.event_dt and not revision.event_attendees %}N/A{% endif %}
90				</td>
91			</tr>
92			<tr>
93				<td>Contributors</td>
94				<td>
95					<div class="ui list">
96						{% for contributor in revision.contributors.all() %}
97							<div class="item">
98								<i class="user circle icon"></i>
99								<div class="content"><a href="mailto:{{ contributor.email }}">
100									{% if contributor.first_name %}
101										{{ contributor.first_name }} {{ contributor.last_name }}
102									{% else %}
103										{{ contributor.email }}
104									{% endif %}
105								</a></div>
106							</div>
107						{% endfor %}
108					</div>
109				</td>
110			</tr>
111			<tr>
112				<td>Comments</td>
113				<td>{{ revision.comments|markdown }}</td>
114			</tr>
115			<tr>
116				<td>Revenue</td>
117				<td>
118					<div id="revenue_grid"></div>
119					{% if revision.revenue_comments %}
120						<div class="ui accordion">
121							<div class="active title">
122								<i class="dropdown icon"></i>
123								Revenue comments
124							</div>
125							<div class="active content">
126								{{ revision.revenue_comments|markdown }}
127							</div>
128						</div>
129					{% endif %}
130				</td>
131			</tr>
132			<tr>
133				<td>Expenses</td>
134				<td>
135					{% if revision.expense_no_emergency_fund %}
136						<p><input type="checkbox" id="expense_no_emergency_fund" disabled checked> No emergency fund required (please add a comment explaining why)</p>
137					{% endif %}
138					<div id="expense_grid"></div>
139					{% if revision.expense_comments %}
140						<div class="ui accordion">
141							<div class="active title">
142								<i class="dropdown icon"></i>
143								Expense comments
144							</div>
145							<div class="active content">
146								{{ revision.expense_comments|markdown }}
147							</div>
148						</div>
149					{% endif %}
150				</td>
151			</tr>
152			<tr>
153				<td>Total Profit (Loss)</td>
154				<td style="text-align: right; font-weight: bold; padding-right: 2.3em;">{{ '${:.2f}'.format(revision.get_revenue_total() - revision.get_expense_total()) if revision.get_revenue_total() >= revision.get_expense_total() else '(${:.2f})'.format(revision.get_expense_total() - revision.get_revenue_total()) }}</td>
155			</tr>
156		</tbody>
157	</table>
158	
159	{% if is_latest %}
160		<form class="ui form" action="{{ url('budget_action', kwargs={'id': revision.budget.id}) }}" method="POST">
161			<div class="required field">
162				<textarea rows="4" name="comment"></textarea>
163			</div>
164			<input type="hidden" name="action">
165			<input type="hidden" name="csrfmiddlewaretoken" value="{{ csrf_token }}">
166			<button class="ui primary button" data-action="Comment" onclick="return uiSubmit(this);">Comment</button>
167			
168			{% if revision.state == import('sstreasury.models').BudgetState.AWAIT_REVIEW.value and request.user.groups.filter(name='Treasury').exists() %}
169				<button class="ui right floated labeled basic negative icon button" data-action="Comment,Return" onclick="return uiConfirm(this);"><i class="undo icon"></i> Comment and return for re-drafting</button>
170				
171				<button class="ui right floated labeled positive icon button" data-action="Comment,Endorse" onclick="return uiConfirm(this);"><i class="check icon"></i> Comment and endorse</button>
172			{% elif revision.state != import('sstreasury.models').BudgetState.APPROVED.value and request.user.groups.filter(name='Secretary').exists() %}
173				<button class="ui right floated labeled basic negative icon button" data-action="Comment,CmteReturn" onclick="return uiConfirm(this);"><i class="undo icon"></i> Comment and return for re-drafting</button>
174				
175				<button class="ui right floated labeled positive icon button" data-action="Comment,Approve" onclick="return uiConfirm(this);"><i class="check icon"></i> Comment and approve</button>
176			{% endif %}
177		</form>
178		
179		<div class="ui feed">
180			{% for item in history %}
181				{% if item.__class__.__name__ == 'BudgetComment' %}
182					<div class="event">
183						<div class="label">
184							<i class="comment alternate outline icon"></i>
185						</div>
186						<div class="content">
187							<div class="summary">
188								<i class="user circle icon"></i>
189								<a href="mailto:{{ item.author.email }}">{{ item.author.first_name }} {{ item.author.last_name }}</a> commented
190								<div class="date">
191									{{ localtime(item.time) }}
192								</div>
193							</div>
194							<div class="extra text">
195								{{ item.content|markdown }}
196							</div>
197						</div>
198					</div>
199				{% elif item.__class__.__name__ == 'BudgetRevision' %}
200					<div class="event">
201						<div class="label">
202							<i class="edit icon"></i>
203						</div>
204						<div class="content">
205							<div class="summary">
206								<i class="user circle icon"></i>
207								{% if item.action == import('sstreasury.models').BudgetAction.CREATE.value %}
208									<a href="mailto:{{ item.author.email }}">{{ item.author.first_name }} {{ item.author.last_name }}</a> created the budget <a href="{{ url('budget_view', kwargs={'id': revision.budget.id}) }}?revision={{ item.id }}">(view)</a>
209								{% elif item.action == import('sstreasury.models').BudgetAction.EDIT.value %}
210									<a href="mailto:{{ item.author.email }}">{{ item.author.first_name }} {{ item.author.last_name }}</a> edited the budget <a href="{{ url('budget_view', kwargs={'id': revision.budget.id}) }}?revision={{ item.id }}">(view)</a>
211								{% elif item.action == import('sstreasury.models').BudgetAction.UPDATE_STATE.value %}
212									<a href="mailto:{{ item.author.email }}">{{ item.author.first_name }} {{ item.author.last_name }}</a> changed the state to: {{ item.get_state_display() }}
213								{% else %}
214									<a href="mailto:{{ item.author.email }}">{{ item.author.first_name }} {{ item.author.last_name }}</a> modified the budget <a href="{{ url('budget_view', kwargs={'id': revision.budget.id}) }}?revision={{ item.id }}">(view)</a>
215								{% endif %}
216								<div class="date">
217									{{ localtime(item.time) }}
218								</div>
219							</div>
220						</div>
221					</div>
222				{% endif %}
223			{% endfor %}
224		</div>
225		
226		{% if claims is not none %}
227			<h2>Reimbursement claims</h2>
228			
229			{% if claims %}
230				<table class="ui celled table">
231					<thead>
232						<tr>
233							<th class="nine wide">Purpose</th>
234							<th class="four wide">Status</th>
235							<th class="two wide">Total</th>
236							<th class="one wide">View</th>
237						</tr>
238					</thead>
239					<tbody>
240						{% for claim in claims %}
241							<tr>
242								<td>{{ claim.purpose }}</td>
243								<td>{{ claim.get_state_display() }}</td>
244								<td>{{ '${:.2f}'.format(claim.get_total()) }}</td>
245								<td>
246									<a href="{{ url('claim_view', kwargs={'id': claim.id}) }}" class="ui tiny primary icon button"><i class="eye icon"></i></a>
247								</td>
248							</tr>
249						{% endfor %}
250					</tbody>
251				</table>
252				
253				<div class="ui warning message">
254					<p>This list will not include invoices, or other transactions tracked outside of Self Service.</p>
255				</div>
256			{% else %}
257				<p>There are no claims to display.</p>
258			{% endif %}
259		{% endif %}
260	{% endif %}
261	
262	<div class="ui modal">
263		<div class="content" data-action="Submit">
264			<p>Are you sure you want to submit this budget for Treasury review? You will not be able to make any additional changes without withdrawing the budget.</p>
265		</div>
266		<div class="content" data-action="Endorse">
267			<p>Are you sure you want to give this budget Treasury endorsement?</p>
268		</div>
269		<div class="content" data-action="Comment,Endorse">
270			<p>Are you sure you want to give this budget Treasury endorsement?</p>
271		</div>
272		<div class="content" data-action="Return">
273			<p>Are you sure you want to refuse this budget Treasury endorsement and return it for re-drafting?</p>
274		</div>
275		<div class="content" data-action="Comment,Return">
276			<p>Are you sure you want to refuse this budget Treasury endorsement and return it for re-drafting?</p>
277		</div>
278		<div class="content" data-action="Approve">
279			<p>Are you sure you want to mark this budget as committee-approved?</p>
280		</div>
281		<div class="content" data-action="Comment,Approve">
282			<p>Are you sure you want to mark this budget as committee-approved?</p>
283		</div>
284		<div class="content" data-action="CmteReturn">
285			<p>Are you sure you want to refuse this budget committee approval and return it for re-drafting?</p>
286		</div>
287		<div class="content" data-action="Comment,CmteReturn">
288			<p>Are you sure you want to refuse this budget committee approval and return it for re-drafting?</p>
289		</div>
290		<div class="content" data-action="Withdraw">
291			<p>Are you sure you want to withdraw this budget from being considered for approval? The budget will be reverted to a draft.</p>
292		</div>
293		<div class="actions">
294			<div class="ui primary approve button">Continue</div>
295			<div class="ui cancel button">Cancel</div>
296		</div>
297	</div>
298{% endblock %}
299
300{% block head %}
301	{{ super() }}
302	
303	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jsgrid@1.5.3/dist/jsgrid.min.css" integrity="sha256-a/jNbtm7jpeKiXCShJ8YC+eNL9Abh7CBiYXHgaofUVs=" crossorigin="anonymous">
304	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jsgrid@1.5.3/dist/jsgrid-theme.min.css" integrity="sha256-0rD7ZUV4NLK6VtGhEim14ZUZGC45Kcikjdcr4N03ddA=" crossorigin="anonymous">
305	
306	<style>
307		/* Fix the CSS */
308		
309		.ui.mydefinition.table > tbody > tr > td:first-child:not(.ignored) {
310			background: rgba(0,0,0,.03);
311			font-weight: 700;
312			color: rgba(0,0,0,.95);
313		}
314		
315		.jsgrid-align-right, .jsgrid-align-right input, .jsgrid-align-right select, .jsgrid-align-right textarea {
316			text-align: right !important;
317		}
318		.jsgrid-cell {
319			padding: .5em !important;
320		}
321		.jsgrid-header-row .jsgrid-header-cell {
322			text-align: center !important;
323		}
324	</style>
325{% endblock %}
326
327{% block script %}
328	{{ super() }}
329	
330	<script>
331		function uiSubmit(button) {
332			button.form.elements['action'].value = button.dataset['action'];
333			button.form.submit();
334			return false;
335		}
336		
337		function uiConfirm(button) {
338			$('.ui.modal .content').hide();
339			$('.ui.modal .content').filter('[data-action="' + button.dataset['action'] + '"]').show();
340			$('.ui.modal').modal({
341				closable: false,
342				onApprove: function() {
343					uiSubmit(button);
344				}
345			}).modal('show');
346			
347			return false;
348		}
349	</script>
350	
351	<script src="https://cdn.jsdelivr.net/npm/jsgrid@1.5.3/dist/jsgrid.min.js" integrity="sha256-lzjMTpg04xOdI+MJdjBst98bVI6qHToLyVodu3EywFU=" crossorigin="anonymous"></script>
352	
353	<script src="{{ static('sstreasury/budget.js') }}"></script>
354	
355	<script>
356		var revenue_data = JSON.parse({{ import('json').dumps(import('json').dumps(revision.revenue))|safe }});
357		var expense_data = JSON.parse({{ import('json').dumps(import('json').dumps(revision.expense))|safe }});
358		var editing = false;
359		makeGrid();
360		
361		$('.jsgrid-filter-row, .jsgrid-insert-row').attr('style', 'display: none !important;'); /* Override Semantic UI */
362	</script>
363{% endblock %}
Contact (issues, pull requests, etc.) at git@yingtongli.me. Generated by cgit.