Next major version 2 with PHP 8.1, Symfony 6, Tabler UI, 2FA ... (#2902)

This commit is contained in:
Kevin Papst
2022-12-31 21:19:55 +01:00
committed by GitHub
parent 95e06746bd
commit 90a0fd8a22
2164 changed files with 83700 additions and 86426 deletions

View File

@@ -1,8 +1,3 @@
{% macro invoices(view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set event = actions(app.user, 'invoices', view) %}
{{ widgets.page_actions(event.actions) }}
{% endmacro %}
{% macro invoice(invoice, view) %}
{% import "macros/widgets.html.twig" as widgets %}
@@ -10,24 +5,6 @@
{{ widgets.table_actions(event.actions) }}
{% endmacro %}
{% macro invoice_listing(view, query) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set event = actions(app.user, 'invoice_details', view, {'query': query}) %}
{{ widgets.page_actions(event.actions) }}
{% endmacro %}
{% macro invoice_upload(view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set event = actions(app.user, 'invoice_upload', view) %}
{{ widgets.page_actions(event.actions) }}
{% endmacro %}
{% macro invoice_templates(view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set event = actions(app.user, 'invoice_templates', view) %}
{{ widgets.page_actions(event.actions) }}
{% endmacro %}
{% macro invoice_template(template, view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set event = actions(app.user, 'invoice_template', view, {'template': template, 'token': csrf_token('invoice.delete_template')}) %}

View File

@@ -1,24 +1,24 @@
{% extends 'base.html.twig' %}
{% import "invoice/actions.html.twig" as actions %}
{% import "macros/widgets.html.twig" as widgets %}
{% block page_title %}{{ 'label.invoice_renderer'|trans({}, 'invoice-renderer') }}{% endblock %}
{% block page_actions %}{{ actions.invoice_upload('index') }}{% endblock %}
{% block main %}
{% if can_upload and form is not null %}
{% form_theme form '@AdminLTE/layout/form-theme-horizontal.html.twig' %}
{% set formOptions = {
'title': 'upload'|trans,
'form': form,
'back': false,
'reset': false
} %}
{% embed 'default/_form.html.twig' with formOptions %}
{% block form_body %}
{% embed '@theme/embeds/card.html.twig' %}
{% form_theme form 'form/horizontal.html.twig' %}
{% block box_title %}
{{ 'upload'|trans }}
{% endblock %}
{% block box_body %}
{{ form_start(form) }}
{{ form_row(form.document) }}
{{ form_widget(form) }}
<p>
<a href="https://github.com/kimai/invoice-templates" target="_blank">{{ 'download_invoice_renderer'|trans({}, 'invoice-renderer') }}</a>
</p>
{{ form_end(form) }}
{% endblock %}
{% block box_footer %}
<button type="submit" class="btn btn-primary">{{ 'action.save'|trans }}</button>
<a href="{{ path('admin_invoice_template') }}" class="btn btn-link">{{ 'back'|trans({}, 'actions') }}</a>
{% endblock %}
{% endembed %}
{% elseif upload_error is not null %}
@@ -26,21 +26,21 @@
{% endif %}
{% if documents|length > 0 %}
{% embed '@AdminLTE/Widgets/box-widget.html.twig' with {'documents': documents} %}
{% embed '@theme/embeds/card.html.twig' with {'documents': documents} %}
{% import "invoice/actions.html.twig" as actions %}
{% import "macros/widgets.html.twig" as widgets %}
{% block box_title %}{{ 'label.invoice_renderer'|trans({}, 'invoice-renderer') }}{% endblock %}
{% block box_title %}{{ 'invoice_renderer'|trans({}, 'invoice-renderer') }}{% endblock %}
{% block box_attributes %}
id="invoice_document_list"
{% endblock %}
{% block box_body_class %}no-padding{% endblock %}
{% block box_body_class %}p-0{% endblock %}
{% block box_body %}
<table class="table table-hover dataTable">
<thead>
<tr>
<th>{{ 'file'|trans }}</th>
<th>{{ 'updated_at'|trans }}</th>
<th>{{ 'label.template'|trans }}</th>
<th>{{ 'template'|trans }}</th>
<th></th>
</tr>
</thead>

View File

@@ -1,235 +1,216 @@
{% extends 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/datatables.html.twig" as tables %}
{% import "macros/toolbar.html.twig" as toolbar %}
{% import "invoice/actions.html.twig" as actions %}
{% set totalDuration = 0 %}
{% set totalRates = {} %}
{% set showEmpty = false %}
{% if searched %}
{% set showEmpty = true %}
{% for model in models %}
{% if showEmpty %}
{% set showEmpty = model.calculator is empty or model.calculator.entries is empty %}
{% endif %}
{% set totalDuration = totalDuration + model.calculator.timeWorked %}
{% set customerCurrency = model.customer.currency %}
{% if totalRates[customerCurrency] is not defined %}
{% set totalRates = totalRates|merge({(customerCurrency): 0.00}) %}
{% endif %}
{% set totalRates = totalRates|merge({(customerCurrency): totalRates[customerCurrency] + model.calculator.total}) %}
{% endfor %}
{% endif %}
{% set columns = {
'date': {'class': 'alwaysVisible w-min', 'orderBy': false},
'project': {'class': 'hidden-xs hidden-sm', 'orderBy': false},
'description': {'class': 'hidden-xs hidden-sm hidden', 'orderBy': false},
'user': {'class': 'hidden-xs hidden-sm w-min', 'orderBy': false},
'unit_price': {'class': 'hidden-xs text-right w-min', 'orderBy': false},
'amount': {'class': 'text-right w-min', 'orderBy': false},
'duration': {'class': 'hidden-xs text-right w-min', 'orderBy': false},
'total_rate': {'class': 'text-right alwaysVisible w-min', 'orderBy': false},
'project': {'class': 'd-none d-md-table-cell', 'orderBy': false},
'description': {'class': 'd-none d-xl-table-cell', 'orderBy': false},
'user': {'class': 'd-none d-xl-table-cell w-min', 'orderBy': false},
'unit_price': {'class': 'd-none d-sm-table-cell text-end w-min', 'orderBy': false},
'amount': {'class': 'd-none d-sm-table-cell text-end w-min', 'orderBy': false},
'duration': {'class': 'text-end w-min', 'orderBy': false},
'total_rate': {'class': 'text-end alwaysVisible w-min', 'orderBy': false},
} %}
{% set tableName = 'invoice' %}
{% set tableName = 'invoice_create' %}
{% block page_title %}{{ 'invoices'|trans }}{% endblock %}
{% block page_actions %}{{ actions.invoices('index') }}{% endblock %}
{% block main_before %}
{{ tables.data_table_column_modal(tableName, columns) }}
{% block status %}
{% from "macros/status.html.twig" import status_duration, status_money %}
{{ status_duration(totalDuration|duration) }}
{% for totalCurrency, totalRate in totalRates %}
{{ status_money(totalRate|money(totalCurrency)) }}
{% endfor %}
{% endblock %}
{% block main %}
{% if is_granted('create_invoice') %}
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
{% import "macros/search.html.twig" as search %}
{% form_theme form '@AdminLTE/layout/form-theme-horizontal.html.twig' %}
{% block box_title %}{{ 'invoice.filter'|trans }}{% endblock %}
{% block box_before %}{{ form_start(form) }}{% endblock %}
{% block box_body %}
{{ form_errors(form) }}
{% if form.searchTerm is defined %}
{{ form_row(form.searchTerm, {'row_attr': {'class': 'invoice_search_form_row_searchTerm'}}) }}
{% endif %}
{{ form_row(form.daterange, {'row_attr': {'class': 'invoice_search_form_row_daterange'}}) }}
{{ form_row(form.customers, {'row_attr': {'class': 'invoice_search_form_row_customers'}}) }}
{{ form_row(form.projects, {'row_attr': {'class': 'invoice_search_form_row_projects'}}) }}
{% if form.activities is defined %}
{{ form_row(form.activities, {'row_attr': {'class': 'invoice_search_form_row_activities'}}) }}
{% endif %}
{% if form.tags is defined %}
{{ form_row(form.tags, {'row_attr': {'class': 'invoice_search_form_row_tags'}}) }}
{% endif %}
{% if form.users is defined %}
{{ form_row(form.users, {'row_attr': {'class': 'invoice_search_form_row_users'}}) }}
{% endif %}
{% if form.teams is defined %}
{{ form_row(form.teams, {'row_attr': {'class': 'invoice_search_form_row_teams'}}) }}
{% endif %}
{% if form.exported is defined %}
{{ form_row(form.exported, {'row_attr': {'class': 'invoice_search_form_row_exported'}}) }}
{% endif %}
{{ form_row(form.template, {'row_attr': {'class': 'invoice_search_form_row_template'}}) }}
{% if form.markAsExported is defined %}
{{ form_row(form.markAsExported, {'row_attr': {'class': 'invoice_search_form_row_markAsExported'}}) }}
{% endif %}
{% endblock %}
{% block box_footer%}
{{ search.searchButton(form) }}
{% endblock %}
{% block box_after %}{{ form_end(form) }}{% endblock %}
{% endembed %}
{% else %}
{{ widgets.callout('danger', 'http_error_403.suggestion'|trans({}, 'exceptions')) }}
{% endif %}
{% set totalDuration = 0 %}
{% set totalRates = {} %}
{% if searched %}
{% set showEmpty = true %}
{% for model in models %}
{% if showEmpty %}
{% set showEmpty = model.calculator is empty or model.calculator.entries is empty %}
{% embed '@theme/embeds/card.html.twig' %}
{% import "macros/search.html.twig" as search %}
{% form_theme form 'form/horizontal.html.twig' %}
{% block box_title %}{{ 'invoice.filter'|trans }}{% endblock %}
{% block box_before %}{{ form_start(form) }}{% endblock %}
{% block box_body %}
{{ form_errors(form) }}
{% if form.searchTerm is defined %}
{{ form_row(form.searchTerm, {'row_attr': {'class': 'mb-3 invoice_search_form_row_searchTerm'}}) }}
{% endif %}
{% set totalDuration = totalDuration + model.calculator.timeWorked %}
{% set customerCurrency = model.customer.currency %}
{% if totalRates[customerCurrency] is not defined %}
{% set totalRates = totalRates|merge({(customerCurrency): 0.00}) %}
{{ form_row(form.daterange, {'row_attr': {'class': 'mb-3 invoice_search_form_row_daterange'}}) }}
{{ form_row(form.customers, {'row_attr': {'class': 'mb-3 invoice_search_form_row_customers'}}) }}
{{ form_row(form.projects, {'row_attr': {'class': 'mb-3 invoice_search_form_row_projects'}}) }}
{% if form.activities is defined %}
{{ form_row(form.activities, {'row_attr': {'class': 'mb-3 invoice_search_form_row_activities'}}) }}
{% endif %}
{% set totalRates = totalRates|merge({(customerCurrency): totalRates[customerCurrency] + model.calculator.total}) %}
{% endfor %}
{% if showEmpty %}
{{ widgets.nothing_found() }}
{% endif %}
{% if form.tags is defined %}
{{ form_row(form.tags, {'row_attr': {'class': 'mb-3 invoice_search_form_row_tags'}}) }}
{% endif %}
{% if form.users is defined %}
{{ form_row(form.users, {'row_attr': {'class': 'mb-3 invoice_search_form_row_users'}}) }}
{% endif %}
{% if form.teams is defined %}
{{ form_row(form.teams, {'row_attr': {'class': 'mb-3 invoice_search_form_row_teams'}}) }}
{% endif %}
{% if form.exported is defined %}
{{ form_row(form.exported, {'row_attr': {'class': 'mb-3 invoice_search_form_row_exported'}}) }}
{% endif %}
<div class="d-none">
{{ form_row(form.template, {'row_attr': {'class': 'mb-3 invoice_search_form_row_template'}}) }}
{{ form_row(form.invoiceDate, {'row_attr': {'class': 'mb-3 invoice_search_form_row_invoiceDate'}}) }}
</div>
{% endblock %}
{% block box_footer%}
{{ search.searchButton(form) }}
{% endblock %}
{% block box_after %}{{ form_end(form) }}{% endblock %}
{% endembed %}
{% if showEmpty %}
{{ widgets.nothing_found() }}
{% endif %}
{% if models|length > 0 %}
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
{% embed '@theme/embeds/card.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import '@AdminLTE/Macros/buttons.html.twig' as button %}
{% import "macros/datatables.html.twig" as tables %}
{% block box_title %}
{{ 'button.preview'|trans }}: {{ 'invoices'|trans }}
{{ widgets.label(totalDuration|duration, 'gray') }}
{% for totalCurrency, totalRate in totalRates %}
{{ widgets.label(totalRate|money(totalCurrency), 'gray') }}
{% endfor %}
{% endblock %}
{% block box_body_class %}no-padding{% endblock %}
{% block box_footer %}
<a href="#" onclick="return saveAllInvoices(this);" class="btn btn-success" id="create_all_invoices">
{{ 'action.save_all'|trans }}
</a>
{{ 'preview'|trans }}
{% endblock %}
{% block box_attributes %}id="invoice_customer_forms"{% endblock %}
{% block box_body_class %}p-0{% endblock %}
{% block box_body %}
<table class="table table-hover dataTable">
<table class="table dataTable">
<thead>
<tr>
<th>{{ 'label.customer'|trans }}</th>
<th class="w-min text-center actions"></th>
<th class="w-min text-right hidden-xs">{{ 'label.duration'|trans }}</th>
<th class="w-min text-right hidden-xs">{{ 'label.total_rate'|trans }}</th>
<th class="d-sm-table-cell d-none"></th>
<th>{{ 'customer'|trans }}</th>
<th class="w-min text-end d-sm-table-cell d-none">{{ 'duration'|trans }}</th>
<th class="w-min text-end d-sm-table-cell d-none">{{ 'total_rate'|trans }}</th>
<th class="w-min text-center actions alwaysVisible"></th>
</tr>
</thead>
<tbody>
{% for model in models %}
{% set isDecimal = model.template.decimalDuration|default(false) %}
{% set isDecimal = true %}
{% set currency = model.currency %}
{% set isEmptyModel = model.calculator is empty or model.calculator.entries is empty %}
{% set customerForm = forms[loop.index0] %}
<tr>
<td class="w-min d-sm-table-cell d-none">
{% if not isEmptyModel %}
{{ widgets.card_tool_button('collapse', {'onclick': "this.parentElement.parentElement.nextElementSibling.classList.toggle('d-none');return false;"}) }}
{% endif %}
</td>
<td>
{% if is_granted('view', model.customer) %}
<a class="link-black" href="{{ path('customer_details', {id: model.customer.id}) }}">{{ widgets.label_customer(model.customer) }}</a>
<a class="text-reset" href="{{ path('customer_details', {id: model.customer.id}) }}">{{ widgets.label_customer(model.customer) }}</a>
{% else %}
{{ widgets.label_customer(model.customer) }}
{% endif %}
</td>
<td class="w-min text-center">
{{ widgets.action_button('print', {'url': '#', 'onclick': 'return singleInvoice(this, true)', 'title': 'button.preview'|trans, 'target': '_blank', 'class': 'btn btn-sm', 'attr': {'data-customer': model.customer.id, 'data-template': model.template.id, 'data-href': path('invoice_preview', {'customer': model.customer.id, 'token': csrf_token('invoice.preview')})}}) }}
{{ widgets.action_button('save', {'url': '#', 'onclick': 'return singleInvoice(this, false)', 'title': 'action.save'|trans, 'class': 'btn btn-sm', 'attr': {'data-customer': model.customer.id, 'data-template': model.template.id, 'data-href': path('invoice_create', {'customer': model.customer.id, 'template': model.template.id, 'token': csrf_token('invoice.create')})}}, 'success') }}
</td>
<td class="w-min text-right hidden-xs">
<td class="w-min text-end d-sm-table-cell d-none">
{{ model.calculator.timeWorked|duration(isDecimal) }}
</td>
<td class="w-min text-right hidden-xs">
<span title="{{ 'label.vat'|trans }}: {{ model.calculator.tax|money(currency) }}" data-toggle="tooltip">{{ model.calculator.total|money(currency) }}</span>
<td class="w-min text-end d-sm-table-cell d-none">
<span title="{{ 'vat'|trans }}: {{ model.calculator.tax|money(currency) }}" data-toggle="tooltip">{{ model.calculator.total|money(currency) }}</span>
</td>
<td class="w-min text-center actions alwaysVisible">
{% for attrs in [{'class': 'd-inline-flex d-md-none'}, {'icon': false, 'class': 'd-none d-md-inline-flex'}] %}
{{ widgets.action_button('print', {'url': '#', 'onclick': 'return singleInvoice(this, true)', 'title': 'preview'|trans, 'target': '_blank', 'attr': {'data-customer': model.customer.id, 'data-href': path('invoice_preview', {'customer': model.customer.id, 'token': csrf_token('invoice.preview')})}}|merge(attrs)) }}
{{ widgets.action_button('invoice', {'url': '#', 'onclick': 'return singleInvoice(this, false)', 'title': 'action.save'|trans, 'attr': {'data-customer': model.customer.id, 'data-href': path('invoice_create', {'customer': model.customer.id, 'token': csrf_token('invoice.create')})}}|merge(attrs), 'success') }}
{% endfor %}
</td>
</tr>
<tr class="d-none">
<td colspan="5" class="p-2">
{% if not isEmptyModel %}
{% form_theme customerForm 'form/horizontal.html.twig' %}
{{ form_start(customerForm) }}
{{ form_rest(customerForm) }}
{{ form_end(customerForm) }}
{% set isDecimal = true %}
{% set entries = model.calculator.entries %}
{% set currency = model.currency %}
{% set itemsAmount = entries|length %}
{{ tables.datatable_header(tableName, columns, model.query, {'boxClass': ''}) }}
{% if limit_preview %}
{% set entries = entries|slice(0, 100) %}
{% endif %}
{% for entry in entries %}
{% set amount = entry.amount %}
{% set duration = entry.duration|duration(isDecimal) %}
{% set rate = 0 %}
{% if entry.fixedRate is not null %}
{% set rate = entry.fixedRate %}
{% elseif entry.hourlyRate is not null %}
{% set rate = entry.hourlyRate %}
{% endif %}
<tr>
<td class="{{ tables.data_table_column_class(tableName, columns, 'date') }}">{{ entry.begin|date_short }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'project') }}">
{% if is_granted('view', entry.project) %}
<a class="text-reset" href="{{ path('project_details', {id: entry.project.id}) }}">{{ widgets.label_project(entry.project) }}</a>
{% else %}
{{ widgets.label_project(entry.project) }}
{% endif %}
{% if entry.activity is not null %}
<br>
<small>
{% if is_granted('view', entry.activity) %}
<a class="text-reset" href="{{ path('activity_details', {id: entry.activity.id}) }}">{{ widgets.label_activity(entry.activity) }}</a>
{% else %}
{{ widgets.label_activity(entry.activity) }}
{% endif %}
</small>
{% endif %}
</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'description') }} timesheet-description">
{% if entry.description is not empty %}
{{ entry.description|desc2html }}
{% endif %}
</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'user') }}">{{ widgets.label_user(entry.user) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'unit_price') }}">{{ rate|money(currency) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'amount') }}">{{ amount }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'duration') }}" data-duration="{{ entry.duration }}">{{ duration }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'total_rate') }}">{{ entry.rate|money(currency) }}</td>
</tr>
{% endfor %}
{% if limit_preview and itemsAmount > 100 %}
<tr class="warning">
<td colspan="8">&raquo; {{ 'preview.skipped_rows'|trans({'%rows%': (itemsAmount - 100)}) }}</td>
</tr>
{% endif %}
{{ tables.data_table_footer(entries) }}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div style="display: none" id="create-token" data-value="{{ csrf_token('invoice.create') }}"></div>
<div style="display: none" id="preview-token" data-value="{{ csrf_token('invoice.preview') }}"></div>
{% endblock %}
{% endembed %}
{% for model in models %}
{% set isEmptyModel = model.calculator is empty or model.calculator.entries is empty %}
{% if not isEmptyModel %}
{% set customer = model.query.customers[0] %}
{% set isDecimal = model.template.decimalDuration|default(false) %}
{% set entries = model.calculator.entries %}
{% set currency = model.currency %}
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/datatables.html.twig" as tables %}
{% block box_title %}
<span id="invoice_preview_details_{{ customer.id }}">{{ widgets.label_customer(customer) }}</span>
{{ widgets.label(model.calculator.timeWorked|duration, 'gray') }}
{{ widgets.label(model.calculator.total|money(currency), 'gray') }}
{% endblock %}
{% block box_body_class %}invoice-preview-box no-padding{% endblock %}
{% block box_body %}
{{ tables.datatable_header(tableName, columns, model.query, {'boxClass': ''}) }}
{% set itemsAmount = entries|length %}
{% if limit_preview %}
{% set entries = entries|slice(0, 100) %}
{% endif %}
{% for entry in entries %}
{% set amount = entry.amount %}
{% set duration = entry.duration|duration(isDecimal) %}
{% set rate = 0 %}
{% if entry.fixedRate is not null %}
{% set rate = entry.fixedRate %}
{% elseif entry.hourlyRate is not null %}
{% set rate = entry.hourlyRate %}
{% endif %}
<tr>
<td class="{{ tables.data_table_column_class(tableName, columns, 'date') }}">{{ entry.begin|date_short }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'project') }}">
{% if is_granted('view', entry.project) %}
<a class="link-black" href="{{ path('project_details', {id: entry.project.id}) }}">{{ widgets.label_project(entry.project) }}</a>
{% else %}
{{ widgets.label_project(entry.project) }}
{% endif %}
{% if entry.activity is not null %}
<br>
<small>
{% if is_granted('view', entry.activity) %}
<a class="link-black" href="{{ path('activity_details', {id: entry.activity.id}) }}">{{ widgets.label_activity(entry.activity) }}</a>
{% else %}
{{ widgets.label_activity(entry.activity) }}
{% endif %}
</small>
{% endif %}
</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'description') }} timesheet-description">
{% if entry.description is not empty %}
{{ entry.description|desc2html }}
{% endif %}
</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'user') }}">{{ widgets.label_user(entry.user) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'unit_price') }}">{{ rate|money(currency) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'amount') }}">{{ amount }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'duration') }}" data-duration="{{ entry.duration }}">{{ duration }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'total_rate') }}">{{ entry.rate|money(currency) }}</td>
</tr>
{% endfor %}
{% if limit_preview and itemsAmount > 100 %}
<tr class="warning">
<td colspan="8">&raquo; {{ 'preview.skipped_rows'|trans({'%rows%': (itemsAmount - 100)}) }}</td>
</tr>
{% endif %}
<tr class="summary">
<td class="{{ tables.data_table_column_class(tableName, columns, 'date') }}"></td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'project') }}"></td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'description') }}"></td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'user') }}"></td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'unit_price') }}"></td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'amount') }}"></td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'duration') }}">{{ model.calculator.timeWorked|duration(isDecimal) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'total_rate') }}">{{ model.calculator.total|money(currency) }}</td>
</tr>
{{ tables.data_table_footer(entries) }}
{% endblock %}
{% endembed %}
{% endif %}
{% endfor %}
{% endif %}
{% endblock %}
@@ -240,11 +221,13 @@
{% set formSelector = 'form#' ~ formId %}
<script type="text/javascript">
function singleInvoice(link, preview)
{
const formName = 'customer_' + link.dataset['customer'];
const template = document.getElementById(formName + '_template').value;
const date = document.getElementById(formName + '_invoiceDate').value;
const formPlugin = kimai.getPlugin('form');
const overwrites = {'customers[]': link.dataset['customer'], 'template': link.dataset['template']};
const overwrites = {'customers[]': link.dataset['customer'], 'template': template, 'invoiceDate': date};
const uri = formPlugin.convertFormDataToQueryString(document.getElementById('{{ formId }}'), overwrites);
const invoiceUrl = link.dataset['href'] + '?' + uri;
@@ -261,28 +244,15 @@
return true;
}
function saveAllInvoices(link)
{
const formPlugin = kimai.getPlugin('form');
const uri = formPlugin.convertFormDataToQueryString(document.getElementById('{{ formId }}'));
link.classList.toggle('disabled');
link.href = 'javascript: void(0)';
document.location = '{{ path('invoice') }}?token={{ csrf_token('invoice.create') }}&createInvoice=true&' + uri;
return false;
}
document.addEventListener('kimai.initialized', function() {
/** @type CustomEvent event */
document.addEventListener('kimai.initialized', function(event) {
KimaiReloadPageWidget.create('kimai.systemConfigUpdate', true);
{% if models|length > 0 %}
jQuery('body').on('change', '#{{ form.template.vars.id }}', function(event) {
document.getElementById('{{ form.template.vars.id }}').addEventListener('change', function(event) {
document.getElementById('{{ form.vars.attr.id }}').submit();
});
{% endif %}
});
</script>
{% endblock %}

View File

@@ -1,9 +1,7 @@
{% extends app.request.xmlHttpRequest ? 'form.html.twig' : 'base.html.twig' %}
{% block page_title %}{{ 'invoices'|trans }}{% endblock %}
{% extends kimai_context.modalRequest ? 'form.html.twig' : 'base.html.twig' %}
{% block main %}
{% set formEditTemplate = app.request.xmlHttpRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig' %}
{% set formEditTemplate = kimai_context.modalRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig' %}
{% set formOptions = {
'title': invoice.customer.name ~ ' ' ~ invoice.createdAt|date_short~ ' ' ~ invoice.total|money(invoice.customer.currency),
'form': form,

View File

@@ -1,76 +1,33 @@
{% extends 'base.html.twig' %}
{% extends 'datatable.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/search.html.twig" as search %}
{% import "macros/datatables.html.twig" as tables %}
{% import "invoice/actions.html.twig" as actions %}
{% import "invoice/macros.html.twig" as macros %}
{% set columns = {
'date': {'class': 'alwaysVisible text-nowrap'},
'user': {'class': 'hidden-xs hidden-sm text-nowrap hidden', 'orderBy': false},
'customer': {'class': 'hidden-xs hidden-sm', 'orderBy': false},
'comment': {'class': 'hidden-xs hidden-sm', 'title': 'label.description'|trans},
} %}
{% for field in metaColumns %}
{% set columns = columns|merge({
('mf_' ~ field.name): {'title': field.label|trans, 'class': 'hidden-xs hidden-sm mf_' ~ field.name, 'orderBy': false}
}) %}
{% endfor %}
{% set columns = columns|merge({
'invoice_number': {'class': 'hidden-xs hidden-sm w-min', 'title': 'invoice.number'|trans, 'orderBy': false},
'due_date': {'class': 'hidden-xs w-min', 'title': 'invoice.due_days'|trans, 'orderBy': false},
'payment_date': {'class': 'hidden-xs hidden w-min', 'title': 'invoice.payment_date'|trans, 'orderBy': false},
'status': {'class': 'alwaysVisible w-min', 'orderBy': false},
'subtotal': {'class': 'hidden-xs text-right w-min hidden', 'title': 'invoice.subtotal'|trans, 'orderBy': false},
'tax': {'class': 'hidden-xs text-right w-min hidden', 'title': 'invoice.tax'|trans},
'total_rate': {'class': 'hidden-xs text-right w-min'},
'actions': {'class': 'actions alwaysVisible', 'orderBy': false},
}) %}
{% set tableName = 'invoices' %}
{% block page_title %}{{ 'invoices'|trans }}{% endblock %}
{% block page_actions %}{{ actions.invoice_listing('index', query) }}{% endblock %}
{% block page_search %}{{ search.searchModal(toolbarForm) }}{% endblock %}
{% block main_before %}
{{ tables.data_table_column_modal(tableName, columns) }}
{% endblock %}
{% block main %}
{% if entries is empty %}
{{ widgets.nothing_found() }}
{% else %}
{{ tables.datatable_header(tableName, columns, query, {}) }}
{% for entry in entries %}
<tr class="modal-ajax-form open-edit{% if entry.canceled %} warning text-muted{% endif %}" data-href="{{ path('admin_invoice_edit', {'id': entry.id}) }}">
<td class="{{ tables.data_table_column_class(tableName, columns, 'date') }}">{{ entry.createdAt|date_short }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'user') }}">{{ widgets.user_avatar(entry.user) }} {{ widgets.username(entry.user) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'customer') }}">{{ widgets.label_customer(entry.customer) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'comment') }}">{{ entry.comment }}</td>
{% for field in metaColumns %}
<td class="{{ tables.data_table_column_class(tableName, columns, 'mf_' ~ field.name) }}">
{{ tables.datatable_meta_column(entry, field) }}
</td>
{% endfor %}
<td class="{{ tables.data_table_column_class(tableName, columns, 'invoice_number') }}">{{ widgets.label(entry.invoiceNumber, 'default') }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'due_date') }}">{{ macros.invoice_due_date(entry) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'payment_date') }}">
{% if entry.paymentDate and entry.paid %}
{{ widgets.label(entry.paymentDate|date_short, 'primary') }}
{% endif %}
</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'status') }}">{{ macros.invoice_status(entry) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'subtotal') }}">{{ entry.subtotal|money(entry.currency) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'tax') }}">{{ entry.tax|money(entry.currency) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'total_rate') }}">{{ entry.total|money(entry.currency) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'actions') }}">{{ actions.invoice(entry, 'index') }}</td>
</tr>
{% block datatable_row %}
<tr class="modal-ajax-form open-edit{% if entry.canceled %} warning text-muted{% endif %}" data-href="{{ path('admin_invoice_edit', {'id': entry.id}) }}">
<td class="{{ tables.class(dataTable, 'avatar') }}">{{ widgets.user_avatar(entry.user) }}</td>
<td class="{{ tables.class(dataTable, 'date') }}">{{ entry.createdAt|date_short }}</td>
<td class="{{ tables.class(dataTable, 'user') }}">{{ widgets.label_user(entry.user) }}</td>
<td class="{{ tables.class(dataTable, 'customer') }}">{{ widgets.label_customer(entry.customer) }}</td>
<td class="{{ tables.class(dataTable, 'comment') }}">{{ entry.comment }}</td>
{% for field in metaColumns %}
<td class="{{ tables.class(dataTable, 'mf_' ~ field.name) }}">
{{ tables.datatable_meta_column(entry, field) }}
</td>
{% endfor %}
{{ tables.data_table_footer(entries, 'admin_invoice_list') }}
{% endif %}
<td class="{{ tables.class(dataTable, 'invoice_number') }}">{{ widgets.label(entry.invoiceNumber, 'default') }}</td>
<td class="{{ tables.class(dataTable, 'due_date') }}">{{ _self.invoice_due_date(entry) }}</td>
<td class="{{ tables.class(dataTable, 'payment_date') }}">
{% if entry.paymentDate and entry.paid %}
{{ widgets.label(entry.paymentDate|date_short, 'primary') }}
{% endif %}
</td>
<td class="{{ tables.class(dataTable, 'status') }}">{{ _self.invoice_status(entry) }}</td>
<td class="{{ tables.class(dataTable, 'subtotal') }}">{{ entry.subtotal|money(entry.currency) }}</td>
<td class="{{ tables.class(dataTable, 'tax') }}">{{ entry.tax|money(entry.currency) }}</td>
<td class="{{ tables.class(dataTable, 'total_rate') }}">{{ entry.total|money(entry.currency) }}</td>
<td class="{{ tables.class(dataTable, 'actions') }}">{{ actions.invoice(entry, 'index') }}</td>
</tr>
{% endblock %}
{% block javascripts %}
@@ -82,9 +39,33 @@
});
</script>
{% endif %}
<script type="text/javascript">
document.addEventListener('kimai.initialized', function() {
KimaiReloadPageWidget.create('kimai.invoiceUpdate');
});
</script>
{% endblock %}
{% macro invoice_status(invoice) %}
{% from "macros/widgets.html.twig" import label %}
{% set overdue = invoice.overdue %}
{% if invoice.new and overdue %}
{{ label('status.new'|trans, 'danger') }}
{% elseif invoice.new %}
{{ label('status.new'|trans, 'primary') }}
{% elseif invoice.pending and overdue %}
{{ label('status.pending'|trans, 'danger') }}
{% elseif invoice.pending %}
{{ label('status.pending'|trans, 'warning') }}
{% elseif invoice.paid %}
{{ label('status.paid'|trans, 'success') }}
{% elseif invoice.canceled %}
{{ label('status.canceled'|trans, 'gray') }}
{% endif %}
{% endmacro %}
{% macro invoice_due_date(invoice) %}
{% from "macros/widgets.html.twig" import label %}
{% if invoice.canceled %}
{{ label('status.canceled'|trans, 'gray') }}
{% elseif invoice.overdue and not invoice.paid %}
{{ label(invoice.dueDate|date_short, 'danger') }}
{% else %}
{{ label(invoice.dueDate|date_short, 'primary') }}
{% endif %}
{% endmacro %}

