107 lines
4.3 KiB
Twig
107 lines
4.3 KiB
Twig
{% extends 'base.html.twig' %}
|
|
{% import "macros/widgets.html.twig" as widgets %}
|
|
{% import "macros/toolbar.html.twig" as toolbar %}
|
|
{% import "macros/datatables.html.twig" as tables %}
|
|
|
|
{% set columns = {
|
|
'date': 'alwaysVisible',
|
|
'user': 'hidden-sm',
|
|
'description': 'hidden-xs hidden-sm',
|
|
'unit_price': 'hidden-xs text-center',
|
|
'amount': 'text-center',
|
|
'total_rate': 'text-right alwaysVisible',
|
|
} %}
|
|
|
|
{% set tableName = 'invoice' %}
|
|
|
|
{% block page_title %}{{ 'invoice.title'|trans }}{% endblock %}
|
|
{% block page_subtitle %}{{ 'invoice.subtitle'|trans }}{% endblock %}
|
|
{% block page_actions %}
|
|
{% set actions = {'filter': '#collapseInvoice', 'visibility': '#modal_invoice'} %}
|
|
{% if is_granted('create_invoice_template') %}
|
|
{% set actions = actions|merge({'create': path('admin_invoice_template_create')}) %}
|
|
{% endif %}
|
|
{% if is_granted('view_invoice_template') %}
|
|
{% set actions = actions|merge({'list': path('admin_invoice_template')}) %}
|
|
{% endif %}
|
|
{{ widgets.page_actions(actions) }}
|
|
{% endblock %}
|
|
|
|
{% block main_before %}
|
|
{{ toolbar.toolbar(form, 'collapseInvoice', true) }}
|
|
{{ tables.data_table_column_modal(tableName, columns) }}
|
|
{% endblock %}
|
|
|
|
{% block main_after %}
|
|
<div class="clearfix"></div>
|
|
{% endblock %}
|
|
|
|
{% block main %}
|
|
|
|
{% set entries = {} %}
|
|
{% if model.calculator is not empty and model.calculator.entries is not empty %}
|
|
{% set entries = model.calculator.entries %}
|
|
{% endif %}
|
|
|
|
{% if entries is empty %}
|
|
{{ widgets.callout('warning', 'error.no_entries_found') }}
|
|
{% else %}
|
|
{{ widgets.callout('success', 'invoice.preview') }}
|
|
|
|
{{ tables.data_table_header(tableName, columns) }}
|
|
{% for entry in entries %}
|
|
{% set duration = entry.duration|duration() %}
|
|
{% if entry.fixedRate is not null %}
|
|
{% set rate = entry.fixedRate %}
|
|
{% set duration = 1 %}
|
|
{% elseif entry.hourlyRate is not null %}
|
|
{% set rate = entry.hourlyRate %}
|
|
{% else %}
|
|
{% set rate = entry.user.preferenceValue('hourly_rate') %}
|
|
{% endif %}
|
|
<tr>
|
|
<td class="text-nowrap">{{ entry.begin|date_short }}</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, 'description') }} timesheet-description">
|
|
{% if entry.description is not empty %}
|
|
{{ entry.description|desc2html }}
|
|
{% else %}
|
|
{{ entry.activity.name }} / {{ entry.project.name }}
|
|
{% endif %}
|
|
</td>
|
|
<td class="{{ tables.data_table_column_class(tableName, columns, 'unit_price') }} text-center">{{ rate|money(model.calculator.currency) }}</td>
|
|
<td class="{{ tables.data_table_column_class(tableName, columns, 'amount') }} text-center text-nowrap">{{ duration }}</td>
|
|
<td class="text-right text-nowrap">{{ entry.rate|money(model.calculator.currency) }}</td>
|
|
</tr>
|
|
{% endfor %}
|
|
{{ tables.data_table_footer(entries) }}
|
|
|
|
{% if is_granted('create_invoice') %}
|
|
<div class="row no-print">
|
|
<div class="col-xs-12">
|
|
<button type="button" id="print-invoice-button" class="btn btn-success pull-right">
|
|
<i class="{{ 'print'|icon }}"></i> {{ 'button.print'|trans }}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
{% endif %}
|
|
|
|
{% endblock %}
|
|
|
|
{% block javascripts %}
|
|
{{ parent() }}
|
|
{% if is_granted('create_invoice') %}
|
|
<script type="text/javascript">
|
|
$(document).ready(function () {
|
|
$("body").on('click', '#print-invoice-button', function() {
|
|
var prevAction = $( "#invoice-print-form" ).attr('action');
|
|
$( "#invoice-print-form" ).attr('target', '_blank').attr('action', '{{ path('invoice_print') }}');
|
|
$( "#invoice-print-form" ).submit();
|
|
$( "#invoice-print-form" ).removeAttr('target').attr('action', prevAction);
|
|
});
|
|
});
|
|
</script>
|
|
{% endif %}
|
|
{% endblock %}
|