refactored invoice and export screens (#1046)

This commit is contained in:
Kevin Papst
2019-08-22 18:56:21 +02:00
committed by GitHub
parent 405ea0076b
commit 46e5650882
55 changed files with 930 additions and 906 deletions

View File

@@ -85,7 +85,7 @@
</a>
</li>
{% endif %}
{% if is_granted('view_export') %}
{% if is_granted('create_export') %}
<li class="visible-xs-inline-block">
<a href="{{ path('export') }}" class="ddt-large">
<i class="{{ 'export'|icon }} fa-2x"></i>

View File

@@ -1,3 +1,6 @@
{% if form_theme is defined %}
{% form_theme form form_theme %}
{% endif %}
<div class="box box-primary">
{{ form_start(form) }}
<div class="box-header with-border">

View File

@@ -0,0 +1,13 @@
{% macro export(view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set actions = {} %}
{% if view == 'preview' %}
{% set actions = {'off': {'id':'export-toggle-button'}} %}
{% endif %}
{% set actions = actions|merge({'help': {'url': 'export.html'|docu_link, 'target': '_blank'}}) %}
{% set event = trigger('actions.export', {'actions': actions, 'view': view}) %}
{{ widgets.page_actions(event.payload.actions) }}
{% endmacro %}

View File

@@ -2,7 +2,7 @@
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/toolbar.html.twig" as toolbar %}
{% import "macros/datatables.html.twig" as tables %}
{% import "macros/actions.html.twig" as actions %}
{% import "export/actions.html.twig" as actions %}
{% set columns = {
'date': 'alwaysVisible',
@@ -21,89 +21,96 @@
{% block page_title %}{{ 'export.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'export.subtitle'|trans }}{% endblock %}
{% block page_actions %}{{ actions.export('index') }}{% endblock %}
{% block main_before %}
{{ toolbar.toolbar(form, 'collapseExport', true) }}
{{ tables.data_table_column_modal(tableName, columns) }}
{% endblock %}
{% block main_after %}
<div class="clearfix"></div>
{% endblock %}
{% block page_actions %}{{ actions.export((preview_show ? 'preview' : 'index')) }}{% endblock %}
{% block main %}
{% if entries is empty %}
{{ widgets.callout('warning', 'error.no_entries_found') }}
{% else %}
{{ tables.data_table_header(tableName, columns) }}
{% for entry in entries %}
{% set currency = entry.project.customer.currency %}
{% 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, 'customer') }}">{{ widgets.label_customer(entry.project.customer) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'project') }}">{{ widgets.label_project(entry.project) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'activity') }}">{{ widgets.label_activity(entry.activity) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'description') }} timesheet-description">
{{ entry.description }}
</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'unit_price') }} text-nowrap">
{{ rate|money(currency) }}
</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'duration') }} text-nowrap">
{{ duration }}
</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'total_rate') }} text-nowrap">
{{ entry.rate|money(currency) }}
</td>
<td>
{% if is_granted('edit_export', entry) %}
{% if entry.exported %}
<button type="button" class="btn btn-default exportBtn active" data-toggle="button" aria-pressed="true" autocomplete="off"
data-exported-text="{{ 'entryState.exported'|trans }}" data-clean-text="{{ 'entryState.not_exported'|trans }}" data-timesheet="{{ entry.id }}">
{{ 'entryState.exported'|trans }}
</button>
{% else %}
<button type="button" class="btn btn-default exportBtn" data-toggle="button" aria-pressed="false" autocomplete="off"
data-exported-text="{{ 'entryState.exported'|trans }}" data-clean-text="{{ 'entryState.not_exported'|trans }}" data-timesheet="{{ entry.id }}">
{{ 'entryState.not_exported'|trans }}
</button>
{% endif %}
{% else %}
{% if entry.exported %}
{{ 'entryState.exported'|trans }}
{% else %}
{{ 'entryState.not_exported'|trans }}
{% endif %}
{% endif %}
</td>
</tr>
{% endfor %}
{{ tables.data_table_footer(entries) }}
{% if is_granted('create_export') %}
<div class="row no-print">
<div class="col-xs-12">
<div class="btn-group pull-right" id="export-buttons" role="group">
{% for button in renderer %}
<button type="button" id="export-{{ button.id }}-button" class="btn btn-success startExportBtn" data-type="{{ button.id }}">
<i class="{{ button.icon|icon }}"></i> {{ ('button.' ~ button.title)|trans }}
</button>
{% endfor %}
</div>
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
{% form_theme form '@AdminLTE/layout/form-theme-horizontal.html.twig' %}
{% block box_title %}{{ 'export.filter'|trans }}{% endblock %}
{% block box_before %}{{ form_start(form) }}{% endblock %}
{% block box_body %}
{{ form_row(form.daterange) }}
{{ form_row(form.customer) }}
{{ form_row(form.project) }}
{{ form_row(form.activity) }}
{{ form_row(form.users) }}
{{ form_row(form.tags) }}
{{ form_row(form.exported) }}
{{ form_row(form.state) }}
{{ form_row(form.markAsExported) }}
{% endblock %}
{% block box_footer%}
<div class="btn-group" id="export-buttons" role="group">
{% for button in renderer %}
<button type="button" id="export-{{ button.id }}-button" class="btn btn-success startExportBtn" data-type="{{ button.id }}">
<i class="{{ button.icon|icon }}"></i> {{ ('button.' ~ button.title)|trans }}
</button>
{% endfor %}
</div>
</div>
{{ form_widget(form.preview, {'attr': {'data-toggle': 'tooltip', 'title': 'limited_entries'|trans({'%max%': preview_max})}}) }}
{% endblock %}
{% block box_after %}{{ form_end(form) }}{% endblock %}
{% endembed %}
{% if preview_show %}
{% if entries is empty %}
{{ widgets.callout('warning', 'error.no_entries_found') }}
{% else %}
{{ tables.data_table_header(tableName, columns) }}
{% for entry in entries %}
{% set currency = entry.project.customer.currency %}
{% 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, 'customer') }}">{{ widgets.label_customer(entry.project.customer) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'project') }}">{{ widgets.label_project(entry.project) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'activity') }}">{{ widgets.label_activity(entry.activity) }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'description') }} timesheet-description">
{{ entry.description }}
</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'unit_price') }} text-nowrap">
{{ rate|money(currency) }}
</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'duration') }} text-nowrap">
{{ duration }}
</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'total_rate') }} text-nowrap">
{{ entry.rate|money(currency) }}
</td>
<td>
{% if is_granted('edit_export', entry) %}
{% if entry.exported %}
<button type="button" class="btn btn-default exportBtn active" data-toggle="button" aria-pressed="true" autocomplete="off"
data-exported-text="{{ 'entryState.exported'|trans }}" data-clean-text="{{ 'entryState.not_exported'|trans }}" data-timesheet="{{ entry.id }}">
{{ 'entryState.exported'|trans }}
</button>
{% else %}
<button type="button" class="btn btn-default exportBtn" data-toggle="button" aria-pressed="false" autocomplete="off"
data-exported-text="{{ 'entryState.exported'|trans }}" data-clean-text="{{ 'entryState.not_exported'|trans }}" data-timesheet="{{ entry.id }}">
{{ 'entryState.not_exported'|trans }}
</button>
{% endif %}
{% else %}
{% if entry.exported %}
{{ 'entryState.exported'|trans }}
{% else %}
{{ 'entryState.not_exported'|trans }}
{% endif %}
{% endif %}
</td>
</tr>
{% endfor %}
{{ tables.data_table_footer(entries) }}
{% endif %}
{% endif %}

