Skip to content

Commit 60d9368

Browse files
committed
Cleanup PDF invoice template
1 parent 86bac19 commit 60d9368

File tree

3 files changed

+155
-135
lines changed

3 files changed

+155
-135
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Version 2.0.1
4+
5+
Compatibility: requires minimum Kimai 2.0
6+
7+
- Cleanup PDF invoice template
8+
39
## Version 2.0
410

511
Compatibility: requires minimum Kimai 2.0

Resources/invoices/demo.html.twig

+148-134
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,159 @@
1-
{% extends 'invoice/layout.html.twig' %}
1+
<!DOCTYPE html>
2+
{% set fallback = app.request is not null ? app.request.locale : 'en' %}
3+
{% set language = model.template.language|default(fallback) %}
4+
<html lang="{{ language }}">
5+
<head>
6+
<meta charset="utf-8">
7+
<style type="text/css">
8+
{{ encore_entry_css_source('invoice')|raw }}
9+
</style>
10+
</head>
11+
<body class="invoice_print">
12+
<div class="wrapper">
13+
<section class="invoice">
214

3-
{% block invoice %}
4-
<div class="row">
5-
<div class="col-xs-12">
6-
<h2 class="page-header">
7-
<span contenteditable="true">{{ model.template.title }}</span>
8-
<small class="pull-right">{{ 'date'|trans }}: {{ model.invoiceDate|date_short }}</small>
9-
</h2>
10-
</div>
11-
</div>
15+
<div class="row">
16+
<div class="col-xs-12">
17+
<h2 class="page-header">
18+
<span contenteditable="true">{{ model.template.title }}</span>
19+
<small class="pull-right">{{ 'date'|trans }}: {{ model.invoiceDate|date_short }}</small>
20+
</h2>
21+
</div>
22+
</div>
1223

13-
<div class="row">
14-
<div class="col-sm-5">
15-
{{ 'invoice.from'|trans }}
16-
<address contenteditable="true">
17-
<strong>{{ model.template.company }}</strong><br>
18-
{{ model.template.address|trim|nl2br }}
19-
{% if model.template.vatId is not empty %}
20-
<br>
21-
{{ 'vat_id'|trans }}:
22-
{{ model.template.vatId }}
23-
{% endif %}
24-
</address>
25-
</div>
26-
<div class="col-sm-2"></div>
27-
<div class="col-sm-5">
28-
{% set customerPhone = model.customer.phone|default(model.customer.mobile) %}
29-
{{ 'invoice.to'|trans }}
30-
<address contenteditable="true">
31-
<strong>{{ model.customer.company|default(model.customer.name) }}</strong><br>
32-
{{ model.customer.address|nl2br }}
33-
{% if model.customer.vatId is not empty %}
34-
<br>
35-
{{ 'vat_id'|trans }}: {{ model.customer.vatId }}
36-
{% endif %}
37-
{% if model.customer.number is not empty %}
38-
<br>
39-
{{ 'number'|trans }}: {{ model.customer.number }}
40-
{% endif %}
41-
{% if model.query.project is not empty and model.query.project.orderNumber is not empty %}
42-
<br>
43-
{{ 'orderNumber'|trans }}: {{ model.query.project.orderNumber }}
44-
{% endif %}
45-
</address>
46-
</div>
47-
</div>
24+
<div class="row">
25+
<div class="col-sm-5">
26+
{{ 'invoice.from'|trans }}
27+
<address contenteditable="true">
28+
<strong>{{ model.template.company }}</strong><br>
29+
{{ model.template.address|trim|nl2br }}
30+
{% if model.template.vatId is not empty %}
31+
<br>
32+
{{ 'vat_id'|trans }}:
33+
{{ model.template.vatId }}
34+
{% endif %}
35+
</address>
36+
</div>
37+
<div class="col-sm-2"></div>
38+
<div class="col-sm-5">
39+
{% set customerPhone = model.customer.phone|default(model.customer.mobile) %}
40+
{{ 'invoice.to'|trans }}
41+
<address contenteditable="true">
42+
<strong>{{ model.customer.company|default(model.customer.name) }}</strong><br>
43+
{{ model.customer.address|nl2br }}
44+
{% if model.customer.vatId is not empty %}
45+
<br>
46+
{{ 'vat_id'|trans }}: {{ model.customer.vatId }}
47+
{% endif %}
48+
{% if model.customer.number is not empty %}
49+
<br>
50+
{{ 'number'|trans }}: {{ model.customer.number }}
51+
{% endif %}
52+
{% if model.query.project is not empty and model.query.project.orderNumber is not empty %}
53+
<br>
54+
{{ 'orderNumber'|trans }}: {{ model.query.project.orderNumber }}
55+
{% endif %}
56+
</address>
57+
</div>
58+
</div>
4859

