Upload invoice documents via UI (#1495)

This commit is contained in:
Kevin Papst
2020-02-27 23:19:19 +01:00
committed by GitHub
parent 34d2228d5d
commit bf11de82fc
16 changed files with 245 additions and 12 deletions

View File

@@ -26,12 +26,31 @@
{% set actions = actions|merge({'create': path('admin_invoice_template_create')}) %}
{% endif %}
{% if is_granted('upload_invoice_template') %}
{# File upload does not work in a modal right now #}
{% set actions = actions|merge({'upload': {'url': path('admin_invoice_document_upload')}}) %}
{% 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_upload(view) %}
{% import "macros/widgets.html.twig" as widgets %}
{% set actions = {} %}
{% if view == 'index' and is_granted('manage_invoice_template') %}
{% set actions = actions|merge({'back': path('admin_invoice_template')}) %}
{% endif %}
{% set actions = actions|merge({'help': {'url': 'invoices.html'|docu_link, 'target': '_blank'}}) %}
{% set event = trigger('actions.invoice_upload', {'actions': actions, 'view': 'index'}) %}
{{ widgets.page_actions(actions) }}
{% endmacro %}
{% macro invoice_template(template, view) %}
{% import "macros/widgets.html.twig" as widgets %}

View File

@@ -0,0 +1,49 @@
{% extends app.request.xmlHttpRequest ? 'form.html.twig' : 'base.html.twig' %}
{% import "invoice/actions.html.twig" as actions %}
{% block page_title %}{{ 'admin_invoice_template.title'|trans }}{% endblock %}
{% block page_actions %}{{ actions.invoice_upload('index') }}{% endblock %}
{% block main %}
{% if form is not null %}
{% form_theme form '@AdminLTE/layout/form-theme-horizontal.html.twig' %}
{% set formEditTemplate = app.request.xmlHttpRequest ? 'default/_form_modal.html.twig' : 'default/_form.html.twig' %}
{% set formOptions = {
'title': 'upload'|trans,
'form': form,
'back': path('admin_invoice_template')
} %}
{% embed formEditTemplate with formOptions %}
{% block form_body %}
{{ form_row(form.document) }}
{{ form_widget(form) }}
{% endblock %}
{% endembed %}
{% endif %}
{% if documents|length > 0 %}
{% embed '@AdminLTE/Widgets/box-widget.html.twig' with {'documents': documents} %}
{% import "project/actions.html.twig" as actions %}
{% import "macros/widgets.html.twig" as widgets %}
{% block box_title %}{{ 'label.invoice_renderer'|trans({}, 'invoice-renderer') }}{% endblock %}
{% block box_attributes %}
id="invoice_document_list"
{% endblock %}
{% block box_body_class %}no-padding{% endblock %}
{% block box_body %}
<table class="table table-hover dataTable">
<tbody>
{% for document in documents %}
<tr>
<td>{{ document.id }}</td>
<td>{{ document.lastChange|date }}</td>
<td>{{ document.filename|replace({(baseDirectory): ''}) }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}
{% endembed %}
{% endif %}
{% endblock %}