-
-
Notifications
You must be signed in to change notification settings - Fork 746
Expand file tree
/
Copy pathpdf-layout.html.twig
More file actions
347 lines (345 loc) · 15.7 KB
/
pdf-layout.html.twig
File metadata and controls
347 lines (345 loc) · 15.7 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
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
{% set showUserColumn = showUserColumn ?? true %}
{% set showInternalRate = showInternalRate ?? false %}
{% set showRateColumn = showRateColumn ?? is_granted('view_rate_other_timesheet') %}
{% set showHourlyRateColumn = showRateColumn and (showHourlyRateColumn ?? false) %}
{% set showSummaryHourlyRate = showRateColumn and (showSummaryHourlyRate ?? false) %}
{% set showRateBudget = showRateBudget ?? false %}
{% set showTimeBudget = showTimeBudget ?? false %}
{% set showCustomerSummary = showCustomerSummary ?? true %}
{% set showTotalSummary = showTotalSummary ?? true %}
{% set showDateTimeShort = showDateTimeShort ?? false %}
{% set showPageBreak = showPageBreak ?? true %}
{% set now = create_date('now', app.user) %}
{% set decimal = decimal ?? false %}
{# this is only triggered, if a user exports from his personal timesheet screen #}
{% if query is defined and query.user is not null %}
{% set showUserColumn = false %}
{# if exporting via the admin screen, users without view_rate_own_timesheet might still see their own rates #}
{% set showRateColumn = is_granted('view_rate_own_timesheet') %}
{% endif %}
{% set summaryColumns = ['customer', 'project'] %}
{% if showTimeBudget %}
{% set summaryColumns = summaryColumns|merge(['timeBudget']) %}
{% endif %}
{% if showRateBudget %}
{% set summaryColumns = summaryColumns|merge(['budget']) %}
{% endif %}
{% if showSummaryHourlyRate %}
{% set summaryColumns = summaryColumns|merge(['hourlyRate']) %}
{% endif %}
{% set summaryColumns = summaryColumns|merge(['duration']) %}
{% if showRateColumn %}
{% if showInternalRate %}
{% set summaryColumns = summaryColumns|merge(['internalRate']) %}
{% endif %}
{% set summaryColumns = summaryColumns|merge(['rate']) %}
{% endif %}
<html{% if app.request is defined and app.request is not null %} lang="{{ app.request.locale }}"{% endif %}>
<head>
<title>{% block document_title %}{{ 'export'|trans }}{% endblock %}</title>
{% block styles %}
<style>
{{ encore_entry_css_source('export-pdf')|raw }}
</style>
{% endblock %}
</head>
<body>
{% block pdf_footer %}
<!--mpdf
<htmlpagefooter name="myfooter">
<table style="border-top: 1px solid #000000; font-size: 9pt; padding-top: 3mm; width: 100%">
<tr>
<td align="left">
{{ 'export.page_of'|trans({'%page%': '{PAGENO}', '%pages%': '{nb}'}) }}
{% if not showUserColumn and query is defined and query.user %}
–
{{ 'user'|trans }}: {{ query.user.displayName }}
{% endif %}
</td>
<td align="right">
{% set company = config('theme.branding.company') %}
{% if company is not empty %}
{{ company }} – {{ now|date_time }}
{% else %}
{{ 'export.date_copyright'|trans({'%date%': now|date_time, '%kimai%': '<a href="' ~ constant('App\\Constants::HOMEPAGE') ~ '">' ~ constant('App\\Constants::SOFTWARE') ~ '</a>'})|raw }}
{% endif %}
</td>
</tr>
</table>
</htmlpagefooter>
<sethtmlpagefooter name="myfooter" value="on" />
mpdf-->
{% endblock %}
{% block body_start %}{% endblock %}
{% block summary %}
{% block summary_header %}
<h2 style="margin-bottom: 4px; padding-bottom: 0">{% block title %}{{ 'export.document_title'|trans }}{% endblock %}</h2>
{% if query is defined %}
<p>
{{ 'export.period'|trans }}:
{{ query.begin|date_short }} - {{ query.end|date_short }}
</p>
{% endif %}
<h3>{{ 'export.summary'|trans }}</h3>
{% endblock %}
<table class="items">
<thead>
<tr>
{% block summary_head_row_start %}{% endblock %}
{% for summaryColumn in summaryColumns %}
{% if summaryColumn == 'customer' %}
<th>{{ 'customer'|trans }}</th>
{% elseif summaryColumn == 'project' %}
<th>{{ 'project'|trans }}</th>
{% else %}
<th class="center">{{ summaryColumn|trans }}</th>
{% endif %}
{% endfor %}
{% block summary_head_row_end %}{% endblock %}
</tr>
</thead>
<tbody>
{% set customer = null %}
{% set customerDuration = 0 %}
{% set customerRate = 0 %}
{% set customerInternalRate = 0 %}
{% set customerCurrency = null %}
{% set customerCount = 0 %}
{% set multiCurrency = false %}
{% set totalDuration = 0 %}
{% set totalInternalRate = 0 %}
{% set totalRate = 0 %}
{% for id, summary in summaries %}
<!-- CONTENT_PART -->
{% set totalDuration = totalDuration + summary.duration %}
{% set totalInternalRate = totalInternalRate + summary.rate_internal %}
{% set totalRate = totalRate + summary.rate %}
{% if customerCurrency is not null and customerCurrency is not same as(summary.currency) %}
{% set multiCurrency = true %}
{% endif %}
{% if customer is same as(null) %}
{% set customer = summary.customer %}
{% set customerCurrency = summary.currency %}
{% endif %}
{% if customer is not same as(summary.customer) %}
<tr class="summary">
{% block summary_customer_row_start %}{% endblock %}
{% for summaryColumn in summaryColumns %}
{% if summaryColumn == 'duration' %}
<td class="totals duration">{{ customerDuration|duration(decimal) }}</td>
{% elseif summaryColumn == 'internalRate' %}
<td class="totals cost">{{ customerInternalRate|money(customerCurrency) }}</td>
{% elseif summaryColumn == 'rate' %}
<td class="totals cost">{{ customerRate|money(customerCurrency) }}</td>
{% else %}
<td></td>
{% endif %}
{% endfor %}
{% block summary_customer_row_end %}{% endblock %}
</tr>
{% set customerCurrency = summary.currency %}
{% set customer = summary.customer %}
{% set customerDuration = 0 %}
{% set customerRate = 0 %}
{% set customerInternalRate = 0 %}
{% set customerCount = 0 %}
{% endif %}
<tr class="{{ cycle(['odd', 'even'], customerCount) }}">
{% block summary_project_row_start %}{% endblock %}
{% for summaryColumn in summaryColumns %}
{% if summaryColumn == 'customer' %}
<td>{{ summary.customer }}</td>
{% elseif summaryColumn == 'project' %}
<td>{{ summary.project }}</td>
{% elseif summaryColumn == 'timeBudget' %}
<td class="center">
{% if budgets[id] is defined and budgets[id].time_left > 0 %}
{{ budgets[id].time_left|duration(decimal) }}
{% endif %}
</td>
{% elseif summaryColumn == 'budget' %}
<td class="center">
{% if budgets[id] is defined and budgets[id].money_left > 0 %}
{{ budgets[id].money_left|money(summary.currency) }}
{% endif %}
</td>
{% elseif summaryColumn == 'hourlyRate' %}
{% set summaryHourlyRate = summary.duration/3600 %}
<td class="cost">{{ summaryHourlyRate > 0 ? (summary.rate/summaryHourlyRate)|money(summary.currency) : '' }}</td>
{% elseif summaryColumn == 'duration' %}
<td class="duration">{{ summary.duration|duration(decimal) }}</td>
{% elseif summaryColumn == 'internalRate' %}
<td class="cost">{{ summary.rate_internal|money(summary.currency) }}</td>
{% elseif summaryColumn == 'rate' %}
<td class="cost">{{ summary.rate|money(summary.currency) }}</td>
{% endif %}
{% endfor %}
{% block summary_project_row_end %}{% endblock %}
</tr>
{% set customerDuration = customerDuration + summary.duration %}
{% set customerRate = customerRate + summary.rate %}
{% set customerInternalRate = customerInternalRate + summary.rate_internal %}
{% set customerCount = customerCount + 1 %}
{% endfor %}
{% if showCustomerSummary and customer is not same as(null) %}
<tr class="summary">
{% block summary_customer_summary_row_start %}{% endblock %}
{% for summaryColumn in summaryColumns %}
{% if summaryColumn == 'duration' %}
<td class="totals duration">{{ customerDuration|duration(decimal) }}</td>
{% elseif summaryColumn == 'internalRate' %}
<td class="totals cost">{{ customerInternalRate|money(customerCurrency) }}</td>
{% elseif summaryColumn == 'rate' %}
<td class="totals cost">{{ customerRate|money(customerCurrency) }}</td>
{% else %}
<td></td>
{% endif %}
{% endfor %}
{% block summary_customer_summary_row_end %}{% endblock %}
</tr>
{% endif %}
{% if showTotalSummary and not multiCurrency %}
<tr class="{% if not showCustomerSummary %}summary{% else %}summary-total{% endif %}">
{% block summary_summary_row_start %}{% endblock %}
<td class="totals" colspan="2">
{{ 'sum.total'|trans }}
</td>
{% for summaryColumn in summaryColumns %}
{% if summaryColumn == 'duration' %}
<td class="totals duration">{{ totalDuration|duration(decimal) }}</td>
{% elseif summaryColumn == 'internalRate' %}
<td class="totals cost">{{ totalInternalRate|money(customerCurrency) }}</td>
{% elseif summaryColumn == 'rate' %}
<td class="totals cost">{{ totalRate|money(customerCurrency) }}</td>
{% elseif summaryColumn not in ['customer', 'project'] %}
<td></td>
{% endif %}
{% endfor %}
{% block summary_summary_row_end %}{% endblock %}
</tr>
{% endif %}
</tbody>
</table>
{% if showPageBreak %}
<pagebreak>
{% endif %}
{% endblock %}
{% block items %}
{% block items_header %}
<h3>{{ 'export.full_list'|trans }}</h3>
{% endblock %}
{% set duration = 0 %}
{% set rate = 0 %}
{% set rateInternal = 0 %}
{% set currency = false %}
<table class="items">
<thead>
<tr>
{% block items_head_row_start %}{% endblock %}
<th>{{ 'date'|trans }}</th>
{% if showUserColumn %}
<th>{{ 'user'|trans }}</th>
{% endif %}
<th>{{ 'description'|trans }}</th>
{% if showHourlyRateColumn %}
<th class="center">{{ 'hourlyRate'|trans }}</th>
{% endif %}
<th class="center">{{ 'duration'|trans }}</th>
{% if showRateColumn %}
{% if showInternalRate %}
<th class="center">{{ 'internalRate'|trans }}</th>
{% endif %}
<th class="center">{{ 'rate'|trans }}</th>
{% endif %}
{% block items_head_row_end %}{% endblock %}
</tr>
</thead>
<tbody>
{% for entry in entries %}
<!-- CONTENT_PART -->
{% set duration = duration + entry.duration %}
{% set entryCurrency = entry.project.customer.currency %}
{% if currency is same as(false) %}
{% set currency = entryCurrency %}
{% endif %}
{% if currency is not same as(entryCurrency) %}
{% set currency = null %}
{% endif %}
<tr class="{{ cycle(['odd', 'even'], loop.index0) }}">
{% block items_entry_row_start %}{% endblock %}
<td class="text-nowrap">
{% block date_begin %}{% if not showDateTimeShort %}{{ entry.begin|date_time }}{% else %}{{ entry.begin|date_short }}{% endif %}{% endblock %}
{% if entry.end %}
{% block date_end %}{% if not showDateTimeShort %}<br>{{ entry.end|date_time }}{% endif %}{% endblock %}
{% endif %}
</td>
{% if showUserColumn %}
<td>{{ entry.user.displayName }}</td>
{% endif %}
<td>
{% block description %}
{{ entry.project.customer.name }} - {{ entry.project.name }}{% if entry.activity is not null %} - {{ entry.activity.name }}{% endif %}
{% if entry.description is not empty %}
<br>
<i>{{ entry.description|desc2html }}</i>
{% endif %}
{% endblock %}
</td>
{% if showHourlyRateColumn %}
<td class="cost">
{% if entry.fixedRate %}
-
{% else %}
{{ entry.hourlyRate|money(entryCurrency) }}
{% endif %}
</td>
{% endif %}
<td class="duration">
{% if entry.duration == 0 %}
-
{% else %}
{{ entry.duration|duration(decimal) }}
{% endif %}
</td>
{% if showRateColumn %}
{# no check for is_granted('view_rate', entry) because it is only available for timesheets,
but maybe missing for other potential export repositories #}
{% set rate = rate + entry.rate %}
{% set rateInternal = rateInternal + entry.internalRate %}
{% set entryRate = entry.rate|money(entryCurrency) %}
{% set entryRateInternal = entry.internalRate|money(entryCurrency) %}
{% if showInternalRate %}
<td class="cost">{{ entryRateInternal }}</td>
{% endif %}
<td class="cost">{{ entryRate }}</td>
{% endif %}
{% block items_entry_row_end %}{% endblock %}
</tr>
{% endfor %}
{% block items_summary %}
<tr class="summary">
{% block items_summary_row_start %}{% endblock %}
{% if showUserColumn %}
<td colspan="3">{{ 'sum.total'|trans }}</td>
{% else %}
<td colspan="2">{{ 'sum.total'|trans }}</td>
{% endif %}
{% if showHourlyRateColumn %}
<td class="totals cost"></td>
{% endif %}
<td class="totals duration">{{ duration|duration(decimal) }}</td>
{% if showRateColumn %}
{% if showInternalRate %}
<td class="totals cost">{% if currency is not null %}{{ rateInternal|money(currency) }}{% endif %}</td>
{% endif %}
<td class="totals cost">{% if currency is not null %}{{ rate|money(currency) }}{% endif %}</td>
{% endif %}
{% block items_summary_row_end %}{% endblock %}
</tr>
{% endblock %}
</tbody>
</table>
{% endblock %}
{% block body_end %}{% endblock %}
</body>
</html>