49-
<div class="row">
50-
<div class="col-sm-5">
51-
<p contenteditable="true">
52-
<strong>{{ 'invoice.number'|trans }}:</strong>
53-
{{ model.invoiceNumber }}
60+
<div class="row">
61+
<div class="col-sm-5">
62+
<p contenteditable="true">
63+
<strong>{{ 'invoice.number'|trans }}:</strong>
64+
{{ model.invoiceNumber }}
5465

55-
<br>
56-
<strong>{{ 'invoice.due_days'|trans }}:</strong>
57-
{{ model.dueDate|date_short }}
58-
</p>
59-
</div>
60-
<div class="col-sm-7"></div>
61-
</div>
66+
<br>
67+
<strong>{{ 'invoice.due_days'|trans }}:</strong>
68+
{{ model.dueDate|date_short }}
69+
</p>
70+
</div>
71+
<div class="col-sm-7"></div>
72+
</div>
6273

63-
<div class="row invoice-items">
64-
<div class="col-xs-12 table-responsive">
65-
<table class="table">
66-
<thead>
67-
<tr>
68-
<th>{{ 'date'|trans }}</th>
69-
<th>{{ 'description'|trans }}</th>
70-
<th class="text-right">{{ 'unit_price'|trans }}</th>
71-
<th class="text-right">{{ 'amount'|trans }}</th>
72-
<th class="text-right">{{ 'total_rate'|trans }}</th>
73-
</tr>
74-
</thead>
75-
<tbody>
76-
{% for entry in model.calculator.entries %}
77-
{% set duration = entry.duration|duration(true) %}
78-
{% if entry.fixedRate %}
79-
{% set rate = entry.fixedRate %}
80-
{% set duration = entry.amount|amount %}
81-
{% else %}
82-
{% set rate = entry.hourlyRate %}
83-
{% endif %}
84-
<tr>
85-
<td nowrap class="text-nowrap">{{ entry.begin|date_short }}</td>
86-
<td contenteditable="true">
87-
{% if entry.description is not empty %}
88-
{{ entry.description|nl2br }}
74+
<div class="row invoice-items">
75+
<div class="col-xs-12 table-responsive">
76+
<table class="table">
77+
<thead>
78+
<tr>
79+
<th>{{ 'date'|trans }}</th>
80+
<th>{{ 'description'|trans }}</th>
81+
<th class="text-right">{{ 'unit_price'|trans }}</th>
82+
<th class="text-right">{{ 'amount'|trans }}</th>
83+
<th class="text-right">{{ 'total_rate'|trans }}</th>
84+
</tr>
85+
</thead>
86+
<tbody>
87+
{% for entry in model.calculator.entries %}
88+
{% set duration = entry.duration|duration(true) %}
89+
{% if entry.fixedRate %}
90+
{% set rate = entry.fixedRate %}
91+
{% set duration = entry.amount|amount %}
8992
{% else %}
90-
{{ entry.activity.name }} / {{ entry.project.name }}
93+
{% set rate = entry.hourlyRate %}
9194
{% endif %}
92-
</td>
93-
<td nowrap class="text-nowrap text-right">{{ rate|money(model.calculator.currency) }}</td>
94-
<td nowrap class="text-nowrap text-right">{{ duration }}</td>
95-
<td nowrap class="text-nowrap text-right">{{ entry.rate|money(model.calculator.currency) }}</td>
96-
</tr>
97-
{% endfor %}
98-
</tbody>
99-
<tfoot>
100-
<tr>
101-
<td colspan="4" class="text-right">
102-
{{ 'invoice.subtotal'|trans }}
103-
</td>
104-
<td class="text-right">{{ model.calculator.subtotal|money(model.calculator.currency) }}</td>
105-
</tr>
106-
<tr>
107-
<td colspan="4" class="text-right">
108-
{{ 'invoice.tax'|trans }} ({{ model.calculator.vat }}%)
109-
</td>
110-
<td class="text-right">{{ model.calculator.tax|money(model.calculator.currency) }}</td>
111-
</tr>
112-
<tr>
113-
<td colspan="4" class="text-right text-nowrap">
114-
<strong>{{ 'invoice.total'|trans }}</strong>
115-
</td>
116-
<td class="text-right">
117-
<strong>{{ model.calculator.total|money(model.calculator.currency) }}</strong>
118-
</td>
119-
</tr>
120-
</tfoot>
121-
</table>
122-
</div>
123-
</div>
95+
<tr>
96+
<td nowrap class="text-nowrap">{{ entry.begin|date_short }}</td>
97+
<td contenteditable="true">
98+
{% if entry.description is not empty %}
99+
{{ entry.description|nl2br }}
100+
{% else %}
101+
{{ entry.activity.name }} / {{ entry.project.name }}
102+
{% endif %}
103+
</td>
104+
<td nowrap class="text-nowrap text-right">{{ rate|money(model.calculator.currency) }}</td>
105+
<td nowrap class="text-nowrap text-right">{{ duration }}</td>
106+
<td nowrap class="text-nowrap text-right">{{ entry.rate|money(model.calculator.currency) }}</td>
107+
</tr>
108+
{% endfor %}
109+
</tbody>
110+
<tfoot>
111+
<tr>
112+
<td colspan="4" class="text-right">
113+
{{ 'invoice.subtotal'|trans }}
114+
</td>
115+
<td class="text-right">{{ model.calculator.subtotal|money(model.calculator.currency) }}</td>
116+
</tr>
117+
<tr>
118+
<td colspan="4" class="text-right">
119+
{{ 'invoice.tax'|trans }} ({{ model.calculator.vat }}%)
120+
</td>
121+
<td class="text-right">{{ model.calculator.tax|money(model.calculator.currency) }}</td>
122+
</tr>
123+
<tr>
124+
<td colspan="4" class="text-right text-nowrap">
125+
<strong>{{ 'invoice.total'|trans }}</strong>
126+
</td>
127+
<td class="text-right">
128+
<strong>{{ model.calculator.total|money(model.calculator.currency) }}</strong>
129+
</td>
130+
</tr>
131+
</tfoot>
132+
</table>
133+
</div>
134+
</div>
124135