View File

@@ -260,8 +260,10 @@
<tr>
<td class="column-date text-nowrap" {% if not columns.date %}style="display: none"{% endif %}>
{{ entry.begin|date_time }}
<br>
{{ entry.end|date_time }}
{% if entry.end %}
<br>
{{ entry.end|date_time }}
{% endif %}
</td>
<td class="column-username" {% if not columns.username %}style="display: none"{% endif %}>
{{ widgets.username(entry.user) }}

View File

@@ -144,8 +144,10 @@ mpdf-->
<tr class="{{ cycle(['odd', 'even'], loop.index0) }}">
<td>
{{ entry.begin|date_time }}
<br>
{{ entry.end|date_time }}
{% if entry.end %}
<br>
{{ entry.end|date_time }}
{% endif %}
</td>
<td>
{{ entry.project.customer.name }} - {{ entry.project.name }} - {{ entry.activity.name }}

View File

@@ -0,0 +1,47 @@
{% macro invoices(view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set actions = {} %}
{% if is_granted('manage_invoice_template') %}
{% set actions = actions|merge({'list': path('admin_invoice_template')}) %}
{% endif %}
{% set actions = actions|merge({'help': {'url': 'invoices.html'|docu_link, 'target': '_blank'}}) %}
{% set event = trigger('actions.invoices', {'actions': actions, 'view': view}) %}
{{ widgets.page_actions(event.payload.actions) }}
{% endmacro %}
{% macro invoice_templates(view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set actions = {} %}
{% if is_granted('view_invoice') %}
{% set actions = actions|merge({'back': path('invoice')}) %}
{% endif %}
{% if is_granted('manage_invoice_template') %}
{% set actions = actions|merge({'create': path('admin_invoice_template_create')}) %}
{% endif %}
{% set actions = actions|merge({'help': {'url': 'invoices.html'|docu_link, 'target': '_blank'}}) %}
{% set event = trigger('actions.invoice_templates', {'actions': actions, 'view': 'index'}) %}
{{ widgets.page_actions(actions) }}
{% endmacro %}
{% macro invoice_template(template, view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set actions = {} %}
{% if is_granted('manage_invoice_template') %}
{% set actions = actions|merge({'edit': {'url': path('admin_invoice_template_edit', {'id' : template.id}), 'class': 'modal-ajax-form'}}) %}
{% set actions = actions|merge({'copy': path('admin_invoice_template_copy', {'id' : template.id})}) %}
{% set actions = actions|merge({'trash': path('admin_invoice_template_delete', {'id' : template.id})}) %}
{% endif %}
{% set event = trigger('actions.invoice_template', {'actions': actions, 'view': view, 'template': template}) %}
{{ widgets.table_actions(event.payload.actions) }}
{% endmacro %}

View File

@@ -2,11 +2,11 @@
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/toolbar.html.twig" as toolbar %}
{% import "macros/datatables.html.twig" as tables %}
{% import "macros/actions.html.twig" as actions %}
{% import "invoice/actions.html.twig" as actions %}
{% set columns = {
'date': 'alwaysVisible',
'user': 'hidden-sm',
'user': 'hidden-xs hidden-sm',
'description': 'hidden-xs hidden-sm',
'unit_price': 'hidden-xs text-center',
'amount': 'text-center',
@@ -19,63 +19,66 @@
{% block page_subtitle %}{{ 'invoice.subtitle'|trans }}{% endblock %}
{% block page_actions %}{{ actions.invoices('index') }}{% 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 %}
{% if is_granted('create_invoice') %}
{% embed '@AdminLTE/Widgets/box-widget.html.twig' %}
{% 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_row(form.daterange) }}
{{ form_row(form.customer) }}
{{ form_row(form.project) }}
{{ form_row(form.activity) }}
{{ form_row(form.users) }}
{{ form_row(form.tags) }}
{{ form_row(form.exported) }}
{{ form_row(form.template) }}
{{ form_row(form.markAsExported) }}
{% endblock %}
{% block box_footer%}
{{ form_widget(form.create, {'attr': {'class': 'btn btn-success'}}) }}
{{ form_widget(form.preview, {'attr': {'data-toggle': 'tooltip', 'title': 'limited_entries'|trans({'%max%': preview_max})}}) }}
{% endblock %}
{% block box_after %}{{ form_end(form) }}{% endblock %}
{% endembed %}
{% else %}
{{ widgets.callout('danger', 'http_error_403.suggestion'|trans({}, 'exceptions')) }}
{% 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 %}{# FIXME fixed rates #}
{% 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|escape|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">
<a href="{{ path('invoice_print') }}" class="btn btn-success pull-right toolbar-action" data-method="POST">
<i class="{{ 'print'|icon }}"></i> {{ 'button.print'|trans }}
</a>
</div>
</div>
{% if preview_show %}
{% if model.calculator is empty or model.calculator.entries is empty %}
{{ widgets.callout('warning', 'error.no_entries_found') }}
{% else %}
{% set entries = model.calculator.entries %}
{{ 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 %}{# FIXME fixed rates #}
{% 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|escape|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) }}
{% endif %}
{% endif %}

View File

@@ -1,7 +1,7 @@
{% extends 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/datatables.html.twig" as tables %}
{% import "macros/actions.html.twig" as actions %}
{% import "invoice/actions.html.twig" as actions %}
{% block page_title %}{{ 'admin_invoice_template.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'admin_invoice_template.subtitle'|trans }}{% endblock %}
@@ -25,28 +25,16 @@
{{ tables.data_table_header(tableName, columns) }}
{% for entry in entries %}
<tr{% if is_granted('edit', entry) %} class="modal-ajax-form open-edit" data-href="{{ path('admin_invoice_template_edit', {'id' : entry.id, 'page': page}) }}"{% endif %}>
<tr class="modal-ajax-form open-edit" data-href="{{ path('admin_invoice_template_edit', {'id' : entry.id}) }}">
<td>{{ 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, 'due_days') }}">{{ entry.dueDays }}</td>
<td class="{{ tables.data_table_column_class(tableName, columns, 'vat') }}">{{ entry.vat }}</td>
<td class="actions">
{# TODO move me to actions macro #}
{% set actions = {} %}
{% if is_granted('edit', entry) %}
{% set actions = {'edit': {'url': path('admin_invoice_template_edit', {'id' : entry.id, 'page': page}), 'class': 'modal-ajax-form'}} %}
{% endif %}
{% if is_granted('create_invoice_template') %}
{% set actions = actions|merge({'copy': path('admin_invoice_template_copy', {'id' : entry.id, 'page': page})}) %}
{% endif %}
{% if is_granted('delete', entry) %}
{% set actions = actions|merge({'trash': path('admin_invoice_template_delete', {'id' : entry.id, 'page': page})}) %}
{% endif %}
{% set event = trigger('actions.invoice_templates', {'actions': actions, 'view': 'index', 'template': entry}) %}
{{ widgets.table_actions(actions) }}
{{- actions.invoice_template(entry, 'index') -}}
</td>
</tr>
{% endfor %}
{{ tables.data_table_footer(entries, 'admin_invoice_template_paginated') }}
{{ tables.data_table_footer(entries, 'admin_invoice_template') }}
{% endblock %}

View File

@@ -439,51 +439,6 @@
{{ widgets.page_actions(event.payload.actions) }}
{% endmacro %}
{% macro export(view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set actions = {'filter': '#collapseExport', 'visibility': '#modal_export', 'off': {'id':'export-toggle-button'}} %}
{% set actions = actions|merge({'help': {'url': 'export.html'|docu_link, 'target': '_blank'}}) %}
{% set event = trigger('actions.export', {'actions': actions, 'view': view}) %}
{{ widgets.page_actions(event.payload.actions) }}
{% endmacro %}
{% macro invoices(view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% 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 %}
{% set actions = actions|merge({'help': {'url': 'invoices.html'|docu_link, 'target': '_blank'}}) %}
{% set event = trigger('actions.invoices', {'actions': actions, 'view': view}) %}
{{ widgets.page_actions(event.payload.actions) }}
{% endmacro %}
{% macro invoice_templates(view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set actions = {} %}
{% if is_granted('view_invoice') %}
{% set actions = actions|merge({'back': path('invoice')}) %}
{% endif %}
{% if is_granted('create_invoice_template') %}
{% set actions = actions|merge({'create': path('admin_invoice_template_create')}) %}
{% endif %}
{% set actions = actions|merge({'help': {'url': 'invoices.html'|docu_link, 'target': '_blank'}}) %}
{% set event = trigger('actions.invoice_templates', {'actions': actions, 'view': 'index'}) %}
{{ widgets.page_actions(actions) }}
{% endmacro %}
{% macro teams(view) %}
{% import "macros/widgets.html.twig" as widgets %}