Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
144 lines (125 sloc) 6.28 KB
{% 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 "macros/actions.html.twig" as actions %}
{% block page_title %}{{ 'timesheet.title'|trans }}{% endblock %}
{% block page_subtitle %}{{ 'timesheet.subtitle'|trans }}{% endblock %}
{% block page_actions %}{{ actions.timesheets('index') }}{% endblock %}
{% block main_before %}
{{ toolbar.toolbar(toolbarForm, 'collapseTimesheet', showFilter) }}
{% endblock %}
{% block main %}
{% import _self as timesheet %}
{% if entries.count == 0 %}
{{ widgets.callout('warning', 'error.no_entries_found') }}
{% else %}
{% set columns = {'date': ''} %}
{% if not duration_only %}
{% set columns = columns|merge({'starttime': '', 'endtime': 'hidden-xs'}) %}
{% endif %}
{% set columns = columns|merge({'duration': ''}) %}
{% if is_granted('view_rate_own_timesheet') %}
{% set columns = columns|merge({'rate': 'hidden-xs'}) %}
{% endif %}
{% set columns = columns|merge({
'customer': 'hidden-xs hidden-sm',
'project': 'hidden-xs hidden-sm',
'activity': 'hidden-xs hidden-sm',
'description': 'hidden-xs hidden-sm',
'actions': 'alwaysVisible',
}) %}
{% set tableName = 'timesheet' %}
{{ tables.data_table_header(tableName, columns, showSummary) }}
{% set day = null %}
{% set dayDuration = 0 %}
{% set dayRate = {} %}
{% for entry in entries %}
{% set customerCurrency = entry.project.customer.currency %}
{% if day is same as(null) %}
{% set day = entry.begin|date_short %}
{% endif %}
{% if showSummary and day is not same as(entry.begin|date_short) %}
{{ timesheet.summary(day, dayDuration, dayRate, columns) }}
{% set day = entry.begin|date_short %}
{% set dayDuration = 0 %}
{% set dayRate = {} %}
{% endif %}
<tr>
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'date') }}">{{ entry.begin|date_short }}</td>
{% if not duration_only %}
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'starttime') }}">{{ entry.begin|time }}</td>
{% endif %}
{% if entry.end %}
{% if not duration_only %}
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'endtime') }}">{{ entry.end|time }}</td>
{% endif %}
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'duration') }}">{{ entry.duration|duration }}</td>
{% if is_granted('view_rate', entry) %}
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'rate') }}">{{ entry.rate|money(entry.project.customer.currency) }}</td>
{% endif %}
{% else %}
{% if not duration_only %}
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'endtime') }}">&dash;</td>
{% endif %}
<td class="text-nowrap {{ tables.data_table_column_class(tableName, columns, 'duration') }}"><i>{{ entry|duration }}</i></td>
{% if is_granted('view_rate', entry) %}
<td class="{{ tables.data_table_column_class(tableName, columns, 'rate') }}">&dash;</td>
{% endif %}
{% endif %}
<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|desc2html }}</td>
<td>
{{ actions.timesheet(entry, 'index') }}
</td>
</tr>
{% if entry.end %}
{% if dayRate[customerCurrency] is not defined %}
{% set dayRate = dayRate|merge({(customerCurrency): 0}) %}
{% endif %}
{% set dayRate = dayRate|merge({(customerCurrency): dayRate[customerCurrency] + entry.rate}) %}
{% endif %}
{% set dayDuration = dayDuration + entry.duration %}
{% endfor %}
{% if showSummary %}
{{ timesheet.summary(day, dayDuration, dayRate, columns) }}
{% endif %}
{{ tables.data_table_footer(entries, 'timesheet_paginated') }}
{% endif %}
{% endblock %}
{% block javascripts %}
{{ parent() }}
<script type="text/javascript">
function exportTimesheet() {
var form = $("div.toolbar form.navbar-form");
var prevAction = form.attr('action');
form.attr('target', '_blank').attr('action', '{{ path('timesheet_export') }}');
form.submit();
form.removeAttr('target').attr('action', prevAction);
return false;
}
</script>
{% endblock %}
{% macro summary(day, duration, dayRates, columns) %}
<tr class="summary info">
<td class="text-nowrap">{{ day }}</td>
<td></td>
<td></td>
<td class="text-nowrap">{{ duration|duration }}</td>
{% if is_granted('view_rate_own_timesheet') %}
<td class="text-nowrap">
{% for currency, rate in dayRates %}
{{ rate|money(currency) }}
{% if not loop.last %}
<br>
{% endif %}
{% endfor %}
</td>
<td colspan="{{ (columns|length) - 5 }}"></td>
{% else %}
<td colspan="{{ (columns|length) - 4 }}"></td>
{% endif %}
</tr>
{% endmacro %}
You can’t perform that action at this time.