125-
<div class="row">
126-
<div class="col-xs-12">
127-
{% if model.template.paymentTerms is not empty %}
128-
<div contenteditable="true" class="paymentTerms">
129-
{{ model.template.paymentTerms|nl2br|md2html }}
136+
<div class="row">
137+
<div class="col-xs-12">
138+
{% if model.template.paymentTerms is not empty %}
139+
<div contenteditable="true" class="paymentTerms">
140+
{{ model.template.paymentTerms|nl2br|md2html }}
141+
</div>
142+
{% endif %}
143+
</div>
130144
</div>
131-
{% endif %}
132-
</div>
133-
</div>
134145

135-
<footer class="footer">
136-
<p>
137-
<strong>{{ 'address'|trans }}</strong>: {{ model.template.company }} &ndash; {{ model.template.address|replace({"\n": ' &ndash; ', "\r\n": ' &ndash; ', "\r": ' &ndash; '})|raw }}
138-
<br>
139-
<strong>{{ 'invoice_bank_account'|trans }}</strong>: {{ model.template.paymentDetails|replace({"\n": ' &ndash; ', "\r\n": ' &ndash; ', "\r": ' &ndash; '})|raw }}
140-
<br>
141-
<strong>{{ 'contact'|trans }}</strong>: {{ model.template.contact|replace({"\n": ' &ndash; ', "\r\n": ' &ndash; ', "\r": ' &ndash; '})|raw }}
142-
</p>
143-
</footer>
146+
<footer class="footer">
147+
<p>
148+
<strong>{{ 'address'|trans }}</strong>: {{ model.template.company }} &ndash; {{ model.template.address|replace({"\n": ' &ndash; ', "\r\n": ' &ndash; ', "\r": ' &ndash; '})|raw }}
149+
<br>
150+
<strong>{{ 'invoice_bank_account'|trans }}</strong>: {{ model.template.paymentDetails|replace({"\n": ' &ndash; ', "\r\n": ' &ndash; ', "\r": ' &ndash; '})|raw }}
151+
<br>
152+
<strong>{{ 'contact'|trans }}</strong>: {{ model.template.contact|replace({"\n": ' &ndash; ', "\r\n": ' &ndash; ', "\r": ' &ndash; '})|raw }}
153+
</p>
154+
</footer>
144155

145-
{% endblock %}
156+
</section>
157+
</div>
158+
</body>
159+
</html>

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "Showcase plugin for Kimai, with demos for many extension points within the core",
44
"homepage": "https://github.com/Keleo/DemoBundle",
55
"type": "kimai-plugin",
6-
"version": "2.0",
6+
"version": "2.0.1",
77
"keywords": [
88
"kimai",
99
"kimai-plugin"

0 commit comments

Comments
 (0)