View File

@@ -1,29 +0,0 @@
{% macro invoice_status(invoice) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set overdue = invoice.overdue %}
{% if invoice.new and overdue %}
{{ widgets.label('status.new'|trans, 'danger') }}
{% elseif invoice.new %}
{{ widgets.label('status.new'|trans, 'primary') }}
{% elseif invoice.pending and overdue %}
{{ widgets.label('status.pending'|trans, 'danger') }}
{% elseif invoice.pending %}
{{ widgets.label('status.pending'|trans, 'warning') }}
{% elseif invoice.paid %}
{{ widgets.label('status.paid'|trans, 'success') }}
{% elseif invoice.canceled %}
{{ widgets.label('status.canceled'|trans, 'gray') }}
{% endif %}
{% endmacro %}
{% macro invoice_due_date(invoice) %}
{% import "macros/widgets.html.twig" as widgets %}
{% if invoice.canceled %}
{{ widgets.label('status.canceled'|trans, 'gray') }}
{% elseif invoice.overdue and not invoice.paid %}
{{ widgets.label(invoice.dueDate|date_short, 'danger') }}
{% else %}
{{ widgets.label(invoice.dueDate|date_short, 'primary') }}
{% endif %}
{% endmacro %}

View File

@@ -1,13 +1,14 @@
<!DOCTYPE html>
{% set fallback = app.request is not null ? app.request.locale : 'en' %}
{% set language = model.template.language|default(fallback) %}
{% set isDecimal = model.template.decimalDuration|default(false) %}
{% set currency = model.currency %}
{%- set fallback = app.request is not null ? app.request.locale : 'en' -%}
{%- set language = model.template.language|default(fallback) -%}
{%- set isDecimal = true -%}
{%- set currency = model.currency -%}
{%- set project = model.query.project -%}
<html lang="{{ language }}">
<head>
<meta charset="UTF-8">
<title>{% block title %}{{ model.invoiceNumber }}-{{ model.customer.company|default(model.customer.name)|u.snake }}{% endblock %}</title>
<style type="text/css">
<style>
{{ encore_entry_css_source('invoice-pdf')|raw }}
</style>
</head>
@@ -20,7 +21,7 @@
{{ model.template.title }}
</td>
<td class="date text-right">
{{ 'label.date'|trans }}: {{ model.invoiceDate|date_short }}
{{ 'date'|trans }}: {{ model.invoiceDate|date_short }}
</td>
</tr>
</table>
@@ -30,10 +31,10 @@
<table class="footer">
<tr>
<td>
<strong>{{ 'label.contact'|trans }}</strong>:
<strong>{{ 'contact'|trans }}</strong>:
{{ model.template.contact|nl2str(' &ndash; ') }}
<br>
<strong>{{ 'label.invoice_bank_account'|trans }}</strong>:
<strong>{{ 'invoice_bank_account'|trans }}</strong>:
{{ model.template.paymentDetails|nl2str(' &ndash; ') }}
</td>
<td align="right">
@@ -44,7 +45,6 @@
</htmlpagefooter>
<sethtmlpagefooter page="ALL" value="on" name="footer" show-this-page="1" />
mpdf-->
<div class="wrapper">
<table class="addresses">
<tr>
<td style="width:60%">
@@ -55,7 +55,7 @@ mpdf-->
{{ model.customer.address|nl2br }}
{% if model.customer.vatId is not empty %}
<br>
{{ 'label.vat_id'|trans }}: {{ model.customer.vatId }}
{{ 'vat_id'|trans }}: {{ model.customer.vatId }}
{% endif %}
</td>
<td>
@@ -66,7 +66,7 @@ mpdf-->
{{ model.template.address|trim|nl2br }}
{% if model.template.vatId is not empty %}
<br>
{{ 'label.vat_id'|trans }}:
{{ 'vat_id'|trans }}:
{{ model.template.vatId }}
{% endif %}
</td>
@@ -83,25 +83,29 @@ mpdf-->
{% if model.customer.number is not empty %}
<br>
{{ 'label.number'|trans }}:
{{ 'number'|trans }}:
{{ model.customer.number }}
{% endif %}
{% if model.query.project is not empty and model.query.project.orderNumber is not empty %}
{% if project is not null and project.orderNumber is not empty %}
<br>
{{ 'label.orderNumber'|trans }}:
{{ model.query.project.orderNumber }}
{{ 'orderNumber'|trans }}:
{{ project.orderNumber }}
{% endif %}
</p>
{% if model.customer.invoiceText is not empty%}
<p>{{ model.customer.invoiceText|md2html }}</p>
{% endif %}
<table class="items">
<thead>
<tr>
<th class="first"><strong>{{ 'label.date'|trans }}</strong></th>
<th><strong>{{ 'label.description'|trans }}</strong></th>
<th class="text-right"><strong>{{ 'label.unit_price'|trans }}</strong></th>
<th class="text-right"><strong>{{ 'label.amount'|trans }}</strong></th>
<th class="last text-right"><strong>{{ 'label.total_rate'|trans }}</strong></th>
<th class="first"><strong>{{ 'date'|trans }}</strong></th>
<th><strong>{{ 'description'|trans }}</strong></th>
<th class="text-right"><strong>{{ 'unit_price'|trans }}</strong></th>
<th class="text-right"><strong>{{ 'amount'|trans }}</strong></th>
<th class="last text-right"><strong>{{ 'total_rate'|trans }}</strong></th>
</tr>
</thead>
<tbody>
@@ -114,7 +118,7 @@ mpdf-->
{% else %}
{% set rate = entry.hourlyRate %}
{% endif %}
<tr{# class="{{ cycle(['odd', 'even'], id) }}"#}>
<tr>
<td nowrap class="first text-nowrap">{{ entry.begin|date_short }}</td>
<td contenteditable="true">
{% if entry.description is not empty %}
@@ -160,6 +164,5 @@ mpdf-->
{{ model.template.paymentTerms|md2html }}
</div>
{% endif %}
</div>
</body>
</html>

View File

@@ -1,13 +1,14 @@
{% extends 'invoice/layout.html.twig' %}
{% block invoice %}
{% set isDecimal = model.template.decimalDuration|default(false) %}
{% set isDecimal = true %}
{% set currency = model.currency %}
{% set project = model.query.project %}
<div class="row">
<div class="col-xs-12">
<h2 class="page-header">
<span contenteditable="true">{{ model.template.title }}</span>
<small class="pull-right">{{ 'label.date'|trans }}: {{ model.invoiceDate|date_short }}</small>
<small class="pull-right">{{ 'date'|trans }}: {{ model.invoiceDate|date_short }}</small>
</h2>
</div>
</div>
@@ -20,15 +21,15 @@
{{ model.customer.address|nl2br }}
{% if model.customer.vatId is not empty %}
<br>
{{ 'label.vat_id'|trans }}: {{ model.customer.vatId }}
{{ 'vat_id'|trans }}: {{ model.customer.vatId }}
{% endif %}
{% if model.customer.number is not empty %}
<br>
{{ 'label.number'|trans }}: {{ model.customer.number }}
{{ 'number'|trans }}: {{ model.customer.number }}
{% endif %}
{% if model.query.project is not empty and model.query.project.orderNumber is not empty %}
{% if project is not null and project.orderNumber is not empty %}
<br>
{{ 'label.orderNumber'|trans }}: {{ model.query.project.orderNumber }}
{{ 'orderNumber'|trans }}: {{ project.orderNumber }}
{% endif %}
</address>
</div>
@@ -40,7 +41,7 @@
{{ model.template.address|trim|nl2br }}
{% if model.template.vatId is not empty %}
<br>
{{ 'label.vat_id'|trans }}:
{{ 'vat_id'|trans }}:
{{ model.template.vatId }}
{% endif %}
</address>
@@ -66,11 +67,11 @@
<table class="table">
<thead>
<tr>
<th>{{ 'label.date'|trans }}</th>
<th>{{ 'label.description'|trans }}</th>
<th class="text-right">{{ 'label.unit_price'|trans }}</th>
<th class="text-right">{{ 'label.amount'|trans }}</th>
<th class="text-right">{{ 'label.total_rate'|trans }}</th>
<th>{{ 'date'|trans }}</th>
<th>{{ 'description'|trans }}</th>
<th class="text-end">{{ 'unit_price'|trans }}</th>
<th class="text-end">{{ 'amount'|trans }}</th>
<th class="text-end">{{ 'total_rate'|trans }}</th>
</tr>
</thead>
<tbody>
@@ -91,32 +92,32 @@
{% if entry.activity is not null %}{{ entry.activity.name }} / {% endif %}{{ entry.project.name }}
{% endif %}
</td>
<td nowrap class="text-nowrap text-right">{{ rate|money(currency) }}</td>
<td nowrap class="text-nowrap text-right">{{ duration }}</td>
<td nowrap class="text-nowrap text-right">{{ entry.rate|money(currency) }}</td>
<td nowrap class="text-nowrap text-end">{{ rate|money(currency) }}</td>
<td nowrap class="text-nowrap text-end">{{ duration }}</td>
<td nowrap class="text-nowrap text-end">{{ entry.rate|money(currency) }}</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
{% if model.calculator.tax > 0 or not model.isHideZeroTax() %}
<tr>
<td colspan="4" class="text-right">
<td colspan="4" class="text-end">
{{ 'invoice.subtotal'|trans }}
</td>
<td class="text-right">{{ model.calculator.subtotal|money(currency) }}</td>
<td class="text-end">{{ model.calculator.subtotal|money(currency) }}</td>
</tr>
<tr>
<td colspan="4" class="text-right">
<td colspan="4" class="text-end">
{{ 'invoice.tax'|trans }} ({{ model.calculator.vat }}%)
</td>
<td class="text-right">{{ model.calculator.tax|money(currency) }}</td>
<td class="text-end">{{ model.calculator.tax|money(currency) }}</td>
</tr>
{% endif %}
<tr>
<td colspan="4" class="text-right text-nowrap">
<td colspan="4" class="text-end text-nowrap">
<strong>{{ 'invoice.total'|trans }}</strong>
</td>
<td class="text-right">
<td class="text-end">
<strong>{{ model.calculator.total|money(currency) }}</strong>
</td>
</tr>
@@ -137,11 +138,11 @@
<footer class="footer">
<p>
<strong>{{ 'label.address'|trans }}</strong>: {{ model.template.company }} &ndash; {{ model.template.address|nl2str(' &ndash; ') }}
<strong>{{ 'address'|trans }}</strong>: {{ model.template.company }} &ndash; {{ model.template.address|nl2str(' &ndash; ') }}
<br>
<strong>{{ 'label.invoice_bank_account'|trans }}</strong>: {{ model.template.paymentDetails|nl2str(' &ndash; ') }}
<strong>{{ 'invoice_bank_account'|trans }}</strong>: {{ model.template.paymentDetails|nl2str(' &ndash; ') }}
<br>
<strong>{{ 'label.contact'|trans }}</strong>: {{ model.template.contact|nl2str(' &ndash; ') }}
<strong>{{ 'contact'|trans }}</strong>: {{ model.template.contact|nl2str(' &ndash; ') }}
</p>
</footer>
{% endblock %}

View File

@@ -1,6 +0,0 @@
{% set items = [] %}
{% for entry in entries %}
{% set items = items|merge([entry]) %}
{% endfor %}
{% set json = invoice|merge({'items': items}) %}
{{ json|json_encode|raw}}

View File

@@ -1,13 +1,14 @@
<!DOCTYPE html>
{% set fallback = app.request is not null ? app.request.locale : 'en' %}
{% set language = model.template.language|default(fallback) %}
{% set isDecimal = model.template.decimalDuration|default(false) %}
{% set currency = model.currency %}
{%- set fallback = app.request is not null ? app.request.locale : 'en' -%}
{%- set language = model.template.language|default(fallback) -%}
{%- set isDecimal = true -%}
{%- set currency = model.currency -%}
{%- set project = model.query.project -%}
<html lang="{{ language }}">
<head>
<meta charset="UTF-8">
<title>{% block title %}{{ model.invoiceNumber }}-{{ model.customer.company|default(model.customer.name)|u.snake }}{% endblock %}</title>
<style type="text/css">
<style>
{{ encore_entry_css_source('invoice-pdf')|raw }}
</style>
</head>
@@ -19,7 +20,7 @@
<td class="text-small">
{{ model.template.company }} &ndash; {{ model.template.address|nl2str(' &ndash; ') }}
{% if model.template.vatId is not empty %}
&ndash; {{ 'label.vat_id'|trans }}: {{ model.template.vatId }}
&ndash; {{ 'vat_id'|trans }}: {{ model.template.vatId }}
{% endif %}
</td>
<td class="text-small text-right">
@@ -33,18 +34,18 @@
<table class="footer text-small">
<tr>
<td style="width: 33%">
<strong>{{ 'label.address'|trans }}</strong>
<strong>{{ 'address'|trans }}</strong>
<br>
{{ model.template.company }}<br>
{{ model.template.address|nl2br }}
</td>
<td class="text-center">
<strong>{{ 'label.invoice_bank_account'|trans }}</strong>
<strong>{{ 'invoice_bank_account'|trans }}</strong>
<br>
{{ model.template.paymentDetails|nl2br }}
</td>
<td class="text-right" style="width: 33%">
<strong>{{ 'label.contact'|trans }}</strong>
<strong>{{ 'contact'|trans }}</strong>
<br>
{{ model.template.contact|nl2br }}
</td>
@@ -53,7 +54,6 @@
</htmlpagefooter>
<sethtmlpagefooter page="ALL" value="on" name="footer" show-this-page="1" />
mpdf-->
<div class="wrapper">
<table class="addresses">
<tr>
<td>
@@ -65,7 +65,7 @@ mpdf-->
{% set classRight = 'text-right text-nowrap padding-left' %}
<table style="width: 240px">
<tr>
<td class="{{ classLeft }}">{{ 'label.date'|trans }}</td>
<td class="{{ classLeft }}">{{ 'date'|trans }}</td>
<td class="{{ classRight }}">{{ model.invoiceDate|date_short }}</td>
</tr>
<tr>
@@ -82,19 +82,19 @@ mpdf-->
</tr>
{% if model.customer.number is not empty %}
<tr>
<td class="{{ classLeft }}">{{ 'label.number'|trans }}</td>
<td class="{{ classLeft }}">{{ 'number'|trans }}</td>
<td class="{{ classRight }}">{{ model.customer.number }}</td>
</tr>
{% endif %}
{% if model.query.project is not empty and model.query.project.orderNumber is not empty %}
{% if project is not null and project.orderNumber is not empty %}
<tr>
<td class="{{ classLeft }}">{{ 'label.orderNumber'|trans }}</td>
<td class="{{ classRight }}">{{ model.query.project.orderNumber }}</td>
<td class="{{ classLeft }}">{{ 'orderNumber'|trans }}</td>
<td class="{{ classRight }}">{{ project.orderNumber }}</td>
</tr>
{% endif %}
{% if model.customer.vatId is not empty %}
<tr>
<td class="{{ classLeft }}">{{ 'label.vat_id'|trans }}</td>
<td class="{{ classLeft }}">{{ 'vat_id'|trans }}</td>
<td class="{{ classRight }}">{{ model.customer.vatId }}</td>
</tr>
{% endif %}
@@ -105,13 +105,17 @@ mpdf-->
<h2 style="margin-top: 60px">{{ model.template.title }}</h2>
{% if model.customer.invoiceText is not empty%}
<p>{{ model.customer.invoiceText|md2html }}</p>
{% endif %}
<table class="items">
<thead>
<tr>
<th class="first">{{ 'label.description'|trans }}</th>
<th class="text-right">{{ 'label.unit_price'|trans }}</th>
<th class="text-right">{{ 'label.amount'|trans }}</th>
<th class="last text-right">{{ 'label.total_rate'|trans }}</th>
<th class="first">{{ 'description'|trans }}</th>
<th class="text-right">{{ 'unit_price'|trans }}</th>
<th class="text-right">{{ 'amount'|trans }}</th>
<th class="last text-right">{{ 'total_rate'|trans }}</th>
</tr>
</thead>
<tbody>
@@ -170,6 +174,5 @@ mpdf-->
{{ model.template.paymentTerms|md2html }}
</p>
{% endif %}
</div>
</body>
</html>

View File

@@ -1,15 +0,0 @@
{% for key, value in invoice %}
{{ key }}
{% if value is not empty %}
{{ value|multiline_indent(' ') }}
{% endif %}
{% endfor %}
{% for entry in entries %}
---
{% for key, value in entry %}
{{ key }}
{% if value is not empty %}
{{ value|multiline_indent(' ') }}
{% endif %}
{% endfor %}
{% endfor %}

View File

@@ -2,7 +2,9 @@
{% extends 'invoice/layout.html.twig' %}
{% block invoice %}
{% set isDecimal = model.template.decimalDuration|default(false) %}
{% set isDecimal = true %}
{% set project = model.query.project %}
{% set activity = model.query.activity %}
<div class="row">
<div class="col-xs-12">
<h2 class="page-header">
@@ -13,7 +15,7 @@
<div class="row">
<div class="col-xs-12">
<table class="table no-border table-condensed">
<table class="table no-border table-sm">
<tr>
<th>{{ 'invoice.from'|trans }}</th>
<td contenteditable="true">
@@ -25,7 +27,7 @@
</td>
</tr>
<tr>
<th>{{ 'label.date'|trans }}</th>
<th>{{ 'date'|trans }}</th>
<td contenteditable="true">
{% if model.query.begin|date('m') != model.query.end|date('m') or model.query.begin|date('Y') != model.query.end|date('Y') %}
{{ model.query.begin|date_short }} - {{ model.query.end|date_short }}
@@ -35,28 +37,28 @@
</td>
</tr>
<tr>
<th>{{ 'label.customer'|trans }}</th>
<th>{{ 'customer'|trans }}</th>
<td contenteditable="true">
{% if model.customer.number is not empty %}[{{ model.customer.number }}]{% endif %}
{{ model.customer.name }}{% if model.customer.contact is not empty %} / {{ model.customer.contact }}{% endif %}
</td>
</tr>
{% if model.query.project is not empty %}
{% if project is not null %}
<tr>
<th>{{ 'label.project'|trans }}</th>
<th>{{ 'project'|trans }}</th>
<td contenteditable="true">
{{ model.query.project.name }}
{% if model.query.project.orderNumber is not empty %}
({{ 'label.orderNumber'|trans }}: {{ model.query.project.orderNumber }})
{{ project.name }}
{% if project.orderNumber is not empty %}
({{ 'orderNumber'|trans }}: {{ project.orderNumber }})
{% endif %}
</td>
</tr>
{% endif %}
{% if model.query.activity is not empty %}
{% if activity is not null %}
<tr>
<th>{{ 'label.activity'|trans }}</th>
<th>{{ 'activity'|trans }}</th>
<td contenteditable="true">
{{ model.query.activity.name }}
{{ activity.name }}
</td>
</tr>
{% endif %}
@@ -69,12 +71,12 @@
<table class="table table-striped">
<thead>
<tr>
<th>{{ 'label.date'|trans }}</th>
<th>{{ 'date'|trans }}</th>
{% if model.query.user is empty %}
<th>{{ 'label.user'|trans }}</th>
<th>{{ 'user'|trans }}</th>
{% endif %}
<th>{{ 'label.activity'|trans }}</th>
<th class="text-right">{{ 'label.hours'|trans }}</th>
<th>{{ 'activity'|trans }}</th>
<th class="text-right">{{ 'hours'|trans }}</th>
</tr>
</thead>
<tbody>
@@ -112,7 +114,7 @@
<div class="row">
<div class="col-xs-12">
{% if model.template.paymentTerms is not empty %}
<p class="lead">{{ 'label.payment_terms'|trans }}</p>
<p class="lead">{{ 'payment_terms'|trans }}</p>
<p class="text-muted well well-sm no-shadow" contenteditable="true" style="margin-bottom: 100px">
{{ model.template.paymentTerms|trim|nl2br }}

View File

@@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<kimai version="{{ constant('App\\Constants::VERSION') }}">
{% for key, value in invoice %}
<{{ key }}{% if value is empty %}/>{% else %}>{{ value|escape }}</{{ key }}>{% endif %}
{% endfor %}
<items>
{%- for entry in entries %}
<item>
{% for key, value in entry %}
<{{ key }}{% if value is empty %}/>{% else %}>{{ value|escape }}</{{ key }}>{% endif %}
{% endfor %}
</item>
{%- endfor %}
</items>
</kimai>

View File

@@ -1,9 +1,7 @@
{% extends app.request.xmlHttpRequest ? 'form.html.twig' : 'base.html.twig' %}
{% block page_title %}{{ 'admin_invoice_template.title'|trans }}{% endblock %}
{% extends kimai_context.modalRequest ? 'form.html.twig' : 'base.html.twig' %}
{% block main %}
{% set formEditTemplate = app.request.xmlHttpRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig' %}
{% set formEditTemplate = kimai_context.modalRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig' %}
{% set formOptions = {
'title': template.name|default('create'|trans),
'form': form,
@@ -48,7 +46,7 @@
</div>
<div class="row">
<div class="col-md-6">
{{ form_row(form.renderer) }}
{{ form_row(form.renderer, {'help_html': true, 'help': '<a href="https://github.com/kimai/invoice-templates" target="_blank">' ~ ('download_invoice_renderer'|trans({}, 'invoice-renderer')) ~ '</a>'}) }}
</div>
<div class="col-md-6">
{{ form_row(form.language) }}
@@ -62,12 +60,7 @@
{{ form_row(form.numberGenerator) }}
</div>
</div>
<div class="row">
<div class="col-md-12">
{{ form_row(form.decimalDuration) }}
</div>
</div>
{{ form_widget(form) }}
{{ form_rest(form) }}
{% endblock %}
{% endembed %}
{% endblock %}

View File

@@ -1,56 +1,23 @@
{% extends 'base.html.twig' %}
{% extends 'datatable.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/datatables.html.twig" as tables %}
{% import "invoice/actions.html.twig" as actions %}
{% set columns = {
'name': {'class': 'alwaysVisible text-nowrap', 'orderBy': false},
'title': {'class': 'hidden-xs text-nowrap', 'orderBy': false},
'company': {'class': 'hidden-xs hidden-sm hidden', 'orderBy': false},
'vat_id': {'class': 'hidden-xs hidden-sm text-nowrap', 'orderBy': false},
'tax_rate': {'class': 'hidden-xs hidden-sm hidden-md text-nowrap', 'orderBy': false},
'due_days': {'class': 'hidden-xs hidden-sm hidden-md text-nowrap', 'orderBy': false},
'address': {'class': 'hidden', 'orderBy': false},
'contact': {'class': 'hidden', 'orderBy': false},
'calculator': {'title': 'label.invoice_calculator'|trans({}, 'invoice-calculator'), 'class': 'hidden', 'orderBy': false},
'renderer': {'title': 'label.invoice_renderer'|trans({}, 'invoice-renderer'), 'class': 'hidden', 'orderBy': false},
'language': {'class': 'text-nowrap', 'orderBy': false},
'actions': {'class': 'actions alwaysVisible', 'orderBy': false},
} %}
{% set tableName = 'invoice_template' %}
{% block page_title %}{{ 'admin_invoice_template.title'|trans }}{% endblock %}
{% block page_actions %}{{ actions.invoice_templates('index') }}{% endblock %}
{% block main_before %}
{{ tables.data_table_column_modal(tableName, columns) }}
{% endblock %}
{% block main %}
{% if entries.count == 0 %}
{{ widgets.nothing_found('kimai.invoiceTemplateUpdate') }}
{% endif %}
{{ tables.datatable_header(tableName, columns, null, {'reload': 'kimai.invoiceTemplateUpdate'}) }}
{% for entry in entries %}
<tr class="modal-ajax-form open-edit" data-href="{{ path('admin_invoice_template_edit', {'id' : entry.id}) }}">
<td class="{{ tables.data_table_column_class(tableName, columns, 'name') }}">{{ entry.name }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'title') }}">{{ entry.title }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'company') }}">{{ entry.company }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'vat_id') }}">{{ entry.vatId }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'tax_rate') }}">{{ entry.vat }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'due_days') }}">{{ entry.dueDays }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'address') }}">{{ entry.address|nl2br }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'contact') }}">{{ entry.contact|nl2br }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'calculator') }}">{{ entry.calculator|trans({}, 'invoice-calculator') }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'renderer') }}">{{ entry.renderer|trans({}, 'invoice-renderer') }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'language') }}">{% if entry.language is not empty %}{{ entry.language|language }}{% endif %}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'actions') }}">
{{- actions.invoice_template(entry, 'index') -}}
</td>
</tr>
{% endfor %}
{{ tables.data_table_footer(entries, 'admin_invoice_template') }}
{% block datatable_row %}
<tr class="modal-ajax-form open-edit" data-href="{{ path('admin_invoice_template_edit', {'id' : entry.id}) }}">
<td class="{{ tables.class(dataTable, 'name') }}">{{ entry.name }}</td>
<td class="{{ tables.class(dataTable, 'title') }}">{{ entry.title }}</td>
<td class="{{ tables.class(dataTable, 'company') }}">{{ entry.company }}</td>
<td class="{{ tables.class(dataTable, 'vat_id') }}">{{ entry.vatId }}</td>
<td class="{{ tables.class(dataTable, 'tax_rate') }}">{{ entry.vat }}</td>
<td class="{{ tables.class(dataTable, 'due_days') }}">{{ entry.dueDays }}</td>
<td class="{{ tables.class(dataTable, 'address') }}">{{ entry.address|nl2br }}</td>
<td class="{{ tables.class(dataTable, 'contact') }}">{{ entry.contact|nl2br }}</td>
<td class="{{ tables.class(dataTable, 'calculator') }}">{{ entry.calculator|trans({}, 'invoice-calculator') }}</td>
<td class="{{ tables.class(dataTable, 'renderer') }}">{{ entry.renderer|trans({}, 'invoice-renderer') }}</td>
<td class="{{ tables.class(dataTable, 'language') }}">{% if entry.language is not empty %}{{ entry.language|locale_name }}{% endif %}</td>
<td class="{{ tables.class(dataTable, 'actions') }}">
{{- actions.invoice_template(entry, 'index') -}}
</td>
</tr>
{% endblock %}