added export module (#538)
This commit is contained in:
172
templates/export/renderer/default.html.twig
Normal file
172
templates/export/renderer/default.html.twig
Normal file
@@ -0,0 +1,172 @@
|
||||
{% import "macros/widgets.html.twig" as widgets %}
|
||||
{% extends 'export/layout.html.twig' %}
|
||||
|
||||
{% block export %}
|
||||
<style>
|
||||
.items tr.summary {
|
||||
}
|
||||
.items td.totals {
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
}
|
||||
.items td.duration,
|
||||
.items th.duration,
|
||||
.items th.cost,
|
||||
.items td.cost {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<h2>{{ 'export.document_title'|trans }}</h2>
|
||||
<p>
|
||||
{{ 'export.period'|trans }}:
|
||||
{{ query.begin|date_short }} - {{ query.end|date_short }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xs-12">
|
||||
<h3>{{ 'export.summary'|trans }}</h3>
|
||||
<table class="items table table-condensed table-bordered dataTable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ 'label.customer'|trans }}</th>
|
||||
<th>{{ 'label.project'|trans }}</th>
|
||||
<th class="duration">{{ 'label.duration'|trans }}</th>
|
||||
<th class="cost">{{ 'label.rate'|trans }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% set customer = null %}
|
||||
{% set customerDuration = 0 %}
|
||||
{% set customerRate = 0 %}
|
||||
{% set customerCurrency = null %}
|
||||
{% for summary in summaries %}
|
||||
{% 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">
|
||||
<td colspan="2"></td>
|
||||
<td class="totals duration">{{ customerDuration|duration }}</td>
|
||||
<td class="totals cost">{{ customerRate|money(customerCurrency) }}</td>
|
||||
</tr>
|
||||
{% set customerCurrency = summary.currency %}
|
||||
{% set customer = summary.customer %}
|
||||
{% set customerDuration = 0 %}
|
||||
{% set customerRate = 0 %}
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td>{{ summary.customer }}</td>
|
||||
<td>{{ summary.project }}</td>
|
||||
<td class="duration">{{ summary.duration|duration }}</td>
|
||||
<td class="cost">{{ summary.rate|money(summary.currency) }}</td>
|
||||
</tr>
|
||||
{% set customerDuration = customerDuration + summary.duration %}
|
||||
{% set customerRate = customerRate + summary.rate %}
|
||||
{% endfor %}
|
||||
{% if customer is not same as(null) %}
|
||||
<tr class="summary">
|
||||
<td colspan="2"></td>
|
||||
<td class="totals duration">{{ customerDuration|duration }}</td>
|
||||
<td class="totals cost">{{ customerRate|money(customerCurrency) }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% set columns = [
|
||||
'label.date',
|
||||
'label.begin',
|
||||
'label.end',
|
||||
'label.username',
|
||||
'label.customer',
|
||||
'label.project',
|
||||
'label.activity',
|
||||
'label.description',
|
||||
'label.exported',
|
||||
'label.hourly_rate',
|
||||
'label.fixed_rate',
|
||||
'label.duration',
|
||||
'label.rate',
|
||||
] %}
|
||||
|
||||
<div class="row" id="export-records">
|
||||
<div class="col-xs-12">
|
||||
<h3>{{ 'export.full_list'|trans }}</h3>
|
||||
<table class="table table-condensed table-bordered dataTable">
|
||||
<thead>
|
||||
<tr>
|
||||
{% for columnTitle in columns %}
|
||||
<th>{{ columnTitle|trans }}</th>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% set timeWorked = 0 %}
|
||||
{% set rateTotal = 0 %}
|
||||
{% set currency = false %}
|
||||
{% for entry in entries %}
|
||||
{% set timeWorked = timeWorked + entry.duration %}
|
||||
{% set rateTotal = rateTotal + entry.rate %}
|
||||
{% if currency is same as(false) %}
|
||||
{% set currency = entry.project.customer.currency %}
|
||||
{% endif %}
|
||||
{% if currency is not same as(entry.project.customer.currency) %}
|
||||
{% set currency = null %}
|
||||
{% endif %}
|
||||
<tr>
|
||||
<td class="text-nowrap">{{ entry.begin|date_short }}</td>
|
||||
<td class="text-nowrap">{{ entry.begin|date("H:i") }}</td>
|
||||
<td class="text-nowrap">{{ entry.end|date("H:i") }}</td>
|
||||
<td>{{ widgets.username(entry.user) }}</td>
|
||||
<td>{{ entry.project.customer.name }}</td>
|
||||
<td>{{ entry.project.name }}</td>
|
||||
<td>{{ entry.activity.name }}</td>
|
||||
<td>
|
||||
{% if entry.description is not empty %}
|
||||
{{ entry.description|desc2html }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if entry.exported %}
|
||||
{{ 'entryState.exported'|trans }}
|
||||
{% else %}
|
||||
{{ 'entryState.not_exported'|trans }}
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="text-nowrap">{{ entry.hourlyRate|money(entry.project.customer.currency) }}</td>
|
||||
<td class="text-nowrap">{{ entry.fixedRate|money(entry.project.customer.currency) }}</td>
|
||||
<td class="text-nowrap">{{ entry.duration|duration }}</td>
|
||||
<td class="text-nowrap">
|
||||
{{ entry.rate|money(entry.project.customer.currency) }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="{{ ( columns|length ) - 2 }}" class="text-right"></th>
|
||||
<th class="text-nowrap">
|
||||
{{ timeWorked|duration }}
|
||||
</th>
|
||||
<th class="text-nowrap">
|
||||
{% if currency is not null and currency is not same as(false) %}
|
||||
{{ rateTotal|money(currency) }}
|
||||
{% else %}
|
||||
{{ rateTotal|money }}
|
||||
{% endif %}
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
169
templates/export/renderer/pdf.html.twig
Normal file
169
templates/export/renderer/pdf.html.twig
Normal file
@@ -0,0 +1,169 @@
|
||||
<html>
|
||||
<head>
|
||||
<style>
|
||||
body {font-family: sans-serif;
|
||||
font-size: 10pt;
|
||||
}
|
||||
p { margin: 0pt; }
|
||||
table.items {
|
||||
border: 0.1mm solid #000000;
|
||||
}
|
||||
td { vertical-align: top; }
|
||||
.items td {
|
||||
border-left: 0.1mm solid #000000;
|
||||
border-right: 0.1mm solid #000000;
|
||||
}
|
||||
.items tr.even {
|
||||
background-color: #e0ebff;
|
||||
}
|
||||
.items tr.summary {
|
||||
background-color: #efefef;
|
||||
}
|
||||
.items tr.summary td {
|
||||
font-weight: bold;
|
||||
border-top: 0.1mm solid #000000;
|
||||
border-bottom: 0.1mm solid #000000;
|
||||
}
|
||||
table thead td {
|
||||
background-color: #ececec;
|
||||
text-align: center;
|
||||
border: 0.1mm solid #000000;
|
||||
font-variant: small-caps;
|
||||
}
|
||||
.items td.totals {
|
||||
font-weight: bold;
|
||||
text-align: right;
|
||||
border: 0.1mm solid #000000;
|
||||
}
|
||||
.items td.duration,
|
||||
.items td.cost {
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<!--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}'}) }}
|
||||
</td>
|
||||
<td align="right">
|
||||
{{ 'export.date_copyright'|trans({'%date%': now|date_short ~ ' ' ~ now|date('H:i'), '%kimai%': '<a href="' ~ constant('App\\Constants::HOMEPAGE') ~ '">' ~ constant('App\\Constants::SOFTWARE') ~ '</a>'})|raw }}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</htmlpagefooter>
|
||||
<sethtmlpagefooter name="myfooter" value="on" />
|
||||
mpdf-->
|
||||
<h2 style="margin-bottom: 0; padding-bottom: 0">{{ 'export.document_title'|trans }}</h2>
|
||||
<p>
|
||||
{{ 'export.period'|trans }}:
|
||||
{{ query.begin|date_short }} - {{ query.end|date_short }}
|
||||
</p>
|
||||
<h3>{{ 'export.summary'|trans }}</h3>
|
||||
<table class="items" width="100%" style="font-size: 9pt; border-collapse: collapse; " cellpadding="8">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>{{ 'label.customer'|trans }}</td>
|
||||
<td>{{ 'label.project'|trans }}</td>
|
||||
<td>{{ 'label.duration'|trans }}</td>
|
||||
<td>{{ 'label.rate'|trans }}</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% set customer = null %}
|
||||
{% set customerDuration = 0 %}
|
||||
{% set customerRate = 0 %}
|
||||
{% set customerCurrency = null %}
|
||||
{% set customerCount = 0 %}
|
||||
{% for summary in summaries %}
|
||||
{% 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">
|
||||
<td colspan="2"></td>
|
||||
<td class="totals duration">{{ customerDuration|duration }}</td>
|
||||
<td class="totals cost">{{ customerRate|money(customerCurrency) }}</td>
|
||||
</tr>
|
||||
{% set customerCurrency = summary.currency %}
|
||||
{% set customer = summary.customer %}
|
||||
{% set customerDuration = 0 %}
|
||||
{% set customerRate = 0 %}
|
||||
{% set customerCount = 0 %}
|
||||
{% endif %}
|
||||
<tr class="{{ cycle(['odd', 'even'], customerCount) }}">
|
||||
<td>{{ summary.customer }}</td>
|
||||
<td>{{ summary.project }}</td>
|
||||
<td class="duration">{{ summary.duration|duration }}</td>
|
||||
<td class="cost">{{ summary.rate|money(summary.currency) }}</td>
|
||||
</tr>
|
||||
{% set customerDuration = customerDuration + summary.duration %}
|
||||
{% set customerRate = customerRate + summary.rate %}
|
||||
{% set customerCount = customerCount + 1 %}
|
||||
{% endfor %}
|
||||
{% if customer is not same as(null) %}
|
||||
<tr class="summary">
|
||||
<td colspan="2"></td>
|
||||
<td class="totals duration">{{ customerDuration|duration }}</td>
|
||||
<td class="totals cost">{{ customerRate|money(customerCurrency) }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<pagebreak>
|
||||
|
||||
<h3>{{ 'export.full_list'|trans }}</h3>
|
||||
|
||||
{% set duration = 0 %}
|
||||
{% set rate = 0 %}
|
||||
{% set currency = false %}
|
||||
<table class="items" width="100%" style="font-size: 9pt; border-collapse: collapse; " cellpadding="8">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>{{ 'label.date'|trans }}</td>
|
||||
<td width="">{{ 'label.description'|trans }}</td>
|
||||
<td>{{ 'label.duration'|trans }}</td>
|
||||
<td>{{ 'label.rate'|trans }}</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for entry in entries %}
|
||||
{% set duration = duration + entry.duration %}
|
||||
{% set rate = rate + entry.rate %}
|
||||
{% if currency is same as(false) %}
|
||||
{% set currency = entry.project.customer.currency %}
|
||||
{% endif %}
|
||||
{% if currency is not same as(entry.project.customer.currency) %}
|
||||
{% set currency = null %}
|
||||
{% endif %}
|
||||
<tr class="{{ cycle(['odd', 'even'], loop.index0) }}">
|
||||
<td>
|
||||
{{ entry.begin|date_time }}
|
||||
<br>
|
||||
{{ entry.end|date_time }}
|
||||
</td>
|
||||
<td>
|
||||
{{ entry.project.customer.name }} - {{ entry.project.name }} - {{ entry.activity.name }}
|
||||
{% if entry.description is not empty %}
|
||||
<br>
|
||||
<i>{{ entry.description|desc2html }}</i>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="duration">{{ entry.duration|duration }}</td>
|
||||
<td class="cost">{{ entry.rate|money(entry.project.customer.currency) }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr class="summary">
|
||||
<td colspan="2"></td>
|
||||
<td class="totals duration">{{ duration|duration }}</td>
|
||||
<td class="totals cost">{{ rate|money(currency) }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user