{% 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 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-center w-min', 'orderBy': false}, 'amount': {'class': 'text-center w-min', 'orderBy': false}, 'duration': {'class': 'hidden-xs text-center w-min', 'orderBy': false}, 'total_rate': {'class': 'text-right alwaysVisible w-min', 'orderBy': false}, } %} {% set tableName = 'invoice' %} {% block page_title %}{{ 'invoice.title'|trans }}{% endblock %} {% block page_actions %}{{ actions.invoices('index') }}{% endblock %} {% block main_before %} {{ tables.data_table_column_modal(tableName, columns) }} {% 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) }} {% endif %} {{ form_row(form.daterange) }} {{ form_row(form.customers) }} {{ form_row(form.projects) }} {% if form.activities is defined %} {{ form_row(form.activities) }} {% endif %} {% if form.tags is defined %} {{ form_row(form.tags) }} {% endif %} {% if form.users is defined %} {{ form_row(form.users) }} {% endif %} {% if form.exported is defined %} {{ form_row(form.exported) }} {% endif %} {{ form_row(form.template) }} {{ form_row(form.markAsExported) }} {% 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 %} {% if searched %} {% set showEmpty = true %} {% for model in models %} {% if showEmpty %} {% set showEmpty = model.calculator is empty or model.calculator.entries is empty %} {% endif %} {% endfor %} {% if showEmpty %} {{ widgets.nothing_found() }} {% endif %} {% endif %} {% if models|length > 0 %} {% embed '@AdminLTE/Widgets/box-widget.html.twig' %} {% import "macros/widgets.html.twig" as widgets %} {% import '@AdminLTE/Macros/buttons.html.twig' as button %} {% block box_title %} {{ 'button.preview'|trans }}: {{ 'invoice.title'|trans }} {% endblock %} {% block box_body_class %}no-padding{% endblock %} {% block box_footer %} {{ 'action.save_all'|trans }} {% endblock %} {% block box_body %} {% for model in models %} {% set isDecimal = model.template.decimalDuration|default(false) %} {% set currency = model.currency %} {% endfor %}
{{ 'label.customer'|trans }}
{{ widgets.label_customer(model.customer) }} {{ widgets.action_button('show', {'url': '#invoice_preview_details_' ~ model.customer.id, 'title': 'timesheet.all'|trans, 'class': 'btn btn-sm hidden-xs hidden-sm'}, 'link') }} {{ widgets.action_button('print', {'url': '#', 'onclick': 'return singleInvoice(this)', 'title': 'button.preview'|trans, 'target': '_blank', 'class': 'btn btn-sm', 'attr': {'data-href': path('invoice_preview', {'customer': model.customer.id, 'template': model.template.id})}}) }} {{ widgets.action_button('save', {'url': '#', 'onclick': 'return singleInvoice(this)', 'title': 'action.save'|trans, 'class': 'btn btn-sm', 'attr': {'data-href': path('invoice_create', {'customer': model.customer.id, 'template': model.template.id})}}, 'success') }}
{% 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 %} {{ widgets.label_customer(customer) }} {{ 'label.duration'|trans }}: {{ model.calculator.timeWorked|duration() }}, {{ 'label.total_rate'|trans }}: {{ model.calculator.total|money(currency) }} {% 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 %} {{ entry.begin|date_short }} {{ widgets.label_project(entry.project) }} {% if entry.activity is not null %}
{{ widgets.label_activity(entry.activity) }} {% endif %} {% if entry.description is not empty %} {{ entry.description|desc2html }} {% endif %} {{ widgets.label_user(entry.user) }} {{ rate|money(currency) }} {{ amount }} {{ duration }} {{ entry.rate|money(currency) }} {% endfor %} {% if limit_preview and itemsAmount > 100 %} » {{ 'preview.skipped_rows'|trans({'%rows%': (itemsAmount - 100)}) }} {% endif %} {{ model.calculator.timeWorked|duration(isDecimal) }} {{ model.calculator.total|money(currency) }} {{ tables.data_table_footer(entries) }} {% endblock %} {% endembed %} {% endif %} {% endfor %} {% endif %} {% endblock %} {% block javascripts %} {{ parent() }} {% set formId = form.vars.attr.id %} {% set formSelector = 'form#' ~ formId %} {% endblock %}