added basic invoice rendering #97 #93 (#99)

This commit is contained in:
Kevin Papst
2018-01-21 22:50:46 +01:00
committed by GitHub
parent 9a161b8fd9
commit 4cbc5391c0
73 changed files with 2986 additions and 918 deletions

View File

@@ -11,11 +11,9 @@
{{ widgets.callout('warning', 'error.no_entries_found') }}
{% endif %}
{# Available fields: vat; contact; address; country; phone; fax; mobile; mail; homepage; timezone; #}
{{ tables.data_table_header({
'label.id': 'hidden-xs',
'label.name': '',
'label.customer_number': 'hidden-xs',
'label.project': '',
'label.comment': 'hidden-xs',
'label.country': 'hidden-xs',
@@ -26,8 +24,8 @@
{% for entry in entries %}
<tr>
<td class="hidden-xs">{{ entry.id }}</td>
<td>{{ entry.name }} {% if entry.company is not empty %}({{ entry.company }}){% endif %}</td>
<td class="hidden-xs">{{ entry.number }}</td>
<td>
{% for project in entry.projects %}
<a href="{{ path('admin_project_edit', {'id' : project.id}) }}">{{ widgets.label_project(project) }}</a>

View File

@@ -1,5 +1,15 @@
{% extends '@AvanzuAdminTheme/layout/default-layout.html.twig' %}
{% block avanzu_page_content_before %}
<div class="pad margin no-print">
{% block main_before %}{% endblock %}
</div>
{% endblock %}
{% block avanzu_page_content_after %}
{% block main_after %}{% endblock %}
{% endblock %}
{% block avanzu_page_content %}
{{ include('default/_flash_messages.html.twig') }}
{% block main %}{% endblock %}
@@ -31,16 +41,17 @@
{% block avanzu_head %}
<link rel="stylesheet" href="{{ asset('css/kimai.css') }}">
{#<link rel="stylesheet" href="{{ asset('theme/plugins/datepicker/datepicker3.css') }}">#}
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
{% endblock %}
{% block avanzu_footer %}
{% block footer %}
<footer class="main-footer">
<footer class="main-footer no-print">
<div class="pull-right hidden-xs">
<b>Version</b> 2.0
<b>Version</b> 2.0 dev
</div>
<strong>Copyright &copy; {{ 'now'|date('Y') }} - <a href="http://www.kevinpapst.de">Kevin Papst</a></strong>.
Made with ♥ by <a href="http://www.kevinpapst.de">Kevin Papst</a>.
{{ 'footer.license'|trans }}
</footer>
<!-- Page rendered on {{ 'now'|localizeddate('long', 'long', null, 'UTC') }} -->
@@ -74,6 +85,8 @@
{% block avanzu_javascripts %}
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<script src="{{ asset('theme/bootstrap/js/bootstrap.min.js') }}"></script>
{#<script src="{{ asset('theme/plugins/daterangepicker/moment.min.js') }}"></script>
<script src="{{ asset('theme/plugins/datepicker/bootstrap-datepicker.js') }}"></script>#}
<script src="{{ asset('js/kimai.js') }}"></script>
<script src="{{ asset('theme/plugins/slimScroll/jquery.slimscroll.min.js') }}"></script>
<script src="{{ asset('js/Chart.min.js') }}"></script>

View File

@@ -1,19 +0,0 @@
{#
Each field type is rendered by a template fragment, which is determined
by the name of your form type class (DateTimePickerType -> date_time_picker)
and the suffix "_widget". This can be controlled by overriding getBlockPrefix()
in DateTimePickerType.
See http://symfony.com/doc/current/cookbook/form/create_custom_field_type.html#creating-a-template-for-the-field
#}
{% block date_time_picker_widget %}
{% spaceless %}
<div class="input-group date" data-toggle="datetimepicker">
{{ block('datetime_widget') }}
<span class="input-group-addon">
<span class="fa fa-calendar"></span>
</span>
</div>
{% endspaceless %}
{% endblock %}

View File

@@ -0,0 +1,26 @@
{% extends "@AvanzuAdminTheme/layout/form-theme.html.twig" %}
{% block date_widget %}
{% if widget == 'single_text' %}
{% if attr.class is defined %}
{% set class = attr.class ~ ' timepicker' %}
{% else %}
{% set class = ' timepicker' %}
{% endif %}
{% set class = class ~ ' datepicker' %}
{% set attr = attr|merge({'class' : class, 'data-datepickerenable':'on'}) %}
{{ block('form_widget_simple') }}
{% else %}
{% set date_pattern = '<div class="row">' ~ date_pattern ~ '</div>'|raw %}
{{ date_pattern|replace({
'{{ year }}' : '<div class="col-xs-4">{{ year }}</div>',
'{{ month }}' : '<div class="col-xs-4">{{ month }}</div>',
'{{ day }}' : '<div class="col-xs-4">{{ day }}</div>',
})|raw|replace({
'{{ year }}': form_widget(form.year),
'{{ month }}': form_widget(form.month),
'{{ day }}': form_widget(form.day),
})|raw }}
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,27 @@
{% extends 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/toolbar.html.twig" as macro %}
{% block page_title %}{{ 'invoice.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'invoice.subtitle'|trans }}{% endblock %}
{% block javascript_imports %}<script src="{{ asset('js/toolbar.js') }}"></script>{% endblock %}
{% block avanzu_page_content_class %}invoice{% endblock %}
{% block main_before %}
{{ macro.toolbar(form, {'plus-square': path('admin_invoice_template_create'), 'list': path('admin_invoice_template')}) }}
{% endblock %}
{% block main_after %}
<div class="clearfix"></div>
{% endblock %}
{% block main %}
{% if model.entries is empty or action is empty %}
{{ widgets.callout('warning', 'invoice.select_filter') }}
{% else %}
{{ render(controller(action, {'model': model})) }}
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,111 @@
<div class="row">
<div class="col-xs-12">
<h2 class="page-header">
<i class="fa fa-globe"></i> <span contenteditable="true">{{ model.template.title }}</span>
<small class="pull-right">{{ 'label.date'|trans }}: {{ model.invoiceDate|date(kimai_context.date_1) }}</small>
</h2>
</div>
</div>
<div class="row invoice-info">
<div class="col-sm-4 invoice-col">
{{ 'invoice.from'|trans }}
<address contenteditable="true">
<strong>{{ model.template.company }}</strong><br>
{{ model.template.address|trim|nl2br }}
</address>
</div>
<div class="col-sm-4 invoice-col">
{% set customerPhone = model.customer.phone|default(model.customer.mobile) %}
{{ 'invoice.to'|trans }}
<address contenteditable="true">
<strong>{{ model.customer.company|default(model.customer.name) }}</strong><br>
{{ model.customer.address|nl2br }}
{% if model.customer.phone is not empty %}
<br>
{{ 'label.phone'|trans }}: {{ model.customer.phone }}
{% endif %}
{% if model.customer.mail is not empty %}
<br>
{{ 'label.email'|trans }}: {{ model.customer.mail }}
{% endif %}
</address>
</div>
<div class="col-sm-4 invoice-col">
<p contenteditable="true">
<b>{{ 'invoice.number'|trans }} {{ model.numberGenerator.invoiceNumber }}</b>
</p>
<p contenteditable="true">
<b>{{ 'invoice.due_days'|trans }}:</b> {{ model.dueDate|date(kimai_context.date_1) }}<br>
<b>{{ 'label.customer_number'|trans }}:</b> {{ model.customer.number }}<br>
</p>
</div>
</div>
<div class="row">
<div class="col-xs-12 table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>{{ 'label.date'|trans }}</th>
<th>{{ 'label.activity'|trans }}</th>
<th>{{ 'label.hours'|trans }}</th>
<th>{{ 'label.rate'|trans }}</th>
</tr>
</thead>
<tbody>
{% for entry in model.entries %}
<tr>
<td>{{ entry.begin|date(kimai_context.date_1) }}</td>
<td>{{ entry.activity.name }} / {{ entry.activity.project.name }}</td>
<td>{{ entry.duration|duration }}</td>
<td>{{ entry.rate|money(model.calculator.currency) }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-xs-6">
{% if model.template.paymentTerms is not empty %}
<p class="lead">{{ 'label.payment_terms'|trans }}</p>
<p class="text-muted well well-sm no-shadow" contenteditable="true">
{{ model.template.paymentTerms|trim|nl2br }}
</p>
{% endif %}
</div>
<div class="col-xs-6">
<p class="lead" contenteditable="true">{{ 'invoice.due_days'|trans }} {{ model.dueDate|date(kimai_context.date_1) }}</p>
<div class="table-responsive">
<table class="table">
<tbody>
<tr>
<th style="width:50%">{{ 'invoice.subtotal'|trans }}</th>
<td>{{ model.calculator.subtotal|money(model.calculator.currency) }}</td>
</tr>
<tr>
<th>{{ 'invoice.tax'|trans }} ({{ model.calculator.vat }}%)</th>
<td>{{ model.calculator.tax|money(model.calculator.currency) }}</td>
</tr>
<tr>
<th>{{ 'invoice.total'|trans }}</th>
<td>{{ model.calculator.total|money(model.calculator.currency) }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="row no-print">
<div class="col-xs-12">
<button type="button" class="btn btn-success pull-right" onclick="window.print();return false;" style="margin-right: 5px;">
<i class="fa fa-print"></i> {{ 'button.print'|trans }}
</button>
</div>
</div>

View File

@@ -0,0 +1,12 @@
{% extends 'base.html.twig' %}
{% block page_title %}{{ 'admin_invoice_template.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'admin_invoice_template.subtitle'|trans }}{% endblock %}
{% block main %}
{{ include('default/_form.html.twig', {
'title': template.name|default('create'|trans),
'form': form,
'back': path('admin_invoice_template')
}) }}
{% endblock %}

View File

@@ -0,0 +1,37 @@
{% extends 'base.html.twig' %}
{% import "macros/widgets.html.twig" as widgets %}
{% import "macros/datatables.html.twig" as tables %}
{% block page_title %}{{ 'admin_invoice_template.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'admin_invoice_template.subtitle'|trans }}{% endblock %}
{% block main %}
{% if entries.count == 0 %}
{{ widgets.callout('warning', 'error.no_entries_found') }}
{% endif %}
{{ tables.data_table_header({
'label.name': '',
'label.title': '',
'label.due_days': 'hidden-xs',
'label.vat': 'hidden-xs',
'label.invoice_renderer': 'hidden-xs',
'label.actions': '',
}) }}
{% for entry in entries %}
<tr>
<td>{{ entry.name }}</td>
<td>{{ entry.title }}</td>
<td class="hidden-xs hidden-sm">{{ entry.dueDays }}</td>
<td class="hidden-xs hidden-sm">{{ entry.vat }}</td>
<td class="hidden-xs hidden-sm">{{ "invoice_renderer.#{entry.renderer}"|trans }}</td>
<td>
{% set actionButtons = {'edit': path('admin_invoice_template_edit', {'id' : entry.id, 'page': page})} %}
{{ widgets.button_group(actionButtons) }}
</td>
</tr>
{% endfor %}
{{ tables.data_table_footer(entries, 'admin_invoice_template_paginated') }}
{% endblock %}

View File

@@ -2,33 +2,8 @@
{% macro data_table_header(entries, form, tools, toolsRight) %}
<div class="box data_table">
{% if form or tools or toolsRight %}
<div class="box-header with-border">
{% if tools %}
<div class="btn-group tools-left">
{% for icon,url in tools %}
<a class="btn btn-default" href="{{ url }}"><i class="fa fa-{{ icon }}"></i></a>
{% endfor %}
</div>
{% endif %}
{% if form %}
<div class="box-title toolbar">
{{ form_start(form) }}
{{ form_widget(form) }}
{{ form_end(form) }}
</div>
{% endif %}
{% if toolsRight %}
<div class="box-tools">
<div class="btn-group">
{% for icon,url in tools %}
<a class="btn btn-default" href="{{ url }}"><i class="fa fa-{{ icon }}"></i></a>
{% endfor %}
</div>
</div>
{% endif %}
</div>
{% import "macros/toolbar.html.twig" as macro %}
{{ macro.toolbar(form, tools, toolsRight) }}
{% endif %}
<div class="box-body no-padding">
<div class="dataTables_wrapper form-inline dt-bootstrap">
@@ -72,7 +47,7 @@
</div>
</div>
<div class="navigation text-center">
<div class="navigation text-center no-print">
{{ pagerfanta(entries, 'twitter_bootstrap3_translated', { routeName: route }) }}
</div>
{% endmacro %}

View File

@@ -0,0 +1,31 @@
{% macro toolbar(form, tools, toolsRight) %}
<div class="box-header">
{% if tools %}
<div class="btn-group tools-left no-print">
{% for icon,url in tools %}
<a class="btn btn-default" href="{{ url }}"><i class="fa fa-{{ icon }}"></i></a>
{% endfor %}
</div>
{% endif %}
{% if form %}
<div class="box-title toolbar no-print">
{% form_theme form 'form/toolbar-theme.html.twig' %}
{{ form_start(form) }}
{{ form_widget(form) }}
{{ form_end(form) }}
</div>
{% endif %}
{% if toolsRight %}
<div class="box-tools">
<div class="btn-group">
{% for icon,url in tools %}
<a class="btn btn-default" href="{{ url }}"><i class="fa fa-{{ icon }}"></i></a>
{% endfor %}
</div>
</div>
{% endif %}
</div>
{% endmacro %}

View File

@@ -83,9 +83,9 @@
</div>
{% endmacro %}
{% macro callout(type, description, title) %}
{% macro callout(type, description, title, icon) %}
<div class="callout callout-{{ type|default('danger') }} lead">
{% if title %}<h4>{{ title|trans }}</h4>{% endif %}
{% if title %}<h4>{% if icon %}<i class="fa fa-{{ icon }}">{% endif %}</i> {{ title|trans }}</h4>{% endif %}
<p>{{ description|trans }}</p>
</div>
{% endmacro %}